/v1/payments/refundApply
POST /v1/payments/refundApply
The refundApply
Ā API is used to initiate a refund of a successful payment, refund a transaction and return money to the payer. The transaction can be refunded partially or fully. This API returns SUCCESS
Ā when deducting money from the merchant is successful.
Note:
1) The merchant/partner submits a refund request to wallets directly
2) Wallets determines whether the refund is successful based on its own payment status and respond to merchants/partners.
3) Multiple refund requests are supported for one successful payment, but the total refund amount can not be greater than the payment amount.
Message structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, seeļ¼
Request
Property | Data type | Required | Description | Example |
refundRequestId | StringĀ | Yes | The unqiue ID of a refund generated by merchants.
| "2019112719074101000700000088881xxxx" |
paymentId | StringĀ | Yes | TheĀ unqiueĀ ID of the corresponding original payment. Max. length: 64 characters. | "201911271907410100070000009999xxxx" |
refundAmount | Amount | Yes | Refund amount. | { Ā Ā "currency": "CLP", Ā Ā "value": "10000" Ā } |
refundReason | StringĀ | No | Refund reason. Max. length: 256 characters. | "have returned goods to the shop" |
Response
Property | Data type | Required | Description | Example |
result | Yes | The request result, which contains information such as status and error codes. | { Ā Ā "resultCode": "SUCCESS", Ā Ā "resultStatus": "S", Ā Ā "resultMessage": "success" Ā } | |
refundId | StringĀ | No | Unique refund order number. It isĀ generated by Wallet, which uniquely identifies the refund. It is mandatory when the result.resultStatus is S.Max. length: 64 characters. | "2019112719074101000700000019000xxxx" |
Result Process Logic
In the response, the result.resultStatus
field indicates the result of processing a request as follows.
resultStatus | DecriptionĀ |
S | The corresponding It means thatĀ the refund is successful, the merchant/partner can process as success. |
U | The corresponding It means that when handling the refund request, an unknown exception occurs. The merchant/partner can call the Refund Inquiry ( What needs to note is as follow:
If other response (almost never occur), the merchant/partner should process like U. |
F | That means this transaction is failed.Ā The corresponding It means that the refund is failed. The failure reasons can be the followings, but not limited to:Ā Ā
For details, see the followingĀ Error codes section. |
Error codes
Error codes are usually classified into the following categories:
- Common error codes: are common for all Mini Program OpenAPIs. Ā
- API-specific error codes: are listed in the following table.
resultStatus | resultCode | resultMessage |
S | SUCCESS | Success |
F | MSG_PARSE_ERROR | Message parsed error. |
F | FUNCTION_NOT_MATCH | Function parameter does not match API. |
F | INVALID_CLIENT | Invalid client. |
F | INVALID_SIGNATURE | Signature is invalid. |
F | INVALID_CLIENT_STATUS | Invalid client status. |
F | ORDER_STATUS_INVALID | Order status is invalid. |
F | ORDER_NOT_EXIST | Order does not exist. |
F | PARTNER_NOT_EXIST | Partner status abnormal. |
F | REFUND_AMOUNT_EXCEED | The total refund amount has exceed the payment amount. |
F | REFUND_WINDOW_EXCEED | Exceed Refund window. |
F | REPEAT_REQ_INCONSISTENT | Repeated submit, and requests are inconsistent. |
F | AGREEMENT_REFUND_NOT_ALLOWED | Refund not allowed by contract |
F | PARTIAL_REFUND_NOT_ALLOWED | Partial refund not allowed, Coupon payment may be included |
Sample
For example, a wallet user applies for refund of 100 USD of a successful payment at the merchant/partner. So the merchant/partner will call this refund API to the wallet to refund money to users.
- User can start a refund request from the Mini Program or the merchant cashier.
- The merchant server calls this refund interface to refund.
- E-wallet returns the refund result to the merchant server.
- The merchant should return the refund result to the Mini Program or the merchant cashier.
Request
{
"paymentId": "20221124111212800100166473700277756",
"refundRequestId": "rrIX-vONE-HiNM-QLMJ-emWN-sFlC-JX",
"refundAmount": {
"currency": "CLP",
"value": "123450"
},
"refundReason": "User refund the goods."
}
- refundRequestId is the unique ID of this refund request, generated by merchant/partner, merchant/partner should make sure it is unique, because wallet will use refundRequestId to do idempotent process.
- paymentIdĀ is the payment ID generated by Wallet, which is the unique payment identifier associated with this refund.
- refundAmountĀ describes 100 USD should refund to user, refund amount should less than origin payment amount. The amount to pay out for this refund.refundAmount.currency and paymentAmount.currency in payment request are the same. And if there are multiple refunds for a particular payment, the total successful refunded amount cannot exceed the payment amount in the payment transaction.
Note:
- paymentId and paymentRequestId can not both empty, wallet has to find out the origin payment order based on paymentId or paymentRequestId.
Response
{
"result": {
"resultCode": "SUCCESS",
"resultStatus": "S",
"resultMessage": "Success"
},
"refundId": "20221124111212800100166473700277756"
}
- result.resultStatus==S shows that the Wallet refund is successful.
- refundId is generated by Wallet, uniquely identifies the refund.
- refundTime describes the success date time of this refund.