taler-docs

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

post-orders-ORDER_ID-abort.rst (5831B)


      1 .. http:post:: [/instances/$INSTANCE]/orders/$ORDER_ID/abort
      2 
      3   Abort paying for an order and obtain a refund for coins that
      4   were already deposited as part of a failed payment.
      5 
      6   **Request:**
      7 
      8   The request must be an `abort request <AbortRequest>`.  We force the wallet
      9   to specify the affected coins as it may only request for a subset of the coins
     10   (i.e. because the wallet knows that some were double-spent causing the failure).
     11   Also we need to know the coins because there may be two wallets "competing" over
     12   the same order and one wants to abort while the other still proceeds with the
     13   payment. Here we need to again know which subset of the deposits to abort.
     14 
     15   **Response:**
     16 
     17   :http:statuscode:`200 OK`:
     18     The merchant accepted the request, and passed it on to the exchange. The body is a
     19     a `abort response <AbortResponse>`. Note that the exchange
     20     MAY still have encountered errors in processing. Those will then be part of
     21     the body. Wallets MUST carefully consider errors for each of the coins as
     22     returned by the exchange.
     23   :http:statuscode:`400 Bad request`:
     24     Either the client request is malformed or some specific processing error
     25     happened that may be the fault of the client as detailed in the JSON body
     26     of the response.
     27   :http:statuscode:`403 Forbidden`:
     28     The ``h_contract`` does not match the $ORDER_ID.
     29   :http:statuscode:`404 Not found`:
     30     The merchant backend could not find the order or the instance
     31     and thus cannot process the abort request.
     32   :http:statuscode:`408 Request timeout`:
     33     The merchant backend took too long getting a response from the exchange.
     34     The wallet SHOULD retry soon.
     35   :http:statuscode:`412 Precondition failed`:
     36     Aborting the payment is not allowed, as the original payment did succeed.
     37     It is possible that a different wallet succeeded with the payment. This
     38     wallet should thus try to refresh all of the coins involved in the payment.
     39   :http:statuscode:`502 Bad gateway`:
     40     The merchant's interaction with the exchange failed in some way.
     41     The error from the exchange is included.
     42   :http:statuscode:`504 Gateway timeout`:
     43     The merchant's interaction with the exchange took too long.
     44     The client might want to try again later.
     45 
     46   The backend will return an `abort response <AbortResponse>`, which includes
     47   verbatim the error codes received from the exchange's
     48   :ref:`refund <exchange_refund>` API.  The frontend should pass the replies verbatim to
     49   the browser/wallet.
     50 
     51   **Details:**
     52 
     53   .. ts:def:: AbortRequest
     54 
     55     interface AbortRequest {
     56 
     57       // Hash of the order's contract terms (this is used to authenticate the
     58       // wallet/customer in case $ORDER_ID is guessable).
     59       h_contract: HashCode;
     60 
     61       // List of coins the wallet would like to see refunds for.
     62       // (Should be limited to the coins for which the original
     63       // payment succeeded, as far as the wallet knows.)
     64       coins: AbortingCoin[];
     65     }
     66 
     67   .. ts:def:: AbortingCoin
     68 
     69     interface AbortingCoin {
     70       // Public key of a coin for which the wallet is requesting an abort-related refund.
     71       coin_pub: EddsaPublicKey;
     72 
     73       // The amount to be refunded (matches the original contribution)
     74       // @Deprecated since **v18**.
     75       contribution: Amount;
     76 
     77       // URL of the exchange this coin was withdrawn from.
     78       exchange_url: string;
     79     }
     80 
     81 
     82   .. ts:def:: AbortResponse
     83 
     84     interface AbortResponse {
     85 
     86       // List of refund responses about the coins that the wallet
     87       // requested an abort for.  In the same order as the ``coins``
     88       // from the original request.
     89       // The ``rtransaction_id`` is implied to be 0.
     90       refunds: MerchantAbortPayRefundStatus[];
     91     }
     92 
     93   .. ts:def:: MerchantAbortPayRefundStatus
     94 
     95     type MerchantAbortPayRefundStatus =
     96       | MerchantAbortPayRefundSuccessStatus
     97       | MerchantAbortPayRefundUndepositedStatus
     98       | MerchantAbortPayRefundFailureStatus;
     99 
    100   .. ts:def:: MerchantAbortPayRefundFailureStatus
    101 
    102     // Details about why a refund failed.
    103     interface MerchantAbortPayRefundFailureStatus {
    104       // Used as tag for the sum type RefundStatus sum type.
    105       type: "failure";
    106 
    107       // HTTP status of the exchange request, must NOT be 200.
    108       exchange_status: Integer;
    109 
    110       // Taler error code from the exchange reply, if available.
    111       exchange_code?: Integer;
    112 
    113       // If available, HTTP reply from the exchange.
    114       exchange_reply?: Object;
    115     }
    116 
    117   .. ts:def:: MerchantAbortPayRefundSuccessStatus
    118 
    119     // Additional details needed to verify the refund confirmation signature
    120     // (``h_contract_terms`` and ``merchant_pub``) are already known
    121     // to the wallet and thus not included.
    122     interface MerchantAbortPayRefundSuccessStatus {
    123       // Used as tag for the sum type MerchantCoinRefundStatus sum type.
    124       type: "success";
    125 
    126       // HTTP status of the exchange request, 200 (integer) required for refund confirmations.
    127       exchange_status: 200;
    128 
    129       // The EdDSA :ref:`signature` (binary-only) with purpose
    130       // `TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND` using a current signing key of the
    131       // exchange affirming the successful refund.
    132       exchange_sig: EddsaSignature;
    133 
    134       // Public EdDSA key of the exchange that was used to generate the signature.
    135       // Should match one of the exchange's signing keys from ``/keys``.  It is given
    136       // explicitly as the client might otherwise be confused by clock skew as to
    137       // which signing key was used.
    138       exchange_pub: EddsaPublicKey;
    139     }
    140 
    141   .. ts:def:: MerchantAbortPayRefundUndepositedStatus
    142 
    143     // The merchant didn't deposit the coin in the first place,
    144     // no refund possible.
    145     interface MerchantAbortPayRefundSuccessStatus {
    146       // Used as tag for the sum type MerchantCoinRefundStatus sum type.
    147       type: "undeposited";
    148     }