api-merchant.rst (80159B)
1 .. 2 This file is part of GNU TALER. 3 Copyright (C) 2014-2026 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3.0, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 16 @author Marcello Stanisci 17 @author Florian Dold 18 @author Christian Grothoff 19 @author Priscilla Huang 20 @author Martin Schanzenbach 21 22 .. _merchant-api: 23 24 ============================ 25 Merchant Backend RESTful API 26 ============================ 27 28 --------------- 29 Version History 30 --------------- 31 32 The currently implemented protocol version is **v34**. 33 34 * The Android PoS app is currently targeting **v20**. 35 * The SPA is currently targeting **vXX**. 36 * taler-mdb is currently targeting **v27**. 37 * anastasis is currently targeting **v27**. 38 * taler-woocommerce is currently targeting **v29**. 39 * taler-drupal-turnstile is currently targeting **v29**. 40 * taler-drupal-commerce is currently targeting **vXX**. 41 * paivana is currently targeting **v29**. 42 43 **Version history:** 44 45 * ``v21``: Added self-provisioning and two factor authentication 46 * ``v22``: Added various defaults 47 * ``v23``: Added various defaults, fields and some new filters 48 * ``v24``: Make minor changes to refund semantics 49 * ``v25``: adds features to group amounts internally (say to 50 separate tips, taxes and revenue in reporting), endpoints 51 for periodic report generation and inventory-based templates, 52 new long-polling for KYC and features for templates to support 53 session-based payments 54 * ``v26``: adds unclaim endpoint, enhanced settlement reporting 55 * ``v27``: adds various fields to a few endpoints 56 * ``v28``: adds the ``/kycauth`` endpoint for wire transfer subject 57 shortening during KYC Auth wire transfers and expands :http:get:`/config </config>`. 58 * ``v29``: adds ``max_pickup_duration`` to templates (for Paivana) 59 * ``v30``: adds ``debit_restrictions`` to GET /exchanges (for SPA) 60 * ``v31``: adds ``/private/accept-tos-early`` and related API changes 61 * ``v32``: adds "force" argument for locked product deletion 62 * ``v33``: adds ``build_version`` to :http:get:`/config </config>` and 63 ``max_age_s`` to ``[/instances/$INSTANCE]/private/orders``, deprecating 64 the ``max_age`` query parameter of that endpoint 65 * ``v34``: adds ``editable_amount`` to the choices of a Paivana template 66 together with the ``choice_amounts`` request field to instantiate them, 67 and ``min_amount``/``max_amount`` to bound client-chosen amounts for 68 templates of any type 69 70 **Upcoming versions:** 71 72 * ``vTAXES``: adds features to manage taxes 73 * ``vChallengeConfirmation``: adds challenge-signature OTP algorithms for 74 payment confirmations verified by offline appliances and tags 75 (see :doc:`DD 97 </design-documents/097-challenge-confirmations>`) 76 * ``vTokenFountains``: adds fountains for distributing promotional 77 merchant tokens 78 (see :doc:`DD 98 </design-documents/098-token-fountains>`) 79 * ``vMixedPayments``: adds the additive ``amount_external`` field for orders 80 settled partly outside of Taler, the ``/private/orders/$ORDER_ID/collect`` 81 endpoint for completing zero-Taler orders without a wallet, the 82 ``/private/orders/$ORDER_ID/refund-external`` endpoint for recording 83 externally settled refunds, and exposes both through order status 84 (see :doc:`DD 96 </design-documents/096-partial-payments>`) 85 86 **Ideas for future version:** 87 88 * ``vXXX``: marker for features not yet targeted for release 89 90 ----------------------- 91 Base URLs and Instances 92 ----------------------- 93 94 A single merchant backend installation can host multiple merchant instances. 95 This is useful when multiple businesses want to share the same payment 96 infrastructure. 97 98 Merchant backends have one special ``admin`` instance. This ``admin`` 99 instance is used when no explicit instance is specified. Note that using 100 ``/instances/admin/$ANYTHING`` is deprecated and will result in a permanent 101 redirect (HTTP status 308) to ``$ANYTHING``. Despite its name, this instance 102 must be created after the installation. 103 104 Each instance (admin and others) has a base URL. The resources under 105 this base URL are divided into the following categories: 106 107 * Public endpoints that are exposed to the Internet 108 * Private endpoints (under ``/private/*``) that are only supposed to be exposed 109 to the merchant internally, and must not be exposed on the 110 Internet. 111 * Management endpoints (under ``/management/*``) are also private and dedicated 112 to CRUD operation over instances and reset authentication settings over all 113 instances. Only accessible with the admin instance authentication token. 114 115 Examples: 116 117 .. code-block:: none 118 119 Base URL of the merchant (admin instance) at merchant-backend.example.com: 120 https://merchant-backend.example.com/ 121 122 A private endpoint (admin instance): 123 https://merchant-backend.example.com/private/orders 124 125 A public endpoint (admin instance and order id "ABCD"): 126 https://merchant-backend.example.com/orders/ABCD 127 128 A private endpoint ("myinst" instance): 129 https://merchant-backend.example.com/instances/myinst/private/orders 130 131 A public endpoint ("myinst" instance and order id "ABCD"): 132 https://merchant-backend.example.com/instances/myinst/orders/ABCD 133 134 A private endpoint (explicit "admin" instance): 135 https://merchant-backend.example.com/private/orders 136 137 A public endpoint (explicit "admin" instance): 138 https://merchant-backend.example.com/orders 139 140 Endpoints to manage other instances (ONLY for implicit "admin" instance): 141 https://merchant-backend.example.com/management/instances 142 https://merchant-backend.example.com/management/instances/$ID 143 144 Endpoints to manage own instance: 145 https://merchant-backend.example.com/private 146 https://merchant-backend.example.com/private/auth 147 https://merchant-backend.example.com/instances/$ID/private 148 https://merchant-backend.example.com/instances/$ID/forgot-password 149 https://merchant-backend.example.com/instances/$ID/private/auth 150 151 Unavailabe endpoints (will return 404): 152 https://merchant-backend.example.com/instances/myinst/private/instances 153 154 .. _merchant-session-id: 155 156 ----------- 157 Session IDs 158 ----------- 159 160 Payments can be bound to a *session*, which is identified by a session ID. 161 Session IDs are chosen by the merchant's frontend (or by the client device, 162 as is the case for the Paivana IDs given to 163 :http:post:`[/instances/$INSTANCE]/templates/$TEMPLATE_ID`); the backend 164 merely stores them and uses them to match a payment against the session it 165 was made for. 166 167 .. ts:def:: SessionID 168 169 // Identifier of the session a payment is bound to. Like a `Slug`, 170 // a session ID must only use ASCII alphanumeric characters 171 // ("A-Z", "a-z", "0-9") and the punctuation characters "-", ".", 172 // "_", ":" and "~", and must not be "." or "..". Unlike a slug, a 173 // session ID may also contain "=" and may be empty. 174 // Session IDs are case-sensitive. 175 type SessionID = string; 176 177 A session ID is thus *not* a slug. It additionally permits ``=`` because 178 session IDs are frequently base64-encoded identifiers, which may end in 179 padding. And it may be empty: the empty session ID means that a payment is 180 not bound to any session. Clients must expect to encounter it, as the 181 backend itself puts an empty session ID into the ``taler://pay/`` URI of an 182 order that has no session (the session is the last path component of that 183 URI and thus cannot simply be omitted), and wallets send back what they were 184 given. Endpoints for which only an actual session makes sense say so 185 explicitly and reject the empty session ID. 186 187 ----------------- 188 Generic Responses 189 ----------------- 190 191 The following (error) responses are applicable to all endpoints 192 unless specified otherwise. 193 194 .. include:: merchant/any-star.rst 195 196 .. _merchant-api-authentication: 197 198 -------------- 199 Authentication 200 -------------- 201 202 Each merchant instance has separate authentication settings for the private API resources 203 of that instance. 204 205 Currently, the ``/private/auth/`` API supports two main authentication methods in the `InstanceAuthConfigurationMessage`: 206 207 * ``external``: (@deprecated since **v20**) With this method, no checks are done by the merchant backend. 208 Instead, a reverse proxy / API gateway must do all authentication/authorization checks. 209 * ``token`` (**@since v19**): With this method, the client must provide an authorization header 210 that contains a bearer token when accessing a protected endpoint in the form 211 ``Authorization: Bearer secret-token:$TOKEN``. 212 ``$TOKEN`` is an authentication token retrieved from the ``/private/token`` endpoint using basic authorization. 213 The respective username is the instance ``$ID``, and the password the instance password (``$INSTANCE_PASSWORD``). 214 A login token is commonly only valid for a limited period of time and scoped to specific permissions. 215 If the ``$INSTANCE_PASSWORD`` is lost, the administrator can set a password 216 using the ``taler-merchant-passwd`` command-line tool. 217 * ``token`` (@deprecated since **v19**): With this method, the client must provide an authentication token in 218 the format ``secret-token: $INSTANCE_PASSWORD``. 219 The behaviour is then equivalent to the ``token`` method above. 220 Any API may be accessed using the bearer authentication ``secret-token: $INSTANCE_PASSWORD``. 221 Notice that this behaviour is deprecated and will be phased out in favor of login tokens. 222 223 For testing, the service may be started with the configuration option ``DISABLED_AUTHENTICATION = YES`` 224 in section ``[merchant]`` (@since **v20**). 225 226 .. _merchant-api-scopes: 227 228 Scopes and permissions 229 ^^^^^^^^^^^^^^^^^^^^^^ 230 231 Authorization in the merchant backend is expressed with *permissions*. Every 232 endpoint that requires authorization requires exactly one permission, which is 233 stated as **Required permission** in the documentation of that endpoint. 234 Permission names have the form ``$RESOURCE-$ACTION``, where ``$ACTION`` is 235 usually ``read`` (for operations that only inspect state) or ``write`` (for 236 operations that change it). 237 238 Clients do not request individual permissions. Instead, an access token is 239 issued for a *scope*, which is a fixed, named set of permissions. A request is 240 authorized if the permission required by the endpoint is covered by the scope 241 of the access token that was used. 242 243 Permissions 244 """"""""""" 245 246 The following permissions exist: 247 248 .. list-table:: 249 :widths: 25 75 250 :header-rows: 1 251 252 * - Permission 253 - Grants access to 254 * - ``accounts-read`` 255 - Listing and inspecting the bank accounts of the instance, and starting 256 KYC authentication for one of them. 257 * - ``accounts-write`` 258 - Adding, modifying and deleting bank accounts of the instance, and 259 accepting the terms of service of an exchange ahead of time. 260 * - ``auth-write`` 261 - Changing the authentication settings of the instance itself 262 (via the instance's own ``/private/auth`` endpoint). 263 * - ``categories-read`` 264 - Listing and inspecting product categories. 265 * - ``categories-write`` 266 - Creating, modifying and deleting product categories. 267 * - ``donau-read`` 268 - Listing the linked Donau charity instances. 269 * - ``donau-write`` 270 - Adding and removing Donau charity instance links. 271 * - ``fountains-read`` 272 - Listing and inspecting token fountains. Since **vTokenFountains**. 273 * - ``fountains-write`` 274 - Creating, modifying and deleting token fountains. 275 Since **vTokenFountains**. 276 * - ``groups-read`` 277 - Listing product groups. 278 * - ``groups-write`` 279 - Creating, modifying and deleting product groups. 280 * - ``instances-auth-write`` 281 - Changing the authentication settings of *any* instance via the 282 ``/management/`` API. Only the ``admin`` instance can hold this 283 permission in a useful way. 284 * - ``instances-kyc-read`` 285 - Querying the KYC status of *any* instance via the ``/management/`` API. 286 * - ``instances-read`` 287 - Reading the configuration of the instance itself. 288 * - ``instances-write`` 289 - Creating, inspecting, modifying and deleting instances. Note that this 290 permission is required for *all* operations on the ``/management/`` 291 instance API, including the ``GET`` operations that merely list or 292 inspect instances, as well as for modifying or deleting the instance 293 itself via its own private API. 294 * - ``kyc-read`` 295 - Querying the KYC status of the instance itself. 296 * - ``orders-read`` 297 - Listing orders and checking their payment, refund and wire transfer 298 status. 299 * - ``orders-write`` 300 - Creating orders, forgetting parts of a contract, collecting zero-amount 301 orders and deleting orders. 302 * - ``orders-refund`` 303 - Granting refunds and recording externally settled refunds. 304 * - ``otp-devices-read`` 305 - Listing and inspecting one-time-password (OTP) devices. 306 * - ``otp-devices-write`` 307 - Creating, modifying and deleting OTP devices. 308 * - ``pos-read`` 309 - Downloading the full point-of-sale configuration 310 (:http:get:`[/instances/$INSTANCE]/private/pos`). 311 * - ``pots-read`` 312 - Listing and inspecting money pots. 313 * - ``pots-write`` 314 - Creating, modifying and deleting money pots. 315 * - ``products-read`` 316 - Listing and inspecting products in the inventory. 317 * - ``products-write`` 318 - Adding, modifying and deleting products in the inventory. 319 * - ``products-lock`` 320 - Locking products in the inventory 321 (:http:post:`[/instances/$INSTANCE]/private/products/$PRODUCT_ID/lock`). 322 * - ``reports-read`` 323 - Listing and inspecting reports. 324 * - ``reports-write`` 325 - Creating, modifying and deleting reports. 326 * - ``statistics-read`` 327 - Reading counter, amount and transaction statistics. 328 * - ``templates-read`` 329 - Listing and inspecting order templates. 330 * - ``templates-write`` 331 - Creating, modifying and deleting order templates. 332 * - ``tokenfamilies-read`` 333 - Listing and inspecting token families. 334 * - ``tokenfamilies-write`` 335 - Creating, modifying and deleting token families. 336 * - ``tokens-read`` 337 - Listing the access tokens that were issued for the instance. 338 * - ``tokens-write`` 339 - Revoking access tokens of the instance by serial. 340 * - ``token-refresh`` 341 - Obtaining a new access token from 342 :http:post:`[/instances/$INSTANCE]/private/token` using an existing 343 access token. This permission is special: it is *not* part of any 344 scope's permission set and is not implied by ``*``. It is granted 345 exactly if the access token used is refreshable (see below). 346 * - ``transfers-read`` 347 - Listing expected and actual wire transfers, including incoming 348 transfers. 349 * - ``transfers-write`` 350 - Informing the backend about wire transfers and deleting such records. 351 * - ``units-read`` 352 - Listing and inspecting measurement units. 353 * - ``units-write`` 354 - Creating, modifying and deleting measurement units. 355 * - ``webhooks-read`` 356 - Listing and inspecting webhooks. 357 * - ``webhooks-write`` 358 - Creating, modifying and deleting webhooks. 359 360 Endpoints of the wallet-facing (public) API, such as those used to claim, pay 361 for or abort an order, require no permission at all and are documented as 362 "**Required permission:** none". 363 364 Scopes 365 """""" 366 367 Access tokens can be requested with a (limiting) scope. The available scopes 368 and the permissions they grant are: 369 370 .. list-table:: 371 :widths: 15 45 40 372 :header-rows: 1 373 374 * - Scope 375 - Permissions 376 - Remarks 377 * - ``readonly`` 378 - ``*-read`` 379 - Every permission ending in ``-read``. Note that this does *not* include 380 the ``/management/`` instance API, which requires ``instances-write`` 381 even for ``GET`` requests. 382 * - ``all`` 383 - ``*`` 384 - Every permission. Tokens with this scope are always refreshable. 385 @since **v19** 386 * - ``write`` 387 - ``*`` 388 - @deprecated since **v19**, identical to ``all``. 389 * - ``spa`` 390 - ``*`` 391 - Every permission; used by the merchant backoffice SPA. Unlike ``all``, 392 this scope is not implicitly refreshable. @since **v20** 393 * - ``order-simple`` 394 - ``orders-read``, ``orders-write`` 395 - Allows the creation of orders and checking of payment status. 396 @since **v19** 397 * - ``order-pos`` 398 - ``orders-read``, ``orders-write``, ``pos-read``, ``products-lock`` 399 - Same as ``order-simple``, plus reading the point-of-sale configuration 400 and inventory locking. @since **v19** 401 * - ``order-mgmt`` 402 - ``orders-read``, ``orders-write``, ``pos-read``, ``orders-refund`` 403 - Same as ``order-simple``, plus reading the point-of-sale configuration 404 and granting refunds. @since **v19** 405 * - ``order-full`` 406 - ``orders-read``, ``orders-write``, ``pos-read``, ``products-lock``, 407 ``orders-refund`` 408 - ``order-pos`` and ``order-mgmt`` combined. @since **v19** 409 410 .. note:: 411 412 The ``products-lock`` permission granted by ``order-pos`` and ``order-full`` 413 is only required for explicitly locking products via 414 :http:post:`[/instances/$INSTANCE]/private/products/$PRODUCT_ID/lock`. 415 Creating an order (which locks inventory as a side effect) requires only 416 ``orders-write``. 417 418 .. ts:def:: TokenScope 419 420 // Scope of an access token. Since **v19**, the scope may be 421 // suffixed with ":refreshable" (see below), for example 422 // "order-pos:refreshable". "write" is deprecated since **v19** 423 // and is equivalent to "all". 424 type TokenScope = "readonly" | "all" | "spa" | "order-simple" | "order-pos" | "order-mgmt" | "order-full" | "write"; 425 426 Matching rules 427 """""""""""""" 428 429 Given the permission ``$P`` required by an endpoint and the permission set of 430 the scope of the access token used, access is granted if any of the following 431 holds: 432 433 * the scope contains ``*``; 434 * the scope contains ``*-read`` and ``$P`` ends in ``-read``; 435 * the scope contains ``*-write`` and ``$P`` ends in ``-write``; 436 * the scope contains ``$P`` literally. 437 438 The permission ``token-refresh`` is handled separately and is granted if and 439 only if the access token is refreshable, regardless of the scope's permission 440 set. 441 442 Refreshable tokens 443 """""""""""""""""" 444 445 Since **v19** the scope may be suffixed with ``:refreshable``, e.g. 446 ``order-pos:refreshable``. 447 This allows the token to be refreshed at the token endpoint. 448 This behaviour replaces the deprecated ``refreshable`` field in the `LoginTokenRequest`. 449 Tokens with the ``all`` (or the deprecated ``write``) scope are always 450 refreshable. 451 452 When requesting a token from 453 :http:post:`[/instances/$INSTANCE]/private/token` with an existing access 454 token, the requested scope must be a subset of the scope of the token used, 455 and a non-refreshable token can never be used to obtain a refreshable one. 456 457 ----------------- 458 Configuration API 459 ----------------- 460 461 The configuration API exposes basic information about a merchant backend, 462 such as the implemented version of the protocol and the currency used. 463 464 .. include:: merchant/get-config.rst 465 466 .. include:: tos.rst 467 468 ------------------- 469 Exchange Status API 470 ------------------- 471 472 The exchange status API exposes basic information about the exchanges 473 configured for a merchant backend, in particular the acceptable 474 currencies, master public keys and the status of the merchant backend's 475 download of the :http:get:`/keys </keys>` from the exchange. This is mostly useful 476 to diagnose configuration problems. 477 478 .. include:: merchant/get-exchanges.rst 479 480 --------------- 481 Two Factor Auth 482 --------------- 483 484 202 Challenge Responses 485 ^^^^^^^^^^^^^^^^^^^^^^^ 486 487 Various APIs generate ``202 Accepted`` HTTP status codes when multi-factor 488 authentication (MFA) is required. In this case, the response will be a 489 `ChallengeResponse`. In these cases, the client must first request and solve 490 one or more challenges before repeating the request. When repeating the 491 request, they must include a list of comma-separated challenge IDs of the 492 solved challenges in a ``Taler-Challenge-Ids`` HTTP header. The body must 493 remain absolutely unchanged. 494 495 .. note:: 496 497 If all allowed attempts to solve the MFA challenge(s) fail, the endpoint 498 may start to return ``403 Forbidden`` until the issued challenges expire, 499 preventing the request from being completed for a while. In this case, 500 repeating the request with a different body may still be allowed! 501 502 .. ts:def:: ChallengeResponse 503 504 // @since v21 505 interface ChallengeResponse { 506 // List of challenge IDs that must be solved before the 507 // client may proceed. 508 challenges: Challenge[]; 509 510 // True if **all** challenges must be solved (AND), false if 511 // it is sufficient to solve one of them (OR). 512 combi_and: boolean; 513 514 } 515 516 .. ts:def:: Challenge 517 518 interface Challenge { 519 // Unique identifier of the challenge to solve to run this protected 520 // operation. 521 challenge_id: Slug; 522 523 // Channel of the last successful transmission of the TAN challenge. 524 tan_channel: TanChannel; 525 526 // Info of the last successful transmission of the TAN challenge. 527 // Hint to show to the user as to where the challenge was 528 // sent or what to use to solve the challenge. May not 529 // contain the full address for privacy. 530 tan_info: string; 531 532 } 533 534 Requesting challenges 535 ^^^^^^^^^^^^^^^^^^^^^ 536 537 .. include:: merchant/post-challenge-CHALLENGE_ID.rst 538 539 Solving challenges 540 ^^^^^^^^^^^^^^^^^^ 541 542 .. include:: merchant/post-challenge-CHALLENGE_ID-confirm.rst 543 544 ---------- 545 Wallet API 546 ---------- 547 548 This section describes (public) endpoints that wallets must be able 549 to interact with directly (without HTTP-based authentication). These 550 endpoints are used to process payments (claiming an order, paying 551 for the order, checking payment/refund status and aborting payments), 552 and to process refunds (checking refund status, obtaining the refund). 553 554 555 Claiming an order 556 ^^^^^^^^^^^^^^^^^ 557 558 The first step of processing any Taler payment consists of the 559 (authorized) wallet claiming the order for itself. In this process, 560 the wallet provides a wallet-generated nonce that is added 561 into the contract terms. This step prevents two different 562 wallets from paying for the same contract, which would be bad 563 especially if the merchant only has finite stocks. 564 565 A claim token can be used to ensure that the wallet claiming an 566 order is actually authorized to do so. This is useful in cases 567 where order IDs are predictable and malicious actors may try to 568 claim orders (say in a case where stocks are limited). 569 570 571 .. include:: merchant/post-orders-ORDER_ID-claim.rst 572 573 .. include:: merchant/post-orders-ORDER_ID-unclaim.rst 574 575 576 Making the payment 577 ^^^^^^^^^^^^^^^^^^ 578 579 .. include:: merchant/post-orders-ORDER_ID-pay.rst 580 581 582 Querying payment status 583 ^^^^^^^^^^^^^^^^^^^^^^^ 584 585 .. include:: merchant/get-orders-ORDER_ID.rst 586 587 .. include:: merchant/get-sessions-SESSION_ID.rst 588 589 590 Demonstrating payment 591 ^^^^^^^^^^^^^^^^^^^^^ 592 593 In case a wallet has already paid for an order, this is a fast way of proving 594 to the merchant that the order was already paid. The alternative would be to 595 replay the original payment, but simply providing the merchant's signature 596 saves bandwidth and computation time. 597 598 Demonstrating payment is useful in case a digital good was made available 599 only to clients with a particular session ID: if that session ID expired or 600 if the user is using a different client, demonstrating payment will allow 601 the user to regain access to the digital good without having to pay for it 602 again. 603 604 .. include:: merchant/post-orders-ORDER_ID-paid.rst 605 606 607 Aborting incomplete payments 608 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 609 610 In rare cases (such as a wallet restoring from an outdated backup) it is possible 611 that a wallet fails to complete a payment because it runs out of e-cash in the 612 middle of the process. The abort API allows the wallet to abort the payment for 613 such an incomplete payment and to regain control over the coins that were spent 614 so far. Aborts are not permitted for payments that have completed. In contrast to 615 refunds, aborts do not require approval by the merchant because aborts always 616 are for incomplete payments for an order and never for established contracts. 617 618 619 .. _order-abort: 620 .. include:: merchant/post-orders-ORDER_ID-abort.rst 621 622 623 Obtaining refunds 624 ^^^^^^^^^^^^^^^^^ 625 626 Refunds allow merchants to fully or partially restitute e-cash to a wallet, 627 for example because the merchant determined that it could not actually fulfill 628 the contract. Refunds must be approved by the merchant's business logic. 629 630 .. include:: merchant/post-orders-ORDER_ID-refund.rst 631 632 633 ------------------- 634 Instance management 635 ------------------- 636 637 Instances allow one merchant backend to be shared by multiple merchants. 638 Every backend must have at least one instance, typically the "admin" 639 instance setup before it can be used to manage inventory or process payments. 640 641 642 Setting up instances 643 ^^^^^^^^^^^^^^^^^^^^ 644 645 .. include:: merchant/post-instances.rst 646 647 .. include:: merchant/post-instances-INSTANCE-forgot-password.rst 648 649 .. include:: merchant/post-management-instances.rst 650 651 .. include:: merchant/post-management-instances-INSTANCE-auth.rst 652 653 Access control tokens 654 ^^^^^^^^^^^^^^^^^^^^^ 655 656 .. include:: merchant/post-private-token.rst 657 658 .. include:: merchant/get-private-tokens.rst 659 660 .. include:: merchant/delete-private-tokens-SERIAL.rst 661 662 .. include:: merchant/delete-private-token.rst 663 664 .. include:: merchant/patch-management-instances-INSTANCE.rst 665 666 667 Inspecting instances 668 ^^^^^^^^^^^^^^^^^^^^ 669 670 .. _instances: 671 .. include:: merchant/get-management-instances.rst 672 673 .. include:: merchant/get-management-instances-INSTANCE.rst 674 675 676 Getting statistics 677 ^^^^^^^^^^^^^^^^^^ 678 679 .. include:: merchant/get-private-statistics-amount-SLUG.rst 680 681 .. include:: merchant/get-private-statistics-counter-SLUG.rst 682 683 .. include:: merchant/get-private-statistics-report-NAME.rst 684 685 686 Deleting instances 687 ^^^^^^^^^^^^^^^^^^ 688 689 .. include:: merchant/delete-management-instances-INSTANCE.rst 690 691 692 KYC status checks 693 ^^^^^^^^^^^^^^^^^ 694 695 .. _merchantkycstatus: 696 697 .. include:: merchant/get-private-kyc.rst 698 699 .. include:: merchant/post-private-accept-tos-early.rst 700 701 702 ------------- 703 Bank Accounts 704 ------------- 705 706 One or more bank accounts must be associated with an instance 707 so that the instance can receive payments. Payments may be made 708 into any of the active bank accounts of an instance. 709 710 .. include:: merchant/post-private-accounts.rst 711 712 .. include:: merchant/patch-private-accounts-H_WIRE.rst 713 714 .. include:: merchant/get-private-accounts.rst 715 716 .. include:: merchant/get-private-accounts-H_WIRE.rst 717 718 .. include:: merchant/delete-private-accounts-H_WIRE.rst 719 720 .. include:: merchant/post-private-accounts-H_WIRE-kycauth.rst 721 722 723 -------------------- 724 Inventory management 725 -------------------- 726 727 .. _inventory: 728 729 Inventory management is an *optional* backend feature that can be used to 730 manage limited stocks of products and to auto-complete product descriptions in 731 contracts (such that the frontends have to do less work). You can use the 732 Taler merchant backend to process payments *without* using its inventory 733 management. 734 735 .. _decimal-quantity: 736 737 Decimal quantities 738 ^^^^^^^^^^^^^^^^^^ 739 740 .. ts:def:: DecimalQuantity 741 742 // Fixed-point decimal string in the form "<integer>[.<fraction>]". 743 // Fractional part has up to six digits. 744 // "-1" is only valid for fields that explicitly allow "infinity". 745 // Since protocol **v25**; used in template selection since **v25**. 746 type DecimalQuantity = string; 747 748 749 Managing measurement units 750 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 751 752 .. include:: merchant/get-private-units.rst 753 754 .. include:: merchant/get-private-units-UNIT.rst 755 756 .. include:: merchant/post-private-units.rst 757 758 .. include:: merchant/patch-private-units-UNIT.rst 759 760 .. include:: merchant/delete-private-units-UNIT.rst 761 762 763 Managing product categories 764 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 765 766 .. include:: merchant/get-private-categories.rst 767 768 .. include:: merchant/get-private-categories-CATEGORY_ID.rst 769 770 .. include:: merchant/post-private-categories.rst 771 772 .. include:: merchant/patch-private-categories-CATEGORY_ID.rst 773 774 .. include:: merchant/delete-private-categories-CATEGORY_ID.rst 775 776 777 Managing products in the inventory 778 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 779 780 .. include:: merchant/post-private-products.rst 781 782 .. include:: merchant/patch-private-products-PRODUCT_ID.rst 783 784 .. include:: merchant/get-private-products.rst 785 786 .. include:: merchant/get-private-products-PRODUCT_ID.rst 787 788 .. include:: merchant/delete-private-products-PRODUCT_ID.rst 789 790 791 792 Providing configuration data for point-of-sale terminals 793 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 794 795 .. include:: merchant/get-private-pos.rst 796 797 798 Fetching product images 799 ^^^^^^^^^^^^^^^^^^^^^^^ 800 801 .. include:: merchant/get-products-IMAGE_HASH-image.rst 802 803 804 805 Reserving inventory 806 ^^^^^^^^^^^^^^^^^^^ 807 808 .. include:: merchant/post-private-products-PRODUCT_ID-lock.rst 809 810 811 ------------------ 812 Payment processing 813 ------------------ 814 815 To process Taler payments, a merchant must first set up an order with 816 the merchant backend. The order is then claimed by a wallet, and 817 paid by the wallet. The merchant can check the payment status of the 818 order. Once the order is paid, the merchant may (for a limited time) 819 grant refunds on the order. 820 821 Creating orders 822 ^^^^^^^^^^^^^^^ 823 824 .. _post-order: 825 826 .. include:: merchant/post-private-orders.rst 827 828 Inspecting orders 829 ^^^^^^^^^^^^^^^^^ 830 831 .. include:: merchant/get-private-orders.rst 832 833 .. include:: merchant/get-private-orders-ORDER_ID.rst 834 835 836 .. _collect-order: 837 838 Collecting zero-Taler orders 839 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 840 841 Orders whose Taler ``amount`` is zero, for example because the full total 842 was settled through ``amount_external``, can be completed by the merchant 843 backend itself instead of a customer wallet. 844 845 .. include:: merchant/post-private-orders-ORDER_ID-collect.rst 846 847 848 .. _private-order-data-cleanup: 849 850 Private order data cleanup 851 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 852 853 Some orders may contain sensitive information that the merchant may not want 854 to retain after fulfillment, such as the customer's shipping address. By 855 initially labeling these order components as forgettable, the merchant can 856 later tell the backend to forget those details (without changing the hash of 857 the contract!) to minimize risks from information leakage. 858 859 .. include:: merchant/patch-private-orders-ORDER_ID-forget.rst 860 861 .. include:: merchant/delete-private-orders-ORDER_ID.rst 862 863 864 .. _merchant_refund: 865 866 ----------------- 867 Approving Refunds 868 ----------------- 869 870 .. include:: merchant/post-private-orders-ORDER_ID-refund.rst 871 872 .. include:: merchant/post-private-orders-ORDER_ID-refund-external.rst 873 874 875 ----------------------- 876 Tracking Wire Transfers 877 ----------------------- 878 879 This API is used by merchants that want to track the payments from the 880 exchange to be sure that they have been paid on time. By telling the merchant 881 backend about all incoming wire transfers, the backend can detect if an 882 exchange failed to perform a wire transfer that was due. 883 884 885 Informing the backend about incoming wire transfers 886 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 887 888 .. include:: merchant/post-private-transfers.rst 889 890 891 Querying known wire transfers 892 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 893 894 .. include:: merchant/get-private-transfers.rst 895 896 897 898 Querying expected wire transfers 899 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 900 901 .. include:: merchant/get-private-incoming.rst 902 903 904 .. include:: merchant/get-private-incoming-ID.rst 905 906 907 Deleting confirmed wire transfer 908 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 909 910 Deleting a wire transfer can be useful in case of a data entry 911 mistake. In particular, if the exchange base URL was entered 912 badly, deleting the old entry and adding a correct one is a 913 good idea. Note that deleting wire transfers is not possible 914 if they were expected. 915 916 .. include:: merchant/delete-private-transfers-TID.rst 917 918 919 .. _merchant-otp-device-api: 920 921 ----------- 922 OTP Devices 923 ----------- 924 925 OTP devices can be used to allow offline merchants 926 to validate that a customer made a payment. 927 928 929 .. include:: merchant/post-private-otp-devices.rst 930 931 932 .. include:: merchant/patch-private-otp-devices-DEVICE_ID.rst 933 934 935 .. include:: merchant/get-private-otp-devices.rst 936 937 .. include:: merchant/get-private-otp-devices-DEVICE_ID.rst 938 939 .. include:: merchant/delete-private-otp-devices-DEVICE_ID.rst 940 941 942 .. _merchant-template-api: 943 944 --------- 945 Templates 946 --------- 947 948 The template is a backend feature that is used to allow wallets to create an 949 order. This is useful in cases where a store does not have Internet 950 connectivity or where a Web site wants to enable payments on a purely static 951 Web page (for example to collect donations). In these cases, the GNU Taler 952 wallet can be used to setup an order (and then of course pay for it). 953 954 Templates can describe a fixed contract (``fixed-order``), an inventory-backed 955 cart where the wallet picks products and quantities (``inventory-cart``), or a 956 session-based template (``paivana``). The template type controls which fields 957 appear in the contract and which inputs are required during instantiation. 958 959 The template itself primarily provides order details that cannot be changed 960 by the customer when the wallet creates the order. The idea is that the user 961 *may* be prompted to enter certain information, such as the amount to be paid, 962 or the order summary (as a reminder to themselves or a message to the store), 963 while the template provides all of the other contract details. 964 965 The typical user-experience with templates is that the user first scans a QR 966 code or clicks on a taler://-URI which contains a ``pay-template`` (see `LSD 967 0006 <https://lsd.gnunet.org/lsd0006/>`__). The URI specifies which values the 968 user should supply, currently either nothing, the amount, the order summary or 969 both. The URI may also specify defaults or partial defaults for those 970 values. After the user has supplied those values, the wallet will use the 971 public template API to create the order, then fetch the order details, and 972 proceed as if it had been given the respective ``pay`` URI in the first place: 973 show the full contract details and allow the user to make a payment. If the 974 user chooses to abort the payment, the wallet should give the user the 975 opportunity to edit the values and create another order with different values. 976 If the template does not include any values that the user is allowed to edit 977 (so it is basically a fixed contract), the wallet should directly create the 978 order and immediately proceed to the contract acceptance dialog. 979 980 The business process for the templating API is also pretty simple. First, the 981 private API is used to setup (or edit) the template, providing all of the 982 contract terms that subsequently cannot be changed by the customer/wallet. 983 This template data is then stored under the template ID which can be freely 984 chosen and must be in URL-encoded format. The SPA should also make it easy 985 for the merchant to convert the template ID into a taler://-URI and/or QR code. 986 Here, the merchant must additionally specify the defaults (if any) for the 987 customer-editable values. Afterwards, the merchant can print out the QR code 988 for display at the store, add a link to the taler://-URI and/or embed the 989 respective QR-code image into their Web page. 990 991 To receive a payment confirmation, the mechant may choose to configure a 992 webhook in the merchant backend on the ``pay`` action, for example to send an 993 SMS to their mobile phone. For points-of-sale without a mobile phone or 994 Internet connectivity, the OTP mechanism can also be used to confirm payments. 995 996 997 Adding templates 998 ^^^^^^^^^^^^^^^^ 999 1000 .. include:: merchant/post-private-templates.rst 1001 1002 1003 Editing templates 1004 ^^^^^^^^^^^^^^^^^ 1005 1006 .. include:: merchant/patch-private-templates-TEMPLATE_ID.rst 1007 1008 1009 Inspecting template 1010 ^^^^^^^^^^^^^^^^^^^ 1011 1012 .. include:: merchant/get-private-templates.rst 1013 1014 .. include:: merchant/get-private-templates-TEMPLATE_ID.rst 1015 1016 1017 Removing template 1018 ^^^^^^^^^^^^^^^^^ 1019 1020 .. include:: merchant/delete-private-templates-TEMPLATE_ID.rst 1021 1022 1023 Using template 1024 ^^^^^^^^^^^^^^ 1025 1026 .. include:: merchant/get-templates-TEMPLATE_ID.rst 1027 1028 .. include:: merchant/post-templates-TEMPLATE_ID.rst 1029 1030 .. _merchant-webhooks: 1031 1032 -------- 1033 Webhooks 1034 -------- 1035 1036 The webhook is a backend feature that is used to trigger an HTTP request 1037 to some business logic of the merchant in real-time whenever a specified 1038 type of event happens. Depending on the type of the event, webhooks 1039 may include additional meta-data, such as the amount or contract paid 1040 by the customer. For details on setup and supported event payloads, see the 1041 `Merchant manual – Setting up a webhook <https://docs.taler.net/taler-merchant-manual.html#setting-up-a-webhook>`_. 1042 1043 Each webhook is bound to an ``event_type``. The backend currently recognizes the following types, which are mirrored in the `WebhookEventType` enum so API clients can 1044 validate their payloads without guesswork: 1045 1046 .. ts:def:: WebhookEventType 1047 1048 enum WebhookEventType { 1049 ORDER_CREATED = "order_created", 1050 PAY = "pay", 1051 REFUND = "refund", 1052 ORDER_SETTLED = "order_settled", 1053 CATEGORY_ADDED = "category_added", 1054 CATEGORY_UPDATED = "category_updated", 1055 CATEGORY_DELETED = "category_deleted", 1056 INVENTORY_ADDED = "inventory_added", 1057 INVENTORY_UPDATED = "inventory_updated", 1058 INVENTORY_DELETED = "inventory_deleted" 1059 } 1060 1061 - ``order_created``: fired whenever a new order is created and exposes the ``order_id``, contract, and owning ``instance_id``. 1062 - ``pay``: emitted after a payment succeeds; the payload contains the paid contract terms and ``order_id``. 1063 - ``refund``: triggered when a refund is approved and includes timestamp, refunded amount, and reason. 1064 - ``order_settled``: sent when reconciliation links a wire transfer to an order (includes ``order_id`` and ``wtid``). 1065 - ``category_added`` / ``category_updated`` / ``category_deleted``: cover lifecycle changes to product categories. 1066 - ``inventory_added`` / ``inventory_updated`` / ``inventory_deleted``: cover lifecycle changes to inventory items, including descriptive fields and stock state. 1067 1068 For the full payloads associated with each event consult the merchant manual section linked above. 1069 1070 1071 Adding webhooks 1072 ^^^^^^^^^^^^^^^ 1073 1074 .. include:: merchant/post-private-webhooks.rst 1075 1076 1077 Editing webhooks 1078 ^^^^^^^^^^^^^^^^ 1079 1080 .. include:: merchant/patch-private-webhooks-WEBHOOK_ID.rst 1081 1082 1083 Inspecting webhook 1084 ^^^^^^^^^^^^^^^^^^ 1085 1086 .. include:: merchant/get-private-webhooks.rst 1087 1088 .. include:: merchant/get-private-webhooks-WEBHOOK_ID.rst 1089 1090 1091 Removing webhook 1092 ^^^^^^^^^^^^^^^^ 1093 1094 .. include:: merchant/delete-private-webhooks-WEBHOOK_ID.rst 1095 1096 1097 ------- 1098 Reports 1099 ------- 1100 1101 Reports are a backend feature that is used to send periodic 1102 reports to the merchant. Reports are sent using notification 1103 helper programs which must be configured for each merchant backend. 1104 1105 Since protocol **v25**. 1106 1107 Generating reports 1108 ^^^^^^^^^^^^^^^^^^ 1109 1110 .. include:: merchant/post-reports-REPORT_ID.rst 1111 1112 1113 Scheduling periodic reports 1114 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1115 1116 .. include:: merchant/post-private-reports.rst 1117 1118 1119 Editing scheduled reports 1120 ^^^^^^^^^^^^^^^^^^^^^^^^^ 1121 1122 .. include:: merchant/patch-private-reports-REPORT_ID.rst 1123 1124 1125 Inspecting reporting schedules 1126 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1127 1128 .. include:: merchant/get-private-reports.rst 1129 1130 .. include:: merchant/get-private-reports-REPORT_ID.rst 1131 1132 1133 Removing scheduled reports 1134 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 1135 1136 .. include:: merchant/delete-private-reports-REPORT_ID.rst 1137 1138 1139 -------------- 1140 Product groups 1141 -------------- 1142 1143 Product groups are used to manage taxes. Each product is in 1144 exactly one group and that group is typically used to determine 1145 the applicable tax rules. Products that are not assigned explicitly 1146 to a group are considered to be in the *default* product group. 1147 1148 Product groups are different from categories as a product can be 1149 in multiple categories. Furthermore, categories are used to make 1150 it easier to find products in user interfaces, while product 1151 groups are used to make it easier to manage taxes. 1152 1153 Since protocol **v25**. 1154 1155 Adding groups 1156 ^^^^^^^^^^^^^ 1157 1158 .. include:: merchant/post-private-groups.rst 1159 1160 1161 Editing groups 1162 ^^^^^^^^^^^^^^ 1163 1164 .. include:: merchant/patch-private-groups-GROUP_ID.rst 1165 1166 1167 Inspecting groups 1168 ^^^^^^^^^^^^^^^^^ 1169 1170 .. include:: merchant/get-private-groups.rst 1171 1172 1173 Removing groups 1174 ^^^^^^^^^^^^^^^ 1175 1176 .. include:: merchant/delete-private-groups-GROUP_ID.rst 1177 1178 1179 ---- 1180 Pots 1181 ---- 1182 1183 Pots are a backend feature that is used for accounting. Transacted 1184 amounts can be assigned into pots, for example to separate out 1185 tips and taxes from revenue for reporting. 1186 1187 Since protocol **v25**. 1188 1189 Adding pots 1190 ^^^^^^^^^^^ 1191 1192 .. include:: merchant/post-private-pots.rst 1193 1194 1195 Editing pots 1196 ^^^^^^^^^^^^ 1197 1198 .. include:: merchant/patch-private-pots-POT_ID.rst 1199 1200 1201 Inspecting pots 1202 ^^^^^^^^^^^^^^^ 1203 1204 .. include:: merchant/get-private-pots.rst 1205 1206 .. include:: merchant/get-private-pots-POT_ID.rst 1207 1208 1209 Removing pots 1210 ^^^^^^^^^^^^^ 1211 1212 .. include:: merchant/delete-private-pots-POT_ID.rst 1213 1214 1215 ---------------------------------------- 1216 Token Families: Subscriptions, Discounts 1217 ---------------------------------------- 1218 1219 This API provides functionalities for the issuance, management, and revocation 1220 of token families. Tokens facilitate the implementation of subscriptions and 1221 discounts, engaging solely the merchant and the user. Each token family 1222 encapsulates details pertaining to its respective tokens, guiding the merchant's 1223 backend on the appropriate processing and handling. 1224 1225 1226 Creating token families 1227 ^^^^^^^^^^^^^^^^^^^^^^^ 1228 1229 .. include:: merchant/post-private-tokenfamilies.rst 1230 1231 1232 Updating token families 1233 ^^^^^^^^^^^^^^^^^^^^^^^ 1234 1235 .. include:: merchant/patch-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst 1236 1237 1238 1239 Inspecting token families 1240 ^^^^^^^^^^^^^^^^^^^^^^^^^ 1241 1242 .. include:: merchant/get-private-tokenfamilies.rst 1243 1244 .. include:: merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst 1245 1246 1247 1248 Deleting token families 1249 ^^^^^^^^^^^^^^^^^^^^^^^ 1250 1251 .. include:: merchant/delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst 1252 1253 1254 .. _merchant-fountain-api: 1255 1256 ----------------------------------------- 1257 Fountains: Promotional Token Distribution 1258 ----------------------------------------- 1259 1260 A fountain is a bearer credential that entitles a wallet to withdraw 1261 blind-signed promotional tokens for a set of token families without 1262 creating an order per withdrawal. An institution can distribute a fountain 1263 to one recipient or share it for a campaign 1264 (see :doc:`DD 98 </design-documents/098-token-fountains>`). 1265 1266 Wallets receive the credential as a 1267 ``taler://fountain/$MERCHANT_HOST[/$INSTANCE_PATH]/$FOUNTAIN_ID/$FOUNTAIN_SECRET`` 1268 URI. All fountain endpoints are available since protocol 1269 **vTokenFountains**. 1270 1271 Managing fountains 1272 ^^^^^^^^^^^^^^^^^^ 1273 1274 .. include:: merchant/post-private-fountains.rst 1275 1276 .. include:: merchant/patch-private-fountains-FOUNTAIN_ID.rst 1277 1278 .. include:: merchant/get-private-fountains.rst 1279 1280 .. include:: merchant/get-private-fountains-FOUNTAIN_ID.rst 1281 1282 .. include:: merchant/delete-private-fountains-FOUNTAIN_ID.rst 1283 1284 1285 Wallet fountain API 1286 ^^^^^^^^^^^^^^^^^^^ 1287 1288 .. include:: merchant/get-fountain-info.rst 1289 1290 .. include:: merchant/post-fountain-withdraw.rst 1291 1292 1293 ----------------------- 1294 Donau Charity Instances 1295 ----------------------- 1296 1297 A merchant instance can link one or more **Donau charity instances**. 1298 Each link associates the instance’s own public key with a charity registered 1299 at some Donau service. These links are managed under the private API. 1300 1301 Permissions 1302 ^^^^^^^^^^^ 1303 1304 * ``donau-read`` — list linked charities. 1305 * ``donau-write`` — add or remove charity links. 1306 1307 See :ref:`Scopes <merchant-api-scopes>` for how permissions relate to the 1308 scope of an access token. 1309 1310 Listing charity instances 1311 ^^^^^^^^^^^^^^^^^^^^^^^^^ 1312 1313 .. include:: merchant/get-private-donau.rst 1314 1315 Adding a charity instance 1316 ^^^^^^^^^^^^^^^^^^^^^^^^^ 1317 1318 .. include:: merchant/post-private-donau.rst 1319 1320 Deleting a charity instance 1321 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1322 1323 .. include:: merchant/delete-private-donau-DONAU_SERIAL.rst 1324 1325 1326 ------------------ 1327 The Contract Terms 1328 ------------------ 1329 1330 This section describes the overall structure of templates, orders and contract 1331 terms that are the foundation for Taler payments. 1332 1333 .. _template-contract-details: 1334 1335 Templates 1336 ^^^^^^^^^ 1337 1338 The template contract is like the most raw form where many choices are still 1339 open or deferred. 1340 1341 1342 .. ts:def:: TemplateContractDetails 1343 1344 type TemplateContractDetails = (TemplateContractFixedOrder | TemplateContractInventoryCart | TemplateContractPaivana) & TemplateContractCommon; 1345 1346 .. ts:def:: TemplateContractCommon 1347 1348 interface TemplateContractCommon { 1349 // Template type to apply. Defaults to "fixed-order" if omitted. 1350 // Prescribes which interface has to be followed 1351 // Since protocol **v25**. 1352 template_type?: TemplateType; 1353 1354 // Human-readable summary for the template. 1355 summary?: string; 1356 1357 // Required currency for payments to the template. 1358 // This parameter is optional and should not be present 1359 // if "amount" is given. 1360 currency?: string; 1361 1362 // Lower bound (inclusive) on amounts the client gets to choose 1363 // when instantiating this template. Excludes any tip. Only 1364 // amounts the client had an influence on are checked against 1365 // this bound: the amount given in the request for a "fixed-order" 1366 // template, the total of the selected products for an 1367 // "inventory-cart" template, and the amount of an editable choice 1368 // for a "paivana" template. Requires "currency" to be given and 1369 // to match, must be in the same currency as "max_amount", and 1370 // must not exceed it. 1371 // Since protocol **v34**. 1372 min_amount?: Amount; 1373 1374 // Upper bound (inclusive) on amounts the client gets to choose 1375 // when instantiating this template. Excludes any tip. Checked 1376 // against the same amounts as "min_amount". Requires "currency" 1377 // to be given and to match. 1378 // Since protocol **v34**. 1379 max_amount?: Amount; 1380 1381 // The time the customer need to pay before his order will be deleted. 1382 // It is deleted if the customer did not pay and if the duration is over. 1383 pay_duration?: RelativeTime; 1384 1385 // How long will customers have to access / read / pick-up 1386 // the resource they are buying? Will turn into 1387 // max_pickup_time in the contract. Optional, if not given 1388 // the duration is forever. 1389 // Since protocol **v29**. 1390 max_pickup_duration?: RelativeTime; 1391 1392 // Minimum age buyer must have (in years). Default is 0. 1393 minimum_age?: Integer; 1394 1395 // Inventory-cart: request a tip during instantiation. 1396 // Since protocol **v25**. 1397 request_tip?: boolean; 1398 } 1399 1400 .. ts:def:: TemplateType 1401 1402 enum TemplateType { 1403 FIXED_ORDER = "fixed-order", 1404 INVENTORY_CART = "inventory-cart", 1405 PAIVANA = "paivana" 1406 } 1407 1408 .. ts:def:: TemplateContractFixedOrder 1409 1410 interface TemplateContractFixedOrder { 1411 1412 // The price is imposed by the merchant and cannot be changed by the customer. 1413 // This parameter is optional. 1414 amount?: Amount; 1415 1416 } 1417 1418 .. ts:def:: TemplateContractInventoryCart 1419 1420 interface TemplateContractInventoryCart { 1421 1422 // Inventory-cart: allow any inventory item to be selected. 1423 // Since protocol **v25**. 1424 selected_all?: boolean; 1425 1426 // Inventory-cart: only products in these categories are selectable. 1427 // Since protocol **v25**. 1428 selected_categories?: Integer[]; 1429 1430 // Inventory-cart: only these products are selectable. 1431 // Since protocol **v25**. 1432 selected_products?: string[]; 1433 1434 // Inventory-cart: require exactly one selection entry. 1435 // Since protocol **v25**. 1436 choose_one?: boolean; 1437 1438 // Inventory-cart: backend-provided payload with selectable data. 1439 // Only present in ``GET /templates/$TEMPLATE_ID`` responses. 1440 // Since protocol **v25**. 1441 inventory_payload?: InventoryPayload; 1442 } 1443 1444 .. ts:def:: TemplateContractPaivana 1445 1446 interface TemplateContractPaivana { 1447 1448 // POSIX extended regular expression over URLs for which 1449 // this template is valid. Matched against the absolute 1450 // URL, and anchored: it must match that URL in its 1451 // entirety, not merely occur within it. 1452 // Optional, if not given all URLs are accepted. 1453 // Since protocol **v25**. 1454 website_regex?: string; 1455 1456 // Methods to pay for the contract. 1457 choices: TemplateOrderChoice[]; 1458 } 1459 1460 The backend only stores ``website_regex``; it is the paywall proxy 1461 reading these templates that evaluates it. ``paivana-httpd`` matches 1462 it against the **absolute** URL of the request (``BASE_URL`` or the 1463 scheme and ``Host`` of the request, followed by the path) and anchors 1464 it, so an expression written against the path alone, or meant as a 1465 substring rule, will not apply. See :ref:`Paivana-Templates` in the 1466 :doc:`Paivana operator manual <../taler-paivana-manual>` for the 1467 matching rules and worked examples. 1468 1469 If exactly one of the ``choices`` of a Paivana template has 1470 ``editable_amount`` set, the template may also carry an ``amount`` in its 1471 ``editable_defaults`` to tell the user interface to offer a single amount 1472 field with that default; the client then submits it as the ``amount`` of 1473 the `UsingTemplateCommonRequest`. With more than one editable choice, the 1474 defaults are the ``amount`` values of the choices themselves and the client 1475 must use ``choice_amounts``. 1476 1477 .. _template-choice: 1478 1479 Template Choices 1480 ^^^^^^^^^^^^^^^^ 1481 1482 The `OrderChoice` object describes a possible choice within an order. The 1483 choice is done by the wallet and consists of in- and outputs. In the example 1484 of buying an article, the merchant could present the customer with the 1485 choice to use a valid subscription token or pay using a gift 1486 voucher. Available since protocol **v21**. 1487 1488 .. ts:def:: OrderChoice 1489 1490 interface OrderChoice { 1491 // Total price for the choice. The exchange will subtract deposit 1492 // fees from that amount before transferring it to the merchant. 1493 amount: Amount; 1494 1495 // Optional tip amount. Must match the currency of ``amount``. 1496 // Since protocol **v25**. 1497 tip?: Amount; 1498 1499 // Human readable description of the semantics of the choice 1500 // within the contract to be shown to the user at payment. 1501 description?: string; 1502 1503 // Map from IETF 47 language tags to localized descriptions. 1504 description_i18n?: { [lang_tag: string]: string }; 1505 1506 // Inputs that must be provided by the customer, if this choice is selected. 1507 // Defaults to empty array if not specified. 1508 inputs?: OrderInput[]; 1509 1510 // Outputs provided by the merchant, if this choice is selected. 1511 // Defaults to empty array if not specified. 1512 outputs?: OrderOutput[]; 1513 1514 // Maximum total deposit fee accepted by the merchant for this contract. 1515 // Overrides defaults of the merchant instance. 1516 max_fee?: Amount; 1517 } 1518 1519 A choice of a *template* contract may additionally allow the client to 1520 replace the amount when the template is instantiated. 1521 1522 .. ts:def:: TemplateOrderChoice 1523 1524 interface TemplateOrderChoice extends OrderChoice { 1525 // If true, the client may replace "amount" when instantiating 1526 // the template; "amount" then merely provides the default. The 1527 // client may only change the value, never the currency. The 1528 // resulting amount is subject to the "min_amount" and 1529 // "max_amount" bounds of the template (if any). 1530 // Defaults to false, in which case the amount is fixed by the 1531 // merchant. 1532 // Since protocol **v34**. 1533 editable_amount?: boolean; 1534 } 1535 1536 .. ts:def:: OrderInput 1537 1538 // For now, only token inputs are supported. 1539 type OrderInput = OrderInputToken; 1540 1541 .. ts:def:: OrderInputToken 1542 1543 interface OrderInputToken { 1544 1545 // Token input. 1546 type: "token"; 1547 1548 // Token family slug as configured in the merchant backend. Slug is unique 1549 // across all configured tokens of a merchant. 1550 token_family_slug: Slug; 1551 1552 // How many units of the input are required. 1553 // Defaults to 1 if not specified. Output with count == 0 are ignored by 1554 // the merchant backend. 1555 count?: Integer; 1556 1557 } 1558 1559 .. ts:def:: OrderOutput 1560 1561 type OrderOutput = OrderOutputToken | OrderOutputTaxReceipt; 1562 1563 .. ts:def:: OrderOutputToken 1564 1565 interface OrderOutputToken { 1566 1567 // Token output. 1568 type: "token"; 1569 1570 // Token family slug as configured in the merchant backend. Slug is unique 1571 // across all configured tokens of a merchant. 1572 token_family_slug: Slug; 1573 1574 // How many units of the output are issued by the merchant. 1575 // Defaults to 1 if not specified. Output with count == 0 are ignored by 1576 // the merchant backend. 1577 count?: Integer; 1578 1579 // When should the output token be valid. Can be specified if the 1580 // desired validity period should be in the future (like selling 1581 // a subscription for the next month). Optional. If not given, 1582 // the validity is supposed to be "now" (time of order creation). 1583 valid_at?: Timestamp; 1584 1585 } 1586 1587 .. ts:def:: OrderOutputTaxReceipt 1588 1589 interface OrderOutputTaxReceipt { 1590 1591 // Tax receipt output. 1592 type: "tax-receipt"; 1593 1594 // Donation amount. Useful if the donation is only for 1595 // part of the total. 1596 // Optional, if not given the purchase total amount is 1597 // assumed to be the donation amount. 1598 amount?: Amount; 1599 } 1600 1601 .. _contract-base-terms: 1602 1603 Contract base terms 1604 ^^^^^^^^^^^^^^^^^^^ 1605 1606 These are the basic terms that are shared terms between orders and contracts 1607 and basically present (or optional) all the time. 1608 1609 .. ts:def:: ContractBaseTerms 1610 1611 interface ContractBaseTerms { 1612 // Human-readable description of the whole purchase. 1613 summary: string; 1614 1615 // Map from IETF BCP 47 language tags to localized summaries. 1616 summary_i18n?: { [lang_tag: string]: string }; 1617 1618 // Unique, free-form identifier for the proposal. 1619 // Must be unique within a merchant instance. 1620 // For merchants that do not store proposals in their DB 1621 // before the customer paid for them, the ``order_id`` can be used 1622 // by the frontend to restore a proposal from the information 1623 // encoded in it (such as a short product identifier and timestamp). 1624 order_id: Slug; 1625 1626 // URL where the same contract could be ordered again (if 1627 // available). Returned also at the public order endpoint 1628 // for people other than the actual buyer (hence public, 1629 // in case order IDs are guessable). 1630 public_reorder_url?: WebURL; 1631 1632 // URL that will show that the order was successful after 1633 // it has been paid for. Optional, but either ``fulfillment_url`` 1634 // or ``fulfillment_message`` must be specified in every 1635 // contract terms. 1636 // 1637 // If a non-unique fulfillment URL is used, a customer can only 1638 // buy the order once and will be redirected to a previous purchase 1639 // when trying to buy an order with the same fulfillment URL a second 1640 // time. This is useful for digital goods that a customer only needs 1641 // to buy once but should be able to repeatedly download. 1642 // 1643 // For orders where the customer is expected to be able to make 1644 // repeated purchases (for equivalent goods), the fulfillment URL 1645 // should be made unique for every order. The easiest way to do 1646 // this is to include a unique order ID in the fulfillment URL. 1647 // 1648 // When POSTing to the merchant, the placeholder text "${ORDER_ID}" 1649 // is be replaced with the actual order ID (useful if the 1650 // order ID is generated server-side and needs to be 1651 // in the URL). Note that this placeholder can only be used once. 1652 // Front-ends may use other means to generate a unique fulfillment URL. 1653 // Because of that placeholder, the value given here is merely a 1654 // string and not yet a `WebURL`; only after the substitution has 1655 // been performed is the result a `WebURL`. 1656 fulfillment_url?: string; 1657 1658 // Message shown to the customer after paying for the order. 1659 // Either fulfillment_url or fulfillment_message must be specified. 1660 fulfillment_message?: string; 1661 1662 // Map from IETF BCP 47 language tags to localized fulfillment 1663 // messages. 1664 fulfillment_message_i18n?: { [lang_tag: string]: string }; 1665 1666 // Delivery location for (all!) products. 1667 delivery_location?: Location; 1668 1669 // Time indicating when the order should be delivered. 1670 // May be overwritten by individual products. 1671 delivery_date?: Timestamp; 1672 1673 // Specifies for how long the wallet should try to get an 1674 // automatic refund for the purchase. If this field is 1675 // present, the wallet should wait for a few seconds after 1676 // the purchase and then automatically attempt to obtain 1677 // a refund. The wallet should probe until "delay" 1678 // after the payment was successful (i.e. via long polling 1679 // or via explicit requests with exponential back-off). 1680 // 1681 // In particular, if the wallet is offline 1682 // at that time, it MUST repeat the request until it gets 1683 // one response from the merchant after the delay has expired. 1684 // If the refund is granted, the wallet MUST automatically 1685 // recover the payment. This is used in case a merchant 1686 // knows that it might be unable to satisfy the contract and 1687 // desires for the wallet to attempt to get the refund without any 1688 // customer interaction. Note that it is NOT an error if the 1689 // merchant does not grant a refund. 1690 auto_refund?: RelativeTime; 1691 1692 // Extra data that is only interpreted by the merchant frontend. 1693 // Useful when the merchant needs to store extra information on a 1694 // contract without storing it separately in their database. 1695 // Must really be an Object (not a string, integer, float or array). 1696 extra?: Object; 1697 1698 // Minimum age the buyer must have (in years). Default is 0. 1699 // This value is at least as large as the maximum over all 1700 // mimimum age requirements of the products in this contract. 1701 // It might also be set independent of any product, due to 1702 // legal requirements. 1703 minimum_age?: Integer; 1704 1705 // Default money pot to use for this order, applies to the 1706 // amount remaining that was not claimed by money pots of 1707 // products or taxes. Not useful to wallets, only for 1708 // merchant-internal accounting. If not given, the remaining 1709 // account is simply not accounted for in any money pot. 1710 // Since **v25**. 1711 order_default_money_pot?: Integer; 1712 1713 // Latest time until which the good or service specified in the 1714 // contract may be picked up by the customer. This is usually 1715 // for digital goods where the customer has a finite window 1716 // for downloading the resource(s). 1717 max_pickup_time?: Timestamp; 1718 1719 } 1720 1721 .. _order-details: 1722 1723 Orders 1724 ^^^^^^ 1725 1726 The `Order` object represents the starting point for new `ContractTerms`. 1727 After validating and sanitizing all inputs, the merchant backend will add 1728 additional information to the order and create a new `ContractTerms` object 1729 that will be stored in the database. 1730 1731 .. ts:def:: Order 1732 1733 type Order = ContractBaseTerms & (OrderV0 | OrderV1) & OrderCommon; 1734 1735 .. ts:def:: OrderV0 1736 1737 interface OrderV0 { 1738 // Optional, defaults to 0 if not set. 1739 version?: 0; 1740 1741 // Total price for the transaction, including tip. The exchange will 1742 // subtract deposit fees from that amount before transferring it to 1743 // the merchant. 1744 amount: Amount; 1745 1746 // Optional tip amount. Must match the currency of ``amount``. 1747 // Since protocol **v25**. 1748 tip?: Amount; 1749 1750 // Maximum total deposit fee accepted by the merchant for this contract. 1751 // Overrides defaults of the merchant instance. 1752 max_fee?: Amount; 1753 } 1754 1755 .. ts:def:: OrderV1 1756 1757 interface OrderV1 { 1758 // Version 1 order support discounts and subscriptions. 1759 // https://docs.taler.net/design-documents/046-mumimo-contracts.html 1760 // @since protocol **v21** 1761 version: 1; 1762 1763 // List of contract choices that the customer can select from. 1764 // @since protocol **v21** 1765 choices: OrderChoice[]; 1766 } 1767 1768 1769 .. ts:def:: OrderCommon 1770 1771 interface OrderCommon { 1772 1773 // List of products that are part of the purchase. 1774 products?: ProductEntry[]; 1775 1776 // After this deadline has passed, no refunds will be accepted. 1777 // Overrides deadline calculated from ``refund_delay`` in 1778 // `PostOrderRequest`. 1779 // A value of "never" is not allowed. 1780 refund_deadline?: Timestamp; 1781 1782 // After this deadline, the merchant won't accept payments for the contract. 1783 // Overrides deadline calculated from default pay delay configured in 1784 // merchant backend. 1785 // A value of "never" is not allowed. 1786 pay_deadline?: Timestamp; 1787 1788 // Transfer deadline for the exchange. Must be in the deposit permissions 1789 // of coins used to pay for this order. 1790 // Overrides deadline calculated from default wire transfer delay 1791 // configured in merchant backend. Must be after refund deadline. 1792 // A value of "never" is not allowed. 1793 wire_transfer_deadline?: Timestamp; 1794 1795 // Payments for this order that were settled outside of Taler, 1796 // for example in cash or by card. The ``amount`` field above (or 1797 // the selected choice's ``amount`` for v1 orders) remains the 1798 // amount paid with Taler; the full order total is the sum of that 1799 // amount and all entries here. If present, all entries and (for 1800 // v1 orders) all choices must use the currency of the Taler 1801 // ``amount``. Never contains a ``taler`` entry. 1802 // @since protocol **vMixedPayments**. 1803 amount_external?: ExternalPaymentInfo[]; 1804 1805 } 1806 1807 .. ts:def:: ExternalPaymentInfo 1808 1809 interface ExternalPaymentInfo { 1810 // External payment method, for example "cash" or "card". 1811 // Must be a stable, non-empty ASCII identifier and must 1812 // never be "taler". 1813 method: string; 1814 1815 // Identifier of the payment action within the order, unique 1816 // among the entries of this ``amount_external`` array. 1817 // Examples: "cash1", "card1", "card2". 1818 id: string; 1819 1820 // Amount covered by this payment action. Must use the same 1821 // currency as the Taler ``amount`` of the order. 1822 amount: Amount; 1823 1824 // Additional method-specific fields for reconciliation or audit, 1825 // for example a cashier number, terminal identifier or 1826 // authorization code. These must be flat scalar values (no 1827 // nested objects or arrays) so that the merchant portal can 1828 // render ``amount_external`` as a generic table. 1829 [field: string]: string | Amount | Integer | boolean | null; 1830 } 1831 1832 .. _product-entry: 1833 1834 Product entries 1835 ^^^^^^^^^^^^^^^ 1836 1837 .. ts:def:: ProductEntry 1838 1839 type ProductEntry = (ProductSold | MinimalInventoryProduct); 1840 1841 1842 The following `MinimalInventoryProduct` can be provided if the parts of the 1843 order are inventory-based, that is if the `PostOrderRequest` uses 1844 ``inventory_products``. For such products, which must be in the backend's 1845 inventory, the backend can automatically fill in the amount and other details 1846 about the product that are known to it from its ``products`` table. Note that 1847 the ``inventory_products`` will be appended to the list of ``products`` that 1848 the frontend already put into the ``order``. So the frontend can sell 1849 additional non-inventory products together with ``inventory_products``. Note 1850 that the backend will NOT update the ``amount`` of the ``order``, so the 1851 frontend must already have calculated the total price --- including the 1852 ``inventory_products``. 1853 1854 .. ts:def:: MinimalInventoryProduct 1855 1856 // Note that if the frontend does give details beyond these, 1857 // it will override those details (including price or taxes) 1858 // that the backend would otherwise fill in via the inventory. 1859 interface MinimalInventoryProduct { 1860 1861 // Which product is requested (here mandatory!). 1862 product_id: Slug; 1863 1864 // Legacy integer quantity. 1865 // Deprecated since **v25**; 1866 // defaults to 1 if both ``quantity`` and ``unit_quantity`` are absent. 1867 quantity?: Integer; 1868 1869 // Preferred quantity string using "<integer>[.<fraction>]" syntax. 1870 // @since **v25**; 1871 unit_quantity?: string 1872 1873 // Money pot to use for this product, overrides value from 1874 // the inventory if given. 1875 // Since **v25**. 1876 product_money_pot?: Integer; 1877 1878 } 1879 1880 Clients must supply either ``quantity`` or ``unit_quantity`` when referencing 1881 inventory products. If both are missing the backend assumes a quantity of 1882 one. ``unit_quantity`` follows the same decimal-string rules as 1883 ``unit_total_stock``. 1884 1885 1886 .. _contract-token-family: 1887 1888 Contract token family 1889 ^^^^^^^^^^^^^^^^^^^^^ 1890 1891 The contract token family provides additional meta-data about 1892 input and output tokens associated with a particular choice of 1893 payment. 1894 1895 .. ts:def:: ContractTokenFamily 1896 1897 interface ContractTokenFamily { 1898 // Human-readable name of the token family. 1899 name: string; 1900 1901 // Human-readable description of the semantics of 1902 // this token family (for display). 1903 description: string; 1904 1905 // Map from IETF BCP 47 language tags to localized descriptions. 1906 description_i18n?: { [lang_tag: string]: string }; 1907 1908 // Public keys used to validate tokens issued by this token family. 1909 keys: TokenIssuePublicKey[]; 1910 1911 // Kind-specific information of the token 1912 details: ContractTokenDetails; 1913 1914 // Must a wallet understand this token type to 1915 // process contracts that use or issue it? 1916 critical: boolean; 1917 }; 1918 1919 .. ts:def:: TokenIssuePublicKey 1920 1921 type TokenIssuePublicKey = 1922 | TokenIssueRsaPublicKey 1923 | TokenIssueCsPublicKey; 1924 1925 .. ts:def:: TokenIssueRsaPublicKey 1926 1927 interface TokenIssueRsaPublicKey { 1928 cipher: "RSA"; 1929 1930 // RSA public key. 1931 rsa_pub: RsaPublicKey; 1932 1933 // Start time of this key's signatures validity period. 1934 signature_validity_start: Timestamp; 1935 1936 // End time of this key's signatures validity period. 1937 signature_validity_end: Timestamp; 1938 1939 } 1940 1941 .. ts:def:: TokenIssueCsPublicKey 1942 1943 interface TokenIssueCsPublicKey { 1944 cipher: "CS"; 1945 1946 // CS public key. 1947 cs_pub: Cs25519Point; 1948 1949 // Start time of this key's signatures validity period. 1950 signature_validity_start: Timestamp; 1951 1952 // End time of this key's signatures validity period. 1953 signature_validity_end: Timestamp; 1954 1955 } 1956 1957 .. ts:def:: ContractTokenDetails 1958 1959 type ContractTokenDetails = 1960 | ContractSubscriptionTokenDetails 1961 | ContractDiscountTokenDetails; 1962 1963 .. ts:def:: ContractSubscriptionTokenDetails 1964 1965 interface ContractSubscriptionTokenDetails { 1966 class: "subscription"; 1967 1968 // Array of domain names where this subscription 1969 // can be safely used (e.g. the issuer warrants that 1970 // these sites will re-issue tokens of this type 1971 // if the respective contract says so). May contain 1972 // "*" for any domain or subdomain. 1973 trusted_domains: string[]; 1974 }; 1975 1976 .. ts:def:: ContractDiscountTokenDetails 1977 1978 interface ContractDiscountTokenDetails { 1979 class: "discount"; 1980 1981 // Array of domain names where this discount token 1982 // is intended to be used. May contain "*" for any 1983 // domain or subdomain. Users should be warned about 1984 // sites proposing to consume discount tokens of this 1985 // type that are not in this list that the merchant 1986 // is accepting a coupon from a competitor and thus 1987 // may be attaching different semantics (like get 20% 1988 // discount for my competitors 30% discount token). 1989 expected_domains: string[]; 1990 }; 1991 1992 1993 .. _proto-contract-terms: 1994 1995 Proto contract terms 1996 ^^^^^^^^^^^^^^^^^^^^ 1997 1998 The proto-contract terms are the proposed contract that a merchant 1999 is about to present to a wallet, but that lacks the wallet's *nonce* 2000 and is thus not yet buyer-specific. 2001 2002 2003 2004 .. ts:def:: ProtoContractTerms 2005 2006 type ProtoContractTerms = ContractBaseTerms & (ContractTermsV0 | ContractTermsV1) & ContractTermsCommon; 2007 2008 2009 .. ts:def:: ContractTermsV0 2010 2011 interface ContractTermsV0 { 2012 // Defaults to version 0. 2013 version?: 0; 2014 2015 // Total price for the transaction, including tip. 2016 // The exchange will subtract deposit fees from that amount 2017 // before transferring it to the merchant. 2018 amount: Amount; 2019 2020 // Optional tip amount. Must match the currency of ``amount``. 2021 // Since protocol **v25**. 2022 tip?: Amount; 2023 2024 // Maximum total deposit fee accepted by the merchant for this contract. 2025 // Overrides defaults of the merchant instance. 2026 max_fee: Amount; 2027 } 2028 2029 .. ts:def:: ContractTermsV1 2030 2031 interface ContractTermsV1 { 2032 // Version 1 supports the ``choices`` array, see 2033 // https://docs.taler.net/design-documents/046-mumimo-contracts.html. 2034 // @since protocol **v21** 2035 version: 1; 2036 2037 // List of contract choices that the customer can select from. 2038 // @since protocol **v21** 2039 choices: ContractChoice[]; 2040 2041 // Map of storing metadata and issue keys of 2042 // token families referenced in this contract. 2043 // @since protocol **v21** 2044 token_families: { [token_family_slug: Slug]: ContractTokenFamily }; 2045 } 2046 2047 .. ts:def:: ContractTermsCommon 2048 2049 interface ContractTermsCommon { 2050 2051 // Time when this contract was generated. 2052 timestamp: Timestamp; 2053 2054 // After this deadline has passed, no refunds will be accepted. 2055 refund_deadline: Timestamp; 2056 2057 // After this deadline, the merchant won't accept payments for the contract. 2058 pay_deadline: Timestamp; 2059 2060 // Transfer deadline for the exchange. Must be in the 2061 // deposit permissions of coins used to pay for this order. 2062 wire_transfer_deadline: Timestamp; 2063 2064 // Merchant's public key used to sign this proposal; this information 2065 // is typically added by the backend. Note that this can be an ephemeral key. 2066 merchant_pub: EddsaPublicKey; 2067 2068 // Base URL of the (public!) merchant backend API. 2069 // Must be an absolute URL that ends with a slash. 2070 merchant_base_url: WebURL; 2071 2072 // More info about the merchant, see below. 2073 merchant: Merchant; 2074 2075 // List of products that are part of the purchase (see `ProductSold`). 2076 products: ProductSold[]; 2077 2078 // The hash of the merchant instance's wire details. 2079 h_wire: HashCode; 2080 2081 // Wire transfer method identifier for the wire method associated with ``h_wire``. 2082 // The wallet may only select exchanges via a matching auditor if the 2083 // exchange also supports this wire method. 2084 // The wire transfer fees must be added based on this wire transfer method. 2085 wire_method: string; 2086 2087 // Exchanges that the merchant accepts even if it does not accept any auditors that audit them. 2088 exchanges: Exchange[]; 2089 2090 // Payments for this order that were settled outside of Taler, 2091 // for example in cash or by card. The ``amount`` field (or the 2092 // selected choice's ``amount`` for v1 contracts) remains the amount 2093 // paid with Taler; the full order total is the sum of that amount 2094 // and all entries here. See `ExternalPaymentInfo`. 2095 // @since protocol **vMixedPayments**. 2096 amount_external?: ExternalPaymentInfo[]; 2097 2098 } 2099 2100 .. ts:def:: ContractChoice 2101 2102 interface ContractChoice { 2103 // Price to be paid for this choice. Could be 0. 2104 // The price is in addition to other instruments, 2105 // such as rations and tokens. 2106 // The exchange will subtract deposit fees from that amount 2107 // before transferring it to the merchant. 2108 amount: Amount; 2109 2110 // Optional tip amount. Must match the currency of ``amount``. 2111 // Since protocol **v25**. 2112 tip?: Amount; 2113 2114 // Human readable description of the semantics of the choice 2115 // within the contract to be shown to the user at payment. 2116 description?: string; 2117 2118 // Map from IETF 47 language tags to localized descriptions. 2119 description_i18n?: { [lang_tag: string]: string }; 2120 2121 // List of inputs the wallet must provision (all of them) to 2122 // satisfy the conditions for the contract. 2123 inputs: ContractInput[]; 2124 2125 // List of outputs the merchant promises to yield (all of them) 2126 // once the contract is paid. 2127 outputs: ContractOutput[]; 2128 2129 // Maximum total deposit fee accepted by the merchant for this contract. 2130 max_fee: Amount; 2131 } 2132 2133 .. ts:def:: ContractInput 2134 2135 // For now, only tokens are supported as inputs. 2136 type ContractInput = ContractInputToken; 2137 2138 .. ts:def:: ContractInputToken 2139 2140 interface ContractInputToken { 2141 type: "token"; 2142 2143 // Slug of the token family in the 2144 // ``token_families`` map on the order. 2145 token_family_slug: Slug; 2146 2147 // Number of tokens of this type required. 2148 // Defaults to one if the field is not provided. 2149 count?: Integer; 2150 }; 2151 2152 .. ts:def:: ContractOutput 2153 2154 // For now, only tokens are supported as outputs. 2155 type ContractOutput = ContractOutputToken | ContractOutputTaxReceipt; 2156 2157 .. ts:def:: ContractOutputToken 2158 2159 interface ContractOutputToken { 2160 type: "token"; 2161 2162 // Slug of the token family in the 2163 // 'token_families' map on the top-level. 2164 token_family_slug: Slug; 2165 2166 // Number of tokens to be issued. 2167 // Defaults to one if the field is not provided. 2168 count?: Integer; 2169 2170 // When should the output token be valid. Can be specified if the 2171 // desired validity period should be in the future (like selling 2172 // a subscription for the next month). Optional. If not given, 2173 // the validity is supposed to be "now" (time of order creation). 2174 valid_at?: Timestamp; 2175 2176 // Index of the public key for this output token 2177 // in the `ContractTokenFamily` ``keys`` array. 2178 key_index: Integer; 2179 2180 } 2181 2182 .. ts:def:: ContractOutputTaxReceipt 2183 2184 interface ContractOutputTaxReceipt { 2185 2186 // Tax receipt output. 2187 type: "tax-receipt"; 2188 2189 // Array of base URLs of donation authorities that can be 2190 // used to issue the tax receipts. The client must select one. 2191 donau_urls: WebURL[]; 2192 2193 // Total amount that will be on the tax receipt. 2194 amount: Amount; 2195 2196 } 2197 2198 2199 Product listing 2200 ^^^^^^^^^^^^^^^ 2201 2202 The `ProductSold` object describes a product and the quantity 2203 being purchased from the merchant as well as possibly the price 2204 and applicable taxes. 2205 It has the following structure: 2206 2207 .. ts:def:: ProductSold 2208 2209 interface ProductSold { 2210 2211 // Merchant-internal identifier for the product. 2212 product_id?: Slug; 2213 2214 // Name of the product. 2215 // Since API version **v20**. Optional only for 2216 // backwards-compatibility, should be considered mandatory 2217 // moving forward! 2218 product_name?: string; 2219 2220 // Human-readable product description. 2221 description: string; 2222 2223 // Map from IETF BCP 47 language tags to localized descriptions. 2224 description_i18n?: { [lang_tag: string]: string }; 2225 2226 // Legacy integer portion of the quantity to deliver defaults to 1 if not specified. 2227 quantity?: Integer; 2228 2229 // Preferred quantity string using "<integer>[.<fraction>]" syntax with up to six fractional digits. 2230 unit_quantity?: string; 2231 2232 // Unit in which the product is measured (liters, kilograms, packages, etc.). 2233 unit?: Slug; 2234 2235 // The price of the product; 2236 // Deprecated since **v25**; 2237 // this is the total price 2238 // for ``quantity`` times ``unit`` of this product. 2239 price?: Amount; 2240 2241 // Price of ``unit_quantity`` units of the product in various currencies. 2242 // Zero or absent implies that the product is not sold 2243 // separately. 2244 // Since API version **v25**. 2245 prices?: Amount[]; 2246 2247 // True if the ``prices`` given are the net price, 2248 // false if they are the gross price. Note that even ``prices`` are the 2249 // gross price, ``taxes`` may be missing if the merchant configured 2250 // gross ``prices`` but did not configure any ``taxes``. 2251 // Similarly, the merchant may have configured net ``prices`` 2252 // for products but deals with taxes on a per-order basis. Thus, it 2253 // may not always be possible to compute the gross price from the net 2254 // price for an individual product, necessitating this flag. 2255 // Since protocol **vTAXES**. 2256 prices_are_net: boolean; 2257 2258 // An optional base64-encoded product image. 2259 image?: ImageDataUrl; 2260 2261 // A list of taxes paid by the merchant for this product. Can be empty. 2262 // Will likely change soon! 2263 taxes?: Tax[]; 2264 2265 // Time indicating when this product should be delivered. 2266 delivery_date?: Timestamp; 2267 2268 // Money pot to use for this product, overrides value from 2269 // the inventory if given. Not useful to wallets, only for 2270 // merchant-internal accounting. 2271 // Since **v25**. 2272 product_money_pot?: Integer; 2273 2274 } 2275 2276 .. ts:def:: Tax 2277 2278 interface Tax { 2279 // The name of the tax. 2280 name: string; 2281 2282 // Amount paid in tax. 2283 tax: Amount; 2284 } 2285 2286 .. ts:def:: Merchant 2287 2288 interface Merchant { 2289 // The merchant's legal name of business. 2290 name: string; 2291 2292 // Email address for contacting the merchant. 2293 email?: string; 2294 2295 // Merchant public website. 2296 website?: WebURL; 2297 2298 // An optional base64-encoded product image. 2299 logo?: ImageDataUrl; 2300 2301 // Label for a location with the business address of the merchant. 2302 address?: Location; 2303 2304 // Label for a location that denotes the jurisdiction for disputes. 2305 // Some of the typical fields for a location (such as a street address) may be absent. 2306 jurisdiction?: Location; 2307 } 2308 2309 2310 .. ts:def:: Location 2311 2312 // Delivery location, loosely modeled as a subset of 2313 // ISO20022's PostalAddress25. 2314 interface Location { 2315 // Nation with its own government. 2316 country?: string; 2317 2318 // Identifies a subdivision of a country such as state, region, county. 2319 country_subdivision?: string; 2320 2321 // Identifies a subdivision within a country sub-division. 2322 district?: string; 2323 2324 // Name of a built-up area, with defined boundaries, and a local government. 2325 town?: string; 2326 2327 // Specific location name within the town. 2328 town_location?: string; 2329 2330 // Identifier consisting of a group of letters and/or numbers that 2331 // is added to a postal address to assist the sorting of mail. 2332 post_code?: string; 2333 2334 // Name of a street or thoroughfare. 2335 street?: string; 2336 2337 // Name of the building or house. 2338 building_name?: string; 2339 2340 // Number that identifies the position of a building on a street. 2341 building_number?: string; 2342 2343 // Free-form address lines, should not exceed 7 elements. 2344 address_lines?: string[]; 2345 } 2346 2347 2348 Exchanges 2349 ^^^^^^^^^ 2350 2351 The wallet must select an exchange that the merchant accepts by 2352 listing it in the exchanges array. 2353 2354 .. ts:def:: Exchange 2355 2356 interface Exchange { 2357 // The exchange's base URL. 2358 url: WebURL; 2359 2360 // How much would the merchant like to use this exchange. 2361 // The wallet should use a suitable exchange with high 2362 // priority. The following priority values are used, but 2363 // it should be noted that they are NOT in any way normative. 2364 // 2365 // 0: likely it will not work (recently seen with account 2366 // restriction that would be bad for this merchant) 2367 // 512: merchant does not know, might be down (merchant 2368 // did not yet get /wire response). 2369 // 1024: good choice (recently confirmed working) 2370 priority: Integer; 2371 2372 // Master public key of the exchange. 2373 master_pub: EddsaPublicKey; 2374 2375 // Maximum amount that the merchant could be paid 2376 // using this exchange (due to legal limits). 2377 // New in protocol **v17**. 2378 // Optional, no limit if missing. 2379 max_contribution?: Amount; 2380 } 2381 2382 In addition to the fields described above, 2383 each object (from `ContractTerms` down) 2384 can mark certain fields as "forgettable" by listing the names of those fields 2385 in a special peer field ``_forgettable``. 2386 (See :ref:`Private order data cleanup <private-order-data-cleanup>`.) 2387 2388 2389 .. _contract-terms: 2390 2391 Final contract terms 2392 ^^^^^^^^^^^^^^^^^^^^ 2393 2394 The contract terms are the final object that is signed by both 2395 parties to finalize a purchase. It must have the following structure: 2396 2397 .. ts:def:: ContractTerms 2398 2399 type ContractTerms = ProtoContractTerms & ContractTermsNonce; 2400 2401 .. ts:def:: ContractTermsNonce 2402 2403 interface ContractTermsNonce { 2404 2405 // Nonce generated by the wallet and echoed by the merchant 2406 // in this field when the order is claimed and converted 2407 // into a contract that is bound to a wallet. 2408 nonce: EddsaPublicKey; 2409 }