- POST [/instances/$INSTANCE]/templates/$TEMPLATE_ID#
This using template can be modified by everyone and will be used to create order.
Request:
The request must be a UsingTemplateDetailsRequest and we accept JSON application and URL encoded.
Response:
- 400 Bad Request:
The request body is malformed. Returned with
TALER_EC_GENERIC_PARAMETER_MALFORMED,TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_AMOUNT,TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_CURRENCY,TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_SUMMARY,TALER_EC_MERCHANT_POST_USING_TEMPLATES_AMOUNT_CONFLICT_TEMPLATES_CONTRACT_AMOUNT,TALER_EC_MERCHANT_POST_USING_TEMPLATES_SUMMARY_CONFLICT_TEMPLATES_CONTRACT_SUBJECT,TALER_EC_MERCHANT_POST_USING_TEMPLATES_WRONG_PRODUCT,TALER_EC_MERCHANT_POST_USING_TEMPLATES_WRONG_TYPEorTALER_EC_MERCHANT_GENERIC_CURRENCY_MISMATCH.- 404 Not found:
The template, instance, or product is unknown. Returned with
TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWNorTALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN.- 409 Conflict:
The request contradicts the template. In particular, this is returned with
TALER_EC_MERCHANT_POST_USING_TEMPLATES_AMOUNT_CONFLICT_TEMPLATES_CONTRACT_AMOUNTif the template fixes the amount but the request provides one, ifamountandchoice_amountsare both given, ifamountis used as a shorthand but the template has no or more than one choice witheditable_amount, if achoice_amountsentry selects a choice withouteditable_amount, or if a client-chosen amount violates themin_amountormax_amountof the template. Returned withTALER_EC_MERCHANT_GENERIC_CURRENCY_MISMATCHif a client-chosen amount is in the wrong currency.- 413 Request entity too large:
The uploaded body is to long, it exceeds the size limit. Returned with an error code of
TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMIT.- 500 Internal Server Error:
The server experienced an internal failure. Returned with
TALER_EC_GENERIC_DB_FETCH_FAILED,TALER_EC_GENERIC_FAILED_COMPUTE_AMOUNTorTALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE.
The response is exactly the same type of response as when creating an order using POST /private/orders.
Details:
type UsingTemplateDetailsRequest = (UsingTemplateFixedOrderRequest | UsingTemplateInventoryCartRequest | UsingTemplatePaivanaRequest) & UsingTemplateCommonRequest;
interface UsingTemplateCommonRequest { // Type of the template being instantiated. // Possible values include "fixed-order", // "inventory-cart" and "paivana". // Since protocol **v25**. // Defaults to "fixed-order" while supporting previous // protocol versions. template_type: string; // Summary to use in the contract. Only if // not already specified by the template. summary?: string; // The amount to be paid, including tip. // For a "paivana" template, this is a shorthand that is only // allowed if exactly one of the choices of the template has // "editable_amount" set: the amount then replaces the amount of // that choice, the tip is added on top of it (as for a choice // with a fixed amount), and the field is mutually exclusive with // "choice_amounts". amount?: Amount; // Optional tip amount. Must match the currency of amount or the // fixed template currency. // Since protocol **v25**. tip?: Amount; // Challenge obtained from an offline verifier, such as an // appliance or electronic tag: 32 bytes, Crockford Base32 // encoded. Stored // with the order and signed by the OTP device associated with // the template when the POS confirmation is computed. Only // meaningful -- and then mandatory -- if the template's OTP // device uses a challenge-signature algorithm ("ECDSA_CHALLENGE" // or "EDDSA_CHALLENGE"); rejected otherwise. // Since protocol **vChallengeConfirmation**. challenge?: string; }
interface UsingTemplateFixedOrderRequest { template_type: "fixed-order"; }
interface UsingTemplateInventoryCartRequest { template_type: "inventory-cart"; // Inventory-cart: selected products and quantities. // Since protocol **v25**. inventory_selection?: InventorySelectionEntry[]; }
interface InventorySelectionEntry { // Inventory product to add. product_id: Slug; // Quantity in "<integer>[.<fraction>]" form using the product unit rules. quantity: DecimalQuantity; }
interface UsingTemplatePaivanaRequest { template_type: "paivana"; // Website to which access is being sold. // Will become the fulfillment URL in the contract. website: WebURL; // Client Paivana ID to grant access to. // This becomes the "session_id" for session-based // access control. paivana_id: string; // Amounts chosen by the client for the choices of the template // that have "editable_amount" set. Choices that are not // mentioned keep the amount given in the template. Mutually // exclusive with the "amount" field. // Since protocol **v34**. choice_amounts?: TemplateChoiceAmount[]; }
interface TemplateChoiceAmount { // Index of the choice in the "choices" array of the template // contract. The choice must have "editable_amount" set. choice_index: Integer; // Amount to use for that choice, excluding any tip. Must be in // the currency of the choice, and within the "min_amount" and // "max_amount" bounds of the template (if any). Any "tip" given // in the request is added on top of this amount. amount: Amount; }