Refunding an Order
Overview
Reimbursing customers by issuing Total or Partial refunds for their orders is available via API.
Issuing refunds can be done on the REST protocol via a POST request to /orders/{RefNo}/refund/ and on SOAP and JSON-RPC protocols via the issueRefund method.
Availability
Refunding an order via API is available for all accounts.
Requirements
- Order must be in status COMPLETE
- Order must not be older than 3 months
- The refunded amount must not be higher than the total amount of the order
Request Object
Field name |
Type |
Required/Optional |
Description |
---|---|---|---|
RefNo |
String |
Required (only on SOAP and JSON-RPC) |
2Checkout generates unique reference numbers for the refunded order. |
Amount |
Double |
Required |
The amount refunded for that order. Can be equal to the order amount (for full order refund) or smaller (for partial refunds). The currency of the amount is the same as the currency the order was paid in. |
Items |
Array of RefundItem |
Required |
The details of the refunded items. |
Comment |
String |
Required |
Free text comment for the refund. |
Reason |
String |
Required |
The refund reason; must be one of the default refund reasons or a custom reason defined in the 2Checkout Merchant Control Panel. |
RefundItem Object
Field name |
Type |
Required/Optional |
Description |
---|---|---|---|
LineItemReference |
String |
Optional |
2Checkout product code for the refunded product. |
Quantity |
Integer |
Optional |
Quantity of product refunded. |
Amount |
Double |
Optional |
Amount refunded. |
Request example
REST
{
"amount": 23,
"items": [
{
"LineItemReference": "my_product_1",
"Quantity": 1
}
],
"comment": "requested by shopper",
"reason": "CUSTOM_REASON"
}
SOAP and JSON-RPC Example
For the SOAP and JSON-RPC protocols, the issueRefund method needs to be called with the components of the requests in the parameter list.
More information about issuing refunds can be found here (for JSON-RPC) and here (for SOAP).
The JSON-RPC object that needs to be sent would look like
{
"jsonrpc":"2.0",
"method":"issueRefund",
"params":[
"om7sb5uob2p2g9r321iif2v3hd7p5gkn", //session id
"11370513", //orderRef
"25.39", //amount
{
"Quantity":1, //quantity of product refunded
"Amount":25.39 //amount of product refunded
},
"This is a comment", //comment
"Duplicate purchase" //reason
],
"id":2
}
For SOAP requests, the following parameters need to be added to the SOAP request:
$refundedOrder = $client->issueRefund($sessionID, $orderReference, $amount, $items, $comment, $reason);
Response
The API will return a Boolean when issuing refunds. A true response means that the refund was registered successfully.
Error handling
A full list of errors returned by the issueRefund API method can be found here.