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