taler-docs

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

get-private-orders-ORDER_ID.rst (10056B)


      1 .. http:get:: [/instances/$INSTANCE]/private/orders/$ORDER_ID
      2 
      3   Merchant checks the payment status of an order.  If the order exists but is not paid
      4   and not claimed yet, the response provides a redirect URL.  When the user goes to this URL,
      5   they will be prompted for payment.  Differs from the ``public`` API both
      6   in terms of what information is returned and in that the wallet must provide
      7   the contract hash to authenticate, while for this API we assume that the
      8   merchant is authenticated (as the endpoint is not ``public``).
      9 
     10   **Required permission:** ``orders-read``
     11 
     12   **Request:**
     13 
     14   :query session_id: *Optional*. Session ID that the payment must be bound to.  If not specified, the payment is not session-bound.
     15   :query transfer: Deprecated in protocol **V6**. *Optional*. If set to "YES", try to obtain the wire transfer status for this order from the exchange. Otherwise, the wire transfer status MAY be returned if it is available.
     16   :query timeout_ms: *Optional*. Timeout in milliseconds to wait for a payment if the answer would otherwise be negative (long polling).
     17   :query lp_not_etag=ETAG: *Optional*.
     18     Specifies what status change we are long-polling for.
     19     If specified, the endpoint will only return once the returned "Etag"
     20     would differ from the ETAG specified by the client. The "Etag"
     21     is computed over the entire response body, and thus assured to change
     22     whenever any data point in the response changes. This is ideal for
     23     clients that want to learn about any change in the response.  Clients
     24     using this query parameter should probably also set a "If-none-match"
     25     HTTP header so that if the ``timeout_ms`` expires, they can get back
     26     a "304 Not modified" with an empty body if nothing changed.
     27   :query allow_refunded_for_repurchase: *Optional*. Since protocol **v9** refunded orders are only returned under "already_paid_order_id" if this flag is set explicitly to "YES".
     28 
     29   **Response:**
     30 
     31   :http:statuscode:`200 OK`:
     32     Returns a `MerchantOrderStatusResponse`, whose format can differ based on the status of the payment.
     33   :http:statuscode:`304 Not modified`:
     34     The ``ETag`` in the response did not change compared to the one
     35     given in the ``If-none-match`` HTTP header specified by the client.
     36     @since protocol **v25**.
     37   :http:statuscode:`400 Bad Request`:
     38     A query parameter or HTTP header is malformed.
     39     Returned with ``TALER_EC_GENERIC_PARAMETER_MALFORMED`` or
     40     ``TALER_EC_GENERIC_HTTP_HEADERS_MALFORMED``.
     41   :http:statuscode:`404 Not found`:
     42     The order or instance is unknown to the backend. Error code
     43     is set to either ``TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN`` or
     44     ``TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN``.
     45   :http:statuscode:`500 Internal Server Error`:
     46     The server experienced an internal failure.
     47     Returned with ``TALER_EC_GENERIC_DB_FETCH_FAILED``,
     48     ``TALER_EC_GENERIC_DB_INVARIANT_FAILURE``,
     49     ``TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH``,
     50     ``TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID`` or
     51     ``TALER_EC_MERCHANT_GET_ORDERS_ID_INVALID_CONTRACT_VERSION``.
     52 
     53   **Details:**
     54 
     55   .. ts:def:: MerchantOrderStatusResponse
     56 
     57     type MerchantOrderStatusResponse = CheckPaymentPaidResponse |
     58                                        CheckPaymentClaimedResponse |
     59                                        CheckPaymentUnpaidResponse;
     60 
     61   .. ts:def:: CheckPaymentPaidResponse
     62 
     63     interface CheckPaymentPaidResponse {
     64       // The customer paid for this contract.
     65       order_status: "paid";
     66 
     67       // Was the payment refunded (even partially)?
     68       refunded: boolean;
     69 
     70       // True if there are any approved refunds that the wallet has
     71       // not yet obtained.
     72       refund_pending: boolean;
     73 
     74       // Did the exchange wire us the funds?
     75       wired: boolean;
     76 
     77       // Total amount the exchange deposited into our bank account
     78       // for this contract, excluding fees.
     79       deposit_total: Amount;
     80 
     81       // Numeric `error code <error-codes>` indicating errors the exchange
     82       // encountered tracking the wire transfer for this purchase (before
     83       // we even got to specific coin issues).
     84       // 0 if there were no issues.
     85       exchange_code: Integer;
     86 
     87       // HTTP status code returned by the exchange when we asked for
     88       // information to track the wire transfer for this purchase.
     89       // 0 if there were no issues.
     90       exchange_http_status: Integer;
     91 
     92       // Total amount that was refunded, 0 if refunded is false.
     93       refund_amount: Amount;
     94 
     95       // Contract terms.
     96       contract_terms: ContractTerms;
     97 
     98       // Index of the selected choice within the ``choices`` array of
     99       // ``contract terms``.
    100       // @since protocol **v21**
    101       choice_index?: Integer;
    102 
    103       // If the order is paid, set to the last time when a payment
    104       // was made to pay for this order. @since **v14**.
    105       last_payment: Timestamp;
    106 
    107       // The wire transfer status from the exchange for this order if
    108       // available, otherwise empty array.
    109       wire_details: TransactionWireTransfer[];
    110 
    111       // Groups about trouble obtaining wire transfer details,
    112       // empty array if no trouble were encountered.
    113       // @deprecated in protocol **v6**.
    114       // FIXME-REMOVED-ALREADY: the merchant backend no longer emits this
    115       // field; it is deprecated here but already gone from the code.
    116       wire_groups: TransactionWireReport[];
    117 
    118       // The refund details for this order.  One entry per
    119       // refunded coin; empty array if there are no refunds.
    120       refund_details: RefundDetails[];
    121 
    122       // Status URL, can be used as a redirect target for the browser
    123       // to show the order QR code / trigger the wallet.
    124       order_status_url: string;
    125     }
    126 
    127   .. ts:def:: CheckPaymentClaimedResponse
    128 
    129     interface CheckPaymentClaimedResponse {
    130       // A wallet claimed the order, but did not yet pay for the contract.
    131       order_status: "claimed";
    132 
    133       // Contract terms.
    134       contract_terms: ContractTerms;
    135 
    136       // Status URL, can be used as a redirect target for the browser
    137       // to show the order QR code / trigger the wallet.
    138       // Since protocol **v19**.
    139       order_status_url: string;
    140     }
    141 
    142   .. ts:def:: CheckPaymentUnpaidResponse
    143 
    144     interface CheckPaymentUnpaidResponse {
    145       // The order was not yet claimed (and thus certainly also
    146       // not yet paid).
    147       order_status: "unpaid";
    148 
    149       // URI that the wallet must process to complete the payment.
    150       taler_pay_uri: string;
    151 
    152       // Time when the order was created.
    153       creation_time: Timestamp;
    154 
    155       // Deadline when the offer expires; the customer must pay before.
    156       // @since protocol **v21**.
    157       // @deprecated in **v25** (use proto_contract_terms.pay_deadline instead).
    158       pay_deadline: Timestamp;
    159 
    160       // Order summary text.
    161       // @deprecated in **v25** (use proto_contract_terms.summary instead).
    162       summary: string;
    163 
    164       // We cannot return the "final" contract terms here because
    165       // the ``nonce`` is not available because the wallet did not yet
    166       // claim the order.
    167       // So the "ProtoContractTerms" are basically the contract terms,
    168       // but without the ``nonce``.
    169       // @since protocol **v25**.
    170       proto_contract_terms: ProtoContractTerms;
    171 
    172       // Total amount of the order (to be paid by the customer).
    173       // Will be undefined for unpaid v1 orders
    174       // @deprecated in **v25** (use proto_contract_terms instead).
    175       total_amount?: Amount;
    176 
    177       // Alternative order ID which was paid for already in the same session.
    178       // Only given if the same product was purchased before in the same session.
    179       already_paid_order_id?: string;
    180 
    181       // Fulfillment URL of an already paid order. Only given if under this
    182       // session an already paid order with a fulfillment URL exists.
    183       already_paid_fulfillment_url?: string;
    184 
    185       // Status URL, can be used as a redirect target for the browser
    186       // to show the order QR code / trigger the wallet.
    187       order_status_url: string;
    188 
    189     }
    190 
    191   .. ts:def:: RefundDetails
    192 
    193     interface RefundDetails {
    194       // Reason given for the refund.
    195       reason: string;
    196 
    197       // True if a refund is still available for the wallet for this payment.
    198       pending: boolean;
    199 
    200       // When was the refund approved with a POST to
    201       // [/instances/$INSTANCE]/private/orders/$ORDER_ID/refund
    202       timestamp: Timestamp;
    203 
    204       // Total amount that was refunded (minus a refund fee).
    205       amount: Amount;
    206     }
    207 
    208   .. ts:def:: TransactionWireTransfer
    209 
    210     interface TransactionWireTransfer {
    211       // Responsible exchange.
    212       exchange_url: string;
    213 
    214       // 32-byte wire transfer identifier.
    215       wtid: Base32;
    216 
    217       // Execution time of the wire transfer.
    218       execution_time: Timestamp;
    219 
    220       // Total amount that has been wire transferred
    221       // to the merchant from this exchange for this
    222       // purchase. The ``deposit_fee`` was already
    223       // subtracted. However, the ``wire_fee`` may still
    224       // apply (but not to the order, only to the aggregated transfer).
    225       amount: Amount;
    226 
    227       // Deposit fees to be paid to the
    228       // exchange for this order.
    229       // Since **v26**.
    230       deposit_fee: Amount;
    231 
    232       // Was this transfer confirmed by the merchant via the
    233       // POST /transfers API, or is it merely claimed by the exchange?
    234       confirmed: boolean;
    235 
    236       // Transfer serial ID of this wire transfer, useful as
    237       // ``offset`` for the GET ``/private/incoming`` endpoint.
    238       // Since **v25**.
    239       expected_transfer_serial_id: Integer;
    240     }
    241 
    242   .. ts:def:: TransactionWireReport
    243 
    244     interface TransactionWireReport {
    245       // Numerical `error code <error-codes>`.
    246       code: Integer;
    247 
    248       // Human-readable error description.
    249       hint: string;
    250 
    251       // Numerical `error code <error-codes>` from the exchange.
    252       exchange_code: Integer;
    253 
    254       // HTTP status code received from the exchange.
    255       exchange_http_status: Integer;
    256 
    257       // Public key of the coin for which we got the exchange error.
    258       coin_pub: CoinPublicKey;
    259     }