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