get-private-orders-ORDER_ID.rst (10922B)
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`` (see :ref:`Scopes <merchant-api-scopes>`) 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 // The refund details for this order. One entry per 112 // refunded coin; empty array if there are no refunds. 113 refund_details: RefundDetails[]; 114 115 // Refunds settled outside of Taler that were recorded for this 116 // order via 117 // [/instances/$INSTANCE]/private/orders/$ORDER_ID/refund-external. 118 // These are bookkeeping entries only; empty array if there are 119 // none. 120 // @since protocol **vMixedPayments**. 121 refunds_external: ExternalRefundInfo[]; 122 123 // Status URL, can be used as a redirect target for the browser 124 // to show the order QR code / trigger the wallet. 125 order_status_url: WebURL; 126 } 127 128 .. ts:def:: CheckPaymentClaimedResponse 129 130 interface CheckPaymentClaimedResponse { 131 // A wallet claimed the order, but did not yet pay for the contract. 132 order_status: "claimed"; 133 134 // Contract terms. 135 contract_terms: ContractTerms; 136 137 // Status URL, can be used as a redirect target for the browser 138 // to show the order QR code / trigger the wallet. 139 // Since protocol **v19**. 140 order_status_url: WebURL; 141 } 142 143 .. ts:def:: CheckPaymentUnpaidResponse 144 145 interface CheckPaymentUnpaidResponse { 146 // The order was not yet claimed (and thus certainly also 147 // not yet paid). 148 order_status: "unpaid"; 149 150 // URI that the wallet must process to complete the payment. 151 taler_pay_uri: string; 152 153 // Time when the order was created. 154 creation_time: Timestamp; 155 156 // Deadline when the offer expires; the customer must pay before. 157 // @since protocol **v21**. 158 // @deprecated in **v25** (use proto_contract_terms.pay_deadline instead). 159 pay_deadline: Timestamp; 160 161 // Order summary text. 162 // @deprecated in **v25** (use proto_contract_terms.summary instead). 163 summary: string; 164 165 // We cannot return the "final" contract terms here because 166 // the ``nonce`` is not available because the wallet did not yet 167 // claim the order. 168 // So the "ProtoContractTerms" are basically the contract terms, 169 // but without the ``nonce``. 170 // @since protocol **v25**. 171 proto_contract_terms: ProtoContractTerms; 172 173 // Total amount of the order (to be paid by the customer). 174 // Will be undefined for unpaid v1 orders 175 // @deprecated in **v25** (use proto_contract_terms instead). 176 total_amount?: Amount; 177 178 // Alternative order ID which was paid for already in the same session. 179 // Only given if the same product was purchased before in the same session. 180 already_paid_order_id?: Slug; 181 182 // Fulfillment URL of an already paid order. Only given if under this 183 // session an already paid order with a fulfillment URL exists. 184 already_paid_fulfillment_url?: WebURL; 185 186 // Status URL, can be used as a redirect target for the browser 187 // to show the order QR code / trigger the wallet. 188 order_status_url: WebURL; 189 190 } 191 192 .. ts:def:: RefundDetails 193 194 interface RefundDetails { 195 // Reason given for the refund. 196 reason: string; 197 198 // True if a refund is still available for the wallet for this payment. 199 pending: boolean; 200 201 // When was the refund approved with a POST to 202 // [/instances/$INSTANCE]/private/orders/$ORDER_ID/refund 203 timestamp: Timestamp; 204 205 // Total amount that was refunded (minus a refund fee). 206 amount: Amount; 207 } 208 209 .. ts:def:: ExternalRefundInfo 210 211 interface ExternalRefundInfo { 212 // Identifier of this refund within the order, either chosen by 213 // the merchant or assigned by the backend. 214 id: string; 215 216 // Method by which the funds were returned to the customer, 217 // for example "cash" or "card". May differ from the methods used 218 // to pay the order. Never "taler". 219 method: string; 220 221 // The ``id`` of the ``amount_external`` entry this refund 222 // reverses, when the refund maps to a specific original payment. 223 payment_id?: string; 224 225 // Amount returned to the customer via the external method. 226 amount: Amount; 227 228 // Human-readable refund justification. 229 reason: string; 230 231 // When the external refund was recorded at the backend. 232 timestamp: Timestamp; 233 } 234 235 .. ts:def:: TransactionWireTransfer 236 237 interface TransactionWireTransfer { 238 // Responsible exchange. 239 exchange_url: WebURL; 240 241 // 32-byte wire transfer identifier. 242 wtid: Base32; 243 244 // Execution time of the wire transfer. 245 execution_time: Timestamp; 246 247 // Total amount that has been wire transferred 248 // to the merchant from this exchange for this 249 // purchase. The ``deposit_fee`` was already 250 // subtracted. However, the ``wire_fee`` may still 251 // apply (but not to the order, only to the aggregated transfer). 252 amount: Amount; 253 254 // Deposit fees to be paid to the 255 // exchange for this order. 256 // Since **v26**. 257 deposit_fee: Amount; 258 259 // Was this transfer confirmed by the merchant via the 260 // POST /transfers API, or is it merely claimed by the exchange? 261 confirmed: boolean; 262 263 // Transfer serial ID of this wire transfer, useful as 264 // ``offset`` for the GET ``/private/incoming`` endpoint. 265 // Since **v25**. 266 expected_transfer_serial_id: Integer; 267 } 268 269 .. ts:def:: TransactionWireReport 270 271 interface TransactionWireReport { 272 // Numerical `error code <error-codes>`. 273 code: Integer; 274 275 // Human-readable error description. 276 hint: string; 277 278 // Numerical `error code <error-codes>` from the exchange. 279 exchange_code: Integer; 280 281 // HTTP status code received from the exchange. 282 exchange_http_status: Integer; 283 284 // Public key of the coin for which we got the exchange error. 285 coin_pub: CoinPublicKey; 286 }