Table of Contents
A single merchant backend installation can host multiple merchant instances. This is useful when multiple businesses want to share the same payment infrastructure.
Merchant backends have one special default
instance. This default
instance is used when no explicit instance is specified. Despite its name,
this instance must be created after the installation. In case no default
instance is found - or its credentials got lost -, the administrator can use
the default instance’s rights by resorting on the --auth
command line option,
or by restarting the service by providing an environment variable called
TALER_MERCHANT_TOKEN
.
Each instance (default and others) has a base URL. The resources under this base URL are divided into to categories:
/private/*
) that are only supposed to be exposed
to the merchant internally, and must not be exposed on the
Internet./management/*
) are also private and dedicated
to CRUD operation over instances and reset authentication settings over all
instances. Only accessible with the default instance authentication tokenExamples:
Base URL of the merchant (default instance) at merchant-backend.example.com:
https://merchant-backend.example.com/
A private endpoint (default instance):
https://merchant-backend.example.com/private/orders
A public endpoint (default instance and order id "ABCD"):
https://merchant-backend.example.com/orders/ABCD
A private endpoint ("myinst" instance):
https://merchant-backend.example.com/instances/myinst/private/orders
A public endpoint ("myinst" instance and order id "ABCD"):
https://merchant-backend.example.com/instances/myinst/orders/ABCD
A private endpoint (explicit "default" instance):
https://merchant-backend.example.com/instances/default/private/orders
A public endpoint (explicit "default" instance):
https://merchant-backend.example.com/instances/default/orders
Endpoints to manage other instances (ONLY for implicit "default" instance):
https://merchant-backend.example.com/management/instances
https://merchant-backend.example.com/management/instances/$ID
Endpoints to manage own instance:
https://merchant-backend.example.com/private
https://merchant-backend.example.com/private/auth
https://merchant-backend.example.com/instances/$ID/private
https://merchant-backend.example.com/instances/$ID/private/auth
Unavailabe endpoints (will return 404):
https://merchant-backend.example.com/instances/myinst/private/instances
Each merchant instance has separate authentication settings for the private API resources of that instance.
Currently, the API supports two auth methods:
external
: With this method, no checks are done by the merchant backend.
Instead, a reverse proxy / API gateway must do all authentication/authorization checks.token
: With this method, the client must provide a Authorization: Bearer $TOKEN
header, where $TOKEN
is a secret authentication token configured for the instance.The configuration API exposes basic information about a merchant backend, such as the implemented version of the protocol and the currency used.
GET
/config
¶Return the protocol version and currency supported by this merchant backend.
Response:
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;
// Name of the protocol.
name: "taler-merchant";
// Currency supported by this backend.
currency: string;
}
This section describes (public) endpoints that wallets must be able to interact with directly (without HTTP-based authentication). These endpoints are used to process payments (claiming an order, paying for the order, checking payment/refund status and aborting payments), process refunds (checking refund status, obtaining the refund), and to pick up tips.
The first step of processing any Taler payment consists of the (authorized) wallet claiming the order for itself. In this process, the wallet provides a wallet-generated nonce that is added into the contract terms. This step prevents two different wallets from paying for the same contract, which would be bad especially if the merchant only has finite stocks.
A claim token can be used to ensure that the wallet claiming an order is actually authorized to do so. This is useful in cases where order IDs are predictable and malicious actors may try to claim orders (say in a case where stocks are limited).
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.
interface ClaimRequest {
// Nonce to identify the wallet that claimed the order.
nonce: string;
// 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;
}
Response:
interface ClaimResponse {
// Contract terms of the claimed order
contract_terms: ContractTerms;
// Signature by the merchant over the contract terms.
sig: EddsaSignature;
}
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.
Response:
frontend
should now fulfill the contract.
Note that it is possible that refunds have been granted.exchange_url
for which the payment failed,
in addition to the response from the exchange to the /batch-deposit
request.The backend will return verbatim the error codes received from the exchange’s 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.
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;
}
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;
}
export 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: 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;
}
GET
[/instances/$INSTANCE]/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,
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:
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.timeout_ms
specifies how long we will wait for the refund.timeout_ms
will specify how long we will wait for the refund.Response:
h_contract
(or the token
for unclaimed orders) does not match the order
and we have no fulfillment URL in the contract.interface StatusPaid {
// 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;
}
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;
}
interface StatusUnpaidResponse {
// URI that the wallet must process to complete the payment.
taler_pay_uri: string;
// Status URL, can be used as a redirect target for the browser
// to show the order QR code / trigger the wallet.
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;
}
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.
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.
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.
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.
Response:
frontend
should now fulfill the contract.
Note that it is possible that refunds have been granted.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;
}
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.
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. 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:
h_contract
does not match the $ORDER_ID.The backend will return an abort response, which includes verbatim the error codes received from the exchange’s refund API. The frontend should pass the replies verbatim to the browser/wallet.
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[];
}
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;
}
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[];
}
type MerchantAbortPayRefundStatus =
| MerchantAbortPayRefundSuccessStatus
| 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;
}
// 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;
}
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.
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:
h_contract
does not match the order.interface WalletRefundRequest {
// Hash of the order's contract terms (this is used to authenticate the
// wallet/customer).
h_contract: HashCode;
}
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;
}
type MerchantCoinRefundStatus =
| MerchantCoinRefundSuccessStatus
| 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;
}
// 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;
}
Tips are a way for wallets to obtain e-cash from a website.
GET
[/instances/$INSTANCE]/tips/$TIP_ID
¶Handle request from wallet to provide details about a tip.
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. If the backend installation does not include the required HTML templates, a 406 status code is returned.
Response:
interface TipInformation {
// Exchange from which the tip will be withdrawn. Needed by the
// wallet to determine denominations, fees, etc.
exchange_url: string;
// URL where to go after obtaining the tip.
next_url: 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;
}
POST
[/instances/$INSTANCE]/tips/$TIP_ID/pickup
¶Handle request from wallet to pick up a tip.
Request:
The request body is a TipPickupRequest object.
Response:
interface TipPickupRequest {
// List of planchets the wallet wants to use for the tip.
planchets: 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;
}
interface TipResponse {
// Blind RSA signatures over the planchets.
// The order of the signatures matches the planchets list.
blind_sigs: BlindSignature[];
}
interface BlindSignature {
// The (blind) RSA signature. Still needs to be unblinded.
blind_sig: BlindedRsaSignature;
}
Instances allow one merchant backend to be shared by multiple merchants. Every backend must have at least one instance, typically the “default” instance setup before it can be used to manage inventory or process payments.
POST
/management/instances
¶This request will be used to create a new merchant instance in the backend.
It is only available for the implicit default
instance.
Request:
The request must be a InstanceConfigurationMessage.
Response:
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 the respective account is set to
// inactive and thus unavailable for new contracts, but preserved
// in the database as existing offers and contracts may still refer
// to it.
payto_uris: string[];
// 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.
email?: 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;
// 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 overridden 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;
}
POST
/management/instances/$INSTANCE/auth
¶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
default
instance, depending on the access path used.Request the request must be an InstanceAuthConfigurationMessage.
interface InstanceAuthConfigurationMessage {
// Type of authentication.
// "external": The mechant backend does not do
// any authentication checks. Instead an API
// gateway must do the authentication.
// "token": The merchant checks an auth token.
// See "token" for details.
method: "external" | "token";
// For method "external", this field is mandatory.
// The token MUST begin with the string "secret-token:".
// After the auth token has been set (with method "token"),
// the value must be provided in a "Authorization: Bearer $token"
// header.
token?: string;
}
PATCH
/management/instances/$INSTANCE
¶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 default
instance, depending on the access path used.
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:
interface InstanceReconfigurationMessage {
// The URI where the wallet will send coins. A merchant may have
// multiple accounts, thus this is an array. Note that removing
// URIs from this list deactivates the specified accounts
// (they will no longer be used for future contracts).
payto_uris: string[];
// Merchant name corresponding to this instance.
name: string;
// Merchant email for customer contact.
email?: 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;
// 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 overridden 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;
}
GET
/management/instances
¶This is used to return the list of all the merchant instances.
It is only available for the implicit default
instance.
Response:
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:
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;
}
GET
/management/instances/$INSTANCE
¶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 default
instance, depending on the access path used.
Response:
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;
// Merchant email for customer contact.
email?: string;
// 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;
// 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 overridden 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;
// Authentication configuration.
// Does not contain the token when token auth is configured.
auth: {
type: "external" | "token";
};
}
DELETE
/management/instances/$INSTANCE
¶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) 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 default
instance, depending on the access path used.
Request:
Response
default
instance.TAX_RECORD_EXPIRATION
time.
The latter case only applies if purge
was set.Note
This is a draft API that is not yet implemented.
GET
/management/instances/$INSTANCE/kyc
¶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.
Request:
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.
Details:
interface AccountKycRedirects {
// Array of pending KYCs.
pending_kycs: MerchantAccountKycRedirect[];
// Array of exchanges with no reply.
timeout_kycs: ExchangeKycTimeout[];
}
interface MerchantAccountKycRedirect {
// URL that the user should open in a browser to
// proceed with the KYC process (as returned
// by the exchange's /kyc-check/ endpoint).
kyc_url: string;
// Base URL of the exchange this is about.
exchange_url: string;
// Our bank wire account this is about.
payto_uri: string;
}
interface ExchangeKycTimeout {
// Base URL of the exchange this is about.
exchange_url: string;
// Numeric error code indicating errors the exchange
// returned, or TALER_EC_INVALID for none.
exchange_code: number;
// HTTP status code returned by the exchange when we asked for
// information about the KYC status.
// 0 if there was no response at all.
exchange_http_status: number;
}
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.
POST
[/instances/$INSTANCE]/private/products
¶This is used to add a product to the inventory.
Request:
The request must be a ProductAddDetail.
Response:
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;
// Minimum age buyer must have (in years). Default is 0.
minimum_age?: Integer;
}
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”.
Request:
The request must be a ProductPatchDetail.
Response:
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;
// Minimum age buyer must have (in years). Default is 0.
minimum_age?: Integer;
}
GET
[/instances/$INSTANCE]/private/products
¶This is used to return the list of all items in the inventory.
Response:
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:
interface InventoryEntry {
// Product identifier, as found in the product.
product_id: string;
}
GET
[/instances/$INSTANCE]/private/products/$PRODUCT_ID
¶This is used to obtain detailed information about a product in the inventory.
Response:
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;
// Minimum age buyer must have (in years).
minimum_age?: Integer;
}
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.
Request:
The request must be a LockRequest.
Response:
quantity
.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;
// How many units should be locked?
quantity: Integer;
}
Note
The GNUNET_CRYPTO_random_timeflake()
C API can be used
to generate such timeflakes for clients written in C.
DELETE
[/instances/$INSTANCE]/private/products/$PRODUCT_ID
¶Delete information about a product. Fails if the product is locked by anyone.
Response:
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.
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. In order to get this URL use GET [/instances/$INSTANCE]/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:
Possible reasons are:
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.
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 current
// time plus the specified delay. If it's not set, refunds will not be
// possible.
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;
// 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'.
create_token?: boolean;
}
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.
interface MinimalOrderDetail {
// Amount to be paid by the customer.
amount: Amount;
// Short summary of the order.
summary: string;
// See documentation of fulfillment_url in ContractTerms.
// Either fulfillment_url or fulfillment_message must be specified.
fulfillment_url?: string;
// See documentation of fulfillment_message in ContractTerms.
// Either fulfillment_url or fulfillment_message must be specified.
fulfillment_message?: string;
}
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
.
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;
}
interface PostOrderResponse {
// Order ID of the response that was just created.
order_id: string;
// Token that authorizes the wallet to claim the order.
// Provided only if "create_token" was set to 'true'
// in the request.
token?: ClaimToken;
}
interface OutOfStockResponse {
// Product ID of an out-of-stock item.
product_id: string;
// Requested quantity.
requested_quantity: Integer;
// Available quantity (must be below requested_quantity).
available_quantity: Integer;
// When do we expect the product to be again in stock?
// Optional, not given if unknown.
restock_expected?: Timestamp;
}
GET
[/instances/$INSTANCE]/private/orders
¶Returns known orders up to some point in the past.
Request:
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
).delta
for its interpretation. If not specified, we default to the oldest or most recent entry, depending on delta
.delta
for its interpretation. Defaults to INT64_MAX
, namely the biggest row id possible in the database.delta
orders.Response:
interface OrderHistory {
// Timestamp-sorted array of all orders matching the query.
// The order of the sorting depends on the sign of delta.
orders : 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: number;
// When the order was created.
timestamp: Timestamp;
// The amount of money the order is for.
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;
}
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
).
Request:
Response:
type MerchantOrderStatusResponse = CheckPaymentPaidResponse |
CheckPaymentClaimedResponse |
CheckPaymentUnpaidResponse;
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 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: 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_http_status: number;
// Total amount that was refunded, 0 if refunded is false.
refund_amount: Amount;
// Contract terms.
contract_terms: ContractTerms;
// The 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[];
// 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;
}
interface CheckPaymentClaimedResponse {
// A wallet claimed the order, but did not yet pay for the contract.
order_status: "claimed";
// Contract terms.
contract_terms: ContractTerms;
}
interface CheckPaymentUnpaidResponse {
// The order was neither claimed nor paid.
order_status: "unpaid";
// URI that the wallet must process to complete the payment.
taler_pay_uri: string;
// when was the order created
creation_time: Timestamp;
// Order summary text.
summary: string;
// Total amount of the order (to be paid by the customer).
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;
// We do we NOT return the contract terms here because they may not
// exist in case the wallet did not yet claim them.
}
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.
amount: Amount;
// Was this transfer confirmed by the merchant via the
// POST /transfers API, or is it merely claimed by the exchange?
confirmed: boolean;
}
interface TransactionWireReport {
// Numerical error code.
code: number;
// Human-readable error description.
hint: string;
// Numerical error code from the exchange.
exchange_code: number;
// HTTP status code received from the exchange.
exchange_http_status: number;
// Public key of the coin for which we got the exchange error.
coin_pub: CoinPublicKey;
}
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.
PATCH
[/instances/$INSTANCE]/private/orders/$ORDER_ID/forget
¶Forget fields in an order’s contract terms that the merchant no longer needs.
Request:
The request must be a forget request. 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 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
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:
interface ForgetRequest {
// Array of valid JSON paths to forgettable fields in the order's
// contract terms.
fields: string[];
}
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:
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.
Request:
The request body is a RefundRequest object.
Response:
interface RefundRequest {
// Amount to be refunded.
refund: Amount;
// Human-readable refund justification.
reason: string;
}
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;
}
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.
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).
Request:
The request must provide transfer information.
Response:
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.)GET /transfer
status
for this wire transfer. Details of the exchange error are returned.Details:
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;
// Target account that received the wire transfer.
payto_uri: string;
// Base URL of the exchange that made the wire transfer.
exchange_url: string;
}
interface MerchantTrackTransferResponse {
// Total amount transferred.
total: Amount;
// Applicable wire fee that was charged.
wire_fee: Amount;
// Time of the execution of the wire transfer by the exchange, according to the exchange.
execution_time: Timestamp;
// Details about the deposits.
deposits_sums: MerchantTrackTransferDetail[];
}
type ExchangeConflictDetails = WireFeeConflictDetails |
TrackTransferConflictDetails;
// Note: this is not the full 'proof' of misbehavior, 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:
code: "TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_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;
}
interface TrackTransferConflictDetails {
// Numerical error code.
code: "TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_REPORTS";
// Text describing the issue for humans.
hint: string;
// 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.
//
// 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;
// Amount the exchange counted the coin for in the transfer.
amount_with_fee: Amount;
// Expected value of the coin.
coin_value: Amount;
// Expected deposit fee of the coin.
coin_fee: Amount;
// Expected deposit fee of the coin.
deposit_fee: Amount;
}
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;
}
GET
[/instances/$INSTANCE]/private/transfers
¶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:
-20
.transfer_serial_id
for an iteration.Response:
interface TransferList {
// List of all the transfers that fit the filter that we know.
transfers : 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;
// Target 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: number;
// 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;
// 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;
// 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).
confirmed?: boolean;
}
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 no longer possible once we got a reply from the exchange.
DELETE
[/instances/$INSTANCE]/private/transfers/$TID
¶Here, the TID is the ‘transfer_serial_id’ of the transfer to delete.
Response:
Tips are a way for websites to give small amounts of e-cash to visitors (for example as a financial reward for providing information or watching advertizements). Tips are non-contractual: neither merchant nor consumer have any contractual information about the other party as a result of the tip.
Reserves are basically funds a merchant has provided to an exchange for a tipping campaign. Each reserve has a limited lifetime (say 2–4 weeks). Any funds not used to tip customers will automatically be wired back from the exchange to the originating account.
To begin tipping, a merchant must tell the backend to set up a reserve. The backend will return a reserve public key which must be used as the wire transfer subject when wiring the tipping campaign funds to the exchange.
POST
[/instances/$INSTANCE]/private/reserves
¶Create a reserve for tipping.
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:
/wire
details from the specified exchange base URL.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;
}
interface ReserveCreateConfirmation {
// Public key identifying the reserve.
reserve_pub: EddsaPublicKey;
// Wire account of the exchange where to transfer the funds.
payto_uri: string;
}
GET
[/instances/$INSTANCE]/private/reserves
¶Obtain list of reserves that have been created for tipping.
Request:
Response:
interface TippingReserveStatus {
// Array of all known reserves (possibly empty!).
reserves: ReserveStatusEntry[];
}
interface ReserveStatusEntry {
// Public key of the reserve.
reserve_pub: EddsaPublicKey;
// 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;
// Is this reserve active (false if it was deleted but not purged)?
active: boolean;
}
GET
[/instances/$INSTANCE]/private/reserves/$RESERVE_PUB
¶Obtain information about a specific reserve that have been created for tipping.
Request:
Response:
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;
// URI to use to fill the reserve, can be NULL
// if the reserve is inactive or was already filled
payto_uri: string;
// URL of the exchange hosting the reserve,
// NULL if the reserve is inactive
exchange_url: string;
}
POST
[/instances/$INSTANCE]/private/reserves/$RESERVE_PUB/authorize-tip
¶Authorize creation of a tip from the given reserve.
Request:
The request body is a TipCreateRequest object.
Response:
interface TipCreateRequest {
// Amount that the customer should be tipped.
amount: Amount;
// 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;
}
interface TipCreateConfirmation {
// Unique tip identifier for the tip that was created.
tip_id: HashCode;
// taler://tip URI for the tip.
taler_tip_uri: string;
// URL that will directly trigger processing
// the tip when the browser is redirected to it.
tip_status_url: string;
// When does the tip expire?
tip_expiration: Timestamp;
}
POST
[/instances/$INSTANCE]/private/tips
¶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:
The request body is a TipCreateRequest object.
Response:
DELETE
[/instances/$INSTANCE]/private/reserves/$RESERVE_PUB
¶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.
Request:
Response:
GET
[/instances/$INSTANCE]/private/tips/$TIP_ID
¶Obtain information about a particular tip.
Request:
Response:
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[];
}
GET
[/instances/$INSTANCE]/private/tips
¶Return the list of all tips.
Request:
row_id
for an iteration.Response:
interface TipsResponse {
// List of tips that are present in the backend.
tips: Tip[];
}
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).
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). 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. 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 TBD mechanism can also be used to confirm payments.
POST
[/instances/$INSTANCE]/private/templates
¶This is used to create a template.
Request:
The request must be a TemplateAddDetails.
Response:
interface TemplateAddDetails {
// Template ID to use.
template_id: string;
// Human-readable description for the template.
template_description: string;
// A base64-encoded key of the point-of-sale.
// This parameter is optional.
pos_key?: string;
// Algorithm for computing the POS confirmation, 0 for none.
pos_algorithm?: Integer;
// Additional information in a separate template.
template_contract: TemplateContractDetails;
}
interface TemplateContractDetails {
// Human-readable summary for the template.
summary?: string;
// The price is imposed by the merchant and cannot be changed by the customer.
// This parameter is optional.
amount?: Amount;
// Minimum age buyer must have (in years). Default is 0.
minimum_age: Integer;
// 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;
}
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.
Request:
The request must be a TemplatePatchDetails.
Response:
interface TemplatePatchDetails {
// Human-readable description for the template.
template_description: string;
// A base64-encoded key of the point-of-sale.
// This parameter is optional.
pos_key?: string;
// Algorithm for computing the POS confirmation, 0 for none.
pos_algorithm?: Integer;
// Additional information in a separate template.
template_contract: TemplateContractDetails;
}
GET
[/instances/$INSTANCE]/private/templates
¶This is used to return the list of all the templates.
Response:
interface TemplateSummaryResponse {
// List of templates that are present in our backend.
templates_list: TemplateEntry[];
}
The TemplateEntry object describes a template. It has the following structure:
interface TemplateEntry {
// Template identifier, as found in the template.
template_id: string;
// Human-readable description for the template.
template_description: string;
}
GET
[/instances/$INSTANCE]/private/templates/$TEMPLATE_ID
¶This is used to obtain detailed information about a specific template.
Response:
interface TemplateDetails {
// Human-readable description for the template.
template_description: string;
// A base64-encoded key of the point-of-sale.
// This parameter is optional.
pos_key?: string;
// Algorithm for computing the POS confirmation, 0 for none.
pos_algorithm?: Integer;
// Additional information in a separate template.
template_contract: TemplateContractDetails;
}
DELETE
[/instances/$INSTANCE]/private/templates/$TEMPLATE_ID
¶This is used to delete information about a template. If we no longer use it.
Response:
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 UsingTemplateDetails and we accept JSON application and URL encoded.
Response:
The response is exactly the same type of response as when creating an order using POST /private/orders.
Details:
interface UsingTemplateDetails {
// Summary of the template
summary?: string;
// The amount entered by the customer.
amount?: Amount;
}
The webhook is a backend feature that is used to send a confirmation to the merchant. It can be send with a SMS, email or with another method. It will confirm that the customer paid the merchant. It will show the date and the price the customer paid.
POST
[/instances/$INSTANCES]/private/webhooks
¶This is used to create a webhook.
Request:
The request must be a WebhookAddDetails.
Response:
interface WebhookAddDetails {
// Webhook ID to use.
webhook_id: string;
// The event of the webhook: why the webhook is used.
event_type: string;
// 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;
}
PATCH
[/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID
¶This is used to update a webhook.
Request:
The request must be a WebhookPatchDetails.
Response:
interface WebhookPatchDetails {
// The event of the webhook: why the webhook is used.
event_type: string;
// 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;
}
GET
[/instances/$INSTANCES]/private/webhooks
¶This is used to return all the webhooks that are present in our backend.
Response:
interface WebhookSummaryResponse {
// Return webhooks that are present in our backend.
webhooks: WebhookEntry[];
}
The WebhookEntry object describes a webhook. It has the following structure:
interface WebhookEntry {
// Webhook identifier, as found in the webhook.
webhook_id: string;
// The event of the webhook: why the webhook is used.
event_type: string;
}
GET
[/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID
¶This is used to obtain detailed information about apecific template.
Response:
interface WebhookDetails {
// The event of the webhook: why the webhook is used.
event_type: string;
// 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;
}
DELETE
[/instances/$INSTANCES]/private/webhooks/$WEBHOOK_ID
¶This is used to delete information about a webhook.
Response:
This section describes the overall structure of the contract terms that are the foundation for Taler payments.
The contract terms must have the following structure:
interface ContractTerms {
// 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, free-form identifier for the proposal.
// 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;
// Total price for the transaction.
// The exchange will subtract deposit fees from that amount
// before transferring it to the merchant.
amount: Amount;
// 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;
// URL that will show that the order was successful after
// it has been paid for. Optional. When POSTing to the
// merchant, the placeholder "${ORDER_ID}" will be
// replaced with the actual order ID (useful if the
// order ID is generated server-side and needs to be
// in the URL).
// Note that this placeholder can only be used once.
// Either fulfillment_url or fulfillment_message must be specified.
fulfillment_url?: string;
// Message shown to the customer after paying for the order.
// 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 };
// Maximum total deposit fee accepted by the merchant for this contract.
max_fee: Amount;
// Maximum wire fee accepted by the merchant (customer share to be
// divided by the wire_fee_amortization factor, and further reduced
// if deposit fees are below max_fee). Default if missing is zero.
max_wire_fee: Amount;
// Over how many customer transactions does the merchant expect to
// amortize wire fees on average? If the exchange's wire fee is
// above max_wire_fee, the difference is divided by this number
// to compute the expected customer's contribution to the wire fee.
// The customer's contribution may further be reduced by the difference
// between the max_fee and the sum of the actual deposit fees.
// Optional, default value if missing is 1. 0 and negative values are
// invalid and also interpreted as 1.
wire_fee_amortization: number;
// List of products that are part of the purchase (see Product).
products: Product[];
// Time when this contract was generated.
timestamp: Timestamp;
// After this deadline has passed, no refunds will be accepted.
refund_deadline: Timestamp;
// After this deadline, the merchant won't accept payments for the contract.
pay_deadline: Timestamp;
// Transfer deadline for the exchange. Must be in the
// deposit permissions of coins used to pay for this order.
wire_transfer_deadline: Timestamp;
// Merchant's public key used to sign this proposal; this information
// is typically added by the backend. Note that this can be an ephemeral key.
merchant_pub: EddsaPublicKey;
// Base URL of the (public!) merchant backend API.
// Must be an absolute URL that ends with a slash.
merchant_base_url: string;
// More info about the merchant, see below.
merchant: Merchant;
// The hash of the merchant instance's wire details.
h_wire: HashCode;
// Wire transfer method identifier for the wire method associated with h_wire.
// The wallet may only select exchanges via a matching auditor if the
// exchange also supports this wire method.
// The wire transfer fees must be added based on this wire transfer method.
wire_method: string;
// Any exchanges audited by these auditors are accepted by the merchant.
auditors: Auditor[];
// Exchanges that the merchant accepts even if it does not accept any auditors that audit them.
exchanges: Exchange[];
// Delivery location for (all!) products.
delivery_location?: Location;
// Time indicating when the order should be delivered.
// May be overwritten by individual products.
delivery_date?: Timestamp;
// Nonce generated by the wallet and echoed by the merchant
// in this field when the proposal is generated.
nonce: string;
// Specifies for how long the wallet should try to get an
// automatic refund for the purchase. If this field is
// present, the wallet should wait for a few seconds after
// the purchase and then automatically attempt to obtain
// a refund. The wallet should probe until "delay"
// after the payment was successful (i.e. via long polling
// or via explicit requests with exponential back-off).
//
// In particular, if the wallet is offline
// at that time, it MUST repeat the request until it gets
// one response from the merchant after the delay has expired.
// If the refund is granted, the wallet MUST automatically
// recover the payment. This is used in case a merchant
// knows that it might be unable to satisfy the contract and
// desires for the wallet to attempt to get the refund without any
// customer interaction. Note that it is NOT an error if the
// merchant does not grant a refund.
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.
extra?: any;
}
The wallet must select an exchange that either the merchant accepts directly by listing it in the exchanges array, or for which the merchant accepts an auditor that audits that exchange by listing it in the auditors array.
The Product object describes the product being purchased from the merchant. It has the following structure:
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 number of units of the product to deliver to the customer.
quantity?: Integer;
// Unit in which the product is measured (liters, kilograms, packages, etc.).
unit?: 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 taxes paid by the merchant for this product. Can be empty.
taxes?: Tax[];
// Time indicating when this product should be delivered.
delivery_date?: Timestamp;
}
interface Tax {
// The name of the tax.
name: string;
// Amount paid in tax.
tax: Amount;
}
interface Merchant {
// The merchant's legal name of business.
name: string;
// Label for a location with the business address of the merchant.
email?: string;
// Label for a location with the business address of the merchant.
website?: string;
// An optional base64-encoded product image.
logo?: ImageDataUrl;
// Label for a location with the business address of the merchant.
address?: Location;
// Label for a location that denotes the jurisdiction for disputes.
// Some of the typical fields for a location (such as a street address) may be absent.
jurisdiction?: Location;
}
// Delivery location, loosely modeled as a subset of
// ISO20022's PostalAddress25.
interface Location {
// Nation with its own government.
country?: string;
// Identifies a subdivision of a country such as state, region, county.
country_subdivision?: string;
// Identifies a subdivision within a country sub-division.
district?: string;
// Name of a built-up area, with defined boundaries, and a local government.
town?: string;
// Specific location name within the town.
town_location?: string;
// Identifier consisting of a group of letters and/or numbers that
// is added to a postal address to assist the sorting of mail.
post_code?: string;
// Name of a street or thoroughfare.
street?: string;
// Name of the building or house.
building_name?: string;
// Number that identifies the position of a building on a street.
building_number?: string;
// Free-form address lines, should not exceed 7 elements.
address_lines?: string[];
}
interface Auditor {
// Official name.
name: string;
// Auditor's public key.
auditor_pub: EddsaPublicKey;
// Base URL of the auditor.
url: string;
}
interface Exchange {
// The exchange's base URL.
url: string;
// Master public key of the exchange.
master_pub: EddsaPublicKey;
}
In addition to the fields described above,
each object (from ContractTerms
down)
can mark certain fields as “forgettable” by listing the names of those fields
in a special peer field _forgettable
.
(See Private order data cleanup.)