taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

post-templates-TEMPLATE_ID.rst (3833B)


      1 .. http:post:: [/instances/$INSTANCE]/templates/$TEMPLATE_ID
      2 
      3   This using template can be modified by everyone and will be used to create order.
      4 
      5 
      6   **Request:**
      7 
      8   The request must be a `UsingTemplateDetailsRequest` and we accept JSON application and URL encoded.
      9 
     10   **Response:**
     11 
     12   :http:statuscode:`400 Bad Request`:
     13     The request body is malformed.
     14     Returned with ``TALER_EC_GENERIC_PARAMETER_MALFORMED``,
     15     ``TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_AMOUNT``,
     16     ``TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_CURRENCY``,
     17     ``TALER_EC_MERCHANT_POST_USING_TEMPLATES_NO_SUMMARY``,
     18     ``TALER_EC_MERCHANT_POST_USING_TEMPLATES_AMOUNT_CONFLICT_TEMPLATES_CONTRACT_AMOUNT``,
     19     ``TALER_EC_MERCHANT_POST_USING_TEMPLATES_SUMMARY_CONFLICT_TEMPLATES_CONTRACT_SUBJECT``,
     20     ``TALER_EC_MERCHANT_POST_USING_TEMPLATES_WRONG_PRODUCT``,
     21     ``TALER_EC_MERCHANT_POST_USING_TEMPLATES_WRONG_TYPE`` or
     22     ``TALER_EC_MERCHANT_GENERIC_CURRENCY_MISMATCH``.
     23   :http:statuscode:`404 Not found`:
     24     The template, instance, or product is unknown.
     25     Returned with ``TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN`` or
     26     ``TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN``.
     27   :http:statuscode:`413 Request entity too large`:
     28     The uploaded body is to long, it exceeds the size limit.
     29     Returned with an error code of
     30     ``TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMIT``.
     31   :http:statuscode:`500 Internal Server Error`:
     32     The server experienced an internal failure.
     33     Returned with ``TALER_EC_GENERIC_DB_FETCH_FAILED``,
     34     ``TALER_EC_GENERIC_FAILED_COMPUTE_AMOUNT`` or
     35     ``TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE``.
     36 
     37   The response is exactly the same type of response as when
     38   creating an order using :ref:`POST /private/orders <post-order>`.
     39 
     40   **Details:**
     41 
     42   .. ts:def:: UsingTemplateDetailsRequest
     43 
     44     type UsingTemplateDetailsRequest = (UsingTemplateFixedOrderRequest | UsingTemplateInventoryCartRequest | UsingTemplatePaivanaRequest) & UsingTemplateCommonRequest;
     45 
     46   .. ts:def:: UsingTemplateCommonRequest
     47 
     48     interface UsingTemplateCommonRequest {
     49 
     50       // Type of the template being instantiated.
     51       // Possible values include "fixed-order",
     52       // "inventory-cart" and "paivana".
     53       // Since protocol **v25**.
     54       // Defaults to "fixed-order" while supporting previous
     55       // protocol versions.
     56       template_type: string;
     57 
     58       // Summary to use in the contract. Only if
     59       // not already specified by the template.
     60       summary?: string;
     61 
     62       // The amount to be paid, including tip.
     63       amount?: Amount;
     64 
     65       // Optional tip amount. Must match the currency of ``amount`` or the
     66       // fixed template currency.
     67       // Since protocol **v25**.
     68       tip?: Amount;
     69 
     70     }
     71 
     72   .. ts:def:: UsingTemplateFixedOrderRequest
     73 
     74     interface UsingTemplateFixedOrderRequest {
     75        template_type: "fixed-order";
     76 
     77     }
     78 
     79   .. ts:def:: UsingTemplateInventoryCartRequest
     80 
     81     interface UsingTemplateInventoryCartRequest {
     82       template_type: "inventory-cart";
     83 
     84       // Inventory-cart: selected products and quantities.
     85       // Since protocol **v25**.
     86       inventory_selection?: InventorySelectionEntry[];
     87     }
     88 
     89   .. ts:def:: InventorySelectionEntry
     90 
     91     interface InventorySelectionEntry {
     92       // Inventory product to add.
     93       product_id: string;
     94 
     95       // Quantity in "<integer>[.<fraction>]" form using the product unit rules.
     96       quantity: DecimalQuantity;
     97     }
     98 
     99   .. ts:def:: UsingTemplatePaivanaRequest
    100 
    101     interface UsingTemplatePaivanaRequest {
    102       template_type: "paivana";
    103 
    104       // URL of the Paivana-protected website to be
    105       // accessed. Will become the fulfillment URL in
    106       // the contract.
    107       website: string;
    108 
    109       // Client Paivana ID to grant access to.
    110       // This becomes the "session_id" for session-based
    111       // access control.
    112       paivana_id: string;
    113 
    114     }