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