commit 237507ccf48084b712f5b6895bb8b24dc104e3a4 parent 0a6d6af74284237f41d6236feba36bd9b843ddb8 Author: Christian Grothoff <christian@grothoff.org> Date: Sun, 8 Feb 2026 22:22:43 +0100 break up merchant docs into one file per endpoint Diffstat:
| M | core/api-merchant.rst | | | 7214 | +++++-------------------------------------------------------------------------- |
| A | core/merchant/any-star.rst | | | 7 | +++++++ |
| A | core/merchant/delete-management-instances-INSTANCE.rst | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/delete-private-accounts-H_WIRE.rst | | | 10 | ++++++++++ |
| A | core/merchant/delete-private-categories-CATEGORY_ID.rst | | | 13 | +++++++++++++ |
| A | core/merchant/delete-private-donau-DONAU_SERIAL.rst | | | 12 | ++++++++++++ |
| A | core/merchant/delete-private-groups-GROUP_SERIAL.rst | | | 13 | +++++++++++++ |
| A | core/merchant/delete-private-orders-ORDER_ID.rst | | | 14 | ++++++++++++++ |
| A | core/merchant/delete-private-otp-devices-DEVICE_ID.rst | | | 10 | ++++++++++ |
| A | core/merchant/delete-private-pots-POT_SERIAL.rst | | | 16 | ++++++++++++++++ |
| A | core/merchant/delete-private-products-PRODUCT_ID.rst | | | 15 | +++++++++++++++ |
| A | core/merchant/delete-private-reports-REPORT_SERIAL.rst | | | 13 | +++++++++++++ |
| A | core/merchant/delete-private-templates-TEMPLATE_ID.rst | | | 12 | ++++++++++++ |
| A | core/merchant/delete-private-token.rst | | | 8 | ++++++++ |
| A | core/merchant/delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst | | | 14 | ++++++++++++++ |
| A | core/merchant/delete-private-tokens-SERIAL.rst | | | 19 | +++++++++++++++++++ |
| A | core/merchant/delete-private-transfers-TID.rst | | | 15 | +++++++++++++++ |
| A | core/merchant/delete-private-units-UNIT.rst | | | 14 | ++++++++++++++ |
| A | core/merchant/delete-private-webhooks-WEBHOOK_ID.rst | | | 13 | +++++++++++++ |
| A | core/merchant/get-config.rst | | | 176 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-exchanges.rst | | | 47 | +++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-management-instances-INSTANCE-kyc.rst | | | 191 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-management-instances-INSTANCE-statistics-amount-SLUG.rst | | | 77 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-management-instances-INSTANCE-statistics-counter-SLUG.rst | | | 78 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-management-instances-INSTANCE-statistics-report-NAME.rst | | | 109 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-management-instances-INSTANCE.rst | | | 94 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-management-instances.rst | | | 52 | ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-orders-ORDER_ID.rst | | | 119 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-accounts-H_WIRE.rst | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-accounts.rst | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-categories-CATEGORY_ID.rst | | | 39 | +++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-categories.rst | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-donau.rst | | | 55 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-groups.rst | | | 51 | +++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-incoming-ID.rst | | | 60 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-incoming.rst | | | 87 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-orders-ORDER_ID.rst | | | 246 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-orders.rst | | | 78 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-otp-devices-DEVICE_ID.rst | | | 80 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-otp-devices.rst | | | 33 | +++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-pos.rst | | | 101 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-pots-POT_SERIAL.rst | | | 31 | +++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-pots.rst | | | 51 | +++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-products-PRODUCT_ID.rst | | | 99 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-products.rst | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-reports-REPORT_SERIAL.rst | | | 57 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-reports.rst | | | 51 | +++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-templates-TEMPLATE_ID.rst | | | 49 | +++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-templates.rst | | | 37 | +++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst | | | 73 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-tokenfamilies.rst | | | 55 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-tokens.rst | | | 58 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-transfers.rst | | | 78 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-units-UNIT.rst | | | 12 | ++++++++++++ |
| A | core/merchant/get-private-units.rst | | | 52 | ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-webhooks-WEBHOOK_ID.rst | | | 36 | ++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-private-webhooks.rst | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-products-IMAGE_HASH-image.rst | | | 23 | +++++++++++++++++++++++ |
| A | core/merchant/get-sessions-SESSION_ID.rst | | | 53 | +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/get-templates-TEMPLATE_ID.rst | | | 170 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-management-instances-INSTANCE.rst | | | 86 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-accounts-H_WIRE.rst | | | 36 | ++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-categories-CATEGORY_ID.rst | | | 15 | +++++++++++++++ |
| A | core/merchant/patch-private-groups-GROUP_ID.rst | | | 18 | ++++++++++++++++++ |
| A | core/merchant/patch-private-orders-ORDER_ID-forget.rst | | | 52 | ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-otp-devices-DEVICE_ID.rst | | | 42 | ++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-pots-POT_ID.rst | | | 47 | +++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-products-PRODUCT_ID.rst | | | 127 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-reports-REPORT_ID.rst | | | 16 | ++++++++++++++++ |
| A | core/merchant/patch-private-templates-TEMPLATE_ID.rst | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-units-UNIT.rst | | | 47 | +++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/patch-private-webhooks-WEBHOOK_ID.rst | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-challenge-CHALLENGE_ID-confirm.rst | | | 40 | ++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-challenge-CHALLENGE_ID.rst | | | 49 | +++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-instances-INSTANCE-forgot-password.rst | | | 25 | +++++++++++++++++++++++++ |
| A | core/merchant/post-instances.rst | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-management-instances-INSTANCE-auth.rst | | | 67 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-management-instances.rst | | | 95 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-orders-ORDER_ID-abort.rst | | | 148 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-orders-ORDER_ID-claim.rst | | | 45 | +++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-orders-ORDER_ID-paid.rst | | | 62 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-orders-ORDER_ID-pay.rst | | | 354 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-orders-ORDER_ID-refund.rst | | | 121 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-orders-ORDER_ID-unclaim.rst | | | 42 | ++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-accounts.rst | | | 83 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-categories.rst | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-donau.rst | | | 35 | +++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-groups.rst | | | 40 | ++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-orders-ORDER_ID-refund.rst | | | 59 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-orders.rst | | | 494 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-otp-devices.rst | | | 46 | ++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-pots.rst | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-products-PRODUCT_ID-lock.rst | | | 63 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-products.rst | | | 151 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-reports.rst | | | 60 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-templates.rst | | | 136 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-token.rst | | | 70 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-tokenfamilies.rst | | | 76 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-transfers.rst | | | 39 | +++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-units.rst | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-private-webhooks.rst | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
| A | core/merchant/post-reports-REPORT_ID.rst | | | 31 | +++++++++++++++++++++++++++++++ |
| A | core/merchant/post-templates-TEMPLATE_ID.rst | | | 89 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
104 files changed, 6935 insertions(+), 6832 deletions(-)
diff --git a/core/api-merchant.rst b/core/api-merchant.rst @@ -125,13 +125,7 @@ Generic Responses The following (error) responses are applicable to all endpoints unless specified otherwise. -.. http:any:: * - - :http:statuscode:`403 Forbidden`: - * ``TALER_EC_GENERIC_FORBIDDEN``: Missing permissions. - * ``TALER_EC_MERCHANT_ACCOUNT_TWOFA_UNCONFIRMED``: The account - needs to confirm authentication factors before it can proceed - with the request. +.. include:: merchant/any-star.rst -------------- Authentication @@ -186,182 +180,7 @@ Configuration API The configuration API exposes basic information about a merchant backend, such as the implemented version of the protocol and the currency used. -.. http:get:: /config - - Return the protocol version and currency supported by this merchant backend. - This specification corresponds to ``current`` protocol being version **v24**. - - **Response:** - - :http:statuscode:`200 OK`: - The body is a `MerchantVersionResponse`. - - **Details:** - - .. ts:def:: MerchantVersionResponse - - interface MerchantVersionResponse { - // libtool-style representation of the Merchant protocol version, see - // https://www.gnu.org/software/libtool/manual/html_node/Versioning.html#Versioning - // The format is "current:revision:age". - version: string; - - // Name of the protocol. - name: "taler-merchant"; - - // URN of the implementation (needed to interpret 'revision' in version). - // @since **v8**, may become mandatory in the future. - implementation?: string; - - // Default (!) currency supported by this backend. - // This is the currency that the backend should - // suggest by default to the user when entering - // amounts. See ``currencies`` for a list of - // supported currencies and how to render them. - currency: string; - - // Which Persona should be used by default by new clients in the SPA. - // Can be changed locally per browers under "Personalization". - // Possible values include "expert", "offline-vending-machine", - // "point-of-sale", "digital-publishing", "e-commerce" and "developer". - // @since **v23**. - default_persona: string; - - // How services should render currencies supported - // by this backend. Maps - // currency codes (e.g. "EUR" or "KUDOS") to - // the respective currency specification. - // All currencies in this map are supported by - // the backend. Note that the actual currency - // specifications are a *hint* for applications - // that would like *advice* on how to render amounts. - // Applications *may* ignore the currency specification - // if they know how to render currencies that they are - // used with. - currencies: { currency : CurrencySpecification}; - - // Maps available report generator configuration section names - // to descriptions of the respective report generator. - // Since **v25**. - report_generators: { section_name : string}; - - // Posix regular expression for allowed phone numbers; - // applies when creating or patching an instance. - // Optional, can be NULL for no restrictions. - // Since **v26**. - phone_regex?: string; - - // Array of exchanges trusted by the merchant. - // @since **v6**. - exchanges: ExchangeConfigInfo[]; - - // Set when the merchant supports - // self-provisioning instances. - // Since protocol **v21** - have_self_provisioning: boolean; - - // True if this merchant backend supports the Donau - // extension and can thus issue donation receipts. - // Should primarily be used to control the SPA's CRUD - // functionality for Donau. - // @since **v21** - have_donau: boolean; - - // Tan channels that are required - // to be confirmed for an instance to - // be useable. - // @since **v21** - mandatory_tan_channels?: TanChannel[]; - - // Space-separated list of enabled payment target types. - // Useful if the SPA should not show allow adding other - // types of bank accounts. "*" is used to represent no - // restriction. - // @since **v22** - payment_target_types: string; - - // Regular expression representing further restrictions - // on allowed payment targets. Any "payto://"-URI supplied - // for a bank account must match the given regular expression. - // For example, "payto://iban/CH.*" would restrict the system - // to only Swiss bank accounts. - // Optional, no restrictions are imposed if the field is - // absent. - // @since **v22** - // CAUTION: Likely to be removed/deprecated, - // as we'll want an array of restrictions with the - // same format as the exchange uses, as this allows - // proper i18n and spec/code reuse. - payment_target_regex? string; - - // Default payment delay for new instances. - // This is the default to use for new instances, see the instance value for - // the instance-specific default. - // A value of "forever" is not allowed. - // @since **v22** - default_pay_delay: RelativeTime; - - // If the frontend does NOT specify a refund deadline, how long should - // refunds be allowed by default? - // This is the default to use for new instances, see the instance value for - // the instance-specific default. - // A value of "forever" is not allowed. - // @since **v22** - default_refund_delay: RelativeTime; - - // Default wire transfer delay for new instances. - // This is the default to use for new instances, see the instance value for - // the instance-specific default. - // A value of "forever" is not allowed. - // @since **v22** - default_wire_transfer_delay: RelativeTime; - - // Default interval to which wire deadlines computed by - // adding the wire_transfer_delay on top of the refund - // deadline should be rounded up to. - // @since **v23** - default_wire_transfer_rounding_interval: RoundingInterval; - } - - .. ts:def:: TanChannel - - enum TanChannel { - SMS = "sms", - EMAIL = "email" - } - - .. ts:def:: RoundingInterval - - enum RoundingInterval { - NONE = "NONE", - SECOND = "SECOND", - MINUTE = "MINUTE", - HOUR = "HOUR", - DAY = "DAY", - WEEK = "WEEK", - MONTH = "MONTH", - QUARTER = "QUARTER", - YEAR = "YEAR" - } - - .. ts:def:: ExchangeConfigInfo - - interface ExchangeConfigInfo { - - // Base URL of the exchange REST API. - base_url: string; - - // Currency for which the merchant is configured - // to trust the exchange. - // May not be the one the exchange actually uses, - // but is the only one we would trust this exchange for. - currency: string; - - // Offline master public key of the exchange. The - // ``/keys`` data must be signed with this public - // key for us to trust it. - master_pub: EddsaPublicKey; - } +.. include:: merchant/get-config.rst .. include:: tos.rst @@ -375,53 +194,7 @@ currencies, master public keys and the status of the merchant backend's download of the ``/keys`` from the exchange. This is mostly useful to diagnose configuration problems. -.. http:get:: /exchanges - - Return information about exchanges configured for this merchant backend. - @since **v26**. - - **Response:** - - :http:statuscode:`200 OK`: - The body is a `ExchangeStatusResponse`. - - **Details:** - - .. ts:def:: ExchangeStatusResponse - - interface ExchangeStatusResponse { - - exchanges: ExchangeStatusDetail[]; - - } - - .. ts:def:: ExchangeStatusDetail - - interface ExchangeStatusDetail { - - // Base URL of the exchange this is about. - exchange_url: string; - - // Time when the backend will download ``/keys`` next. - next_download: Timestamp; - - // Time when the current ``/keys`` response is expected to - // expire. Missing if we do not have one. - keys_expiration?: Timestamp; - - // HTTP status code returned by the exchange when we asked for - // ``/keys``. 0 if we did not receive an HTTP status code. - // Usually 200 for success. - keys_http_status: Integer; - - // Numeric `error code <error-codes>` indicating an - // error we had processing the ``/keys`` response. - keys_ec: Integer; - - // Human-readable error description matching ``keys_ec``. - keys_hint: string; - - } +.. include:: merchant/get-exchanges.rst --------------- Two Factor Auth @@ -480,99 +253,12 @@ remain absolutely unchanged. Requesting challenges ^^^^^^^^^^^^^^^^^^^^^ -.. http:post:: [/instances/$INSTANCE]/challenge/$CHALLENGE_ID - - Send TAN code for the ``CHALLENGE_ID`` challenge. - - This request can be posted several times to trigger TAN retransmission when - the current code has expired or too many confirmation attempts have been - made. - - This endpoint is not authenticated, it may be used even when mandatory TAN - channels were not validated yet. - - @since **v21** - - **Request:** - - The request body must be a JSON object, but can otherwise be empty - (so just send '{}'). - - **Response:** - - :http:statuscode:`200 Ok`: - The TAN code has been sent. The body will be a `ChallengeRequestResponse`. - :http:statuscode:`404 Not Found`: - The challenge was not found. - Returned with ``TALER_EC_MERCHANT_TAN_CHALLENGE_UNKNOWN``. - :http:statuscode:`410 Gone`: - The challenge was already solved. - Returned with ``TALER_EC_MERCHANT_TAN_CHALLENGE_SOLVED``. - :http:statuscode:`429 Too many requests`: - Too many challenges are active right now, - you must wait or confirm current challenges. - Returned with ``TALER_EC_MERCHANT_TAN_TOO_EARLY``. - :http:statuscode:`502 Bad Gateway`: - TAN transmition via ``tan_channel`` failed. - Returned with ``TALER_EC_MERCHANT_MFA_HELPER_EXEC_FAILED``. - - **Details:** - - .. ts:def:: ChallengeRequestResponse - - interface ChallengeRequestResponse { - // How long does the client have to solve the - // challenge. - solve_expiration: Timestamp; - - // What is the earlist time at which the client - // may request a new challenge to be transmitted? - earliest_retransmission: Timestamp; - } +.. include:: merchant/post-challenge-CHALLENGE_ID.rst Solving challenges ^^^^^^^^^^^^^^^^^^ -.. http:post:: [/instances/$INSTANCE]/challenge/$CHALLENGE_ID/confirm - - Solves the ``CHALLENGE_ID`` challenge and allows performing the protected operation. - - @since **v21** - - When the challenge is confirmed, you can call the protected endpoint again - with ``CHALLENGE_ID`` in the ``Taler-Challenge-Ids`` HTTP header and the - original request body. - - This endpoints is not authenticated for token creation challenges. Too many - unsuccessful attempts to confirm token creation challenges block the - account. - - This endpoint may be used even when mandatory TAN channels - were not validated yet. - - **Request:** - - .. ts:def:: MerchantChallengeSolveRequest - - interface MerchantChallengeSolveRequest { - - // The TAN code that solves $CHALLENGE_ID. - tan: string; - } - - **Response:** - - :http:statuscode:`204 No Content`: - The challenge was solved. - :http:statuscode:`404 Not Found`: - The challenge was not found. - Returned with ``TALER_EC_MERCHANT_TAN_CHALLENGE_UNKNOWN``. - :http:statuscode:`409 Conflict`: - Wrong TAN, returned with an - error code of ``TALER_EC_MERCHANT_TAN_CHALLENGE_FAILED``. - :http:statuscode:`429 Too many requests`: - Too many failed confirmation attempts, a new TAN must be requested. - Returned with ``TALER_EC_MERCHANT_TAN_TOO_MANY_ATTEMPTS``. +.. include:: merchant/post-challenge-CHALLENGE_ID-confirm.rst ---------- Wallet API @@ -601,6443 +287,663 @@ where order IDs are predictable and malicious actors may try to claim orders (say in a case where stocks are limited). -.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/claim +.. include:: merchant/post-orders-ORDER_ID-claim.rst - Wallet claims ownership (via nonce) over an order. By claiming - an order, the wallet obtains the full contract terms, and thereby - implicitly also the hash of the contract terms it needs for the - other ``public`` APIs to authenticate itself as the wallet that - is indeed eligible to inspect this particular order's status. +.. include:: merchant/post-orders-ORDER_ID-unclaim.rst - **Request:** - The request must be a `ClaimRequest`. +Making the payment +^^^^^^^^^^^^^^^^^^ - **Response:** +.. include:: merchant/post-orders-ORDER_ID-pay.rst - :http:statuscode:`200 OK`: - The client has successfully claimed the order. - The response contains the :ref:`contract terms <contract-terms>`. - :http:statuscode:`404 Not found`: - The backend is unaware of the instance or order. - :http:statuscode:`409 Conflict`: - Someone else has already claimed the same order ID with a different nonce. - **Details:** +Querying payment status +^^^^^^^^^^^^^^^^^^^^^^^ - .. ts:def:: ClaimRequest +.. include:: merchant/get-orders-ORDER_ID.rst - interface ClaimRequest { - // Nonce to identify the wallet that claimed the order. - nonce: EddsaPublicKey; - // Token that authorizes the wallet to claim the order. - // *Optional* as the merchant may not have required it - // (``create_token`` set to ``false`` in `PostOrderRequest`). - token?: ClaimToken; - } +.. include:: merchant/get-sessions-SESSION_ID.rst - .. ts:def:: ClaimResponse - interface ClaimResponse { - // Contract terms of the claimed order - contract_terms: ContractTerms; +Demonstrating payment +^^^^^^^^^^^^^^^^^^^^^ - // Signature by the merchant over the contract terms. - sig: EddsaSignature; - } +In case a wallet has already paid for an order, this is a fast way of proving +to the merchant that the order was already paid. The alternative would be to +replay the original payment, but simply providing the merchant's signature +saves bandwidth and computation time. -.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/unclaim +Demonstrating payment is useful in case a digital good was made available +only to clients with a particular session ID: if that session ID expired or +if the user is using a different client, demonstrating payment will allow +the user to regain access to the digital good without having to pay for it +again. - Wallet releases ownership over an order. By unclaiming an - order, it becomes possible for another wallet to claim it. - This is useful if a user abandons buying the order with one - wallet but then wants to pay with a different wallet. +.. include:: merchant/post-orders-ORDER_ID-paid.rst - @since protocol **v26**. - **Request:** +Aborting incomplete payments +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - The request must be an `UnclaimRequest`. +In rare cases (such as a wallet restoring from an outdated backup) it is possible +that a wallet fails to complete a payment because it runs out of e-cash in the +middle of the process. The abort API allows the wallet to abort the payment for +such an incomplete payment and to regain control over the coins that were spent +so far. Aborts are not permitted for payments that have completed. In contrast to +refunds, aborts do not require approval by the merchant because aborts always +are for incomplete payments for an order and never for established contracts. - **Response:** - :http:statuscode:`204 No content`: - The client has successfully unclaimed the order. - :http:statuscode:`403 Forbidden`: - The signature is invalid. - :http:statuscode:`404 Not found`: - The backend is unaware of the instance or order. - :http:statuscode:`409 Conflict`: - The order was already paid, and thus cannot be unclaimed anymore. +.. _order-abort: +.. include:: merchant/post-orders-ORDER_ID-abort.rst - **Details:** - .. ts:def:: UnclaimRequest +Obtaining refunds +^^^^^^^^^^^^^^^^^ - interface UnclaimRequest { - // Signature using the key of the claim nonce - // to affirm unclaiming of the order. - unclaim_sig: EddsaSignature; +Refunds allow merchants to fully or partially restitute e-cash to a wallet, +for example because the merchant determined that it could not actually fulfill +the contract. Refunds must be approved by the merchant's business logic. - // Nonce to identify the wallet that claimed the order, - // public key matching ``unclaim_sig``. - nonce: EddsaPublicKey; - // Hash of the order's contract terms, used - // to enable signature verification without - // database access. - h_contract: HashCode; - } +.. include:: merchant/post-orders-ORDER_ID-refund.rst -Making the payment -^^^^^^^^^^^^^^^^^^ +------------------- +Instance management +------------------- -.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/pay - - Pay for an order by giving a deposit permission for coins. Typically used by - the customer's wallet. Note that this request does not include the - usual ``h_contract`` argument to authenticate the wallet, as the hash of - the contract is implied by the signatures of the coins. Furthermore, this - API doesn't really return useful information about the order. - - **Request:** - - The request must be a `pay request <PayRequest>`. - - **Response:** - - :http:statuscode:`200 OK`: - The exchange accepted all of the coins. - The body is a `payment response <PaymentResponse>`. - The ``frontend`` should now fulfill the contract. - Note that it is possible that refunds have been granted. - :http:statuscode:`400 Bad request`: - Either the client request is malformed or some specific processing error - happened that may be the fault of the client as detailed in the JSON body - of the response. - This includes the case where the payment is insufficient (sum is below - the required total amount, for example because the wallet calculated the - fees wrong). - Applicable error codes: - - * ``MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND``: Wallet tried - to pay with a non-existent denomination. - - :http:statuscode:`402 Payment required`: - There used to be a sufficient payment, but due to refunds the amount effectively - paid is no longer sufficient. (If the amount is generally insufficient, we - return "400 Bad Request", only if this is because of refunds we return 402.) - :http:statuscode:`403 Forbidden`: - One of the coin signatures was not valid. - :http:statuscode:`404 Not found`: - The merchant backend could not find the order - or the instance or a token family or - the Donau charity specified in - the contract and thus cannot process the payment. - Applicable error codes: - - * ``MERCHANT_GENERIC_TOKEN_KEY_UNKNOWN`` - * ``MERCHANT_GENERIC_ORDER_UNKNOWN`` - * ``MERCHANT_GENERIC_DONAU_CHARITY_UNKNOWN`` - * ``MERCHANT_GENERIC_INSTANCE_UNKNOWN`` - - :http:statuscode:`408 Request timeout`: - The backend took too long to process the request. Likely the merchant's connection - to the exchange timed out. Try again. - Applicable error codes: - - * ``MERCHANT_GENERIC_EXCHANGE_TIMEOUT`` - - :http:statuscode:`409 Conflict`: - The exchange rejected the payment because a coin was already spent (or - used in a different way for the same purchase previously), or - the merchant rejected the payment because the order was already fully paid - (and then return signatures with refunds). If a coin was already spent - (this includes re-using the same coin after a refund), - the response will include the ``exchange_url`` for which the payment failed, - in addition to the response from the exchange to the ``/batch-deposit`` request. - Applicable error codes: - - * ``MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_FUNDS``: Exchange reported insufficient - funds for one of the coins. - - :http:statuscode:`410 Gone`: - The offer has expired and is no longer available or - the provided payment has expired. - Applicable error codes: - - * ``MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_DEPOSIT_EXPIRED``: payment expired - * ``MERCHANT_POST_ORDERS_ID_PAY_OFFER_EXPIRED``: offer expired - - :http:statuscode:`412 Precondition failed`: - The given exchange is not acceptable for this merchant, as it is not in the - list of accepted exchanges and not audited by an approved auditor. - TODO: Status code may be changed to 409 in the future as 412 is technically wrong. - :http:statuscode:`451 Unavailable for Legal Reasons`: - The exchange has rejected the deposit by the merchant - for legal reasons. This is **not** exactly a client - failure (and possibly nobody's fault except for the - regulator). In any case, the wallet should refresh - the deposited coins of the affected exchange and - may try to pay with coins from another exchange if - possible (it has such coins and the merchant accepts - coins from another exchange). - The body is a `PaymentDeniedLegallyResponse` with - details about the failure. - Since protocol **v17**. - :http:statuscode:`501 Not implemented`: - This is returned if an optional feature required to - process this particular payment is no longer implemented. - This should only be possible if a different version - of the backend software was deployed between order - creation and payment. - - Applicable error codes: - - * ``MERCHANT_GENERIC_DONAU_NOT_CONFIGURED``: returned if donations are not supported - * ``MERCHANT_GENERIC_FEATURE_NOT_AVAILABLE``: usually returned if a token type is not supported - - :http:statuscode:`502 Bad gateway`: - The merchant's interaction with the exchange failed in some way. - The client might want to try again later. - This includes failures such as the denomination key of a coin not being - known to the exchange as far as the merchant can tell. - Applicable error codes: - - * ``MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS`` - * ``MERCHANT_GENERIC_EXCHANGE_REPLY_MALFORMED`` - - :http:statuscode:`504 Gateway timeout`: - The merchant's interaction with the exchange took too long. - The client might want to try again later. - - The backend will return verbatim the error codes received from the exchange's - :ref:`deposit <deposit>` API. If the wallet made a mistake, like by - double-spending for example, the frontend should pass the reply verbatim to - the browser/wallet. If the payment was successful, the frontend MAY use - this to trigger some business logic. - - **Details:** - - .. ts:def:: PaymentResponse - - interface PaymentResponse { - // Signature on ``TALER_PaymentResponsePS`` with the public - // key of the merchant instance. - sig: EddsaSignature; - - // Text to be shown to the point-of-sale staff as a proof of - // payment. - pos_confirmation?: string; - - // Signed tokens. Returned in the same order as the - // token envelopes were provided in the request. Specifically, - // the order will follow the order of the outputs from the - // contract terms, and then within each output follow the - // order in which the ``wallet_data`` contained the respective - // blinded envelopes. The donation tokens will be present - // at the offset matching the place where a donation receipt - // was indicated in the outputs array, and of course be skipped - // if the ``PayWalletData`` did not have a ``donau`` field. - // @since protocol **v21** - token_sigs?: SignedTokenEnvelope[]; +Instances allow one merchant backend to be shared by multiple merchants. +Every backend must have at least one instance, typically the "admin" +instance setup before it can be used to manage inventory or process payments. - } - .. ts:def:: PayRequest +Setting up instances +^^^^^^^^^^^^^^^^^^^^ - interface PayRequest { - // The coins used to make the payment. - coins: CoinPaySig[]; +.. include:: merchant/post-instances.rst - // Input tokens required by choice indicated by ``choice_index``. - // @since protocol **v21** - tokens?: TokenUseSig[]; - // Custom inputs from the wallet for the contract. - wallet_data?: PayWalletData; +.. include:: merchant/post-instances-INSTANCE-forgot-password.rst - // The session for which the payment is made (or replayed). - // Only set for session-based payments. - session_id?: string; - } +.. include:: merchant/post-management-instances.rst - .. ts:def:: SignedTokenEnvelope +.. include:: merchant/post-management-instances-INSTANCE-auth.rst - interface SignedTokenEnvelope { - // Blind signature made by the merchant. - blind_sig: TokenIssueBlindSig; +.. include:: merchant/post-private-token.rst - } +.. include:: merchant/get-private-tokens.rst - .. ts:def:: TokenIssueBlindSig +.. include:: merchant/delete-private-tokens-SERIAL.rst - type TokenIssueBlindSig = RSATokenIssueBlindSig | CSTokenIssueBlindSig; +.. include:: merchant/delete-private-token.rst - .. ts:def:: RSATokenIssueBlindSig +.. include:: merchant/patch-management-instances-INSTANCE.rst - interface RSATokenIssueBlindSig { - cipher: "RSA"; - // (blinded) RSA signature - blinded_rsa_signature: BlindedRsaSignature; - } +Inspecting instances +^^^^^^^^^^^^^^^^^^^^ - .. ts:def:: CSTokenIssueBlindSig +.. _instances: +.. include:: merchant/get-management-instances.rst - interface CSTokenIssueBlindSig { - cipher: "CS"; - // Signer chosen bit value, 0 or 1, used - // in Clause Blind Schnorr to make the - // ROS problem harder. - b: Integer; +.. include:: merchant/get-management-instances-INSTANCE.rst - // Blinded scalar calculated from c_b. - s: Cs25519Scalar; - } +Getting statistics +^^^^^^^^^^^^^^^^^^ - .. ts:def:: PayWalletData +.. include:: merchant/get-management-instances-INSTANCE-statistics-amount-SLUG.rst - interface PayWalletData { - // Index of the selected choice within the ``choices`` array of - // the contract terms. - // @since protocol **v21** - choice_index?: Integer; +.. include:: merchant/get-management-instances-INSTANCE-statistics-counter-SLUG.rst - // Array of output tokens to be (blindly) signed by the merchant. - // Output tokens specified in choice indicated by ``choice_index``. - // @since protocol **v21** - tokens_evs?: TokenEnvelope[]; - // Request for donation receipts to be issued. - // @since protocol **v21** - donau?: DonationRequestData; - } +.. include:: merchant/get-management-instances-INSTANCE-statistics-report-NAME.rst - .. ts:def:: DonationRequestData - interface DonationRequestData { - // Base URL of the selected Donau - url: string; +Deleting instances +^^^^^^^^^^^^^^^^^^ - // Year for which the donation receipts are expected. - // Also determines which keys are used to sign the - // blinded donation receipts. - year: Integer; +.. include:: merchant/delete-management-instances-INSTANCE.rst - // Array of blinded donation receipts to sign. - // Must NOT be empty (if no donation receipts - // are desired, just leave the entire ``donau`` - // argument blank). - budikeypairs: BlindedDonationReceiptKeyPair[]; - } - .. ts:def:: CoinPaySig +KYC status checks +^^^^^^^^^^^^^^^^^ - interface CoinPaySig { - // Signature by the coin. - coin_sig: EddsaSignature; +.. _merchantkycstatus: - // Public key of the coin being spent. - coin_pub: EddsaPublicKey; +.. include:: merchant/get-management-instances-INSTANCE-kyc.rst - // Signature made by the denomination public key. - ub_sig: UnblindedSignature; - // The hash of the denomination public key associated with this coin. - h_denom: HashCode; +------------- +Bank Accounts +------------- - // The amount that is subtracted from this coin with this payment. - contribution: Amount; +One or more bank accounts must be associated with an instance +so that the instance can receive payments. Payments may be made +into any of the active bank accounts of an instance. - // URL of the exchange this coin was withdrawn from. - exchange_url: string; - // Signature affirming the posession of the - // respective private key proving that the payer - // is old enough. Only provided if the paid contract - // has an age restriction and the coin is - // age-restricted. - minimum_age_sig?: EddsaSignature; +.. include:: merchant/post-private-accounts.rst - // Age commitment vector of the coin. - // Only provided if the paid contract - // has an age restriction and the coin is - // age-restricted. - age_commitment?: Edx25519PublicKey[]; - // Hash over the agge commitment vector of the coin. - // Only provided if the paid contract - // does NOT have an age restriction and the coin is - // age-restricted. - h_age_commitment?: AgeCommitmentHash; - } +.. include:: merchant/patch-private-accounts-H_WIRE.rst - .. ts:def:: TokenUseSig - interface TokenUseSig { +.. include:: merchant/get-private-accounts.rst - // Signature on ``TALER_TokenUseRequestPS`` with the token use key of - // the token being used in this request. - token_sig: EddsaSignature; +.. include:: merchant/get-private-accounts-H_WIRE.rst - // Token use public key. - token_pub: EddsaPublicKey; - // Unblinded signature on ``TALER_TokenIssueRequestPS`` with the token - // issue public key of the merchant. - ub_sig: UnblindedSignature; - // Hash of the token issue public key associated with this token. - h_issue: HashCode; - } +.. include:: merchant/delete-private-accounts-H_WIRE.rst - .. ts:def:: TokenEnvelope - // This type depends on the cipher used to sign token families. This is - // configured by the merchant and defined for each token family in the - // contract terms. - type TokenEnvelope = RSATokenEnvelope | CSTokenEnvelope; +-------------------- +Inventory management +-------------------- - .. ts:def:: RSATokenEnvelope +.. _inventory: - interface RSATokenEnvelope { +Inventory management is an *optional* backend feature that can be used to +manage limited stocks of products and to auto-complete product descriptions in +contracts (such that the frontends have to do less work). You can use the +Taler merchant backend to process payments *without* using its inventory +management. - // RSA is used for the blind signature. - cipher: "RSA"; +.. _decimal-quantity: - // Blinded signature of the token's `public EdDSA key <eddsa-token-pub>`. - rsa_blinded_pub: BlindedRsaSignature; +Decimal quantities +^^^^^^^^^^^^^^^^^^ - } +.. ts:def:: DecimalQuantity - .. ts:def:: CSTokenEnvelope + // Fixed-point decimal string in the form "<integer>[.<fraction>]". + // Fractional part has up to six digits. + // "-1" is only valid for fields that explicitly allow "infinity". + // Since protocol **v25**; used in template selection since **v25**. + type DecimalQuantity = string; - interface CSTokenEnvelope { - // Blind Clause-Schnorr signature scheme is used for the blind signature. - // See https://taler.net/papers/cs-thesis.pdf for details. - cipher: "CS"; - // Public nonce - cs_nonce: string; // Crockford `Base32` encoded +Managing measurement units +^^^^^^^^^^^^^^^^^^^^^^^^^^ - // Two Curve25519 scalars, each representing a blinded challenge - cs_blinded_c0: string; // Crockford `Base32` encoded - cs_blinded_c1: string; // Crockford `Base32` encoded - } +.. include:: merchant/get-private-units.rst - .. ts:def:: PaymentDeniedLegallyResponse +.. include:: merchant/get-private-units-UNIT.rst - interface PaymentDeniedLegallyResponse { - // Numeric `error code <error-codes>` unique to the condition. - // Error code, must be - // TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_LEGALLY_REFUSED. - code: Integer; +.. include:: merchant/post-private-units.rst - // Base URL of the exchanges that denied the payment. - // The wallet should refresh the coins from these - // exchanges, but may try to pay with coins from - // other exchanges. - exchange_base_urls: string[]; - } +.. include:: merchant/patch-private-units-UNIT.rst -Querying payment status -^^^^^^^^^^^^^^^^^^^^^^^ +.. include:: merchant/delete-private-units-UNIT.rst -.. http:get:: [/instances/$INSTANCE]/orders/$ORDER_ID - - Query the payment status of an order. This endpoint is for the wallet - and possibly for Web shops and other integrations that need an - unauthenticated way to query the order status (like when checking - it from JavaScript from inside the customer's browser). It is also - possible to just redirect a browser to this URL to initiate the - payment process. - - When a client (usually a wallet) goes to this URL and it is unpaid, - it will be prompted for payment. - This endpoint typically also supports requests with the "Accept" header - requesting "text/html". In this case, an HTML response suitable for - triggering the interaction with the wallet is returned, with ``timeout_ms`` - ignored (treated as zero). If the backend installation does not include the - required HTML templates, a 406 status code is returned. - - In the case that the request was made with a claim token (even the wrong one) - and the order was claimed and paid, the server will redirect the client to - the fulfillment URL. This redirection will happen with a 302 status code - if the "Accept" header specified "text/html", and with a 202 status code - otherwise. - - **Request:** - - :query h_contract=HASH: *Optional*. Hash of the order's contract terms (this is used to authenticate the wallet/customer in case $ORDER_ID is guessable). Required once an order was claimed. - :query token=TOKEN: *Optional*. Authorizes the request via the claim token that was returned in the `PostOrderResponse`. Used with unclaimed orders only. Whether token authorization is required is determined by the merchant when the frontend creates the order. - :query session_id=STRING: *Optional*. Session ID that the payment must be bound to. If not specified, the payment is not session-bound. - :query timeout_ms=NUMBER: *Optional.* If specified, the merchant backend will - wait up to ``timeout_ms`` milliseconds for completion of the payment before - sending the HTTP response. A client must never rely on this behavior, as the - merchant backend may return a response immediately. - :query await_refund_obtained=BOOLEAN: *Optional*. If set to "yes", poll for the order's pending refunds to be picked up. ``timeout_ms`` specifies how long we will wait for the refund. - :query refund=AMOUNT: *Optional*. Indicates that we are polling for a refund above the given AMOUNT. ``timeout_ms`` will specify how long we will wait for the refund. - :query allow_refunded_for_repurchase: *Optional*. Since protocol **v9** refunded orders are only returned under "already_paid_order_id" if this flag is set explicitly to "YES". - - **Response:** - - :http:statuscode:`200 OK`: - The response is a `StatusPaidResponse`. - :http:statuscode:`202 Accepted`: - The response is a `StatusGotoResponse`. - Returned only for unauthenticated (no nonce, no contract hash) - requests and only if the order was claimed already. - Only returned if the content type requested was not HTML, - if HTML was requested a `302 Found` will be returned instead. - The target site may allow the client to setup a fresh - order (as this one has been taken) or may - trigger repurchase detection. - Note that **if** the contract lacks a ``public_reorder_url`` - the backend will instead return a `403 Forbidden` response. - :http:statuscode:`302 Found`: - The client should go to the indicated location (via HTTP "Location:" header). - Returned only for unauthenticated (no nonce, no contract hash) - requests and only if the order was claimed already. - Only returned if the content type requested was HTML - if HTML was not requested a `302 Accepted` will be returned instead. - The target site may allow the client to setup a fresh - order (as this one has been taken) or may - trigger repurchase detection. - Note that **if** the contract lacks a ``public_reorder_url`` - the backend will instead return a `403 Forbidden` response. - :http:statuscode:`402 Payment required`: - The response is a `StatusUnpaidResponse`. - :http:statuscode:`403 Forbidden`: - The ``h_contract`` (or the ``token`` for unclaimed orders) does not match the order - and we have no fulfillment URL in the contract. - :http:statuscode:`404 Not found`: - The merchant backend is unaware of the order. - :http:statuscode:`406 Not acceptable`: - The merchant backend could not load the template required to generate a reply in the desired format. (Likely HTML templates were not properly installed.) - - **Details:** - - .. ts:def:: StatusPaidResponse - - interface StatusPaidResponse { - // Was the payment refunded (even partially, via refund or abort)? - refunded: boolean; - - // Is any amount of the refund still waiting to be picked up (even partially)? - refund_pending: boolean; - - // Amount that was refunded in total. - refund_amount: Amount; - - // Amount that already taken by the wallet. - refund_taken: Amount; - } - .. ts:def:: StatusGotoResponse +Managing product categories +^^^^^^^^^^^^^^^^^^^^^^^^^^^ - interface StatusGotoResponse { - // The client should go to the reorder URL, there a fresh - // order might be created as this one is taken by another - // customer or wallet (or repurchase detection logic may - // apply). - public_reorder_url: string; - } +.. include:: merchant/get-private-categories.rst - .. ts:def:: StatusUnpaidResponse +.. include:: merchant/get-private-categories-CATEGORY_ID.rst - interface StatusUnpaidResponse { - // URI that the wallet must process to complete the payment. - taler_pay_uri: string; - // Fulfillment URL of the contract. - // If present, it should be possible to create an - // equivalent order by redirecting a browser to this - // URL. Once the customer has paid, they should see the - // order's fulfillment (digital goods, tracking data for - // shipping, etc.) under this URL (assuming they use the - // same session that the wallet used when making the payment). - fulfillment_url?: string; +.. include:: merchant/post-private-categories.rst - // Alternative order ID which was paid for already in the same session. - // Only given if the same product was purchased before in the same session. - already_paid_order_id?: string; - } +.. include:: merchant/patch-private-categories-CATEGORY_ID.rst -.. http:get:: [/instances/$INSTANCE]/sessions/$SESSION_ID?fulfillment_url=$URL +.. include:: merchant/delete-private-categories-CATEGORY_ID.rst - Query the payment status for a session and fulfillment URL. - This endpoint is for Web shops, - Paivana and other integrations (like JavaScript from inside the customer's - browser) that need an unauthenticated way to query a payment status where - they do not know the order ID because they *only* know the session ID they - passed into the template mechanism. Here, the "$SESSION_ID" is an arbitrary - string, the semantics of which are left to the application. However, it must - match the "$SESSION_ID" passed to the template mechanism. - Since protocol **v25**. +Managing products in the inventory +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - **Request:** +.. include:: merchant/post-private-products.rst - :query fulfillment_url=URL: *Mandatory.* Specifies the fulfillment URL - for which the order must be valid. - :query timeout_ms=NUMBER: *Optional.* If specified, the merchant backend will - wait up to ``timeout_ms`` milliseconds for completion of the payment before - sending the HTTP response. A client must never rely on this behavior, as the - merchant backend may return a response immediately. - **Response:** +.. include:: merchant/patch-private-products-PRODUCT_ID.rst - :http:statuscode:`200 OK`: - The response is a `GetSessionStatusPaidResponse`. Returned if an - order that paid for the respective session exists and was paid. - :http:statuscode:`202 Accepted`: - The response is a `GetSessionStatusUnpaidResponse`. Returned if an - order that paid for the respective session exists, - but not yet paid. - :http:statuscode:`404 Not found`: - The merchant backend is unaware of an order matching the given session. - **Details:** +.. include:: merchant/get-private-products.rst - .. ts:def:: GetSessionStatusPaidResponse - interface GetSessionStatusPaidResponse { +.. include:: merchant/get-private-products-PRODUCT_ID.rst - // Order ID of the paid order. - order_id: String; - } +.. include:: merchant/delete-private-products-PRODUCT_ID.rst - .. ts:def:: GetSessionStatusUnpaidResponse - interface GetSessionStatusUnpaidResponse { - // Order ID of the unpaid order. - order_id: String; +Providing configuration data for point-of-sale terminals +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - } +.. include:: merchant/get-private-pos.rst -Demonstrating payment -^^^^^^^^^^^^^^^^^^^^^ +Fetching product images +^^^^^^^^^^^^^^^^^^^^^^^ -In case a wallet has already paid for an order, this is a fast way of proving -to the merchant that the order was already paid. The alternative would be to -replay the original payment, but simply providing the merchant's signature -saves bandwidth and computation time. +.. include:: merchant/get-products-IMAGE_HASH-image.rst -Demonstrating payment is useful in case a digital good was made available -only to clients with a particular session ID: if that session ID expired or -if the user is using a different client, demonstrating payment will allow -the user to regain access to the digital good without having to pay for it -again. -.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/paid - Prove that the client previously paid for an order by providing - the merchant's signature from the `payment response <PaymentResponse>`. - Typically used by the customer's wallet if it receives a request for - payment for an order that it already paid. This is more compact than - re-transmitting the full payment details. - Note that this request does include the - usual ``h_contract`` argument to authenticate the wallet and - to allow the merchant to verify the signature before checking - with its own database. +Reserving inventory +^^^^^^^^^^^^^^^^^^^ - **Request:** +.. include:: merchant/post-private-products-PRODUCT_ID-lock.rst - The request must be a `paid request <PaidRequest>`. - **Response:** - :http:statuscode:`200 Ok`: - The merchant accepted the signature. - The ``frontend`` should now fulfill the contract. - Note that it is possible that refunds have been granted. Response is of type `PaidRefundStatusResponse`. - :http:statuscode:`400 Bad request`: - Either the client request is malformed or some specific processing error - happened that may be the fault of the client as detailed in the JSON body - of the response. - :http:statuscode:`403 Forbidden`: - The signature was not valid. - :http:statuscode:`404 Not found`: - The merchant backend could not find the order or the instance - and thus cannot process the request. +------------------ +Payment processing +------------------ - **Details**: +To process Taler payments, a merchant must first set up an order with +the merchant backend. The order is then claimed by a wallet, and +paid by the wallet. The merchant can check the payment status of the +order. Once the order is paid, the merchant may (for a limited time) +grant refunds on the order. - .. ts:def:: PaidRefundStatusResponse +Creating orders +^^^^^^^^^^^^^^^ - interface PaidRefundStatusResponse { +.. _post-order: - // Text to be shown to the point-of-sale staff as a proof of - // payment (present only if re-usable OTP algorithm is used). - pos_confirmation?: string; +.. include:: merchant/post-private-orders.rst - // True if the order has been subjected to - // refunds. False if it was simply paid. - refunded: boolean; - } +Inspecting orders +^^^^^^^^^^^^^^^^^ - .. ts:def:: PaidRequest +.. include:: merchant/get-private-orders.rst - interface PaidRequest { - // Signature on ``TALER_PaymentResponsePS`` with the public - // key of the merchant instance. - sig: EddsaSignature; +.. include:: merchant/get-private-orders-ORDER_ID.rst - // Hash of the order's contract terms (this is used to authenticate the - // wallet/customer and to enable signature verification without - // database access). - h_contract: HashCode; - // Session id for which the payment is proven. - session_id: string; - } +.. _private-order-data-cleanup: -Aborting incomplete payments -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Private order data cleanup +^^^^^^^^^^^^^^^^^^^^^^^^^^ -In rare cases (such as a wallet restoring from an outdated backup) it is possible -that a wallet fails to complete a payment because it runs out of e-cash in the -middle of the process. The abort API allows the wallet to abort the payment for -such an incomplete payment and to regain control over the coins that were spent -so far. Aborts are not permitted for payments that have completed. In contrast to -refunds, aborts do not require approval by the merchant because aborts always -are for incomplete payments for an order and never for established contracts. +Some orders may contain sensitive information that the merchant may not want +to retain after fulfillment, such as the customer's shipping address. By +initially labeling these order components as forgettable, the merchant can +later tell the backend to forget those details (without changing the hash of +the contract!) to minimize risks from information leakage. -.. _order-abort: -.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/abort - - Abort paying for an order and obtain a refund for coins that - were already deposited as part of a failed payment. - - **Request:** - - The request must be an `abort request <AbortRequest>`. We force the wallet - to specify the affected coins as it may only request for a subset of the coins - (i.e. because the wallet knows that some were double-spent causing the failure). - Also we need to know the coins because there may be two wallets "competing" over - the same order and one wants to abort while the other still proceeds with the - payment. Here we need to again know which subset of the deposits to abort. - - **Response:** - - :http:statuscode:`200 OK`: - The merchant accepted the request, and passed it on to the exchange. The body is a - a `abort response <AbortResponse>`. Note that the exchange - MAY still have encountered errors in processing. Those will then be part of - the body. Wallets MUST carefully consider errors for each of the coins as - returned by the exchange. - :http:statuscode:`400 Bad request`: - Either the client request is malformed or some specific processing error - happened that may be the fault of the client as detailed in the JSON body - of the response. - :http:statuscode:`403 Forbidden`: - The ``h_contract`` does not match the $ORDER_ID. - :http:statuscode:`404 Not found`: - The merchant backend could not find the order or the instance - and thus cannot process the abort request. - :http:statuscode:`408 Request timeout`: - The merchant backend took too long getting a response from the exchange. - The wallet SHOULD retry soon. - :http:statuscode:`412 Precondition failed`: - Aborting the payment is not allowed, as the original payment did succeed. - It is possible that a different wallet succeeded with the payment. This - wallet should thus try to refresh all of the coins involved in the payment. - :http:statuscode:`502 Bad gateway`: - The merchant's interaction with the exchange failed in some way. - The error from the exchange is included. - :http:statuscode:`504 Gateway timeout`: - The merchant's interaction with the exchange took too long. - The client might want to try again later. - - The backend will return an `abort response <AbortResponse>`, which includes - verbatim the error codes received from the exchange's - :ref:`refund <exchange_refund>` API. The frontend should pass the replies verbatim to - the browser/wallet. - - **Details:** - - .. ts:def:: AbortRequest - - interface AbortRequest { - - // Hash of the order's contract terms (this is used to authenticate the - // wallet/customer in case $ORDER_ID is guessable). - h_contract: HashCode; - - // List of coins the wallet would like to see refunds for. - // (Should be limited to the coins for which the original - // payment succeeded, as far as the wallet knows.) - coins: AbortingCoin[]; - } +.. include:: merchant/patch-private-orders-ORDER_ID-forget.rst - .. ts:def:: AbortingCoin - interface AbortingCoin { - // Public key of a coin for which the wallet is requesting an abort-related refund. - coin_pub: EddsaPublicKey; +.. include:: merchant/delete-private-orders-ORDER_ID.rst - // The amount to be refunded (matches the original contribution) - // @Deprecated since **v18**. - contribution: Amount; - // URL of the exchange this coin was withdrawn from. - exchange_url: string; - } +.. _merchant_refund: +----------------- +Approving Refunds +----------------- - .. ts:def:: AbortResponse +.. include:: merchant/post-private-orders-ORDER_ID-refund.rst - interface AbortResponse { - // List of refund responses about the coins that the wallet - // requested an abort for. In the same order as the ``coins`` - // from the original request. - // The ``rtransaction_id`` is implied to be 0. - refunds: MerchantAbortPayRefundStatus[]; - } +----------------------- +Tracking Wire Transfers +----------------------- - .. ts:def:: MerchantAbortPayRefundStatus +This API is used by merchants that want to track the payments from the +exchange to be sure that they have been paid on time. By telling the merchant +backend about all incoming wire transfers, the backend can detect if an +exchange failed to perform a wire transfer that was due. - type MerchantAbortPayRefundStatus = - | MerchantAbortPayRefundSuccessStatus - | MerchantAbortPayRefundUndepositedStatus - | MerchantAbortPayRefundFailureStatus; - .. ts:def:: MerchantAbortPayRefundFailureStatus +Informing the backend about incoming wire transfers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - // Details about why a refund failed. - interface MerchantAbortPayRefundFailureStatus { - // Used as tag for the sum type RefundStatus sum type. - type: "failure"; +.. include:: merchant/post-private-transfers.rst - // HTTP status of the exchange request, must NOT be 200. - exchange_status: Integer; - // Taler error code from the exchange reply, if available. - exchange_code?: Integer; +Querying known wire transfers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - // If available, HTTP reply from the exchange. - exchange_reply?: Object; - } +.. include:: merchant/get-private-transfers.rst - .. ts:def:: MerchantAbortPayRefundSuccessStatus - // Additional details needed to verify the refund confirmation signature - // (``h_contract_terms`` and ``merchant_pub``) are already known - // to the wallet and thus not included. - interface MerchantAbortPayRefundSuccessStatus { - // Used as tag for the sum type MerchantCoinRefundStatus sum type. - type: "success"; - // HTTP status of the exchange request, 200 (integer) required for refund confirmations. - exchange_status: 200; +Querying expected wire transfers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - // The EdDSA :ref:`signature` (binary-only) with purpose - // `TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND` using a current signing key of the - // exchange affirming the successful refund. - exchange_sig: EddsaSignature; +.. include:: merchant/get-private-incoming.rst - // Public EdDSA key of the exchange that was used to generate the signature. - // Should match one of the exchange's signing keys from ``/keys``. It is given - // explicitly as the client might otherwise be confused by clock skew as to - // which signing key was used. - exchange_pub: EddsaPublicKey; - } - .. ts:def:: MerchantAbortPayRefundUndepositedStatus +.. include:: merchant/get-private-incoming-ID.rst - // The merchant didn't deposit the coin in the first place, - // no refund possible. - interface MerchantAbortPayRefundSuccessStatus { - // Used as tag for the sum type MerchantCoinRefundStatus sum type. - type: "undeposited"; - } +Deleting confirmed wire transfer +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Obtaining refunds -^^^^^^^^^^^^^^^^^ +Deleting a wire transfer can be useful in case of a data entry +mistake. In particular, if the exchange base URL was entered +badly, deleting the old entry and adding a correct one is a +good idea. Note that deleting wire transfers is not possible +if they were expected. -Refunds allow merchants to fully or partially restitute e-cash to a wallet, -for example because the merchant determined that it could not actually fulfill -the contract. Refunds must be approved by the merchant's business logic. +.. include:: merchant/delete-private-transfers-TID.rst -.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/refund +----------- +OTP Devices +----------- - Obtain refunds for an order. After talking to the exchange, the refunds will - no longer be pending if processed successfully. +OTP devices can be used to allow offline merchants +to validate that a customer made a payment. - **Request:** - The request body is a `WalletRefundRequest` object. +.. include:: merchant/post-private-otp-devices.rst - **Response:** - :http:statuscode:`200 OK`: - The response is a `WalletRefundResponse`. - :http:statuscode:`204 No content`: - There are no refunds for the order. - :http:statuscode:`403 Forbidden`: - The ``h_contract`` does not match the order. - :http:statuscode:`404 Not found`: - The merchant backend is unaware of the order. - :http:statuscode:`410 Gone`: - The wire deadline has past and it is too late to grant a refund. - Since protocol **v24**. +.. include:: merchant/patch-private-otp-devices-DEVICE_ID.rst - **Details:** - .. ts:def:: WalletRefundRequest +.. include:: merchant/get-private-otp-devices.rst - interface WalletRefundRequest { - // Hash of the order's contract terms (this is used to authenticate the - // wallet/customer). - h_contract: HashCode; - } +.. include:: merchant/get-private-otp-devices-DEVICE_ID.rst - .. ts:def:: WalletRefundResponse +.. include:: merchant/delete-private-otp-devices-DEVICE_ID.rst - interface WalletRefundResponse { - // Amount that was refunded in total. - refund_amount: Amount; - // Successful refunds for this payment, empty array for none. - refunds: MerchantCoinRefundStatus[]; +.. _merchant-template-api: - // Public key of the merchant. - merchant_pub: EddsaPublicKey; +--------- +Templates +--------- - } - - .. ts:def:: MerchantCoinRefundStatus - - type MerchantCoinRefundStatus = - | MerchantCoinRefundSuccessStatus - | MerchantCoinRefundFailureStatus; - - .. ts:def:: MerchantCoinRefundFailureStatus - - // Details about why a refund failed. - interface MerchantCoinRefundFailureStatus { - // Used as tag for the sum type RefundStatus sum type. - type: "failure"; - - // HTTP status of the exchange request, must NOT be 200. - exchange_status: Integer; - - // Taler error code from the exchange reply, if available. - exchange_code?: Integer; - - // If available, HTTP reply from the exchange. - exchange_reply?: Object; - - // Refund transaction ID. - rtransaction_id: Integer; - - // Public key of a coin that was refunded. - coin_pub: EddsaPublicKey; - - // Amount that was refunded, including refund fee charged by the exchange - // to the customer. - refund_amount: Amount; - - // Timestamp when the merchant approved the refund. - // Useful for grouping refunds. - execution_time: Timestamp; - } - - .. ts:def:: MerchantCoinRefundSuccessStatus - - // Additional details needed to verify the refund confirmation signature - // (``h_contract_terms`` and ``merchant_pub``) are already known - // to the wallet and thus not included. - interface MerchantCoinRefundSuccessStatus { - // Used as tag for the sum type MerchantCoinRefundStatus sum type. - type: "success"; - - // HTTP status of the exchange request, 200 (integer) required for refund confirmations. - exchange_status: 200; - - // The EdDSA :ref:`signature` (binary-only) with purpose - // `TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND` using a current signing key of the - // exchange affirming the successful refund. - exchange_sig: EddsaSignature; - - // Public EdDSA key of the exchange that was used to generate the signature. - // Should match one of the exchange's signing keys from /keys. It is given - // explicitly as the client might otherwise be confused by clock skew as to - // which signing key was used. - exchange_pub: EddsaPublicKey; - - // Refund transaction ID. - rtransaction_id: Integer; - - // Public key of a coin that was refunded. - coin_pub: EddsaPublicKey; - - // Amount that was refunded, including refund fee charged by the exchange - // to the customer. - refund_amount: Amount; - - // Timestamp when the merchant approved the refund. - // Useful for grouping refunds. - execution_time: Timestamp; - } - - -------------------- -Instance management -------------------- - -Instances allow one merchant backend to be shared by multiple merchants. -Every backend must have at least one instance, typically the "admin" -instance setup before it can be used to manage inventory or process payments. - - -Setting up instances -^^^^^^^^^^^^^^^^^^^^ - -.. http:post:: /instances - - This request will be used to create a new merchant instance in the backend. - Since protocol **v21**. - - Only available if self-provisioning is enabled. - - **Required permission:** none - - **Request:** - - The request must be a `InstanceConfigurationMessage`. - - :query token_validity_ms=DURATION: *Optional*. - Pass a non-zero DURATION in milliseconds to get a - refreshable login token for the SPA with the - given validity duration in the response. @since **v21**. - - **Response:** - - :http:statuscode:`200 Ok`: - The backend has successfully created the instance. Body will - be an `LoginTokenSuccessResponse` with a refreshable - login token for the SPA as requested. @since **v21**. - :http:statuscode:`202 Accepted`: - 2FA is required for this operation, usually to validate the - email and/or phone numbers provided for the instance. - This returns the `ChallengeResponse`. @since **v21** - :http:statuscode:`204 No Content`: - The backend has successfully created the instance. No login - token was requested, so nothing is returned. - :http:statuscode:`409 Conflict`: - This instance already exists, but with other configuration options. - Use "PATCH" to update an instance configuration. Alternatively, - the currency provided in the configuration does not match the - currency supported by this backend. Another possible conflict - would be if a deleted but not purged instance is known under this - ID to the backend. - - -.. http:post:: /instances/$INSTANCE/forgot-password - - Same as ``/management/instances/$INSTANCE/private/auth`` it will update the password of the instance but - without requiring the current password. On the first call it will validate the request - and return the multi-factor authentication challenge IDs with - a ``202 Accepted`` response. Once the challenges are solved the - request needs to be repeated with the ``Taler-Challenge-Ids`` header. - - This endpoint is **not** available for the ``admin`` instance. - The administrator must use the command-line tool if they forgot - their password. - - Since protocol **v21**. - - **Request** the request must be an `InstanceAuthConfigurationMessage`. - - **Response:** - - :http:statuscode:`202 Accepted`: - 2FA is required for this operation. This returns - the `ChallengeResponse`. @since **v21** - :http:statuscode:`204 No content`: - The backend has successfully changed the credentials for the instance. - :http:statuscode:`404 Not found`: - This instance is unknown and thus cannot be reconfigured. - - -.. http:post:: /management/instances - - This request will be used to create a new merchant instance in the backend. - It is only available for the implicit ``admin`` instance. - - **Required permission:** ``instances-write`` - - **Request:** - - The request must be a `InstanceConfigurationMessage`. - - **Response:** - - :http:statuscode:`202 Accepted`: - 2FA is required for this operation, usually to validate the - email and/or phone numbers registered for the instance. - This returns the `ChallengeResponse`. @since **v21** - :http:statuscode:`204 No content`: - The backend has successfully created the instance. - :http:statuscode:`409 Conflict`: - This instance already exists, but with other configuration options. - Use "PATCH" to update an instance configuration. Alternatively, - the currency provided in the configuration does not match the - currency supported by this backend. Another possible conflict - would be if a deleted but not purged instance is known under this - ID to the backend. - - **Details:** - - .. ts:def:: InstanceConfigurationMessage - - interface InstanceConfigurationMessage { - - // Name of the merchant instance to create (will become $INSTANCE). - // Must match the regex ``^[A-Za-z0-9][A-Za-z0-9_.@-]+$``. - id: string; - - // Merchant name corresponding to this instance. - name: string; - - // Merchant email for customer contact and password reset. - email?: string; - - // Merchant phone number for password reset (2-FA) - // @since **v21**. - phone_number?: string; - - // Merchant public website. - website?: string; - - // Merchant logo. - logo?: ImageDataUrl; - - // Authentication settings for this instance - auth: InstanceAuthConfigurationMessage; - - // The merchant's physical address (to be put into contracts). - address: Location; - - // The jurisdiction under which the merchant conducts its business - // (to be put into contracts). - jurisdiction: Location; - - // Use STEFAN curves to determine default fees? - // If false, no fees are allowed by default. - // Can always be overridden by the frontend on a per-order basis. - use_stefan: boolean; - - // If the frontend does NOT specify a payment deadline, how long should - // offers we make be valid by default? - // Optional @since **v22** (before the setting was mandatory). - // If not provided, the global merchant default will be used. - default_pay_delay?: RelativeTime; - - // If the frontend does NOT specify a refund deadline, how long should - // refunds be allowed by default? Added on top of the - // payment deadline. - // @since **v22** - default_refund_delay?: RelativeTime; - - // If the frontend does NOT specify an execution date, how long should - // we tell the exchange to wait to aggregate transactions before - // executing the wire transfer? This delay is added on top of - // the refund deadline and afterwards subject to rounding - // via the ``default_wire_transfer_rounding_interval``. - // Optional @since **v22** (before the setting was mandatory). - // If not provided, the global merchant default will be used. - default_wire_transfer_delay?: RelativeTime; - - // How far should the wire deadline (if computed with the help of - // the ``default_wire_transfer_delay``) be rounded up to compute - // the ultimate wire deadline? - // @since **v22**, defaults to no rounding if not given. - default_wire_transfer_rounding_interval?: RoundingInterval; - } - -.. http:post:: /management/instances/$INSTANCE/auth -.. http:post:: [/instances/$INSTANCE]/private/auth - - Update the authentication settings for an instance. POST operations against - an instance are authenticated by checking that an authorization is provided - that matches either the credential required by the instance being modified - OR the ``admin`` instance, depending on the access path used. - - **Required permission:** ``instances-auth-write`` - - **Request** the request must be an `InstanceAuthConfigurationMessage`. - - **Response:** - - :http:statuscode:`202 Accepted`: - 2FA is required for this operation. This returns the `ChallengeResponse` response. @since **v21** - :http:statuscode:`204 No content`: - The backend has successfully changed the credentials for the instance. - :http:statuscode:`404 Not found`: - This instance is unknown and thus cannot be reconfigured. - - **Details:** - - .. ts:def:: InstanceAuthConfigurationMessage - - type InstanceAuthConfigurationMessage = InstanceAuthConfigToken | InstanceAuthConfigTokenOLD | InstanceAuthConfigExternal - - .. ts:def:: InstanceAuthConfigToken - - // @since **v19** - interface InstanceAuthConfigToken { - // The API is accessible through API tokens. - // Tokens are retrieved from the /private/token - // endpoint. - method: "token"; - - // Authentication against the /private/token endpoint - // is done using basic authentication with the configured password - // in the "password" field. Tokens are passed to other endpoints for - // authorization using RFC 8959 bearer tokens. - password: string; - - } - - .. ts:def:: InstanceAuthConfigTokenOLD - - // @deprecated since **v19** - interface InstanceAuthConfigTokenOLD { - // The API is accessible through API tokens. - // Tokens are retrieved from the /private/token - // endpoint. - method: "token"; - - // The value of this field MUST begin with the string "secret-token:". - token: string; - - } - - .. ts:def:: InstanceAuthConfigExternal - - // @deprecated since **v20** - interface InstanceAuthConfigExternal { - // The mechant backend does not do - // any authentication checks. Instead an API - // gateway must do the authentication. - method: "external"; - } - - -.. http:post:: [/instances/$INSTANCE]/private/token - - Retrieve an access token for the merchant API for instance - ``$INSTANCE``. - When accessed with a Bearer token for authentication, the token - must have scope ``token-refresh`` and the requested scope must be a subset - of the scope of the token. - When accessed with Basic authentication the instance password must be provided - along with ``$INSTANCE`` as username. - - - **Required permission:** ``token-refresh`` if accessed using a Bearer token. - - **Request:** - - The request must be a `LoginTokenRequest`. - - **Response:** - - :http:statuscode:`200 Ok`: - The backend is returning the access token in a - `LoginTokenSuccessResponse`. - :http:statuscode:`202 Accepted`: - 2FA is required for this operation. - This returns the `ChallengeResponse`. @since **v21** - - **Details:** - - .. ts:def:: LoginTokenRequest - - interface LoginTokenRequest { - // Scope of the token (which kinds of operations it will allow) - scope: "readonly" | "write" | "all" | "order-simple" | "order-pos" | "order-mgmt" | "order-full"; - - // Server may impose its own upper bound - // on the token validity duration - duration?: RelativeTime; - - // Optional token description - description?: string; - - // Can this token be refreshed? - // Defaults to false. Deprecated since **v19**. - // Use ":refreshable" scope prefix instead. - refreshable?: boolean; - } - - .. ts:def:: LoginTokenSuccessResponse - - interface LoginTokenSuccessResponse { - // deprecated since v19. See access_token - token: string; - - // The login token that can be used to access resources - // that are in scope for some time. Must be prefixed - // with "Bearer " when used in the "Authorization" HTTP header. - // Will already begin with the RFC 8959 prefix. - // **Since v19** - access_token: string; - - // Scope of the token (which kinds of operations it will allow) - scope: "readonly" | "write" | "all" | "order-simple" | "order-pos" | "order-mgmt" | "order-full"; - - // Server may impose its own upper bound - // on the token validity duration - expiration: Timestamp; - - // Can this token be refreshed? - refreshable: boolean; - } - -.. http:get:: [/instances/$INSTANCE]/private/tokens - - Retrieve a list of issued access tokens for ``$INSTANCE``. - - @since **v19** - - **Required permission**: ``tokens-read`` - - **Request:** - - :query limit: *Optional.* - At most return the given number of results. Negative for descending by ``serial``, positive for ascending by ``serial``. Defaults to ``-20``. - :query offset: *Optional.* - Starting ``serial`` for :ref:`pagination <row-id-pagination>`. - - **Response:** - - :http:statuscode:`200 OK`: - Response is a `TokenInfos`. - :http:statuscode:`204 No content`: - No tokens. - :http:statuscode:`401 Unauthorized`: - Invalid or missing credentials. - :http:statuscode:`403 Forbidden`: - Missing rights. - - **Details:** - - .. ts:def:: TokenInfos - - interface TokenInfos { - tokens: TokenInfo[]; - } - - .. ts:def:: TokenInfo - - interface TokenInfo { - // Time when the token was created. - creation_time: Timestamp; - - // Time when the token expires. - expiration: Timestamp; - - // Scope for the token. - scope: "readonly" | "readwrite" | ...; - - // Is the token refreshable into a new token during its - // validity? - // Refreshable tokens effectively provide indefinite - // access if they are refreshed in time. - refreshable: boolean; - - // Optional token description - description?: string; - - // Opaque unique ID used for pagination. - serial: Integer; - } - -.. http:delete:: [/instances/$INSTANCE]/private/tokens/$SERIAL - - Delete a token for ``$INSTANCE`` API access by its ``$SERIAL``. - - - @since **v19** - - **Required permission**: ``tokens-write`` - - **Response:** - - :http:statuscode:`204 No content`: - Token deleted. - :http:statuscode:`401 Unauthorized`: - Invalid or missing credentials. - :http:statuscode:`403 Forbidden`: - Missing permission. - :http:statuscode:`404 Not found`: - The token was not found. - -.. http:delete:: [/instances/$INSTANCE]/private/token - - Delete the token presented in the authorization header. - - **Response:** - - :http:statuscode:`204 No content`: - The access token used to authorize this request was revoked. - -.. http:patch:: /management/instances/$INSTANCE -.. http:patch:: [/instances/$INSTANCE]/private - - Update the configuration of a merchant instance. PATCH operations against - an instance are authenticated by checking that an authorization is provided - that matches either the credential required by the instance being modified - OR the ``admin`` instance, depending on the access path used. - - **Required permission:** ``instances-token-write`` - - **Request** - - The request must be a `InstanceReconfigurationMessage`. - Removing an existing ``payto_uri`` deactivates - the account (it will no longer be used for future contracts). - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully created the instance. - :http:statuscode:`404 Not found`: - This instance is unknown and thus cannot be reconfigured. - - **Details:** - - .. ts:def:: InstanceReconfigurationMessage - - interface InstanceReconfigurationMessage { - - // Merchant name corresponding to this instance. - name: string; - - // Merchant email for customer contact and password reset. - email?: string; - - // Merchant phone number for password reset (2-FA) - // @since **v21**. - phone_number?: string; - - // Merchant public website. - website?: string; - - // Merchant logo. - logo?: ImageDataUrl; - - // The merchant's physical address (to be put into contracts). - address: Location; - - // The jurisdiction under which the merchant conducts its business - // (to be put into contracts). - jurisdiction: Location; - - // Use STEFAN curves to determine default fees? - // If false, no fees are allowed by default. - // Can always be overridden by the frontend on a per-order basis. - use_stefan: boolean; - - // If the frontend does NOT specify a payment deadline, how long should - // offers we make be valid by default? - // A value of "forever" is not allowed. - // Optional @since **v22** (before the setting was mandatory). - // If not provided, the previous setting will now simply be preserved. - default_pay_delay?: RelativeTime; - - // If the frontend does NOT specify a refund deadline, how long should - // refunds be allowed by default? Added on top of the payment deadline. - // A value of "forever" is not allowed. - // @since **v22** - default_refund_delay?: RelativeTime; - - // If the frontend does NOT specify an execution date, how long should - // we tell the exchange to wait to aggregate transactions before - // executing the wire transfer? This delay is added on top of - // the refund deadline and afterwards subject to rounding - // via the ``default_wire_transfer_rounding_interval``. - // A value of "forever" is not allowed. - // Optional @since **v22** (before the setting was mandatory). - // If not provided, the previous setting will now simply be preserved. - default_wire_transfer_delay?: RelativeTime; - - // How far should the wire deadline (if computed with the help of - // the ``default_wire_transfer_delay``) be rounded up to compute - // the ultimate wire deadline? - // @since **v22**, defaults to no rounding if not given. - default_wire_transfer_rounding_interval?: RoundingInterval; - } - - -Inspecting instances -^^^^^^^^^^^^^^^^^^^^ - -.. _instances: -.. http:get:: /management/instances - - This is used to return the list of all the merchant instances. - It is only available for the implicit ``admin`` instance. - - **Required permission:** ``instances-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the list of instances stored. Returns - a `InstancesResponse`. - - **Details:** - - .. ts:def:: InstancesResponse - - interface InstancesResponse { - // List of instances that are present in the backend (see `Instance`). - instances: Instance[]; - } - - The `Instance` object describes the instance registered with the backend. - It does not include the full details, only those that usually concern the frontend. - It has the following structure: - - .. ts:def:: Instance - - interface Instance { - // Merchant name corresponding to this instance. - name: string; - - // Merchant public website. - website?: string; - - // Merchant logo. - logo?: ImageDataUrl; - - // Merchant instance this response is about ($INSTANCE). - id: string; - - // Public key of the merchant/instance, in Crockford Base32 encoding. - merchant_pub: EddsaPublicKey; - - // List of the payment targets supported by this instance. Clients can - // specify the desired payment target in /order requests. Note that - // front-ends do not have to support wallets selecting payment targets. - payment_targets: string[]; - - // Has this instance been deleted (but not purged)? - deleted: boolean; - } - - -.. http:get:: /management/instances/$INSTANCE -.. http:get:: [/instances/$INSTANCE]/private - - This is used to query a specific merchant instance. GET operations against - an instance are authenticated by checking that an authorization is provided - that matches either the credential required by the instance being modified - OR the ``admin`` instance, depending on the access path used. - - This endpoint may be used even when mandatory TAN channels - were not validated yet. - - **Required permission:** ``instances-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the list of instances stored. Returns - a `QueryInstancesResponse`. - - **Details:** - - .. ts:def:: QueryInstancesResponse - - interface QueryInstancesResponse { - - // Merchant name corresponding to this instance. - name: string; - - // Merchant email for customer contact and password reset. - email?: string; - - // True if the ``email`` address was validated. - // @since **v21**. - email_validated?: boolean; - - // Merchant phone number for password reset (2-FA) - // @since **v21**. - phone_number?: string; - - // True if the ``email`` address was validated. - // @since **v21**. - phone_validated?: boolean; - - // Merchant public website. - website?: string; - - // Merchant logo. - logo?: ImageDataUrl; - - // Public key of the merchant/instance, in Crockford Base32 encoding. - merchant_pub: EddsaPublicKey; - - // The merchant's physical address (to be put into contracts). - address: Location; - - // The jurisdiction under which the merchant conducts its business - // (to be put into contracts). - jurisdiction: Location; - - // Use STEFAN curves to determine default fees? - // If false, no fees are allowed by default. - // Can always be overridden by the frontend on a per-order basis. - use_stefan: boolean; - - // If the frontend does NOT specify a payment deadline, how long should - // offers we make be valid by default? Added to the order creation - // time. - default_pay_delay: RelativeTime; - - // If the frontend does NOT specify a refund deadline, how long should - // refunds be allowed by default? Added to the payment deadline. - // @since **v22** - default_refund_delay: RelativeTime; - - // If the frontend does NOT specify an execution date, how long should - // we tell the exchange to wait to aggregate transactions before - // executing the wire transfer? This delay is added to the - // refund deadline and subject to rounding to the - // ``default_wire_transfer_rounding_interval``. - default_wire_transfer_delay: RelativeTime; - - // Default interval to which wire deadlines computed by - // adding the wire_transfer_delay on top of the refund - // deadline should be rounded up to. - // @since **v23** - default_wire_transfer_rounding_interval: RoundingInterval; - - // Authentication configuration. - // Does not contain the token when token auth is configured. - auth: { - method: "external" | "token"; - }; - - } - - -Getting statistics -^^^^^^^^^^^^^^^^^^ - -.. http:get:: /management/instances/$INSTANCE/statistics-amount/$SLUG -.. http:get:: [/instances/$INSTANCE]/private/statistics-amount/$SLUG - - This request will return be used to statistics where the - values are amounts. All available values for the given - SLUG will be returned. - Since protocol **v25**. - - **Required permission:** ``statistics-read`` - - **Request:** - - :query by: *Optional*. If set to "BUCKET", only statistics by bucket will be returned. If set to "INTERVAL", only statistics kept by interval will be returned. If not set or set to "ANY", both will be returned. - - **Response:** - - :http:statuscode:`200 Ok`: - The body will be a `MerchantStatisticsAmountResponse` - :http:statuscode:`401 Unauthorized`: - The request is unauthorized. - :http:statuscode:`404 Not found`: - The instance is unknown to the backend. - - **Details:** - - .. ts:def:: MerchantStatisticsAmountResponse - - interface MerchantStatisticsAmountResponse { - - // Statistics kept for a particular fixed time window. - buckets: MerchantStatisticAmountByBucket[]; - - // Human-readable bucket statistic description. - // Unset if no buckets returned - buckets_description?: string; - - // Statistics kept for a particular sliding interval. - intervals: MerchantStatisticAmountByInterval[]; - - // Human-readable interval statistic description. - // Unset if no buckets returned - intervals_description?: string; - } - - .. ts:def:: MerchantStatisticAmountByBucket - - interface MerchantStatisticAmountByBucket { - - // Start time of the bucket (inclusive) - start_time: Timestamp; - - // End time of the bucket (exclusive) - end_time: Timestamp; - - // Range of the bucket - range: StatisticBucketRange; - - // Sum of all amounts falling under the given - // SLUG within this timeframe. - cumulative_amounts: Amount[]; - - } - - .. ts:def:: MerchantStatisticAmountByInterval - - interface MerchantStatisticAmountByInterval { - - // Start time of the interval. - // The interval always ends at the response - // generation time. - start_time: Timestamp; - - // Sum of all amounts falling under the given - // SLUG within this timeframe. - cumulative_amounts: Amount[]; - - } - -.. http:get:: /management/instances/$INSTANCE/statistics-counter/$SLUG -.. http:get:: [/instances/$INSTANCE]/private/statistics-counter/$SLUG - - This request will return be used to statistics where the - values are counters. All available values for the given - SLUG will be returned. - Since protocol **v25**. - - **Required permission:** ``statistics-read`` - - **Request:** - - :query by: *Optional*. If set to "BUCKET", only statistics by bucket will be returned. If set to "INTERVAL", only statistics kept by interval will be returned. If not set or set to "ANY", both will be returned. - - **Response:** - - :http:statuscode:`200 Ok`: - The body will be a `MerchantStatisticsCounterResponse` - :http:statuscode:`401 Unauthorized`: - The request is unauthorized. - :http:statuscode:`404 Not found`: - The instance is unknown to the backend. - - **Details:** - - .. ts:def:: MerchantStatisticsCounterResponse - - interface MerchantStatisticsCounterResponse { - - // Statistics kept for a particular fixed time window. - buckets: MerchantStatisticCounterByBucket[]; - - // Human-readable bucket statistic description. - // Unset if no buckets returned - buckets_description?: string; - - // Statistics kept for a particular sliding interval. - intervals: MerchantStatisticCounterByInterval[]; - - // Human-readable interval statistic description. - // Unset if no intervals returned - intervals_description?: string; - - } - - .. ts:def:: MerchantStatisticCounterByBucket - - interface MerchantStatisticCounterByBucket { - - // Start time of the bucket (inclusive) - start_time: Timestamp; - - // End time of the bucket (exclusive) - end_time: Timestamp; - - // Range of the bucket - range: StatisticBucketRange; - - // Sum of all counters falling under the given - // SLUG within this timeframe. - cumulative_counter: Integer; - - } - - .. ts:def:: MerchantStatisticCounterByInterval - - interface MerchantStatisticCounterByInterval { - - // Start time of the interval. - // The interval always ends at the response - // generation time. - start_time: Timestamp; - - // Sum of all counters falling under the given - // SLUG within this timeframe. - cumulative_counter: Integer; - - } - - -.. http:get:: /management/instances/$INSTANCE/statistics-report/$NAME -.. http:get:: [/instances/$INSTANCE]/private/statistics-report/$NAME - - This request will return be used to generate a specific - report based on $NAME. The backend **MAY** support generating - the report in various formats. Supported values for ``$NAME`` include: - - * "transactions" (total revenue, total refunds, fees - as well as number of transactions), since **v25** - * "money-pots" (changes to totals in money pots), since **v25** - * "taxes" (amount of taxes withheld by tax class), since **vTAXES**, - * "sales-funnel" (number and volume of orders - created, claimed, paid, refunded and settled), since **vXXX**, - - The overall endpoint family exists since protocol **v25**. - - **Required permission:** ``statistics-read`` - - **Request:** - - *Accept*: - The client may specify the desired MIME-type for the result. - Supported are the usual "application/json", but also - "application/pdf". - - :query granularity: *Optional*. Determines the bucket granularity - to return. Accepted are "hour", "day", "week", - "month", "quarter" and "year". Defaults to "month". - :query count: *Optional*. Number of buckets to return. Defaults depends - on the granularity. - - **Response:** - - :http:statuscode:`200 Ok`: - If JSON is requested, the body will be - a `MerchantStatisticsReportResponse`, otherwise a PDF. - :http:statuscode:`401 Unauthorized`: - The request is unauthorized. - :http:statuscode:`404 Not found`: - The instance is unknown to the backend. - :http:statuscode:`410 Gone`: - The requested statistical data is unavailable because - it is not kept at the requested granularity for this long. - :http:statuscode:`501 Not implemented`: - The requested functionality is not implemented. - Usually returned if the PDF generator is not available - at this backend and the requested format was application/pdf. - - **Details:** - - .. ts:def:: MerchantStatisticsReportResponse - - interface MerchantStatisticsReportResponse { - - // Name of the business for which the report is generated. - business_name: String; - - // Starting date for the report. - start_date: Timestamp; - - // End date for the report. - end_date: Timestamp; - - // Period of time covered by each bucket (aka granularity). - bucket_period: RelativeTime; - - // Charts to include in the report. - charts: MerchantReportChart[]; - - } - - .. ts:def:: MerchantReportChart - - interface MerchantReportChart { - - // Name of the chart. - chart_name: String; - - // Label to use for the y-axis of the chart. - // (x-axis is always time). - y_label: String; - - // Statistical values for the respective time windows, - // one entry per ``bucket_period`` in between ``start_date`` - // and ``end_date``. - data_groups: BucketDataGroup[]; - - // Human-readable labels for the ``values`` in each of the - // ``data_groups``. Length of the array must match the - // length of the ``values`` arrays. - labels: string[]; - - // Should the ``values`` in each of the ``data_groups`` - // be rendered cumulatively or using a grouped representation? - cumulative: boolean; - - } - - .. ts:def:: BucketDataGroup - - interface BucketDataGroup { - - // Starting data for this group - start_date: Timestamp; - - // Values in the data group. - values: Float[]; - - } - - -Deleting instances -^^^^^^^^^^^^^^^^^^ - -.. http:delete:: /management/instances/$INSTANCE -.. http:delete:: [/instances/$INSTANCE]/private - - This request will be used to delete (permanently disable) - or purge merchant instance in the backend. Purging will - delete all offers and payments associated with the instance, - while disabling (the default behavior) only deletes the private key - and makes the instance unusable for new orders or payments. - - For deletion, the authentication credentials must match - the instance that is being deleted or the ``admin`` - instance, depending on the access path used. - - **Required permission:** ``instances-write`` - - **Request:** - - :query purge: *Optional*. If set to YES, the instance will be fully - deleted. Otherwise only the private key would be deleted. - - **Response:** - - :http:statuscode:`202 Accepted`: - 2FA is required for this operation, usually to validate the - email and/or phone numbers registered for the instance. - This returns the `ChallengeResponse`. @since **v21** - :http:statuscode:`204 No content`: - The backend has successfully removed the instance. The body is empty. - :http:statuscode:`401 Unauthorized`: - The request is unauthorized. Note that for already deleted instances, - the request must be authorized using the ``admin`` instance. - :http:statuscode:`404 Not found`: - The instance is unknown to the backend. - :http:statuscode:`409 Conflict`: - The instance cannot be deleted because it has pending offers, or - the instance cannot be purged because it has successfully processed - payments that have not passed the ``TAX_RECORD_EXPIRATION`` time. - The latter case only applies if ``purge`` was set. - - -KYC status checks -^^^^^^^^^^^^^^^^^ - -.. _merchantkycstatus: - -.. http:GET:: /management/instances/$INSTANCE/kyc -.. http:GET:: /instances/$INSTANCE/private/kyc - - Check KYC status of a particular payment target. - Prompts the exchange to inquire with the bank - as to the KYC status of the respective account - and returns the result. - - **Required permission:** ``instances-kyc-read`` - - **Request:** - - :query h_wire=H_WIRE: *Optional*. If specified, the KYC check should - return the KYC status only for this wire account. Otherwise, for all wire accounts. - :query exchange_url=URL: *Optional*. If specified, the KYC check should - return the KYC status only for the given exchange. Otherwise, for all exchanges we interacted with. - :query lpt=TARGET: *Optional*. - Specifies what status change we are long-polling for. - Use 1 to wait for the KYC auth transfer (access token available), - 2 to wait for an AML investigation to be done, - and 3 to wait for the KYC status to be OK. - If multiple accounts or exchanges match the query, - any account reaching the TARGET state will cause - the response to be returned. - @since protocol **v17**. @deprecated with **v25**, use ``lp_*``-query parameters instead. - :query lp_status=STATUS: *Optional*. - Specifies what status change we are long-polling for. - If specified, the endpoint will only return once the status *matches* the given value. - If multiple accounts or exchanges match the query, - any account reaching the STATUS will cause the response to be returned. - @since protocol **v25**. - :query lp_not_status=STATUS: *Optional*. - Specifies what status change we are long-polling for. - If specified, the endpoint will only return once the status no longer matches the given value. - If multiple accounts or exchanges *no longer matches* the given STATUS - will cause the response to be returned. - @since protocol **v25**. - :query lp_not_etag=ETAG: *Optional*. - Specifies what status change we are long-polling for. - If specified, the endpoint will only return once the returned "Etag" - would differ from the ETAG specified by the client. The "Etag" - is computed over the entire response body, and thus assured to change - whenever any data point in the response changes. This is ideal for - clients that want to learn about any change in the response. Clients - using this query parameter should probably also set a "If-none-match" - HTTP header so that if the ``timeout_ms`` expires, they can get back - a "304 Not modified" with an empty body if nothing changed. - @since protocol **v25**. - :query timeout_ms=NUMBER: *Optional.* If specified, the merchant will - wait up to ``timeout_ms`` milliseconds for the exchanges to confirm completion of the KYC process(es). - - **Response:** - - If different exchanges cause different errors when processing - the request, the largest HTTP status code that is applicable - is returned. - - :http:statuscode:`200 Ok`: - The user may be redirected to the provided locations to perform - KYC checks. - The response will be a `MerchantAccountKycRedirectsResponse` object. - Uses this status code and format only since protocol **v17**. - :http:statuscode:`204 No content`: - No possibilities for KYC operations exist. - @since protocol **v25** only returned if this instance has no bank - accounts or no exchanges are configured for the merchant backend. - :http:statuscode:`304 Not modified`: - The ``ETag`` in the response did not change compared to the one - given in the ``If-none-match`` HTTP header specified by the client. - @since protocol **v25**. - - **Details:** - - .. ts:def:: MerchantAccountKycRedirectsResponse - - interface MerchantAccountKycRedirectsResponse { - - // Array of KYC status information for - // the exchanges and bank accounts selected - // by the query. - kyc_data: MerchantAccountKycRedirect[]; - - } - - .. ts:def:: MerchantAccountKycRedirect - - interface MerchantAccountKycRedirect { - - // Summary of the status of the KYC process. Possible values are: - // - // o "unsupported-account": this exchange does not support the given account (this is unlikely to change automatically, but could be perfectly normal if the account is supported by at least one other exchange). @since protocol **v25**. - // o "no-exchange-keys": we do not (yet) have the /keys of the exchange - // - "kyc-wire-impossible": KYC auth transfer needed but not possible - // (see also: auth_conflict). - // @ "kyc-wire-required": KYC auth transfer still needed and possible - // @ "kyc-required": merchant must supply KYC data to proceed (incl. - // in case of exposed zero-limits on deposit/aggregation) - // + "awaiting-aml-review": account under review by payment provider - // + "ready": everything is fine, account can be fully used - // - "logic-bug": merchant backend logic bug - // o "merchant-internal-error": merchant had an internal error - // o "exchange-internal-error": exchange had an internal error - // o "exchange-gateway-timeout": network timeout at gateway - // o "exchange-unreachable": exchange did not respond at all to our KYC status inquiry - // this can be briefly the case even if an exchange is online, as any HTTP request - // takes time to be processed; as a result, the KYC status for this account is unknown - // - "exchange-status-invalid": exchange violated protocol in reply - // - // "+" are perfectly normal states, "@" are states where the user - // must performn an action (show link!); "o" are reasonable transient - // states that could happen and are we are expected to likely recover - // from automatically but that we should inform the user about - // (show in yellow?), "-" are hard error states from which - // there is likely no good automatic recovery from (show in red?). - status: string; - - // Full payto URI of the bank wire account this is about. - payto_uri: string; - - // Currency used by the exchange. - // @since protocol **v25**. - exchange_currency: string; - - // Hash of the salted payto://-URI of our bank wire - // account this is about. - // @since protocol **v17**. - h_wire: string; - - // Base URL of the exchange this is about. - exchange_url: string; - - // HTTP status code returned by the exchange when we asked for - // information about the KYC status. - // @since protocol **v17**. - exchange_http_status: Integer; - - // True if we did not get a ``/keys`` response from - // the exchange and thus cannot do certain checks, such as - // determining default account limits or account eligibility. - no_keys: boolean; - - // True if the given account cannot do KYC at the - // given exchange because no wire method exists that could - // be used to do the KYC auth wire transfer. - auth_conflict: boolean; - - // Numeric `error code <error-codes>` indicating errors the exchange - // returned, or TALER_EC_INVALID for none. - // Optional (as there may not always have - // been an error code). - // @since protocol **v17**. - exchange_code?: Integer; - - // Access token needed to open the KYC SPA and/or - // access the ``/kyc-info/`` endpoint. - // Optional as without the KYC auth wire transfer we - // may simply not have an access token yet. - access_token?: AccountAccessToken; - - // Array with limitations that currently apply to this - // account and that may be increased or lifted if the - // KYC check is passed. - // Note that additional limits *may* exist and not be - // communicated to the client. If such limits are - // reached, this *may* be indicated by the account - // going into ``aml_review`` state. However, it is - // also possible that the exchange may legally have - // to deny operations without being allowed to provide - // any justification. - // The limits should be used by the client to - // possibly structure their operations (e.g. withdraw - // what is possible below the limit, ask the user to - // pass KYC checks or withdraw the rest after the time - // limit is passed, warn the user to not withdraw too - // much or even prevent the user from generating a - // request that would cause it to exceed hard limits). - limits?: AccountLimit[]; - - // Array of full payto://-URIs with - // wire transfer instructions (including - // optional amount and subject) for a KYC auth wire - // transfer. Set only if this is (still) required - // to get the given exchange working. - // Array because the exchange may have multiple - // bank accounts, in which case any of these - // accounts will do. - // Optional. - // @since protocol **v17**. - payto_kycauths?: string[]; - - } - - -------------- -Bank Accounts -------------- - -One or more bank accounts must be associated with an instance -so that the instance can receive payments. Payments may be made -into any of the active bank accounts of an instance. - - -.. http:post:: [/instances/$INSTANCE]/private/accounts - - This is used to add an account to an instance. - - **Required permission:** ``accounts-write`` - - **Request:** - - The request must have an `AccountAddDetails` body. - - **Response:** - - :http:statuscode:`200 Ok`: - Adding the account was successful, we return the salt selected by the backend and the resulting wire hash in an `AccountAddResponse`. - :http:statuscode:`202 Accepted`: - 2FA is required for this operation, usually to validate the - email and/or phone numbers registered for the instance. - This returns the `ChallengeResponse`. @since **v21** - :http:statuscode:`404 Not found`: - The merchant instance is unknown or it is not in our data. - :http:statuscode:`409 Conflict`: - The provided information is inconsistent with the current state of the instance. - Usually this means we already have this account, but with conflicting credit facade information. - Inactive accounts can be reactivated using this method even if the - credit facade information differs from the previous state. - - **Details:** - - .. ts:def:: AccountAddDetails - - interface AccountAddDetails { - - // Full payto:// URI of the account. - payto_uri: string; - - // URL from where the merchant can download information - // about incoming wire transfers to this account. - credit_facade_url?: string; - - // Credentials to use when accessing the credit facade. - // Never returned on a GET (as this may be somewhat - // sensitive data). Can be set in POST - // or PATCH requests to update (or delete) credentials. - // To really delete credentials, set them to the type: "none". - credit_facade_credentials?: FacadeCredentials; - - } - - .. ts:def:: FacadeCredentials - - type FacadeCredentials = - | NoFacadeCredentials - | BasicAuthFacadeCredentials; - - .. ts:def:: NoFacadeCredentials - - interface NoFacadeCredentials { - type: "none"; - }; - - .. ts:def:: BasicAuthFacadeCredentials - - interface BasicAuthFacadeCredentials { - type: "basic"; - - // Username to use to authenticate - username: string; - - // Password to use to authenticate - password: string; - }; - - .. ts:def:: AccountAddResponse - - interface AccountAddResponse { - - // Hash over the wire details (including over the salt). - h_wire: HashCode; - - // Salt used to compute h_wire. - salt: HashCode; - - } - - -.. http:patch:: [/instances/$INSTANCE]/private/accounts/$H_WIRE - - This is used to update a bank account. - - **Required permission:** ``accounts-write`` - - **Request:** - - The request must be a `AccountPatchDetails`. - - **Response:** - - :http:statuscode:`204 No content`: - The account has successfully modified. - :http:statuscode:`404 Not found`: - The account (``H_WIRE``) is unknown to the backend. - - **Details:** - - .. ts:def:: AccountPatchDetails - - interface AccountPatchDetails { - - // URL from where the merchant can download information - // about incoming wire transfers to this account. - credit_facade_url?: string; - - // Credentials to use when accessing the credit facade. - // Never returned on a GET (as this may be somewhat - // sensitive data). Can be set in POST - // or PATCH requests to update (or delete) credentials. - // To really delete credentials, set them to the type: "none". - // If the argument is omitted, the old credentials - // are simply preserved. - credit_facade_credentials?: FacadeCredentials; - } - - -.. http:get:: [/instances/$INSTANCE]/private/accounts - - This is used to return the list of all the bank accounts - of an instance. - - **Required permission:** ``accounts-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned all the accounts. Returns a `AccountsSummaryResponse`. - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. - - **Details:** - - .. ts:def:: AccountsSummaryResponse - - interface AccountsSummaryResponse { - - // List of accounts that are known for the instance. - accounts: BankAccountEntry[]; - } - - .. ts:def:: BankAccountEntry - - interface BankAccountEntry { - - // Full payto:// URI of the account. - payto_uri: string; - - // Hash over the wire details (including over the salt). - h_wire: HashCode; - - // true if this account is active, - // false if it is historic. - active: boolean; - } - -.. http:get:: [/instances/$INSTANCE]/private/accounts/$H_WIRE - - This is used to obtain detailed information about a specific bank account. - - - **Required permission:** ``accounts-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the detailed information about a specific bank account. - Returns a `BankAccountDetail`. - :http:statuscode:`404 Not found`: - The bank account or instance is unknown to the backend. - - **Details:** - - .. ts:def:: BankAccountDetail - - interface BankAccountDetail { - - // Full payto:// URI of the account. - payto_uri: string; - - // Hash over the wire details (including over the salt). - h_wire: HashCode; - - // Salt used to compute h_wire. - salt: HashCode; - - // URL from where the merchant can download information - // about incoming wire transfers to this account. - credit_facade_url?: string; - - // true if this account is active, - // false if it is historic. - active: boolean; - } - - - -.. http:delete:: [/instances/$INSTANCE]/private/accounts/$H_WIRE - - **Required permission:** ``accounts-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deactivated the account. - :http:statuscode:`404 Not found`: - The backend does not know the instance or the account. - - --------------------- -Inventory management --------------------- - -.. _inventory: - -Inventory management is an *optional* backend feature that can be used to -manage limited stocks of products and to auto-complete product descriptions in -contracts (such that the frontends have to do less work). You can use the -Taler merchant backend to process payments *without* using its inventory -management. - -.. _decimal-quantity: - -Decimal quantities -^^^^^^^^^^^^^^^^^^ - -.. ts:def:: DecimalQuantity - - // Fixed-point decimal string in the form "<integer>[.<fraction>]". - // Fractional part has up to six digits. - // "-1" is only valid for fields that explicitly allow "infinity". - // Since protocol **v25**; used in template selection since **v25**. - type DecimalQuantity = string; - - -Managing measurement units -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCE]/private/units - - Returns the list of measurement units available to an instance. - - **Required permission:** ``units-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend returned the unit catalog. The body is a `UnitListResponse`. - - **Details:** - - .. ts:def:: UnitListResponse - - interface UnitListResponse { - units: MerchantUnit[]; - } - - .. ts:def:: MerchantUnit - - interface MerchantUnit { - // Unique serial for the unit. - unit_serial: Integer; - - // Short identifier used in product definitions. - unit: string; - - // Human-readable long label. - unit_name_long: string; - - // Human-readable short label. - unit_name_short: string; - - // Optional translations for the long label. - unit_name_long_i18n?: { [lang_tag: string]: string }; - - // Optional translations for the short label. - unit_name_short_i18n?: { [lang_tag: string]: string }; - - // Whether fractional quantities are allowed for this unit. - unit_allow_fraction: boolean; - - // Maximum fractional precision (0-6) enforced for this unit. - unit_precision_level: Integer; - - // Whether the unit is currently active. - unit_active: boolean; - - // True if the unit is provided by the backend and cannot be removed. - unit_builtin: boolean; - } - -.. http:get:: [/instances/$INSTANCE]/private/units/$UNIT - - Fetch details for a single measurement unit. - - **Required permission:** ``units-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend returned the unit definition. The body is a `MerchantUnit`. - :http:statuscode:`404 Not found`: - The unit is unknown to the backend. - - -.. http:post:: [/instances/$INSTANCE]/private/units - - Create a custom measurement unit or reactivate a previously disabled one. - - **Required permission:** ``units-write`` - - **Request:** - - The request must be a `UnitAddRequest`. - - **Response:** - - :http:statuscode:`204 No content`: - The backend added the unit. - :http:statuscode:`409 Conflict`: - A built-in unit with the same short name already exists. - - .. ts:def:: UnitAddRequest - - interface UnitAddRequest { - // Short identifier to reference the unit from products and orders. - unit: string; - - // Human-readable long label (e.g. "kilogram"). - unit_name_long: string; - - // Human-readable short label (e.g. "kg"). - unit_name_short: string; - - // Optional translations for the long label keyed by BCP 47 language tags. - unit_name_long_i18n?: { [lang_tag: string]: string }; - - // Optional translations for the short label keyed by BCP 47 language tags. - unit_name_short_i18n?: { [lang_tag: string]: string }; - - // Defaults to false; set to true to enable fractional quantities. - unit_allow_fraction?: boolean; - - // Fractional precision (0-6). Ignored when ``unit_allow_fraction`` is false. - unit_precision_level?: Integer; - - // Defaults to true. - unit_active?: boolean; - } - - -.. http:patch:: [/instances/$INSTANCE]/private/units/$UNIT - - Update attributes of a measurement unit. - - **Required permission:** ``units-write`` - - **Request:** - - The request must be a `UnitPatchRequest`. - - **Response:** - - :http:statuscode:`204 No content`: - The backend updated the unit. - :http:statuscode:`404 Not found`: - The unit is unknown to the backend. - - Built-in units allow changing ``unit_allow_fraction``, ``unit_precision_level``, and - ``unit_active``; other fields are immutable for built-ins. - - .. ts:def:: UnitPatchRequest - - interface UnitPatchRequest { - // Updated human-readable long label. - unit_name_long?: string; - - // Updated human-readable short label. - unit_name_short?: string; - - // Updated translations for the long label keyed by BCP 47 language tags. - unit_name_long_i18n?: { [lang_tag: string]: string }; - - // Updated translations for the short label keyed by BCP 47 language tags. - unit_name_short_i18n?: { [lang_tag: string]: string }; - - // Override to allow or forbid fractional quantities. - unit_allow_fraction?: boolean; - - // Override for the fractional precision (0-6). Ignored if fractions are disabled. - unit_precision_level?: Integer; - - // Toggle whether the unit is active. - unit_active?: boolean; - } - - Fractional precision is capped at six decimal places. Disabling - ``unit_allow_fraction`` forces ``unit_precision_level`` to zero. - - -.. http:delete:: [/instances/$INSTANCE]/private/units/$UNIT - - Remove a custom unit from an instance. - - **Required permission:** ``units-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The unit was removed. - :http:statuscode:`404 Not found`: - The unit is unknown to the backend. - :http:statuscode:`409 Conflict`: - Built-in units cannot be deleted. - - -Managing product categories -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCE]/private/categories - - This request returns the known product categories - and the number of products in each category. - Since API version **v16**. - - **Required permission:** ``categories-read`` - - **Response:** - - :http:statuscode:`200 Ok`: - The body is a `CategoryListResponse`. - - **Details:** - - .. ts:def:: CategoryListResponse - - interface CategoryListResponse { - - // Array with all of the categories we know. - categories: CategoryListEntry[]; - - } - - .. ts:def:: CategoryListEntry - - interface CategoryListEntry { - - // Unique number for the category. - category_id: Integer; - - // Name of the category. - name: string; - - // Translations of the name into various - // languages. - name_i18n?: { [lang_tag: string]: string }; - - // Number of products in this category. - // A product can be in more than one category. - product_count: Integer; - - } - -.. http:get:: [/instances/$INSTANCE]/private/categories/$CATEGORY_ID - - This request returns the known products in the given - category. - Since API version **v16**. - - **Required permission:** ``categories-read`` - - **Response:** - - :http:statuscode:`200 Ok`: - The body is a `CategoryProductListResponse`. - - **Details:** - - .. ts:def:: CategoryProductListResponse - - interface CategoryProductListResponse { - - // Name of the category. - name: string; - - // Translations of the name into various - // languages. - name_i18n?: { [lang_tag: string]: string }; - - // The products in this category. - products: CategoryProductSummary[]; - - } - - .. ts:def:: CategoryProductSummary - - interface CategoryProductSummary { - - // ID of a product in the category. - product_id: string; - - } - - -.. http:post:: [/instances/$INSTANCE]/private/categories - - This is used to create a new category for the inventory. - Since API version **v16**. - - **Required permission:** ``categories-write`` - - **Request:** - - The request is a `CategoryCreateRequest`. - - **Response:** - - :http:statuscode:`200 Ok`: - The response is a `CategoryCreatedResponse`. - - **Details:** - - .. ts:def:: CategoryCreateRequest - - interface CategoryCreateRequest { - - // Name of the category. - name: string; - - // Translations of the name into various - // languages. - name_i18n?: { [lang_tag: string]: string }; - - } - - .. ts:def:: CategoryCreatedResponse - - interface CategoryCreatedResponse { - - // Number of the newly created category. - category_id: Integer; - } - - -.. http:patch:: [/instances/$INSTANCE]/private/categories/$CATEGORY_ID - - This is used to edit a category. - Since API version **v16**. - - **Required permission:** ``categories-write`` - - **Request:** - - The request is a `CategoryCreateRequest`. - - **Response:** - - :http:statuscode:`204 No Content`: - The category was modified successfully. - -.. http:delete:: [/instances/$INSTANCE]/private/categories/$CATEGORY_ID - - This is used to delete a category. - Since API version **v16**. - - **Required permission:** ``categories-write`` - - **Response:** - - :http:statuscode:`204 No Content`: - The category was deleted. - :http:statuscode:`404 Not Found`: - The category was possibly already deleted or is unknown. - - -Managing products in the inventory -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:post:: [/instances/$INSTANCE]/private/products - - This is used to add a product to the inventory. - - **Required permission:** ``products-write`` - - **Request:** - - The request must be a `ProductAddDetailRequest`. - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully expanded the inventory. - :http:statuscode:`404 Not found`: - The instance, category, product group or money pot specified are - unknown. Possible error ``code`` values are thus: - ``TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN`` (instance unknown), - ``TALER_EC_MERCHANT_GENERIC_PRODUCT_GROUP_UNKNOWN`` (product group unknown) - ``TALER_EC_MERCHANT_GENERIC_MONEY_POT_UNKNOWN`` (money pot unknown), - ``TALER_EC_MERCHANT_GENERIC_CATEGORY_UNKNOWN`` - (category unknown, specific category is given in the details). - - :http:statuscode:`409 Conflict`: - The backend already knows a product with this product ID, - but with different details. Returned with a ``code`` of - ``TALER_EC_MERCHANT_PRIVATE_POST_PRODUCTS_CONFLICT_PRODUCT_EXISTS``. - - **Details:** - - .. ts:def:: ProductAddDetailRequest - - interface ProductAddDetailRequest { - - // Product ID to use. - product_id: string; - - // Human-readable product name. - // Since API version **v20**. Optional only for - // backwards-compatibility, should be considered mandatory - // moving forward! - product_name?: string; - - // Human-readable product description. - description: string; - - // Map from IETF BCP 47 language tags to localized descriptions. - description_i18n?: { [lang_tag: string]: string }; - - // Categories into which the product belongs. - // Used in the POS-endpoint. - // Since API version **v16**. - categories?: Integer[]; - - // Unit in which the product is measured (liters, kilograms, packages, etc.). - unit: string; - - // Optional override to control whether fractional quantities are permitted. - // Defaults to the policy implied by ``unit``. - unit_allow_fraction?: boolean; - - // Override for the fractional precision level (0-6). Only relevant if - // ``unit_allow_fraction`` is true. Defaults come from ``unit``. - unit_precision_level?: Integer; - - // Preferred way to express inventory counts using "<integer>[.<fraction>]" syntax. - // Use "-1" for unlimited stock. Required unless ``total_stock`` is provided. - unit_total_stock?: DecimalQuantity; - - // Legacy stock counter. Deprecated, use ``unit_total_stock`` instead. - // Still required when ``unit_total_stock`` is omitted. - total_stock?: Integer; - - // Preferred way to express the per-unit price of the product. Supply at least one entry; - // the first entry must match ``price``. - // The price given MUST include applicable taxes if ``price_is_net`` - // is false, and MUST exclude applicable taxes if ``price_is_net`` - // is true. - // Zero implies that the product is not sold separately or that the price must be supplied - // by the frontend. - // Each entry must use a distinct currency. - // Since API version **v25**. - // Currency uniqueness enforced since protocol **v25**. - unit_price?: Amount[]; - - // True if the price(s) given are a net prices, false if they are - // gross prices. - // Since protocol **vTAXES**. - price_is_net?: boolean; - - // Legacy price field. - // Deprecated since **v25**; - // when present it must match the first element of ``unit_price``. - price?: Amount; - - // An optional base64-encoded product image. - image?: ImageDataUrl; - - // A list of taxes paid by the merchant for one unit of this product. - taxes?: Tax[]; - - // Identifies where the product is in stock. - address?: Location; - - // Identifies when we expect the next restocking to happen. - next_restock?: Timestamp; - - // Minimum age buyer must have (in years). Default is 0. - minimum_age?: Integer; - - // Product group the product belongs to. 0 and missing both - // means default. - // Since **v25**. - product_group_id?: Integer; - - // Money pot revenue on the product should be accounted in. - // 0 and missing both mean no money pot (revenue accounted - // in money pot of the overall order or not at all). - // Since **v25**. - money_pot_id?: Integer; - - } - - Clients SHOULD migrate to the new ``unit_*`` fields and treat ``total_stock`` and ``price`` - as deprecated compatibility shims. If both the legacy and the new representation are supplied, - their values must match. Omitting both ``unit_total_stock`` and ``total_stock`` (or both - ``unit_price`` and ``price``) results in a ``400 Bad Request``. When only ``price`` is given, - the backend treats it as a one-element ``unit_price`` array. - - ``unit_total_stock`` uses a fixed-point decimal string in the form ``INTEGER[.FRACTION]`` with - at most six fractional digits. Scientific notation or special values such as ``NaN`` are not - accepted. Supply ``"-1"`` to represent unlimited stock. See - :ref:`DecimalQuantity <decimal-quantity>`. - - Fractional behaviour defaults to the value of ``unit``. The backend disables fractions for - ``Piece``, ``Set``, ``Custom``, ``WeightUnitMg`` and ``SizeUnitMm``. Other predefined units - allow fractional quantities with the following default precision levels: - - - Precision ``1``: ``WeightUnitG``, ``SizeUnitCm``, ``SurfaceUnitMm2``, ``VolumeUnitMm3``. - - Precision ``2``: ``WeightUnitOunce``, ``SizeUnitInch``, ``SurfaceUnitCm2``, - ``VolumeUnitInch3``, ``VolumeUnitOunce``, ``TimeUnitHour``, ``TimeUnitMonth``. - - Precision ``3``: ``WeightUnitTon``, ``WeightUnitKg``, ``WeightUnitPound``, ``SizeUnitM``, - ``SizeUnitDm``, ``SizeUnitFoot``, ``SurfaceUnitDm2``, ``SurfaceUnitFoot2``, ``VolumeUnitCm3``, - ``VolumeUnitLitre``, ``VolumeUnitGallon``, ``TimeUnitSecond``, ``TimeUnitMinute``, - ``TimeUnitDay``, ``TimeUnitWeek``. - - Precision ``4``: ``SurfaceUnitM2``, ``SurfaceUnitInch2``, ``TimeUnitYear``. - - Precision ``5``: ``VolumeUnitDm3``, ``VolumeUnitFoot3``. - - Precision ``6``: ``VolumeUnitM3``. - - Integrations can override these defaults by explicitly setting ``unit_allow_fraction`` and/or - ``unit_precision_level``. - - -.. http:patch:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID - - This is used to update product details in the inventory. Note that the - ``total_stock`` and ``total_lost`` numbers MUST be greater or equal than - previous values (this design ensures idempotency). In case stocks were lost - but not sold, increment the ``total_lost`` number. All fields in the - request are optional, those that are not given are simply preserved (not - modified). Note that the ``description_i18n`` and ``taxes`` can only be - modified in bulk: if it is given, all translations must be provided, not - only those that changed. ``never`` should be used for the ``next_restock`` - timestamp to indicate no intention/possibility of restocking, while a time - of zero is used to indicate "unknown". - - **Required permission:** ``products-write`` - - **Request:** - - The request must be a `ProductPatchDetailRequest`. - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully expanded the inventory. - :http:statuscode:`404 Not found`: - The instance, product, category, product group or money pot specified are - unknown. Possible error ``code`` values are thus: - ``TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN`` (instance unknown), - ``TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN`` (product unknown), - ``TALER_EC_MERCHANT_GENERIC_PRODUCT_GROUP_UNKNOWN`` (product group unknown) - ``TALER_EC_MERCHANT_GENERIC_MONEY_POT_UNKNOWN`` (money pot unknown), - ``TALER_EC_MERCHANT_GENERIC_CATEGORY_UNKNOWN`` - (category unknown, specific category is given in the details). - :http:statuscode:`409 Conflict`: - The provided information is inconsistent with the current state of - the inventory. - - - .. ts:def:: ProductPatchDetailRequest - - interface ProductPatchDetailRequest { - - // Human-readable product name. - // Since API version **v20**. Optional only for - // backwards-compatibility, should be considered mandatory - // moving forward! - product_name?: string; - - // Human-readable product description. - description: string; - - // Map from IETF BCP 47 language tags to localized descriptions. - description_i18n?: { [lang_tag: string]: string }; - - // Unit in which the product is measured (liters, kilograms, packages, etc.). - unit: string; - - // Optional override to control whether fractional quantities are permitted. - unit_allow_fraction?: boolean; - - // Override for the fractional precision level (0-6). Only relevant if - // ``unit_allow_fraction`` is true. - unit_precision_level?: Integer; - - // Categories into which the product belongs. - // Used in the POS-endpoint. - // Since API version **v16**. - categories?: Integer[]; - - // Preferred way to express the per-unit price. Supply at least one entry; - // the first entry represents the base price and MUST include applicable taxes. - // Zero implies that the product is not sold separately or that the price must be supplied - // by the frontend. - // Each entry must use a distinct currency. - // Since API version **v25**. - // Currency uniqueness enforced since protocol **v25**. - unit_price?: Amount[]; - - // Legacy price field. - // Deprecated since **v25**; - // when present it must match the first element of ``unit_price``. - price?: Amount; - - // True if the price(s) given are a net prices, false if they are - // gross prices. - // Since protocol **vTAXES**. - price_is_net?: boolean; - - // An optional base64-encoded product image. - image?: ImageDataUrl; - - // A list of taxes paid by the merchant for one unit of this product. - taxes?: Tax[]; - - // Preferred way to express inventory counts using "<integer>[.<fraction>]" syntax. - // Use "-1" for unlimited stock. - unit_total_stock?: DecimalQuantity; - - // Legacy stock counter. Deprecated, use ``unit_total_stock`` instead. - total_stock?: Integer; - - // Number of units of the product that were lost (spoiled, stolen, etc.). - total_lost?: Integer; - - // Identifies where the product is in stock. - address?: Location; - - // Identifies when we expect the next restocking to happen. - next_restock?: Timestamp; - - // Minimum age buyer must have (in years). Default is 0. - minimum_age?: Integer; - - // Product group the product belongs to. 0 and missing both - // means default. - // Since **v25**. - product_group_id?: Integer; - - // Money pot revenue on the product should be accounted in. - // 0 and missing both mean no money pot (revenue accounted - // in money pot of the overall order or not at all). - // Since **v25**. - money_pot_id?: Integer; - - } - - The same compatibility rules for the ``unit_*`` fields and their deprecated counterparts apply - when patching an existing product. - - -.. http:get:: [/instances/$INSTANCE]/private/products - - This is used to return the list of all items in the inventory. - - **Required permission:** ``products-read`` - - **Request:** - - :query limit: *Optional*. At most return the given number of results. Negative for descending by row ID, positive for ascending by row ID. Default is ``20``. Since protocol **v12**. - :query offset: *Optional*. Starting ``product_serial_id`` for an iteration. Since protocol **v12**. - :query category_filter: *Optional*. Only returns products that are in a category where the category name contains the given text as a substring. Matching is case-insensitive. Since protocol **v23**. - :query name_filter: *Optional*. Only returns products where the product name contains the given text as a substring. Matching is case-insensitive. Since protocol **v23**. - :query description_filter: *Optional*. Only returns products where the product description contains the given text as a substring. Matching is case-insensitive. Since protocol **v23**. - :query product_group_serial: *Optional*. Only returns products where the product group serial matches the given value. Since protocol **v25**. - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the inventory. Returns - a `InventorySummaryResponse`. - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. - - **Details:** - - .. ts:def:: InventorySummaryResponse - - interface InventorySummaryResponse { - // List of products that are present in the inventory. - products: InventoryEntry[]; - } - - The `InventoryEntry` object describes an item in the inventory. It has the following structure: - - .. ts:def:: InventoryEntry - - interface InventoryEntry { - // Product identifier, as found in the product. - product_id: string; - - // ``product_serial_id`` of the product in the database. - product_serial: Integer; - - } - - -.. http:get:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID - - This is used to obtain detailed information about a product in the inventory. - - **Required permission:** ``products-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the inventory. Returns - a `ProductDetailResponse`. - :http:statuscode:`404 Not found`: - The product (ID) is unknown to the backend. - - **Details:** - - .. ts:def:: ProductDetailResponse - - interface ProductDetailResponse { - - // Human-readable product name. - // Since API version **v20**. - product_name: string; - - // Human-readable product description. - description: string; - - // Map from IETF BCP 47 language tags to localized descriptions. - description_i18n: { [lang_tag: string]: string }; - - // Unit in which the product is measured (liters, kilograms, packages, etc.). - unit: string; - - // Does the backend allow fractional quantities for this unit? - unit_allow_fraction: boolean; - - // Maximum fractional precision (0-6) enforced for inventory operations. - unit_precision_level: Integer; - - // Categories into which the product belongs. - // Since API version **v16**. - categories: Integer[]; - - // Price tiers for this product. The first entry represents the base price and MUST include - // applicable taxes. Zero implies the product is not sold separately or that the price is not - // fixed, and must be supplied by the front-end. - unit_price: Amount[]; - - // Legacy price field kept for compatibility. - // Deprecated since **v25**; - // equal to the first element of ``unit_price``. - price: Amount; - - // An optional base64-encoded product image. - image: ImageDataUrl; - - // A list of taxes paid by the merchant for one unit of this product. - // Optional since **v15**. - taxes?: Tax[]; - - // True if the price(s) given are a net prices, false if they are - // gross prices. - // Since protocol **vTAXES**. - price_is_net: boolean; - - // Legacy integer stock counter kept for compatibility. ``-1`` indicates unlimited stock. - total_stock: Integer; - - // Stock expressed using "<integer>[.<fraction>]" syntax with up to six fractional digits. - // Use ``"-1"`` for unlimited stock. - unit_total_stock: DecimalQuantity; - - // Number of units of the product that have already been sold. - total_sold: Integer; - - // Number of units of the product that were lost (spoiled, stolen, etc.). - total_lost: Integer; - - // Identifies where the product is in stock. - // Optional since **v15**. - address?: Location; - - // Identifies when we expect the next restocking to happen. - next_restock?: Timestamp; - - // Minimum age buyer must have (in years). - minimum_age?: Integer; - - // Product group the product belongs to. Missing means default. - // Since **v25**. - product_group_id?: Integer; - - // Money pot revenue on the product should be accounted in. - // Missing means no money pot (revenue accounted - // in money pot of the overall order or not at all). - // Since **v25**. - money_pot_id?: Integer; - - } - - -.. http:delete:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID - - Delete information about a product. Fails if the product is locked by - anyone. - - **Required permission:** ``products-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deleted the product. - :http:statuscode:`404 Not found`: - The backend does not know the instance or the product. - :http:statuscode:`409 Conflict`: - The backend refuses to delete the product because it is locked. - - - -Providing configuration data for point-of-sale terminals -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCE]/private/pos - - This is used to return the point-of-sale (POS) configuration with full details on all items in the inventory. - - Endpoint was introduced in protocol **v15**. - - **Required permission:** ``products-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the inventory. Returns - a `FullInventoryDetailsResponse`. - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. - - **Details:** - - .. ts:def:: FullInventoryDetailsResponse - - interface FullInventoryDetailsResponse { - - // List of products that are present in the inventory. - products: MerchantPosProductDetail[]; - - // List of categories in the inventory. - categories: MerchantCategory[]; - - } - - .. ts:def:: MerchantPosProductDetail - - interface MerchantPosProductDetail { - - // A unique numeric ID of the product - product_serial: Integer; - - // A merchant-internal unique identifier for the product. - product_id: string; - - // Human-readable product name. - // Since API version **v20**. - product_name: string; - - // A list of category IDs this product belongs to. - // Typically, a product only belongs to one category, but more than one is supported. - categories: Integer[]; - - // Human-readable product description. - description: string; - - // Map from IETF BCP 47 language tags to localized descriptions. - description_i18n: { [lang_tag: string]: string }; - - // Unit in which the product is measured (liters, kilograms, packages, etc.). - unit: string; - - // Does the backend allow fractional quantities for this unit? - unit_allow_fraction: boolean; - - // Maximum fractional precision (0-6) enforced for inventory operations. - unit_precision_level: Integer; - - // Price tiers for this product. The first entry represents the base price and MUST include - // applicable taxes. Zero implies the product is not sold separately or that the price is not - // fixed, and must be supplied by the front-end. - unit_price: Amount[]; - - // Legacy price field kept for compatibility. Deprecated; equal to the first element of ``unit_price``. - price: Amount; - - // An optional base64-encoded product image. - image?: ImageDataUrl; - - // A list of taxes paid by the merchant for one unit of this product. - taxes?: Tax[]; - - // Legacy integer stock counter kept for compatibility. ``-1`` indicates unlimited stock. - total_stock?: Integer; - - // Stock expressed using "<integer>[.<fraction>]" syntax with up to six fractional digits. - // Use ``"-1"`` for unlimited stock. - unit_total_stock: string; - - // Minimum age buyer must have (in years). - minimum_age?: Integer; - - } - - .. ts:def:: MerchantCategory - - interface MerchantCategory { - // A unique numeric ID of the category - id: Integer; - - // The name of the category. This will be shown to users and used in the order summary. - name: string; - - // Map from IETF BCP 47 language tags to localized names - name_i18n?: { [lang_tag: string]: string }; - } - - -Fetching product images -^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:get:: /products/$IMAGE_HASH/image - - Returns a stored product image by its content hash. The hash is the lowercase - hexadecimal SHA-256 digest of the base64-encoded image data supplied in - ``image`` during product creation or update. - - **Required permission:** none (public endpoint) - - **Response:** - - :http:statuscode:`200 OK`: - The body is a `ProductImageResponse`. - :http:statuscode:`400 Bad Request`: - The hash is not a valid hex-encoded SHA-256 digest. - :http:statuscode:`404 Not found`: - No image is known for the given hash. - - .. ts:def:: ProductImageResponse - - interface ProductImageResponse { - // Data URL containing the product image as stored in the backend. - image: ImageDataUrl; - } - - - -Reserving inventory -^^^^^^^^^^^^^^^^^^^ - -.. http:post:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID/lock - - This is used to lock a certain quantity of the product for a limited - duration while the customer assembles a complete order. Note that - frontends do not have to "unlock", they may rely on the timeout as - given in the ``duration`` field. Re-posting a lock with a different - ``duration`` or ``quantity`` updates the existing lock for the same UUID - and does not result in a conflict. - - Unlocking by using a ``quantity`` of zero is - optional but recommended if customers remove products from the - shopping cart. Note that actually POSTing to ``/orders`` with set - ``inventory_products`` and using ``lock_uuids`` will **transition** the - lock to the newly created order (which may have a different ``duration`` - and ``quantity`` than what was requested in the lock operation). - If an order is for fewer items than originally locked, the difference - is automatically unlocked. - - **Required permission:** ``products-lock`` - - **Request:** - - The request must be a `LockRequest`. - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully locked (or unlocked) the requested ``quantity``. - :http:statuscode:`404 Not found`: - The backend has does not know this product. - :http:statuscode:`410 Gone`: - The backend does not have enough of product in stock. Returns an `OutOfStockResponse`. - - **Details:** - - .. ts:def:: LockRequest - - interface LockRequest { - - // UUID that identifies the frontend performing the lock - // Must be unique for the lifetime of the lock. - lock_uuid: string; - - // How long does the frontend intend to hold the lock? - duration: RelativeTime; - - // Legacy integer quantity to lock. Deprecated; defaults to 1 if both - // ``quantity`` and ``unit_quantity`` are absent. - quantity?: Integer; - - // Preferred way to express the requested quantity using "<integer>[.<fraction>]" syntax. - unit_quantity?: string; - - } - - At least one of ``quantity`` or ``unit_quantity`` must be supplied; omitting both defaults to a - quantity of one. ``unit_quantity`` follows the same decimal-string format described for - ``unit_total_stock``. - - .. note:: - - The ``GNUNET_CRYPTO_random_timeflake()`` C API can be used - to generate such timeflakes for clients written in C. - - - ------------------- -Payment processing ------------------- - -To process Taler payments, a merchant must first set up an order with -the merchant backend. The order is then claimed by a wallet, and -paid by the wallet. The merchant can check the payment status of the -order. Once the order is paid, the merchant may (for a limited time) -grant refunds on the order. - -Creating orders -^^^^^^^^^^^^^^^ - -.. _post-order: - -.. http:post:: [/instances/$INSTANCE]/private/orders - - Create a new order that a customer can pay for. - - This request is **not** idempotent unless an ``order_id`` is explicitly specified. - However, while repeating without an ``order_id`` will create another order, that is - generally pretty harmless (as long as only one of the orders is returned to the wallet). - - .. note:: - - This endpoint does not return a URL to redirect your user to confirm the - payment. To get this URL use either - :http:get:`[/instances/$INSTANCE]/orders/$ORDER_ID` (with - ``taler_pay_uri`` in the `StatusUnpaidResponse`), or - :http:get:`[/instances/$INSTANCE]/private/orders/$ORDER_ID` with the - ``taler_pay_uri`` in the `CheckPaymentUnpaidResponse`). That said, - it is also possible to construct the URL by combining the base URL - with the information from the `PostOrderResponse`. - The API is structured this way since the payment redirect URL is not - unique for every order: there might be varying parameters such as the - session id. - - **Required permission:** ``orders-write`` - - **Request:** - - The request must be a `PostOrderRequest`. - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully created the proposal. The response is a - :ts:type:`PostOrderResponse`. - :http:statuscode:`404 Not found`: - Possible reasons are: - - (1) The order given used products from the inventory, but those were - not found in the inventory. - (2) The merchant instance is unknown (including possibly the instance - being not configured for new orders). - (3) The wire method specified is not supported by the backend. - (4) An OTP device ID was specified and is unknown. - - Details in the error code. - NOTE: currently the client has no good way to find out which product - is not in the inventory, we MAY want to specify that in the reply. - :http:statuscode:`409 Conflict`: - A different proposal already exists under the specified order ID, - or the requested currency is not supported by this backend. Details in - the error code. - :http:statuscode:`410 Gone`: - The order given used products from the inventory that are out of stock. - The response is a :ts:type:`OutOfStockResponse`. - :http:statuscode:`451 Unavailable for Legal Reasons`: - The order could not be created because of legal - reasons, specifically no exchange would accept - a payment at this time because we have not yet - satisfied the respective legal requirements. - The :ref:`KYC status <merchantkycstatus>` API - can be used to determine details about how to - proceed with the KYC process. - Since **v25**, the body is an - `OrderRefusedErrorDetailResponse` with an error - code of ``MERCHANT_PRIVATE_POST_ORDERS_AMOUNT_EXCEEDS_LEGAL_LIMITS``. - - **Details:** - - .. ts:def:: PostOrderRequest - - interface PostOrderRequest { - // The order must at least contain the minimal - // order detail, but can override all. - order: Order; - - // If set, the backend will then set the refund deadline to the - // payment deadline plus the specified delay. - // If it's not set, the default value of the backend might be - // used. Note that both this value and the backend default - // will be ignored if ``refund_deadline`` is set in ``order`` - // as the ``refund_deadline`` takes precedence. - // A value of "forever" is not allowed. - refund_delay?: RelativeTime; - - // Specifies the payment target preferred by the client. Can be used - // to select among the various (active) wire methods supported by the instance. - payment_target?: string; - - // The session for which the payment is made (or replayed). - // Only set for session-based payments. - // Since protocol **v6**. - session_id?: string; - - // Specifies that some products are to be included in the - // order from the inventory. For these inventory management - // is performed (so the products must be in stock) and - // details are completed from the product data of the backend. - inventory_products?: MinimalInventoryProduct[]; - - // Specifies a lock identifier that was used to - // lock a product in the inventory. Only useful if - // ``inventory_products`` is set. Used in case a frontend - // reserved quantities of the individual products while - // the shopping cart was being built. Multiple UUIDs can - // be used in case different UUIDs were used for different - // products (i.e. in case the user started with multiple - // shopping sessions that were combined during checkout). - lock_uuids?: string[]; - - // Should a token for claiming the order be generated? - // False can make sense if the ORDER_ID is sufficiently - // high entropy to prevent adversarial claims (like it is - // if the backend auto-generates one). Default is 'true'. - // Note: This is NOT related to tokens used for subscriptins or discounts. - create_token?: boolean; - - // OTP device ID to associate with the order. - // This parameter is optional. - otp_id?: string; - - } - - The `Order` object represents the starting point for new `ContractTerms`. - After validating and sanatizing all inputs, the merchant backend will add - additional information to the order and create a new `ContractTerms` object - that will be stored in the database. - - .. ts:def:: Order - - type Order = (OrderV1 | OrderV0) & OrderCommon; - - .. ts:def:: OrderV1 - - interface OrderV1 { - // Version 1 order support discounts and subscriptions. - // https://docs.taler.net/design-documents/046-mumimo-contracts.html - // @since protocol **v21** - version: 1; - - // List of contract choices that the customer can select from. - // @since protocol **v21** - choices?: OrderChoice[]; - } - - .. ts:def:: OrderV0 - - interface OrderV0 { - // Optional, defaults to 0 if not set. - version?: 0; - - // Total price for the transaction, including tip. The exchange will - // subtract deposit fees from that amount before transferring it to - // the merchant. - amount: Amount; - - // Optional tip amount. Must match the currency of ``amount``. - // Since protocol **v25**. - tip?: Amount; - - // Maximum total deposit fee accepted by the merchant for this contract. - // Overrides defaults of the merchant instance. - max_fee?: Amount; - } - - .. ts:def:: OrderCommon - - interface OrderCommon { - // Human-readable description of the whole purchase. - summary: string; - - // Map from IETF BCP 47 language tags to localized summaries. - summary_i18n?: { [lang_tag: string]: string }; - - // Unique identifier for the order. Only characters - // allowed are "A-Za-z0-9" and ".:_-". - // Must be unique within a merchant instance. - // For merchants that do not store proposals in their DB - // before the customer paid for them, the ``order_id`` can be used - // by the frontend to restore a proposal from the information - // encoded in it (such as a short product identifier and timestamp). - order_id?: string; - - // URL where the same contract could be ordered again (if - // available). Returned also at the public order endpoint - // for people other than the actual buyer (hence public, - // in case order IDs are guessable). - public_reorder_url?: string; - - // See documentation of ``fulfillment_url`` field in `ContractTerms`. - // Either fulfillment_url or fulfillment_message must be specified. - // When creating an order, the fulfillment URL can - // contain ``${ORDER_ID}`` which will be substituted with the - // order ID of the newly created order. - fulfillment_url?: string; - - // See documentation of ``fulfillment_message`` in `ContractTerms`. - // Either ``fulfillment_url`` or ``fulfillment_message`` must be specified. - fulfillment_message?: string; - - // Map from IETF BCP 47 language tags to localized fulfillment - // messages. - fulfillment_message_i18n?: { [lang_tag: string]: string }; - - // Minimum age the buyer must have to buy. - minimum_age?: Integer; - - // List of products that are part of the purchase. - products?: ProductSold[]; - - // Time when this contract was generated. If null, defaults to current - // time of merchant backend. - timestamp?: Timestamp; - - // After this deadline has passed, no refunds will be accepted. - // Overrides deadline calculated from ``refund_delay`` in - // ``PostOrderRequest``. - // A value of "never" is not allowed. - refund_deadline?: Timestamp; - - // After this deadline, the merchant won't accept payments for the contract. - // Overrides deadline calculated from default pay delay configured in - // merchant backend. - // A value of "never" is not allowed. - pay_deadline?: Timestamp; - - // Transfer deadline for the exchange. Must be in the deposit permissions - // of coins used to pay for this order. - // Overrides deadline calculated from default wire transfer delay - // configured in merchant backend. Must be after refund deadline. - // A value of "never" is not allowed. - wire_transfer_deadline?: Timestamp; - - // Base URL of the (public!) merchant backend API. - // Must be an absolute URL that ends with a slash. - // Defaults to the base URL this request was made to. - merchant_base_url?: string; - - // Delivery location for (all!) products. - delivery_location?: Location; - - // Time indicating when the order should be delivered. - // May be overwritten by individual products. - // Must be in the future. - delivery_date?: Timestamp; - - // See documentation of ``auto_refund`` in ``ContractTerms``. - // Specifies for how long the wallet should try to get an - // automatic refund for the purchase. - auto_refund?: RelativeTime; - - // Extra data that is only interpreted by the merchant frontend. - // Useful when the merchant needs to store extra information on a - // contract without storing it separately in their database. - // Must really be an Object (not a string, integer, float or array). - extra?: Object; - - // Money pot to increment for whatever order payment amount - // is not yet assigned to a pot via the ``ProductSold``. - // Not useful to wallets, only for - // merchant-internal accounting. - // Since protocol **v25**. - order_default_money_pot?: Integer; - - } - - - The `OrderChoice` object describes a possible choice within an order. The - choice is done by the wallet and consists of in- and outputs. In the example - of buying an article, the merchant could present the customer with the - choice to use a valid subscription token or pay using a gift - voucher. Available since protocol **v21**. - - .. ts:def:: OrderChoice - - interface OrderChoice { - // Total price for the choice. The exchange will subtract deposit - // fees from that amount before transferring it to the merchant. - amount: Amount; - - // Optional tip amount. Must match the currency of ``amount``. - // Since protocol **v25**. - tip?: Amount; - - // Human readable description of the semantics of the choice - // within the contract to be shown to the user at payment. - description?: string; - - // Map from IETF 47 language tags to localized descriptions. - description_i18n?: { [lang_tag: string]: string }; - - // Inputs that must be provided by the customer, if this choice is selected. - // Defaults to empty array if not specified. - inputs?: OrderInput[]; - - // Outputs provided by the merchant, if this choice is selected. - // Defaults to empty array if not specified. - outputs?: OrderOutput[]; - - // Maximum total deposit fee accepted by the merchant for this contract. - // Overrides defaults of the merchant instance. - max_fee?: Amount; - } - - .. ts:def:: OrderInput - - // For now, only token inputs are supported. - type OrderInput = OrderInputToken; - - .. ts:def:: OrderInputToken - - interface OrderInputToken { - - // Token input. - type: "token"; - - // Token family slug as configured in the merchant backend. Slug is unique - // across all configured tokens of a merchant. - token_family_slug: string; - - // How many units of the input are required. - // Defaults to 1 if not specified. Output with count == 0 are ignored by - // the merchant backend. - count?: Integer; - - } - - .. ts:def:: OrderOutput - - type OrderOutput = OrderOutputToken | OrderOutputTaxReceipt; - - .. ts:def:: OrderOutputToken - - interface OrderOutputToken { - - // Token output. - type: "token"; - - // Token family slug as configured in the merchant backend. Slug is unique - // across all configured tokens of a merchant. - token_family_slug: string; - - // How many units of the output are issued by the merchant. - // Defaults to 1 if not specified. Output with count == 0 are ignored by - // the merchant backend. - count?: Integer; - - // When should the output token be valid. Can be specified if the - // desired validity period should be in the future (like selling - // a subscription for the next month). Optional. If not given, - // the validity is supposed to be "now" (time of order creation). - valid_at?: Timestamp; - - } - - .. ts:def:: OrderOutputTaxReceipt - - interface OrderOutputTaxReceipt { - - // Tax receipt output. - type: "tax-receipt"; - - } - - The following `MinimalInventoryProduct` can be provided if the parts of the - order are inventory-based, that is if the `PostOrderRequest` uses - ``inventory_products``. For such products, which must be in the backend's inventory, - the backend can automatically fill in the amount and other details about - the product that are known to it from its ``products`` table. - Note that the ``inventory_products`` will be appended to the - list of ``products`` that the frontend already put into the ``order``. - So if the frontend can sell additional non-inventory products together - with ``inventory_products``. Note that the backend will NOT update - the ``amount`` of the ``order``, so the frontend must already have calculated - the total price --- including the ``inventory_products``. - - .. ts:def:: MinimalInventoryProduct - - // Note that if the frontend does give details beyond these, - // it will override those details (including price or taxes) - // that the backend would otherwise fill in via the inventory. - interface MinimalInventoryProduct { - - // Which product is requested (here mandatory!). - product_id: string; - - // Legacy integer quantity. - // Deprecated since **v25**; - // defaults to 1 if both ``quantity`` and ``unit_quantity`` are absent. - quantity?: Integer; - - // Preferred quantity string using "<integer>[.<fraction>]" syntax. - // @since **v25**; - unit_quantity?: string - - // Money pot to use for this product, overrides value from - // the inventory if given. - // Since **v25**. - product_money_pot?: Integer; - - } - - Supply either ``quantity`` or ``unit_quantity`` when referencing inventory products. If both are - missing the backend assumes a quantity of one. ``unit_quantity`` follows the same decimal-string - rules as ``unit_total_stock``. - - .. ts:def:: PostOrderResponse - - interface PostOrderResponse { - // Order ID of the response that was just created. - order_id: string; - - // Deadline when the offer expires; the customer must pay before. - // @since protocol **v21**. - pay_deadline: Timestamp; - - // Token that authorizes the wallet to claim the order. - // Provided only if "create_token" was set to 'true' - // in the request. - token?: ClaimToken; - } - - .. ts:def:: OutOfStockResponse - - interface OutOfStockResponse { - - // Product ID of an out-of-stock item. - product_id: string; - - // Legacy integer quantity requested. Deprecated; see ``unit_requested_quantity``. - requested_quantity: Integer; - - // Requested quantity using "<integer>[.<fraction>]" syntax with up to six fractional digits. - unit_requested_quantity: string; - - // Legacy integer availability (must be below ``requested_quantity``). - available_quantity: Integer; - - // Available quantity using "<integer>[.<fraction>]" syntax with up to six fractional digits. - unit_available_quantity: string; - - // When do we expect the product to be again in stock? - // Optional, not given if unknown. - restock_expected?: Timestamp; - } - - - .. ts:def:: OrderRefusedErrorDetailResponse - - interface OrderRefusedErrorDetailResponse { - - // Numeric `error code <error-codes>` unique to the condition. - // Will be MERCHANT_PRIVATE_POST_ORDERS_AMOUNT_EXCEEDS_LEGAL_LIMITS). - code: ErrorCode; - - // Human-readable description of the error, i.e. "missing parameter", "commitment violation", ... - // Should give a human-readable hint about the error's nature. Optional, may change without notice! - hint?: string; - - // Detail about why a specific exchange was rejected. - // Note that an exchange that was allowed is not listed. - // It is possible that no exchanges were rejected (in which - // case this array would be empty) and still the operation - // failed because the total of the allowed amounts per - // exchange ended up below the order total. Thus, that - // is ultimately always the cause here (as per the code), - // but the *other* reasons why exchanges might have been - // rejected could be enlightening to the user and are - // thus provided here. - exchange_rejections: ExchangeRejectionDetail; - } - - .. ts:def:: ExchangeRejectionDetail - - interface ExchangeRejectionDetail { - - // Base URL of the rejected exchange - exchange_url: string; - - // Numeric `error code <error-codes>` unique to why - // this exchange was not acceptable. - // Can be MERCHANT_GENERIC_CURRENCY_MISMATCH, - // MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_LEGALLY_REFUSED - // (zero deposit limit, likely KYC required), - // MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE - // (we failed to download /keys from the exchange), - // MERCHANT_POST_ORDERS_ID_PAY_WIRE_METHOD_UNSUPPORTED - // (none of our bank accounts has a compatible wire method) - code: ErrorCode; - - // Human-readable description of the error. - // Should give a human-readable hint about the error's nature. - // Optional, may change without notice! - hint?: string; - - } - -Inspecting orders -^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCE]/private/orders - - Returns known orders up to some point in the past. - - **Required permission:** ``orders-read`` - - **Request:** - - :query paid: *Optional*. If set to yes, only return paid orders, if no only unpaid orders. Do not give (or use "all") to see all orders regardless of payment status. - :query refunded: *Optional*. If set to yes, only return refunded orders, if no only unrefunded orders. Do not give (or use "all") to see all orders regardless of refund status. - :query wired: *Optional*. If set to yes, only return wired orders, if no only orders with missing wire transfers. Do not give (or use "all") to see all orders regardless of wire transfer status. - :query delta: *Optional*. takes value of the form ``N (-N)``, so that at most ``N`` values strictly older (younger) than ``start`` and ``date_s`` are returned. Defaults to ``-20`` to return the last 20 entries (before ``start`` and/or ``date_s``). Deprecated in protocol **v12**. Use *limit* instead. - :query limit: *Optional*. At most return the given number of results. Negative for descending by row ID, positive for ascending by row ID. Default is ``20``. Since protocol **v12**. - :query date_s: *Optional.* Non-negative date in seconds after the UNIX Epoc, see ``delta`` for its interpretation. If not specified, we default to the oldest or most recent entry, depending on ``limit``. - :query start: *Optional*. Row number threshold, see ``limit`` for its interpretation. Defaults to ``INT64_MAX``, namely the biggest row id possible in the database. Deprecated in protocol **v12**. Use *offset* instead. - :query offset: *Optional*. Starting ``row_id`` for an iteration. Since protocol **v12**. - :query timeout_ms: *Optional*. Timeout in milliseconds to wait for additional orders if the answer would otherwise be negative (long polling). Only useful if ``limit`` is positive. Note that the merchant MAY still return a response that contains fewer than ``limit`` orders. - :query session_id: *Optional*. Since protocol **v6**. Filters by session ID. - :query fulfillment_url: *Optional*. Since protocol **v6**. Filters by fulfillment URL. - :query summary_filter: *Optional*. Only returns orders where the summary contains the given text as a substring. Matching is case-insensitive. Since protocol **v23**. - - **Response:** - - :http:statuscode:`200 OK`: - The response is an `OrderHistory`. - - **Details:** - - .. ts:def:: OrderHistory - - interface OrderHistory { - // Timestamp-sorted array of all orders matching the query. - // The order of the sorting depends on the sign of ``limit``. - orders : OrderHistoryEntry[]; - } - - - .. ts:def:: OrderHistoryEntry - - interface OrderHistoryEntry { - - // Order ID of the transaction related to this entry. - order_id: string; - - // Row ID of the order in the database. - row_id: Integer; - - // When the order was created. - timestamp: Timestamp; - - // The amount of money the order is for. If the contract - // has multiple choices and the user has not yet made a choice, - // we return the amount of the first choice. - amount: Amount; - - // The total amount of refunds granted by the merchant. - // Includes refunds that the wallet did not yet pick up. - // Only available if the order was paid. - // Since **v24**. - refund_amount: Amount; - - // The amount of refunds the customer's wallet did not yet - // pick up. Only available if the order was paid. - // Since **v24**. - pending_refund_amount: Amount; - - // The summary of the order. - summary: string; - - // Whether some part of the order is refundable, - // that is the refund deadline has not yet expired - // and the total amount refunded so far is below - // the value of the original transaction. - refundable: boolean; - - // Whether the order has been paid or not. - paid: boolean; - } - -.. http:get:: [/instances/$INSTANCE]/private/orders/$ORDER_ID - - Merchant checks the payment status of an order. If the order exists but is not paid - and not claimed yet, the response provides a redirect URL. When the user goes to this URL, - they will be prompted for payment. Differs from the ``public`` API both - in terms of what information is returned and in that the wallet must provide - the contract hash to authenticate, while for this API we assume that the - merchant is authenticated (as the endpoint is not ``public``). - - **Required permission:** ``orders-read`` - - **Request:** - - :query session_id: *Optional*. Session ID that the payment must be bound to. If not specified, the payment is not session-bound. - :query transfer: Deprecated in protocol **V6**. *Optional*. If set to "YES", try to obtain the wire transfer status for this order from the exchange. Otherwise, the wire transfer status MAY be returned if it is available. - :query timeout_ms: *Optional*. Timeout in milliseconds to wait for a payment if the answer would otherwise be negative (long polling). - :query lp_not_etag=ETAG: *Optional*. - Specifies what status change we are long-polling for. - If specified, the endpoint will only return once the returned "Etag" - would differ from the ETAG specified by the client. The "Etag" - is computed over the entire response body, and thus assured to change - whenever any data point in the response changes. This is ideal for - clients that want to learn about any change in the response. Clients - using this query parameter should probably also set a "If-none-match" - HTTP header so that if the ``timeout_ms`` expires, they can get back - a "304 Not modified" with an empty body if nothing changed. - :query allow_refunded_for_repurchase: *Optional*. Since protocol **v9** refunded orders are only returned under "already_paid_order_id" if this flag is set explicitly to "YES". - - **Response:** - - :http:statuscode:`200 OK`: - Returns a `MerchantOrderStatusResponse`, whose format can differ based on the status of the payment. - :http:statuscode:`304 Not modified`: - The ``ETag`` in the response did not change compared to the one - given in the ``If-none-match`` HTTP header specified by the client. - @since protocol **v25**. - :http:statuscode:`404 Not found`: - The order or instance is unknown to the backend. Error code - is set to either ``MERCHANT_GENERIC_ORDER_UNKNOWN`` or - ``MERCHANT_GENERIC_INSTANCE_UNKNOWN``. - - **Details:** - - .. ts:def:: MerchantOrderStatusResponse - - type MerchantOrderStatusResponse = CheckPaymentPaidResponse | - CheckPaymentClaimedResponse | - CheckPaymentUnpaidResponse; - - .. ts:def:: CheckPaymentPaidResponse - - interface CheckPaymentPaidResponse { - // The customer paid for this contract. - order_status: "paid"; - - // Was the payment refunded (even partially)? - refunded: boolean; - - // True if there are any approved refunds that the wallet has - // not yet obtained. - refund_pending: boolean; - - // Did the exchange wire us the funds? - wired: boolean; - - // Total amount the exchange deposited into our bank account - // for this contract, excluding fees. - deposit_total: Amount; - - // Numeric `error code <error-codes>` indicating errors the exchange - // encountered tracking the wire transfer for this purchase (before - // we even got to specific coin issues). - // 0 if there were no issues. - exchange_code: Integer; - - // HTTP status code returned by the exchange when we asked for - // information to track the wire transfer for this purchase. - // 0 if there were no issues. - exchange_http_status: Integer; - - // Total amount that was refunded, 0 if refunded is false. - refund_amount: Amount; - - // Contract terms. - contract_terms: ContractTerms; - - // Index of the selected choice within the ``choices`` array of - // ``contract terms``. - // @since protocol **v21** - choice_index?: Integer; - - // If the order is paid, set to the last time when a payment - // was made to pay for this order. @since **v14**. - last_payment: Timestamp; - - // The wire transfer status from the exchange for this order if - // available, otherwise empty array. - wire_details: TransactionWireTransfer[]; - - // Groups about trouble obtaining wire transfer details, - // empty array if no trouble were encountered. - // @deprecated in protocol **v6**. - wire_groups: TransactionWireReport[]; - - // The refund details for this order. One entry per - // refunded coin; empty array if there are no refunds. - refund_details: RefundDetails[]; - - // Status URL, can be used as a redirect target for the browser - // to show the order QR code / trigger the wallet. - order_status_url: string; - } - - .. ts:def:: CheckPaymentClaimedResponse - - interface CheckPaymentClaimedResponse { - // A wallet claimed the order, but did not yet pay for the contract. - order_status: "claimed"; - - // Contract terms. - contract_terms: ContractTerms; - - // Status URL, can be used as a redirect target for the browser - // to show the order QR code / trigger the wallet. - // Since protocol **v19**. - order_status_url: string; - } - - .. ts:def:: CheckPaymentUnpaidResponse - - interface CheckPaymentUnpaidResponse { - // The order was not yet claimed (and thus certainly also - // not yet paid). - order_status: "unpaid"; - - // URI that the wallet must process to complete the payment. - taler_pay_uri: string; - - // Time when the order was created. - creation_time: Timestamp; - - // Deadline when the offer expires; the customer must pay before. - // @since protocol **v21**. - // @deprecated in **v25** (use proto_contract_terms.pay_deadline instead). - pay_deadline: Timestamp; - - // Order summary text. - // @deprecated in **v25** (use proto_contract_terms.summary instead). - summary: string; - - // We cannot return the "final" contract terms here because - // the ``nonce`` is not available because the wallet did not yet - // claim the order. - // So the "ProtoContractTerms" are basically the contract terms, - // but without the ``nonce``. - // @since protocol **v25**. - proto_contract_terms: ProtoContractTerms; - - // Total amount of the order (to be paid by the customer). - // Will be undefined for unpaid v1 orders - // @deprecated in **v25** (use proto_contract_terms instead). - total_amount?: Amount; - - // Alternative order ID which was paid for already in the same session. - // Only given if the same product was purchased before in the same session. - already_paid_order_id?: string; - - // Fulfillment URL of an already paid order. Only given if under this - // session an already paid order with a fulfillment URL exists. - already_paid_fulfillment_url?: string; - - // Status URL, can be used as a redirect target for the browser - // to show the order QR code / trigger the wallet. - order_status_url: string; - - } - - .. ts:def:: RefundDetails - - interface RefundDetails { - // Reason given for the refund. - reason: string; - - // True if a refund is still available for the wallet for this payment. - pending: boolean; - - // When was the refund approved with a POST to - // [/instances/$INSTANCE]/private/orders/$ORDER_ID/refund - timestamp: Timestamp; - - // Total amount that was refunded (minus a refund fee). - amount: Amount; - } - - .. ts:def:: TransactionWireTransfer - - interface TransactionWireTransfer { - // Responsible exchange. - exchange_url: string; - - // 32-byte wire transfer identifier. - wtid: Base32; - - // Execution time of the wire transfer. - execution_time: Timestamp; - - // Total amount that has been wire transferred - // to the merchant from this exchange for this - // purchase. The ``deposit_fee`` was already - // subtracted. However, the ``wire_fee`` may still - // apply (but not to the order, only to the aggregated transfer). - amount: Amount; - - // Deposit fees to be paid to the - // exchange for this order. - // Since **v26**. - deposit_fee: Amount; - - // Was this transfer confirmed by the merchant via the - // POST /transfers API, or is it merely claimed by the exchange? - confirmed: boolean; - - // Transfer serial ID of this wire transfer, useful as - // ``offset`` for the GET ``/private/incoming`` endpoint. - // Since **v25**. - expected_transfer_serial_id: Integer; - } - - .. ts:def:: TransactionWireReport - - interface TransactionWireReport { - // Numerical `error code <error-codes>`. - code: Integer; - - // Human-readable error description. - hint: string; - - // Numerical `error code <error-codes>` from the exchange. - exchange_code: Integer; - - // HTTP status code received from the exchange. - exchange_http_status: Integer; - - // Public key of the coin for which we got the exchange error. - coin_pub: CoinPublicKey; - } - - - -.. _private-order-data-cleanup: - -Private order data cleanup -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Some orders may contain sensitive information that the merchant may not want -to retain after fulfillment, such as the customer's shipping address. By -initially labeling these order components as forgettable, the merchant can -later tell the backend to forget those details (without changing the hash of -the contract!) to minimize risks from information leakage. - - -.. http:patch:: [/instances/$INSTANCE]/private/orders/$ORDER_ID/forget - - Forget fields in an order's contract terms that the merchant no - longer needs. - - **Required permission:** ``orders-write`` - - **Request:** - - The request must be a `forget request <ForgetRequest>`. The fields specified - must have been marked as forgettable when the contract was created. Fields in - the request that are not in the `contract terms <ContractTerms>` are ignored. - - A valid - JSON path is defined as a string beginning with ``$.`` that follows the dot - notation: ``$.wire_fee``, for example. The ``$`` represents the `contract terms <ContractTerms>` - object, and an identifier following a ``.`` represents the field of that - identifier belonging to the object preceding the dot. Arrays can be indexed - by an non-negative integer within brackets: ``$.products[1]``. An asterisk ``*`` - can be used to index an array as a wildcard, which expands the path into a - list of paths containing one path for - each valid array index: ``$.products[*].description``. For a path to be valid, - it must end with a reference to a field of an object (it cannot end with an - array index or wildcard). - - **Response:** - - :http:statuscode:`200 OK`: - The merchant deleted the specified fields from the contract of - order $ORDER_ID. - :http:statuscode:`204 No content`: - The merchant had already deleted the specified fields - from the contract of order $ORDER_ID. - :http:statuscode:`400 Bad request`: - The request is malformed or one of the paths is invalid. - :http:statuscode:`404 Not found`: - The merchant backend could not find the order or the instance - and thus cannot process the forget request. - :http:statuscode:`409 Conflict`: - The request includes a field that was not marked as forgettable, so - the merchant cannot delete that field. - - **Details:** - - .. ts:def:: ForgetRequest - - interface ForgetRequest { - - // Array of valid JSON paths to forgettable fields in the order's - // contract terms. - fields: string[]; - } - - -.. http:delete:: [/instances/$INSTANCE]/private/orders/$ORDER_ID - - Delete information about an order. Fails if the order was paid in the - last 10 years (or whatever ``TAX_RECORD_EXPIRATION`` is set to) or was - claimed but is unpaid and thus still a valid offer. - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deleted the order. - :http:statuscode:`404 Not found`: - The backend does not know the instance or the order. - :http:statuscode:`409 Conflict`: - The backend refuses to delete the order. - - -.. _merchant_refund: - ------------------ -Approving Refunds ------------------ - -.. http:post:: [/instances/$INSTANCE]/private/orders/$ORDER_ID/refund - - Increase the refund amount associated with a given order. The user should be - redirected to the ``taler_refund_uri`` to trigger refund processing in the wallet. - - **Required permission:** ``orders-refund`` - - **Request:** - - The request body is a `RefundRequest` object. - - **Response:** - - :http:statuscode:`200 OK`: - The refund amount has been increased, the backend - responds with a `MerchantRefundResponse`. - :http:statuscode:`403 Forbidden`: - For the given order, the refund delay was zero and thus - refunds are categorically not allowed. - :http:statuscode:`404 Not found`: - The order is unknown to the merchant. - :http:statuscode:`410 Gone`: - It is too late for aborting, the exchange may have already wired the funds - to the merchant. - :http:statuscode:`409 Conflict`: - The refund amount exceeds the amount originally paid. - :http:statuscode:`451 Unavailable for Legal Reasons`: - The refund could not be awarded because of legal - reasons (an exchange would refuse). The merchant - staff needs to find another way to give a refund - to the customer. - The body is an `ErrorDetail` with an error - code of ``MERCHANT_POST_ORDERS_ID_REFUND_EXCHANGE_TRANSACTION_LIMIT_VIOLATION``. - - **Details:** - - .. ts:def:: RefundRequest - - interface RefundRequest { - // Amount to be refunded. - refund: Amount; - - // Human-readable refund justification. - reason: string; - } - - .. ts:def:: MerchantRefundResponse - - interface MerchantRefundResponse { - - // URL (handled by the backend) that the wallet should access to - // trigger refund processing. - // taler://refund/... - taler_refund_uri: string; - - // Contract hash that a client may need to authenticate an - // HTTP request to obtain the above URI in a wallet-friendly way. - h_contract: HashCode; - } - - ------------------------ -Tracking Wire Transfers ------------------------ - -This API is used by merchants that want to track the payments from the -exchange to be sure that they have been paid on time. By telling the merchant -backend about all incoming wire transfers, the backend can detect if an -exchange failed to perform a wire transfer that was due. - - -Informing the backend about incoming wire transfers -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:post:: [/instances/$INSTANCE]/private/transfers - - Inform the backend over an incoming wire transfer. The backend should inquire about the details with the exchange and mark the respective orders as wired. Note that the request will fail if the WTID is not unique (which should be guaranteed by a correct exchange). - This request is idempotent and should also be used to merely re-fetch the - transfer information from the merchant's database (assuming we got a non-error - response from the exchange before). - - **Required permission:** ``transfers-write`` - - **Request:** - - The request must provide `transfer information <TransferInformation>`. - - **Response:** - - :http:statuscode:`204 No content`: - The wire transfer is now confirmed at the merchant. - :http:statuscode:`404 Not found`: - The instance or account are unknown to the exchange. - :http:statuscode:`409 Conflict`: - The wire transfer identifier is already known to us, but for a different amount. - - **Details:** - - .. ts:def:: TransferInformation - - interface TransferInformation { - // How much was wired to the merchant (minus fees). - credit_amount: Amount; - - // Raw wire transfer identifier identifying the wire transfer (a base32-encoded value). - wtid: WireTransferIdentifierRawP; - - // Full payto://-URI of the bank account that received the wire transfer. - payto_uri: string; - - // Base URL of the exchange that made the wire transfer. - exchange_url: string; - } - - -Querying known wire transfers -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCE]/private/transfers - - Obtain a list of all wire transfers the backend was told - had been made into the merchant bank account. - Since protocol **v20** this endpoint is only about - actually confirmed wire transfers. - - **Required permission:** ``transfers-read`` - - **Request:** - - :query payto_uri: *Optional*. Full payto://-URI to filter for transfers to the given bank account (subject and amount MUST NOT be given in the payto:// URI). Note that the URI must be URL-encoded. - - :query before: *Optional*. Filter for transfers executed before the given timestamp. - - :query after: *Optional*. Filter for transfers executed after the given timestamp. - - :query limit: *Optional*. At most return the given number of results. Negative for descending in execution time, positive for ascending in execution time. Default is ``-20``. - - :query offset: *Optional*. Starting ``transfer_serial_id`` for an iteration. - - :query expected: *Optional*. Filter transfers that we expected to receive (YES: only expected, NO: only unexpected, ALL: default). Since protocol **v20**. - - - **Response:** - - :http:statuscode:`200 OK`: - The body of the response is a `TransferList`. - - **Details:** - - .. ts:def:: TransferList - - interface TransferList { - // List of all the transfers that fit the filter that we know. - transfers : TransferDetails[]; - } - - .. ts:def:: TransferDetails - - interface TransferDetails { - // How much was wired to the merchant (minus fees). - credit_amount: Amount; - - // Raw wire transfer identifier identifying the wire transfer (a base32-encoded value). - wtid: WireTransferIdentifierRawP; - - // Full payto://-URI of the bank account that received the wire transfer. - payto_uri: string; - - // Base URL of the exchange that made the wire transfer. - exchange_url: string; - - // Serial number identifying the transfer in the merchant backend. - // Used for filtering via ``offset``. - transfer_serial_id: Integer; - - // Time of the execution of the wire transfer. - // Missing if unknown in protocol **v25**. - execution_time?: Timestamp; - - // True if we checked the exchange's answer and are happy with it. - // False if we have an answer and are unhappy, missing if we - // do not have an answer from the exchange. - // Removed in protocol **v20**. - verified?: boolean; - - // True if the merchant uses the POST /transfers API to confirm - // that this wire transfer took place (and it is thus not - // something merely claimed by the exchange). - // Removed in protocol **v20**. - confirmed?: boolean; - - // True if this wire transfer was expected. - // (a matching "/private/incoming" record exists). - // Since protocol **v20**. - expected?: boolean; - } - - - -Querying expected wire transfers -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCE]/private/incoming - - Obtain a list of expected incoming wire transfers the backend is - anticipating. - Since protocol **v20**. - - **Required permission:** ``transfers-read`` - - **Request:** - - :query payto_uri: *Optional*. Full payto://-URI to filter for transfers to the given bank account (subject and amount MUST NOT be given in the payto:// URI). Note that the URI must be URL-encoded. - - :query before: *Optional*. Filter for transfers executed before the given timestamp. - - :query after: *Optional*. Filter for transfers executed after the given timestamp. - - :query limit: *Optional*. At most return the given number of results. Negative for descending in execution time, positive for ascending in execution time. Default is ``-20``. - - :query offset: *Optional*. Starting ``expected_transfer_serial_id`` for an iteration. - - :query verified: *Optional*. Filter transfers by verification status (YES: reconcilation worked, NO: reconciliation failed, ALL: default) - - :query confirmed: *Optional*. Filter transfers that were confirmed (YES: credit confirmed, NO: credit still pending, ALL: default) - - - **Response:** - - :http:statuscode:`200 OK`: - The body of the response is a `ExpectedTransferListResponse`. - - **Details:** - - .. ts:def:: ExpectedTransferListResponse - - interface ExpectedTransferListResponse { - // List of all the expected incoming transfers that fit the - // filter that we know. - incoming : ExpectedTransferDetails[]; - } - - .. ts:def:: ExpectedTransferDetails - - interface ExpectedTransferDetails { - // How much should be wired to the merchant (minus fees). - expected_credit_amount?: Amount; - - // Raw wire transfer identifier identifying the wire transfer (a base32-encoded value). - wtid: WireTransferIdentifierRawP; - - // Full payto://-URI of the bank account that received the wire transfer. - payto_uri: string; - - // Base URL of the exchange that made the wire transfer. - exchange_url: string; - - // Serial number identifying the expected transfer in the backend. - // Used for filtering via ``offset``. - expected_transfer_serial_id: Integer; - - // Expected time of the execution of the wire transfer - // by the exchange, according to the exchange. - execution_time?: Timestamp; - - // True if we checked the exchange's answer and are happy with - // the reconciation data. - // False if we have an answer and are unhappy, missing if we - // do not have an answer from the exchange. - // Does not imply that the wire transfer was settled (for - // that, see ``confirmed``). - validated: boolean; - - // True if the merchant uses the POST /transfers API to confirm - // that this wire transfer took place (and it is thus not - // something merely claimed by the exchange). - // (a matching entry exists in /private/transfers) - confirmed: boolean; - - // Last HTTP status we received from the exchange, 0 for - // none (incl. timeout) - last_http_status: Integer; - - // Last Taler error code we got from the exchange. - last_ec: ErrorCode; - - // Last error detail we got back from the exchange. - last_error_detail?: string; - } - - -.. http:get:: [/instances/$INSTANCE]/private/incoming/$ID - - Obtain details about an expected incoming wire transfers the backend is - anticipating. ID must be the ``expected_transfer_serial_id`` - from `ExpectedTransferDetails`. - Since protocol **v26**. - - **Required permission:** ``transfers-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The body of the response is a `ExpectedTransferDetailResponse`. - :http:statuscode:`404 Not found`: - The expected wire transfer ``$ID`` is unknown. - :http:statuscode:`409 Conflict`: - The exchange did not yet provide the transaction details - (the ``last_http_status`` of the `ExpectedTransferDetails` is - not 200). The information may be available later but is not yet. - - **Details:** - - .. ts:def:: ExpectedTransferDetailResponse - - interface ExpectedTransferDetails { - - // List of orders that are settled by this wire - // transfer according to the exchange. Only - // available if ``last_http_status`` is 200. - reconciliation_details?: ExchangeTransferReconciliationDetails[]; - - // Wire fee paid by the merchant. Only - // available if ``last_http_status`` is 200. - // Not present if the backend was unable to obtain the - // wire fee for the ``execution_time`` from the exchange. - // (If missing, this is thus indicative of a minor error.) - wire_fee?: Amount; - - } - - .. ts:def:: ExchangeTransferReconciliationDetails - - interface ExchangeTransferReconciliationDetails { - - // ID of the order for which these are the - // reconciliation details. - order_id: string; - - // Remaining deposit total to be paid, - // that is the total amount of the order - // minus any refunds that were granted. - // The actual amount to be wired is this - // amount minus ``deposit_fee`` and (overall) - // minus the ``wire_fee`` of the transfer. - remaining_deposit: Amount; - - // Deposit fees paid to the exchange for this order. - deposit_fee: Amount; - - } - - -Deleting confirmed wire transfer -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Deleting a wire transfer can be useful in case of a data entry -mistake. In particular, if the exchange base URL was entered -badly, deleting the old entry and adding a correct one is a -good idea. Note that deleting wire transfers is not possible -if they were expected. - -.. http:delete:: [/instances/$INSTANCE]/private/transfers/$TID - - Here, the TID is the 'transfer_serial_id' of the transfer - to delete. - - **Required permission:** ``transfers-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The transfer was deleted. - :http:statuscode:`404 Not found`: - The transfer was already unknown. - :http:statuscode:`409 Conflict`: - The transfer cannot be deleted anymore. - - ------------ -OTP Devices ------------ - -OTP devices can be used to allow offline merchants -to validate that a customer made a payment. - - -.. http:post:: [/instances/$INSTANCE]/private/otp-devices - - This is used to associate an OTP device with an instance. - - **Required permission:** ``otp-devices-write`` - - **Request:** - - The request must be a `OtpDeviceAddDetails`. - - **Response:** - - :http:statuscode:`204 No content`: - The creation of the template is successful. - :http:statuscode:`404 Not found`: - The merchant instance is unknown or it is not in our data. - - **Details:** - - .. ts:def:: OtpDeviceAddDetails - - interface OtpDeviceAddDetails { - - // Device ID to use. - otp_device_id: string; - - // Human-readable description for the device. - otp_device_description: string; - - // A key encoded with RFC 3548 Base32. - // IMPORTANT: This is not using the typical - // Taler base32-crockford encoding. - // Instead it uses the RFC 3548 encoding to - // be compatible with the TOTP standard. - otp_key: string; - - // Algorithm for computing the POS confirmation. - // "NONE" or 0: No algorithm (no pos confirmation will be generated) - // "TOTP_WITHOUT_PRICE" or 1: Without amounts (typical OTP device) - // "TOTP_WITH_PRICE" or 2: With amounts (special-purpose OTP device) - // The "string" variants are supported @since protocol **v7**. - otp_algorithm: Integer | string; - - // Counter for counter-based OTP devices. - otp_ctr?: Integer; - } - - -.. http:patch:: [/instances/$INSTANCE]/private/otp-devices/$DEVICE_ID - - This is used to update an OTP device. It is useful when we need to change information in the OTP device or when we have mistake some information. - - **Required permission:** ``otp-devices-write`` - - **Request:** - - The request must be a `OtpDevicePatchDetails`. - - **Response:** - - :http:statuscode:`204 No content`: - The template has successfully modified. - :http:statuscode:`404 Not found`: - The template(ID) is unknown to the backend. - :http:statuscode:`409 Conflict`: - The provided information is inconsistent with the current state of the template. Changes made is the same with - another store. - - **Details:** - - .. ts:def:: OtpDevicePatchDetails - - interface OtpDevicePatchDetails { - - // Human-readable description for the device. - otp_device_description: string; - - // A key encoded with RFC 3548 Base32. - // IMPORTANT: This is not using the typical - // Taler base32-crockford encoding. - // Instead it uses the RFC 3548 encoding to - // be compatible with the TOTP standard. - otp_key?: string; - - // Algorithm for computing the POS confirmation. - otp_algorithm: Integer; - - // Counter for counter-based OTP devices. - otp_ctr?: Integer; - } - - -.. http:get:: [/instances/$INSTANCE]/private/otp-devices - - This is used to return the list of all the OTP devices. - - **Required permission:** ``otp-devices-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned all the templates. Returns a `OtpDeviceSummaryResponse`. - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. - - **Details:** - - .. ts:def:: OtpDeviceSummaryResponse - - interface OtpDeviceSummaryResponse { - - // Array of devices that are present in our backend. - otp_devices: OtpDeviceEntry[]; - } - - .. ts:def:: OtpDeviceEntry - - interface OtpDeviceEntry { - - // Device identifier. - otp_device_id: string; - - // Human-readable description for the device. - device_description: string; - } - -.. http:get:: [/instances/$INSTANCE]/private/otp-devices/$DEVICE_ID - - This is used to obtain detailed information about a specific OTP device. - - The client can provide additional inputs in the query to allow the backend - to compute and return a sample OTP code. Note that it is not an error if - the client provides query arguments that are not being used *or* that are - insufficient for the server to compute the ``otp_code``: If the client - provides inadequate query parameters, the ``otp_code`` is simply omitted - from the response. - - **Required permission:** ``otp-devices-read`` - - **Query:** - - :query faketime=TIMESTAMP: *Optional*. Timestamp in seconds to use when calculating the current OTP code of the device. Since protocol **v10**. - :query price=AMOUNT: *Optional*. Price to use when calculating the current OTP code of the device. Since protocol **v10**. - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the detailed information about a specific OTP device. - Returns a `OtpDeviceDetails`. - :http:statuscode:`404 Not found`: - The OTP device or instance is unknown to the backend. - - **Details:** - - .. ts:def:: OtpDeviceDetails - - interface OtpDeviceDetails { - - // Human-readable description for the device. - device_description: string; - - // Algorithm for computing the POS confirmation. - // - // Currently, the following numbers are defined: - // 0: None - // 1: TOTP without price - // 2: TOTP with price - otp_algorithm: Integer; - - // Counter for counter-based OTP devices. - otp_ctr?: Integer; - - // Current time for time-based OTP devices. - // Will match the ``faketime`` argument of the - // query if one was present, otherwise the current - // time at the backend. - // - // Available since protocol **v10**. - otp_timestamp: Integer; - - // Current OTP confirmation string of the device. - // Matches exactly the string that would be returned - // as part of a payment confirmation for the given - // amount and time (so may contain multiple OTP codes). - // - // If the ``otp_algorithm`` is time-based, the code is - // returned for the current time, or for the ``faketime`` - // if a TIMESTAMP query argument was provided by the client. - // - // When using OTP with counters, the counter is **NOT** - // increased merely because this endpoint created - // an OTP code (this is a GET request, after all!). - // - // If the ``otp_algorithm`` requires an amount, the - // ``amount`` argument must be specified in the - // query, otherwise the ``otp_code`` is not - // generated. - // - // This field is *optional* in the response, as it is - // only provided if we could compute it based on the - // ``otp_algorithm`` and matching client query arguments. - // - // Available since protocol **v10**. - otp_code?: string; - - } - -.. http:delete:: [/instances/$INSTANCE]/private/otp-devices/$DEVICE_ID - - **Required permission:** ``otp-devices-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deleted the OTP device. - :http:statuscode:`404 Not found`: - The backend does not know the instance or the OTP device. - - -.. _merchant-template-api: - ---------- -Templates ---------- - -The template is a backend feature that is used to allow wallets to create an -order. This is useful in cases where a store does not have Internet -connectivity or where a Web site wants to enable payments on a purely static -Web page (for example to collect donations). In these cases, the GNU Taler -wallet can be used to setup an order (and then of course pay for it). - -Templates can describe a fixed contract (``fixed-order``), an inventory-backed -cart where the wallet picks products and quantities (``inventory-cart``), or a -session-based template (``paivana``). The template type controls which fields -appear in the contract and which inputs are required during instantiation. - -The template itself primarily provides order details that cannot be be changed -by the customer when the wallet creates the order. The idea is that the user -*may* be prompted to enter certain information, such as the amount to be paid, -or the order summary (as a reminder to themselves or a message to the store), -while the template provides all of the other contract details. - -The typical user-experience with templatates is that the user first scans a QR -code or clicks on a taler://-URI which contains a ``pay-template`` (see `LSD -0006 <https://lsd.gnunet.org/lsd0006/>`__). The URI specifies which values the -user should supply, currently either nothing, the amount, the order summary or -both. The URI may also specify defaults or partial defaults for those -values. After the user has supplied those values, the wallet will use the -public template API to create the order, then fetch the order details, and -proceed as if it had been given the respective ``pay`` URI in the first place: -show the full contract details and allow the user to make a payment. If the -user chooses to aborts the payment, the wallet should give the user the -opportunity to edit the values and create another order with different values. -If the template does not include any values that the user is allowed to edit -(so it is basically a fixed contract), the wallet should directly create the -order and immediately proceed to the contract acceptance dialog. - -The business process for the templating API is also pretty simple. First, the -private API is used to setup (or edit) the template, providing all of the -contract terms that subsequently cannot be changed by the customer/wallet. -This template data is then stored under the template ID which can be freely -chosen and must be in URL-encoded format. The SPA should also make it easy -for the merchant to convert the template ID into a taler://-URI and/or QR code. -Here, the merchant must additionally specify the defaults (if any) for the -customer-editable values. Afterwards, the merchant can print out the QR code -for display at the store, add a link to the taler://-URI and/or embed the -respective QR-code image into their Web page. - -To receive a payment confirmation, the mechant may choose to configure a -webhook in the merchant backend on the ``pay`` action, for example to send an -SMS to their mobile phone. For points-of-sale without a mobile phone or -Internet connectivity, the OTP mechanism can also be used to confirm payments. - - - -Adding templates -^^^^^^^^^^^^^^^^ - -.. http:post:: [/instances/$INSTANCE]/private/templates - - This is used to create a template. - - **Required permission:** ``templates-write`` - - **Request:** - - The request must be a `TemplateAddDetails`. - - - **Response:** - - :http:statuscode:`204 No content`: - The creation of the template is successful. - :http:statuscode:`404 Not found`: - The merchant instance is unknown or it is not in our data. - - **Details:** - - - .. ts:def:: TemplateAddDetails - - interface TemplateAddDetails { - - // Template ID to use. - template_id: string; - - // Human-readable description for the template. - template_description: string; - - // OTP device ID. - // This parameter is optional. - otp_id?: string; - - // Fixed contract information for orders created from - // this template. - template_contract: TemplateContractDetails; - - // Key-value pairs matching a subset of the - // fields from ``template_contract`` that are - // user-editable defaults for this template. - // Since protocol **v13**. - editable_defaults?: Object; - } - - - .. ts:def:: TemplateContractDetails - - type TemplateContractDetails = (TemplateContractFixedOrder | TemplateContractInventoryCart | TemplateContractPaivana) & TemplateContractCommon; - - .. ts:def:: TemplateContractCommon - - interface TemplateContractCommon { - // Template type to apply. Defaults to "fixed-order" if omitted. - // Prescribes which interface has to be followed - // Since protocol **v25**. - template_type?: TemplateType; - - // Human-readable summary for the template. - summary?: string; - - // Required currency for payments to the template. - // This parameter is optional and should not be present - // if "amount" is given. - currency?: string; - - // The time the customer need to pay before his order will be deleted. - // It is deleted if the customer did not pay and if the duration is over. - pay_duration?: RelativeTime; - - // Minimum age buyer must have (in years). Default is 0. - minimum_age?: Integer; - - // Inventory-cart: request a tip during instantiation. - // Since protocol **v25**. - request_tip?: boolean; - } - - .. ts:def:: TemplateType - - enum TemplateType { - FIXED_ORDER = "fixed-order", - INVENTORY_CART = "inventory-cart", - PAIVANA = "paivana" - } - - .. ts:def:: TemplateContractFixedOrder - - interface TemplateContractFixedOrder { - - // The price is imposed by the merchant and cannot be changed by the customer. - // This parameter is optional. - amount?: Amount; - - } - - .. ts:def:: TemplateContractInventoryCart - - interface TemplateContractInventoryCart { - - // Inventory-cart: allow any inventory item to be selected. - // Since protocol **v25**. - selected_all?: boolean; - - // Inventory-cart: only products in these categories are selectable. - // Since protocol **v25**. - selected_categories?: Integer[]; - - // Inventory-cart: only these products are selectable. - // Since protocol **v25**. - selected_products?: string[]; - - // Inventory-cart: require exactly one selection entry. - // Since protocol **v25**. - choose_one?: boolean; - - // Inventory-cart: backend-provided payload with selectable data. - // Only present in ``GET /templates/$TEMPLATE_ID`` responses. - // Since protocol **v25**. - inventory_payload?: InventoryPayload; - } - - .. ts:def:: TemplateContractPaivana - - interface TemplateContractPaivana { - - // Regular expression over URLs for which - // this template is valid. - // Optional, if not given all URLs are accepted. - // Since protocol **v25**. - website_regex?: string; - - // Methods to pay for the contract. - choices: OrderChoice[]; - } - - -Editing templates -^^^^^^^^^^^^^^^^^ - - -.. http:patch:: [/instances/$INSTANCE]/private/templates/$TEMPLATE_ID - - This is used to update a template. It is useful when we need to change information in the template or when we have mistake some information. - - **Required permission:** ``templates-write`` - - **Request:** - - The request must be a `TemplatePatchDetails`. - - **Response:** - - :http:statuscode:`204 No content`: - The template has successfully modified. - :http:statuscode:`404 Not found`: - The template(ID) is unknown to the backend. - :http:statuscode:`409 Conflict`: - The provided information is inconsistent with the current state of the template. Changes made is the same with - another store. - - **Details:** - - - .. ts:def:: TemplatePatchDetails - - interface TemplatePatchDetails { - - // Human-readable description for the template. - template_description: string; - - // OTP device ID. - // This parameter is optional. - otp_id?: string; - - // Additional information in a separate template. - template_contract: TemplateContractDetails; - - // Key-value pairs matching a subset of the - // fields from ``template_contract`` that are - // user-editable defaults for this template. - // Since protocol **v13**. - editable_defaults?: Object; - } - - - -Inspecting template -^^^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCE]/private/templates - - This is used to return the list of all the templates. - - - **Required permission:** ``templates-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned all the templates. Returns a `TemplateSummaryResponse`. - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. - - **Details:** - - .. ts:def:: TemplateSummaryResponse - - interface TemplateSummaryResponse { - - // List of templates that are present in our backend. - templates: TemplateEntry[]; - } - - The `TemplateEntry` object describes a template. It has the following structure: - - .. ts:def:: TemplateEntry - - interface TemplateEntry { - - // Template identifier, as found in the template. - template_id: string; - - // Human-readable description for the template. - template_description: string; - - } - -.. http:get:: [/instances/$INSTANCE]/private/templates/$TEMPLATE_ID - - This is used to obtain detailed information about a specific template. - - - **Required permission:** ``templates-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the detailed information about a specific template. - Returns a `TemplateDetails`. - :http:statuscode:`404 Not found`: - The instance or template(ID) is unknown to the backend. - - **Details:** - - - .. ts:def:: TemplateDetails - - interface TemplateDetails { - - // Human-readable description for the template. - template_description: string; - - // OTP device ID. - // This parameter is optional. - otp_id?: string; - - // Additional information in a separate template. - template_contract: TemplateContractDetails; - - // Key-value pairs matching a subset of the - // fields from ``template_contract`` that are - // user-editable defaults for this template. - // Since protocol **v13**. - editable_defaults?: Object; - - // Required currency for payments. Useful if no - // amount is specified in the ``template_contract`` - // but the user should be required to pay in a - // particular currency anyway. Merchant backends - // may reject requests if the ``template_contract`` - // or ``editable_defaults`` do - // specify an amount in a different currency. - // This parameter is optional. - // Since protocol **v13**. - required_currency?: string; - } - - - -Removing template -^^^^^^^^^^^^^^^^^ - -.. http:delete:: [/instances/$INSTANCE]/private/templates/$TEMPLATE_ID - - This is used to delete information about a template. If we no longer use it. - - **Required permission:** ``templates-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deleted the template. - :http:statuscode:`404 Not found`: - The backend does not know the instance or the template. - - - -Using template -^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCE]/templates/$TEMPLATE_ID - - This is used to obtain information about a specific template by wallets - before they ask the user to fill in details. - This endpoint is available since protocol **v11**. - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the detailed information about a specific template. - Returns a `WalletTemplateDetailsRequest`. - :http:statuscode:`404 Not found`: - The instance or template(ID) is unknown to the backend. - - **Details:** - - For ``inventory-cart`` templates the backend augments the returned - ``template_contract`` with ``inventory_payload`` containing products, - categories, and units. The payload is filtered by the template's - ``selected_all``, ``selected_categories``, and ``selected_products`` settings. - - .. ts:def:: WalletTemplateDetailsRequest - - interface WalletTemplateDetailsRequest { - - // Type of the template being instantiated. - // Possible values include "fixed-order", - // "inventory-cart" and "paivana". - // Since protocol **v25**. - // Defaults to "fixed-order" while supporting previous - // protocol versions. - template_type: string; - - // Hard-coded information about the contract terms - // for this template. - template_contract: TemplateContractDetails; - - // Key-value pairs matching a subset of the - // fields from ``template_contract`` that are - // user-editable defaults for this template. - // Since protocol **v13**. - editable_defaults?: Object; - - // Required currency for payments. Useful if no - // amount is specified in the ``template_contract`` - // but the user should be required to pay in a - // particular currency anyway. Merchant backends - // may reject requests if the ``template_contract`` - // or ``editable_defaults`` do - // specify an amount in a different currency. - // This parameter is optional. - // Since protocol **v13**. - required_currency?: string; - } - - .. ts:def:: InventoryPayload - - interface InventoryPayload { - // Inventory products available for selection. - // Since protocol **v25**. - products: InventoryPayloadProduct[]; - - // Categories referenced by the payload products. - // Since protocol **v25**. - categories: InventoryPayloadCategory[]; - - // Custom units referenced by the payload products. - // Since protocol **v25**. - units: InventoryPayloadUnit[]; - } - - .. ts:def:: InventoryPayloadProduct - - interface InventoryPayloadProduct { - // Product identifier. - // Since protocol **v25**. - product_id: string; - - // Human-readable product name. - // Since protocol **v25**. - product_name: string; - - // Human-readable product description. - // Since protocol **v25**. - description: string; - - // Localized product descriptions. - // Since protocol **v25**. - description_i18n?: { [lang_tag: string]: string }; - - // Unit identifier for the product. - // Since protocol **v25**. - unit: string; - - // Price tiers for the product. - // Since protocol **v25**. - unit_prices: Amount[]; - - // Whether fractional quantities are allowed for this unit. - // Since protocol **v25**. - unit_allow_fraction: boolean; - - // Maximum fractional precision (0-6) enforced for this unit. - // Since protocol **v25**. - unit_precision_level: Integer; - - // Remaining stock available for selection. - // Since protocol **v25**. - remaining_stock: DecimalQuantity; - - // Category identifiers associated with this product. - // Since protocol **v25**. - categories: Integer[]; - - // Taxes applied to the product. - // Since protocol **v25**. - taxes?: Tax[]; - - // Hash of the product image (if any). - // Since protocol **v25**. - image_hash?: string; - } - - .. ts:def:: InventoryPayloadCategory - - interface InventoryPayloadCategory { - // Category identifier. - // Since protocol **v25**. - category_id: Integer; - - // Human-readable category name. - // Since protocol **v25**. - category_name: string; - - // Localized category names. - // Since protocol **v25**. - category_name_i18n?: { [lang_tag: string]: string }; - } - - .. ts:def:: InventoryPayloadUnit - - interface InventoryPayloadUnit { - // Unit identifier. - // Since protocol **v25**. - unit: string; - - // Human-readable long label. - // Since protocol **v25**. - unit_name_long: string; - - // Localized long labels. - // Since protocol **v25**. - unit_name_long_i18n?: { [lang_tag: string]: string }; - - // Human-readable short label. - // Since protocol **v25**. - unit_name_short: string; - - // Localized short labels. - // Since protocol **v25**. - unit_name_short_i18n?: { [lang_tag: string]: string }; - - // Whether fractional quantities are allowed for this unit. - // Since protocol **v25**. - unit_allow_fraction: boolean; - - // Maximum fractional precision (0-6) enforced for this unit. - // Since protocol **v25**. - unit_precision_level: Integer; - } - - -.. http:post:: [/instances/$INSTANCES]/templates/$TEMPLATE_ID - - This using template can be modified by everyone and will be used to create order. - - - **Request:** - - The request must be a `UsingTemplateDetailsRequest` and we accept JSON application and URL encoded. - - **Response:** - - The response is exactly the same type of response as when - creating an order using :ref:`POST /private/orders <post-order>`. - - **Details:** - - .. ts:def:: UsingTemplateDetailsRequest - - type UsingTemplateDetailsRequest = (UsingTemplateFixedOrderRequest | UsingTemplateInventoryCartRequest | UsingTemplatePaivanaRequest) & UsingTemplateCommonRequest; - - .. ts:def:: UsingTemplateCommonRequest - - interface UsingTemplateCommonRequest { - - // Type of the template being instantiated. - // Possible values include "fixed-order", - // "inventory-cart" and "paivana". - // Since protocol **v25**. - // Defaults to "fixed-order" while supporting previous - // protocol versions. - template_type: string; - - // Summary to use in the contract. Only if - // not already specified by the template. - summary?: string; - - // The amount to be paid, including tip. - amount?: Amount; - - // Optional tip amount. Must match the currency of ``amount`` or the - // fixed template currency. - // Since protocol **v25**. - tip?: Amount; - - } - - .. ts:def:: UsingTemplateFixedOrderRequest - - interface UsingTemplateFixedOrderRequest { - template_type: "fixed-order"; - - } - - .. ts:def:: UsingTemplateInventoryCartRequest - - interface UsingTemplateInventoryCartRequest { - template_type: "inventory-cart"; - - // Inventory-cart: selected products and quantities. - // Since protocol **v25**. - inventory_selection?: InventorySelectionEntry[]; - } - - .. ts:def:: InventorySelectionEntry - - interface InventorySelectionEntry { - // Inventory product to add. - product_id: string; - - // Quantity in "<integer>[.<fraction>]" form using the product unit rules. - quantity: DecimalQuantity; - } - - .. ts:def:: UsingTemplatePaivanaRequest - - interface UsingTemplatePaivanaRequest { - template_type: "paivana"; - - // URL of the Paivana-protected website to be - // accessed. Will become the fulfillment URL in - // the contract. - website: string; - - // Client Paivana ID to grant access to. - // This becomes the "session_id" for session-based - // access control. - paivana_id: string; - - } - - --------- -Webhooks --------- - -The webhook is a backend feature that is used to trigger an HTTP request -to some business logic of the merchant in real-time whenever a specified -type of event happens. Depending on the type of the event, webhooks -may include additional meta-data, such as the amount or contract paid -by the customer. For details on setup and supported event payloads, see the -`Merchant manual – Setting up a webhook <https://docs.taler.net/taler-merchant-manual.html#setting-up-a-webhook>`_. - -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 -validate their payloads without guesswork: - -.. ts:def:: WebhookEventType - - enum WebhookEventType { - ORDER_CREATED = "order_created", - PAY = "pay", - REFUND = "refund", - ORDER_SETTLED = "order_settled", - CATEGORY_ADDED = "category_added", - CATEGORY_UPDATED = "category_updated", - CATEGORY_DELETED = "category_deleted", - INVENTORY_ADDED = "inventory_added", - INVENTORY_UPDATED = "inventory_updated", - INVENTORY_DELETED = "inventory_deleted" - } - -- ``order_created``: fired whenever a new order is created and exposes the ``order_id``, contract, and owning ``instance_id``. -- ``pay``: emitted after a payment succeeds; the payload contains the paid contract terms and ``order_id``. -- ``refund``: triggered when a refund is approved and includes timestamp, refunded amount, and reason. -- ``order_settled``: sent when reconciliation links a wire transfer to an order (includes ``order_id`` and ``wtid``). -- ``category_added`` / ``category_updated`` / ``category_deleted``: cover lifecycle changes to product categories. -- ``inventory_added`` / ``inventory_updated`` / ``inventory_deleted``: cover lifecycle changes to inventory items, including descriptive fields and stock state. - -For the full payloads associated with each event consult the merchant manual section linked above. - - - -Adding webhooks -^^^^^^^^^^^^^^^ - -.. http:post:: [/instances/$INSTANCES]/private/webhooks - - This is used to create a webhook. - - **Required permission:** ``webhooks-write`` - - **Request:** - - The request must be a `WebhookAddDetails`. - - **Response:** - - :http:statuscode:`204 No content`: - The creation of the webhook is successsful. - - :http:statuscode:`404 Not found`: - The merchant instance is unknown or it not in our data. - - **Details:** - - .. ts:def:: WebhookAddDetails - - interface WebhookAddDetails { - - // Webhook ID to use. - webhook_id: string; - - // The event of the webhook: why the webhook is used. - event_type: WebhookEventType; - - // URL of the webhook where the customer will be redirected. - url: string; - - // Method used by the webhook - http_method: string; - - // Header template of the webhook - header_template?: string; - - // Body template by the webhook - body_template?: string; - - } - - -Editing webhooks -^^^^^^^^^^^^^^^^ - -.. http:patch:: [/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID - - This is used to update a webhook. - - **Required permission:** ``webhooks-write`` - - **Request:** - - The request must be a `WebhookPatchDetails`. - - **Response:** - - :http:statuscode:`204 No content`: - The webhook has successfully modified. - :http:statuscode:`404 Not found`: - The webhook(ID) is unknown to the backend. - :http:statuscode:`409 Conflict`: - The provided information is inconsistent with the current state of the webhook. Changes made is the same with another store. - - **Details:** - - .. ts:def:: WebhookPatchDetails - - interface WebhookPatchDetails { - - // The event of the webhook: why the webhook is used. - event_type: WebhookEventType; - - // URL of the webhook where the customer will be redirected. - url: string; - - // Method used by the webhook - http_method: string; - - // Header template of the webhook - header_template?: string; - - // Body template by the webhook - body_template?: string; - - } - - - -Inspecting webhook -^^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCES]/private/webhooks - - This is used to return all the webhooks that are present in our backend. - - **Required permission:** ``webhooks-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned all the webhooks. Returns a `WebhookSummaryResponse`. - - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. - - **Details:** - - .. ts:def:: WebhookSummaryResponse - - interface WebhookSummaryResponse { - - // Return webhooks that are present in our backend. - webhooks: WebhookEntry[]; - - } - - The `WebhookEntry` object describes a webhook. It has the following structure: - - .. ts:def:: WebhookEntry - - interface WebhookEntry { - - // Webhook identifier, as found in the webhook. - webhook_id: string; - - // The event of the webhook: why the webhook is used. - event_type: WebhookEventType; - - } - - -.. http:get:: [/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID - - This is used to obtain detailed information about a specific webhook. - - **Required permission:** ``webhooks-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the detailed information about a specific webhook. Returns a `WebhookDetails`. - - :http:statuscode:`404 Not found`: - The webhook(ID) is unknown to the backend. - - **Details:** - - .. ts:def:: WebhookDetails - - interface WebhookDetails { - - // The event of the webhook: why the webhook is used. - event_type: WebhookEventType; - - // URL of the webhook where the customer will be redirected. - url: string; - - // Method used by the webhook - http_method: string; - - // Header template of the webhook - header_template?: string; - - // Body template by the webhook - body_template?: string; - - } - - -Removing webhook -^^^^^^^^^^^^^^^^ - -.. http:delete:: [/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID - - This is used to delete information about a webhook. - - **Required permission:** ``webhooks-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deleted the webhook. - - :http:statuscode:`404 Not found`: - The webhook(ID) or the instance is unknown to the backend. - - -------- -Reports -------- - -Reports are a backend feature that is used to send periodic -reports to the merchant. Reports are sent using notification -helper programs which must be configured for each merchant backend. - -Since protocol **v25**. - -Generating reports -^^^^^^^^^^^^^^^^^^ - -.. http:post:: /reports/$REPORT_ID - - This is used to request the generation of a periodic report. - It is used internally by the ``taler-merchant-report-generator``. - The endpoint itself is unauthenticated, but the ``report-token`` - serves to authorize the request. - - **Request:** - - The request must be a `ReportGenerationRequest`. - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully added a new report. - Details returned (including the content type) depend - fully on the type of report that was requested. - - :http:statuscode:`404 Not found`: - The report ID *or* the report token are unknown. - - **Details:** - - .. ts:def:: ReportGenerationRequest - - interface ReportGenerationRequest { - - // Report token authorizing the report generation. - report_token: ShortHashCode; - - } - - -Scheduling periodic reports -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:post:: [/instances/$INSTANCES]/private/reports - - This is used to schedule the generation of periodic reports. - - **Required permission:** ``reports-write`` - - **Request:** - - The request must be a `ReportAddRequest`. - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully added a new report. Returns a `ReportAddedResponse`. - - :http:statuscode:`404 Not found`: - The merchant instance is unknown. - :http:statuscode:`501 Not implemented`: - The report generator specified in the ``program_section`` is not configured. - - **Details:** - - .. ts:def:: ReportAddRequest - - interface ReportAddRequest { - - // Description of the report. Possibly included - // in the report message. - description: string; - - // Merchant backend configuration section specifying - // the program to use to transmit the report - program_section: string; - - // Mime-type to request from the data source. - mime_type: string; - - // Base URL to request the data from. - data_source: string; - - // Address where the report program should send - // the report. - target_address: string; - - // Report frequency - report_frequency: RelativeTime; - - // Report frequency shift. Defaults to zero if missing. - report_frequency_shift?: RelativeTime; - - } - - .. ts:def:: ReportAddedResponse - - interface ReportAddedResponse { - - // Unique ID for the report. - report_serial_id: Integer; - - } - - -Editing scheduled reports -^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:patch:: [/instances/$INSTANCES]/private/reports/$REPORT_ID - - This is used to update a scheduled report. - - **Required permission:** ``reports-write`` - - **Request:** - - The request body must be a `ReportAddRequest`. - - **Response:** - - :http:statuscode:`204 No content`: - The report has successfully modified. - :http:statuscode:`404 Not found`: - The report or instance is unknown to the backend. - - -Inspecting reporting schedules -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:get:: [/instances/$INSTANCES]/private/reports - - This is used to return all the scheduled reports - that are present in our backend. - - **Required permission:** ``reports-read`` - - **Request:** - - :query limit: *Optional.* - At most return the given number of results. Negative for descending by ``serial``, positive for ascending by ``serial``. Defaults to ``-20``. - :query offset: *Optional.* - Starting ``serial`` for :ref:`pagination <row-id-pagination>`. - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned all the reports. - Returns a `ReportsSummaryResponse`. - - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. - - **Details:** - - .. ts:def:: ReportsSummaryResponse - - interface ReportsSummaryResponse { - - // Return reports that are present in our backend. - reports: ReportEntry[]; - - } - - The `ReportEntry` object describes a report. - It has the following structure: - - .. ts:def:: ReportEntry - - interface ReportEntry { - - // Report identifier - report_serial: Integer; - - // Description for the report. - description: string; - - // Frequency for the report. - report_frequency: RelativeTime; - - } - - -.. http:get:: [/instances/$INSTANCES]/private/reports/$REPORT_SERIAL - - This is used to obtain detailed information about a specific - scheduled report. - - **Required permission:** ``reports-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully returned the detailed information about a specific report. Returns a `ReportDetailResponse`. - - :http:statuscode:`404 Not found`: - The report or instance is unknown to the backend. - - **Details:** - - .. ts:def:: ReportDetailResponse - - interface ReportDetailResponse { - - // Report identifier - report_serial: Integer; - - // Description of the report. Possibly included - // in the report message. - description: string; - - // Merchant backend configuration section specifying - // the program to use to transmit the report - program_section: string; - - // Mime-type to request from the data source. - mime_type: string; - - // Base URL to request the data from. - data_source: string; - - // Address where the report program should send - // the report. - target_address: string; - - // Report frequency - report_frequency: RelativeTime; - - // Report frequency shift - report_frequency_shift: RelativeTime; - - // Numeric `error code <error-codes>` unique to the - // error encountered in generating the latest report. - // Absent if there was no error. - last_error_code?: Integer; - - // Details about any error encountered - // in generating the latest report. - last_error_detail?: string; - } - - -Removing scheduled reports -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. http:delete:: [/instances/$INSTANCES]/private/reports/$REPORT_SERIAL - - This is used to delete report generation from the schedule. - - **Required permission:** ``reports-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deleted the report. - - :http:statuscode:`404 Not found`: - The report or the instance is unknown to the backend. - - - --------------- -Product groups --------------- - -Product groups are used to manage taxes. Each product is in -exactly one group and that group is typically used to determine -the applicable tax rules. Products that are not assigned explicitly -to a group are considered to be in the *default* product group. - -Product groups are different from categories as a product can be -in multiple categories. Furthermore, categories are used to make -it easier to find products in user interfaces, while product -groups are used to make it easier to manage taxes. - -Since protocol **v25**. - -Adding groups -^^^^^^^^^^^^^ - -.. http:post:: [/instances/$INSTANCES]/private/groups - - This is used to create a group. - - **Required permission:** ``groups-write`` - - **Request:** - - The request must be a `GroupAddRequest`. - - **Response:** - - :http:statuscode:`200 OK`: - The backend has successfully added a new group. Returns a `GroupAddedResponse`. - - :http:statuscode:`404 Not found`: - The merchant instance is unknown. - - **Details:** - - .. ts:def:: GroupAddRequest - - interface GroupAddRequest { - - // Unique name for the group (unique per instance). - group_name: string; - - // Description of the group. - description: string; - - } - - .. ts:def:: GroupAddedResponse - - interface GroupAddedResponse { - - // Unique ID for the group. - group_serial_id: Integer; - - } - - -Editing groups -^^^^^^^^^^^^^^ - -.. http:patch:: [/instances/$INSTANCES]/private/groups/$GROUP_ID - - This is used to update a group. - - **Required permission:** ``groups-write`` - - **Request:** - - The request body must be a `GroupAddRequest`. - - **Response:** - - :http:statuscode:`204 No content`: - The group has successfully modified. - :http:statuscode:`404 Not found`: - The group or instance is unknown to the backend. - :http:statuscode:`409 Conflict`: - The specified group name is already in use. - - -Inspecting groups -^^^^^^^^^^^^^^^^^ +The template is a backend feature that is used to allow wallets to create an +order. This is useful in cases where a store does not have Internet +connectivity or where a Web site wants to enable payments on a purely static +Web page (for example to collect donations). In these cases, the GNU Taler +wallet can be used to setup an order (and then of course pay for it). -.. http:get:: [/instances/$INSTANCES]/private/groups +Templates can describe a fixed contract (``fixed-order``), an inventory-backed +cart where the wallet picks products and quantities (``inventory-cart``), or a +session-based template (``paivana``). The template type controls which fields +appear in the contract and which inputs are required during instantiation. - This is used to return all the groups - that are present in our backend. +The template itself primarily provides order details that cannot be be changed +by the customer when the wallet creates the order. The idea is that the user +*may* be prompted to enter certain information, such as the amount to be paid, +or the order summary (as a reminder to themselves or a message to the store), +while the template provides all of the other contract details. - **Required permission:** ``groups-read`` +The typical user-experience with templatates is that the user first scans a QR +code or clicks on a taler://-URI which contains a ``pay-template`` (see `LSD +0006 <https://lsd.gnunet.org/lsd0006/>`__). The URI specifies which values the +user should supply, currently either nothing, the amount, the order summary or +both. The URI may also specify defaults or partial defaults for those +values. After the user has supplied those values, the wallet will use the +public template API to create the order, then fetch the order details, and +proceed as if it had been given the respective ``pay`` URI in the first place: +show the full contract details and allow the user to make a payment. If the +user chooses to aborts the payment, the wallet should give the user the +opportunity to edit the values and create another order with different values. +If the template does not include any values that the user is allowed to edit +(so it is basically a fixed contract), the wallet should directly create the +order and immediately proceed to the contract acceptance dialog. - **Request:** +The business process for the templating API is also pretty simple. First, the +private API is used to setup (or edit) the template, providing all of the +contract terms that subsequently cannot be changed by the customer/wallet. +This template data is then stored under the template ID which can be freely +chosen and must be in URL-encoded format. The SPA should also make it easy +for the merchant to convert the template ID into a taler://-URI and/or QR code. +Here, the merchant must additionally specify the defaults (if any) for the +customer-editable values. Afterwards, the merchant can print out the QR code +for display at the store, add a link to the taler://-URI and/or embed the +respective QR-code image into their Web page. - :query limit: *Optional.* - At most return the given number of results. Negative for descending by ``serial``, positive for ascending by ``serial``. Defaults to ``-20``. - :query offset: *Optional.* - Starting ``serial`` for :ref:`pagination <row-id-pagination>`. +To receive a payment confirmation, the mechant may choose to configure a +webhook in the merchant backend on the ``pay`` action, for example to send an +SMS to their mobile phone. For points-of-sale without a mobile phone or +Internet connectivity, the OTP mechanism can also be used to confirm payments. - **Response:** - :http:statuscode:`200 OK`: - The backend has successfully returned all the groups. - Returns a `GroupsSummaryResponse`. - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. +Adding templates +^^^^^^^^^^^^^^^^ - **Details:** +.. include:: merchant/post-private-templates.rst - .. ts:def:: GroupsSummaryResponse - interface GroupsSummaryResponse { +Editing templates +^^^^^^^^^^^^^^^^^ - // Return groups that are present in our backend. - groups: GroupEntry[]; - } +.. include:: merchant/patch-private-templates-TEMPLATE_ID.rst - The `GroupEntry` object describes a group. - It has the following structure: - .. ts:def:: GroupEntry - interface GroupEntry { +Inspecting template +^^^^^^^^^^^^^^^^^^^ - // Group identifier - group_serial: Integer; +.. include:: merchant/get-private-templates.rst - // Unique name for the group (unique per instance). - group_name: string; +.. include:: merchant/get-private-templates-TEMPLATE_ID.rst - // Description for the group. - description: string; - } +Removing template +^^^^^^^^^^^^^^^^^ -Removing groups -^^^^^^^^^^^^^^^ +.. include:: merchant/delete-private-templates-TEMPLATE_ID.rst -.. http:delete:: [/instances/$INSTANCES]/private/groups/$GROUP_SERIAL - This is used to delete information about a group. - **Required permission:** ``groups-write`` +Using template +^^^^^^^^^^^^^^ - **Response:** +.. include:: merchant/get-templates-TEMPLATE_ID.rst - :http:statuscode:`204 No content`: - The backend has successfully deleted the group. - :http:statuscode:`404 Not found`: - The group or the instance is unknown to the backend. +.. include:: merchant/post-templates-TEMPLATE_ID.rst +-------- +Webhooks +-------- ----- -Pots ----- +The webhook is a backend feature that is used to trigger an HTTP request +to some business logic of the merchant in real-time whenever a specified +type of event happens. Depending on the type of the event, webhooks +may include additional meta-data, such as the amount or contract paid +by the customer. For details on setup and supported event payloads, see the +`Merchant manual – Setting up a webhook <https://docs.taler.net/taler-merchant-manual.html#setting-up-a-webhook>`_. -Pots are a backend feature that is used for accounting. Transacted -amounts can be assigned into pots, for example to separate out -tips and taxes from revenue for reporting. +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 +validate their payloads without guesswork: -Since protocol **v25**. +.. ts:def:: WebhookEventType -Adding pots -^^^^^^^^^^^ + enum WebhookEventType { + ORDER_CREATED = "order_created", + PAY = "pay", + REFUND = "refund", + ORDER_SETTLED = "order_settled", + CATEGORY_ADDED = "category_added", + CATEGORY_UPDATED = "category_updated", + CATEGORY_DELETED = "category_deleted", + INVENTORY_ADDED = "inventory_added", + INVENTORY_UPDATED = "inventory_updated", + INVENTORY_DELETED = "inventory_deleted" + } -.. http:post:: [/instances/$INSTANCES]/private/pots +- ``order_created``: fired whenever a new order is created and exposes the ``order_id``, contract, and owning ``instance_id``. +- ``pay``: emitted after a payment succeeds; the payload contains the paid contract terms and ``order_id``. +- ``refund``: triggered when a refund is approved and includes timestamp, refunded amount, and reason. +- ``order_settled``: sent when reconciliation links a wire transfer to an order (includes ``order_id`` and ``wtid``). +- ``category_added`` / ``category_updated`` / ``category_deleted``: cover lifecycle changes to product categories. +- ``inventory_added`` / ``inventory_updated`` / ``inventory_deleted``: cover lifecycle changes to inventory items, including descriptive fields and stock state. - This is used to create a pot. +For the full payloads associated with each event consult the merchant manual section linked above. - **Required permission:** ``pots-write`` - **Request:** - The request must be a `PotAddRequest`. +Adding webhooks +^^^^^^^^^^^^^^^ - **Response:** +.. include:: merchant/post-private-webhooks.rst - :http:statuscode:`200 OK`: - The backend has successfully added a new pot. Returns a `PotAddedResponse`. - :http:statuscode:`404 Not found`: - The merchant instance is unknown. +Editing webhooks +^^^^^^^^^^^^^^^^ - **Details:** +.. include:: merchant/patch-private-webhooks-WEBHOOK_ID.rst - .. ts:def:: PotAddRequest - interface PotAddRequest { - // Description of the pot. Possibly included - // in the pot message. - description: string; +Inspecting webhook +^^^^^^^^^^^^^^^^^^ - // Name of the pot. Must be unique per instance. - pot_name: string; +.. include:: merchant/get-private-webhooks.rst - } - .. ts:def:: PotAddedResponse +.. include:: merchant/get-private-webhooks-WEBHOOK_ID.rst - interface PotAddedResponse { - // Unique ID for the pot. - pot_serial_id: Integer; +Removing webhook +^^^^^^^^^^^^^^^^ - } +.. include:: merchant/delete-private-webhooks-WEBHOOK_ID.rst -Editing pots -^^^^^^^^^^^^ +------- +Reports +------- -.. http:patch:: [/instances/$INSTANCES]/private/pots/$POT_ID +Reports are a backend feature that is used to send periodic +reports to the merchant. Reports are sent using notification +helper programs which must be configured for each merchant backend. - This is used to update a pot. +Since protocol **v25**. - **Required permission:** ``pots-write`` +Generating reports +^^^^^^^^^^^^^^^^^^ - **Request:** +.. include:: merchant/post-reports-REPORT_ID.rst - The request body must be a `PotModifyRequest`. - **Response:** +Scheduling periodic reports +^^^^^^^^^^^^^^^^^^^^^^^^^^^ - :http:statuscode:`204 No content`: - The pot has successfully modified. - :http:statuscode:`404 Not found`: - The pot or instance is unknown to the backend. - :http:statuscode:`409 Conflict`: - The pot total did not match the expected total - and thus resetting the pot failed. +.. include:: merchant/post-private-reports.rst - **Details:** - .. ts:def:: PotModifyRequest +Editing scheduled reports +^^^^^^^^^^^^^^^^^^^^^^^^^ - interface PotModifyRequest { +.. include:: merchant/patch-private-reports-REPORT_ID.rst - // Description of the pot. Possibly included - // in the pot message. - description: string; - // Name of the pot. Must be unique per instance. - pot_name: string; +Inspecting reporting schedules +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - // Expected current totals amount in the pot. - // Should be given if ``new_pot_total`` is specified - // as this allows checking that the pot total did - // not change in the meantime. However, this is - // not enforced server-side, the client may choose - // to not use this safety-measure. - expected_pot_totals?: Amount[]; +.. include:: merchant/get-private-reports.rst - // Expected new total amounts to store in the pot. - // Does **not** have to be in the same currencies as - // the existing amounts in the pot. Used to reset - // the pot and/or change the amounts. - new_pot_totals?: Amount[]; - } +.. include:: merchant/get-private-reports-REPORT_SERIAL.rst -Inspecting pots -^^^^^^^^^^^^^^^ +Removing scheduled reports +^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. http:get:: [/instances/$INSTANCES]/private/pots +.. include:: merchant/delete-private-reports-REPORT_SERIAL.rst - This is used to return all the pots - that are present in our backend. - **Required permission:** ``pots-read`` - **Request:** +-------------- +Product groups +-------------- - :query limit: *Optional.* - At most return the given number of results. Negative for descending by ``serial``, positive for ascending by ``serial``. Defaults to ``-20``. - :query offset: *Optional.* - Starting ``serial`` for :ref:`pagination <row-id-pagination>`. +Product groups are used to manage taxes. Each product is in +exactly one group and that group is typically used to determine +the applicable tax rules. Products that are not assigned explicitly +to a group are considered to be in the *default* product group. - **Response:** +Product groups are different from categories as a product can be +in multiple categories. Furthermore, categories are used to make +it easier to find products in user interfaces, while product +groups are used to make it easier to manage taxes. - :http:statuscode:`200 OK`: - The backend has successfully returned all the pots. - Returns a `PotsSummaryResponse`. +Since protocol **v25**. - :http:statuscode:`404 Not found`: - The backend has does not know about the instance. +Adding groups +^^^^^^^^^^^^^ - **Details:** +.. include:: merchant/post-private-groups.rst - .. ts:def:: PotsSummaryResponse - interface PotsSummaryResponse { +Editing groups +^^^^^^^^^^^^^^ - // Return pots that are present in our backend. - pots: PotEntry[]; +.. include:: merchant/patch-private-groups-GROUP_ID.rst - } - The `PotEntry` object describes a pot. - It has the following structure: +Inspecting groups +^^^^^^^^^^^^^^^^^ - .. ts:def:: PotEntry +.. include:: merchant/get-private-groups.rst - interface PotEntry { - // Pot identifier - pot_serial: Integer; +Removing groups +^^^^^^^^^^^^^^^ - // Name of the pot. Must be unique per instance. - pot_name: string; +.. include:: merchant/delete-private-groups-GROUP_SERIAL.rst - // Current total amounts in the pot. - pot_totals: Amount[]; - } +---- +Pots +---- -.. http:get:: [/instances/$INSTANCES]/private/pots/$POT_SERIAL +Pots are a backend feature that is used for accounting. Transacted +amounts can be assigned into pots, for example to separate out +tips and taxes from revenue for reporting. - This is used to obtain detailed information about specific pot. +Since protocol **v25**. - **Required permission:** ``pots-read`` +Adding pots +^^^^^^^^^^^ - **Response:** +.. include:: merchant/post-private-pots.rst - :http:statuscode:`200 OK`: - The backend has successfully returned the detailed information about a specific pot. Returns a `PotDetailResponse`. - :http:statuscode:`404 Not found`: - The pot or instance is unknown to the backend. +Editing pots +^^^^^^^^^^^^ - **Details:** +.. include:: merchant/patch-private-pots-POT_ID.rst - .. ts:def:: PotDetailResponse - interface PotDetailResponse { - // Description of the pot. Possibly included - // in the pot message. - description: string; +Inspecting pots +^^^^^^^^^^^^^^^ - // Name of the pot. Must be unique per instance. - pot_name: string; +.. include:: merchant/get-private-pots.rst - // Current total amount in the pot. - pot_totals: Amount[]; - } +.. include:: merchant/get-private-pots-POT_SERIAL.rst Removing pots ^^^^^^^^^^^^^ -.. http:delete:: [/instances/$INSTANCES]/private/pots/$POT_SERIAL - - This is used to delete information about a pot. Existing - references to the pot will simply be lost and treated as "no pot"; - there will be no indication that the pot is still in used from the - backend. - - **Required permission:** ``pots-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deleted the pot. - - :http:statuscode:`404 Not found`: - The pot or the instance is unknown to the backend. +.. include:: merchant/delete-private-pots-POT_SERIAL.rst @@ -7055,287 +961,30 @@ backend on the appropriate processing and handling. Creating token families ^^^^^^^^^^^^^^^^^^^^^^^ -.. http:post:: [/instances/$INSTANCES]/private/tokenfamilies - - This is used to create a token family. - - **Required permission:** ``tokenfamilies-write`` - - **Request:** - - The request must be a `TokenFamilyCreateRequest`. - - **Response:** - - :http:statuscode:`204 No content`: - The token family was created successfully. - - :http:statuscode:`404 Not found`: - The merchant backend is unaware of the instance. - - **Details:** - - .. ts:def:: TokenFamilyCreateRequest - - interface TokenFamilyCreateRequest { - - // Identifier for the token family consisting of unreserved characters - // according to RFC 3986. - slug: string; - - // Human-readable name for the token family. - name: string; - - // Human-readable description for the token family. - description: string; - - // Optional map from IETF BCP 47 language tags to localized descriptions. - description_i18n?: { [lang_tag: string]: string }; - - // Additional meta data, such as the ``trusted_domains`` - // or ``expected_domains``. Depends on the ``kind``. - extra_data?: object; - - // Start time of the token family's validity period. - // If not specified, merchant backend will use the current time. - valid_after?: Timestamp; - - // End time of the token family's validity period. - valid_before: Timestamp; - - // Validity duration of an issued token. - duration: RelativeTime; - - // Rounding granularity for the start validity of keys. - // The desired time is rounded down to a multiple of this - // granularity and then the ``start_offset`` is added to - // compute the actual start time of the token keys' validity. - // The end is then computed by adding the ``duration``. - // Must be 1 minute, 1 hour, 1 day, 1 week, 30 days, 90 days - // or 365 days (1 year). - validity_granularity: RelativeTime; - - // Offset to subtract from the start time rounded to ``validity_granularity`` - // to compute the actual start time for a key. - // Default is zero. - start_offset: RelativeTime; - - // Kind of the token family. - kind: TokenFamilyKind; - - } - - .. ts:def:: TokenFamilyKind - - enum TokenFamilyKind { - Discount = "discount", - Subscription = "subscription", - } +.. include:: merchant/post-private-tokenfamilies.rst Updating token families ^^^^^^^^^^^^^^^^^^^^^^^ -.. http:patch:: [/instances/$INSTANCES]/private/tokenfamilies/$TOKEN_FAMILY_SLUG - - This is used to update a token family. - - **Required permission:** ``tokenfamilies-write`` - - **Request:** - - The request must be a `TokenFamilyUpdateRequest`. - - **Response:** - - :http:statuscode:`204 No Content`: - The token family was successsful updated. - - :http:statuscode:`404 Not found`: - The merchant backend is unaware of the token family or instance. - - **Details:** - - .. ts:def:: TokenFamilyUpdateRequest - - interface TokenFamilyUpdateRequest { - - // Human-readable name for the token family. - name: string; - - // Human-readable description for the token family. - description: string; - - // Optional map from IETF BCP 47 language tags to localized descriptions. - description_i18n: { [lang_tag: string]: string }; - - // Additional meta data, such as the ``trusted_domains`` - // or ``expected_domains``. Depends on the ``kind``. - extra_data?: object; - - // Start time of the token family's validity period. - valid_after: Timestamp; - - // End time of the token family's validity period. - valid_before: Timestamp; - - } +.. include:: merchant/patch-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst Inspecting token families ^^^^^^^^^^^^^^^^^^^^^^^^^ -.. http:get:: [/instances/$INSTANCES]/private/tokenfamilies - - This is used to list all configured token families for an instance. - - **Required permission:** ``tokenfamilies-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The merchant backend has successfully returned all token families. - Returns a `TokenFamiliesList`. - - :http:statuscode:`404 Not found`: - The merchant backend is unaware of the instance. - - **Details:** - - .. ts:def:: TokenFamiliesList - - // TODO: Add pagination - - interface TokenFamiliesList { - - // All configured token families of this instance. - token_families: TokenFamilySummary[]; - - } - - .. ts:def:: TokenFamilySummary - - interface TokenFamilySummary { - // Identifier for the token family consisting of unreserved characters - // according to RFC 3986. - slug: string; - - // Human-readable name for the token family. - name: string; - - // Human-readable description for the token family. - // @since protocol **v23**. - description: string; - - // Optional map from IETF BCP 47 language tags to localized descriptions. - // @since protocol **v23**. - description_i18n?: { [lang_tag: string]: string }; - - // Start time of the token family's validity period. - valid_after: Timestamp; - - // End time of the token family's validity period. - valid_before: Timestamp; +.. include:: merchant/get-private-tokenfamilies.rst - // Kind of the token family. - kind: TokenFamilyKind; - } - - -.. http:get:: [/instances/$INSTANCES]/private/tokenfamilies/$TOKEN_FAMILY_SLUG - - This is used to get detailed information about a specific token family. - - **Required permission:** ``tokenfamilies-read`` - - **Response:** - - :http:statuscode:`200 OK`: - The merchant backend has successfully returned the detailed information - about a specific token family. Returns a `TokenFamilyDetails`. - - :http:statuscode:`404 Not found`: - The merchant backend is unaware of the token family or instance. - - **Details:** - - The `TokenFamilyDetails` object describes a configured token family. - - .. ts:def:: TokenFamilyDetails - - interface TokenFamilyDetails { - - // Identifier for the token family consisting of unreserved characters - // according to RFC 3986. - slug: string; - - // Human-readable name for the token family. - name: string; - - // Human-readable description for the token family. - description: string; - - // Optional map from IETF BCP 47 language tags to localized descriptions. - description_i18n?: { [lang_tag: string]: string }; - // Additional meta data, such as the ``trusted_domains`` - // or ``expected_domains``. Depends on the ``kind``. - extra_data?: object; - - // Start time of the token family's validity period. - // No token validities can start before this time - // (but they could be sold before). - valid_after: Timestamp; - - // End time of the token family's validity period. - // No tokens will be accepted after this time. - valid_before: Timestamp; - - // Validity duration of an issued token. - duration: RelativeTime; - - // Rounding granularity for the start validity of keys. - // The desired time is rounded down to a multiple of this - // granularity and then the ``start_offset`` is added to - // compute the actual start time of the token keys' validity. - // The end is then computed by adding the ``duration``. - validity_granularity: RelativeTime; - - // Offset in seconds to subtract from the start time rounded to ``validity_granularity`` - // to compute the actual start time for a key. - start_offset: RelativeTime; - - // Kind of the token family. - kind: TokenFamilyKind; - - // How many tokens have been issued for this family. - issued: Integer; - - // How many tokens have been used for this family. - used: Integer; - - } +.. include:: merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst Deleting token families ^^^^^^^^^^^^^^^^^^^^^^^ -.. http:delete:: [/instances/$INSTANCES]/private/tokenfamilies/$TOKEN_FAMILY_SLUG - - This is used to delete a token family. Issued tokens of this family will not - be spendable anymore. - - **Required permission:** ``tokenfamilies-write`` - - **Response:** - - :http:statuscode:`204 No content`: - The backend has successfully deleted the token family. - - :http:statuscode:`404 Not found`: - The merchant backend is unaware of the token family or instance. +.. include:: merchant/delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst ----------------------- @@ -7355,116 +1004,17 @@ Permissions Listing charity instances ^^^^^^^^^^^^^^^^^^^^^^^^^ -.. http:get:: [/instances/$INSTANCE]/private/donau - - Return all Donau charity instances currently linked to ``$INSTANCE``. - - **Required permission:** ``donau-read`` - - **Response:** - - :http:statuscode:`200 OK`: - Body is a :ts:type:`DonauInstancesResponse`. - :http:statuscode:`401 Unauthorized`: - Missing or invalid credentials. - :http:statuscode:`404 Not found`: - The merchant instance is unknown. - - **Details:** - - .. ts:def:: DonauInstancesResponse - - interface DonauInstancesResponse { - // List of linked charity instances - donau_instances: DonauInstance[]; - } - - .. ts:def:: DonauInstance - - interface DonauInstance { - // Serial number identifying the record inside the backend - donau_instance_serial: Integer; - - // Base URL of the Donau service - donau_url: string; - - // Human-readable charity name - charity_name: string; - - // EdDSA public key of the charity (binary) - charity_pub_key: EddsaPublicKey; - - // Charity identifier inside the Donau service - charity_id: Integer; - - // Maximum donation amount per calendar year - charity_max_per_year: Amount; - - // Cumulative receipts in the current year - charity_receipts_to_date: Amount; - - // Calendar year the receipts refer to - current_year: Integer; - - // Exchange-style ``/keys`` response published by Donau, - // missing if not yet known to the merchant backend. - donau_keys_json?: object; - } +.. include:: merchant/get-private-donau.rst Adding a charity instance ^^^^^^^^^^^^^^^^^^^^^^^^^ -.. http:post:: [/instances/$INSTANCE]/private/donau - - Link a new Donau charity instance to ``$INSTANCE``. - The backend fetches and validates the charity’s metadata from the given - Donau service before persisting the link. - - **Required permission:** ``donau-write`` - - **Request:** - - The body **must** be a :ts:type:`PostDonauRequest`. - - .. ts:def:: PostDonauRequest - - interface PostDonauRequest { - // Base URL of the Donau service hosting the charity - donau_url: string; - - // Numeric charity identifier inside the Donau service - charity_id: Integer; - } - - **Response:** - - :http:statuscode:`204 No content`: - The charity link was created successfully. - :http:statuscode:`202 Accepted`: - Operation requires MFA; a :ts:type:`ChallengeResponse` is returned. @since **v21** - :http:statuscode:`400 Bad request`: - Malformed JSON or missing fields. - :http:statuscode:`409 Conflict`: - * The charity is already linked with different parameters, or - * The charity’s public key does **not** match the merchant instance’s public key. - :http:statuscode:`502 Bad gateway`: - Communication with the Donau service failed. +.. include:: merchant/post-private-donau.rst Deleting a charity instance ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. http:delete:: [/instances/$INSTANCE]/private/donau/$DONAU_SERIAL - - Unlink the Donau charity instance identified by ``$DONAU_SERIAL``. - - **Required permission:** ``donau-write`` - - **Response:** - - :http:statuscode:`204 No content`: - Charity link removed. - :http:statuscode:`404 Not found`: - No such charity link exists. +.. include:: merchant/delete-private-donau-DONAU_SERIAL.rst diff --git a/core/merchant/any-star.rst b/core/merchant/any-star.rst @@ -0,0 +1,7 @@ +.. http:any:: * + + :http:statuscode:`403 Forbidden`: + * ``TALER_EC_GENERIC_FORBIDDEN``: Missing permissions. + * ``TALER_EC_MERCHANT_ACCOUNT_TWOFA_UNCONFIRMED``: The account + needs to confirm authentication factors before it can proceed + with the request. diff --git a/core/merchant/delete-management-instances-INSTANCE.rst b/core/merchant/delete-management-instances-INSTANCE.rst @@ -0,0 +1,38 @@ +.. http:delete:: /management/instances/$INSTANCE +.. http:delete:: [/instances/$INSTANCE]/private + + This request will be used to delete (permanently disable) + or purge merchant instance in the backend. Purging will + delete all offers and payments associated with the instance, + while disabling (the default behavior) only deletes the private key + and makes the instance unusable for new orders or payments. + + For deletion, the authentication credentials must match + the instance that is being deleted or the ``admin`` + instance, depending on the access path used. + + **Required permission:** ``instances-write`` + + **Request:** + + :query purge: *Optional*. If set to YES, the instance will be fully + deleted. Otherwise only the private key would be deleted. + + **Response:** + + :http:statuscode:`202 Accepted`: + 2FA is required for this operation, usually to validate the + email and/or phone numbers registered for the instance. + This returns the `ChallengeResponse`. @since **v21** + :http:statuscode:`204 No content`: + The backend has successfully removed the instance. The body is empty. + :http:statuscode:`401 Unauthorized`: + The request is unauthorized. Note that for already deleted instances, + the request must be authorized using the ``admin`` instance. + :http:statuscode:`404 Not found`: + The instance is unknown to the backend. + :http:statuscode:`409 Conflict`: + The instance cannot be deleted because it has pending offers, or + the instance cannot be purged because it has successfully processed + payments that have not passed the ``TAX_RECORD_EXPIRATION`` time. + The latter case only applies if ``purge`` was set. diff --git a/core/merchant/delete-private-accounts-H_WIRE.rst b/core/merchant/delete-private-accounts-H_WIRE.rst @@ -0,0 +1,10 @@ +.. http:delete:: [/instances/$INSTANCE]/private/accounts/$H_WIRE + + **Required permission:** ``accounts-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deactivated the account. + :http:statuscode:`404 Not found`: + The backend does not know the instance or the account. diff --git a/core/merchant/delete-private-categories-CATEGORY_ID.rst b/core/merchant/delete-private-categories-CATEGORY_ID.rst @@ -0,0 +1,13 @@ +.. http:delete:: [/instances/$INSTANCE]/private/categories/$CATEGORY_ID + + This is used to delete a category. + Since API version **v16**. + + **Required permission:** ``categories-write`` + + **Response:** + + :http:statuscode:`204 No Content`: + The category was deleted. + :http:statuscode:`404 Not Found`: + The category was possibly already deleted or is unknown. diff --git a/core/merchant/delete-private-donau-DONAU_SERIAL.rst b/core/merchant/delete-private-donau-DONAU_SERIAL.rst @@ -0,0 +1,12 @@ +.. http:delete:: [/instances/$INSTANCE]/private/donau/$DONAU_SERIAL + + Unlink the Donau charity instance identified by ``$DONAU_SERIAL``. + + **Required permission:** ``donau-write`` + + **Response:** + + :http:statuscode:`204 No content`: + Charity link removed. + :http:statuscode:`404 Not found`: + No such charity link exists. diff --git a/core/merchant/delete-private-groups-GROUP_SERIAL.rst b/core/merchant/delete-private-groups-GROUP_SERIAL.rst @@ -0,0 +1,13 @@ +.. http:delete:: [/instances/$INSTANCES]/private/groups/$GROUP_SERIAL + + This is used to delete information about a group. + + **Required permission:** ``groups-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the group. + + :http:statuscode:`404 Not found`: + The group or the instance is unknown to the backend. diff --git a/core/merchant/delete-private-orders-ORDER_ID.rst b/core/merchant/delete-private-orders-ORDER_ID.rst @@ -0,0 +1,14 @@ +.. http:delete:: [/instances/$INSTANCE]/private/orders/$ORDER_ID + + Delete information about an order. Fails if the order was paid in the + last 10 years (or whatever ``TAX_RECORD_EXPIRATION`` is set to) or was + claimed but is unpaid and thus still a valid offer. + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the order. + :http:statuscode:`404 Not found`: + The backend does not know the instance or the order. + :http:statuscode:`409 Conflict`: + The backend refuses to delete the order. diff --git a/core/merchant/delete-private-otp-devices-DEVICE_ID.rst b/core/merchant/delete-private-otp-devices-DEVICE_ID.rst @@ -0,0 +1,10 @@ +.. http:delete:: [/instances/$INSTANCE]/private/otp-devices/$DEVICE_ID + + **Required permission:** ``otp-devices-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the OTP device. + :http:statuscode:`404 Not found`: + The backend does not know the instance or the OTP device. diff --git a/core/merchant/delete-private-pots-POT_SERIAL.rst b/core/merchant/delete-private-pots-POT_SERIAL.rst @@ -0,0 +1,16 @@ +.. http:delete:: [/instances/$INSTANCES]/private/pots/$POT_SERIAL + + This is used to delete information about a pot. Existing + references to the pot will simply be lost and treated as "no pot"; + there will be no indication that the pot is still in used from the + backend. + + **Required permission:** ``pots-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the pot. + + :http:statuscode:`404 Not found`: + The pot or the instance is unknown to the backend. diff --git a/core/merchant/delete-private-products-PRODUCT_ID.rst b/core/merchant/delete-private-products-PRODUCT_ID.rst @@ -0,0 +1,15 @@ +.. http:delete:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID + + Delete information about a product. Fails if the product is locked by + anyone. + + **Required permission:** ``products-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the product. + :http:statuscode:`404 Not found`: + The backend does not know the instance or the product. + :http:statuscode:`409 Conflict`: + The backend refuses to delete the product because it is locked. diff --git a/core/merchant/delete-private-reports-REPORT_SERIAL.rst b/core/merchant/delete-private-reports-REPORT_SERIAL.rst @@ -0,0 +1,13 @@ +.. http:delete:: [/instances/$INSTANCES]/private/reports/$REPORT_SERIAL + + This is used to delete report generation from the schedule. + + **Required permission:** ``reports-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the report. + + :http:statuscode:`404 Not found`: + The report or the instance is unknown to the backend. diff --git a/core/merchant/delete-private-templates-TEMPLATE_ID.rst b/core/merchant/delete-private-templates-TEMPLATE_ID.rst @@ -0,0 +1,12 @@ +.. http:delete:: [/instances/$INSTANCE]/private/templates/$TEMPLATE_ID + + This is used to delete information about a template. If we no longer use it. + + **Required permission:** ``templates-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the template. + :http:statuscode:`404 Not found`: + The backend does not know the instance or the template. diff --git a/core/merchant/delete-private-token.rst b/core/merchant/delete-private-token.rst @@ -0,0 +1,8 @@ +.. http:delete:: [/instances/$INSTANCE]/private/token + + Delete the token presented in the authorization header. + + **Response:** + + :http:statuscode:`204 No content`: + The access token used to authorize this request was revoked. diff --git a/core/merchant/delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst b/core/merchant/delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst @@ -0,0 +1,14 @@ +.. http:delete:: [/instances/$INSTANCES]/private/tokenfamilies/$TOKEN_FAMILY_SLUG + + This is used to delete a token family. Issued tokens of this family will not + be spendable anymore. + + **Required permission:** ``tokenfamilies-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the token family. + + :http:statuscode:`404 Not found`: + The merchant backend is unaware of the token family or instance. diff --git a/core/merchant/delete-private-tokens-SERIAL.rst b/core/merchant/delete-private-tokens-SERIAL.rst @@ -0,0 +1,19 @@ +.. http:delete:: [/instances/$INSTANCE]/private/tokens/$SERIAL + + Delete a token for ``$INSTANCE`` API access by its ``$SERIAL``. + + + @since **v19** + + **Required permission**: ``tokens-write`` + + **Response:** + + :http:statuscode:`204 No content`: + Token deleted. + :http:statuscode:`401 Unauthorized`: + Invalid or missing credentials. + :http:statuscode:`403 Forbidden`: + Missing permission. + :http:statuscode:`404 Not found`: + The token was not found. diff --git a/core/merchant/delete-private-transfers-TID.rst b/core/merchant/delete-private-transfers-TID.rst @@ -0,0 +1,15 @@ +.. http:delete:: [/instances/$INSTANCE]/private/transfers/$TID + + Here, the TID is the 'transfer_serial_id' of the transfer + to delete. + + **Required permission:** ``transfers-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The transfer was deleted. + :http:statuscode:`404 Not found`: + The transfer was already unknown. + :http:statuscode:`409 Conflict`: + The transfer cannot be deleted anymore. diff --git a/core/merchant/delete-private-units-UNIT.rst b/core/merchant/delete-private-units-UNIT.rst @@ -0,0 +1,14 @@ +.. http:delete:: [/instances/$INSTANCE]/private/units/$UNIT + + Remove a custom unit from an instance. + + **Required permission:** ``units-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The unit was removed. + :http:statuscode:`404 Not found`: + The unit is unknown to the backend. + :http:statuscode:`409 Conflict`: + Built-in units cannot be deleted. diff --git a/core/merchant/delete-private-webhooks-WEBHOOK_ID.rst b/core/merchant/delete-private-webhooks-WEBHOOK_ID.rst @@ -0,0 +1,13 @@ +.. http:delete:: [/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID + + This is used to delete information about a webhook. + + **Required permission:** ``webhooks-write`` + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully deleted the webhook. + + :http:statuscode:`404 Not found`: + The webhook(ID) or the instance is unknown to the backend. diff --git a/core/merchant/get-config.rst b/core/merchant/get-config.rst @@ -0,0 +1,176 @@ +.. http:get:: /config + + Return the protocol version and currency supported by this merchant backend. + This specification corresponds to ``current`` protocol being version **v24**. + + **Response:** + + :http:statuscode:`200 OK`: + The body is a `MerchantVersionResponse`. + + **Details:** + + .. ts:def:: MerchantVersionResponse + + interface MerchantVersionResponse { + // libtool-style representation of the Merchant protocol version, see + // https://www.gnu.org/software/libtool/manual/html_node/Versioning.html#Versioning + // The format is "current:revision:age". + version: string; + + // Name of the protocol. + name: "taler-merchant"; + + // URN of the implementation (needed to interpret 'revision' in version). + // @since **v8**, may become mandatory in the future. + implementation?: string; + + // Default (!) currency supported by this backend. + // This is the currency that the backend should + // suggest by default to the user when entering + // amounts. See ``currencies`` for a list of + // supported currencies and how to render them. + currency: string; + + // Which Persona should be used by default by new clients in the SPA. + // Can be changed locally per browers under "Personalization". + // Possible values include "expert", "offline-vending-machine", + // "point-of-sale", "digital-publishing", "e-commerce" and "developer". + // @since **v23**. + default_persona: string; + + // How services should render currencies supported + // by this backend. Maps + // currency codes (e.g. "EUR" or "KUDOS") to + // the respective currency specification. + // All currencies in this map are supported by + // the backend. Note that the actual currency + // specifications are a *hint* for applications + // that would like *advice* on how to render amounts. + // Applications *may* ignore the currency specification + // if they know how to render currencies that they are + // used with. + currencies: { currency : CurrencySpecification}; + + // Maps available report generator configuration section names + // to descriptions of the respective report generator. + // Since **v25**. + report_generators: { section_name : string}; + + // Posix regular expression for allowed phone numbers; + // applies when creating or patching an instance. + // Optional, can be NULL for no restrictions. + // Since **v26**. + phone_regex?: string; + + // Array of exchanges trusted by the merchant. + // @since **v6**. + exchanges: ExchangeConfigInfo[]; + + // Set when the merchant supports + // self-provisioning instances. + // Since protocol **v21** + have_self_provisioning: boolean; + + // True if this merchant backend supports the Donau + // extension and can thus issue donation receipts. + // Should primarily be used to control the SPA's CRUD + // functionality for Donau. + // @since **v21** + have_donau: boolean; + + // Tan channels that are required + // to be confirmed for an instance to + // be useable. + // @since **v21** + mandatory_tan_channels?: TanChannel[]; + + // Space-separated list of enabled payment target types. + // Useful if the SPA should not show allow adding other + // types of bank accounts. "*" is used to represent no + // restriction. + // @since **v22** + payment_target_types: string; + + // Regular expression representing further restrictions + // on allowed payment targets. Any "payto://"-URI supplied + // for a bank account must match the given regular expression. + // For example, "payto://iban/CH.*" would restrict the system + // to only Swiss bank accounts. + // Optional, no restrictions are imposed if the field is + // absent. + // @since **v22** + // CAUTION: Likely to be removed/deprecated, + // as we'll want an array of restrictions with the + // same format as the exchange uses, as this allows + // proper i18n and spec/code reuse. + payment_target_regex? string; + + // Default payment delay for new instances. + // This is the default to use for new instances, see the instance value for + // the instance-specific default. + // A value of "forever" is not allowed. + // @since **v22** + default_pay_delay: RelativeTime; + + // If the frontend does NOT specify a refund deadline, how long should + // refunds be allowed by default? + // This is the default to use for new instances, see the instance value for + // the instance-specific default. + // A value of "forever" is not allowed. + // @since **v22** + default_refund_delay: RelativeTime; + + // Default wire transfer delay for new instances. + // This is the default to use for new instances, see the instance value for + // the instance-specific default. + // A value of "forever" is not allowed. + // @since **v22** + default_wire_transfer_delay: RelativeTime; + + // Default interval to which wire deadlines computed by + // adding the wire_transfer_delay on top of the refund + // deadline should be rounded up to. + // @since **v23** + default_wire_transfer_rounding_interval: RoundingInterval; + } + + .. ts:def:: TanChannel + + enum TanChannel { + SMS = "sms", + EMAIL = "email" + } + + .. ts:def:: RoundingInterval + + enum RoundingInterval { + NONE = "NONE", + SECOND = "SECOND", + MINUTE = "MINUTE", + HOUR = "HOUR", + DAY = "DAY", + WEEK = "WEEK", + MONTH = "MONTH", + QUARTER = "QUARTER", + YEAR = "YEAR" + } + + .. ts:def:: ExchangeConfigInfo + + interface ExchangeConfigInfo { + + // Base URL of the exchange REST API. + base_url: string; + + // Currency for which the merchant is configured + // to trust the exchange. + // May not be the one the exchange actually uses, + // but is the only one we would trust this exchange for. + currency: string; + + // Offline master public key of the exchange. The + // ``/keys`` data must be signed with this public + // key for us to trust it. + master_pub: EddsaPublicKey; + } diff --git a/core/merchant/get-exchanges.rst b/core/merchant/get-exchanges.rst @@ -0,0 +1,47 @@ +.. http:get:: /exchanges + + Return information about exchanges configured for this merchant backend. + @since **v26**. + + **Response:** + + :http:statuscode:`200 OK`: + The body is a `ExchangeStatusResponse`. + + **Details:** + + .. ts:def:: ExchangeStatusResponse + + interface ExchangeStatusResponse { + + exchanges: ExchangeStatusDetail[]; + + } + + .. ts:def:: ExchangeStatusDetail + + interface ExchangeStatusDetail { + + // Base URL of the exchange this is about. + exchange_url: string; + + // Time when the backend will download ``/keys`` next. + next_download: Timestamp; + + // Time when the current ``/keys`` response is expected to + // expire. Missing if we do not have one. + keys_expiration?: Timestamp; + + // HTTP status code returned by the exchange when we asked for + // ``/keys``. 0 if we did not receive an HTTP status code. + // Usually 200 for success. + keys_http_status: Integer; + + // Numeric `error code <error-codes>` indicating an + // error we had processing the ``/keys`` response. + keys_ec: Integer; + + // Human-readable error description matching ``keys_ec``. + keys_hint: string; + + } diff --git a/core/merchant/get-management-instances-INSTANCE-kyc.rst b/core/merchant/get-management-instances-INSTANCE-kyc.rst @@ -0,0 +1,191 @@ +.. http:GET:: /management/instances/$INSTANCE/kyc +.. http:GET:: /instances/$INSTANCE/private/kyc + + Check KYC status of a particular payment target. + Prompts the exchange to inquire with the bank + as to the KYC status of the respective account + and returns the result. + + **Required permission:** ``instances-kyc-read`` + + **Request:** + + :query h_wire=H_WIRE: *Optional*. If specified, the KYC check should + return the KYC status only for this wire account. Otherwise, for all wire accounts. + :query exchange_url=URL: *Optional*. If specified, the KYC check should + return the KYC status only for the given exchange. Otherwise, for all exchanges we interacted with. + :query lpt=TARGET: *Optional*. + Specifies what status change we are long-polling for. + Use 1 to wait for the KYC auth transfer (access token available), + 2 to wait for an AML investigation to be done, + and 3 to wait for the KYC status to be OK. + If multiple accounts or exchanges match the query, + any account reaching the TARGET state will cause + the response to be returned. + @since protocol **v17**. @deprecated with **v25**, use ``lp_*``-query parameters instead. + :query lp_status=STATUS: *Optional*. + Specifies what status change we are long-polling for. + If specified, the endpoint will only return once the status *matches* the given value. + If multiple accounts or exchanges match the query, + any account reaching the STATUS will cause the response to be returned. + @since protocol **v25**. + :query lp_not_status=STATUS: *Optional*. + Specifies what status change we are long-polling for. + If specified, the endpoint will only return once the status no longer matches the given value. + If multiple accounts or exchanges *no longer matches* the given STATUS + will cause the response to be returned. + @since protocol **v25**. + :query lp_not_etag=ETAG: *Optional*. + Specifies what status change we are long-polling for. + If specified, the endpoint will only return once the returned "Etag" + would differ from the ETAG specified by the client. The "Etag" + is computed over the entire response body, and thus assured to change + whenever any data point in the response changes. This is ideal for + clients that want to learn about any change in the response. Clients + using this query parameter should probably also set a "If-none-match" + HTTP header so that if the ``timeout_ms`` expires, they can get back + a "304 Not modified" with an empty body if nothing changed. + @since protocol **v25**. + :query timeout_ms=NUMBER: *Optional.* If specified, the merchant will + wait up to ``timeout_ms`` milliseconds for the exchanges to confirm completion of the KYC process(es). + + **Response:** + + If different exchanges cause different errors when processing + the request, the largest HTTP status code that is applicable + is returned. + + :http:statuscode:`200 Ok`: + The user may be redirected to the provided locations to perform + KYC checks. + The response will be a `MerchantAccountKycRedirectsResponse` object. + Uses this status code and format only since protocol **v17**. + :http:statuscode:`204 No content`: + No possibilities for KYC operations exist. + @since protocol **v25** only returned if this instance has no bank + accounts or no exchanges are configured for the merchant backend. + :http:statuscode:`304 Not modified`: + The ``ETag`` in the response did not change compared to the one + given in the ``If-none-match`` HTTP header specified by the client. + @since protocol **v25**. + + **Details:** + + .. ts:def:: MerchantAccountKycRedirectsResponse + + interface MerchantAccountKycRedirectsResponse { + + // Array of KYC status information for + // the exchanges and bank accounts selected + // by the query. + kyc_data: MerchantAccountKycRedirect[]; + + } + + .. ts:def:: MerchantAccountKycRedirect + + interface MerchantAccountKycRedirect { + + // Summary of the status of the KYC process. Possible values are: + // + // o "unsupported-account": this exchange does not support the given account (this is unlikely to change automatically, but could be perfectly normal if the account is supported by at least one other exchange). @since protocol **v25**. + // o "no-exchange-keys": we do not (yet) have the /keys of the exchange + // - "kyc-wire-impossible": KYC auth transfer needed but not possible + // (see also: auth_conflict). + // @ "kyc-wire-required": KYC auth transfer still needed and possible + // @ "kyc-required": merchant must supply KYC data to proceed (incl. + // in case of exposed zero-limits on deposit/aggregation) + // + "awaiting-aml-review": account under review by payment provider + // + "ready": everything is fine, account can be fully used + // - "logic-bug": merchant backend logic bug + // o "merchant-internal-error": merchant had an internal error + // o "exchange-internal-error": exchange had an internal error + // o "exchange-gateway-timeout": network timeout at gateway + // o "exchange-unreachable": exchange did not respond at all to our KYC status inquiry + // this can be briefly the case even if an exchange is online, as any HTTP request + // takes time to be processed; as a result, the KYC status for this account is unknown + // - "exchange-status-invalid": exchange violated protocol in reply + // + // "+" are perfectly normal states, "@" are states where the user + // must performn an action (show link!); "o" are reasonable transient + // states that could happen and are we are expected to likely recover + // from automatically but that we should inform the user about + // (show in yellow?), "-" are hard error states from which + // there is likely no good automatic recovery from (show in red?). + status: string; + + // Full payto URI of the bank wire account this is about. + payto_uri: string; + + // Currency used by the exchange. + // @since protocol **v25**. + exchange_currency: string; + + // Hash of the salted payto://-URI of our bank wire + // account this is about. + // @since protocol **v17**. + h_wire: string; + + // Base URL of the exchange this is about. + exchange_url: string; + + // HTTP status code returned by the exchange when we asked for + // information about the KYC status. + // @since protocol **v17**. + exchange_http_status: Integer; + + // True if we did not get a ``/keys`` response from + // the exchange and thus cannot do certain checks, such as + // determining default account limits or account eligibility. + no_keys: boolean; + + // True if the given account cannot do KYC at the + // given exchange because no wire method exists that could + // be used to do the KYC auth wire transfer. + auth_conflict: boolean; + + // Numeric `error code <error-codes>` indicating errors the exchange + // returned, or TALER_EC_INVALID for none. + // Optional (as there may not always have + // been an error code). + // @since protocol **v17**. + exchange_code?: Integer; + + // Access token needed to open the KYC SPA and/or + // access the ``/kyc-info/`` endpoint. + // Optional as without the KYC auth wire transfer we + // may simply not have an access token yet. + access_token?: AccountAccessToken; + + // Array with limitations that currently apply to this + // account and that may be increased or lifted if the + // KYC check is passed. + // Note that additional limits *may* exist and not be + // communicated to the client. If such limits are + // reached, this *may* be indicated by the account + // going into ``aml_review`` state. However, it is + // also possible that the exchange may legally have + // to deny operations without being allowed to provide + // any justification. + // The limits should be used by the client to + // possibly structure their operations (e.g. withdraw + // what is possible below the limit, ask the user to + // pass KYC checks or withdraw the rest after the time + // limit is passed, warn the user to not withdraw too + // much or even prevent the user from generating a + // request that would cause it to exceed hard limits). + limits?: AccountLimit[]; + + // Array of full payto://-URIs with + // wire transfer instructions (including + // optional amount and subject) for a KYC auth wire + // transfer. Set only if this is (still) required + // to get the given exchange working. + // Array because the exchange may have multiple + // bank accounts, in which case any of these + // accounts will do. + // Optional. + // @since protocol **v17**. + payto_kycauths?: string[]; + + } diff --git a/core/merchant/get-management-instances-INSTANCE-statistics-amount-SLUG.rst b/core/merchant/get-management-instances-INSTANCE-statistics-amount-SLUG.rst @@ -0,0 +1,77 @@ +.. http:get:: /management/instances/$INSTANCE/statistics-amount/$SLUG +.. http:get:: [/instances/$INSTANCE]/private/statistics-amount/$SLUG + + This request will return be used to statistics where the + values are amounts. All available values for the given + SLUG will be returned. + Since protocol **v25**. + + **Required permission:** ``statistics-read`` + + **Request:** + + :query by: *Optional*. If set to "BUCKET", only statistics by bucket will be returned. If set to "INTERVAL", only statistics kept by interval will be returned. If not set or set to "ANY", both will be returned. + + **Response:** + + :http:statuscode:`200 Ok`: + The body will be a `MerchantStatisticsAmountResponse` + :http:statuscode:`401 Unauthorized`: + The request is unauthorized. + :http:statuscode:`404 Not found`: + The instance is unknown to the backend. + + **Details:** + + .. ts:def:: MerchantStatisticsAmountResponse + + interface MerchantStatisticsAmountResponse { + + // Statistics kept for a particular fixed time window. + buckets: MerchantStatisticAmountByBucket[]; + + // Human-readable bucket statistic description. + // Unset if no buckets returned + buckets_description?: string; + + // Statistics kept for a particular sliding interval. + intervals: MerchantStatisticAmountByInterval[]; + + // Human-readable interval statistic description. + // Unset if no buckets returned + intervals_description?: string; + } + + .. ts:def:: MerchantStatisticAmountByBucket + + interface MerchantStatisticAmountByBucket { + + // Start time of the bucket (inclusive) + start_time: Timestamp; + + // End time of the bucket (exclusive) + end_time: Timestamp; + + // Range of the bucket + range: StatisticBucketRange; + + // Sum of all amounts falling under the given + // SLUG within this timeframe. + cumulative_amounts: Amount[]; + + } + + .. ts:def:: MerchantStatisticAmountByInterval + + interface MerchantStatisticAmountByInterval { + + // Start time of the interval. + // The interval always ends at the response + // generation time. + start_time: Timestamp; + + // Sum of all amounts falling under the given + // SLUG within this timeframe. + cumulative_amounts: Amount[]; + + } diff --git a/core/merchant/get-management-instances-INSTANCE-statistics-counter-SLUG.rst b/core/merchant/get-management-instances-INSTANCE-statistics-counter-SLUG.rst @@ -0,0 +1,78 @@ +.. http:get:: /management/instances/$INSTANCE/statistics-counter/$SLUG +.. http:get:: [/instances/$INSTANCE]/private/statistics-counter/$SLUG + + This request will return be used to statistics where the + values are counters. All available values for the given + SLUG will be returned. + Since protocol **v25**. + + **Required permission:** ``statistics-read`` + + **Request:** + + :query by: *Optional*. If set to "BUCKET", only statistics by bucket will be returned. If set to "INTERVAL", only statistics kept by interval will be returned. If not set or set to "ANY", both will be returned. + + **Response:** + + :http:statuscode:`200 Ok`: + The body will be a `MerchantStatisticsCounterResponse` + :http:statuscode:`401 Unauthorized`: + The request is unauthorized. + :http:statuscode:`404 Not found`: + The instance is unknown to the backend. + + **Details:** + + .. ts:def:: MerchantStatisticsCounterResponse + + interface MerchantStatisticsCounterResponse { + + // Statistics kept for a particular fixed time window. + buckets: MerchantStatisticCounterByBucket[]; + + // Human-readable bucket statistic description. + // Unset if no buckets returned + buckets_description?: string; + + // Statistics kept for a particular sliding interval. + intervals: MerchantStatisticCounterByInterval[]; + + // Human-readable interval statistic description. + // Unset if no intervals returned + intervals_description?: string; + + } + + .. ts:def:: MerchantStatisticCounterByBucket + + interface MerchantStatisticCounterByBucket { + + // Start time of the bucket (inclusive) + start_time: Timestamp; + + // End time of the bucket (exclusive) + end_time: Timestamp; + + // Range of the bucket + range: StatisticBucketRange; + + // Sum of all counters falling under the given + // SLUG within this timeframe. + cumulative_counter: Integer; + + } + + .. ts:def:: MerchantStatisticCounterByInterval + + interface MerchantStatisticCounterByInterval { + + // Start time of the interval. + // The interval always ends at the response + // generation time. + start_time: Timestamp; + + // Sum of all counters falling under the given + // SLUG within this timeframe. + cumulative_counter: Integer; + + } diff --git a/core/merchant/get-management-instances-INSTANCE-statistics-report-NAME.rst b/core/merchant/get-management-instances-INSTANCE-statistics-report-NAME.rst @@ -0,0 +1,109 @@ +.. http:get:: /management/instances/$INSTANCE/statistics-report/$NAME +.. http:get:: [/instances/$INSTANCE]/private/statistics-report/$NAME + + This request will return be used to generate a specific + report based on $NAME. The backend **MAY** support generating + the report in various formats. Supported values for ``$NAME`` include: + + * "transactions" (total revenue, total refunds, fees + as well as number of transactions), since **v25** + * "money-pots" (changes to totals in money pots), since **v25** + * "taxes" (amount of taxes withheld by tax class), since **vTAXES**, + * "sales-funnel" (number and volume of orders + created, claimed, paid, refunded and settled), since **vXXX**, + + The overall endpoint family exists since protocol **v25**. + + **Required permission:** ``statistics-read`` + + **Request:** + + *Accept*: + The client may specify the desired MIME-type for the result. + Supported are the usual "application/json", but also + "application/pdf". + + :query granularity: *Optional*. Determines the bucket granularity + to return. Accepted are "hour", "day", "week", + "month", "quarter" and "year". Defaults to "month". + :query count: *Optional*. Number of buckets to return. Defaults depends + on the granularity. + + **Response:** + + :http:statuscode:`200 Ok`: + If JSON is requested, the body will be + a `MerchantStatisticsReportResponse`, otherwise a PDF. + :http:statuscode:`401 Unauthorized`: + The request is unauthorized. + :http:statuscode:`404 Not found`: + The instance is unknown to the backend. + :http:statuscode:`410 Gone`: + The requested statistical data is unavailable because + it is not kept at the requested granularity for this long. + :http:statuscode:`501 Not implemented`: + The requested functionality is not implemented. + Usually returned if the PDF generator is not available + at this backend and the requested format was application/pdf. + + **Details:** + + .. ts:def:: MerchantStatisticsReportResponse + + interface MerchantStatisticsReportResponse { + + // Name of the business for which the report is generated. + business_name: String; + + // Starting date for the report. + start_date: Timestamp; + + // End date for the report. + end_date: Timestamp; + + // Period of time covered by each bucket (aka granularity). + bucket_period: RelativeTime; + + // Charts to include in the report. + charts: MerchantReportChart[]; + + } + + .. ts:def:: MerchantReportChart + + interface MerchantReportChart { + + // Name of the chart. + chart_name: String; + + // Label to use for the y-axis of the chart. + // (x-axis is always time). + y_label: String; + + // Statistical values for the respective time windows, + // one entry per ``bucket_period`` in between ``start_date`` + // and ``end_date``. + data_groups: BucketDataGroup[]; + + // Human-readable labels for the ``values`` in each of the + // ``data_groups``. Length of the array must match the + // length of the ``values`` arrays. + labels: string[]; + + // Should the ``values`` in each of the ``data_groups`` + // be rendered cumulatively or using a grouped representation? + cumulative: boolean; + + } + + .. ts:def:: BucketDataGroup + + interface BucketDataGroup { + + // Starting data for this group + start_date: Timestamp; + + // Values in the data group. + values: Float[]; + + } diff --git a/core/merchant/get-management-instances-INSTANCE.rst b/core/merchant/get-management-instances-INSTANCE.rst @@ -0,0 +1,94 @@ +.. http:get:: /management/instances/$INSTANCE +.. http:get:: [/instances/$INSTANCE]/private + + This is used to query a specific merchant instance. GET operations against + an instance are authenticated by checking that an authorization is provided + that matches either the credential required by the instance being modified + OR the ``admin`` instance, depending on the access path used. + + This endpoint may be used even when mandatory TAN channels + were not validated yet. + + **Required permission:** ``instances-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the list of instances stored. Returns + a `QueryInstancesResponse`. + + **Details:** + + .. ts:def:: QueryInstancesResponse + + interface QueryInstancesResponse { + + // Merchant name corresponding to this instance. + name: string; + + // Merchant email for customer contact and password reset. + email?: string; + + // True if the ``email`` address was validated. + // @since **v21**. + email_validated?: boolean; + + // Merchant phone number for password reset (2-FA) + // @since **v21**. + phone_number?: string; + + // True if the ``email`` address was validated. + // @since **v21**. + phone_validated?: boolean; + + // Merchant public website. + website?: string; + + // Merchant logo. + logo?: ImageDataUrl; + + // Public key of the merchant/instance, in Crockford Base32 encoding. + merchant_pub: EddsaPublicKey; + + // The merchant's physical address (to be put into contracts). + address: Location; + + // The jurisdiction under which the merchant conducts its business + // (to be put into contracts). + jurisdiction: Location; + + // Use STEFAN curves to determine default fees? + // If false, no fees are allowed by default. + // Can always be overridden by the frontend on a per-order basis. + use_stefan: boolean; + + // If the frontend does NOT specify a payment deadline, how long should + // offers we make be valid by default? Added to the order creation + // time. + default_pay_delay: RelativeTime; + + // If the frontend does NOT specify a refund deadline, how long should + // refunds be allowed by default? Added to the payment deadline. + // @since **v22** + default_refund_delay: RelativeTime; + + // If the frontend does NOT specify an execution date, how long should + // we tell the exchange to wait to aggregate transactions before + // executing the wire transfer? This delay is added to the + // refund deadline and subject to rounding to the + // ``default_wire_transfer_rounding_interval``. + default_wire_transfer_delay: RelativeTime; + + // Default interval to which wire deadlines computed by + // adding the wire_transfer_delay on top of the refund + // deadline should be rounded up to. + // @since **v23** + default_wire_transfer_rounding_interval: RoundingInterval; + + // Authentication configuration. + // Does not contain the token when token auth is configured. + auth: { + method: "external" | "token"; + }; + + } diff --git a/core/merchant/get-management-instances.rst b/core/merchant/get-management-instances.rst @@ -0,0 +1,52 @@ +.. http:get:: /management/instances + + This is used to return the list of all the merchant instances. + It is only available for the implicit ``admin`` instance. + + **Required permission:** ``instances-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the list of instances stored. Returns + a `InstancesResponse`. + + **Details:** + + .. ts:def:: InstancesResponse + + interface InstancesResponse { + // List of instances that are present in the backend (see `Instance`). + instances: Instance[]; + } + + The `Instance` object describes the instance registered with the backend. + It does not include the full details, only those that usually concern the frontend. + It has the following structure: + + .. ts:def:: Instance + + interface Instance { + // Merchant name corresponding to this instance. + name: string; + + // Merchant public website. + website?: string; + + // Merchant logo. + logo?: ImageDataUrl; + + // Merchant instance this response is about ($INSTANCE). + id: string; + + // Public key of the merchant/instance, in Crockford Base32 encoding. + merchant_pub: EddsaPublicKey; + + // List of the payment targets supported by this instance. Clients can + // specify the desired payment target in /order requests. Note that + // front-ends do not have to support wallets selecting payment targets. + payment_targets: string[]; + + // Has this instance been deleted (but not purged)? + deleted: boolean; + } diff --git a/core/merchant/get-orders-ORDER_ID.rst b/core/merchant/get-orders-ORDER_ID.rst @@ -0,0 +1,119 @@ +.. http:get:: [/instances/$INSTANCE]/orders/$ORDER_ID + + Query the payment status of an order. This endpoint is for the wallet + and possibly for Web shops and other integrations that need an + unauthenticated way to query the order status (like when checking + it from JavaScript from inside the customer's browser). It is also + possible to just redirect a browser to this URL to initiate the + payment process. + + When a client (usually a wallet) goes to this URL and it is unpaid, + it will be prompted for payment. + This endpoint typically also supports requests with the "Accept" header + requesting "text/html". In this case, an HTML response suitable for + triggering the interaction with the wallet is returned, with ``timeout_ms`` + ignored (treated as zero). If the backend installation does not include the + required HTML templates, a 406 status code is returned. + + In the case that the request was made with a claim token (even the wrong one) + and the order was claimed and paid, the server will redirect the client to + the fulfillment URL. This redirection will happen with a 302 status code + if the "Accept" header specified "text/html", and with a 202 status code + otherwise. + + **Request:** + + :query h_contract=HASH: *Optional*. Hash of the order's contract terms (this is used to authenticate the wallet/customer in case $ORDER_ID is guessable). Required once an order was claimed. + :query token=TOKEN: *Optional*. Authorizes the request via the claim token that was returned in the `PostOrderResponse`. Used with unclaimed orders only. Whether token authorization is required is determined by the merchant when the frontend creates the order. + :query session_id=STRING: *Optional*. Session ID that the payment must be bound to. If not specified, the payment is not session-bound. + :query timeout_ms=NUMBER: *Optional.* If specified, the merchant backend will + wait up to ``timeout_ms`` milliseconds for completion of the payment before + sending the HTTP response. A client must never rely on this behavior, as the + merchant backend may return a response immediately. + :query await_refund_obtained=BOOLEAN: *Optional*. If set to "yes", poll for the order's pending refunds to be picked up. ``timeout_ms`` specifies how long we will wait for the refund. + :query refund=AMOUNT: *Optional*. Indicates that we are polling for a refund above the given AMOUNT. ``timeout_ms`` will specify how long we will wait for the refund. + :query allow_refunded_for_repurchase: *Optional*. Since protocol **v9** refunded orders are only returned under "already_paid_order_id" if this flag is set explicitly to "YES". + + **Response:** + + :http:statuscode:`200 OK`: + The response is a `StatusPaidResponse`. + :http:statuscode:`202 Accepted`: + The response is a `StatusGotoResponse`. + Returned only for unauthenticated (no nonce, no contract hash) + requests and only if the order was claimed already. + Only returned if the content type requested was not HTML, + if HTML was requested a `302 Found` will be returned instead. + The target site may allow the client to setup a fresh + order (as this one has been taken) or may + trigger repurchase detection. + Note that **if** the contract lacks a ``public_reorder_url`` + the backend will instead return a `403 Forbidden` response. + :http:statuscode:`302 Found`: + The client should go to the indicated location (via HTTP "Location:" header). + Returned only for unauthenticated (no nonce, no contract hash) + requests and only if the order was claimed already. + Only returned if the content type requested was HTML + if HTML was not requested a `302 Accepted` will be returned instead. + The target site may allow the client to setup a fresh + order (as this one has been taken) or may + trigger repurchase detection. + Note that **if** the contract lacks a ``public_reorder_url`` + the backend will instead return a `403 Forbidden` response. + :http:statuscode:`402 Payment required`: + The response is a `StatusUnpaidResponse`. + :http:statuscode:`403 Forbidden`: + The ``h_contract`` (or the ``token`` for unclaimed orders) does not match the order + and we have no fulfillment URL in the contract. + :http:statuscode:`404 Not found`: + The merchant backend is unaware of the order. + :http:statuscode:`406 Not acceptable`: + The merchant backend could not load the template required to generate a reply in the desired format. (Likely HTML templates were not properly installed.) + + **Details:** + + .. ts:def:: StatusPaidResponse + + interface StatusPaidResponse { + // Was the payment refunded (even partially, via refund or abort)? + refunded: boolean; + + // Is any amount of the refund still waiting to be picked up (even partially)? + refund_pending: boolean; + + // Amount that was refunded in total. + refund_amount: Amount; + + // Amount that already taken by the wallet. + refund_taken: Amount; + } + + .. ts:def:: StatusGotoResponse + + interface StatusGotoResponse { + // The client should go to the reorder URL, there a fresh + // order might be created as this one is taken by another + // customer or wallet (or repurchase detection logic may + // apply). + public_reorder_url: string; + } + + .. ts:def:: StatusUnpaidResponse + + interface StatusUnpaidResponse { + // URI that the wallet must process to complete the payment. + taler_pay_uri: string; + + // Fulfillment URL of the contract. + // If present, it should be possible to create an + // equivalent order by redirecting a browser to this + // URL. Once the customer has paid, they should see the + // order's fulfillment (digital goods, tracking data for + // shipping, etc.) under this URL (assuming they use the + // same session that the wallet used when making the payment). + fulfillment_url?: string; + + // Alternative order ID which was paid for already in the same session. + // Only given if the same product was purchased before in the same session. + already_paid_order_id?: string; + } diff --git a/core/merchant/get-private-accounts-H_WIRE.rst b/core/merchant/get-private-accounts-H_WIRE.rst @@ -0,0 +1,38 @@ +.. http:get:: [/instances/$INSTANCE]/private/accounts/$H_WIRE + + This is used to obtain detailed information about a specific bank account. + + + **Required permission:** ``accounts-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the detailed information about a specific bank account. + Returns a `BankAccountDetail`. + :http:statuscode:`404 Not found`: + The bank account or instance is unknown to the backend. + + **Details:** + + .. ts:def:: BankAccountDetail + + interface BankAccountDetail { + + // Full payto:// URI of the account. + payto_uri: string; + + // Hash over the wire details (including over the salt). + h_wire: HashCode; + + // Salt used to compute h_wire. + salt: HashCode; + + // URL from where the merchant can download information + // about incoming wire transfers to this account. + credit_facade_url?: string; + + // true if this account is active, + // false if it is historic. + active: boolean; + } diff --git a/core/merchant/get-private-accounts.rst b/core/merchant/get-private-accounts.rst @@ -0,0 +1,38 @@ +.. http:get:: [/instances/$INSTANCE]/private/accounts + + This is used to return the list of all the bank accounts + of an instance. + + **Required permission:** ``accounts-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned all the accounts. Returns a `AccountsSummaryResponse`. + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: AccountsSummaryResponse + + interface AccountsSummaryResponse { + + // List of accounts that are known for the instance. + accounts: BankAccountEntry[]; + } + + .. ts:def:: BankAccountEntry + + interface BankAccountEntry { + + // Full payto:// URI of the account. + payto_uri: string; + + // Hash over the wire details (including over the salt). + h_wire: HashCode; + + // true if this account is active, + // false if it is historic. + active: boolean; + } diff --git a/core/merchant/get-private-categories-CATEGORY_ID.rst b/core/merchant/get-private-categories-CATEGORY_ID.rst @@ -0,0 +1,39 @@ +.. http:get:: [/instances/$INSTANCE]/private/categories/$CATEGORY_ID + + This request returns the known products in the given + category. + Since API version **v16**. + + **Required permission:** ``categories-read`` + + **Response:** + + :http:statuscode:`200 Ok`: + The body is a `CategoryProductListResponse`. + + **Details:** + + .. ts:def:: CategoryProductListResponse + + interface CategoryProductListResponse { + + // Name of the category. + name: string; + + // Translations of the name into various + // languages. + name_i18n?: { [lang_tag: string]: string }; + + // The products in this category. + products: CategoryProductSummary[]; + + } + + .. ts:def:: CategoryProductSummary + + interface CategoryProductSummary { + + // ID of a product in the category. + product_id: string; + + } diff --git a/core/merchant/get-private-categories.rst b/core/merchant/get-private-categories.rst @@ -0,0 +1,43 @@ +.. http:get:: [/instances/$INSTANCE]/private/categories + + This request returns the known product categories + and the number of products in each category. + Since API version **v16**. + + **Required permission:** ``categories-read`` + + **Response:** + + :http:statuscode:`200 Ok`: + The body is a `CategoryListResponse`. + + **Details:** + + .. ts:def:: CategoryListResponse + + interface CategoryListResponse { + + // Array with all of the categories we know. + categories: CategoryListEntry[]; + + } + + .. ts:def:: CategoryListEntry + + interface CategoryListEntry { + + // Unique number for the category. + category_id: Integer; + + // Name of the category. + name: string; + + // Translations of the name into various + // languages. + name_i18n?: { [lang_tag: string]: string }; + + // Number of products in this category. + // A product can be in more than one category. + product_count: Integer; + + } diff --git a/core/merchant/get-private-donau.rst b/core/merchant/get-private-donau.rst @@ -0,0 +1,55 @@ +.. http:get:: [/instances/$INSTANCE]/private/donau + + Return all Donau charity instances currently linked to ``$INSTANCE``. + + **Required permission:** ``donau-read`` + + **Response:** + + :http:statuscode:`200 OK`: + Body is a :ts:type:`DonauInstancesResponse`. + :http:statuscode:`401 Unauthorized`: + Missing or invalid credentials. + :http:statuscode:`404 Not found`: + The merchant instance is unknown. + + **Details:** + + .. ts:def:: DonauInstancesResponse + + interface DonauInstancesResponse { + // List of linked charity instances + donau_instances: DonauInstance[]; + } + + .. ts:def:: DonauInstance + + interface DonauInstance { + // Serial number identifying the record inside the backend + donau_instance_serial: Integer; + + // Base URL of the Donau service + donau_url: string; + + // Human-readable charity name + charity_name: string; + + // EdDSA public key of the charity (binary) + charity_pub_key: EddsaPublicKey; + + // Charity identifier inside the Donau service + charity_id: Integer; + + // Maximum donation amount per calendar year + charity_max_per_year: Amount; + + // Cumulative receipts in the current year + charity_receipts_to_date: Amount; + + // Calendar year the receipts refer to + current_year: Integer; + + // Exchange-style ``/keys`` response published by Donau, + // missing if not yet known to the merchant backend. + donau_keys_json?: object; + } diff --git a/core/merchant/get-private-groups.rst b/core/merchant/get-private-groups.rst @@ -0,0 +1,51 @@ +.. http:get:: [/instances/$INSTANCES]/private/groups + + This is used to return all the groups + that are present in our backend. + + **Required permission:** ``groups-read`` + + **Request:** + + :query limit: *Optional.* + At most return the given number of results. Negative for descending by ``serial``, positive for ascending by ``serial``. Defaults to ``-20``. + :query offset: *Optional.* + Starting ``serial`` for :ref:`pagination <row-id-pagination>`. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned all the groups. + Returns a `GroupsSummaryResponse`. + + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: GroupsSummaryResponse + + interface GroupsSummaryResponse { + + // Return groups that are present in our backend. + groups: GroupEntry[]; + + } + + The `GroupEntry` object describes a group. + It has the following structure: + + .. ts:def:: GroupEntry + + interface GroupEntry { + + // Group identifier + group_serial: Integer; + + // Unique name for the group (unique per instance). + group_name: string; + + // Description for the group. + description: string; + + } diff --git a/core/merchant/get-private-incoming-ID.rst b/core/merchant/get-private-incoming-ID.rst @@ -0,0 +1,60 @@ +.. http:get:: [/instances/$INSTANCE]/private/incoming/$ID + + Obtain details about an expected incoming wire transfers the backend is + anticipating. ID must be the ``expected_transfer_serial_id`` + from `ExpectedTransferDetails`. + Since protocol **v26**. + + **Required permission:** ``transfers-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The body of the response is a `ExpectedTransferDetailResponse`. + :http:statuscode:`404 Not found`: + The expected wire transfer ``$ID`` is unknown. + :http:statuscode:`409 Conflict`: + The exchange did not yet provide the transaction details + (the ``last_http_status`` of the `ExpectedTransferDetails` is + not 200). The information may be available later but is not yet. + + **Details:** + + .. ts:def:: ExpectedTransferDetailResponse + + interface ExpectedTransferDetails { + + // List of orders that are settled by this wire + // transfer according to the exchange. Only + // available if ``last_http_status`` is 200. + reconciliation_details?: ExchangeTransferReconciliationDetails[]; + + // Wire fee paid by the merchant. Only + // available if ``last_http_status`` is 200. + // Not present if the backend was unable to obtain the + // wire fee for the ``execution_time`` from the exchange. + // (If missing, this is thus indicative of a minor error.) + wire_fee?: Amount; + + } + + .. ts:def:: ExchangeTransferReconciliationDetails + + interface ExchangeTransferReconciliationDetails { + + // ID of the order for which these are the + // reconciliation details. + order_id: string; + + // Remaining deposit total to be paid, + // that is the total amount of the order + // minus any refunds that were granted. + // The actual amount to be wired is this + // amount minus ``deposit_fee`` and (overall) + // minus the ``wire_fee`` of the transfer. + remaining_deposit: Amount; + + // Deposit fees paid to the exchange for this order. + deposit_fee: Amount; + + } diff --git a/core/merchant/get-private-incoming.rst b/core/merchant/get-private-incoming.rst @@ -0,0 +1,87 @@ +.. http:get:: [/instances/$INSTANCE]/private/incoming + + Obtain a list of expected incoming wire transfers the backend is + anticipating. + Since protocol **v20**. + + **Required permission:** ``transfers-read`` + + **Request:** + + :query payto_uri: *Optional*. Full payto://-URI to filter for transfers to the given bank account (subject and amount MUST NOT be given in the payto:// URI). Note that the URI must be URL-encoded. + + :query before: *Optional*. Filter for transfers executed before the given timestamp. + + :query after: *Optional*. Filter for transfers executed after the given timestamp. + + :query limit: *Optional*. At most return the given number of results. Negative for descending in execution time, positive for ascending in execution time. Default is ``-20``. + + :query offset: *Optional*. Starting ``expected_transfer_serial_id`` for an iteration. + + :query verified: *Optional*. Filter transfers by verification status (YES: reconcilation worked, NO: reconciliation failed, ALL: default) + + :query confirmed: *Optional*. Filter transfers that were confirmed (YES: credit confirmed, NO: credit still pending, ALL: default) + + + **Response:** + + :http:statuscode:`200 OK`: + The body of the response is a `ExpectedTransferListResponse`. + + **Details:** + + .. ts:def:: ExpectedTransferListResponse + + interface ExpectedTransferListResponse { + // List of all the expected incoming transfers that fit the + // filter that we know. + incoming : ExpectedTransferDetails[]; + } + + .. ts:def:: ExpectedTransferDetails + + interface ExpectedTransferDetails { + // How much should be wired to the merchant (minus fees). + expected_credit_amount?: Amount; + + // Raw wire transfer identifier identifying the wire transfer (a base32-encoded value). + wtid: WireTransferIdentifierRawP; + + // Full payto://-URI of the bank account that received the wire transfer. + payto_uri: string; + + // Base URL of the exchange that made the wire transfer. + exchange_url: string; + + // Serial number identifying the expected transfer in the backend. + // Used for filtering via ``offset``. + expected_transfer_serial_id: Integer; + + // Expected time of the execution of the wire transfer + // by the exchange, according to the exchange. + execution_time?: Timestamp; + + // True if we checked the exchange's answer and are happy with + // the reconciation data. + // False if we have an answer and are unhappy, missing if we + // do not have an answer from the exchange. + // Does not imply that the wire transfer was settled (for + // that, see ``confirmed``). + validated: boolean; + + // True if the merchant uses the POST /transfers API to confirm + // that this wire transfer took place (and it is thus not + // something merely claimed by the exchange). + // (a matching entry exists in /private/transfers) + confirmed: boolean; + + // Last HTTP status we received from the exchange, 0 for + // none (incl. timeout) + last_http_status: Integer; + + // Last Taler error code we got from the exchange. + last_ec: ErrorCode; + + // Last error detail we got back from the exchange. + last_error_detail?: string; + } diff --git a/core/merchant/get-private-orders-ORDER_ID.rst b/core/merchant/get-private-orders-ORDER_ID.rst @@ -0,0 +1,246 @@ +.. http:get:: [/instances/$INSTANCE]/private/orders/$ORDER_ID + + Merchant checks the payment status of an order. If the order exists but is not paid + and not claimed yet, the response provides a redirect URL. When the user goes to this URL, + they will be prompted for payment. Differs from the ``public`` API both + in terms of what information is returned and in that the wallet must provide + the contract hash to authenticate, while for this API we assume that the + merchant is authenticated (as the endpoint is not ``public``). + + **Required permission:** ``orders-read`` + + **Request:** + + :query session_id: *Optional*. Session ID that the payment must be bound to. If not specified, the payment is not session-bound. + :query transfer: Deprecated in protocol **V6**. *Optional*. If set to "YES", try to obtain the wire transfer status for this order from the exchange. Otherwise, the wire transfer status MAY be returned if it is available. + :query timeout_ms: *Optional*. Timeout in milliseconds to wait for a payment if the answer would otherwise be negative (long polling). + :query lp_not_etag=ETAG: *Optional*. + Specifies what status change we are long-polling for. + If specified, the endpoint will only return once the returned "Etag" + would differ from the ETAG specified by the client. The "Etag" + is computed over the entire response body, and thus assured to change + whenever any data point in the response changes. This is ideal for + clients that want to learn about any change in the response. Clients + using this query parameter should probably also set a "If-none-match" + HTTP header so that if the ``timeout_ms`` expires, they can get back + a "304 Not modified" with an empty body if nothing changed. + :query allow_refunded_for_repurchase: *Optional*. Since protocol **v9** refunded orders are only returned under "already_paid_order_id" if this flag is set explicitly to "YES". + + **Response:** + + :http:statuscode:`200 OK`: + Returns a `MerchantOrderStatusResponse`, whose format can differ based on the status of the payment. + :http:statuscode:`304 Not modified`: + The ``ETag`` in the response did not change compared to the one + given in the ``If-none-match`` HTTP header specified by the client. + @since protocol **v25**. + :http:statuscode:`404 Not found`: + The order or instance is unknown to the backend. Error code + is set to either ``MERCHANT_GENERIC_ORDER_UNKNOWN`` or + ``MERCHANT_GENERIC_INSTANCE_UNKNOWN``. + + **Details:** + + .. ts:def:: MerchantOrderStatusResponse + + type MerchantOrderStatusResponse = CheckPaymentPaidResponse | + CheckPaymentClaimedResponse | + CheckPaymentUnpaidResponse; + + .. ts:def:: CheckPaymentPaidResponse + + interface CheckPaymentPaidResponse { + // The customer paid for this contract. + order_status: "paid"; + + // Was the payment refunded (even partially)? + refunded: boolean; + + // True if there are any approved refunds that the wallet has + // not yet obtained. + refund_pending: boolean; + + // Did the exchange wire us the funds? + wired: boolean; + + // Total amount the exchange deposited into our bank account + // for this contract, excluding fees. + deposit_total: Amount; + + // Numeric `error code <error-codes>` indicating errors the exchange + // encountered tracking the wire transfer for this purchase (before + // we even got to specific coin issues). + // 0 if there were no issues. + exchange_code: Integer; + + // HTTP status code returned by the exchange when we asked for + // information to track the wire transfer for this purchase. + // 0 if there were no issues. + exchange_http_status: Integer; + + // Total amount that was refunded, 0 if refunded is false. + refund_amount: Amount; + + // Contract terms. + contract_terms: ContractTerms; + + // Index of the selected choice within the ``choices`` array of + // ``contract terms``. + // @since protocol **v21** + choice_index?: Integer; + + // If the order is paid, set to the last time when a payment + // was made to pay for this order. @since **v14**. + last_payment: Timestamp; + + // The wire transfer status from the exchange for this order if + // available, otherwise empty array. + wire_details: TransactionWireTransfer[]; + + // Groups about trouble obtaining wire transfer details, + // empty array if no trouble were encountered. + // @deprecated in protocol **v6**. + wire_groups: TransactionWireReport[]; + + // The refund details for this order. One entry per + // refunded coin; empty array if there are no refunds. + refund_details: RefundDetails[]; + + // Status URL, can be used as a redirect target for the browser + // to show the order QR code / trigger the wallet. + order_status_url: string; + } + + .. ts:def:: CheckPaymentClaimedResponse + + interface CheckPaymentClaimedResponse { + // A wallet claimed the order, but did not yet pay for the contract. + order_status: "claimed"; + + // Contract terms. + contract_terms: ContractTerms; + + // Status URL, can be used as a redirect target for the browser + // to show the order QR code / trigger the wallet. + // Since protocol **v19**. + order_status_url: string; + } + + .. ts:def:: CheckPaymentUnpaidResponse + + interface CheckPaymentUnpaidResponse { + // The order was not yet claimed (and thus certainly also + // not yet paid). + order_status: "unpaid"; + + // URI that the wallet must process to complete the payment. + taler_pay_uri: string; + + // Time when the order was created. + creation_time: Timestamp; + + // Deadline when the offer expires; the customer must pay before. + // @since protocol **v21**. + // @deprecated in **v25** (use proto_contract_terms.pay_deadline instead). + pay_deadline: Timestamp; + + // Order summary text. + // @deprecated in **v25** (use proto_contract_terms.summary instead). + summary: string; + + // We cannot return the "final" contract terms here because + // the ``nonce`` is not available because the wallet did not yet + // claim the order. + // So the "ProtoContractTerms" are basically the contract terms, + // but without the ``nonce``. + // @since protocol **v25**. + proto_contract_terms: ProtoContractTerms; + + // Total amount of the order (to be paid by the customer). + // Will be undefined for unpaid v1 orders + // @deprecated in **v25** (use proto_contract_terms instead). + total_amount?: Amount; + + // Alternative order ID which was paid for already in the same session. + // Only given if the same product was purchased before in the same session. + already_paid_order_id?: string; + + // Fulfillment URL of an already paid order. Only given if under this + // session an already paid order with a fulfillment URL exists. + already_paid_fulfillment_url?: string; + + // Status URL, can be used as a redirect target for the browser + // to show the order QR code / trigger the wallet. + order_status_url: string; + + } + + .. ts:def:: RefundDetails + + interface RefundDetails { + // Reason given for the refund. + reason: string; + + // True if a refund is still available for the wallet for this payment. + pending: boolean; + + // When was the refund approved with a POST to + // [/instances/$INSTANCE]/private/orders/$ORDER_ID/refund + timestamp: Timestamp; + + // Total amount that was refunded (minus a refund fee). + amount: Amount; + } + + .. ts:def:: TransactionWireTransfer + + interface TransactionWireTransfer { + // Responsible exchange. + exchange_url: string; + + // 32-byte wire transfer identifier. + wtid: Base32; + + // Execution time of the wire transfer. + execution_time: Timestamp; + + // Total amount that has been wire transferred + // to the merchant from this exchange for this + // purchase. The ``deposit_fee`` was already + // subtracted. However, the ``wire_fee`` may still + // apply (but not to the order, only to the aggregated transfer). + amount: Amount; + + // Deposit fees to be paid to the + // exchange for this order. + // Since **v26**. + deposit_fee: Amount; + + // Was this transfer confirmed by the merchant via the + // POST /transfers API, or is it merely claimed by the exchange? + confirmed: boolean; + + // Transfer serial ID of this wire transfer, useful as + // ``offset`` for the GET ``/private/incoming`` endpoint. + // Since **v25**. + expected_transfer_serial_id: Integer; + } + + .. ts:def:: TransactionWireReport + + interface TransactionWireReport { + // Numerical `error code <error-codes>`. + code: Integer; + + // Human-readable error description. + hint: string; + + // Numerical `error code <error-codes>` from the exchange. + exchange_code: Integer; + + // HTTP status code received from the exchange. + exchange_http_status: Integer; + + // Public key of the coin for which we got the exchange error. + coin_pub: CoinPublicKey; + } diff --git a/core/merchant/get-private-orders.rst b/core/merchant/get-private-orders.rst @@ -0,0 +1,78 @@ +.. http:get:: [/instances/$INSTANCE]/private/orders + + Returns known orders up to some point in the past. + + **Required permission:** ``orders-read`` + + **Request:** + + :query paid: *Optional*. If set to yes, only return paid orders, if no only unpaid orders. Do not give (or use "all") to see all orders regardless of payment status. + :query refunded: *Optional*. If set to yes, only return refunded orders, if no only unrefunded orders. Do not give (or use "all") to see all orders regardless of refund status. + :query wired: *Optional*. If set to yes, only return wired orders, if no only orders with missing wire transfers. Do not give (or use "all") to see all orders regardless of wire transfer status. + :query delta: *Optional*. takes value of the form ``N (-N)``, so that at most ``N`` values strictly older (younger) than ``start`` and ``date_s`` are returned. Defaults to ``-20`` to return the last 20 entries (before ``start`` and/or ``date_s``). Deprecated in protocol **v12**. Use *limit* instead. + :query limit: *Optional*. At most return the given number of results. Negative for descending by row ID, positive for ascending by row ID. Default is ``20``. Since protocol **v12**. + :query date_s: *Optional.* Non-negative date in seconds after the UNIX Epoc, see ``delta`` for its interpretation. If not specified, we default to the oldest or most recent entry, depending on ``limit``. + :query start: *Optional*. Row number threshold, see ``limit`` for its interpretation. Defaults to ``INT64_MAX``, namely the biggest row id possible in the database. Deprecated in protocol **v12**. Use *offset* instead. + :query offset: *Optional*. Starting ``row_id`` for an iteration. Since protocol **v12**. + :query timeout_ms: *Optional*. Timeout in milliseconds to wait for additional orders if the answer would otherwise be negative (long polling). Only useful if ``limit`` is positive. Note that the merchant MAY still return a response that contains fewer than ``limit`` orders. + :query session_id: *Optional*. Since protocol **v6**. Filters by session ID. + :query fulfillment_url: *Optional*. Since protocol **v6**. Filters by fulfillment URL. + :query summary_filter: *Optional*. Only returns orders where the summary contains the given text as a substring. Matching is case-insensitive. Since protocol **v23**. + + **Response:** + + :http:statuscode:`200 OK`: + The response is an `OrderHistory`. + + **Details:** + + .. ts:def:: OrderHistory + + interface OrderHistory { + // Timestamp-sorted array of all orders matching the query. + // The order of the sorting depends on the sign of ``limit``. + orders : OrderHistoryEntry[]; + } + + + .. ts:def:: OrderHistoryEntry + + interface OrderHistoryEntry { + + // Order ID of the transaction related to this entry. + order_id: string; + + // Row ID of the order in the database. + row_id: Integer; + + // When the order was created. + timestamp: Timestamp; + + // The amount of money the order is for. If the contract + // has multiple choices and the user has not yet made a choice, + // we return the amount of the first choice. + amount: Amount; + + // The total amount of refunds granted by the merchant. + // Includes refunds that the wallet did not yet pick up. + // Only available if the order was paid. + // Since **v24**. + refund_amount: Amount; + + // The amount of refunds the customer's wallet did not yet + // pick up. Only available if the order was paid. + // Since **v24**. + pending_refund_amount: Amount; + + // The summary of the order. + summary: string; + + // Whether some part of the order is refundable, + // that is the refund deadline has not yet expired + // and the total amount refunded so far is below + // the value of the original transaction. + refundable: boolean; + + // Whether the order has been paid or not. + paid: boolean; + } diff --git a/core/merchant/get-private-otp-devices-DEVICE_ID.rst b/core/merchant/get-private-otp-devices-DEVICE_ID.rst @@ -0,0 +1,80 @@ +.. http:get:: [/instances/$INSTANCE]/private/otp-devices/$DEVICE_ID + + This is used to obtain detailed information about a specific OTP device. + + The client can provide additional inputs in the query to allow the backend + to compute and return a sample OTP code. Note that it is not an error if + the client provides query arguments that are not being used *or* that are + insufficient for the server to compute the ``otp_code``: If the client + provides inadequate query parameters, the ``otp_code`` is simply omitted + from the response. + + **Required permission:** ``otp-devices-read`` + + **Query:** + + :query faketime=TIMESTAMP: *Optional*. Timestamp in seconds to use when calculating the current OTP code of the device. Since protocol **v10**. + :query price=AMOUNT: *Optional*. Price to use when calculating the current OTP code of the device. Since protocol **v10**. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the detailed information about a specific OTP device. + Returns a `OtpDeviceDetails`. + :http:statuscode:`404 Not found`: + The OTP device or instance is unknown to the backend. + + **Details:** + + .. ts:def:: OtpDeviceDetails + + interface OtpDeviceDetails { + + // Human-readable description for the device. + device_description: string; + + // Algorithm for computing the POS confirmation. + // + // Currently, the following numbers are defined: + // 0: None + // 1: TOTP without price + // 2: TOTP with price + otp_algorithm: Integer; + + // Counter for counter-based OTP devices. + otp_ctr?: Integer; + + // Current time for time-based OTP devices. + // Will match the ``faketime`` argument of the + // query if one was present, otherwise the current + // time at the backend. + // + // Available since protocol **v10**. + otp_timestamp: Integer; + + // Current OTP confirmation string of the device. + // Matches exactly the string that would be returned + // as part of a payment confirmation for the given + // amount and time (so may contain multiple OTP codes). + // + // If the ``otp_algorithm`` is time-based, the code is + // returned for the current time, or for the ``faketime`` + // if a TIMESTAMP query argument was provided by the client. + // + // When using OTP with counters, the counter is **NOT** + // increased merely because this endpoint created + // an OTP code (this is a GET request, after all!). + // + // If the ``otp_algorithm`` requires an amount, the + // ``amount`` argument must be specified in the + // query, otherwise the ``otp_code`` is not + // generated. + // + // This field is *optional* in the response, as it is + // only provided if we could compute it based on the + // ``otp_algorithm`` and matching client query arguments. + // + // Available since protocol **v10**. + otp_code?: string; + + } diff --git a/core/merchant/get-private-otp-devices.rst b/core/merchant/get-private-otp-devices.rst @@ -0,0 +1,33 @@ +.. http:get:: [/instances/$INSTANCE]/private/otp-devices + + This is used to return the list of all the OTP devices. + + **Required permission:** ``otp-devices-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned all the templates. Returns a `OtpDeviceSummaryResponse`. + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: OtpDeviceSummaryResponse + + interface OtpDeviceSummaryResponse { + + // Array of devices that are present in our backend. + otp_devices: OtpDeviceEntry[]; + } + + .. ts:def:: OtpDeviceEntry + + interface OtpDeviceEntry { + + // Device identifier. + otp_device_id: string; + + // Human-readable description for the device. + device_description: string; + } diff --git a/core/merchant/get-private-pos.rst b/core/merchant/get-private-pos.rst @@ -0,0 +1,101 @@ +.. http:get:: [/instances/$INSTANCE]/private/pos + + This is used to return the point-of-sale (POS) configuration with full details on all items in the inventory. + + Endpoint was introduced in protocol **v15**. + + **Required permission:** ``products-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the inventory. Returns + a `FullInventoryDetailsResponse`. + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: FullInventoryDetailsResponse + + interface FullInventoryDetailsResponse { + + // List of products that are present in the inventory. + products: MerchantPosProductDetail[]; + + // List of categories in the inventory. + categories: MerchantCategory[]; + + } + + .. ts:def:: MerchantPosProductDetail + + interface MerchantPosProductDetail { + + // A unique numeric ID of the product + product_serial: Integer; + + // A merchant-internal unique identifier for the product. + product_id: string; + + // Human-readable product name. + // Since API version **v20**. + product_name: string; + + // A list of category IDs this product belongs to. + // Typically, a product only belongs to one category, but more than one is supported. + categories: Integer[]; + + // Human-readable product description. + description: string; + + // Map from IETF BCP 47 language tags to localized descriptions. + description_i18n: { [lang_tag: string]: string }; + + // Unit in which the product is measured (liters, kilograms, packages, etc.). + unit: string; + + // Does the backend allow fractional quantities for this unit? + unit_allow_fraction: boolean; + + // Maximum fractional precision (0-6) enforced for inventory operations. + unit_precision_level: Integer; + + // Price tiers for this product. The first entry represents the base price and MUST include + // applicable taxes. Zero implies the product is not sold separately or that the price is not + // fixed, and must be supplied by the front-end. + unit_price: Amount[]; + + // Legacy price field kept for compatibility. Deprecated; equal to the first element of ``unit_price``. + price: Amount; + + // An optional base64-encoded product image. + image?: ImageDataUrl; + + // A list of taxes paid by the merchant for one unit of this product. + taxes?: Tax[]; + + // Legacy integer stock counter kept for compatibility. ``-1`` indicates unlimited stock. + total_stock?: Integer; + + // Stock expressed using "<integer>[.<fraction>]" syntax with up to six fractional digits. + // Use ``"-1"`` for unlimited stock. + unit_total_stock: string; + + // Minimum age buyer must have (in years). + minimum_age?: Integer; + + } + + .. ts:def:: MerchantCategory + + interface MerchantCategory { + // A unique numeric ID of the category + id: Integer; + + // The name of the category. This will be shown to users and used in the order summary. + name: string; + + // Map from IETF BCP 47 language tags to localized names + name_i18n?: { [lang_tag: string]: string }; + } diff --git a/core/merchant/get-private-pots-POT_SERIAL.rst b/core/merchant/get-private-pots-POT_SERIAL.rst @@ -0,0 +1,31 @@ +.. http:get:: [/instances/$INSTANCES]/private/pots/$POT_SERIAL + + This is used to obtain detailed information about specific pot. + + **Required permission:** ``pots-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the detailed information about a specific pot. Returns a `PotDetailResponse`. + + :http:statuscode:`404 Not found`: + The pot or instance is unknown to the backend. + + **Details:** + + .. ts:def:: PotDetailResponse + + interface PotDetailResponse { + + // Description of the pot. Possibly included + // in the pot message. + description: string; + + // Name of the pot. Must be unique per instance. + pot_name: string; + + // Current total amount in the pot. + pot_totals: Amount[]; + + } diff --git a/core/merchant/get-private-pots.rst b/core/merchant/get-private-pots.rst @@ -0,0 +1,51 @@ +.. http:get:: [/instances/$INSTANCES]/private/pots + + This is used to return all the pots + that are present in our backend. + + **Required permission:** ``pots-read`` + + **Request:** + + :query limit: *Optional.* + At most return the given number of results. Negative for descending by ``serial``, positive for ascending by ``serial``. Defaults to ``-20``. + :query offset: *Optional.* + Starting ``serial`` for :ref:`pagination <row-id-pagination>`. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned all the pots. + Returns a `PotsSummaryResponse`. + + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: PotsSummaryResponse + + interface PotsSummaryResponse { + + // Return pots that are present in our backend. + pots: PotEntry[]; + + } + + The `PotEntry` object describes a pot. + It has the following structure: + + .. ts:def:: PotEntry + + interface PotEntry { + + // Pot identifier + pot_serial: Integer; + + // Name of the pot. Must be unique per instance. + pot_name: string; + + // Current total amounts in the pot. + pot_totals: Amount[]; + + } diff --git a/core/merchant/get-private-products-PRODUCT_ID.rst b/core/merchant/get-private-products-PRODUCT_ID.rst @@ -0,0 +1,99 @@ +.. http:get:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID + + This is used to obtain detailed information about a product in the inventory. + + **Required permission:** ``products-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the inventory. Returns + a `ProductDetailResponse`. + :http:statuscode:`404 Not found`: + The product (ID) is unknown to the backend. + + **Details:** + + .. ts:def:: ProductDetailResponse + + interface ProductDetailResponse { + + // Human-readable product name. + // Since API version **v20**. + product_name: string; + + // Human-readable product description. + description: string; + + // Map from IETF BCP 47 language tags to localized descriptions. + description_i18n: { [lang_tag: string]: string }; + + // Unit in which the product is measured (liters, kilograms, packages, etc.). + unit: string; + + // Does the backend allow fractional quantities for this unit? + unit_allow_fraction: boolean; + + // Maximum fractional precision (0-6) enforced for inventory operations. + unit_precision_level: Integer; + + // Categories into which the product belongs. + // Since API version **v16**. + categories: Integer[]; + + // Price tiers for this product. The first entry represents the base price and MUST include + // applicable taxes. Zero implies the product is not sold separately or that the price is not + // fixed, and must be supplied by the front-end. + unit_price: Amount[]; + + // Legacy price field kept for compatibility. + // Deprecated since **v25**; + // equal to the first element of ``unit_price``. + price: Amount; + + // An optional base64-encoded product image. + image: ImageDataUrl; + + // A list of taxes paid by the merchant for one unit of this product. + // Optional since **v15**. + taxes?: Tax[]; + + // True if the price(s) given are a net prices, false if they are + // gross prices. + // Since protocol **vTAXES**. + price_is_net: boolean; + + // Legacy integer stock counter kept for compatibility. ``-1`` indicates unlimited stock. + total_stock: Integer; + + // Stock expressed using "<integer>[.<fraction>]" syntax with up to six fractional digits. + // Use ``"-1"`` for unlimited stock. + unit_total_stock: DecimalQuantity; + + // Number of units of the product that have already been sold. + total_sold: Integer; + + // Number of units of the product that were lost (spoiled, stolen, etc.). + total_lost: Integer; + + // Identifies where the product is in stock. + // Optional since **v15**. + address?: Location; + + // Identifies when we expect the next restocking to happen. + next_restock?: Timestamp; + + // Minimum age buyer must have (in years). + minimum_age?: Integer; + + // Product group the product belongs to. Missing means default. + // Since **v25**. + product_group_id?: Integer; + + // Money pot revenue on the product should be accounted in. + // Missing means no money pot (revenue accounted + // in money pot of the overall order or not at all). + // Since **v25**. + money_pot_id?: Integer; + + } diff --git a/core/merchant/get-private-products.rst b/core/merchant/get-private-products.rst @@ -0,0 +1,44 @@ +.. http:get:: [/instances/$INSTANCE]/private/products + + This is used to return the list of all items in the inventory. + + **Required permission:** ``products-read`` + + **Request:** + + :query limit: *Optional*. At most return the given number of results. Negative for descending by row ID, positive for ascending by row ID. Default is ``20``. Since protocol **v12**. + :query offset: *Optional*. Starting ``product_serial_id`` for an iteration. Since protocol **v12**. + :query category_filter: *Optional*. Only returns products that are in a category where the category name contains the given text as a substring. Matching is case-insensitive. Since protocol **v23**. + :query name_filter: *Optional*. Only returns products where the product name contains the given text as a substring. Matching is case-insensitive. Since protocol **v23**. + :query description_filter: *Optional*. Only returns products where the product description contains the given text as a substring. Matching is case-insensitive. Since protocol **v23**. + :query product_group_serial: *Optional*. Only returns products where the product group serial matches the given value. Since protocol **v25**. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the inventory. Returns + a `InventorySummaryResponse`. + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: InventorySummaryResponse + + interface InventorySummaryResponse { + // List of products that are present in the inventory. + products: InventoryEntry[]; + } + + The `InventoryEntry` object describes an item in the inventory. It has the following structure: + + .. ts:def:: InventoryEntry + + interface InventoryEntry { + // Product identifier, as found in the product. + product_id: string; + + // ``product_serial_id`` of the product in the database. + product_serial: Integer; + + } diff --git a/core/merchant/get-private-reports-REPORT_SERIAL.rst b/core/merchant/get-private-reports-REPORT_SERIAL.rst @@ -0,0 +1,57 @@ +.. http:get:: [/instances/$INSTANCES]/private/reports/$REPORT_SERIAL + + This is used to obtain detailed information about a specific + scheduled report. + + **Required permission:** ``reports-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the detailed information about a specific report. Returns a `ReportDetailResponse`. + + :http:statuscode:`404 Not found`: + The report or instance is unknown to the backend. + + **Details:** + + .. ts:def:: ReportDetailResponse + + interface ReportDetailResponse { + + // Report identifier + report_serial: Integer; + + // Description of the report. Possibly included + // in the report message. + description: string; + + // Merchant backend configuration section specifying + // the program to use to transmit the report + program_section: string; + + // Mime-type to request from the data source. + mime_type: string; + + // Base URL to request the data from. + data_source: string; + + // Address where the report program should send + // the report. + target_address: string; + + // Report frequency + report_frequency: RelativeTime; + + // Report frequency shift + report_frequency_shift: RelativeTime; + + // Numeric `error code <error-codes>` unique to the + // error encountered in generating the latest report. + // Absent if there was no error. + last_error_code?: Integer; + + // Details about any error encountered + // in generating the latest report. + last_error_detail?: string; + } diff --git a/core/merchant/get-private-reports.rst b/core/merchant/get-private-reports.rst @@ -0,0 +1,51 @@ +.. http:get:: [/instances/$INSTANCES]/private/reports + + This is used to return all the scheduled reports + that are present in our backend. + + **Required permission:** ``reports-read`` + + **Request:** + + :query limit: *Optional.* + At most return the given number of results. Negative for descending by ``serial``, positive for ascending by ``serial``. Defaults to ``-20``. + :query offset: *Optional.* + Starting ``serial`` for :ref:`pagination <row-id-pagination>`. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned all the reports. + Returns a `ReportsSummaryResponse`. + + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: ReportsSummaryResponse + + interface ReportsSummaryResponse { + + // Return reports that are present in our backend. + reports: ReportEntry[]; + + } + + The `ReportEntry` object describes a report. + It has the following structure: + + .. ts:def:: ReportEntry + + interface ReportEntry { + + // Report identifier + report_serial: Integer; + + // Description for the report. + description: string; + + // Frequency for the report. + report_frequency: RelativeTime; + + } diff --git a/core/merchant/get-private-templates-TEMPLATE_ID.rst b/core/merchant/get-private-templates-TEMPLATE_ID.rst @@ -0,0 +1,49 @@ +.. http:get:: [/instances/$INSTANCE]/private/templates/$TEMPLATE_ID + + This is used to obtain detailed information about a specific template. + + + **Required permission:** ``templates-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the detailed information about a specific template. + Returns a `TemplateDetails`. + :http:statuscode:`404 Not found`: + The instance or template(ID) is unknown to the backend. + + **Details:** + + + .. ts:def:: TemplateDetails + + interface TemplateDetails { + + // Human-readable description for the template. + template_description: string; + + // OTP device ID. + // This parameter is optional. + otp_id?: string; + + // Additional information in a separate template. + template_contract: TemplateContractDetails; + + // Key-value pairs matching a subset of the + // fields from ``template_contract`` that are + // user-editable defaults for this template. + // Since protocol **v13**. + editable_defaults?: Object; + + // Required currency for payments. Useful if no + // amount is specified in the ``template_contract`` + // but the user should be required to pay in a + // particular currency anyway. Merchant backends + // may reject requests if the ``template_contract`` + // or ``editable_defaults`` do + // specify an amount in a different currency. + // This parameter is optional. + // Since protocol **v13**. + required_currency?: string; + } diff --git a/core/merchant/get-private-templates.rst b/core/merchant/get-private-templates.rst @@ -0,0 +1,37 @@ +.. http:get:: [/instances/$INSTANCE]/private/templates + + This is used to return the list of all the templates. + + + **Required permission:** ``templates-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned all the templates. Returns a `TemplateSummaryResponse`. + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: TemplateSummaryResponse + + interface TemplateSummaryResponse { + + // List of templates that are present in our backend. + templates: TemplateEntry[]; + } + + The `TemplateEntry` object describes a template. It has the following structure: + + .. ts:def:: TemplateEntry + + interface TemplateEntry { + + // Template identifier, as found in the template. + template_id: string; + + // Human-readable description for the template. + template_description: string; + + } diff --git a/core/merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst b/core/merchant/get-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst @@ -0,0 +1,73 @@ +.. http:get:: [/instances/$INSTANCES]/private/tokenfamilies/$TOKEN_FAMILY_SLUG + + This is used to get detailed information about a specific token family. + + **Required permission:** ``tokenfamilies-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The merchant backend has successfully returned the detailed information + about a specific token family. Returns a `TokenFamilyDetails`. + + :http:statuscode:`404 Not found`: + The merchant backend is unaware of the token family or instance. + + **Details:** + + The `TokenFamilyDetails` object describes a configured token family. + + .. ts:def:: TokenFamilyDetails + + interface TokenFamilyDetails { + + // Identifier for the token family consisting of unreserved characters + // according to RFC 3986. + slug: string; + + // Human-readable name for the token family. + name: string; + + // Human-readable description for the token family. + description: string; + + // Optional map from IETF BCP 47 language tags to localized descriptions. + description_i18n?: { [lang_tag: string]: string }; + + // Additional meta data, such as the ``trusted_domains`` + // or ``expected_domains``. Depends on the ``kind``. + extra_data?: object; + + // Start time of the token family's validity period. + // No token validities can start before this time + // (but they could be sold before). + valid_after: Timestamp; + + // End time of the token family's validity period. + // No tokens will be accepted after this time. + valid_before: Timestamp; + + // Validity duration of an issued token. + duration: RelativeTime; + + // Rounding granularity for the start validity of keys. + // The desired time is rounded down to a multiple of this + // granularity and then the ``start_offset`` is added to + // compute the actual start time of the token keys' validity. + // The end is then computed by adding the ``duration``. + validity_granularity: RelativeTime; + + // Offset in seconds to subtract from the start time rounded to ``validity_granularity`` + // to compute the actual start time for a key. + start_offset: RelativeTime; + + // Kind of the token family. + kind: TokenFamilyKind; + + // How many tokens have been issued for this family. + issued: Integer; + + // How many tokens have been used for this family. + used: Integer; + + } diff --git a/core/merchant/get-private-tokenfamilies.rst b/core/merchant/get-private-tokenfamilies.rst @@ -0,0 +1,55 @@ +.. http:get:: [/instances/$INSTANCES]/private/tokenfamilies + + This is used to list all configured token families for an instance. + + **Required permission:** ``tokenfamilies-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The merchant backend has successfully returned all token families. + Returns a `TokenFamiliesList`. + + :http:statuscode:`404 Not found`: + The merchant backend is unaware of the instance. + + **Details:** + + .. ts:def:: TokenFamiliesList + + // TODO: Add pagination + + interface TokenFamiliesList { + + // All configured token families of this instance. + token_families: TokenFamilySummary[]; + + } + + .. ts:def:: TokenFamilySummary + + interface TokenFamilySummary { + // Identifier for the token family consisting of unreserved characters + // according to RFC 3986. + slug: string; + + // Human-readable name for the token family. + name: string; + + // Human-readable description for the token family. + // @since protocol **v23**. + description: string; + + // Optional map from IETF BCP 47 language tags to localized descriptions. + // @since protocol **v23**. + description_i18n?: { [lang_tag: string]: string }; + + // Start time of the token family's validity period. + valid_after: Timestamp; + + // End time of the token family's validity period. + valid_before: Timestamp; + + // Kind of the token family. + kind: TokenFamilyKind; + } diff --git a/core/merchant/get-private-tokens.rst b/core/merchant/get-private-tokens.rst @@ -0,0 +1,58 @@ +.. http:get:: [/instances/$INSTANCE]/private/tokens + + Retrieve a list of issued access tokens for ``$INSTANCE``. + + @since **v19** + + **Required permission**: ``tokens-read`` + + **Request:** + + :query limit: *Optional.* + At most return the given number of results. Negative for descending by ``serial``, positive for ascending by ``serial``. Defaults to ``-20``. + :query offset: *Optional.* + Starting ``serial`` for :ref:`pagination <row-id-pagination>`. + + **Response:** + + :http:statuscode:`200 OK`: + Response is a `TokenInfos`. + :http:statuscode:`204 No content`: + No tokens. + :http:statuscode:`401 Unauthorized`: + Invalid or missing credentials. + :http:statuscode:`403 Forbidden`: + Missing rights. + + **Details:** + + .. ts:def:: TokenInfos + + interface TokenInfos { + tokens: TokenInfo[]; + } + + .. ts:def:: TokenInfo + + interface TokenInfo { + // Time when the token was created. + creation_time: Timestamp; + + // Time when the token expires. + expiration: Timestamp; + + // Scope for the token. + scope: "readonly" | "readwrite" | ...; + + // Is the token refreshable into a new token during its + // validity? + // Refreshable tokens effectively provide indefinite + // access if they are refreshed in time. + refreshable: boolean; + + // Optional token description + description?: string; + + // Opaque unique ID used for pagination. + serial: Integer; + } diff --git a/core/merchant/get-private-transfers.rst b/core/merchant/get-private-transfers.rst @@ -0,0 +1,78 @@ +.. http:get:: [/instances/$INSTANCE]/private/transfers + + Obtain a list of all wire transfers the backend was told + had been made into the merchant bank account. + Since protocol **v20** this endpoint is only about + actually confirmed wire transfers. + + **Required permission:** ``transfers-read`` + + **Request:** + + :query payto_uri: *Optional*. Full payto://-URI to filter for transfers to the given bank account (subject and amount MUST NOT be given in the payto:// URI). Note that the URI must be URL-encoded. + + :query before: *Optional*. Filter for transfers executed before the given timestamp. + + :query after: *Optional*. Filter for transfers executed after the given timestamp. + + :query limit: *Optional*. At most return the given number of results. Negative for descending in execution time, positive for ascending in execution time. Default is ``-20``. + + :query offset: *Optional*. Starting ``transfer_serial_id`` for an iteration. + + :query expected: *Optional*. Filter transfers that we expected to receive (YES: only expected, NO: only unexpected, ALL: default). Since protocol **v20**. + + + **Response:** + + :http:statuscode:`200 OK`: + The body of the response is a `TransferList`. + + **Details:** + + .. ts:def:: TransferList + + interface TransferList { + // List of all the transfers that fit the filter that we know. + transfers : TransferDetails[]; + } + + .. ts:def:: TransferDetails + + interface TransferDetails { + // How much was wired to the merchant (minus fees). + credit_amount: Amount; + + // Raw wire transfer identifier identifying the wire transfer (a base32-encoded value). + wtid: WireTransferIdentifierRawP; + + // Full payto://-URI of the bank account that received the wire transfer. + payto_uri: string; + + // Base URL of the exchange that made the wire transfer. + exchange_url: string; + + // Serial number identifying the transfer in the merchant backend. + // Used for filtering via ``offset``. + transfer_serial_id: Integer; + + // Time of the execution of the wire transfer. + // Missing if unknown in protocol **v25**. + execution_time?: Timestamp; + + // True if we checked the exchange's answer and are happy with it. + // False if we have an answer and are unhappy, missing if we + // do not have an answer from the exchange. + // Removed in protocol **v20**. + verified?: boolean; + + // True if the merchant uses the POST /transfers API to confirm + // that this wire transfer took place (and it is thus not + // something merely claimed by the exchange). + // Removed in protocol **v20**. + confirmed?: boolean; + + // True if this wire transfer was expected. + // (a matching "/private/incoming" record exists). + // Since protocol **v20**. + expected?: boolean; + } diff --git a/core/merchant/get-private-units-UNIT.rst b/core/merchant/get-private-units-UNIT.rst @@ -0,0 +1,12 @@ +.. http:get:: [/instances/$INSTANCE]/private/units/$UNIT + + Fetch details for a single measurement unit. + + **Required permission:** ``units-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend returned the unit definition. The body is a `MerchantUnit`. + :http:statuscode:`404 Not found`: + The unit is unknown to the backend. diff --git a/core/merchant/get-private-units.rst b/core/merchant/get-private-units.rst @@ -0,0 +1,52 @@ +.. http:get:: [/instances/$INSTANCE]/private/units + + Returns the list of measurement units available to an instance. + + **Required permission:** ``units-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend returned the unit catalog. The body is a `UnitListResponse`. + + **Details:** + + .. ts:def:: UnitListResponse + + interface UnitListResponse { + units: MerchantUnit[]; + } + + .. ts:def:: MerchantUnit + + interface MerchantUnit { + // Unique serial for the unit. + unit_serial: Integer; + + // Short identifier used in product definitions. + unit: string; + + // Human-readable long label. + unit_name_long: string; + + // Human-readable short label. + unit_name_short: string; + + // Optional translations for the long label. + unit_name_long_i18n?: { [lang_tag: string]: string }; + + // Optional translations for the short label. + unit_name_short_i18n?: { [lang_tag: string]: string }; + + // Whether fractional quantities are allowed for this unit. + unit_allow_fraction: boolean; + + // Maximum fractional precision (0-6) enforced for this unit. + unit_precision_level: Integer; + + // Whether the unit is currently active. + unit_active: boolean; + + // True if the unit is provided by the backend and cannot be removed. + unit_builtin: boolean; + } diff --git a/core/merchant/get-private-webhooks-WEBHOOK_ID.rst b/core/merchant/get-private-webhooks-WEBHOOK_ID.rst @@ -0,0 +1,36 @@ +.. http:get:: [/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID + + This is used to obtain detailed information about a specific webhook. + + **Required permission:** ``webhooks-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the detailed information about a specific webhook. Returns a `WebhookDetails`. + + :http:statuscode:`404 Not found`: + The webhook(ID) is unknown to the backend. + + **Details:** + + .. ts:def:: WebhookDetails + + interface WebhookDetails { + + // The event of the webhook: why the webhook is used. + event_type: WebhookEventType; + + // URL of the webhook where the customer will be redirected. + url: string; + + // Method used by the webhook + http_method: string; + + // Header template of the webhook + header_template?: string; + + // Body template by the webhook + body_template?: string; + + } diff --git a/core/merchant/get-private-webhooks.rst b/core/merchant/get-private-webhooks.rst @@ -0,0 +1,38 @@ +.. http:get:: [/instances/$INSTANCES]/private/webhooks + + This is used to return all the webhooks that are present in our backend. + + **Required permission:** ``webhooks-read`` + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned all the webhooks. Returns a `WebhookSummaryResponse`. + + :http:statuscode:`404 Not found`: + The backend has does not know about the instance. + + **Details:** + + .. ts:def:: WebhookSummaryResponse + + interface WebhookSummaryResponse { + + // Return webhooks that are present in our backend. + webhooks: WebhookEntry[]; + + } + + The `WebhookEntry` object describes a webhook. It has the following structure: + + .. ts:def:: WebhookEntry + + interface WebhookEntry { + + // Webhook identifier, as found in the webhook. + webhook_id: string; + + // The event of the webhook: why the webhook is used. + event_type: WebhookEventType; + + } diff --git a/core/merchant/get-products-IMAGE_HASH-image.rst b/core/merchant/get-products-IMAGE_HASH-image.rst @@ -0,0 +1,23 @@ +.. http:get:: /products/$IMAGE_HASH/image + + Returns a stored product image by its content hash. The hash is the lowercase + hexadecimal SHA-256 digest of the base64-encoded image data supplied in + ``image`` during product creation or update. + + **Required permission:** none (public endpoint) + + **Response:** + + :http:statuscode:`200 OK`: + The body is a `ProductImageResponse`. + :http:statuscode:`400 Bad Request`: + The hash is not a valid hex-encoded SHA-256 digest. + :http:statuscode:`404 Not found`: + No image is known for the given hash. + + .. ts:def:: ProductImageResponse + + interface ProductImageResponse { + // Data URL containing the product image as stored in the backend. + image: ImageDataUrl; + } diff --git a/core/merchant/get-sessions-SESSION_ID.rst b/core/merchant/get-sessions-SESSION_ID.rst @@ -0,0 +1,53 @@ +.. http:get:: [/instances/$INSTANCE]/sessions/$SESSION_ID?fulfillment_url=$URL + + Query the payment status for a session and fulfillment URL. + This endpoint is for Web shops, + Paivana and other integrations (like JavaScript from inside the customer's + browser) that need an unauthenticated way to query a payment status where + they do not know the order ID because they *only* know the session ID they + passed into the template mechanism. Here, the "$SESSION_ID" is an arbitrary + string, the semantics of which are left to the application. However, it must + match the "$SESSION_ID" passed to the template mechanism. + + Since protocol **v25**. + + **Request:** + + :query fulfillment_url=URL: *Mandatory.* Specifies the fulfillment URL + for which the order must be valid. + :query timeout_ms=NUMBER: *Optional.* If specified, the merchant backend will + wait up to ``timeout_ms`` milliseconds for completion of the payment before + sending the HTTP response. A client must never rely on this behavior, as the + merchant backend may return a response immediately. + + **Response:** + + :http:statuscode:`200 OK`: + The response is a `GetSessionStatusPaidResponse`. Returned if an + order that paid for the respective session exists and was paid. + :http:statuscode:`202 Accepted`: + The response is a `GetSessionStatusUnpaidResponse`. Returned if an + order that paid for the respective session exists, + but not yet paid. + :http:statuscode:`404 Not found`: + The merchant backend is unaware of an order matching the given session. + + **Details:** + + .. ts:def:: GetSessionStatusPaidResponse + + interface GetSessionStatusPaidResponse { + + // Order ID of the paid order. + order_id: String; + + } + + .. ts:def:: GetSessionStatusUnpaidResponse + + interface GetSessionStatusUnpaidResponse { + + // Order ID of the unpaid order. + order_id: String; + + } diff --git a/core/merchant/get-templates-TEMPLATE_ID.rst b/core/merchant/get-templates-TEMPLATE_ID.rst @@ -0,0 +1,170 @@ +.. http:get:: [/instances/$INSTANCE]/templates/$TEMPLATE_ID + + This is used to obtain information about a specific template by wallets + before they ask the user to fill in details. + This endpoint is available since protocol **v11**. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully returned the detailed information about a specific template. + Returns a `WalletTemplateDetailsRequest`. + :http:statuscode:`404 Not found`: + The instance or template(ID) is unknown to the backend. + + **Details:** + + For ``inventory-cart`` templates the backend augments the returned + ``template_contract`` with ``inventory_payload`` containing products, + categories, and units. The payload is filtered by the template's + ``selected_all``, ``selected_categories``, and ``selected_products`` settings. + + .. ts:def:: WalletTemplateDetailsRequest + + interface WalletTemplateDetailsRequest { + + // Type of the template being instantiated. + // Possible values include "fixed-order", + // "inventory-cart" and "paivana". + // Since protocol **v25**. + // Defaults to "fixed-order" while supporting previous + // protocol versions. + template_type: string; + + // Hard-coded information about the contract terms + // for this template. + template_contract: TemplateContractDetails; + + // Key-value pairs matching a subset of the + // fields from ``template_contract`` that are + // user-editable defaults for this template. + // Since protocol **v13**. + editable_defaults?: Object; + + // Required currency for payments. Useful if no + // amount is specified in the ``template_contract`` + // but the user should be required to pay in a + // particular currency anyway. Merchant backends + // may reject requests if the ``template_contract`` + // or ``editable_defaults`` do + // specify an amount in a different currency. + // This parameter is optional. + // Since protocol **v13**. + required_currency?: string; + } + + .. ts:def:: InventoryPayload + + interface InventoryPayload { + // Inventory products available for selection. + // Since protocol **v25**. + products: InventoryPayloadProduct[]; + + // Categories referenced by the payload products. + // Since protocol **v25**. + categories: InventoryPayloadCategory[]; + + // Custom units referenced by the payload products. + // Since protocol **v25**. + units: InventoryPayloadUnit[]; + } + + .. ts:def:: InventoryPayloadProduct + + interface InventoryPayloadProduct { + // Product identifier. + // Since protocol **v25**. + product_id: string; + + // Human-readable product name. + // Since protocol **v25**. + product_name: string; + + // Human-readable product description. + // Since protocol **v25**. + description: string; + + // Localized product descriptions. + // Since protocol **v25**. + description_i18n?: { [lang_tag: string]: string }; + + // Unit identifier for the product. + // Since protocol **v25**. + unit: string; + + // Price tiers for the product. + // Since protocol **v25**. + unit_prices: Amount[]; + + // Whether fractional quantities are allowed for this unit. + // Since protocol **v25**. + unit_allow_fraction: boolean; + + // Maximum fractional precision (0-6) enforced for this unit. + // Since protocol **v25**. + unit_precision_level: Integer; + + // Remaining stock available for selection. + // Since protocol **v25**. + remaining_stock: DecimalQuantity; + + // Category identifiers associated with this product. + // Since protocol **v25**. + categories: Integer[]; + + // Taxes applied to the product. + // Since protocol **v25**. + taxes?: Tax[]; + + // Hash of the product image (if any). + // Since protocol **v25**. + image_hash?: string; + } + + .. ts:def:: InventoryPayloadCategory + + interface InventoryPayloadCategory { + // Category identifier. + // Since protocol **v25**. + category_id: Integer; + + // Human-readable category name. + // Since protocol **v25**. + category_name: string; + + // Localized category names. + // Since protocol **v25**. + category_name_i18n?: { [lang_tag: string]: string }; + } + + .. ts:def:: InventoryPayloadUnit + + interface InventoryPayloadUnit { + // Unit identifier. + // Since protocol **v25**. + unit: string; + + // Human-readable long label. + // Since protocol **v25**. + unit_name_long: string; + + // Localized long labels. + // Since protocol **v25**. + unit_name_long_i18n?: { [lang_tag: string]: string }; + + // Human-readable short label. + // Since protocol **v25**. + unit_name_short: string; + + // Localized short labels. + // Since protocol **v25**. + unit_name_short_i18n?: { [lang_tag: string]: string }; + + // Whether fractional quantities are allowed for this unit. + // Since protocol **v25**. + unit_allow_fraction: boolean; + + // Maximum fractional precision (0-6) enforced for this unit. + // Since protocol **v25**. + unit_precision_level: Integer; + } diff --git a/core/merchant/patch-management-instances-INSTANCE.rst b/core/merchant/patch-management-instances-INSTANCE.rst @@ -0,0 +1,86 @@ +.. http:patch:: /management/instances/$INSTANCE +.. http:patch:: [/instances/$INSTANCE]/private + + Update the configuration of a merchant instance. PATCH operations against + an instance are authenticated by checking that an authorization is provided + that matches either the credential required by the instance being modified + OR the ``admin`` instance, depending on the access path used. + + **Required permission:** ``instances-token-write`` + + **Request** + + The request must be a `InstanceReconfigurationMessage`. + Removing an existing ``payto_uri`` deactivates + the account (it will no longer be used for future contracts). + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully created the instance. + :http:statuscode:`404 Not found`: + This instance is unknown and thus cannot be reconfigured. + + **Details:** + + .. ts:def:: InstanceReconfigurationMessage + + interface InstanceReconfigurationMessage { + + // Merchant name corresponding to this instance. + name: string; + + // Merchant email for customer contact and password reset. + email?: string; + + // Merchant phone number for password reset (2-FA) + // @since **v21**. + phone_number?: string; + + // Merchant public website. + website?: string; + + // Merchant logo. + logo?: ImageDataUrl; + + // The merchant's physical address (to be put into contracts). + address: Location; + + // The jurisdiction under which the merchant conducts its business + // (to be put into contracts). + jurisdiction: Location; + + // Use STEFAN curves to determine default fees? + // If false, no fees are allowed by default. + // Can always be overridden by the frontend on a per-order basis. + use_stefan: boolean; + + // If the frontend does NOT specify a payment deadline, how long should + // offers we make be valid by default? + // A value of "forever" is not allowed. + // Optional @since **v22** (before the setting was mandatory). + // If not provided, the previous setting will now simply be preserved. + default_pay_delay?: RelativeTime; + + // If the frontend does NOT specify a refund deadline, how long should + // refunds be allowed by default? Added on top of the payment deadline. + // A value of "forever" is not allowed. + // @since **v22** + default_refund_delay?: RelativeTime; + + // If the frontend does NOT specify an execution date, how long should + // we tell the exchange to wait to aggregate transactions before + // executing the wire transfer? This delay is added on top of + // the refund deadline and afterwards subject to rounding + // via the ``default_wire_transfer_rounding_interval``. + // A value of "forever" is not allowed. + // Optional @since **v22** (before the setting was mandatory). + // If not provided, the previous setting will now simply be preserved. + default_wire_transfer_delay?: RelativeTime; + + // How far should the wire deadline (if computed with the help of + // the ``default_wire_transfer_delay``) be rounded up to compute + // the ultimate wire deadline? + // @since **v22**, defaults to no rounding if not given. + default_wire_transfer_rounding_interval?: RoundingInterval; + } diff --git a/core/merchant/patch-private-accounts-H_WIRE.rst b/core/merchant/patch-private-accounts-H_WIRE.rst @@ -0,0 +1,36 @@ +.. http:patch:: [/instances/$INSTANCE]/private/accounts/$H_WIRE + + This is used to update a bank account. + + **Required permission:** ``accounts-write`` + + **Request:** + + The request must be a `AccountPatchDetails`. + + **Response:** + + :http:statuscode:`204 No content`: + The account has successfully modified. + :http:statuscode:`404 Not found`: + The account (``H_WIRE``) is unknown to the backend. + + **Details:** + + .. ts:def:: AccountPatchDetails + + interface AccountPatchDetails { + + // URL from where the merchant can download information + // about incoming wire transfers to this account. + credit_facade_url?: string; + + // Credentials to use when accessing the credit facade. + // Never returned on a GET (as this may be somewhat + // sensitive data). Can be set in POST + // or PATCH requests to update (or delete) credentials. + // To really delete credentials, set them to the type: "none". + // If the argument is omitted, the old credentials + // are simply preserved. + credit_facade_credentials?: FacadeCredentials; + } diff --git a/core/merchant/patch-private-categories-CATEGORY_ID.rst b/core/merchant/patch-private-categories-CATEGORY_ID.rst @@ -0,0 +1,15 @@ +.. http:patch:: [/instances/$INSTANCE]/private/categories/$CATEGORY_ID + + This is used to edit a category. + Since API version **v16**. + + **Required permission:** ``categories-write`` + + **Request:** + + The request is a `CategoryCreateRequest`. + + **Response:** + + :http:statuscode:`204 No Content`: + The category was modified successfully. diff --git a/core/merchant/patch-private-groups-GROUP_ID.rst b/core/merchant/patch-private-groups-GROUP_ID.rst @@ -0,0 +1,18 @@ +.. http:patch:: [/instances/$INSTANCES]/private/groups/$GROUP_ID + + This is used to update a group. + + **Required permission:** ``groups-write`` + + **Request:** + + The request body must be a `GroupAddRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The group has successfully modified. + :http:statuscode:`404 Not found`: + The group or instance is unknown to the backend. + :http:statuscode:`409 Conflict`: + The specified group name is already in use. diff --git a/core/merchant/patch-private-orders-ORDER_ID-forget.rst b/core/merchant/patch-private-orders-ORDER_ID-forget.rst @@ -0,0 +1,52 @@ +.. http:patch:: [/instances/$INSTANCE]/private/orders/$ORDER_ID/forget + + Forget fields in an order's contract terms that the merchant no + longer needs. + + **Required permission:** ``orders-write`` + + **Request:** + + The request must be a `forget request <ForgetRequest>`. The fields specified + must have been marked as forgettable when the contract was created. Fields in + the request that are not in the `contract terms <ContractTerms>` are ignored. + + A valid + JSON path is defined as a string beginning with ``$.`` that follows the dot + notation: ``$.wire_fee``, for example. The ``$`` represents the `contract terms <ContractTerms>` + object, and an identifier following a ``.`` represents the field of that + identifier belonging to the object preceding the dot. Arrays can be indexed + by an non-negative integer within brackets: ``$.products[1]``. An asterisk ``*`` + can be used to index an array as a wildcard, which expands the path into a + list of paths containing one path for + each valid array index: ``$.products[*].description``. For a path to be valid, + it must end with a reference to a field of an object (it cannot end with an + array index or wildcard). + + **Response:** + + :http:statuscode:`200 OK`: + The merchant deleted the specified fields from the contract of + order $ORDER_ID. + :http:statuscode:`204 No content`: + The merchant had already deleted the specified fields + from the contract of order $ORDER_ID. + :http:statuscode:`400 Bad request`: + The request is malformed or one of the paths is invalid. + :http:statuscode:`404 Not found`: + The merchant backend could not find the order or the instance + and thus cannot process the forget request. + :http:statuscode:`409 Conflict`: + The request includes a field that was not marked as forgettable, so + the merchant cannot delete that field. + + **Details:** + + .. ts:def:: ForgetRequest + + interface ForgetRequest { + + // Array of valid JSON paths to forgettable fields in the order's + // contract terms. + fields: string[]; + } diff --git a/core/merchant/patch-private-otp-devices-DEVICE_ID.rst b/core/merchant/patch-private-otp-devices-DEVICE_ID.rst @@ -0,0 +1,42 @@ +.. http:patch:: [/instances/$INSTANCE]/private/otp-devices/$DEVICE_ID + + This is used to update an OTP device. It is useful when we need to change information in the OTP device or when we have mistake some information. + + **Required permission:** ``otp-devices-write`` + + **Request:** + + The request must be a `OtpDevicePatchDetails`. + + **Response:** + + :http:statuscode:`204 No content`: + The template has successfully modified. + :http:statuscode:`404 Not found`: + The template(ID) is unknown to the backend. + :http:statuscode:`409 Conflict`: + The provided information is inconsistent with the current state of the template. Changes made is the same with + another store. + + **Details:** + + .. ts:def:: OtpDevicePatchDetails + + interface OtpDevicePatchDetails { + + // Human-readable description for the device. + otp_device_description: string; + + // A key encoded with RFC 3548 Base32. + // IMPORTANT: This is not using the typical + // Taler base32-crockford encoding. + // Instead it uses the RFC 3548 encoding to + // be compatible with the TOTP standard. + otp_key?: string; + + // Algorithm for computing the POS confirmation. + otp_algorithm: Integer; + + // Counter for counter-based OTP devices. + otp_ctr?: Integer; + } diff --git a/core/merchant/patch-private-pots-POT_ID.rst b/core/merchant/patch-private-pots-POT_ID.rst @@ -0,0 +1,47 @@ +.. http:patch:: [/instances/$INSTANCES]/private/pots/$POT_ID + + This is used to update a pot. + + **Required permission:** ``pots-write`` + + **Request:** + + The request body must be a `PotModifyRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The pot has successfully modified. + :http:statuscode:`404 Not found`: + The pot or instance is unknown to the backend. + :http:statuscode:`409 Conflict`: + The pot total did not match the expected total + and thus resetting the pot failed. + + **Details:** + + .. ts:def:: PotModifyRequest + + interface PotModifyRequest { + + // Description of the pot. Possibly included + // in the pot message. + description: string; + + // Name of the pot. Must be unique per instance. + pot_name: string; + + // Expected current totals amount in the pot. + // Should be given if ``new_pot_total`` is specified + // as this allows checking that the pot total did + // not change in the meantime. However, this is + // not enforced server-side, the client may choose + // to not use this safety-measure. + expected_pot_totals?: Amount[]; + + // Expected new total amounts to store in the pot. + // Does **not** have to be in the same currencies as + // the existing amounts in the pot. Used to reset + // the pot and/or change the amounts. + new_pot_totals?: Amount[]; + } diff --git a/core/merchant/patch-private-products-PRODUCT_ID.rst b/core/merchant/patch-private-products-PRODUCT_ID.rst @@ -0,0 +1,127 @@ +.. http:patch:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID + + This is used to update product details in the inventory. Note that the + ``total_stock`` and ``total_lost`` numbers MUST be greater or equal than + previous values (this design ensures idempotency). In case stocks were lost + but not sold, increment the ``total_lost`` number. All fields in the + request are optional, those that are not given are simply preserved (not + modified). Note that the ``description_i18n`` and ``taxes`` can only be + modified in bulk: if it is given, all translations must be provided, not + only those that changed. ``never`` should be used for the ``next_restock`` + timestamp to indicate no intention/possibility of restocking, while a time + of zero is used to indicate "unknown". + + **Required permission:** ``products-write`` + + **Request:** + + The request must be a `ProductPatchDetailRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully expanded the inventory. + :http:statuscode:`404 Not found`: + The instance, product, category, product group or money pot specified are + unknown. Possible error ``code`` values are thus: + ``TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN`` (instance unknown), + ``TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN`` (product unknown), + ``TALER_EC_MERCHANT_GENERIC_PRODUCT_GROUP_UNKNOWN`` (product group unknown) + ``TALER_EC_MERCHANT_GENERIC_MONEY_POT_UNKNOWN`` (money pot unknown), + ``TALER_EC_MERCHANT_GENERIC_CATEGORY_UNKNOWN`` + (category unknown, specific category is given in the details). + :http:statuscode:`409 Conflict`: + The provided information is inconsistent with the current state of + the inventory. + + + .. ts:def:: ProductPatchDetailRequest + + interface ProductPatchDetailRequest { + + // Human-readable product name. + // Since API version **v20**. Optional only for + // backwards-compatibility, should be considered mandatory + // moving forward! + product_name?: string; + + // Human-readable product description. + description: string; + + // Map from IETF BCP 47 language tags to localized descriptions. + description_i18n?: { [lang_tag: string]: string }; + + // Unit in which the product is measured (liters, kilograms, packages, etc.). + unit: string; + + // Optional override to control whether fractional quantities are permitted. + unit_allow_fraction?: boolean; + + // Override for the fractional precision level (0-6). Only relevant if + // ``unit_allow_fraction`` is true. + unit_precision_level?: Integer; + + // Categories into which the product belongs. + // Used in the POS-endpoint. + // Since API version **v16**. + categories?: Integer[]; + + // Preferred way to express the per-unit price. Supply at least one entry; + // the first entry represents the base price and MUST include applicable taxes. + // Zero implies that the product is not sold separately or that the price must be supplied + // by the frontend. + // Each entry must use a distinct currency. + // Since API version **v25**. + // Currency uniqueness enforced since protocol **v25**. + unit_price?: Amount[]; + + // Legacy price field. + // Deprecated since **v25**; + // when present it must match the first element of ``unit_price``. + price?: Amount; + + // True if the price(s) given are a net prices, false if they are + // gross prices. + // Since protocol **vTAXES**. + price_is_net?: boolean; + + // An optional base64-encoded product image. + image?: ImageDataUrl; + + // A list of taxes paid by the merchant for one unit of this product. + taxes?: Tax[]; + + // Preferred way to express inventory counts using "<integer>[.<fraction>]" syntax. + // Use "-1" for unlimited stock. + unit_total_stock?: DecimalQuantity; + + // Legacy stock counter. Deprecated, use ``unit_total_stock`` instead. + total_stock?: Integer; + + // Number of units of the product that were lost (spoiled, stolen, etc.). + total_lost?: Integer; + + // Identifies where the product is in stock. + address?: Location; + + // Identifies when we expect the next restocking to happen. + next_restock?: Timestamp; + + // Minimum age buyer must have (in years). Default is 0. + minimum_age?: Integer; + + // Product group the product belongs to. 0 and missing both + // means default. + // Since **v25**. + product_group_id?: Integer; + + // Money pot revenue on the product should be accounted in. + // 0 and missing both mean no money pot (revenue accounted + // in money pot of the overall order or not at all). + // Since **v25**. + money_pot_id?: Integer; + + } + + The same compatibility rules for the ``unit_*`` fields and their deprecated counterparts apply + when patching an existing product. diff --git a/core/merchant/patch-private-reports-REPORT_ID.rst b/core/merchant/patch-private-reports-REPORT_ID.rst @@ -0,0 +1,16 @@ +.. http:patch:: [/instances/$INSTANCES]/private/reports/$REPORT_ID + + This is used to update a scheduled report. + + **Required permission:** ``reports-write`` + + **Request:** + + The request body must be a `ReportAddRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The report has successfully modified. + :http:statuscode:`404 Not found`: + The report or instance is unknown to the backend. diff --git a/core/merchant/patch-private-templates-TEMPLATE_ID.rst b/core/merchant/patch-private-templates-TEMPLATE_ID.rst @@ -0,0 +1,43 @@ +.. http:patch:: [/instances/$INSTANCE]/private/templates/$TEMPLATE_ID + + This is used to update a template. It is useful when we need to change information in the template or when we have mistake some information. + + **Required permission:** ``templates-write`` + + **Request:** + + The request must be a `TemplatePatchDetails`. + + **Response:** + + :http:statuscode:`204 No content`: + The template has successfully modified. + :http:statuscode:`404 Not found`: + The template(ID) is unknown to the backend. + :http:statuscode:`409 Conflict`: + The provided information is inconsistent with the current state of the template. Changes made is the same with + another store. + + **Details:** + + + .. ts:def:: TemplatePatchDetails + + interface TemplatePatchDetails { + + // Human-readable description for the template. + template_description: string; + + // OTP device ID. + // This parameter is optional. + otp_id?: string; + + // Additional information in a separate template. + template_contract: TemplateContractDetails; + + // Key-value pairs matching a subset of the + // fields from ``template_contract`` that are + // user-editable defaults for this template. + // Since protocol **v13**. + editable_defaults?: Object; + } diff --git a/core/merchant/patch-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst b/core/merchant/patch-private-tokenfamilies-TOKEN_FAMILY_SLUG.rst @@ -0,0 +1,44 @@ +.. http:patch:: [/instances/$INSTANCES]/private/tokenfamilies/$TOKEN_FAMILY_SLUG + + This is used to update a token family. + + **Required permission:** ``tokenfamilies-write`` + + **Request:** + + The request must be a `TokenFamilyUpdateRequest`. + + **Response:** + + :http:statuscode:`204 No Content`: + The token family was successsful updated. + + :http:statuscode:`404 Not found`: + The merchant backend is unaware of the token family or instance. + + **Details:** + + .. ts:def:: TokenFamilyUpdateRequest + + interface TokenFamilyUpdateRequest { + + // Human-readable name for the token family. + name: string; + + // Human-readable description for the token family. + description: string; + + // Optional map from IETF BCP 47 language tags to localized descriptions. + description_i18n: { [lang_tag: string]: string }; + + // Additional meta data, such as the ``trusted_domains`` + // or ``expected_domains``. Depends on the ``kind``. + extra_data?: object; + + // Start time of the token family's validity period. + valid_after: Timestamp; + + // End time of the token family's validity period. + valid_before: Timestamp; + + } diff --git a/core/merchant/patch-private-units-UNIT.rst b/core/merchant/patch-private-units-UNIT.rst @@ -0,0 +1,47 @@ +.. http:patch:: [/instances/$INSTANCE]/private/units/$UNIT + + Update attributes of a measurement unit. + + **Required permission:** ``units-write`` + + **Request:** + + The request must be a `UnitPatchRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The backend updated the unit. + :http:statuscode:`404 Not found`: + The unit is unknown to the backend. + + Built-in units allow changing ``unit_allow_fraction``, ``unit_precision_level``, and + ``unit_active``; other fields are immutable for built-ins. + + .. ts:def:: UnitPatchRequest + + interface UnitPatchRequest { + // Updated human-readable long label. + unit_name_long?: string; + + // Updated human-readable short label. + unit_name_short?: string; + + // Updated translations for the long label keyed by BCP 47 language tags. + unit_name_long_i18n?: { [lang_tag: string]: string }; + + // Updated translations for the short label keyed by BCP 47 language tags. + unit_name_short_i18n?: { [lang_tag: string]: string }; + + // Override to allow or forbid fractional quantities. + unit_allow_fraction?: boolean; + + // Override for the fractional precision (0-6). Ignored if fractions are disabled. + unit_precision_level?: Integer; + + // Toggle whether the unit is active. + unit_active?: boolean; + } + + Fractional precision is capped at six decimal places. Disabling + ``unit_allow_fraction`` forces ``unit_precision_level`` to zero. diff --git a/core/merchant/patch-private-webhooks-WEBHOOK_ID.rst b/core/merchant/patch-private-webhooks-WEBHOOK_ID.rst @@ -0,0 +1,41 @@ +.. http:patch:: [/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID + + This is used to update a webhook. + + **Required permission:** ``webhooks-write`` + + **Request:** + + The request must be a `WebhookPatchDetails`. + + **Response:** + + :http:statuscode:`204 No content`: + The webhook has successfully modified. + :http:statuscode:`404 Not found`: + The webhook(ID) is unknown to the backend. + :http:statuscode:`409 Conflict`: + The provided information is inconsistent with the current state of the webhook. Changes made is the same with another store. + + **Details:** + + .. ts:def:: WebhookPatchDetails + + interface WebhookPatchDetails { + + // The event of the webhook: why the webhook is used. + event_type: WebhookEventType; + + // URL of the webhook where the customer will be redirected. + url: string; + + // Method used by the webhook + http_method: string; + + // Header template of the webhook + header_template?: string; + + // Body template by the webhook + body_template?: string; + + } diff --git a/core/merchant/post-challenge-CHALLENGE_ID-confirm.rst b/core/merchant/post-challenge-CHALLENGE_ID-confirm.rst @@ -0,0 +1,40 @@ +.. http:post:: [/instances/$INSTANCE]/challenge/$CHALLENGE_ID/confirm + + Solves the ``CHALLENGE_ID`` challenge and allows performing the protected operation. + + @since **v21** + + When the challenge is confirmed, you can call the protected endpoint again + with ``CHALLENGE_ID`` in the ``Taler-Challenge-Ids`` HTTP header and the + original request body. + + This endpoints is not authenticated for token creation challenges. Too many + unsuccessful attempts to confirm token creation challenges block the + account. + + This endpoint may be used even when mandatory TAN channels + were not validated yet. + + **Request:** + + .. ts:def:: MerchantChallengeSolveRequest + + interface MerchantChallengeSolveRequest { + + // The TAN code that solves $CHALLENGE_ID. + tan: string; + } + + **Response:** + + :http:statuscode:`204 No Content`: + The challenge was solved. + :http:statuscode:`404 Not Found`: + The challenge was not found. + Returned with ``TALER_EC_MERCHANT_TAN_CHALLENGE_UNKNOWN``. + :http:statuscode:`409 Conflict`: + Wrong TAN, returned with an + error code of ``TALER_EC_MERCHANT_TAN_CHALLENGE_FAILED``. + :http:statuscode:`429 Too many requests`: + Too many failed confirmation attempts, a new TAN must be requested. + Returned with ``TALER_EC_MERCHANT_TAN_TOO_MANY_ATTEMPTS``. diff --git a/core/merchant/post-challenge-CHALLENGE_ID.rst b/core/merchant/post-challenge-CHALLENGE_ID.rst @@ -0,0 +1,49 @@ +.. http:post:: [/instances/$INSTANCE]/challenge/$CHALLENGE_ID + + Send TAN code for the ``CHALLENGE_ID`` challenge. + + This request can be posted several times to trigger TAN retransmission when + the current code has expired or too many confirmation attempts have been + made. + + This endpoint is not authenticated, it may be used even when mandatory TAN + channels were not validated yet. + + @since **v21** + + **Request:** + + The request body must be a JSON object, but can otherwise be empty + (so just send '{}'). + + **Response:** + + :http:statuscode:`200 Ok`: + The TAN code has been sent. The body will be a `ChallengeRequestResponse`. + :http:statuscode:`404 Not Found`: + The challenge was not found. + Returned with ``TALER_EC_MERCHANT_TAN_CHALLENGE_UNKNOWN``. + :http:statuscode:`410 Gone`: + The challenge was already solved. + Returned with ``TALER_EC_MERCHANT_TAN_CHALLENGE_SOLVED``. + :http:statuscode:`429 Too many requests`: + Too many challenges are active right now, + you must wait or confirm current challenges. + Returned with ``TALER_EC_MERCHANT_TAN_TOO_EARLY``. + :http:statuscode:`502 Bad Gateway`: + TAN transmition via ``tan_channel`` failed. + Returned with ``TALER_EC_MERCHANT_MFA_HELPER_EXEC_FAILED``. + + **Details:** + + .. ts:def:: ChallengeRequestResponse + + interface ChallengeRequestResponse { + // How long does the client have to solve the + // challenge. + solve_expiration: Timestamp; + + // What is the earlist time at which the client + // may request a new challenge to be transmitted? + earliest_retransmission: Timestamp; + } diff --git a/core/merchant/post-instances-INSTANCE-forgot-password.rst b/core/merchant/post-instances-INSTANCE-forgot-password.rst @@ -0,0 +1,25 @@ +.. http:post:: /instances/$INSTANCE/forgot-password + + Same as ``/management/instances/$INSTANCE/private/auth`` it will update the password of the instance but + without requiring the current password. On the first call it will validate the request + and return the multi-factor authentication challenge IDs with + a ``202 Accepted`` response. Once the challenges are solved the + request needs to be repeated with the ``Taler-Challenge-Ids`` header. + + This endpoint is **not** available for the ``admin`` instance. + The administrator must use the command-line tool if they forgot + their password. + + Since protocol **v21**. + + **Request** the request must be an `InstanceAuthConfigurationMessage`. + + **Response:** + + :http:statuscode:`202 Accepted`: + 2FA is required for this operation. This returns + the `ChallengeResponse`. @since **v21** + :http:statuscode:`204 No content`: + The backend has successfully changed the credentials for the instance. + :http:statuscode:`404 Not found`: + This instance is unknown and thus cannot be reconfigured. diff --git a/core/merchant/post-instances.rst b/core/merchant/post-instances.rst @@ -0,0 +1,38 @@ +.. http:post:: /instances + + This request will be used to create a new merchant instance in the backend. + Since protocol **v21**. + + Only available if self-provisioning is enabled. + + **Required permission:** none + + **Request:** + + The request must be a `InstanceConfigurationMessage`. + + :query token_validity_ms=DURATION: *Optional*. + Pass a non-zero DURATION in milliseconds to get a + refreshable login token for the SPA with the + given validity duration in the response. @since **v21**. + + **Response:** + + :http:statuscode:`200 Ok`: + The backend has successfully created the instance. Body will + be an `LoginTokenSuccessResponse` with a refreshable + login token for the SPA as requested. @since **v21**. + :http:statuscode:`202 Accepted`: + 2FA is required for this operation, usually to validate the + email and/or phone numbers provided for the instance. + This returns the `ChallengeResponse`. @since **v21** + :http:statuscode:`204 No Content`: + The backend has successfully created the instance. No login + token was requested, so nothing is returned. + :http:statuscode:`409 Conflict`: + This instance already exists, but with other configuration options. + Use "PATCH" to update an instance configuration. Alternatively, + the currency provided in the configuration does not match the + currency supported by this backend. Another possible conflict + would be if a deleted but not purged instance is known under this + ID to the backend. diff --git a/core/merchant/post-management-instances-INSTANCE-auth.rst b/core/merchant/post-management-instances-INSTANCE-auth.rst @@ -0,0 +1,67 @@ +.. http:post:: /management/instances/$INSTANCE/auth +.. http:post:: [/instances/$INSTANCE]/private/auth + + Update the authentication settings for an instance. POST operations against + an instance are authenticated by checking that an authorization is provided + that matches either the credential required by the instance being modified + OR the ``admin`` instance, depending on the access path used. + + **Required permission:** ``instances-auth-write`` + + **Request** the request must be an `InstanceAuthConfigurationMessage`. + + **Response:** + + :http:statuscode:`202 Accepted`: + 2FA is required for this operation. This returns the `ChallengeResponse` response. @since **v21** + :http:statuscode:`204 No content`: + The backend has successfully changed the credentials for the instance. + :http:statuscode:`404 Not found`: + This instance is unknown and thus cannot be reconfigured. + + **Details:** + + .. ts:def:: InstanceAuthConfigurationMessage + + type InstanceAuthConfigurationMessage = InstanceAuthConfigToken | InstanceAuthConfigTokenOLD | InstanceAuthConfigExternal + + .. ts:def:: InstanceAuthConfigToken + + // @since **v19** + interface InstanceAuthConfigToken { + // The API is accessible through API tokens. + // Tokens are retrieved from the /private/token + // endpoint. + method: "token"; + + // Authentication against the /private/token endpoint + // is done using basic authentication with the configured password + // in the "password" field. Tokens are passed to other endpoints for + // authorization using RFC 8959 bearer tokens. + password: string; + + } + + .. ts:def:: InstanceAuthConfigTokenOLD + + // @deprecated since **v19** + interface InstanceAuthConfigTokenOLD { + // The API is accessible through API tokens. + // Tokens are retrieved from the /private/token + // endpoint. + method: "token"; + + // The value of this field MUST begin with the string "secret-token:". + token: string; + + } + + .. ts:def:: InstanceAuthConfigExternal + + // @deprecated since **v20** + interface InstanceAuthConfigExternal { + // The mechant backend does not do + // any authentication checks. Instead an API + // gateway must do the authentication. + method: "external"; + } diff --git a/core/merchant/post-management-instances.rst b/core/merchant/post-management-instances.rst @@ -0,0 +1,95 @@ +.. http:post:: /management/instances + + This request will be used to create a new merchant instance in the backend. + It is only available for the implicit ``admin`` instance. + + **Required permission:** ``instances-write`` + + **Request:** + + The request must be a `InstanceConfigurationMessage`. + + **Response:** + + :http:statuscode:`202 Accepted`: + 2FA is required for this operation, usually to validate the + email and/or phone numbers registered for the instance. + This returns the `ChallengeResponse`. @since **v21** + :http:statuscode:`204 No content`: + The backend has successfully created the instance. + :http:statuscode:`409 Conflict`: + This instance already exists, but with other configuration options. + Use "PATCH" to update an instance configuration. Alternatively, + the currency provided in the configuration does not match the + currency supported by this backend. Another possible conflict + would be if a deleted but not purged instance is known under this + ID to the backend. + + **Details:** + + .. ts:def:: InstanceConfigurationMessage + + interface InstanceConfigurationMessage { + + // Name of the merchant instance to create (will become $INSTANCE). + // Must match the regex ``^[A-Za-z0-9][A-Za-z0-9_.@-]+$``. + id: string; + + // Merchant name corresponding to this instance. + name: string; + + // Merchant email for customer contact and password reset. + email?: string; + + // Merchant phone number for password reset (2-FA) + // @since **v21**. + phone_number?: string; + + // Merchant public website. + website?: string; + + // Merchant logo. + logo?: ImageDataUrl; + + // Authentication settings for this instance + auth: InstanceAuthConfigurationMessage; + + // The merchant's physical address (to be put into contracts). + address: Location; + + // The jurisdiction under which the merchant conducts its business + // (to be put into contracts). + jurisdiction: Location; + + // Use STEFAN curves to determine default fees? + // If false, no fees are allowed by default. + // Can always be overridden by the frontend on a per-order basis. + use_stefan: boolean; + + // If the frontend does NOT specify a payment deadline, how long should + // offers we make be valid by default? + // Optional @since **v22** (before the setting was mandatory). + // If not provided, the global merchant default will be used. + default_pay_delay?: RelativeTime; + + // If the frontend does NOT specify a refund deadline, how long should + // refunds be allowed by default? Added on top of the + // payment deadline. + // @since **v22** + default_refund_delay?: RelativeTime; + + // If the frontend does NOT specify an execution date, how long should + // we tell the exchange to wait to aggregate transactions before + // executing the wire transfer? This delay is added on top of + // the refund deadline and afterwards subject to rounding + // via the ``default_wire_transfer_rounding_interval``. + // Optional @since **v22** (before the setting was mandatory). + // If not provided, the global merchant default will be used. + default_wire_transfer_delay?: RelativeTime; + + // How far should the wire deadline (if computed with the help of + // the ``default_wire_transfer_delay``) be rounded up to compute + // the ultimate wire deadline? + // @since **v22**, defaults to no rounding if not given. + default_wire_transfer_rounding_interval?: RoundingInterval; + } diff --git a/core/merchant/post-orders-ORDER_ID-abort.rst b/core/merchant/post-orders-ORDER_ID-abort.rst @@ -0,0 +1,148 @@ +.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/abort + + Abort paying for an order and obtain a refund for coins that + were already deposited as part of a failed payment. + + **Request:** + + The request must be an `abort request <AbortRequest>`. We force the wallet + to specify the affected coins as it may only request for a subset of the coins + (i.e. because the wallet knows that some were double-spent causing the failure). + Also we need to know the coins because there may be two wallets "competing" over + the same order and one wants to abort while the other still proceeds with the + payment. Here we need to again know which subset of the deposits to abort. + + **Response:** + + :http:statuscode:`200 OK`: + The merchant accepted the request, and passed it on to the exchange. The body is a + a `abort response <AbortResponse>`. Note that the exchange + MAY still have encountered errors in processing. Those will then be part of + the body. Wallets MUST carefully consider errors for each of the coins as + returned by the exchange. + :http:statuscode:`400 Bad request`: + Either the client request is malformed or some specific processing error + happened that may be the fault of the client as detailed in the JSON body + of the response. + :http:statuscode:`403 Forbidden`: + The ``h_contract`` does not match the $ORDER_ID. + :http:statuscode:`404 Not found`: + The merchant backend could not find the order or the instance + and thus cannot process the abort request. + :http:statuscode:`408 Request timeout`: + The merchant backend took too long getting a response from the exchange. + The wallet SHOULD retry soon. + :http:statuscode:`412 Precondition failed`: + Aborting the payment is not allowed, as the original payment did succeed. + It is possible that a different wallet succeeded with the payment. This + wallet should thus try to refresh all of the coins involved in the payment. + :http:statuscode:`502 Bad gateway`: + The merchant's interaction with the exchange failed in some way. + The error from the exchange is included. + :http:statuscode:`504 Gateway timeout`: + The merchant's interaction with the exchange took too long. + The client might want to try again later. + + The backend will return an `abort response <AbortResponse>`, which includes + verbatim the error codes received from the exchange's + :ref:`refund <exchange_refund>` API. The frontend should pass the replies verbatim to + the browser/wallet. + + **Details:** + + .. ts:def:: AbortRequest + + interface AbortRequest { + + // Hash of the order's contract terms (this is used to authenticate the + // wallet/customer in case $ORDER_ID is guessable). + h_contract: HashCode; + + // List of coins the wallet would like to see refunds for. + // (Should be limited to the coins for which the original + // payment succeeded, as far as the wallet knows.) + coins: AbortingCoin[]; + } + + .. ts:def:: AbortingCoin + + interface AbortingCoin { + // Public key of a coin for which the wallet is requesting an abort-related refund. + coin_pub: EddsaPublicKey; + + // The amount to be refunded (matches the original contribution) + // @Deprecated since **v18**. + contribution: Amount; + + // URL of the exchange this coin was withdrawn from. + exchange_url: string; + } + + + .. ts:def:: AbortResponse + + interface AbortResponse { + + // List of refund responses about the coins that the wallet + // requested an abort for. In the same order as the ``coins`` + // from the original request. + // The ``rtransaction_id`` is implied to be 0. + refunds: MerchantAbortPayRefundStatus[]; + } + + .. ts:def:: MerchantAbortPayRefundStatus + + type MerchantAbortPayRefundStatus = + | MerchantAbortPayRefundSuccessStatus + | MerchantAbortPayRefundUndepositedStatus + | MerchantAbortPayRefundFailureStatus; + + .. ts:def:: MerchantAbortPayRefundFailureStatus + + // Details about why a refund failed. + interface MerchantAbortPayRefundFailureStatus { + // Used as tag for the sum type RefundStatus sum type. + type: "failure"; + + // HTTP status of the exchange request, must NOT be 200. + exchange_status: Integer; + + // Taler error code from the exchange reply, if available. + exchange_code?: Integer; + + // If available, HTTP reply from the exchange. + exchange_reply?: Object; + } + + .. ts:def:: MerchantAbortPayRefundSuccessStatus + + // Additional details needed to verify the refund confirmation signature + // (``h_contract_terms`` and ``merchant_pub``) are already known + // to the wallet and thus not included. + interface MerchantAbortPayRefundSuccessStatus { + // Used as tag for the sum type MerchantCoinRefundStatus sum type. + type: "success"; + + // HTTP status of the exchange request, 200 (integer) required for refund confirmations. + exchange_status: 200; + + // The EdDSA :ref:`signature` (binary-only) with purpose + // `TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND` using a current signing key of the + // exchange affirming the successful refund. + exchange_sig: EddsaSignature; + + // Public EdDSA key of the exchange that was used to generate the signature. + // Should match one of the exchange's signing keys from ``/keys``. It is given + // explicitly as the client might otherwise be confused by clock skew as to + // which signing key was used. + exchange_pub: EddsaPublicKey; + } + + .. ts:def:: MerchantAbortPayRefundUndepositedStatus + + // The merchant didn't deposit the coin in the first place, + // no refund possible. + interface MerchantAbortPayRefundSuccessStatus { + // Used as tag for the sum type MerchantCoinRefundStatus sum type. + type: "undeposited"; + } diff --git a/core/merchant/post-orders-ORDER_ID-claim.rst b/core/merchant/post-orders-ORDER_ID-claim.rst @@ -0,0 +1,45 @@ +.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/claim + + Wallet claims ownership (via nonce) over an order. By claiming + an order, the wallet obtains the full contract terms, and thereby + implicitly also the hash of the contract terms it needs for the + other ``public`` APIs to authenticate itself as the wallet that + is indeed eligible to inspect this particular order's status. + + **Request:** + + The request must be a `ClaimRequest`. + + **Response:** + + :http:statuscode:`200 OK`: + The client has successfully claimed the order. + The response contains the :ref:`contract terms <contract-terms>`. + :http:statuscode:`404 Not found`: + The backend is unaware of the instance or order. + :http:statuscode:`409 Conflict`: + Someone else has already claimed the same order ID with a different nonce. + + **Details:** + + .. ts:def:: ClaimRequest + + interface ClaimRequest { + // Nonce to identify the wallet that claimed the order. + nonce: EddsaPublicKey; + + // Token that authorizes the wallet to claim the order. + // *Optional* as the merchant may not have required it + // (``create_token`` set to ``false`` in `PostOrderRequest`). + token?: ClaimToken; + } + + .. ts:def:: ClaimResponse + + interface ClaimResponse { + // Contract terms of the claimed order + contract_terms: ContractTerms; + + // Signature by the merchant over the contract terms. + sig: EddsaSignature; + } diff --git a/core/merchant/post-orders-ORDER_ID-paid.rst b/core/merchant/post-orders-ORDER_ID-paid.rst @@ -0,0 +1,62 @@ +.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/paid + + Prove that the client previously paid for an order by providing + the merchant's signature from the `payment response <PaymentResponse>`. + Typically used by the customer's wallet if it receives a request for + payment for an order that it already paid. This is more compact than + re-transmitting the full payment details. + Note that this request does include the + usual ``h_contract`` argument to authenticate the wallet and + to allow the merchant to verify the signature before checking + with its own database. + + **Request:** + + The request must be a `paid request <PaidRequest>`. + + **Response:** + + :http:statuscode:`200 Ok`: + The merchant accepted the signature. + The ``frontend`` should now fulfill the contract. + Note that it is possible that refunds have been granted. Response is of type `PaidRefundStatusResponse`. + :http:statuscode:`400 Bad request`: + Either the client request is malformed or some specific processing error + happened that may be the fault of the client as detailed in the JSON body + of the response. + :http:statuscode:`403 Forbidden`: + The signature was not valid. + :http:statuscode:`404 Not found`: + The merchant backend could not find the order or the instance + and thus cannot process the request. + + **Details**: + + .. ts:def:: PaidRefundStatusResponse + + interface PaidRefundStatusResponse { + + // Text to be shown to the point-of-sale staff as a proof of + // payment (present only if re-usable OTP algorithm is used). + pos_confirmation?: string; + + // True if the order has been subjected to + // refunds. False if it was simply paid. + refunded: boolean; + } + + .. ts:def:: PaidRequest + + interface PaidRequest { + // Signature on ``TALER_PaymentResponsePS`` with the public + // key of the merchant instance. + sig: EddsaSignature; + + // Hash of the order's contract terms (this is used to authenticate the + // wallet/customer and to enable signature verification without + // database access). + h_contract: HashCode; + + // Session id for which the payment is proven. + session_id: string; + } diff --git a/core/merchant/post-orders-ORDER_ID-pay.rst b/core/merchant/post-orders-ORDER_ID-pay.rst @@ -0,0 +1,354 @@ +.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/pay + + Pay for an order by giving a deposit permission for coins. Typically used by + the customer's wallet. Note that this request does not include the + usual ``h_contract`` argument to authenticate the wallet, as the hash of + the contract is implied by the signatures of the coins. Furthermore, this + API doesn't really return useful information about the order. + + **Request:** + + The request must be a `pay request <PayRequest>`. + + **Response:** + + :http:statuscode:`200 OK`: + The exchange accepted all of the coins. + The body is a `payment response <PaymentResponse>`. + The ``frontend`` should now fulfill the contract. + Note that it is possible that refunds have been granted. + :http:statuscode:`400 Bad request`: + Either the client request is malformed or some specific processing error + happened that may be the fault of the client as detailed in the JSON body + of the response. + This includes the case where the payment is insufficient (sum is below + the required total amount, for example because the wallet calculated the + fees wrong). + Applicable error codes: + + * ``MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND``: Wallet tried + to pay with a non-existent denomination. + + :http:statuscode:`402 Payment required`: + There used to be a sufficient payment, but due to refunds the amount effectively + paid is no longer sufficient. (If the amount is generally insufficient, we + return "400 Bad Request", only if this is because of refunds we return 402.) + :http:statuscode:`403 Forbidden`: + One of the coin signatures was not valid. + :http:statuscode:`404 Not found`: + The merchant backend could not find the order + or the instance or a token family or + the Donau charity specified in + the contract and thus cannot process the payment. + Applicable error codes: + + * ``MERCHANT_GENERIC_TOKEN_KEY_UNKNOWN`` + * ``MERCHANT_GENERIC_ORDER_UNKNOWN`` + * ``MERCHANT_GENERIC_DONAU_CHARITY_UNKNOWN`` + * ``MERCHANT_GENERIC_INSTANCE_UNKNOWN`` + + :http:statuscode:`408 Request timeout`: + The backend took too long to process the request. Likely the merchant's connection + to the exchange timed out. Try again. + Applicable error codes: + + * ``MERCHANT_GENERIC_EXCHANGE_TIMEOUT`` + + :http:statuscode:`409 Conflict`: + The exchange rejected the payment because a coin was already spent (or + used in a different way for the same purchase previously), or + the merchant rejected the payment because the order was already fully paid + (and then return signatures with refunds). If a coin was already spent + (this includes re-using the same coin after a refund), + the response will include the ``exchange_url`` for which the payment failed, + in addition to the response from the exchange to the ``/batch-deposit`` request. + Applicable error codes: + + * ``MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_FUNDS``: Exchange reported insufficient + funds for one of the coins. + + :http:statuscode:`410 Gone`: + The offer has expired and is no longer available or + the provided payment has expired. + Applicable error codes: + + * ``MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_DEPOSIT_EXPIRED``: payment expired + * ``MERCHANT_POST_ORDERS_ID_PAY_OFFER_EXPIRED``: offer expired + + :http:statuscode:`412 Precondition failed`: + The given exchange is not acceptable for this merchant, as it is not in the + list of accepted exchanges and not audited by an approved auditor. + TODO: Status code may be changed to 409 in the future as 412 is technically wrong. + :http:statuscode:`451 Unavailable for Legal Reasons`: + The exchange has rejected the deposit by the merchant + for legal reasons. This is **not** exactly a client + failure (and possibly nobody's fault except for the + regulator). In any case, the wallet should refresh + the deposited coins of the affected exchange and + may try to pay with coins from another exchange if + possible (it has such coins and the merchant accepts + coins from another exchange). + The body is a `PaymentDeniedLegallyResponse` with + details about the failure. + Since protocol **v17**. + :http:statuscode:`501 Not implemented`: + This is returned if an optional feature required to + process this particular payment is no longer implemented. + This should only be possible if a different version + of the backend software was deployed between order + creation and payment. + + Applicable error codes: + + * ``MERCHANT_GENERIC_DONAU_NOT_CONFIGURED``: returned if donations are not supported + * ``MERCHANT_GENERIC_FEATURE_NOT_AVAILABLE``: usually returned if a token type is not supported + + :http:statuscode:`502 Bad gateway`: + The merchant's interaction with the exchange failed in some way. + The client might want to try again later. + This includes failures such as the denomination key of a coin not being + known to the exchange as far as the merchant can tell. + Applicable error codes: + + * ``MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS`` + * ``MERCHANT_GENERIC_EXCHANGE_REPLY_MALFORMED`` + + :http:statuscode:`504 Gateway timeout`: + The merchant's interaction with the exchange took too long. + The client might want to try again later. + + The backend will return verbatim the error codes received from the exchange's + :ref:`deposit <deposit>` API. If the wallet made a mistake, like by + double-spending for example, the frontend should pass the reply verbatim to + the browser/wallet. If the payment was successful, the frontend MAY use + this to trigger some business logic. + + **Details:** + + .. ts:def:: PaymentResponse + + interface PaymentResponse { + // Signature on ``TALER_PaymentResponsePS`` with the public + // key of the merchant instance. + sig: EddsaSignature; + + // Text to be shown to the point-of-sale staff as a proof of + // payment. + pos_confirmation?: string; + + // Signed tokens. Returned in the same order as the + // token envelopes were provided in the request. Specifically, + // the order will follow the order of the outputs from the + // contract terms, and then within each output follow the + // order in which the ``wallet_data`` contained the respective + // blinded envelopes. The donation tokens will be present + // at the offset matching the place where a donation receipt + // was indicated in the outputs array, and of course be skipped + // if the ``PayWalletData`` did not have a ``donau`` field. + // @since protocol **v21** + token_sigs?: SignedTokenEnvelope[]; + + } + + .. ts:def:: PayRequest + + interface PayRequest { + // The coins used to make the payment. + coins: CoinPaySig[]; + + // Input tokens required by choice indicated by ``choice_index``. + // @since protocol **v21** + tokens?: TokenUseSig[]; + + // Custom inputs from the wallet for the contract. + wallet_data?: PayWalletData; + + // The session for which the payment is made (or replayed). + // Only set for session-based payments. + session_id?: string; + + } + + .. ts:def:: SignedTokenEnvelope + + interface SignedTokenEnvelope { + + // Blind signature made by the merchant. + blind_sig: TokenIssueBlindSig; + + } + + .. ts:def:: TokenIssueBlindSig + + type TokenIssueBlindSig = RSATokenIssueBlindSig | CSTokenIssueBlindSig; + + .. ts:def:: RSATokenIssueBlindSig + + interface RSATokenIssueBlindSig { + cipher: "RSA"; + + // (blinded) RSA signature + blinded_rsa_signature: BlindedRsaSignature; + } + + .. ts:def:: CSTokenIssueBlindSig + + interface CSTokenIssueBlindSig { + cipher: "CS"; + + // Signer chosen bit value, 0 or 1, used + // in Clause Blind Schnorr to make the + // ROS problem harder. + b: Integer; + + // Blinded scalar calculated from c_b. + s: Cs25519Scalar; + + } + + .. ts:def:: PayWalletData + + interface PayWalletData { + // Index of the selected choice within the ``choices`` array of + // the contract terms. + // @since protocol **v21** + choice_index?: Integer; + + // Array of output tokens to be (blindly) signed by the merchant. + // Output tokens specified in choice indicated by ``choice_index``. + // @since protocol **v21** + tokens_evs?: TokenEnvelope[]; + + // Request for donation receipts to be issued. + // @since protocol **v21** + donau?: DonationRequestData; + } + + .. ts:def:: DonationRequestData + + interface DonationRequestData { + // Base URL of the selected Donau + url: string; + + // Year for which the donation receipts are expected. + // Also determines which keys are used to sign the + // blinded donation receipts. + year: Integer; + + // Array of blinded donation receipts to sign. + // Must NOT be empty (if no donation receipts + // are desired, just leave the entire ``donau`` + // argument blank). + budikeypairs: BlindedDonationReceiptKeyPair[]; + } + + .. ts:def:: CoinPaySig + + interface CoinPaySig { + // Signature by the coin. + coin_sig: EddsaSignature; + + // Public key of the coin being spent. + coin_pub: EddsaPublicKey; + + // Signature made by the denomination public key. + ub_sig: UnblindedSignature; + + // The hash of the denomination public key associated with this coin. + h_denom: HashCode; + + // The amount that is subtracted from this coin with this payment. + contribution: Amount; + + // URL of the exchange this coin was withdrawn from. + exchange_url: string; + + // Signature affirming the posession of the + // respective private key proving that the payer + // is old enough. Only provided if the paid contract + // has an age restriction and the coin is + // age-restricted. + minimum_age_sig?: EddsaSignature; + + // Age commitment vector of the coin. + // Only provided if the paid contract + // has an age restriction and the coin is + // age-restricted. + age_commitment?: Edx25519PublicKey[]; + + // Hash over the agge commitment vector of the coin. + // Only provided if the paid contract + // does NOT have an age restriction and the coin is + // age-restricted. + h_age_commitment?: AgeCommitmentHash; + } + + .. ts:def:: TokenUseSig + + interface TokenUseSig { + + // Signature on ``TALER_TokenUseRequestPS`` with the token use key of + // the token being used in this request. + token_sig: EddsaSignature; + + // Token use public key. + token_pub: EddsaPublicKey; + + // Unblinded signature on ``TALER_TokenIssueRequestPS`` with the token + // issue public key of the merchant. + ub_sig: UnblindedSignature; + + // Hash of the token issue public key associated with this token. + h_issue: HashCode; + } + + .. ts:def:: TokenEnvelope + + // This type depends on the cipher used to sign token families. This is + // configured by the merchant and defined for each token family in the + // contract terms. + type TokenEnvelope = RSATokenEnvelope | CSTokenEnvelope; + + .. ts:def:: RSATokenEnvelope + + interface RSATokenEnvelope { + + // RSA is used for the blind signature. + cipher: "RSA"; + + // Blinded signature of the token's `public EdDSA key <eddsa-token-pub>`. + rsa_blinded_pub: BlindedRsaSignature; + + } + + .. ts:def:: CSTokenEnvelope + + interface CSTokenEnvelope { + // Blind Clause-Schnorr signature scheme is used for the blind signature. + // See https://taler.net/papers/cs-thesis.pdf for details. + cipher: "CS"; + + // Public nonce + cs_nonce: string; // Crockford `Base32` encoded + + // Two Curve25519 scalars, each representing a blinded challenge + cs_blinded_c0: string; // Crockford `Base32` encoded + cs_blinded_c1: string; // Crockford `Base32` encoded + } + + .. ts:def:: PaymentDeniedLegallyResponse + + interface PaymentDeniedLegallyResponse { + + // Numeric `error code <error-codes>` unique to the condition. + // Error code, must be + // TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_LEGALLY_REFUSED. + code: Integer; + + // Base URL of the exchanges that denied the payment. + // The wallet should refresh the coins from these + // exchanges, but may try to pay with coins from + // other exchanges. + exchange_base_urls: string[]; + + } diff --git a/core/merchant/post-orders-ORDER_ID-refund.rst b/core/merchant/post-orders-ORDER_ID-refund.rst @@ -0,0 +1,121 @@ +.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/refund + + Obtain refunds for an order. After talking to the exchange, the refunds will + no longer be pending if processed successfully. + + **Request:** + + The request body is a `WalletRefundRequest` object. + + **Response:** + + :http:statuscode:`200 OK`: + The response is a `WalletRefundResponse`. + :http:statuscode:`204 No content`: + There are no refunds for the order. + :http:statuscode:`403 Forbidden`: + The ``h_contract`` does not match the order. + :http:statuscode:`404 Not found`: + The merchant backend is unaware of the order. + :http:statuscode:`410 Gone`: + The wire deadline has past and it is too late to grant a refund. + Since protocol **v24**. + + **Details:** + + .. ts:def:: WalletRefundRequest + + interface WalletRefundRequest { + // Hash of the order's contract terms (this is used to authenticate the + // wallet/customer). + h_contract: HashCode; + } + + .. ts:def:: WalletRefundResponse + + interface WalletRefundResponse { + // Amount that was refunded in total. + refund_amount: Amount; + + // Successful refunds for this payment, empty array for none. + refunds: MerchantCoinRefundStatus[]; + + // Public key of the merchant. + merchant_pub: EddsaPublicKey; + + } + + .. ts:def:: MerchantCoinRefundStatus + + type MerchantCoinRefundStatus = + | MerchantCoinRefundSuccessStatus + | MerchantCoinRefundFailureStatus; + + .. ts:def:: MerchantCoinRefundFailureStatus + + // Details about why a refund failed. + interface MerchantCoinRefundFailureStatus { + // Used as tag for the sum type RefundStatus sum type. + type: "failure"; + + // HTTP status of the exchange request, must NOT be 200. + exchange_status: Integer; + + // Taler error code from the exchange reply, if available. + exchange_code?: Integer; + + // If available, HTTP reply from the exchange. + exchange_reply?: Object; + + // Refund transaction ID. + rtransaction_id: Integer; + + // Public key of a coin that was refunded. + coin_pub: EddsaPublicKey; + + // Amount that was refunded, including refund fee charged by the exchange + // to the customer. + refund_amount: Amount; + + // Timestamp when the merchant approved the refund. + // Useful for grouping refunds. + execution_time: Timestamp; + } + + .. ts:def:: MerchantCoinRefundSuccessStatus + + // Additional details needed to verify the refund confirmation signature + // (``h_contract_terms`` and ``merchant_pub``) are already known + // to the wallet and thus not included. + interface MerchantCoinRefundSuccessStatus { + // Used as tag for the sum type MerchantCoinRefundStatus sum type. + type: "success"; + + // HTTP status of the exchange request, 200 (integer) required for refund confirmations. + exchange_status: 200; + + // The EdDSA :ref:`signature` (binary-only) with purpose + // `TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND` using a current signing key of the + // exchange affirming the successful refund. + exchange_sig: EddsaSignature; + + // Public EdDSA key of the exchange that was used to generate the signature. + // Should match one of the exchange's signing keys from /keys. It is given + // explicitly as the client might otherwise be confused by clock skew as to + // which signing key was used. + exchange_pub: EddsaPublicKey; + + // Refund transaction ID. + rtransaction_id: Integer; + + // Public key of a coin that was refunded. + coin_pub: EddsaPublicKey; + + // Amount that was refunded, including refund fee charged by the exchange + // to the customer. + refund_amount: Amount; + + // Timestamp when the merchant approved the refund. + // Useful for grouping refunds. + execution_time: Timestamp; + } diff --git a/core/merchant/post-orders-ORDER_ID-unclaim.rst b/core/merchant/post-orders-ORDER_ID-unclaim.rst @@ -0,0 +1,42 @@ +.. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/unclaim + + Wallet releases ownership over an order. By unclaiming an + order, it becomes possible for another wallet to claim it. + This is useful if a user abandons buying the order with one + wallet but then wants to pay with a different wallet. + + @since protocol **v26**. + + **Request:** + + The request must be an `UnclaimRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The client has successfully unclaimed the order. + :http:statuscode:`403 Forbidden`: + The signature is invalid. + :http:statuscode:`404 Not found`: + The backend is unaware of the instance or order. + :http:statuscode:`409 Conflict`: + The order was already paid, and thus cannot be unclaimed anymore. + + **Details:** + + .. ts:def:: UnclaimRequest + + interface UnclaimRequest { + // Signature using the key of the claim nonce + // to affirm unclaiming of the order. + unclaim_sig: EddsaSignature; + + // Nonce to identify the wallet that claimed the order, + // public key matching ``unclaim_sig``. + nonce: EddsaPublicKey; + + // Hash of the order's contract terms, used + // to enable signature verification without + // database access. + h_contract: HashCode; + } diff --git a/core/merchant/post-private-accounts.rst b/core/merchant/post-private-accounts.rst @@ -0,0 +1,83 @@ +.. http:post:: [/instances/$INSTANCE]/private/accounts + + This is used to add an account to an instance. + + **Required permission:** ``accounts-write`` + + **Request:** + + The request must have an `AccountAddDetails` body. + + **Response:** + + :http:statuscode:`200 Ok`: + Adding the account was successful, we return the salt selected by the backend and the resulting wire hash in an `AccountAddResponse`. + :http:statuscode:`202 Accepted`: + 2FA is required for this operation, usually to validate the + email and/or phone numbers registered for the instance. + This returns the `ChallengeResponse`. @since **v21** + :http:statuscode:`404 Not found`: + The merchant instance is unknown or it is not in our data. + :http:statuscode:`409 Conflict`: + The provided information is inconsistent with the current state of the instance. + Usually this means we already have this account, but with conflicting credit facade information. + Inactive accounts can be reactivated using this method even if the + credit facade information differs from the previous state. + + **Details:** + + .. ts:def:: AccountAddDetails + + interface AccountAddDetails { + + // Full payto:// URI of the account. + payto_uri: string; + + // URL from where the merchant can download information + // about incoming wire transfers to this account. + credit_facade_url?: string; + + // Credentials to use when accessing the credit facade. + // Never returned on a GET (as this may be somewhat + // sensitive data). Can be set in POST + // or PATCH requests to update (or delete) credentials. + // To really delete credentials, set them to the type: "none". + credit_facade_credentials?: FacadeCredentials; + + } + + .. ts:def:: FacadeCredentials + + type FacadeCredentials = + | NoFacadeCredentials + | BasicAuthFacadeCredentials; + + .. ts:def:: NoFacadeCredentials + + interface NoFacadeCredentials { + type: "none"; + }; + + .. ts:def:: BasicAuthFacadeCredentials + + interface BasicAuthFacadeCredentials { + type: "basic"; + + // Username to use to authenticate + username: string; + + // Password to use to authenticate + password: string; + }; + + .. ts:def:: AccountAddResponse + + interface AccountAddResponse { + + // Hash over the wire details (including over the salt). + h_wire: HashCode; + + // Salt used to compute h_wire. + salt: HashCode; + + } diff --git a/core/merchant/post-private-categories.rst b/core/merchant/post-private-categories.rst @@ -0,0 +1,38 @@ +.. http:post:: [/instances/$INSTANCE]/private/categories + + This is used to create a new category for the inventory. + Since API version **v16**. + + **Required permission:** ``categories-write`` + + **Request:** + + The request is a `CategoryCreateRequest`. + + **Response:** + + :http:statuscode:`200 Ok`: + The response is a `CategoryCreatedResponse`. + + **Details:** + + .. ts:def:: CategoryCreateRequest + + interface CategoryCreateRequest { + + // Name of the category. + name: string; + + // Translations of the name into various + // languages. + name_i18n?: { [lang_tag: string]: string }; + + } + + .. ts:def:: CategoryCreatedResponse + + interface CategoryCreatedResponse { + + // Number of the newly created category. + category_id: Integer; + } diff --git a/core/merchant/post-private-donau.rst b/core/merchant/post-private-donau.rst @@ -0,0 +1,35 @@ +.. http:post:: [/instances/$INSTANCE]/private/donau + + Link a new Donau charity instance to ``$INSTANCE``. + The backend fetches and validates the charity’s metadata from the given + Donau service before persisting the link. + + **Required permission:** ``donau-write`` + + **Request:** + + The body **must** be a :ts:type:`PostDonauRequest`. + + .. ts:def:: PostDonauRequest + + interface PostDonauRequest { + // Base URL of the Donau service hosting the charity + donau_url: string; + + // Numeric charity identifier inside the Donau service + charity_id: Integer; + } + + **Response:** + + :http:statuscode:`204 No content`: + The charity link was created successfully. + :http:statuscode:`202 Accepted`: + Operation requires MFA; a :ts:type:`ChallengeResponse` is returned. @since **v21** + :http:statuscode:`400 Bad request`: + Malformed JSON or missing fields. + :http:statuscode:`409 Conflict`: + * The charity is already linked with different parameters, or + * The charity’s public key does **not** match the merchant instance’s public key. + :http:statuscode:`502 Bad gateway`: + Communication with the Donau service failed. diff --git a/core/merchant/post-private-groups.rst b/core/merchant/post-private-groups.rst @@ -0,0 +1,40 @@ +.. http:post:: [/instances/$INSTANCES]/private/groups + + This is used to create a group. + + **Required permission:** ``groups-write`` + + **Request:** + + The request must be a `GroupAddRequest`. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully added a new group. Returns a `GroupAddedResponse`. + + :http:statuscode:`404 Not found`: + The merchant instance is unknown. + + **Details:** + + .. ts:def:: GroupAddRequest + + interface GroupAddRequest { + + // Unique name for the group (unique per instance). + group_name: string; + + // Description of the group. + description: string; + + } + + .. ts:def:: GroupAddedResponse + + interface GroupAddedResponse { + + // Unique ID for the group. + group_serial_id: Integer; + + } diff --git a/core/merchant/post-private-orders-ORDER_ID-refund.rst b/core/merchant/post-private-orders-ORDER_ID-refund.rst @@ -0,0 +1,59 @@ +.. http:post:: [/instances/$INSTANCE]/private/orders/$ORDER_ID/refund + + Increase the refund amount associated with a given order. The user should be + redirected to the ``taler_refund_uri`` to trigger refund processing in the wallet. + + **Required permission:** ``orders-refund`` + + **Request:** + + The request body is a `RefundRequest` object. + + **Response:** + + :http:statuscode:`200 OK`: + The refund amount has been increased, the backend + responds with a `MerchantRefundResponse`. + :http:statuscode:`403 Forbidden`: + For the given order, the refund delay was zero and thus + refunds are categorically not allowed. + :http:statuscode:`404 Not found`: + The order is unknown to the merchant. + :http:statuscode:`410 Gone`: + It is too late for aborting, the exchange may have already wired the funds + to the merchant. + :http:statuscode:`409 Conflict`: + The refund amount exceeds the amount originally paid. + :http:statuscode:`451 Unavailable for Legal Reasons`: + The refund could not be awarded because of legal + reasons (an exchange would refuse). The merchant + staff needs to find another way to give a refund + to the customer. + The body is an `ErrorDetail` with an error + code of ``MERCHANT_POST_ORDERS_ID_REFUND_EXCHANGE_TRANSACTION_LIMIT_VIOLATION``. + + **Details:** + + .. ts:def:: RefundRequest + + interface RefundRequest { + // Amount to be refunded. + refund: Amount; + + // Human-readable refund justification. + reason: string; + } + + .. ts:def:: MerchantRefundResponse + + interface MerchantRefundResponse { + + // URL (handled by the backend) that the wallet should access to + // trigger refund processing. + // taler://refund/... + taler_refund_uri: string; + + // Contract hash that a client may need to authenticate an + // HTTP request to obtain the above URI in a wallet-friendly way. + h_contract: HashCode; + } diff --git a/core/merchant/post-private-orders.rst b/core/merchant/post-private-orders.rst @@ -0,0 +1,494 @@ +.. http:post:: [/instances/$INSTANCE]/private/orders + + Create a new order that a customer can pay for. + + This request is **not** idempotent unless an ``order_id`` is explicitly specified. + However, while repeating without an ``order_id`` will create another order, that is + generally pretty harmless (as long as only one of the orders is returned to the wallet). + + .. note:: + + This endpoint does not return a URL to redirect your user to confirm the + payment. To get this URL use either + :http:get:`[/instances/$INSTANCE]/orders/$ORDER_ID` (with + ``taler_pay_uri`` in the `StatusUnpaidResponse`), or + :http:get:`[/instances/$INSTANCE]/private/orders/$ORDER_ID` with the + ``taler_pay_uri`` in the `CheckPaymentUnpaidResponse`). That said, + it is also possible to construct the URL by combining the base URL + with the information from the `PostOrderResponse`. + The API is structured this way since the payment redirect URL is not + unique for every order: there might be varying parameters such as the + session id. + + **Required permission:** ``orders-write`` + + **Request:** + + The request must be a `PostOrderRequest`. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully created the proposal. The response is a + :ts:type:`PostOrderResponse`. + :http:statuscode:`404 Not found`: + Possible reasons are: + + (1) The order given used products from the inventory, but those were + not found in the inventory. + (2) The merchant instance is unknown (including possibly the instance + being not configured for new orders). + (3) The wire method specified is not supported by the backend. + (4) An OTP device ID was specified and is unknown. + + Details in the error code. + NOTE: currently the client has no good way to find out which product + is not in the inventory, we MAY want to specify that in the reply. + :http:statuscode:`409 Conflict`: + A different proposal already exists under the specified order ID, + or the requested currency is not supported by this backend. Details in + the error code. + :http:statuscode:`410 Gone`: + The order given used products from the inventory that are out of stock. + The response is a :ts:type:`OutOfStockResponse`. + :http:statuscode:`451 Unavailable for Legal Reasons`: + The order could not be created because of legal + reasons, specifically no exchange would accept + a payment at this time because we have not yet + satisfied the respective legal requirements. + The :ref:`KYC status <merchantkycstatus>` API + can be used to determine details about how to + proceed with the KYC process. + Since **v25**, the body is an + `OrderRefusedErrorDetailResponse` with an error + code of ``MERCHANT_PRIVATE_POST_ORDERS_AMOUNT_EXCEEDS_LEGAL_LIMITS``. + + **Details:** + + .. ts:def:: PostOrderRequest + + interface PostOrderRequest { + // The order must at least contain the minimal + // order detail, but can override all. + order: Order; + + // If set, the backend will then set the refund deadline to the + // payment deadline plus the specified delay. + // If it's not set, the default value of the backend might be + // used. Note that both this value and the backend default + // will be ignored if ``refund_deadline`` is set in ``order`` + // as the ``refund_deadline`` takes precedence. + // A value of "forever" is not allowed. + refund_delay?: RelativeTime; + + // Specifies the payment target preferred by the client. Can be used + // to select among the various (active) wire methods supported by the instance. + payment_target?: string; + + // The session for which the payment is made (or replayed). + // Only set for session-based payments. + // Since protocol **v6**. + session_id?: string; + + // Specifies that some products are to be included in the + // order from the inventory. For these inventory management + // is performed (so the products must be in stock) and + // details are completed from the product data of the backend. + inventory_products?: MinimalInventoryProduct[]; + + // Specifies a lock identifier that was used to + // lock a product in the inventory. Only useful if + // ``inventory_products`` is set. Used in case a frontend + // reserved quantities of the individual products while + // the shopping cart was being built. Multiple UUIDs can + // be used in case different UUIDs were used for different + // products (i.e. in case the user started with multiple + // shopping sessions that were combined during checkout). + lock_uuids?: string[]; + + // Should a token for claiming the order be generated? + // False can make sense if the ORDER_ID is sufficiently + // high entropy to prevent adversarial claims (like it is + // if the backend auto-generates one). Default is 'true'. + // Note: This is NOT related to tokens used for subscriptins or discounts. + create_token?: boolean; + + // OTP device ID to associate with the order. + // This parameter is optional. + otp_id?: string; + + } + + The `Order` object represents the starting point for new `ContractTerms`. + After validating and sanatizing all inputs, the merchant backend will add + additional information to the order and create a new `ContractTerms` object + that will be stored in the database. + + .. ts:def:: Order + + type Order = (OrderV1 | OrderV0) & OrderCommon; + + .. ts:def:: OrderV1 + + interface OrderV1 { + // Version 1 order support discounts and subscriptions. + // https://docs.taler.net/design-documents/046-mumimo-contracts.html + // @since protocol **v21** + version: 1; + + // List of contract choices that the customer can select from. + // @since protocol **v21** + choices?: OrderChoice[]; + } + + .. ts:def:: OrderV0 + + interface OrderV0 { + // Optional, defaults to 0 if not set. + version?: 0; + + // Total price for the transaction, including tip. The exchange will + // subtract deposit fees from that amount before transferring it to + // the merchant. + amount: Amount; + + // Optional tip amount. Must match the currency of ``amount``. + // Since protocol **v25**. + tip?: Amount; + + // Maximum total deposit fee accepted by the merchant for this contract. + // Overrides defaults of the merchant instance. + max_fee?: Amount; + } + + .. ts:def:: OrderCommon + + interface OrderCommon { + // Human-readable description of the whole purchase. + summary: string; + + // Map from IETF BCP 47 language tags to localized summaries. + summary_i18n?: { [lang_tag: string]: string }; + + // Unique identifier for the order. Only characters + // allowed are "A-Za-z0-9" and ".:_-". + // Must be unique within a merchant instance. + // For merchants that do not store proposals in their DB + // before the customer paid for them, the ``order_id`` can be used + // by the frontend to restore a proposal from the information + // encoded in it (such as a short product identifier and timestamp). + order_id?: string; + + // URL where the same contract could be ordered again (if + // available). Returned also at the public order endpoint + // for people other than the actual buyer (hence public, + // in case order IDs are guessable). + public_reorder_url?: string; + + // See documentation of ``fulfillment_url`` field in `ContractTerms`. + // Either fulfillment_url or fulfillment_message must be specified. + // When creating an order, the fulfillment URL can + // contain ``${ORDER_ID}`` which will be substituted with the + // order ID of the newly created order. + fulfillment_url?: string; + + // See documentation of ``fulfillment_message`` in `ContractTerms`. + // Either ``fulfillment_url`` or ``fulfillment_message`` must be specified. + fulfillment_message?: string; + + // Map from IETF BCP 47 language tags to localized fulfillment + // messages. + fulfillment_message_i18n?: { [lang_tag: string]: string }; + + // Minimum age the buyer must have to buy. + minimum_age?: Integer; + + // List of products that are part of the purchase. + products?: ProductSold[]; + + // Time when this contract was generated. If null, defaults to current + // time of merchant backend. + timestamp?: Timestamp; + + // After this deadline has passed, no refunds will be accepted. + // Overrides deadline calculated from ``refund_delay`` in + // ``PostOrderRequest``. + // A value of "never" is not allowed. + refund_deadline?: Timestamp; + + // After this deadline, the merchant won't accept payments for the contract. + // Overrides deadline calculated from default pay delay configured in + // merchant backend. + // A value of "never" is not allowed. + pay_deadline?: Timestamp; + + // Transfer deadline for the exchange. Must be in the deposit permissions + // of coins used to pay for this order. + // Overrides deadline calculated from default wire transfer delay + // configured in merchant backend. Must be after refund deadline. + // A value of "never" is not allowed. + wire_transfer_deadline?: Timestamp; + + // Base URL of the (public!) merchant backend API. + // Must be an absolute URL that ends with a slash. + // Defaults to the base URL this request was made to. + merchant_base_url?: string; + + // Delivery location for (all!) products. + delivery_location?: Location; + + // Time indicating when the order should be delivered. + // May be overwritten by individual products. + // Must be in the future. + delivery_date?: Timestamp; + + // See documentation of ``auto_refund`` in ``ContractTerms``. + // Specifies for how long the wallet should try to get an + // automatic refund for the purchase. + auto_refund?: RelativeTime; + + // Extra data that is only interpreted by the merchant frontend. + // Useful when the merchant needs to store extra information on a + // contract without storing it separately in their database. + // Must really be an Object (not a string, integer, float or array). + extra?: Object; + + // Money pot to increment for whatever order payment amount + // is not yet assigned to a pot via the ``ProductSold``. + // Not useful to wallets, only for + // merchant-internal accounting. + // Since protocol **v25**. + order_default_money_pot?: Integer; + + } + + + The `OrderChoice` object describes a possible choice within an order. The + choice is done by the wallet and consists of in- and outputs. In the example + of buying an article, the merchant could present the customer with the + choice to use a valid subscription token or pay using a gift + voucher. Available since protocol **v21**. + + .. ts:def:: OrderChoice + + interface OrderChoice { + // Total price for the choice. The exchange will subtract deposit + // fees from that amount before transferring it to the merchant. + amount: Amount; + + // Optional tip amount. Must match the currency of ``amount``. + // Since protocol **v25**. + tip?: Amount; + + // Human readable description of the semantics of the choice + // within the contract to be shown to the user at payment. + description?: string; + + // Map from IETF 47 language tags to localized descriptions. + description_i18n?: { [lang_tag: string]: string }; + + // Inputs that must be provided by the customer, if this choice is selected. + // Defaults to empty array if not specified. + inputs?: OrderInput[]; + + // Outputs provided by the merchant, if this choice is selected. + // Defaults to empty array if not specified. + outputs?: OrderOutput[]; + + // Maximum total deposit fee accepted by the merchant for this contract. + // Overrides defaults of the merchant instance. + max_fee?: Amount; + } + + .. ts:def:: OrderInput + + // For now, only token inputs are supported. + type OrderInput = OrderInputToken; + + .. ts:def:: OrderInputToken + + interface OrderInputToken { + + // Token input. + type: "token"; + + // Token family slug as configured in the merchant backend. Slug is unique + // across all configured tokens of a merchant. + token_family_slug: string; + + // How many units of the input are required. + // Defaults to 1 if not specified. Output with count == 0 are ignored by + // the merchant backend. + count?: Integer; + + } + + .. ts:def:: OrderOutput + + type OrderOutput = OrderOutputToken | OrderOutputTaxReceipt; + + .. ts:def:: OrderOutputToken + + interface OrderOutputToken { + + // Token output. + type: "token"; + + // Token family slug as configured in the merchant backend. Slug is unique + // across all configured tokens of a merchant. + token_family_slug: string; + + // How many units of the output are issued by the merchant. + // Defaults to 1 if not specified. Output with count == 0 are ignored by + // the merchant backend. + count?: Integer; + + // When should the output token be valid. Can be specified if the + // desired validity period should be in the future (like selling + // a subscription for the next month). Optional. If not given, + // the validity is supposed to be "now" (time of order creation). + valid_at?: Timestamp; + + } + + .. ts:def:: OrderOutputTaxReceipt + + interface OrderOutputTaxReceipt { + + // Tax receipt output. + type: "tax-receipt"; + + } + + The following `MinimalInventoryProduct` can be provided if the parts of the + order are inventory-based, that is if the `PostOrderRequest` uses + ``inventory_products``. For such products, which must be in the backend's inventory, + the backend can automatically fill in the amount and other details about + the product that are known to it from its ``products`` table. + Note that the ``inventory_products`` will be appended to the + list of ``products`` that the frontend already put into the ``order``. + So if the frontend can sell additional non-inventory products together + with ``inventory_products``. Note that the backend will NOT update + the ``amount`` of the ``order``, so the frontend must already have calculated + the total price --- including the ``inventory_products``. + + .. ts:def:: MinimalInventoryProduct + + // Note that if the frontend does give details beyond these, + // it will override those details (including price or taxes) + // that the backend would otherwise fill in via the inventory. + interface MinimalInventoryProduct { + + // Which product is requested (here mandatory!). + product_id: string; + + // Legacy integer quantity. + // Deprecated since **v25**; + // defaults to 1 if both ``quantity`` and ``unit_quantity`` are absent. + quantity?: Integer; + + // Preferred quantity string using "<integer>[.<fraction>]" syntax. + // @since **v25**; + unit_quantity?: string + + // Money pot to use for this product, overrides value from + // the inventory if given. + // Since **v25**. + product_money_pot?: Integer; + + } + + Supply either ``quantity`` or ``unit_quantity`` when referencing inventory products. If both are + missing the backend assumes a quantity of one. ``unit_quantity`` follows the same decimal-string + rules as ``unit_total_stock``. + + .. ts:def:: PostOrderResponse + + interface PostOrderResponse { + // Order ID of the response that was just created. + order_id: string; + + // Deadline when the offer expires; the customer must pay before. + // @since protocol **v21**. + pay_deadline: Timestamp; + + // Token that authorizes the wallet to claim the order. + // Provided only if "create_token" was set to 'true' + // in the request. + token?: ClaimToken; + } + + .. ts:def:: OutOfStockResponse + + interface OutOfStockResponse { + + // Product ID of an out-of-stock item. + product_id: string; + + // Legacy integer quantity requested. Deprecated; see ``unit_requested_quantity``. + requested_quantity: Integer; + + // Requested quantity using "<integer>[.<fraction>]" syntax with up to six fractional digits. + unit_requested_quantity: string; + + // Legacy integer availability (must be below ``requested_quantity``). + available_quantity: Integer; + + // Available quantity using "<integer>[.<fraction>]" syntax with up to six fractional digits. + unit_available_quantity: string; + + // When do we expect the product to be again in stock? + // Optional, not given if unknown. + restock_expected?: Timestamp; + } + + + .. ts:def:: OrderRefusedErrorDetailResponse + + interface OrderRefusedErrorDetailResponse { + + // Numeric `error code <error-codes>` unique to the condition. + // Will be MERCHANT_PRIVATE_POST_ORDERS_AMOUNT_EXCEEDS_LEGAL_LIMITS). + code: ErrorCode; + + // Human-readable description of the error, i.e. "missing parameter", "commitment violation", ... + // Should give a human-readable hint about the error's nature. Optional, may change without notice! + hint?: string; + + // Detail about why a specific exchange was rejected. + // Note that an exchange that was allowed is not listed. + // It is possible that no exchanges were rejected (in which + // case this array would be empty) and still the operation + // failed because the total of the allowed amounts per + // exchange ended up below the order total. Thus, that + // is ultimately always the cause here (as per the code), + // but the *other* reasons why exchanges might have been + // rejected could be enlightening to the user and are + // thus provided here. + exchange_rejections: ExchangeRejectionDetail; + } + + .. ts:def:: ExchangeRejectionDetail + + interface ExchangeRejectionDetail { + + // Base URL of the rejected exchange + exchange_url: string; + + // Numeric `error code <error-codes>` unique to why + // this exchange was not acceptable. + // Can be MERCHANT_GENERIC_CURRENCY_MISMATCH, + // MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_LEGALLY_REFUSED + // (zero deposit limit, likely KYC required), + // MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE + // (we failed to download /keys from the exchange), + // MERCHANT_POST_ORDERS_ID_PAY_WIRE_METHOD_UNSUPPORTED + // (none of our bank accounts has a compatible wire method) + code: ErrorCode; + + // Human-readable description of the error. + // Should give a human-readable hint about the error's nature. + // Optional, may change without notice! + hint?: string; + + } diff --git a/core/merchant/post-private-otp-devices.rst b/core/merchant/post-private-otp-devices.rst @@ -0,0 +1,46 @@ +.. http:post:: [/instances/$INSTANCE]/private/otp-devices + + This is used to associate an OTP device with an instance. + + **Required permission:** ``otp-devices-write`` + + **Request:** + + The request must be a `OtpDeviceAddDetails`. + + **Response:** + + :http:statuscode:`204 No content`: + The creation of the template is successful. + :http:statuscode:`404 Not found`: + The merchant instance is unknown or it is not in our data. + + **Details:** + + .. ts:def:: OtpDeviceAddDetails + + interface OtpDeviceAddDetails { + + // Device ID to use. + otp_device_id: string; + + // Human-readable description for the device. + otp_device_description: string; + + // A key encoded with RFC 3548 Base32. + // IMPORTANT: This is not using the typical + // Taler base32-crockford encoding. + // Instead it uses the RFC 3548 encoding to + // be compatible with the TOTP standard. + otp_key: string; + + // Algorithm for computing the POS confirmation. + // "NONE" or 0: No algorithm (no pos confirmation will be generated) + // "TOTP_WITHOUT_PRICE" or 1: Without amounts (typical OTP device) + // "TOTP_WITH_PRICE" or 2: With amounts (special-purpose OTP device) + // The "string" variants are supported @since protocol **v7**. + otp_algorithm: Integer | string; + + // Counter for counter-based OTP devices. + otp_ctr?: Integer; + } diff --git a/core/merchant/post-private-pots.rst b/core/merchant/post-private-pots.rst @@ -0,0 +1,41 @@ +.. http:post:: [/instances/$INSTANCES]/private/pots + + This is used to create a pot. + + **Required permission:** ``pots-write`` + + **Request:** + + The request must be a `PotAddRequest`. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully added a new pot. Returns a `PotAddedResponse`. + + :http:statuscode:`404 Not found`: + The merchant instance is unknown. + + **Details:** + + .. ts:def:: PotAddRequest + + interface PotAddRequest { + + // Description of the pot. Possibly included + // in the pot message. + description: string; + + // Name of the pot. Must be unique per instance. + pot_name: string; + + } + + .. ts:def:: PotAddedResponse + + interface PotAddedResponse { + + // Unique ID for the pot. + pot_serial_id: Integer; + + } diff --git a/core/merchant/post-private-products-PRODUCT_ID-lock.rst b/core/merchant/post-private-products-PRODUCT_ID-lock.rst @@ -0,0 +1,63 @@ +.. http:post:: [/instances/$INSTANCE]/private/products/$PRODUCT_ID/lock + + This is used to lock a certain quantity of the product for a limited + duration while the customer assembles a complete order. Note that + frontends do not have to "unlock", they may rely on the timeout as + given in the ``duration`` field. Re-posting a lock with a different + ``duration`` or ``quantity`` updates the existing lock for the same UUID + and does not result in a conflict. + + Unlocking by using a ``quantity`` of zero is + optional but recommended if customers remove products from the + shopping cart. Note that actually POSTing to ``/orders`` with set + ``inventory_products`` and using ``lock_uuids`` will **transition** the + lock to the newly created order (which may have a different ``duration`` + and ``quantity`` than what was requested in the lock operation). + If an order is for fewer items than originally locked, the difference + is automatically unlocked. + + **Required permission:** ``products-lock`` + + **Request:** + + The request must be a `LockRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully locked (or unlocked) the requested ``quantity``. + :http:statuscode:`404 Not found`: + The backend has does not know this product. + :http:statuscode:`410 Gone`: + The backend does not have enough of product in stock. Returns an `OutOfStockResponse`. + + **Details:** + + .. ts:def:: LockRequest + + interface LockRequest { + + // UUID that identifies the frontend performing the lock + // Must be unique for the lifetime of the lock. + lock_uuid: string; + + // How long does the frontend intend to hold the lock? + duration: RelativeTime; + + // Legacy integer quantity to lock. Deprecated; defaults to 1 if both + // ``quantity`` and ``unit_quantity`` are absent. + quantity?: Integer; + + // Preferred way to express the requested quantity using "<integer>[.<fraction>]" syntax. + unit_quantity?: string; + + } + + At least one of ``quantity`` or ``unit_quantity`` must be supplied; omitting both defaults to a + quantity of one. ``unit_quantity`` follows the same decimal-string format described for + ``unit_total_stock``. + + .. note:: + + The ``GNUNET_CRYPTO_random_timeflake()`` C API can be used + to generate such timeflakes for clients written in C. diff --git a/core/merchant/post-private-products.rst b/core/merchant/post-private-products.rst @@ -0,0 +1,151 @@ +.. http:post:: [/instances/$INSTANCE]/private/products + + This is used to add a product to the inventory. + + **Required permission:** ``products-write`` + + **Request:** + + The request must be a `ProductAddDetailRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The backend has successfully expanded the inventory. + :http:statuscode:`404 Not found`: + The instance, category, product group or money pot specified are + unknown. Possible error ``code`` values are thus: + ``TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN`` (instance unknown), + ``TALER_EC_MERCHANT_GENERIC_PRODUCT_GROUP_UNKNOWN`` (product group unknown) + ``TALER_EC_MERCHANT_GENERIC_MONEY_POT_UNKNOWN`` (money pot unknown), + ``TALER_EC_MERCHANT_GENERIC_CATEGORY_UNKNOWN`` + (category unknown, specific category is given in the details). + + :http:statuscode:`409 Conflict`: + The backend already knows a product with this product ID, + but with different details. Returned with a ``code`` of + ``TALER_EC_MERCHANT_PRIVATE_POST_PRODUCTS_CONFLICT_PRODUCT_EXISTS``. + + **Details:** + + .. ts:def:: ProductAddDetailRequest + + interface ProductAddDetailRequest { + + // Product ID to use. + product_id: string; + + // Human-readable product name. + // Since API version **v20**. Optional only for + // backwards-compatibility, should be considered mandatory + // moving forward! + product_name?: string; + + // Human-readable product description. + description: string; + + // Map from IETF BCP 47 language tags to localized descriptions. + description_i18n?: { [lang_tag: string]: string }; + + // Categories into which the product belongs. + // Used in the POS-endpoint. + // Since API version **v16**. + categories?: Integer[]; + + // Unit in which the product is measured (liters, kilograms, packages, etc.). + unit: string; + + // Optional override to control whether fractional quantities are permitted. + // Defaults to the policy implied by ``unit``. + unit_allow_fraction?: boolean; + + // Override for the fractional precision level (0-6). Only relevant if + // ``unit_allow_fraction`` is true. Defaults come from ``unit``. + unit_precision_level?: Integer; + + // Preferred way to express inventory counts using "<integer>[.<fraction>]" syntax. + // Use "-1" for unlimited stock. Required unless ``total_stock`` is provided. + unit_total_stock?: DecimalQuantity; + + // Legacy stock counter. Deprecated, use ``unit_total_stock`` instead. + // Still required when ``unit_total_stock`` is omitted. + total_stock?: Integer; + + // Preferred way to express the per-unit price of the product. Supply at least one entry; + // the first entry must match ``price``. + // The price given MUST include applicable taxes if ``price_is_net`` + // is false, and MUST exclude applicable taxes if ``price_is_net`` + // is true. + // Zero implies that the product is not sold separately or that the price must be supplied + // by the frontend. + // Each entry must use a distinct currency. + // Since API version **v25**. + // Currency uniqueness enforced since protocol **v25**. + unit_price?: Amount[]; + + // True if the price(s) given are a net prices, false if they are + // gross prices. + // Since protocol **vTAXES**. + price_is_net?: boolean; + + // Legacy price field. + // Deprecated since **v25**; + // when present it must match the first element of ``unit_price``. + price?: Amount; + + // An optional base64-encoded product image. + image?: ImageDataUrl; + + // A list of taxes paid by the merchant for one unit of this product. + taxes?: Tax[]; + + // Identifies where the product is in stock. + address?: Location; + + // Identifies when we expect the next restocking to happen. + next_restock?: Timestamp; + + // Minimum age buyer must have (in years). Default is 0. + minimum_age?: Integer; + + // Product group the product belongs to. 0 and missing both + // means default. + // Since **v25**. + product_group_id?: Integer; + + // Money pot revenue on the product should be accounted in. + // 0 and missing both mean no money pot (revenue accounted + // in money pot of the overall order or not at all). + // Since **v25**. + money_pot_id?: Integer; + + } + + Clients SHOULD migrate to the new ``unit_*`` fields and treat ``total_stock`` and ``price`` + as deprecated compatibility shims. If both the legacy and the new representation are supplied, + their values must match. Omitting both ``unit_total_stock`` and ``total_stock`` (or both + ``unit_price`` and ``price``) results in a ``400 Bad Request``. When only ``price`` is given, + the backend treats it as a one-element ``unit_price`` array. + + ``unit_total_stock`` uses a fixed-point decimal string in the form ``INTEGER[.FRACTION]`` with + at most six fractional digits. Scientific notation or special values such as ``NaN`` are not + accepted. Supply ``"-1"`` to represent unlimited stock. See + :ref:`DecimalQuantity <decimal-quantity>`. + + Fractional behaviour defaults to the value of ``unit``. The backend disables fractions for + ``Piece``, ``Set``, ``Custom``, ``WeightUnitMg`` and ``SizeUnitMm``. Other predefined units + allow fractional quantities with the following default precision levels: + + - Precision ``1``: ``WeightUnitG``, ``SizeUnitCm``, ``SurfaceUnitMm2``, ``VolumeUnitMm3``. + - Precision ``2``: ``WeightUnitOunce``, ``SizeUnitInch``, ``SurfaceUnitCm2``, + ``VolumeUnitInch3``, ``VolumeUnitOunce``, ``TimeUnitHour``, ``TimeUnitMonth``. + - Precision ``3``: ``WeightUnitTon``, ``WeightUnitKg``, ``WeightUnitPound``, ``SizeUnitM``, + ``SizeUnitDm``, ``SizeUnitFoot``, ``SurfaceUnitDm2``, ``SurfaceUnitFoot2``, ``VolumeUnitCm3``, + ``VolumeUnitLitre``, ``VolumeUnitGallon``, ``TimeUnitSecond``, ``TimeUnitMinute``, + ``TimeUnitDay``, ``TimeUnitWeek``. + - Precision ``4``: ``SurfaceUnitM2``, ``SurfaceUnitInch2``, ``TimeUnitYear``. + - Precision ``5``: ``VolumeUnitDm3``, ``VolumeUnitFoot3``. + - Precision ``6``: ``VolumeUnitM3``. + + Integrations can override these defaults by explicitly setting ``unit_allow_fraction`` and/or + ``unit_precision_level``. diff --git a/core/merchant/post-private-reports.rst b/core/merchant/post-private-reports.rst @@ -0,0 +1,60 @@ +.. http:post:: [/instances/$INSTANCES]/private/reports + + This is used to schedule the generation of periodic reports. + + **Required permission:** ``reports-write`` + + **Request:** + + The request must be a `ReportAddRequest`. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully added a new report. Returns a `ReportAddedResponse`. + + :http:statuscode:`404 Not found`: + The merchant instance is unknown. + :http:statuscode:`501 Not implemented`: + The report generator specified in the ``program_section`` is not configured. + + **Details:** + + .. ts:def:: ReportAddRequest + + interface ReportAddRequest { + + // Description of the report. Possibly included + // in the report message. + description: string; + + // Merchant backend configuration section specifying + // the program to use to transmit the report + program_section: string; + + // Mime-type to request from the data source. + mime_type: string; + + // Base URL to request the data from. + data_source: string; + + // Address where the report program should send + // the report. + target_address: string; + + // Report frequency + report_frequency: RelativeTime; + + // Report frequency shift. Defaults to zero if missing. + report_frequency_shift?: RelativeTime; + + } + + .. ts:def:: ReportAddedResponse + + interface ReportAddedResponse { + + // Unique ID for the report. + report_serial_id: Integer; + + } diff --git a/core/merchant/post-private-templates.rst b/core/merchant/post-private-templates.rst @@ -0,0 +1,136 @@ +.. http:post:: [/instances/$INSTANCE]/private/templates + + This is used to create a template. + + **Required permission:** ``templates-write`` + + **Request:** + + The request must be a `TemplateAddDetails`. + + + **Response:** + + :http:statuscode:`204 No content`: + The creation of the template is successful. + :http:statuscode:`404 Not found`: + The merchant instance is unknown or it is not in our data. + + **Details:** + + + .. ts:def:: TemplateAddDetails + + interface TemplateAddDetails { + + // Template ID to use. + template_id: string; + + // Human-readable description for the template. + template_description: string; + + // OTP device ID. + // This parameter is optional. + otp_id?: string; + + // Fixed contract information for orders created from + // this template. + template_contract: TemplateContractDetails; + + // Key-value pairs matching a subset of the + // fields from ``template_contract`` that are + // user-editable defaults for this template. + // Since protocol **v13**. + editable_defaults?: Object; + } + + + .. ts:def:: TemplateContractDetails + + type TemplateContractDetails = (TemplateContractFixedOrder | TemplateContractInventoryCart | TemplateContractPaivana) & TemplateContractCommon; + + .. ts:def:: TemplateContractCommon + + interface TemplateContractCommon { + // Template type to apply. Defaults to "fixed-order" if omitted. + // Prescribes which interface has to be followed + // Since protocol **v25**. + template_type?: TemplateType; + + // Human-readable summary for the template. + summary?: string; + + // Required currency for payments to the template. + // This parameter is optional and should not be present + // if "amount" is given. + currency?: string; + + // The time the customer need to pay before his order will be deleted. + // It is deleted if the customer did not pay and if the duration is over. + pay_duration?: RelativeTime; + + // Minimum age buyer must have (in years). Default is 0. + minimum_age?: Integer; + + // Inventory-cart: request a tip during instantiation. + // Since protocol **v25**. + request_tip?: boolean; + } + + .. ts:def:: TemplateType + + enum TemplateType { + FIXED_ORDER = "fixed-order", + INVENTORY_CART = "inventory-cart", + PAIVANA = "paivana" + } + + .. ts:def:: TemplateContractFixedOrder + + interface TemplateContractFixedOrder { + + // The price is imposed by the merchant and cannot be changed by the customer. + // This parameter is optional. + amount?: Amount; + + } + + .. ts:def:: TemplateContractInventoryCart + + interface TemplateContractInventoryCart { + + // Inventory-cart: allow any inventory item to be selected. + // Since protocol **v25**. + selected_all?: boolean; + + // Inventory-cart: only products in these categories are selectable. + // Since protocol **v25**. + selected_categories?: Integer[]; + + // Inventory-cart: only these products are selectable. + // Since protocol **v25**. + selected_products?: string[]; + + // Inventory-cart: require exactly one selection entry. + // Since protocol **v25**. + choose_one?: boolean; + + // Inventory-cart: backend-provided payload with selectable data. + // Only present in ``GET /templates/$TEMPLATE_ID`` responses. + // Since protocol **v25**. + inventory_payload?: InventoryPayload; + } + + .. ts:def:: TemplateContractPaivana + + interface TemplateContractPaivana { + + // Regular expression over URLs for which + // this template is valid. + // Optional, if not given all URLs are accepted. + // Since protocol **v25**. + website_regex?: string; + + // Methods to pay for the contract. + choices: OrderChoice[]; + } diff --git a/core/merchant/post-private-token.rst b/core/merchant/post-private-token.rst @@ -0,0 +1,70 @@ +.. http:post:: [/instances/$INSTANCE]/private/token + + Retrieve an access token for the merchant API for instance + ``$INSTANCE``. + When accessed with a Bearer token for authentication, the token + must have scope ``token-refresh`` and the requested scope must be a subset + of the scope of the token. + When accessed with Basic authentication the instance password must be provided + along with ``$INSTANCE`` as username. + + + **Required permission:** ``token-refresh`` if accessed using a Bearer token. + + **Request:** + + The request must be a `LoginTokenRequest`. + + **Response:** + + :http:statuscode:`200 Ok`: + The backend is returning the access token in a + `LoginTokenSuccessResponse`. + :http:statuscode:`202 Accepted`: + 2FA is required for this operation. + This returns the `ChallengeResponse`. @since **v21** + + **Details:** + + .. ts:def:: LoginTokenRequest + + interface LoginTokenRequest { + // Scope of the token (which kinds of operations it will allow) + scope: "readonly" | "write" | "all" | "order-simple" | "order-pos" | "order-mgmt" | "order-full"; + + // Server may impose its own upper bound + // on the token validity duration + duration?: RelativeTime; + + // Optional token description + description?: string; + + // Can this token be refreshed? + // Defaults to false. Deprecated since **v19**. + // Use ":refreshable" scope prefix instead. + refreshable?: boolean; + } + + .. ts:def:: LoginTokenSuccessResponse + + interface LoginTokenSuccessResponse { + // deprecated since v19. See access_token + token: string; + + // The login token that can be used to access resources + // that are in scope for some time. Must be prefixed + // with "Bearer " when used in the "Authorization" HTTP header. + // Will already begin with the RFC 8959 prefix. + // **Since v19** + access_token: string; + + // Scope of the token (which kinds of operations it will allow) + scope: "readonly" | "write" | "all" | "order-simple" | "order-pos" | "order-mgmt" | "order-full"; + + // Server may impose its own upper bound + // on the token validity duration + expiration: Timestamp; + + // Can this token be refreshed? + refreshable: boolean; + } diff --git a/core/merchant/post-private-tokenfamilies.rst b/core/merchant/post-private-tokenfamilies.rst @@ -0,0 +1,76 @@ +.. http:post:: [/instances/$INSTANCES]/private/tokenfamilies + + This is used to create a token family. + + **Required permission:** ``tokenfamilies-write`` + + **Request:** + + The request must be a `TokenFamilyCreateRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The token family was created successfully. + + :http:statuscode:`404 Not found`: + The merchant backend is unaware of the instance. + + **Details:** + + .. ts:def:: TokenFamilyCreateRequest + + interface TokenFamilyCreateRequest { + + // Identifier for the token family consisting of unreserved characters + // according to RFC 3986. + slug: string; + + // Human-readable name for the token family. + name: string; + + // Human-readable description for the token family. + description: string; + + // Optional map from IETF BCP 47 language tags to localized descriptions. + description_i18n?: { [lang_tag: string]: string }; + + // Additional meta data, such as the ``trusted_domains`` + // or ``expected_domains``. Depends on the ``kind``. + extra_data?: object; + + // Start time of the token family's validity period. + // If not specified, merchant backend will use the current time. + valid_after?: Timestamp; + + // End time of the token family's validity period. + valid_before: Timestamp; + + // Validity duration of an issued token. + duration: RelativeTime; + + // Rounding granularity for the start validity of keys. + // The desired time is rounded down to a multiple of this + // granularity and then the ``start_offset`` is added to + // compute the actual start time of the token keys' validity. + // The end is then computed by adding the ``duration``. + // Must be 1 minute, 1 hour, 1 day, 1 week, 30 days, 90 days + // or 365 days (1 year). + validity_granularity: RelativeTime; + + // Offset to subtract from the start time rounded to ``validity_granularity`` + // to compute the actual start time for a key. + // Default is zero. + start_offset: RelativeTime; + + // Kind of the token family. + kind: TokenFamilyKind; + + } + + .. ts:def:: TokenFamilyKind + + enum TokenFamilyKind { + Discount = "discount", + Subscription = "subscription", + } diff --git a/core/merchant/post-private-transfers.rst b/core/merchant/post-private-transfers.rst @@ -0,0 +1,39 @@ +.. http:post:: [/instances/$INSTANCE]/private/transfers + + Inform the backend over an incoming wire transfer. The backend should inquire about the details with the exchange and mark the respective orders as wired. Note that the request will fail if the WTID is not unique (which should be guaranteed by a correct exchange). + This request is idempotent and should also be used to merely re-fetch the + transfer information from the merchant's database (assuming we got a non-error + response from the exchange before). + + **Required permission:** ``transfers-write`` + + **Request:** + + The request must provide `transfer information <TransferInformation>`. + + **Response:** + + :http:statuscode:`204 No content`: + The wire transfer is now confirmed at the merchant. + :http:statuscode:`404 Not found`: + The instance or account are unknown to the exchange. + :http:statuscode:`409 Conflict`: + The wire transfer identifier is already known to us, but for a different amount. + + **Details:** + + .. ts:def:: TransferInformation + + interface TransferInformation { + // How much was wired to the merchant (minus fees). + credit_amount: Amount; + + // Raw wire transfer identifier identifying the wire transfer (a base32-encoded value). + wtid: WireTransferIdentifierRawP; + + // Full payto://-URI of the bank account that received the wire transfer. + payto_uri: string; + + // Base URL of the exchange that made the wire transfer. + exchange_url: string; + } diff --git a/core/merchant/post-private-units.rst b/core/merchant/post-private-units.rst @@ -0,0 +1,44 @@ +.. http:post:: [/instances/$INSTANCE]/private/units + + Create a custom measurement unit or reactivate a previously disabled one. + + **Required permission:** ``units-write`` + + **Request:** + + The request must be a `UnitAddRequest`. + + **Response:** + + :http:statuscode:`204 No content`: + The backend added the unit. + :http:statuscode:`409 Conflict`: + A built-in unit with the same short name already exists. + + .. ts:def:: UnitAddRequest + + interface UnitAddRequest { + // Short identifier to reference the unit from products and orders. + unit: string; + + // Human-readable long label (e.g. "kilogram"). + unit_name_long: string; + + // Human-readable short label (e.g. "kg"). + unit_name_short: string; + + // Optional translations for the long label keyed by BCP 47 language tags. + unit_name_long_i18n?: { [lang_tag: string]: string }; + + // Optional translations for the short label keyed by BCP 47 language tags. + unit_name_short_i18n?: { [lang_tag: string]: string }; + + // Defaults to false; set to true to enable fractional quantities. + unit_allow_fraction?: boolean; + + // Fractional precision (0-6). Ignored when ``unit_allow_fraction`` is false. + unit_precision_level?: Integer; + + // Defaults to true. + unit_active?: boolean; + } diff --git a/core/merchant/post-private-webhooks.rst b/core/merchant/post-private-webhooks.rst @@ -0,0 +1,43 @@ +.. http:post:: [/instances/$INSTANCES]/private/webhooks + + This is used to create a webhook. + + **Required permission:** ``webhooks-write`` + + **Request:** + + The request must be a `WebhookAddDetails`. + + **Response:** + + :http:statuscode:`204 No content`: + The creation of the webhook is successsful. + + :http:statuscode:`404 Not found`: + The merchant instance is unknown or it not in our data. + + **Details:** + + .. ts:def:: WebhookAddDetails + + interface WebhookAddDetails { + + // Webhook ID to use. + webhook_id: string; + + // The event of the webhook: why the webhook is used. + event_type: WebhookEventType; + + // URL of the webhook where the customer will be redirected. + url: string; + + // Method used by the webhook + http_method: string; + + // Header template of the webhook + header_template?: string; + + // Body template by the webhook + body_template?: string; + + } diff --git a/core/merchant/post-reports-REPORT_ID.rst b/core/merchant/post-reports-REPORT_ID.rst @@ -0,0 +1,31 @@ +.. http:post:: /reports/$REPORT_ID + + This is used to request the generation of a periodic report. + It is used internally by the ``taler-merchant-report-generator``. + The endpoint itself is unauthenticated, but the ``report-token`` + serves to authorize the request. + + **Request:** + + The request must be a `ReportGenerationRequest`. + + **Response:** + + :http:statuscode:`200 OK`: + The backend has successfully added a new report. + Details returned (including the content type) depend + fully on the type of report that was requested. + + :http:statuscode:`404 Not found`: + The report ID *or* the report token are unknown. + + **Details:** + + .. ts:def:: ReportGenerationRequest + + interface ReportGenerationRequest { + + // Report token authorizing the report generation. + report_token: ShortHashCode; + + } diff --git a/core/merchant/post-templates-TEMPLATE_ID.rst b/core/merchant/post-templates-TEMPLATE_ID.rst @@ -0,0 +1,89 @@ +.. http:post:: [/instances/$INSTANCES]/templates/$TEMPLATE_ID + + This using template can be modified by everyone and will be used to create order. + + + **Request:** + + The request must be a `UsingTemplateDetailsRequest` and we accept JSON application and URL encoded. + + **Response:** + + The response is exactly the same type of response as when + creating an order using :ref:`POST /private/orders <post-order>`. + + **Details:** + + .. ts:def:: UsingTemplateDetailsRequest + + type UsingTemplateDetailsRequest = (UsingTemplateFixedOrderRequest | UsingTemplateInventoryCartRequest | UsingTemplatePaivanaRequest) & UsingTemplateCommonRequest; + + .. ts:def:: UsingTemplateCommonRequest + + interface UsingTemplateCommonRequest { + + // Type of the template being instantiated. + // Possible values include "fixed-order", + // "inventory-cart" and "paivana". + // Since protocol **v25**. + // Defaults to "fixed-order" while supporting previous + // protocol versions. + template_type: string; + + // Summary to use in the contract. Only if + // not already specified by the template. + summary?: string; + + // The amount to be paid, including tip. + amount?: Amount; + + // Optional tip amount. Must match the currency of ``amount`` or the + // fixed template currency. + // Since protocol **v25**. + tip?: Amount; + + } + + .. ts:def:: UsingTemplateFixedOrderRequest + + interface UsingTemplateFixedOrderRequest { + template_type: "fixed-order"; + + } + + .. ts:def:: UsingTemplateInventoryCartRequest + + interface UsingTemplateInventoryCartRequest { + template_type: "inventory-cart"; + + // Inventory-cart: selected products and quantities. + // Since protocol **v25**. + inventory_selection?: InventorySelectionEntry[]; + } + + .. ts:def:: InventorySelectionEntry + + interface InventorySelectionEntry { + // Inventory product to add. + product_id: string; + + // Quantity in "<integer>[.<fraction>]" form using the product unit rules. + quantity: DecimalQuantity; + } + + .. ts:def:: UsingTemplatePaivanaRequest + + interface UsingTemplatePaivanaRequest { + template_type: "paivana"; + + // URL of the Paivana-protected website to be + // accessed. Will become the fulfillment URL in + // the contract. + website: string; + + // Client Paivana ID to grant access to. + // This becomes the "session_id" for session-based + // access control. + paivana_id: string; + + }