summaryrefslogtreecommitdiff
path: root/core/api-merchant.rst
diff options
context:
space:
mode:
Diffstat (limited to 'core/api-merchant.rst')
-rw-r--r--core/api-merchant.rst2439
1 files changed, 1809 insertions, 630 deletions
diff --git a/core/api-merchant.rst b/core/api-merchant.rst
index 469ce766..c56cff0c 100644
--- a/core/api-merchant.rst
+++ b/core/api-merchant.rst
@@ -1,6 +1,6 @@
..
This file is part of GNU TALER.
- Copyright (C) 2014, 2015, 2016, 2017 Taler Systems SA
+ Copyright (C) 2014-2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -23,45 +23,680 @@
Merchant Backend API
====================
+WARNING: This document describes the version 1 of the merchant backend
+API, which is NOT yet implemented in Git master!
+
+The ``*/private/*`` endpoints are only supposed to be exposed
+to the merchant internally, and must not be exposed on the
+Internet.
+
+Most endpoints given here can be prefixed by a base URL that includes the
+specific instance selected (BASE_URL/instances/$INSTANCE/). If
+``/instances/`` is missing from the request path, the ``default`` instance is
+used.
+
.. contents:: Table of Contents
+
+-------------------------
+Getting the configuration
+-------------------------
+
+.. http:get:: /config
+
+ Return the protocol version and currency supported by this merchant backend.
+
+ **Response:**
+
+ :status 200 OK:
+ The exchange accepted all of the coins. The body is a `VersionResponse`.
+
+ .. ts:def:: VersionResponse
+
+ interface VersionResponse {
+ // 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;
+
+ // Currency supported by this backend.
+ currency: string;
+
+ }
+
+
+--------------------------
+Dynamic Merchant Instances
+--------------------------
+
+.. _instances:
+.. http:get:: /private/instances
+
+ This is used to return the list of all the merchant instances
+
+ **Response:**
+
+ :status 200 OK:
+ The backend has successfully returned the list of instances stored. Returns
+ a `InstancesResponse`.
+
+ .. 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 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[];
+
+ }
+
+
+.. http:post:: /private/instances
+
+ This request will be used to create a new merchant instance in the backend.
+
+ **Request:**
+
+ The request must be a `InstanceConfigurationMessage`.
+
+ **Response:**
+
+ :status 204 No content:
+ The backend has successfully created the instance.
+ :status 409 Conflict:
+ This instance already exists, but with other configuration options.
+ Use "PATCH" to update an instance configuration.
+
+ .. ts:def:: InstanceConfigurationMessage
+
+ interface InstanceConfigurationMessage {
+ // The URI where the wallet will send coins. A merchant may have
+ // multiple accounts, thus this is an array. Note that by
+ // removing URIs from this list
+ payto_uris: string[];
+
+ // Name of the merchant instance to create (will become $INSTANCE).
+ id: string;
+
+ // Merchant name corresponding to this instance.
+ name: string;
+
+ // 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;
+
+ // Maximum wire fee this instance is willing to pay.
+ // Can be overridden by the frontend on a per-order basis.
+ default_max_wire_fee: Amount;
+
+ // Default factor for wire fee amortization calculations.
+ // Can be overriden by the frontend on a per-order basis.
+ default_wire_fee_amortization: Integer;
+
+ // Maximum deposit fee (sum over all coins) this instance is willing to pay.
+ // Can be overridden by the frontend on a per-order basis.
+ default_max_deposit_fee: Amount;
+
+ // 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 current
+ // time when we generate the advisory execution time for the exchange.
+ default_wire_transfer_delay: RelativeTime;
+
+ // If the frontend does NOT specify a payment deadline, how long should
+ // offers we make be valid by default?
+ default_pay_delay: RelativeTime;
+
+ }
+
+
+.. http:patch:: /private/instances/$INSTANCE
+
+ Update the configuration of a merchant instance.
+
+ **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:**
+
+ :status 204 No content:
+ The backend has successfully created the instance.
+ :status 404 Not found:
+ This instance is unknown and thus cannot be reconfigured.
+
+ .. ts:def:: InstanceReconfigurationMessage
+
+ interface InstanceReconfigurationMessage {
+ // The URI where the wallet will send coins. A merchant may have
+ // multiple accounts, thus this is an array. Note that by
+ // removing URIs from this list
+ payto_uris: string[];
+
+ // Merchant name corresponding to this instance.
+ name: string;
+
+ // 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;
+
+ // Maximum wire fee this instance is willing to pay.
+ // Can be overridden by the frontend on a per-order basis.
+ default_max_wire_fee: Amount;
+
+ // Default factor for wire fee amortization calculations.
+ // Can be overriden by the frontend on a per-order basis.
+ default_wire_fee_amortization: Integer;
+
+ // Maximum deposit fee (sum over all coins) this instance is willing to pay.
+ // Can be overridden by the frontend on a per-order basis.
+ default_max_deposit_fee: Amount;
+
+ // 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 current
+ // time when we generate the advisory execution time for the exchange.
+ default_wire_transfer_delay: RelativeTime;
+
+ // If the frontend does NOT specify a payment deadline, how long should
+ // offers we make be valid by default?
+ default_pay_delay: RelativeTime;
+
+ }
+
+
+.. http:get:: /private/instances/$INSTANCE
+
+ This is used to query a specific merchant instance.
+
+ **Response:**
+
+ :status 200 OK:
+ The backend has successfully returned the list of instances stored. Returns
+ a `QueryInstancesResponse`.
+
+ .. ts:def:: QueryInstancesResponse
+
+ interface QueryInstancesResponse {
+ // The URI where the wallet will send coins. A merchant may have
+ // multiple accounts, thus this is an array.
+ accounts: MerchantAccount[];
+
+ // Merchant name corresponding to this instance.
+ name: string;
+
+ // 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;
+
+ // Maximum wire fee this instance is willing to pay.
+ // Can be overridden by the frontend on a per-order basis.
+ default_max_wire_fee: Amount;
+
+ // Default factor for wire fee amortization calculations.
+ // Can be overriden by the frontend on a per-order basis.
+ default_wire_fee_amortization: Integer;
+
+ // Maximum deposit fee (sum over all coins) this instance is willing to pay.
+ // Can be overridden by the frontend on a per-order basis.
+ default_max_deposit_fee: Amount;
+
+ // 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 current
+ // time when we generate the advisory execution time for the exchange.
+ default_wire_transfer_delay: RelativeTime;
+
+ // If the frontend does NOT specify a payment deadline, how long should
+ // offers we make be valid by default?
+ default_pay_deadline: RelativeTime;
+
+ }
+
+ .. ts:def:: MerchantAccount
+
+ interface MerchantAccount {
+
+ // 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;
+
+ // true if this account is active,
+ // false if it is historic.
+ active: boolean;
+ }
+
+
+
+.. http:delete:: /private/instances/$INSTANCE
+
+ 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) only deletes the private key
+ and makes the instance unusuable for new orders or payments.
+
+ **Request:**
+
+ :query purge: *Optional*. If set to YES, the instance will be fully
+ deleted. Otherwise only the private key would be deleted.
+
+ **Response**
+
+ :status 204 No content:
+ The backend has successfully removed the instance. The body is empty.
+ :status 404 Not found:
+ The instance is unknown to the backend.
+ :status 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.
+
+
+--------------------
+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.
+
+
+.. http:get:: /private/products
+
+ This is used to return the list of all items in the inventory.
+
+ **Response:**
+
+ :status 200 OK:
+ The backend has successfully returned the inventory. Returns
+ a `InventorySummaryResponse`.
+
+ .. 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;
+
+ }
+
+
+.. http:get:: /private/products/$PRODUCT_ID
+
+ This is used to obtain detailed information about a product in the inventory.
+
+ **Response:**
+
+ :status 200 OK:
+ The backend has successfully returned the inventory. Returns
+ a `ProductDetail`.
+
+ .. ts:def:: ProductDetail
+
+ interface ProductDetail {
+
+ // 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;
+
+ // The price for one ``unit`` of the product. Zero is used
+ // to imply that this product is not sold separately, or
+ // that the price is not fixed, and must be supplied by the
+ // front-end. If non-zero, this price MUST include applicable
+ // taxes.
+ 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[];
+
+ // Number of units of the product in stock in sum in total,
+ // including all existing sales ever. Given in product-specific
+ // units.
+ // A value of -1 indicates "infinite" (i.e. for "electronic" books).
+ total_stock: Integer;
+
+ // 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.
+ address: Location;
+
+ // Identifies when we expect the next restocking to happen.
+ next_restock?: Timestamp;
+
+ }
+
+
+.. http:post:: /private/products
+
+ This is used to add a product to the inventory.
+
+ **Request:**
+
+ The request must be a `ProductAddDetail`.
+
+ **Response:**
+
+ :status 204 No content:
+ The backend has successfully expanded the inventory.
+ :status 409 Conflict:
+ The backend already knows a product with this product ID, but with different details.
+
+
+ .. ts:def:: ProductAddDetail
+
+ interface ProductAddDetail {
+
+ // product ID to use.
+ product_id: 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;
+
+ // The price for one ``unit`` of the product. Zero is used
+ // to imply that this product is not sold separately, or
+ // that the price is not fixed, and must be supplied by the
+ // front-end. If non-zero, this price MUST include applicable
+ // taxes.
+ 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[];
+
+ // Number of units of the product in stock in sum in total,
+ // including all existing sales ever. Given in product-specific
+ // units.
+ // A value of -1 indicates "infinite" (i.e. for "electronic" books).
+ total_stock: Integer;
+
+ // Identifies where the product is in stock.
+ address: Location;
+
+ // Identifies when we expect the next restocking to happen.
+ next_restock?: Timestamp;
+
+ }
+
+
+
+.. http:patch:: /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".
+
+ **Request:**
+
+ The request must be a `ProductPatchDetail`.
+
+ **Response:**
+
+ :status 204 No content:
+ The backend has successfully expanded the inventory.
+
+
+ .. ts:def:: ProductPatchDetail
+
+ interface ProductPatchDetail {
+
+ // 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;
+
+ // The price for one ``unit`` of the product. Zero is used
+ // to imply that this product is not sold separately, or
+ // that the price is not fixed, and must be supplied by the
+ // front-end. If non-zero, this price MUST include applicable
+ // taxes.
+ 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[];
+
+ // Number of units of the product in stock in sum in total,
+ // including all existing sales ever. Given in product-specific
+ // units.
+ // A value of -1 indicates "infinite" (i.e. for "electronic" books).
+ 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;
+
+ }
+
+
+
+.. http:post:: /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 is
+ optional but recommended if customers remove products from the
+ shopping cart. Note that actually POSTing to ``/orders`` with set
+ ``manage_inventory`` and using ``lock_uuid`` 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.
+
+ **Request:**
+
+ The request must be a `LockRequest`.
+
+ **Response:**
+
+ :status 204 No content:
+ The backend has successfully locked (or unlocked) the requested ``quantity``.
+ :status 404 Not found:
+ The backend has does not know this product.
+ :status 410 Gone:
+ The backend does not have enough of product in stock.
+
+ .. ts:def:: LockRequest
+
+ interface LockRequest {
+
+ // UUID that identifies the frontend performing the lock
+ lock_uuid: UUID;
+
+ // How long does the frontend intend to hold the lock
+ duration: RelativeTime;
+
+ // How many units should be locked?
+ quantity: Integer;
+
+ }
+
+
+.. http:delete:: /private/products/$PRODUCT_ID
+
+ Delete information about a product. Fails if the product is locked by
+ anyone.
+
+ **Response:**
+
+ :status 204 No content:
+ The backend has successfully deleted the product.
+ :status 404 Not found:
+ The backend does not know the instance or the product.
+ :status 409 Conflict:
+ The backend refuses to delete the product because it is locked.
+
+
------------------
-Receiving Payments
+Payment processing
------------------
.. _post-order:
-.. http:post:: /order
+.. http:post:: /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.
- In order to get this URL use :http:get:`/check-payment`. 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.
+ This endpoint does not return a URL to redirect your user to confirm the
+ payment. In order to get this URL use :http:get:/orders/$ORDER_ID. 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.
**Request:**
The request must be a `PostOrderRequest`.
- **Response**
+ :query refund_delay: *Optional*. If set, must be a relative time. The backend will then set the refund deadline to the current time plus the specified delay.
+
+ **Response:**
:status 200 OK:
The backend has successfully created the proposal. The response is a
:ts:type:`PostOrderResponse`.
+ :status 404 Not found:
+ The order given used products from the inventory, but those were not found
+ in the inventory. Or the merchant instance is unknown. Details in the
+ error code. NOTE: no good way to find out which product is not in the
+ inventory, we MAY want to specify that in the reply.
+ :status 410 Gone:
+ The order given used products from the inventory that are out of stock.
+ The reponse is a :ts:type:`OutOfStockResponse`.
+
.. ts:def:: PostOrderRequest
interface PostOrderRequest {
// The order must at least contain the minimal
// order detail, but can override all
- order: MinimalOrderDetail | ContractTerms;
+ order: Order;
+
+ // 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;
+
+ // 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
+ // ``manage_inventory`` is set. Used in case a frontend
+ // reserved quantities of the individual products while
+ // the shopping card 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?: UUID[];
+
}
+ .. ts:def:: Order
+
+ type Order : MinimalOrderDetail | ContractTerms;
+
The following fields must be specified in the ``order`` field of the request. Other fields from
`ContractTerms` are optional, and will override the defaults in the merchant configuration.
@@ -69,17 +704,42 @@ Receiving Payments
interface MinimalOrderDetail {
// Amount to be paid by the customer
- amount: Amount
+ amount: Amount;
// Short summary of the order
summary: string;
// URL that will show that the order was successful after
- // it has been paid for. The wallet will always automatically append
- // the order_id as a query parameter.
+ // it has been paid for. The wallet must always automatically append
+ // the order_id as a query parameter to this URL when using it.
fulfillment_url: string;
}
+ The following fields can be specified if the order is inventory-based.
+ In this case, the backend can compute the amounts from the prices given
+ in the inventory. Note that if the frontend does give more details
+ (towards the ContractTerms), this will override those details
+ (including total price) that would otherwise computed based on information
+ from the inventory.
+
+ type ProductSpecification : (MinimalInventoryProduct | Product);
+
+
+ .. 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;
+
+ // How many units of the product are requested
+ quantity: Integer;
+ }
+
+
.. ts:def:: PostOrderResponse
interface PostOrderResponse {
@@ -88,39 +748,375 @@ Receiving Payments
}
-.. http:get:: /check-payment
+ .. ts:def:: OutOfStockResponse
+
+ interface OutOfStockResponse {
+ // Which items are out of stock?
+ missing_products: OutOfStockEntry;
+ }
+
+ .. ts:def:: OutOfStockEntry
+
+ interface OutOfStockEntry {
+ // Product ID of an out-of-stock item
+ product_id: string;
+
+ // Requested quantity
+ requested_quantity: Integer;
+
+ // Available quantity (must be below ``requested_quanitity``)
+ available_quantity: Integer;
+
+ // When do we expect the product to be again in stock?
+ // Optional, not given if unknown.
+ restock_expected?: Timestamp;
+ }
+
+
+
+.. http:get:: /private/orders
+
+ Returns known orders up to some point in the past.
+
+ **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 date: *Optional.* Time threshold, see ``delta`` for its interpretation. Defaults to the oldest or most recent entry, depending on ``delta``.
+ :query start: *Optional*. Row number threshold, see ``delta`` for its interpretation. Defaults to ``UINT64_MAX``, namely the biggest row id possible in the database.
+ :query delta: *Optional*. takes value of the form ``N (-N)``, so that at most ``N`` values strictly older (younger) than ``start`` and ``date`` are returned. Defaults to ``-20`` to return the last 20 entries (before ``start`` and/or ``date``).
+ :query timeout_ms: *Optional*. Timeout in milli-seconds to wait for additional orders if the answer would otherwise be negative (long polling). Only useful if delta is positive. Note that the merchant MAY still return a response that contains fewer than delta orders.
+
+ **Response:**
+
+ :status 200 OK:
+ The response is an `OrderHistory`.
+
+ .. ts:def:: OrderHistory
+
+ interface OrderHistory {
+ // timestamp-sorted array of all orders matching the query.
+ // The order of the sorting depends on the sign of ``delta``.
+ orders : OrderHistory[];
+ }
+
+
+ .. ts:def:: OrderHistoryEntry
+
+ interface OrderHistoryEntry {
+
+ // order ID of the transaction related to this entry.
+ order_id: string;
+
+ }
+
+
+
+.. http:post:: /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`
+
+ .. ts:def:: ClaimRequest
+
+ interface ClaimRequest {
+ // Nonce to identify the wallet that claimed the order.
+ nonce: string;
+ }
+
+ **Response:**
+
+ :status 200 OK:
+ The client has successfully claimed the order.
+ The response contains the :ref:`contract terms <contract-terms>`.
+ :status 404 Not found:
+ The backend is unaware of the instance or order.
+ :status 409 Conflict:
+ The someone else claimed the same order ID with different nonce before.
+
+
+.. http:post:: /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:**
+
+ :status 200 OK:
+ The exchange accepted all of the coins.
+ The body is a `payment response <PaymentResponse>`.
+ The ``frontend`` should now fullfill the contract.
+ :status 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.
+ :status 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 "406 Not Acceptable", only if this is because of refunds we return 402.)
+ :status 403 Forbidden:
+ One of the coin signatures was not valid.
+ :status 404 Not found:
+ The merchant backend could not find the order or the instance
+ and thus cannot process the payment.
+ :status 406 Not Acceptable:
+ The payment is insufficient (sum is below the required total amount).
+ :status 408 Request Timeout:
+ The backend took too long to process the request. Likely the merchant's connection
+ to the exchange timed out. Try again.
+ :status 409 Conflict:
+ The exchange rejected the payment because a coin was already spent before.
+ The response will include the ``coin_pub`` for which the payment failed,
+ in addition to the response from the exchange to the ``/deposit`` request.
+ :status 410 Gone:
+ The offer has expired and is no longer available.
+ :status 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.
+ :status 424 Failed Dependency:
+ The merchant's interaction with the exchange failed in some way.
+ The client might want to try later again.
+ This includes failures like the denomination key of a coin not being
+ known to the exchange as far as the merchant can tell.
+
+ 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.
+
+ .. ts:def:: PaymentResponse
+
+ interface PaymentResponse {
+ // Signature on ``TALER_PaymentResponsePS`` with the public
+ // key of the merchant instance.
+ sig: EddsaSignature;
+
+ }
+
+ .. ts:def:: PayRequest
+
+ interface PayRequest {
+ // The coins used to make the payment.
+ coins: CoinPaySig[];
+
+ // The session for which the payment is made (or replayed).
+ // Only set for session-based payments.
+ session_id?: string;
+
+ }
+
+ .. ts:def:: CoinPaySig
+
+ export interface CoinPaySig {
+ // Signature by the coin.
+ coin_sig: EddsaSignature;
+
+ // Public key of the coin being spend.
+ coin_pub: EddsaPublicKey;
+
+ // Signature made by the denomination public key.
+ ub_sig: RsaSignature;
+
+ // 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;
+ }
+
+.. _order-abort:
+.. http:post:: /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:**
+
+ :status 200 OK:
+ The merchant accepted the request, and passed it on to the exchange. The body is a
+ a `merchant refund response <MerchantRefundResponse>`. 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.
+ :status 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.
+ :status 403 Forbidden:
+ The ``h_contract`` does not match the $ORDER_ID.
+ :status 404 Not found:
+ The merchant backend could not find the order or the instance
+ and thus cannot process the abort request.
+ :status 408 Request Timeout:
+ The merchant backend took too long getting a response from the exchange.
+ The wallet SHOULD retry soon.
+ :status 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.
+ :status 424 Failed Dependency:
+ The merchant's interaction with the exchange failed in some way.
+ The error from the exchange is included.
+
+ 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.
+
+ .. 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)
+ 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.
+ refunds: RefundResult[];
+ }
+
+ .. ts:def:: RefundResult
+
+ // RefundResult differs from RefundDetail as in this case we
+ // can generate a substantially shorter response.
+ interface RefundResult {
+ // HTTP status of the request to the exchange.
+ exchange_http_status: Integer;
+
+ // The full reply from the exchange. Note only actually
+ // a <RefundSuccess> if the \exchange_http_status\ is 200, otherwise
+ // the error message as defined by the refund API. For
+ // aborts, the \rtransaction_id\ is always 0.
+ exchange_reply: RefundSuccess;
+
+ }
- Check the payment status of an order. If the order exists but is not payed yet,
- the response provides a redirect URL.
- When the user goes to this URL, they will be prompted for payment.
+
+
+.. http:get:: /private/orders/$ORDER_ID
+
+ Merchant checks the payment status of an order. If the order exists but is not payed
+ 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/``).
**Request:**
- :query order_id: order id that should be used for the payment
:query session_id: *Optional*. Session ID that the payment must be bound to. If not specified, the payment is not session-bound.
- :query timeout: *Optional*. Timeout in seconds to wait for a payment if the answer would otherwise be negative (long polling).
+ :query transfer: *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 milli-seconds to wait for a payment if the answer would otherwise be negative (long polling).
**Response:**
- Returns a `CheckPaymentResponse`, whose format can differ based on the status of the payment.
+ :status 200 OK:
+ Returns a `MerchantOrderStatusResponse`, whose format can differ based on the status of the payment.
+ :status 404 Not Found:
+ The order or instance is unknown to the backend.
+ :status 424 Failed dependency:
+ We failed to obtain a response from the exchange (about the wire transfer status).
- .. ts:def:: CheckPaymentResponse
+ .. ts:def:: MerchantOrderStatusResponse
- type CheckPaymentResponse = CheckPaymentPaidResponse | CheckPaymentUnpaidResponse
+ type MerchantOrderStatusResponse = CheckPaymentPaidResponse | CheckPaymentUnpaidResponse
.. ts:def:: CheckPaymentPaidResponse
interface CheckPaymentPaidResponse {
+ // did the customer pay for this contract
paid: true;
// Was the payment refunded (even partially)
refunded: boolean;
- // Amount that was refunded, only present if refunded is true.
- refund_amount?: Amount;
+ // 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_ec: number;
+
+ // 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_hc: number;
+
+ // Total amount that was refunded, 0 if refunded is false.
+ refund_amount: Amount;
// Contract terms
contract_terms: ContractTerms;
+
+ // Ihe wire transfer status from the exchange for this order if available, otherwise empty array
+ wire_details: TransactionWireTransfer[];
+
+ // Reports about trouble obtaining wire transfer details, empty array if no trouble were encountered.
+ wire_reports: TransactionWireReport[];
+
+ // The refund details for this order. One entry per
+ // refunded coin; empty array if there are no refunds.
+ refund_details: RefundDetails[];
}
.. ts:def:: CheckPaymentUnpaidResponse
@@ -134,236 +1130,345 @@ Receiving Payments
// 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;
- }
+ // We do we NOT return the contract terms here because they may not
+ // exist in case the wallet did not yet claim them.
+ }
---------------
-Giving Refunds
---------------
+ .. ts:def:: RefundDetails
+ interface RefundDetails {
-.. http:post:: /refund
+ // Reason given for the refund
+ reason: string;
- Increase the refund amount associated with a given order. The user should be
- redirected to the ``refund_redirect_url`` to trigger refund processing in the wallet.
+ // when was the refund approved
+ timestamp: Timestamp;
- **Request**
+ // Total amount that was refunded (minus a refund fee).
+ amount: Amount;
+ }
- The request body is a `RefundRequest` object.
+ .. ts:def:: TransactionWireTransfer
- **Response**
+ interface TransactionWireTransfer {
- :status 200 OK:
- The refund amount has been increased, the backend responds with a `MerchantRefundResponse`
- :status 400 Bad request:
- The refund amount is not consistent: it is not bigger than the previous one.
+ // Responsible exchange
+ exchange_url: string;
- .. ts:def:: RefundRequest
+ // 32-byte wire transfer identifier
+ wtid: Base32;
- interface RefundRequest {
- // Order id of the transaction to be refunded
- order_id: string;
+ // execution time of the wire transfer
+ execution_time: Timestamp;
- // Amount to be refunded
- refund: Amount;
+ // Total amount that has been wire transfered
+ // to the merchant
+ amount: Amount;
- // Human-readable refund justification
- reason: string;
+ // Was this transfer confirmed by the merchant via the
+ // POST /transfers API, or is it merely claimed by the exchange?
+ confirmed: boolean;
}
- .. ts:def:: MerchantRefundResponse
+ .. ts:def:: TransactionWireReport
- interface MerchantRefundResponse {
- // Public key of the merchant
- merchant_pub: string;
+ interface TransactionWireReport {
+ // Numerical `error code <error-codes>`
+ code: number;
+
+ // Human-readable error description
+ hint: string;
+ // Numerical `error code <error-codes>` from the exchange.
+ exchange_ec: number;
- // Contract terms hash of the contract that
- // is being refunded.
- h_contract_terms: string;
+ // HTTP status code received from the exchange.
+ exchange_hc: number;
- // The signed refund permissions, to be sent to the exchange.
- refund_permissions: MerchantRefundPermission[];
+ // Public key of the coin for which we got the exchange error.
+ coin_pub: CoinPublicKey;
- // URL (handled by the backend) that will
- // trigger refund processing in the browser/wallet
- refund_redirect_url: string;
}
- .. ts:def:: MerchantRefundPermission
- interface MerchantRefundPermission {
- // Amount to be refunded.
+
+.. http:get:: /orders/$ORDER_ID/
+
+ Query the payment status of an order. This endpoint is for the wallet.
+ When the wallet goes to this URL and it is unpaid,
+ they will be prompted for payment.
+
+ **Request:**
+
+ :query h_contract: hash of the order's contract terms (this is used to authenticate the wallet/customer in case $ORDER_ID is guessable). *Mandatory!*
+ :query session_id: *Optional*. Session ID that the payment must be bound to. If not specified, the payment is not session-bound.
+ :query timeout_ms: *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 refund=AMOUNT: *Optional*. Indicates that we are polling for a refund above the given AMOUNT. Only useful in combination with timeout.
+
+ **Response:**
+
+ :status 200 OK:
+ The response is a `PublicPayStatusResponse`, with ``paid`` true.
+ :status 403 Forbidden:
+ The ``h_contract`` does not match the order.
+ :status 404 Not found:
+ The merchant backend is unaware of the order.
+
+ .. ts:def:: PublicPayStatusResponse
+
+ type PublicPayStatusResponse = StatusPaid | StatusUnpaid
+
+ .. ts:def:: StatusPaid
+
+ interface StatusPaid {
+ // Has the payment for this order (ever) been completed?
+ paid: true;
+
+ // Was the payment refunded (even partially, via refund or abort)?
+ refunded: boolean;
+
+ // Amount that was refunded in total.
refund_amount: Amount;
- // Fee for the refund.
- refund_fee: Amount;
+ // Successful refunds for this payment, empty array for none.
+ refunds: RefundStatus[];
- // Public key of the coin being refunded.
- coin_pub: string;
+ // Public key of the merchant.
+ merchant_pub: EddsaPublicKey;
- // Refund transaction ID between merchant and exchange.
- rtransaction_id: number;
+ }
+
+ .. ts:def:: StatusUnpaid
+
+ interface StatusUnpaid {
+ // Has the payment for this order (ever) been completed?
+ paid: false;
+
+ // URI that the wallet must process to complete the payment.
+ taler_pay_uri: 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;
- // Signature made by the merchant over the refund permission.
- merchant_sig: string;
}
---------------------
-Giving Customer Tips
---------------------
+ .. ts:def:: RefundStatus
+ type RefundStatus = RefundFailure | RefundConfirmation
-.. http:post:: /tip-authorize
- Authorize a tip that can be picked up by the customer's wallet by POSTing to
- ``/tip-pickup``. Note that this is simply the authorization step the back
- office has to trigger first. The user should be navigated to the ``tip_redirect_url``
- to trigger tip processing in the wallet.
+ .. ts:def:: RefundFailure
- **Request**
+ // Details about why a refund failed.
+ interface RefundFailure {
- The request body is a `TipCreateRequest` object.
+ // HTTP status of the exchange request, must NOT be 200.
+ exchange_status: Integer;
- **Response**
+ // Taler error code from the exchange reply, if available.
+ exchange_code?: Integer;
- :status 200 OK:
- A tip has been created. The backend responds with a `TipCreateConfirmation`
- :status 404 Not Found:
- The instance is unknown to the backend, expired or was never enabled or
- the reserve is unknown to the exchange or expired (see detailed status
- either being TALER_EC_RESERVE_STATUS_UNKNOWN or
- TALER_EC_TIP_AUTHORIZE_INSTANCE_UNKNOWN or
- TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP or
- TALER_EC_TIP_AUTHORIZE_RESERVE_EXPIRED.
- :status 412 Precondition Failed:
- The tip amount requested exceeds the available reserve balance for tipping.
+ // If available, HTTP reply from the exchange.
+ exchange_reply?: Object;
- .. ts:def:: TipCreateRequest
+ // Refund transaction ID.
+ rtransaction_id: Integer;
- interface TipCreateRequest {
- // Amount that the customer should be tipped
- amount: Amount;
+ // public key of a coin that was refunded
+ coin_pub: EddsaPublicKey;
- // Justification for giving the tip
- justification: string;
+ // Amount that was refunded, including refund fee charged by the exchange
+ // to the customer.
+ refund_amout: Amount;
- // URL that the user should be directed to after tipping,
- // will be included in the tip_token.
- next_url: string;
}
- .. ts:def:: TipCreateConfirmation
+ .. ts:def:: RefundConfirmation
- interface TipCreateConfirmation {
- // Token that will be handed to the wallet,
- // contains all relevant information to accept
- // a tip.
- tip_token: string;
+ // 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 RefundConfirmation {
+
+ // 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_amout: Amount;
- // URL that will directly trigger procesing
- // the tip when the browser is redirected to it
- tip_redirect_url: string;
}
-.. http:post:: /tip-query
+.. http:delete:: /private/orders/$ORDER_ID
- Query the status of a tipping reserve.
+ 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**
+ **Response:**
+
+ :status 204 No content:
+ The backend has successfully deleted the order.
+ :status 404 Not found:
+ The backend does not know the instance or the order.
+ :status 409 Conflict:
+ The backend refuses to delete the order.
+
+
+.. _merchant_refund:
+
+--------------
+Giving Refunds
+--------------
+
+.. http:post:: /private/orders/$ORDER_ID/refund
+
+ Increase the refund amount associated with a given order. The user should be
+ redirected to the ``taler_refund_url`` to trigger refund processing in the wallet.
+
+ **Request:**
+
+ The request body is a `RefundRequest` object.
+
+ **Response:**
:status 200 OK:
- A tip has been created. The backend responds with a `TipQueryResponse`
- :status 412 Precondition Failed:
- The merchant backend instance does not have a tipping reserve configured.
+ The refund amount has been increased, the backend responds with a `MerchantRefundResponse`
+ :status 404 Not found:
+ The order is unknown to the merchant
+ :status 410 Gone:
+ It is too late for aborting, the exchange may have already wired the funds
+ to the merchant.
+ :status 409 Conflict:
+ The refund amount exceeds the amount originally paid
- .. ts:def:: TipQueryResponse
+ .. ts:def:: RefundRequest
- interface TipQueryResponse {
- // Amount still available
- amount_available: Amount;
+ interface RefundRequest {
+ // Amount to be refunded
+ refund: Amount;
- // Amount that we authorized for tips
- amount_authorized: Amount;
+ // Human-readable refund justification
+ reason: string;
+ }
- // Amount that was picked up by users already
- amount_picked_up: Amount;
+ .. ts:def:: MerchantRefundResponse
- // Timestamp indicating when the tipping reserve will expire
- expiration: Timestamp;
+ interface MerchantRefundResponse {
- // Reserve public key of the tipping reserve
- reserve_pub: string;
+ // URL (handled by the backend) that the wallet should access to
+ // trigger refund processing.
+ // taler://refund/[$H_CONTRACT/$AMOUNT????]
+ taler_refund_uri: string;
}
+
------------------------
Tracking Wire Transfers
------------------------
-.. http:get:: /track/transfer
+.. http:post:: /private/transfers
- Provides deposits associated with a given wire transfer.
+ 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).
- **Request**
+ **Request:**
- :query wtid: raw wire transfer identifier identifying the wire transfer (a base32-encoded value)
- :query wire_method: name of the wire transfer method used for the wire transfer
- :query exchange: base URL of the exchange that made the wire transfer
+ The request must provide `transfer information <TransferInformation>`.
**Response:**
:status 200 OK:
The wire transfer is known to the exchange, details about it follow in the body.
- The body of the response is a `TrackTransferResponse`. Note that
- the similarity to the response given by the exchange for a /track/transfer
- is completely intended.
-
+ The body of the response is a `MerchantTrackTransferResponse`.
+ :status 202 Accepted:
+ The exchange provided conflicting information about the transfer. Namely,
+ there is at least one deposit among the deposits aggregated by ``wtid``
+ that accounts for a coin whose
+ details don't match the details stored in merchant's database about the same keyed coin.
+ The response body contains the `ExchangeConflictDetails`.
+ This is indicative of a malicious exchange that claims one thing, but did
+ something else. (With respect to the HTTP specficiation, it is not
+ precisely that we did not act upon the request, more that the usual
+ action of filing the transaction as 'finished' does not apply. In
+ the future, this is a case where the backend actually should report
+ the bad behavior to the auditor -- and then hope for the auditor to
+ resolve it. So in that respect, 202 is the right status code as more
+ work remains to be done for a final resolution.)
:status 404 Not Found:
- The wire transfer identifier is unknown to the exchange.
+ The instance is unknown to the exchange.
+ :status 409 Conflict:
+ The wire transfer identifier is already known to us, but for a different amount,
+ wire method or exchange.
+ :status 424 Failed Dependency:
+ The exchange returned an error when we asked it about the "GET /transfer" status
+ for this wire transfer. Details of the exchange error are returned.
- :status 424 Failed Dependency: The exchange provided conflicting information about the transfer. Namely,
- there is at least one deposit among the deposits aggregated by ``wtid`` that accounts for a coin whose
- details don't match the details stored in merchant's database about the same keyed coin.
- The response body contains the `TrackTransferConflictDetails`.
+ **Details:**
+
+ .. ts:def:: TransferInformation
+
+ interface TransferInformation {
+ // how much was wired to the merchant (minus fees)
+ credit_amount: Amount;
- .. ts:def:: TrackTransferResponse
+ // raw wire transfer identifier identifying the wire transfer (a base32-encoded value)
+ wtid: WireTransferIdentifierRawP;
- interface TrackTransferResponse {
+ // target account that received the wire transfer
+ payto_uri: string;
+
+ // base URL of the exchange that made the wire transfer
+ exchange_url: string;
+ }
+
+ .. ts:def:: MerchantTrackTransferResponse
+
+ interface MerchantTrackTransferResponse {
// Total amount transferred
total: Amount;
// Applicable wire fee that was charged
wire_fee: Amount;
- // public key of the merchant (identical for all deposits)
- merchant_pub: EddsaPublicKey;
-
- // hash of the wire details (identical for all deposits)
- h_wire: HashCode;
-
- // Time of the execution of the wire transfer by the exchange
+ // Time of the execution of the wire transfer by the exchange, according to the exchange
execution_time: Timestamp;
// details about the deposits
- deposits_sums: TrackTransferDetail[];
+ deposits_sums: MerchantTrackTransferDetail[];
- // signature from the exchange made with purpose
- // ``TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT``
- 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. Again given
- // explicitly as the client might otherwise be confused by clock skew as to
- // which signing key was used.
- exchange_pub: EddsaSignature;
}
- .. ts:def:: TrackTransferDetail
+ .. ts:def:: MerchantTrackTransferDetail
- interface TrackTransferDetail {
+ interface MerchantTrackTransferDetail {
// Business activity associated with the wire transferred amount
// ``deposit_value``.
order_id: string;
@@ -376,358 +1481,684 @@ Tracking Wire Transfers
}
- **Details:**
+ .. ts:def:: ExchangeConflictDetails
+
+ type ExchangeConflictDetails = WireFeeConflictDetails | TrackTransferConflictDetails
+
+
+ .. ts:def:: WireFeeConflictDetails
+
+ // Note: this is not the full 'proof' of missbehavior, as
+ // the bogus message from the exchange with a signature
+ // over the 'different' wire fee is missing.
+ //
+ // This information is NOT provided by the current implementation,
+ // because this would be quite expensive to generate and is
+ // hardly needed _here_. Once we add automated reports for
+ // the Taler auditor, we need to generate this data anyway
+ // and should probably return it here as well.
+ interface WireFeeConflictDetails {
+ // Numerical `error code <error-codes>`:
+ code: "TALER_EC_POST_TRANSFERS_JSON_BAD_WIRE_FEE";
+
+ // Text describing the issue for humans.
+ hint: string;
+
+
+ // Wire fee (wrongly) charged by the exchange, breaking the
+ // contract affirmed by the exchange_sig.
+ wire_fee: Amount;
+
+ // Timestamp of the wire transfer
+ execution_time: Timestamp;
+
+ // The expected wire fee (as signed by the exchange)
+ expected_wire_fee: Amount;
+
+ // Expected closing fee (needed to verify signature)
+ expected_closing_fee: Amount;
+
+ // Start date of the expected fee structure
+ start_date: Timestamp;
+
+ // End date of the expected fee structure
+ end_date: Timestamp;
+
+ // Signature of the exchange affirming the expected fee structure
+ master_sig: EddsaSignature;
+
+ // Master public key of the exchange
+ master_pub: EddsaPublicKey;
+
+ }
+
.. ts:def:: TrackTransferConflictDetails
interface TrackTransferConflictDetails {
// Numerical `error code <error-codes>`
- code: number;
+ code: "TALER_EC_POST_TRANSFERS_CONFLICTING_REPORTS";
// Text describing the issue for humans.
hint: string;
- // A /deposit response matching ``coin_pub`` showing that the
- // exchange accepted ``coin_pub`` for ``amount_with_fee``.
- exchange_deposit_proof: DepositSuccess;
-
- // Offset in the ``exchange_transfer_proof`` where the
+ // Offset in the ``exchange_transfer`` where the
// exchange's response fails to match the ``exchange_deposit_proof``.
conflict_offset: number;
// The response from the exchange which tells us when the
// coin was returned to us, except that it does not match
// the expected value of the coin.
- exchange_transfer_proof: TrackTransferResponse;
+ //
+ // This field is NOT provided by the current implementation,
+ // because this would be quite expensive to generate and is
+ // hardly needed _here_. Once we add automated reports for
+ // the Taler auditor, we need to generate this data anyway
+ // and should probably return it here as well.
+ exchange_transfer?: TrackTransferResponse;
+
+ // Public key of the exchange used to sign the response to
+ // our deposit request.
+ deposit_exchange_pub: EddsaPublicKey;
+
+ // Signature of the exchange signing the (conflicting) response.
+ // Signs over a \struct TALER_DepositConfirmationPS\.
+ deposit_exchange_sig: EddsaSignature;
+
+ // Hash of the merchant's bank account the wire transfer went to
+ h_wire: HashCode;
+
+ // Hash of the contract terms with the conflicting deposit.
+ h_contract_terms: HashCode;
+
+ // At what time the exchange received the deposit. Needed
+ // to verify the \exchange_sig\.
+ deposit_timestamp: Timestamp;
+
+ // At what time the refund possibility expired (needed to verify \exchange_sig\).
+ refund_deadline: Timestamp;
// Public key of the coin for which we have conflicting information.
coin_pub: EddsaPublicKey;
- // Merchant transaction in which ``coin_pub`` was involved for which
- // we have conflicting information.
- transaction_id: number;
+ // Amount the exchange counted the coin for in the transfer.
+ amount_with_fee: Amount;
// Expected value of the coin.
- amount_with_fee: Amount;
+ coin_value: Amount;
+
+ // Expected deposit fee of the coin.
+ coin_fee: Amount;
// Expected deposit fee of the coin.
deposit_fee: Amount;
}
+ .. ts:def:: TrackTransferProof
+
+ interface TrackTransferProof {
+ // signature from the exchange made with purpose
+ // ``TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT``
+ 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. Again given
+ // explicitly as the client might otherwise be confused by clock skew as to
+ // which signing key was used.
+ exchange_pub: EddsaSignature;
+
+ // hash of the wire details (identical for all deposits)
+ // Needed to check the ``exchange_sig``
+ h_wire: HashCode;
+ }
+
+
-.. http:get:: /track/transaction
+.. http:get:: /private/transfers
- Provide the wire transfer identifier associated with an (existing) deposit operation.
+ Obtain a list of all wire transfers the backend has checked. Note that when
+ filtering by timestamp (using "before" and/or "after"), we use the time
+ reported by the exchange and thus will ONLY return results for which we already
+ have a response from the exchange. This should be virtually all transfers, however
+ it is conceivable that for some transfer the exchange responded with a temporary
+ error (i.e. HTTP status 500+) and then we do not yet have an execution time to
+ filter by. Thus, IF timestamp filters are given, transfers for which we have no
+ response from the exchange yet are automatically excluded.
**Request:**
- :query id: ID of the transaction we want to trace (an integer)
+ :query payto_uri: *Optional*. Filter for transfers to the given bank account (subject and amount MUST NOT be given in the payto URI)
+
+ :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 verified: *Optional*. Filter transfers by verification status.
+
**Response:**
:status 200 OK:
- The deposit has been executed by the exchange and we have a wire transfer identifier.
- The response body is a JSON array of `TransactionWireTransfer` objects.
- :status 202 Accepted:
- The deposit request has been accepted for processing, but was not yet
- executed. Hence the exchange does not yet have a wire transfer identifier.
- The merchant should come back later and ask again.
- The response body is a `TrackTransactionAcceptedResponse <TrackTransactionAcceptedResponse>`. Note that
- the similarity to the response given by the exchange for a /track/order
- is completely intended.
- :status 404 Not Found: The transaction is unknown to the backend.
- :status 424 Failed Dependency:
- The exchange previously claimed that a deposit was not included in a wire
- transfer, and now claims that it is. This means that the exchange is
- dishonest. The response contains the cryptographic proof that the exchange
- is misbehaving in the form of a `TransactionConflictProof`.
+ The body of the response is a `TransferList`.
- **Details:**
+ .. ts:def:: TransferList
- .. ts:def:: TransactionWireTransfer
+ interface TransferList {
+ // list of all the transfers that fit the filter that we know
+ transfers : TransferDetails[];
+ }
- interface TransactionWireTransfer {
+ .. ts:def:: TransferDetails
- // Responsible exchange
- exchange_uri: string;
+ interface TransferDetails {
+ // how much was wired to the merchant (minus fees)
+ credit_amount: Amount;
- // 32-byte wire transfer identifier
- wtid: Base32;
+ // raw wire transfer identifier identifying the wire transfer (a base32-encoded value)
+ wtid: WireTransferIdentifierRawP;
- // execution time of the wire transfer
- execution_time: Timestamp;
+ // target account that received the wire transfer
+ payto_uri: string;
- // Total amount that has been wire transfered
- // to the merchant
- amount: Amount;
- }
+ // base URL of the exchange that made the wire transfer
+ exchange_url: string;
- .. ts:def:: CoinWireTransfer
+ // Serial number identifying the transfer in the merchant backend.
+ // Used for filgering via ``offset``.
+ transfer_serial_id: number;
- interface CoinWireTransfer {
- // public key of the coin that was deposited
- coin_pub: EddsaPublicKey;
+ // Time of the execution of the wire transfer by the exchange, according to the exchange
+ // Only provided if we did get an answer from the exchange.
+ execution_time?: Timestamp;
- // Amount the coin was worth (including deposit fee)
- amount_with_fee: Amount;
+ // 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.
+ verified?: boolean;
- // Deposit fee retained by the exchange for the coin
- deposit_fee: Amount;
+ // True if the merchant uses the POST /transfer API to confirm
+ // that this wire transfer took place (and it is thus not
+ // something merely claimed by the exchange).
+ confirmed?: boolean;
}
- .. ts:def:: TransactionConflictProof
- interface TransactionConflictProof {
- // Numerical `error code <error-codes>`
- code: number;
- // Human-readable error description
- hint: string;
- // A claim by the exchange about the transactions associated
- // with a given wire transfer; it does not list the
- // transaction that ``transaction_tracking_claim`` says is part
- // of the aggregate. This is
- // a ``/track/transfer`` response from the exchange.
- wtid_tracking_claim: TrackTransferResponse;
+--------------------
+Giving Customer Tips
+--------------------
+
+.. _tips:
+.. http:post:: /private/reserves
- // The current claim by the exchange that the given
- // transaction is included in the above WTID.
- // (A response from ``/track/order``).
- transaction_tracking_claim: TrackTransactionResponse;
+ Create a reserve for tipping.
- // Public key of the coin for which we got conflicting information.
- coin_pub: CoinPublicKey;
+ This request is **not** idempotent. However, while repeating
+ it will create another reserve, that is generally pretty harmless
+ (assuming only one of the reserves is filled with a wire transfer).
+ Clients may want to eventually delete the unused reserves to
+ avoid clutter.
+
+ **Request:**
+
+ The request body is a `ReserveCreateRequest` object.
+
+ **Response:**
+
+ :status 200 OK:
+ The backend is waiting for the reserve to be established. The merchant
+ must now perform the wire transfer indicated in the `ReserveCreateConfirmation`.
+ :status 408 Request Timeout:
+ The exchange did not respond on time.
+ :status 409 Conflict:
+ The exchange does not support the requested wire method.
+ :status 424 Failed Dependency:
+ We could not obtain /wire details from the specified exchange base URL.
+
+ .. ts:def:: ReserveCreateRequest
+
+ interface ReserveCreateRequest {
+ // Amount that the merchant promises to put into the reserve
+ initial_balance: Amount;
+
+ // Exchange the merchant intends to use for tipping
+ exchange_url: string;
+
+ // Desired wire method, for example "iban" or "x-taler-bank"
+ wire_method: string;
}
+ .. ts:def:: ReserveCreateConfirmation
--------------------
-Transaction history
--------------------
+ interface ReserveCreateConfirmation {
+ // Public key identifying the reserve
+ reserve_pub: EddsaPublicKey;
-.. http:get:: /history
+ // Wire account of the exchange where to transfer the funds
+ payto_url: string;
- Returns transactions up to some point in the past
+ }
- **Request**
+.. http:get:: /private/reserves
- :query date: time threshold, see ``delta`` for its interpretation.
- :query start: row number threshold, see ``delta`` for its interpretation. Defaults to ``UINT64_MAX``, namely the biggest row id possible in the database.
- :query delta: takes value of the form ``N (-N)``, so that at most ``N`` values strictly younger (older) than ``start`` and ``date`` are returned. Defaults to ``-20``.
- :query ordering: takes value ``"descending"`` or ``"ascending"`` according to the results wanted from younger to older or vice versa. Defaults to ``"descending"``.
+ Obtain list of reserves that have been created for tipping.
- **Response**
+ **Request:**
- :status 200 OK:
- The response is a JSON ``array`` of `TransactionHistory`. The array is
- sorted such that entry ``i`` is younger than entry ``i+1``.
+ :query after: *Optional*. Only return reserves created after the given timestamp in milliseconds
+ :query active: *Optional*. Only return active/inactive reserves depending on the boolean given
+ :query failures: *Optional*. Only return reserves where we disagree with the exchange about the initial balance.
- .. ts:def:: TransactionHistory
+ **Response:**
- interface TransactionHistory {
- // The serial number this entry has in the merchant's DB.
- row_id: number;
+ :status 200 OK:
+ Returns a list of known tipping reserves.
+ The body is a `TippingReserveStatus`.
- // order ID of the transaction related to this entry.
- order_id: string;
+ .. ts:def:: TippingReserveStatus
- // Transaction's timestamp
- timestamp: Timestamp;
+ interface TippingReserveStatus {
+
+ // Array of all known reserves (possibly empty!)
+ reserves: ReserveStatusEntry[];
- // Total amount associated to this transaction.
- amount: Amount;
}
-.. _proposal:
+ .. ts:def:: ReserveStatusEntry
+ interface ReserveStatusEntry {
--------------------------
-Dynamic Merchant Instance
--------------------------
+ // Public key of the reserve
+ reserve_pub: EddsaPublicKey;
-.. note::
+ // Timestamp when it was established
+ creation_time: Timestamp;
- The endpoints to dynamically manage merchant instances has not been
- implemented yet. The bug id for this refernce is 5349.
+ // Timestamp when it expires
+ expiration_time: Timestamp;
-.. http:get:: /instances
+ // Initial amount as per reserve creation call
+ merchant_initial_amount: Amount;
- This is used to return the list of all the merchant instances
+ // Initial amount as per exchange, 0 if exchange did
+ // not confirm reserve creation yet.
+ exchange_initial_amount: Amount;
- **Response**
+ // Amount picked up so far.
+ pickup_amount: Amount;
+
+ // Amount approved for tips that exceeds the pickup_amount.
+ committed_amount: Amount;
+
+ // Is this reserve active (false if it was deleted but not purged)
+ active: boolean;
+ }
+
+
+.. http:get:: /private/reserves/$RESERVE_PUB
+
+ Obtain information about a specific reserve that have been created for tipping.
+
+ **Request:**
+
+ :query tips: *Optional*. If set to "yes", returns also information about all of the tips created
+
+ **Response:**
:status 200 OK:
- The backend has successfully returned the list of instances stored. Returns
- a `InstancesResponse`.
+ Returns the `ReserveDetail`.
+ :status 404 Not found:
+ The tipping reserve is not known.
+ :status 424 Failed Dependency:
+ We are having trouble with the request because of a problem with the exchange.
+ Likely returned with an "exchange_code" in addition to a "code" and
+ an "exchange_http_status" in addition to our own HTTP status. Also usually
+ includes the full exchange reply to our request under "exchange_reply".
+ This is only returned if there was actual trouble with the exchange, not
+ if the exchange merely did not respond yet or if it responded that the
+ reserve was not yet filled.
- .. ts:def:: InstancesResponse
+ .. ts:def:: ReserveDetail
- interface InstancesResponse {
- // List of instances that are present in the backend (see `Instance`)
- instances: Instance[];
+ interface ReserveDetail {
+
+ // Timestamp when it was established
+ creation_time: Timestamp;
+
+ // Timestamp when it expires
+ expiration_time: Timestamp;
+
+ // Initial amount as per reserve creation call
+ merchant_initial_amount: Amount;
+
+ // Initial amount as per exchange, 0 if exchange did
+ // not confirm reserve creation yet.
+ exchange_initial_amount: Amount;
+
+ // Amount picked up so far.
+ pickup_amount: Amount;
+
+ // Amount approved for tips that exceeds the pickup_amount.
+ committed_amount: Amount;
+
+ // Array of all tips created by this reserves (possibly empty!).
+ // Only present if asked for explicitly.
+ tips?: TipStatusEntry[];
+
+ // Is this reserve active (false if it was deleted but not purged)
+ active: boolean;
}
- The `Instance` object describes the instance registered with the backend. It has the following structure:
+ .. ts:def:: TipStatusEntry
- .. ts:def:: Instance
+ interface TipStatusEntry {
- interface Instance {
- // Merchant name corresponding to this instance.
- name: string;
+ // Unique identifier for the tip
+ tip_id: HashCode;
- // The URL where the wallet will send coins.
- payto: string;
+ // Total amount of the tip that can be withdrawn.
+ total_amount: Amount;
- // Merchant instance of the response to create
- instance: string;
+ // Human-readable reason for why the tip was granted.
+ reason: string;
- //unique key for each merchant
- merchant_id: string;
}
-.. http:put:: /instances/
+.. http:post:: /private/reserves/$RESERVE_PUB/authorize-tip
- This request will be used to create a new merchant instance in the backend.
+ Authorize creation of a tip from the given reserve.
- **Request**
+ **Request:**
- The request must be a `CreateInstanceRequest`.
+ The request body is a `TipCreateRequest` object.
- **Response**
+ **Response:**
:status 200 OK:
- The backend has successfully created the instance. The response is a
- `CreateInstanceResponse`.
-
- .. ts:def:: CreateInstanceRequest
+ A tip has been created. The backend responds with a `TipCreateConfirmation`
+ :status 404 Not Found:
+ The instance or the reserve is unknown to the backend.
+ :status 412 Precondition Failed:
+ The tip amount requested exceeds the available reserve balance for tipping.
- interface CreateInstanceRequest {
- // The URL where the wallet has to send coins.
- // payto://-URL of the merchant's bank account. Required.
- payto: string;
+ .. ts:def:: TipCreateRequest
- // Merchant instance of the response to create
- // This field is optional. If it is not specified
- // then it will automatically be created.
- instance?: string;
+ interface TipCreateRequest {
+ // Amount that the customer should be tipped
+ amount: Amount;
- // Merchant name corresponding to this instance.
- name: string;
+ // Justification for giving the tip
+ justification: string;
+ // URL that the user should be directed to after tipping,
+ // will be included in the tip_token.
+ next_url: string;
}
- .. ts:def:: CreateInstanceResponse
+ .. ts:def:: TipCreateConfirmation
+
+ interface TipCreateConfirmation {
+ // Unique tip identifier for the tip that was created.
+ tip_id: HashCode;
+
+ // URL that will directly trigger processing
+ // the tip when the browser is redirected to it
+ tip_redirect_url: string;
- interface CreateInstanceResponse {
- // Merchant instance of the response that was created
- instance: string;
+ // when does the tip expire
+ tip_expiration: Timestamp;
- //unique key for each merchant
- merchant_id: string;
}
-.. http:get:: /instances/<instance-id>
+.. http:post:: /private/tips
- This is used to query a specific merchant instance.
+ Authorize creation of a tip from the given reserve, except with
+ automatic selection of a working reserve of the instance by the
+ backend. Intentionally otherwise identical to the /authorize-tip
+ endpoint given above.
**Request:**
- :query instance_id: instance id that should be used for the instance
+ The request body is a `TipCreateRequest` object.
- **Response**
+ **Response:**
:status 200 OK:
- The backend has successfully returned the list of instances stored. Returns
- a `QueryInstancesResponse`.
+ A tip has been created. The backend responds with a `TipCreateConfirmation`
+ :status 404 Not Found:
+ The instance is unknown to the backend.
+ :status 412 Precondition Failed:
+ The tip amount requested exceeds the available reserve balance for tipping
+ in all of the reserves of the instance.
- .. ts:def:: QueryInstancesResponse
- interface QueryInstancesResponse {
- // The URL where the wallet has to send coins.
- // payto://-URL of the merchant's bank account. Required.
- payto: string;
+.. http:delete:: /private/reserves/$RESERVE_PUB
- // Merchant instance of the response to create
- // This field is optional. If it is not specified
- // then it will automatically be created.
- instance?: string;
+ Delete information about a reserve. Fails if the reserve still has
+ committed to tips that were not yet picked up and that have not yet
+ expired.
- // Merchant name corresponding to this instance.
- name: string;
+ **Request:**
+
+ :query purge: *Optional*. If set to YES, the reserve and all information
+ about tips it issued will be fully deleted.
+ Otherwise only the private key would be deleted.
+
+ **Response:**
+
+ :status 204 No content:
+ The backend has successfully deleted the reserve.
+ :status 404 Not found:
+ The backend does not know the instance or the reserve.
+ :status 409 Conflict:
+ The backend refuses to delete the reserve (committed tips awaiting pickup).
+
+
+
+.. http:get:: /private/tips/$TIP_ID
+
+ Obtain information about a particular tip.
+
+ **Request:**
+
+ :query pickups: if set to "yes", returns also information about all of the pickups
+
+ **Response:**
+
+ :status 200 OK:
+ The tip is known. The backend responds with a `TipDetails` message
+ :status 404 Not Found:
+ The tip is unknown to the backend.
+
+ .. ts:def:: TipDetails
+
+ interface TipDetails {
+ // Amount that we authorized for this tip.
+ total_authorized: Amount;
+
+ // Amount that was picked up by the user already.
+ total_picked_up: Amount;
+
+ // Human-readable reason given when authorizing the tip.
+ reason: string;
+
+ // Timestamp indicating when the tip is set to expire (may be in the past).
+ expiration: Timestamp;
+
+ // Reserve public key from which the tip is funded
+ reserve_pub: EddsaPublicKey;
+
+ // Array showing the pickup operations of the wallet (possibly empty!).
+ // Only present if asked for explicitly.
+ pickups?: PickupDetail[];
}
+ .. ts:def:: PickupDetail
-.. http:post:: /instances/<instance-id>
+ interface PickupDetail {
- This request will be used to update merchant instance in the backend.
+ // Unique identifier for the pickup operation.
+ pickup_id: HashCode;
+ // Number of planchets involved.
+ num_planchets: Integer;
- **Request**
+ // Total amount requested for this pickup_id.
+ requested_amount: Amount;
- The request must be a `PostInstanceUpdateRequest`.
+ }
- **Response**
+
+
+.. http:get:: /tips/$TIP_ID
+
+ Handle request from wallet to provide details about a tip.
+
+ **Response:**
:status 200 OK:
- The backend has successfully updated the instance. The response is a
- `PostInstanceUpdateResponse`.
+ A tip is being returned. The backend responds with a `TipInformation`
+ :status 404 Not Found:
+ The tip identifier is unknown.
- .. ts:def:: PostInstanceUpdateRequest
+ .. ts:def:: TipInformation
- interface PostInstanceUpdateRequest {
- // Merchant instance that is to be updaated. Required.
- instance: string;
+ interface TipInformation {
- // New URL where the wallet has to send coins.
- // payto://-URL of the merchant's bank account. Required.
- payto: string;
+ // Exchange from which the tip will be withdrawn. Needed by the
+ // wallet to determine denominations, fees, etc.
+ exchange_url: string;
- // Merchant name coreesponding to this instance.
- name: string;
+ // (remaining) amount of the tip (including fees).
+ tip_amount: Amount;
+
+ // Timestamp indicating when the tip is set to expire (may be in the past).
+ // Note that tips that have expired MAY also result in a 404 response.
+ expiration: Timestamp;
+ }
+
+
+
+.. http:get:: /private/tips
+
+ Return the list of all tips.
+
+ **Request:**
+
+ :query include_expired: *Optional*. If set to "yes", the result includes expired tips also. Otherwise, only active tips are returned.
+
+ :query limit: *Optional*. At most return the given number of results. Negative for descending in database row id, positive for ascending in database row id.
+
+ :query offset: *Optional*. Starting row_id for an iteration.
+
+ **Response:**
+
+ :status 200 OK:
+ The backend has successfully found the list of tips. The backend responds
+ with a `TipsResponse`.
+
+ .. ts:def:: TipsResponse
+
+ interface TipsResponse {
+ // List of tips that are present in the backend.
+ tips: Tip[];
}
- .. ts:def:: PostInstanceUpdateResponse
+ .. ts:def:: Tip
- interface PostInstanceUpdateResponse {
- // Merchant instance of the response that was updated
- instance: string;
+ interface Tip {
+
+ // id of the tip in the backend database
+ row_id: number;
- //unique key for each merchant
- merchant_id: string;
+ // Unique identifier for the tip.
+ tip_id: HashCode;
+
+ // (remaining) amount of the tip (including fees).
+ tip_amount: Amount;
}
-.. http:delete:: /instances/<instance-id>
- This request will be used to delete merchant instance in the backend.
+.. http:post:: /tips/$TIP_ID/pickup
+
+ Handle request from wallet to pick up a tip.
**Request:**
- :query instance_id: instance id that should be used for the instance
+ The request body is a `TipPickupRequest` object.
- **Response**
+ **Response:**
:status 200 OK:
- The backend has successfully removed the instance. The response is a
- `PostInstanceRemoveResponse`.
+ A tip is being returned. The backend responds with a `TipResponse`
+ :status 401 Unauthorized:
+ The tip amount requested exceeds the tip.
+ :status 404 Not Found:
+ The tip identifier is unknown.
+ :status 409 Conflict:
+ Some of the denomination key hashes of the request do not match those currently available from the exchange (hence there is a conflict between what the wallet requests and what the merchant believes the exchange can provide).
+ :status 410 Gone:
+ The tip has expired.
+
+ .. ts:def:: TipPickupRequest
+
+ interface TipPickupRequest {
+
+ // List of planches the wallet wants to use for the tip
+ planchets: PlanchetDetail[];
+ }
+
+ .. ts:def:: PlanchetDetail
+
+ interface PlanchetDetail {
+ // Hash of the denomination's public key (hashed to reduce
+ // bandwidth consumption)
+ denom_pub_hash: HashCode;
+
+ // coin's blinded public key
+ coin_ev: CoinEnvelope;
+
+ }
+
+ .. ts:def:: TipResponse
+
+ interface TipResponse {
+
+ // Blind RSA signatures over the planchets.
+ // The order of the signatures matches the planchets list.
+ blind_sigs: BlindSignature[];
+ }
+
+ .. ts:def:: BlindSignature
- .. ts:def:: PostInstanceRemoveResponse
+ interface BlindSignature {
- interface PostInstanceRemoveResponse {
- deleted: true;
+ // The (blind) RSA signature. Still needs to be unblinded.
+ blind_sig: BlindedRsaSignature;
}
+
+
+
------------------
The Contract Terms
------------------
+.. _contract-terms:
+
The contract terms must have the following structure:
.. ts:def:: ContractTerms
@@ -858,35 +2289,48 @@ The contract terms must have the following structure:
.. ts:def:: Product
interface Product {
+ // merchant-internal identifier for the product.
+ product_id?: string;
+
// Human-readable product description.
description: string;
// Map from IETF BCP 47 language tags to localized descriptions
description_i18n?: { [lang_tag: string]: string };
- // The quantity of the product to deliver to the customer (optional, if applicable)
- quantity?: string;
+ // The number of units of the product to deliver to the customer.
+ quantity?: Integer;
- // The price of the product; this is the total price for the amount specified by 'quantity'
- price: Amount;
+ // The unit in which the product is measured (liters, kilograms, packages, etc.)
+ unit?: string;
- // merchant-internal identifier for the product
- product_id?: string;
+ // The price of the product; this is the total price for ``quantity`` times ``unit`` of this product.
+ price?: Amount;
// An optional base64-encoded product image
image?: ImageDataUrl;
- // a list of objects indicating a 'taxname' and its amount. Again, italics denotes the object field's name.
- taxes?: any[];
+ // a list of taxes paid by the merchant for this product. Can be empty.
+ taxes?: Tax[];
// time indicating when this product should be delivered
- delivery_date: Timestamp;
+ delivery_date?: Timestamp;
// where to deliver this product. This may be an URL for online delivery
// (i.e. 'http://example.com/download' or 'mailto:customer@example.com'),
// or a location label defined inside the proposition's 'locations'.
// The presence of a colon (':') indicates the use of an URL.
- delivery_location: string;
+ delivery_location?: string;
+ }
+
+ .. ts:def:: Tax
+
+ interface Tax {
+ // the name of the tax
+ name: string;
+
+ // amount paid in tax
+ tax: Amount;
}
.. ts:def:: Merchant
@@ -939,268 +2383,3 @@ The contract terms must have the following structure:
// master public key of the exchange
master_pub: EddsaPublicKey;
}
-
-
--------------------
-Customer-facing API
--------------------
-
-The ``/public/*`` endpoints are publicly exposed on the internet and accessed
-both by the user's browser and their wallet.
-
-
-.. http:post:: /public/pay
-
- Pay for a proposal by giving a deposit permission for coins. Typically used by
- the customer's wallet. Can also be used in ``abort-refund`` mode to refund coins
- that were already deposited as part of a failed payment.
-
- **Request:**
-
- The request must be a `pay request <PayRequest>`.
-
- **Response:**
-
- :status 200 OK:
- The exchange accepted all of the coins. The body is a `PaymentResponse` if
- the request used the mode "pay", or a `MerchantRefundResponse` if the
- request used was the mode "abort-refund".
- The ``frontend`` should now fullfill the contract.
- :status 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.
- :status 401 Unauthorized:
- One of the coin signatures was not valid.
- :status 403 Forbidden:
- The exchange rejected the payment because a coin was already spent before.
- The response will include the 'coin_pub' for which the payment failed,
- in addition to the response from the exchange to the ``/deposit`` request.
-
- 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. This should be the expected case, as the ``frontend``
- cannot really make mistakes; the only reasonable exception is if the
- ``backend`` is unavailable, in which case the customer might appreciate some
- reassurance that the merchant is working on getting his systems back online.
-
- .. ts:def:: PaymentResponse
-
- interface PaymentResponse {
- // Signature on `TALER_PaymentResponsePS` with the public
- // key of the merchant instance.
- sig: EddsaSignature;
-
- // Contract terms hash being signed over.
- h_contract_terms: HashCode;
- }
-
- .. ts:def:: PayRequest
-
- interface PayRequest {
- coins: CoinPaySig[];
-
- // The merchant public key, used to uniquely
- // identify the merchant instance.
- merchant_pub: string;
-
- // Order ID that's being payed for.
- order_id: string;
-
- // Mode for /pay ("pay" or "abort-refund")
- mode: "pay" | "abort-refund";
- }
-
- .. ts:def:: CoinPaySig
-
- export interface CoinPaySig {
- // Signature by the coin.
- coin_sig: string;
-
- // Public key of the coin being spend.
- coin_pub: string;
-
- // Signature made by the denomination public key.
- ub_sig: string;
-
- // The denomination public key associated with this coin.
- denom_pub: string;
-
- // 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;
- }
-
-
-.. http:get:: /public/pay
-
- Query the payment status of an order.
-
- **Request**
-
- :query hc: hash of the order's contract terms
- :query long_poll_ms: *Optional.* If specified, the merchant backend will
- wait up to ``long_poll_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**
-
- :status 200 OK:
- The response is a `PublicPayStatusResponse`.
-
- .. ts:def:: PublicPayStatusResponse
-
- interface PublicPayStatusResponse {
- // Has the payment for this order been completed?
- paid: boolean;
-
- // Refunds for this payment, if any.
- refunds: RefundInfo[];
- }
-
-
- .. ts:def:: RefundInfo
-
- interface RefundInfo {
-
- // Coin from which the refund is going to be taken
- coin_pub: EddsaPublicKey;
-
- // Refund amount taken from coin_pub
- refund_amount: Amount;
-
- // Refund fee
- refund_fee: Amount;
-
- // Identificator of the refund
- rtransaction_id: number;
-
- // Merchant public key
- merchant_pub: EddsaPublicKey
-
- // Merchant signature of a TALER_RefundRequestPS object
- merchant_sig: EddsaSignature;
- }
-
-
-.. http:get:: /public/proposal
-
- Retrieve and take ownership (via nonce) over a proposal.
-
- **Request**
-
- :query order_id: the order id whose refund situation is being queried
- :query nonce: the nonce for the proposal
-
- **Response**
-
- :status 200 OK:
- The backend has successfully retrieved the proposal. It responds with a :ref:`proposal <proposal>`.
-
- :status 403 Forbidden:
- The frontend used the same order ID with different content in the order.
-
-
-.. http:post:: /public/tip-pickup
-
- Handle request from wallet to pick up a tip.
-
- **Request**
-
- The request body is a `TipPickupRequest` object.
-
- **Response**
-
- :status 200 OK:
- A tip is being returned. The backend responds with a `TipResponse`
- :status 401 Unauthorized:
- The tip amount requested exceeds the tip.
- :status 404 Not Found:
- The tip identifier is unknown.
- :status 409 Conflict:
- Some of the denomination key hashes of the request do not match those currently available from the exchange (hence there is a conflict between what the wallet requests and what the merchant believes the exchange can provide).
-
- .. ts:def:: TipPickupRequest
-
- interface TipPickupRequest {
-
- // Identifier of the tip.
- tip_id: HashCode;
-
- // List of planches the wallet wants to use for the tip
- planchets: PlanchetDetail[];
- }
-
- .. ts:def:: PlanchetDetail
-
- interface PlanchetDetail {
- // Hash of the denomination's public key (hashed to reduce
- // bandwidth consumption)
- denom_pub_hash: HashCode;
-
- // coin's blinded public key
- coin_ev: CoinEnvelope;
-
- }
-
- .. ts:def:: TipResponse
-
- interface TipResponse {
- // Public key of the reserve
- reserve_pub: EddsaPublicKey;
-
- // The order of the signatures matches the planchets list.
- reserve_sigs: EddsaSignature[];
- }
-
-
-.. http:get:: /public/poll-payment
-
- Check the payment status of an order.
-
- **Request:**
-
- :query order_id: order id that should be used for the payment
- :query h_contract: hash of the contract (used to authenticate customer)
- :query session_id: *Optional*. Session ID that the payment must be bound to. If not specified, the payment is not session-bound.
- :query timeout: *Optional*. Timeout in seconds to wait for a payment if the answer would otherwise be negative (long polling).
-
- **Response:**
-
- Returns a `PollPaymentResponse`, whose format can differ based on the status of the payment.
-
- .. ts:def:: PollPaymentResponse
-
- type CheckPaymentResponse = PollPaymentPaidResponse | PollPaymentUnpaidResponse
-
- .. ts:def:: PollPaymentPaidResponse
-
- interface PollPaymentPaidResponse {
- // value is always true;
- paid: boolean;
-
- // Was the payment refunded (even partially)
- refunded: boolean;
-
- // Amount that was refunded, only present if refunded is true.
- refund_amount?: Amount;
-
- }
-
- .. ts:def:: PollPaymentUnpaidResponse
-
- interface PollPaymentUnpaidResponse {
- // value is always false;
- paid: boolean;
-
- // URI that the wallet must process to complete the payment.
- taler_pay_uri: 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;
-
- }