api-merchant.rst (51024B)
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 2.1, 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 current protocol version is **v30**. 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 **vXX**. 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 ``/config``. 58 * ``v29``: adds ``max_pickup_duration`` to templates (for Paivana) 59 * ``v30``: adds ``debit_restrictions`` to GET /exchanges (for SPA) 60 61 **Upcoming versions:** 62 63 * ``vTAXES``: adds features to manage taxes 64 65 **Ideas for future version:** 66 67 * ``vXXX``: marker for features not yet targeted for release 68 69 ----------------------- 70 Base URLs and Instances 71 ----------------------- 72 73 A single merchant backend installation can host multiple merchant instances. 74 This is useful when multiple businesses want to share the same payment 75 infrastructure. 76 77 Merchant backends have one special ``admin`` instance. This ``admin`` 78 instance is used when no explicit instance is specified. Note that using 79 ``/instances/admin/$ANYTHING`` is deprecated and will result in a permanent 80 redirect (HTTP status 308) to ``$ANYTHING``. a Despite its name, this instance 81 must be created after the installation. 82 83 Each instance (admin and others) has a base URL. The resources under 84 this base URL are divided into to categories: 85 86 * Public endpoints that are exposed to the Internet 87 * Private endpoints (under ``/private/*``) that are only supposed to be exposed 88 to the merchant internally, and must not be exposed on the 89 Internet. 90 * Management endpoints (under ``/management/*``) are also private and dedicated 91 to CRUD operation over instances and reset authentication settings over all 92 instances. Only accessible with the admin instance authentication token. 93 94 Examples: 95 96 .. code-block:: none 97 98 Base URL of the merchant (admin instance) at merchant-backend.example.com: 99 https://merchant-backend.example.com/ 100 101 A private endpoint (admin instance): 102 https://merchant-backend.example.com/private/orders 103 104 A public endpoint (admin instance and order id "ABCD"): 105 https://merchant-backend.example.com/orders/ABCD 106 107 A private endpoint ("myinst" instance): 108 https://merchant-backend.example.com/instances/myinst/private/orders 109 110 A public endpoint ("myinst" instance and order id "ABCD"): 111 https://merchant-backend.example.com/instances/myinst/orders/ABCD 112 113 A private endpoint (explicit "admin" instance): 114 https://merchant-backend.example.com/private/orders 115 116 A public endpoint (explicit "admin" instance): 117 https://merchant-backend.example.com/orders 118 119 Endpoints to manage other instances (ONLY for implicit "admin" instance): 120 https://merchant-backend.example.com/management/instances 121 https://merchant-backend.example.com/management/instances/$ID 122 123 Endpoints to manage own instance: 124 https://merchant-backend.example.com/private 125 https://merchant-backend.example.com/private/auth 126 https://merchant-backend.example.com/instances/$ID/private 127 https://merchant-backend.example.com/instances/$ID/forgot-password 128 https://merchant-backend.example.com/instances/$ID/private/auth 129 130 Unavailabe endpoints (will return 404): 131 https://merchant-backend.example.com/instances/myinst/private/instances 132 133 ----------------- 134 Generic Responses 135 ----------------- 136 137 The following (error) responses are applicable to all endpoints 138 unless specified otherwise. 139 140 .. include:: merchant/any-star.rst 141 142 .. _merchant-api-authentication: 143 144 -------------- 145 Authentication 146 -------------- 147 148 Each merchant instance has separate authentication settings for the private API resources 149 of that instance. 150 151 Currently, the ``/private/auth/`` API supports two main authentication methods in the ``InstanceAuthConfigurationMessage``: 152 153 * ``external``: (@deprecated since **v20**) With this method, no checks are done by the merchant backend. 154 Instead, a reverse proxy / API gateway must do all authentication/authorization checks. 155 * ``token`` (**@since v19**): With this method, the client must provide an authorization header 156 that contains a bearer token when accessing a protected endpoint in the form 157 ``Authorization: Bearer secret-token:$TOKEN``. 158 ``$TOKEN`` is an authentication token retrieved from the ``/private/token`` endpoint using basic authorization. 159 The respective username is the instance ``$ID``, and the password the instance password (``$INSTANCE_PASSWORD``). 160 A login token is commonly only valid for a limited period of time and scoped to specific permissions. 161 If the ``$INSTANCE_PASSWORD`` is lost, the administrator can set a password 162 using the ``taler-merchant-passwd`` command-line tool. 163 * ``token`` (@deprecated since **v19**): With this method, the client must provide an authentication token in 164 the format ``secret-token: $INSTANCE_PASSWORD``. 165 The behaviour is then equivalent to the ``token`` method above. 166 Any API may be accessed using the bearer authentication ``secret-token: $INSTANCE_PASSWORD``. 167 Notice that this behaviour is deprecated and will be phased out in favor of login tokens. 168 169 For testing, the service may be started with the configuration option ``DISABLED_AUTHENTICATION = YES`` 170 in section ``[merchant]`` (@since **v20**). 171 172 Scopes 173 ^^^^^^ 174 175 Access tokens can be requested with a (limiting) scope. Available scopes and their associated permissions are: 176 177 * ``readonly``: ``*-read`` -- Access to APIs using ``GET`` requests is always allowed. 178 * ``write`` (*deprecated*): See ``all``. 179 * ``all``: ``*`` -- General access to all APIs and endpoints and always refreshable. (@since **v19**) 180 * ``spa``: ``*`` -- General access to all APIs and endpoints. (@since **v20**) 181 * ``order-simple``: ``orders-read``, ``orders-write`` -- Allows the creation of orders and checking of payment status. (@since **v19**) 182 * ``order-pos``: ``orders-read``, ``orders-write``, ``inventory-lock`` -- Same as ``order-simple`` and allows inventory locking. (@since **v19**) 183 * ``order-mgmt``: ``orders-read``, ``orders-write``, ``orders-refund`` -- Same as ``order-simple`` and also allows refunding. (@since **v19**) 184 * ``order-full``: ``orders-read``, ``orders-write``, ``inventory-lock``, ``orders-refund`` -- Same ``order-pos`` and ``order-mgmt`` combined. (@since **v19**) 185 186 Since **v19** the scope may be suffixed with ``:refreshable``, e.g. ``order-pos:refreshable``. 187 This allows the token to be refreshed at the token endpoint. 188 This behaviour replaces the deprecated ``refreshable`` field in the `LoginTokenRequest`. 189 190 ----------------- 191 Configuration API 192 ----------------- 193 194 The configuration API exposes basic information about a merchant backend, 195 such as the implemented version of the protocol and the currency used. 196 197 .. include:: merchant/get-config.rst 198 199 .. include:: tos.rst 200 201 ------------------- 202 Exchange Status API 203 ------------------- 204 205 The exchange status API exposes basic information about the exchanges 206 configured for a merchant backend, in particular the acceptable 207 currencies, master public keys and the status of the merchant backend's 208 download of the ``/keys`` from the exchange. This is mostly useful 209 to diagnose configuration problems. 210 211 .. include:: merchant/get-exchanges.rst 212 213 --------------- 214 Two Factor Auth 215 --------------- 216 217 202 Challenge Responses 218 ^^^^^^^^^^^^^^^^^^^^^^^ 219 220 Various APIs generate ``202 Accepted`` HTTP status codes when multi-factor 221 authentication (MFA) is required. In this case, the response will be a 222 `ChallengeResponse`. In these cases, the client must first request and solve 223 one or more challenges before repeating the request. When repeating the 224 request, they must include a list of comma-separated challenge IDs of the 225 solved challenges in an ``Taler-Challenge-Ids`` HTTP header. The body must 226 remain absolutely unchanged. 227 228 .. note:: 229 230 If all allowed attempts to solve the MFA challenge(s) fail, the endpoint 231 may start to return ``403 Forbidden`` until the issued challenges expire, 232 preventing the request from being completed for a while. In this case, 233 repeating the request with a different body may still be allowed! 234 235 .. ts:def:: ChallengeResponse 236 237 // @since v21 238 interface ChallengeResponse { 239 // List of challenge IDs that must be solved before the 240 // client may proceed. 241 challenges: Challenge[]; 242 243 // True if **all** challenges must be solved (AND), false if 244 // it is sufficient to solve one of them (OR). 245 combi_and: boolean; 246 247 } 248 249 .. ts:def:: Challenge 250 251 interface Challenge { 252 // Unique identifier of the challenge to solve to run this protected 253 // operation. 254 challenge_id: string; 255 256 // Channel of the last successful transmission of the TAN challenge. 257 tan_channel: TanChannel; 258 259 // Info of the last successful transmission of the TAN challenge. 260 // Hint to show to the user as to where the challenge was 261 // sent or what to use to solve the challenge. May not 262 // contain the full address for privacy. 263 tan_info: string; 264 265 } 266 267 Requesting challenges 268 ^^^^^^^^^^^^^^^^^^^^^ 269 270 .. include:: merchant/post-challenge-CHALLENGE_ID.rst 271 272 Solving challenges 273 ^^^^^^^^^^^^^^^^^^ 274 275 .. include:: merchant/post-challenge-CHALLENGE_ID-confirm.rst 276 277 ---------- 278 Wallet API 279 ---------- 280 281 This section describes (public) endpoints that wallets must be able 282 to interact with directly (without HTTP-based authentication). These 283 endpoints are used to process payments (claiming an order, paying 284 for the order, checking payment/refund status and aborting payments), 285 and to process refunds (checking refund status, obtaining the refund). 286 287 288 Claiming an order 289 ^^^^^^^^^^^^^^^^^ 290 291 The first step of processing any Taler payment consists of the 292 (authorized) wallet claiming the order for itself. In this process, 293 the wallet provides a wallet-generated nonce that is added 294 into the contract terms. This step prevents two different 295 wallets from paying for the same contract, which would be bad 296 especially if the merchant only has finite stocks. 297 298 A claim token can be used to ensure that the wallet claiming an 299 order is actually authorized to do so. This is useful in cases 300 where order IDs are predictable and malicious actors may try to 301 claim orders (say in a case where stocks are limited). 302 303 304 .. include:: merchant/post-orders-ORDER_ID-claim.rst 305 306 .. include:: merchant/post-orders-ORDER_ID-unclaim.rst 307 308 309 Making the payment 310 ^^^^^^^^^^^^^^^^^^ 311 312 .. include:: merchant/post-orders-ORDER_ID-pay.rst 313 314 315 Querying payment status 316 ^^^^^^^^^^^^^^^^^^^^^^^ 317 318 .. include:: merchant/get-orders-ORDER_ID.rst 319 320 321 .. include:: merchant/get-sessions-SESSION_ID.rst 322 323 324 Demonstrating payment 325 ^^^^^^^^^^^^^^^^^^^^^ 326 327 In case a wallet has already paid for an order, this is a fast way of proving 328 to the merchant that the order was already paid. The alternative would be to 329 replay the original payment, but simply providing the merchant's signature 330 saves bandwidth and computation time. 331 332 Demonstrating payment is useful in case a digital good was made available 333 only to clients with a particular session ID: if that session ID expired or 334 if the user is using a different client, demonstrating payment will allow 335 the user to regain access to the digital good without having to pay for it 336 again. 337 338 .. include:: merchant/post-orders-ORDER_ID-paid.rst 339 340 341 Aborting incomplete payments 342 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 343 344 In rare cases (such as a wallet restoring from an outdated backup) it is possible 345 that a wallet fails to complete a payment because it runs out of e-cash in the 346 middle of the process. The abort API allows the wallet to abort the payment for 347 such an incomplete payment and to regain control over the coins that were spent 348 so far. Aborts are not permitted for payments that have completed. In contrast to 349 refunds, aborts do not require approval by the merchant because aborts always 350 are for incomplete payments for an order and never for established contracts. 351 352 353 .. _order-abort: 354 .. include:: merchant/post-orders-ORDER_ID-abort.rst 355 356 357 Obtaining refunds 358 ^^^^^^^^^^^^^^^^^ 359 360 Refunds allow merchants to fully or partially restitute e-cash to a wallet, 361 for example because the merchant determined that it could not actually fulfill 362 the contract. Refunds must be approved by the merchant's business logic. 363 364 365 .. include:: merchant/post-orders-ORDER_ID-refund.rst 366 367 368 ------------------- 369 Instance management 370 ------------------- 371 372 Instances allow one merchant backend to be shared by multiple merchants. 373 Every backend must have at least one instance, typically the "admin" 374 instance setup before it can be used to manage inventory or process payments. 375 376 377 Setting up instances 378 ^^^^^^^^^^^^^^^^^^^^ 379 380 .. include:: merchant/post-instances.rst 381 382 383 .. include:: merchant/post-instances-INSTANCE-forgot-password.rst 384 385 386 .. include:: merchant/post-management-instances.rst 387 388 .. include:: merchant/post-management-instances-INSTANCE-auth.rst 389 390 Access control tokens 391 ^^^^^^^^^^^^^^^^^^^^^ 392 393 .. include:: merchant/post-private-token.rst 394 395 .. include:: merchant/get-private-tokens.rst 396 397 .. include:: merchant/delete-private-tokens-SERIAL.rst 398 399 .. include:: merchant/delete-private-token.rst 400 401 .. include:: merchant/patch-management-instances-INSTANCE.rst 402 403 404 Inspecting instances 405 ^^^^^^^^^^^^^^^^^^^^ 406 407 .. _instances: 408 .. include:: merchant/get-management-instances.rst 409 410 .. include:: merchant/get-management-instances-INSTANCE.rst 411 412 413 Getting statistics 414 ^^^^^^^^^^^^^^^^^^ 415 416 .. include:: merchant/get-private-statistics-amount-SLUG.rst 417 418 .. include:: merchant/get-private-statistics-counter-SLUG.rst 419 420 .. include:: merchant/get-private-statistics-report-NAME.rst 421 422 423 Deleting instances 424 ^^^^^^^^^^^^^^^^^^ 425 426 .. include:: merchant/delete-management-instances-INSTANCE.rst 427 428 429 KYC status checks 430 ^^^^^^^^^^^^^^^^^ 431 432 .. _merchantkycstatus: 433 434 .. include:: merchant/get-private-kyc.rst 435 436 437 ------------- 438 Bank Accounts 439 ------------- 440 441 One or more bank accounts must be associated with an instance 442 so that the instance can receive payments. Payments may be made 443 into any of the active bank accounts of an instance. 444 445 446 .. include:: merchant/post-private-accounts.rst 447 448 .. include:: merchant/patch-private-accounts-H_WIRE.rst 449 450 .. include:: merchant/get-private-accounts.rst 451 452 .. include:: merchant/get-private-accounts-H_WIRE.rst 453 454 .. include:: merchant/delete-private-accounts-H_WIRE.rst 455 456 .. include:: merchant/post-private-accounts-H_WIRE-kycauth.rst 457 458 459 -------------------- 460 Inventory management 461 -------------------- 462 463 .. _inventory: 464 465 Inventory management is an *optional* backend feature that can be used to 466 manage limited stocks of products and to auto-complete product descriptions in 467 contracts (such that the frontends have to do less work). You can use the 468 Taler merchant backend to process payments *without* using its inventory 469 management. 470 471 .. _decimal-quantity: 472 473 Decimal quantities 474 ^^^^^^^^^^^^^^^^^^ 475 476 .. ts:def:: DecimalQuantity 477 478 // Fixed-point decimal string in the form "<integer>[.<fraction>]". 479 // Fractional part has up to six digits. 480 // "-1" is only valid for fields that explicitly allow "infinity". 481 // Since protocol **v25**; used in template selection since **v25**. 482 type DecimalQuantity = string; 483 484 485 Managing measurement units 486 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 487 488 .. include:: merchant/get-private-units.rst 489 490 .. include:: merchant/get-private-units-UNIT.rst 491 492 493 .. include:: merchant/post-private-units.rst 494 495 496 .. include:: merchant/patch-private-units-UNIT.rst 497 498 499 .. include:: merchant/delete-private-units-UNIT.rst 500 501 502 Managing product categories 503 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 504 505 .. include:: merchant/get-private-categories.rst 506 507 .. include:: merchant/get-private-categories-CATEGORY_ID.rst 508 509 510 .. include:: merchant/post-private-categories.rst 511 512 513 .. include:: merchant/patch-private-categories-CATEGORY_ID.rst 514 515 .. include:: merchant/delete-private-categories-CATEGORY_ID.rst 516 517 518 Managing products in the inventory 519 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 520 521 .. include:: merchant/post-private-products.rst 522 523 524 .. include:: merchant/patch-private-products-PRODUCT_ID.rst 525 526 527 .. include:: merchant/get-private-products.rst 528 529 530 .. include:: merchant/get-private-products-PRODUCT_ID.rst 531 532 533 .. include:: merchant/delete-private-products-PRODUCT_ID.rst 534 535 536 537 Providing configuration data for point-of-sale terminals 538 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 539 540 .. include:: merchant/get-private-pos.rst 541 542 543 Fetching product images 544 ^^^^^^^^^^^^^^^^^^^^^^^ 545 546 .. include:: merchant/get-products-IMAGE_HASH-image.rst 547 548 549 550 Reserving inventory 551 ^^^^^^^^^^^^^^^^^^^ 552 553 .. include:: merchant/post-private-products-PRODUCT_ID-lock.rst 554 555 556 557 ------------------ 558 Payment processing 559 ------------------ 560 561 To process Taler payments, a merchant must first set up an order with 562 the merchant backend. The order is then claimed by a wallet, and 563 paid by the wallet. The merchant can check the payment status of the 564 order. Once the order is paid, the merchant may (for a limited time) 565 grant refunds on the order. 566 567 Creating orders 568 ^^^^^^^^^^^^^^^ 569 570 .. _post-order: 571 572 .. include:: merchant/post-private-orders.rst 573 574 Inspecting orders 575 ^^^^^^^^^^^^^^^^^ 576 577 .. include:: merchant/get-private-orders.rst 578 579 .. include:: merchant/get-private-orders-ORDER_ID.rst 580 581 582 583 .. _private-order-data-cleanup: 584 585 Private order data cleanup 586 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 587 588 Some orders may contain sensitive information that the merchant may not want 589 to retain after fulfillment, such as the customer's shipping address. By 590 initially labeling these order components as forgettable, the merchant can 591 later tell the backend to forget those details (without changing the hash of 592 the contract!) to minimize risks from information leakage. 593 594 595 .. include:: merchant/patch-private-orders-ORDER_ID-forget.rst 596 597 598 .. include:: merchant/delete-private-orders-ORDER_ID.rst 599 600 601 .. _merchant_refund: 602 603 ----------------- 604 Approving Refunds 605 ----------------- 606 607 .. include:: merchant/post-private-orders-ORDER_ID-refund.rst 608 609 610 ----------------------- 611 Tracking Wire Transfers 612 ----------------------- 613 614 This API is used by merchants that want to track the payments from the 615 exchange to be sure that they have been paid on time. By telling the merchant 616 backend about all incoming wire transfers, the backend can detect if an 617 exchange failed to perform a wire transfer that was due. 618 619 620 Informing the backend about incoming wire transfers 621 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 622 623 .. include:: merchant/post-private-transfers.rst 624 625 626 Querying known wire transfers 627 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 628 629 .. include:: merchant/get-private-transfers.rst 630 631 632 633 Querying expected wire transfers 634 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 635 636 .. include:: merchant/get-private-incoming.rst 637 638 639 .. include:: merchant/get-private-incoming-ID.rst 640 641 642 Deleting confirmed wire transfer 643 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 644 645 Deleting a wire transfer can be useful in case of a data entry 646 mistake. In particular, if the exchange base URL was entered 647 badly, deleting the old entry and adding a correct one is a 648 good idea. Note that deleting wire transfers is not possible 649 if they were expected. 650 651 .. include:: merchant/delete-private-transfers-TID.rst 652 653 654 ----------- 655 OTP Devices 656 ----------- 657 658 OTP devices can be used to allow offline merchants 659 to validate that a customer made a payment. 660 661 662 .. include:: merchant/post-private-otp-devices.rst 663 664 665 .. include:: merchant/patch-private-otp-devices-DEVICE_ID.rst 666 667 668 .. include:: merchant/get-private-otp-devices.rst 669 670 .. include:: merchant/get-private-otp-devices-DEVICE_ID.rst 671 672 .. include:: merchant/delete-private-otp-devices-DEVICE_ID.rst 673 674 675 .. _merchant-template-api: 676 677 --------- 678 Templates 679 --------- 680 681 The template is a backend feature that is used to allow wallets to create an 682 order. This is useful in cases where a store does not have Internet 683 connectivity or where a Web site wants to enable payments on a purely static 684 Web page (for example to collect donations). In these cases, the GNU Taler 685 wallet can be used to setup an order (and then of course pay for it). 686 687 Templates can describe a fixed contract (``fixed-order``), an inventory-backed 688 cart where the wallet picks products and quantities (``inventory-cart``), or a 689 session-based template (``paivana``). The template type controls which fields 690 appear in the contract and which inputs are required during instantiation. 691 692 The template itself primarily provides order details that cannot be be changed 693 by the customer when the wallet creates the order. The idea is that the user 694 *may* be prompted to enter certain information, such as the amount to be paid, 695 or the order summary (as a reminder to themselves or a message to the store), 696 while the template provides all of the other contract details. 697 698 The typical user-experience with templatates is that the user first scans a QR 699 code or clicks on a taler://-URI which contains a ``pay-template`` (see `LSD 700 0006 <https://lsd.gnunet.org/lsd0006/>`__). The URI specifies which values the 701 user should supply, currently either nothing, the amount, the order summary or 702 both. The URI may also specify defaults or partial defaults for those 703 values. After the user has supplied those values, the wallet will use the 704 public template API to create the order, then fetch the order details, and 705 proceed as if it had been given the respective ``pay`` URI in the first place: 706 show the full contract details and allow the user to make a payment. If the 707 user chooses to aborts the payment, the wallet should give the user the 708 opportunity to edit the values and create another order with different values. 709 If the template does not include any values that the user is allowed to edit 710 (so it is basically a fixed contract), the wallet should directly create the 711 order and immediately proceed to the contract acceptance dialog. 712 713 The business process for the templating API is also pretty simple. First, the 714 private API is used to setup (or edit) the template, providing all of the 715 contract terms that subsequently cannot be changed by the customer/wallet. 716 This template data is then stored under the template ID which can be freely 717 chosen and must be in URL-encoded format. The SPA should also make it easy 718 for the merchant to convert the template ID into a taler://-URI and/or QR code. 719 Here, the merchant must additionally specify the defaults (if any) for the 720 customer-editable values. Afterwards, the merchant can print out the QR code 721 for display at the store, add a link to the taler://-URI and/or embed the 722 respective QR-code image into their Web page. 723 724 To receive a payment confirmation, the mechant may choose to configure a 725 webhook in the merchant backend on the ``pay`` action, for example to send an 726 SMS to their mobile phone. For points-of-sale without a mobile phone or 727 Internet connectivity, the OTP mechanism can also be used to confirm payments. 728 729 730 731 Adding templates 732 ^^^^^^^^^^^^^^^^ 733 734 .. include:: merchant/post-private-templates.rst 735 736 737 Editing templates 738 ^^^^^^^^^^^^^^^^^ 739 740 .. include:: merchant/patch-private-templates-TEMPLATE_ID.rst 741 742 743 Inspecting template 744 ^^^^^^^^^^^^^^^^^^^ 745 746 .. include:: merchant/get-private-templates.rst 747 748 .. include:: merchant/get-private-templates-TEMPLATE_ID.rst 749 750 751 Removing template 752 ^^^^^^^^^^^^^^^^^ 753 754 .. include:: merchant/delete-private-templates-TEMPLATE_ID.rst 755 756 757 Using template 758 ^^^^^^^^^^^^^^ 759 760 .. include:: merchant/get-templates-TEMPLATE_ID.rst 761 762 .. include:: merchant/post-templates-TEMPLATE_ID.rst 763 764 .. _merchant-webhooks: 765 766 -------- 767 Webhooks 768 -------- 769 770 The webhook is a backend feature that is used to trigger an HTTP request 771 to some business logic of the merchant in real-time whenever a specified 772 type of event happens. Depending on the type of the event, webhooks 773 may include additional meta-data, such as the amount or contract paid 774 by the customer. For details on setup and supported event payloads, see the 775 `Merchant manual – Setting up a webhook <https://docs.taler.net/taler-merchant-manual.html#setting-up-a-webhook>`_. 776 777 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 778 validate their payloads without guesswork: 779 780 .. ts:def:: WebhookEventType 781 782 enum WebhookEventType { 783 ORDER_CREATED = "order_created", 784 PAY = "pay", 785 REFUND = "refund", 786 ORDER_SETTLED = "order_settled", 787 CATEGORY_ADDED = "category_added", 788 CATEGORY_UPDATED = "category_updated", 789 CATEGORY_DELETED = "category_deleted", 790 INVENTORY_ADDED = "inventory_added", 791 INVENTORY_UPDATED = "inventory_updated", 792 INVENTORY_DELETED = "inventory_deleted" 793 } 794 795 - ``order_created``: fired whenever a new order is created and exposes the ``order_id``, contract, and owning ``instance_id``. 796 - ``pay``: emitted after a payment succeeds; the payload contains the paid contract terms and ``order_id``. 797 - ``refund``: triggered when a refund is approved and includes timestamp, refunded amount, and reason. 798 - ``order_settled``: sent when reconciliation links a wire transfer to an order (includes ``order_id`` and ``wtid``). 799 - ``category_added`` / ``category_updated`` / ``category_deleted``: cover lifecycle changes to product categories. 800 - ``inventory_added`` / ``inventory_updated`` / ``inventory_deleted``: cover lifecycle changes to inventory items, including descriptive fields and stock state. 801 802 For the full payloads associated with each event consult the merchant manual section linked above. 803 804 805 Adding webhooks 806 ^^^^^^^^^^^^^^^ 807 808 .. include:: merchant/post-private-webhooks.rst 809 810 811 Editing webhooks 812 ^^^^^^^^^^^^^^^^ 813 814 .. include:: merchant/patch-private-webhooks-WEBHOOK_ID.rst 815 816 817 Inspecting webhook 818 ^^^^^^^^^^^^^^^^^^ 819 820 .. include:: merchant/get-private-webhooks.rst 821 822 .. include:: merchant/get-private-webhooks-WEBHOOK_ID.rst 823 824 825 Removing webhook 826 ^^^^^^^^^^^^^^^^ 827 828 .. include:: merchant/delete-private-webhooks-WEBHOOK_ID.rst 829 830 831 ------- 832 Reports 833 ------- 834 835 Reports are a backend feature that is used to send periodic 836 reports to the merchant. Reports are sent using notification 837 helper programs which must be configured for each merchant backend. 838 839 Since protocol **v25**. 840 841 Generating reports 842 ^^^^^^^^^^^^^^^^^^ 843 844 .. include:: merchant/post-reports-REPORT_ID.rst 845 846 847 Scheduling periodic reports 848 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 849 850 .. include:: merchant/post-private-reports.rst 851 852 853 Editing scheduled reports 854 ^^^^^^^^^^^^^^^^^^^^^^^^^ 855 856 .. include:: merchant/patch-private-reports-REPORT_ID.rst 857 858 859 Inspecting reporting schedules 860 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 861 862 .. include:: merchant/get-private-reports.rst 863 864 .. include:: merchant/get-private-reports-REPORT_ID.rst 865 866 867 Removing scheduled reports 868 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 869 870 .. include:: merchant/delete-private-reports-REPORT_ID.rst 871 872 873 -------------- 874 Product groups 875 -------------- 876 877 Product groups are used to manage taxes. Each product is in 878 exactly one group and that group is typically used to determine 879 the applicable tax rules. Products that are not assigned explicitly 880 to a group are considered to be in the *default* product group. 881 882 Product groups are different from categories as a product can be 883 in multiple categories. Furthermore, categories are used to make 884 it easier to find products in user interfaces, while product 885 groups are used to make it easier to manage taxes. 886 887 Since protocol **v25**. 888 889 Adding groups 890 ^^^^^^^^^^^^^ 891 892 .. include:: merchant/post-private-groups.rst 893 894 895 Editing groups 896 ^^^^^^^^^^^^^^ 897 898 .. include:: merchant/patch-private-groups-GROUP_ID.rst 899 900 901 Inspecting groups 902 ^^^^^^^^^^^^^^^^^ 903 904 .. include:: merchant/get-private-groups.rst 905 906 907 Removing groups 908 ^^^^^^^^^^^^^^^ 909 910 .. include:: merchant/delete-private-groups-GROUP_ID.rst 911 912 913 ---- 914 Pots 915 ---- 916 917 Pots are a backend feature that is used for accounting. Transacted 918 amounts can be assigned into pots, for example to separate out 919 tips and taxes from revenue for reporting. 920 921 Since protocol **v25**. 922 923 Adding pots 924 ^^^^^^^^^^^ 925 926 .. include:: merchant/post-private-pots.rst 927 928 929 Editing pots 930 ^^^^^^^^^^^^ 931 932 .. include:: merchant/patch-private-pots-POT_ID.rst 933 934 935 936 Inspecting pots 937 ^^^^^^^^^^^^^^^ 938 939 .. include:: merchant/get-private-pots.rst 940 941 .. include:: merchant/get-private-pots-POT_ID.rst 942 943 944 Removing pots 945 ^^^^^^^^^^^^^ 946 947 .. include:: merchant/delete-private-pots-POT_ID.rst 948 949 950 951 ---------------------------------------- 952 Token Families: Subscriptions, Discounts 953 ---------------------------------------- 954 955 This API provides functionalities for the issuance, management, and revocation 956 of token families. Tokens facilitate the implementation of subscriptions and 957 discounts, engaging solely the merchant and the user. Each token family 958 encapsulates details pertaining to its respective tokens, guiding the merchant's 959 backend on the appropriate processing and handling. 960 961 962 Creating token families 963 ^^^^^^^^^^^^^^^^^^^^^^^ 964 965 .. include:: merchant/post-private-tokenfamilies.rst 966 967 968 Updating token families 969 ^^^^^^^^^^^^^^^^^^^^^^^ 970 971 .. include:: merchant/patch-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst 972 973 974 975 Inspecting token families 976 ^^^^^^^^^^^^^^^^^^^^^^^^^ 977 978 .. include:: merchant/get-private-tokenfamilies.rst 979 980 .. include:: merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst 981 982 983 984 Deleting token families 985 ^^^^^^^^^^^^^^^^^^^^^^^ 986 987 .. include:: merchant/delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst 988 989 990 ----------------------- 991 Donau Charity Instances 992 ----------------------- 993 994 A merchant instance can link one or more **Donau charity instances**. 995 Each link associates the instance’s own public key with a charity registered 996 at some Donau service. These links are managed under the private API. 997 998 Permissions 999 ^^^^^^^^^^^ 1000 1001 * ``donau-read`` — list linked charities. 1002 * ``donau-write`` — add or remove charity links. 1003 1004 Listing charity instances 1005 ^^^^^^^^^^^^^^^^^^^^^^^^^ 1006 1007 .. include:: merchant/get-private-donau.rst 1008 1009 Adding a charity instance 1010 ^^^^^^^^^^^^^^^^^^^^^^^^^ 1011 1012 .. include:: merchant/post-private-donau.rst 1013 1014 Deleting a charity instance 1015 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1016 1017 .. include:: merchant/delete-private-donau-DONAU_SERIAL.rst 1018 1019 1020 1021 ------------------ 1022 The Contract Terms 1023 ------------------ 1024 1025 This section describes the overall structure of 1026 the contract terms that are the foundation for 1027 Taler payments. 1028 1029 .. _contract-terms: 1030 1031 The contract terms must have the following structure: 1032 1033 .. ts:def:: ContractTerms 1034 1035 type ContractTerms = ProtoContractTerms & ContractTermsNonce; 1036 1037 .. ts:def:: ContractTermsNonce 1038 1039 interface ContractTermsNonce { 1040 1041 // Nonce generated by the wallet and echoed by the merchant 1042 // in this field when the order is claimed and converted 1043 // into a contract that is bound to a wallet. 1044 nonce: EddsaPublicKey; 1045 } 1046 1047 .. ts:def:: ProtoContractTerms 1048 1049 type ProtoContractTerms = (ContractTermsV1 | ContractTermsV0) & ContractTermsCommon; 1050 1051 1052 .. ts:def:: ContractTermsV1 1053 1054 interface ContractTermsV1 { 1055 // Version 1 supports the ``choices`` array, see 1056 // https://docs.taler.net/design-documents/046-mumimo-contracts.html. 1057 // @since protocol **v21** 1058 version: 1; 1059 1060 // List of contract choices that the customer can select from. 1061 // @since protocol **v21** 1062 choices: ContractChoice[]; 1063 1064 // Map of storing metadata and issue keys of 1065 // token families referenced in this contract. 1066 // @since protocol **v21** 1067 token_families: { [token_family_slug: string]: ContractTokenFamily }; 1068 } 1069 1070 .. ts:def:: ContractTermsV0 1071 1072 interface ContractTermsV0 { 1073 // Defaults to version 0. 1074 version?: 0; 1075 1076 // Total price for the transaction, including tip. 1077 // The exchange will subtract deposit fees from that amount 1078 // before transferring it to the merchant. 1079 amount: Amount; 1080 1081 // Optional tip amount. Must match the currency of ``amount``. 1082 // Since protocol **v25**. 1083 tip?: Amount; 1084 1085 // Maximum total deposit fee accepted by the merchant for this contract. 1086 // Overrides defaults of the merchant instance. 1087 max_fee: Amount; 1088 } 1089 1090 .. ts:def:: ContractTermsCommon 1091 1092 interface ContractTermsCommon { 1093 // Human-readable description of the whole purchase. 1094 summary: string; 1095 1096 // Map from IETF BCP 47 language tags to localized summaries. 1097 summary_i18n?: { [lang_tag: string]: string }; 1098 1099 // Unique, free-form identifier for the proposal. 1100 // Must be unique within a merchant instance. 1101 // For merchants that do not store proposals in their DB 1102 // before the customer paid for them, the ``order_id`` can be used 1103 // by the frontend to restore a proposal from the information 1104 // encoded in it (such as a short product identifier and timestamp). 1105 order_id: string; 1106 1107 // URL where the same contract could be ordered again (if 1108 // available). Returned also at the public order endpoint 1109 // for people other than the actual buyer (hence public, 1110 // in case order IDs are guessable). 1111 public_reorder_url?: string; 1112 1113 // URL that will show that the order was successful after 1114 // it has been paid for. Optional, but either ``fulfillment_url`` 1115 // or ``fulfillment_message`` must be specified in every 1116 // contract terms. 1117 // 1118 // If a non-unique fulfillment URL is used, a customer can only 1119 // buy the order once and will be redirected to a previous purchase 1120 // when trying to buy an order with the same fulfillment URL a second 1121 // time. This is useful for digital goods that a customer only needs 1122 // to buy once but should be able to repeatedly download. 1123 // 1124 // For orders where the customer is expected to be able to make 1125 // repeated purchases (for equivalent goods), the fulfillment URL 1126 // should be made unique for every order. The easiest way to do 1127 // this is to include a unique order ID in the fulfillment URL. 1128 // 1129 // When POSTing to the merchant, the placeholder text "${ORDER_ID}" 1130 // is be replaced with the actual order ID (useful if the 1131 // order ID is generated server-side and needs to be 1132 // in the URL). Note that this placeholder can only be used once. 1133 // Front-ends may use other means to generate a unique fulfillment URL. 1134 fulfillment_url?: string; 1135 1136 // Message shown to the customer after paying for the order. 1137 // Either fulfillment_url or fulfillment_message must be specified. 1138 fulfillment_message?: string; 1139 1140 // Map from IETF BCP 47 language tags to localized fulfillment 1141 // messages. 1142 fulfillment_message_i18n?: { [lang_tag: string]: string }; 1143 1144 // List of products that are part of the purchase (see `ProductSold`). 1145 products: ProductSold[]; 1146 1147 // Time when this contract was generated. 1148 timestamp: Timestamp; 1149 1150 // After this deadline has passed, no refunds will be accepted. 1151 refund_deadline: Timestamp; 1152 1153 // After this deadline, the merchant won't accept payments for the contract. 1154 pay_deadline: Timestamp; 1155 1156 // Transfer deadline for the exchange. Must be in the 1157 // deposit permissions of coins used to pay for this order. 1158 wire_transfer_deadline: Timestamp; 1159 1160 // Merchant's public key used to sign this proposal; this information 1161 // is typically added by the backend. Note that this can be an ephemeral key. 1162 merchant_pub: EddsaPublicKey; 1163 1164 // Base URL of the (public!) merchant backend API. 1165 // Must be an absolute URL that ends with a slash. 1166 merchant_base_url: string; 1167 1168 // More info about the merchant, see below. 1169 merchant: Merchant; 1170 1171 // The hash of the merchant instance's wire details. 1172 h_wire: HashCode; 1173 1174 // Wire transfer method identifier for the wire method associated with ``h_wire``. 1175 // The wallet may only select exchanges via a matching auditor if the 1176 // exchange also supports this wire method. 1177 // The wire transfer fees must be added based on this wire transfer method. 1178 wire_method: string; 1179 1180 // Exchanges that the merchant accepts even if it does not accept any auditors that audit them. 1181 exchanges: Exchange[]; 1182 1183 // Delivery location for (all!) products. 1184 delivery_location?: Location; 1185 1186 // Time indicating when the order should be delivered. 1187 // May be overwritten by individual products. 1188 delivery_date?: Timestamp; 1189 1190 // Specifies for how long the wallet should try to get an 1191 // automatic refund for the purchase. If this field is 1192 // present, the wallet should wait for a few seconds after 1193 // the purchase and then automatically attempt to obtain 1194 // a refund. The wallet should probe until "delay" 1195 // after the payment was successful (i.e. via long polling 1196 // or via explicit requests with exponential back-off). 1197 // 1198 // In particular, if the wallet is offline 1199 // at that time, it MUST repeat the request until it gets 1200 // one response from the merchant after the delay has expired. 1201 // If the refund is granted, the wallet MUST automatically 1202 // recover the payment. This is used in case a merchant 1203 // knows that it might be unable to satisfy the contract and 1204 // desires for the wallet to attempt to get the refund without any 1205 // customer interaction. Note that it is NOT an error if the 1206 // merchant does not grant a refund. 1207 auto_refund?: RelativeTime; 1208 1209 // Extra data that is only interpreted by the merchant frontend. 1210 // Useful when the merchant needs to store extra information on a 1211 // contract without storing it separately in their database. 1212 // Must really be an Object (not a string, integer, float or array). 1213 extra?: Object; 1214 1215 // Minimum age the buyer must have (in years). Default is 0. 1216 // This value is at least as large as the maximum over all 1217 // mimimum age requirements of the products in this contract. 1218 // It might also be set independent of any product, due to 1219 // legal requirements. 1220 minimum_age?: Integer; 1221 1222 // Default money pot to use for this product, applies to the 1223 // amount remaining that was not claimed by money pots of 1224 // products or taxes. Not useful to wallets, only for 1225 // merchant-internal accounting. If not given, the remaining 1226 // account is simply not accounted for in any money pot. 1227 // Since **v25**. 1228 default_money_pot?: Integer; 1229 1230 // Latest time until which the good or service specified in the 1231 // contract may be picked up by the customer. This is usually 1232 // for digital goods where the customer has a finite window 1233 // for downloading the resource(s). 1234 max_pickup_time?: Timestamp; 1235 } 1236 1237 .. ts:def:: ContractChoice 1238 1239 interface ContractChoice { 1240 // Price to be paid for this choice. Could be 0. 1241 // The price is in addition to other instruments, 1242 // such as rations and tokens. 1243 // The exchange will subtract deposit fees from that amount 1244 // before transferring it to the merchant. 1245 amount: Amount; 1246 1247 // Optional tip amount. Must match the currency of ``amount``. 1248 // Since protocol **v25**. 1249 tip?: Amount; 1250 1251 // Human readable description of the semantics of the choice 1252 // within the contract to be shown to the user at payment. 1253 description?: string; 1254 1255 // Map from IETF 47 language tags to localized descriptions. 1256 description_i18n?: { [lang_tag: string]: string }; 1257 1258 // List of inputs the wallet must provision (all of them) to 1259 // satisfy the conditions for the contract. 1260 inputs: ContractInput[]; 1261 1262 // List of outputs the merchant promises to yield (all of them) 1263 // once the contract is paid. 1264 outputs: ContractOutput[]; 1265 1266 // Maximum total deposit fee accepted by the merchant for this contract. 1267 max_fee: Amount; 1268 } 1269 1270 .. ts:def:: ContractInput 1271 1272 // For now, only tokens are supported as inputs. 1273 type ContractInput = ContractInputToken; 1274 1275 .. ts:def:: ContractInputToken 1276 1277 interface ContractInputToken { 1278 type: "token"; 1279 1280 // Slug of the token family in the 1281 // ``token_families`` map on the order. 1282 token_family_slug: string; 1283 1284 // Number of tokens of this type required. 1285 // Defaults to one if the field is not provided. 1286 count?: Integer; 1287 }; 1288 1289 .. ts:def:: ContractOutput 1290 1291 // For now, only tokens are supported as outputs. 1292 type ContractOutput = ContractOutputToken | ContractOutputTaxReceipt; 1293 1294 .. ts:def:: ContractOutputToken 1295 1296 interface ContractOutputToken { 1297 type: "token"; 1298 1299 // Slug of the token family in the 1300 // 'token_families' map on the top-level. 1301 token_family_slug: string; 1302 1303 // Number of tokens to be issued. 1304 // Defaults to one if the field is not provided. 1305 count?: Integer; 1306 1307 // Index of the public key for this output token 1308 // in the `ContractTokenFamily` ``keys`` array. 1309 key_index: Integer; 1310 1311 } 1312 1313 .. ts:def:: ContractOutputTaxReceipt 1314 1315 interface ContractOutputTaxReceipt { 1316 1317 // Tax receipt output. 1318 type: "tax-receipt"; 1319 1320 // Array of base URLs of donation authorities that can be 1321 // used to issue the tax receipts. The client must select one. 1322 donau_urls: string[]; 1323 1324 // Total amount that will be on the tax receipt. 1325 amount: Amount; 1326 1327 } 1328 1329 .. ts:def:: ContractTokenFamily 1330 1331 interface ContractTokenFamily { 1332 // Human-readable name of the token family. 1333 name: string; 1334 1335 // Human-readable description of the semantics of 1336 // this token family (for display). 1337 description: string; 1338 1339 // Map from IETF BCP 47 language tags to localized descriptions. 1340 description_i18n?: { [lang_tag: string]: string }; 1341 1342 // Public keys used to validate tokens issued by this token family. 1343 keys: TokenIssuePublicKey[]; 1344 1345 // Kind-specific information of the token 1346 details: ContractTokenDetails; 1347 1348 // Must a wallet understand this token type to 1349 // process contracts that use or issue it? 1350 critical: boolean; 1351 }; 1352 1353 .. ts:def:: TokenIssuePublicKey 1354 1355 type TokenIssuePublicKey = 1356 | TokenIssueRsaPublicKey 1357 | TokenIssueCsPublicKey; 1358 1359 .. ts:def:: TokenIssueRsaPublicKey 1360 1361 interface TokenIssueRsaPublicKey { 1362 cipher: "RSA"; 1363 1364 // RSA public key. 1365 rsa_pub: RsaPublicKey; 1366 1367 // Start time of this key's signatures validity period. 1368 signature_validity_start: Timestamp; 1369 1370 // End time of this key's signatures validity period. 1371 signature_validity_end: Timestamp; 1372 1373 } 1374 1375 .. ts:def:: TokenIssueCsPublicKey 1376 1377 interface TokenIssueCsPublicKey { 1378 cipher: "CS"; 1379 1380 // CS public key. 1381 cs_pub: Cs25519Point; 1382 1383 // Start time of this key's signatures validity period. 1384 signature_validity_start: Timestamp; 1385 1386 // End time of this key's signatures validity period. 1387 signature_validity_end: Timestamp; 1388 1389 } 1390 1391 .. ts:def:: ContractTokenDetails 1392 1393 type ContractTokenDetails = 1394 | ContractSubscriptionTokenDetails 1395 | ContractDiscountTokenDetails; 1396 1397 .. ts:def:: ContractSubscriptionTokenDetails 1398 1399 interface ContractSubscriptionTokenDetails { 1400 class: "subscription"; 1401 1402 // Array of domain names where this subscription 1403 // can be safely used (e.g. the issuer warrants that 1404 // these sites will re-issue tokens of this type 1405 // if the respective contract says so). May contain 1406 // "*" for any domain or subdomain. 1407 trusted_domains: string[]; 1408 }; 1409 1410 .. ts:def:: ContractDiscountTokenDetails 1411 1412 interface ContractDiscountTokenDetails { 1413 class: "discount"; 1414 1415 // Array of domain names where this discount token 1416 // is intended to be used. May contain "*" for any 1417 // domain or subdomain. Users should be warned about 1418 // sites proposing to consume discount tokens of this 1419 // type that are not in this list that the merchant 1420 // is accepting a coupon from a competitor and thus 1421 // may be attaching different semantics (like get 20% 1422 // discount for my competitors 30% discount token). 1423 expected_domains: string[]; 1424 }; 1425 1426 1427 The wallet must select an exchange that either the merchant accepts directly by 1428 listing it in the exchanges array, or for which the merchant accepts an auditor 1429 that audits that exchange by listing it in the auditors array. 1430 1431 The `ProductSold` object describes a product and the quantity 1432 being purchased from the merchant as well as possibly the price 1433 and applicable taxes. 1434 It has the following structure: 1435 1436 .. ts:def:: ProductSold 1437 1438 interface ProductSold { 1439 1440 // Merchant-internal identifier for the product. 1441 product_id?: string; 1442 1443 // Name of the product. 1444 // Since API version **v20**. Optional only for 1445 // backwards-compatibility, should be considered mandatory 1446 // moving forward! 1447 product_name?: string; 1448 1449 // Human-readable product description. 1450 description: string; 1451 1452 // Map from IETF BCP 47 language tags to localized descriptions. 1453 description_i18n?: { [lang_tag: string]: string }; 1454 1455 // Legacy integer portion of the quantity to deliver defaults to 1 if not specified. 1456 quantity?: Integer; 1457 1458 // Preferred quantity string using "<integer>[.<fraction>]" syntax with up to six fractional digits. 1459 unit_quantity?: string; 1460 1461 // Unit in which the product is measured (liters, kilograms, packages, etc.). 1462 unit?: string; 1463 1464 // The price of the product; 1465 // Deprecated since **v25**; 1466 // this is the total price 1467 // for ``quantity`` times ``unit`` of this product. 1468 price?: Amount; 1469 1470 // Price of ``unit_quantity`` units of the product in various currencies. 1471 // Zero or absent implies that the product is not sold 1472 // separately. 1473 // Since API version **v25**. 1474 prices?: Amount[]; 1475 1476 // True if the ``prices`` given are the net price, 1477 // false if they are the gross price. Note that even ``prices`` are the 1478 // gross price, ``taxes`` may be missing if the merchant configured 1479 // gross ``prices`` but did not configure any ``taxes``. 1480 // Similarly, the merchant may have configured net ``prices`` 1481 // for products but deals with taxes on a per-order basis. Thus, it 1482 // may not always be possible to compute the gross price from the net 1483 // price for an individual product, necessitating this flag. 1484 // Since protocol **vTAXES**. 1485 prices_are_net: boolean; 1486 1487 // An optional base64-encoded product image. 1488 image?: ImageDataUrl; 1489 1490 // A list of taxes paid by the merchant for this product. Can be empty. 1491 // Will likely change soon! 1492 taxes?: Tax[]; 1493 1494 // Time indicating when this product should be delivered. 1495 delivery_date?: Timestamp; 1496 1497 // Money pot to use for this product, overrides value from 1498 // the inventory if given. Not useful to wallets, only for 1499 // merchant-internal accounting. 1500 // Since **v25**. 1501 product_money_pot?: Integer; 1502 1503 } 1504 1505 .. ts:def:: Tax 1506 1507 interface Tax { 1508 // The name of the tax. 1509 name: string; 1510 1511 // Amount paid in tax. 1512 tax: Amount; 1513 } 1514 1515 .. ts:def:: Merchant 1516 1517 interface Merchant { 1518 // The merchant's legal name of business. 1519 name: string; 1520 1521 // Email address for contacting the merchant. 1522 email?: string; 1523 1524 // Label for a location with the business address of the merchant. 1525 website?: string; 1526 1527 // An optional base64-encoded product image. 1528 logo?: ImageDataUrl; 1529 1530 // Label for a location with the business address of the merchant. 1531 address?: Location; 1532 1533 // Label for a location that denotes the jurisdiction for disputes. 1534 // Some of the typical fields for a location (such as a street address) may be absent. 1535 jurisdiction?: Location; 1536 } 1537 1538 1539 .. ts:def:: Location 1540 1541 // Delivery location, loosely modeled as a subset of 1542 // ISO20022's PostalAddress25. 1543 interface Location { 1544 // Nation with its own government. 1545 country?: string; 1546 1547 // Identifies a subdivision of a country such as state, region, county. 1548 country_subdivision?: string; 1549 1550 // Identifies a subdivision within a country sub-division. 1551 district?: string; 1552 1553 // Name of a built-up area, with defined boundaries, and a local government. 1554 town?: string; 1555 1556 // Specific location name within the town. 1557 town_location?: string; 1558 1559 // Identifier consisting of a group of letters and/or numbers that 1560 // is added to a postal address to assist the sorting of mail. 1561 post_code?: string; 1562 1563 // Name of a street or thoroughfare. 1564 street?: string; 1565 1566 // Name of the building or house. 1567 building_name?: string; 1568 1569 // Number that identifies the position of a building on a street. 1570 building_number?: string; 1571 1572 // Free-form address lines, should not exceed 7 elements. 1573 address_lines?: string[]; 1574 } 1575 1576 .. ts:def:: Auditor 1577 1578 interface Auditor { 1579 // Official name. 1580 name: string; 1581 1582 // Auditor's public key. 1583 auditor_pub: EddsaPublicKey; 1584 1585 // Base URL of the auditor. 1586 url: string; 1587 } 1588 1589 .. ts:def:: Exchange 1590 1591 interface Exchange { 1592 // The exchange's base URL. 1593 url: string; 1594 1595 // How much would the merchant like to use this exchange. 1596 // The wallet should use a suitable exchange with high 1597 // priority. The following priority values are used, but 1598 // it should be noted that they are NOT in any way normative. 1599 // 1600 // 0: likely it will not work (recently seen with account 1601 // restriction that would be bad for this merchant) 1602 // 512: merchant does not know, might be down (merchant 1603 // did not yet get /wire response). 1604 // 1024: good choice (recently confirmed working) 1605 priority: Integer; 1606 1607 // Master public key of the exchange. 1608 master_pub: EddsaPublicKey; 1609 1610 // Maximum amount that the merchant could be paid 1611 // using this exchange (due to legal limits). 1612 // New in protocol **v17**. 1613 // Optional, no limit if missing. 1614 max_contribution?: Amount; 1615 } 1616 1617 In addition to the fields described above, 1618 each object (from ``ContractTerms`` down) 1619 can mark certain fields as "forgettable" by listing the names of those fields 1620 in a special peer field ``_forgettable``. 1621 (See :ref:`Private order data cleanup <private-order-data-cleanup>`.)