alipay.acquire.overseas.spot.refund
Call this interface to issue a full or partial refund for a transaction. The refund request cannot be cancelled.
Request
Service address
Environment | HTTPS request URL |
Production environment | |
Test environment |
Request parameters
Parameter | Description |
Basic parameter | |
service String | Interface name
|
sign String | Sign value
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
partner String(16) | The partner ID that is assigned by Alipay to identify an Alipay account. The partner ID is composed of 16 digits and begins with 2088.
|
_input_charset String | The charset with which the request data is encoded. The default value is GBK. UTF-8 is supported.
|
notify_url URL(200) | The URL for receiving asynchronous notifications after the payment is completed.
|
Operation parameter | |
partner_trans_id String(64) | The original partner transaction ID given in the payment request
|
alipay_trans_id String(64) | The Alipay transaction ID
|
partner_refund_id String(64)
| The refund order ID in the partner system. The value of partner_refund_id cannot be the same as that of partner_transaction_id. The partner_refund_id field plus the partner field identifies a refund transaction.
|
refund_amount Number(9,2) | Refund amount, which must be less than or equal to the original transaction amount or the left transaction amount if ever refunded.
|
currency String(10) | The refund currency. Only HKD is supported.
|
refund_reson String(128) | The reason of refund
|
is_sync String(1) | Indicates that the refund request is processed synchronously or asynchronously with a value of Y or N. The default value is N, which means an asynchronous response from Alipay is returned to the merchant if the merchant has set the value of the notify_url field when sending the refund request. If the value is set as Y, it means only a synchronous response is returned to the merchant.
|
Note:
Do not use the halfwidth quotation mark (") in parameter values.
Response
Synchronous response parameters
Parameters accepted by Alipay gateway:
Parameter | Description |
is_success String(1) | Indicates whether the request succeeds or not, with a value of T for success and F for failure. Note: a successful request does not mean the business is accepted and processed successfully.
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
sign String(32) | Sign value
|
result_code String(32) | Processing result of the request, with a value of SUCCESS to indicate the process is successful, FAIL to indicate the process is failed, or UNKNOWN to indicate an unknown result.
|
error String(48) | Error code that is returned when the request is not successful, to describe the request failure reason. For more information, see the Error Code section in this document.
|
partner_trans_id String(64) | Equal to the partner_trans_id field given in the request
|
alipay_trans_id String(64) | The transaction ID assigned by Alipay for the partner’s payment request, which follows a mapping relation with the partner field plus the partner_trans_id field.
|
partner_refund_id String(64) | The refund order id in the partner system. The partner_refund_id field plus the partner field identifies a refund transaction.
|
refund_amount Number(9,2) | Refund amount, which must be less than or equal to the original transaction amount or the left transaction amount if ever refunded.
|
currency String(10) | The refund currency. Only HKD is supported..
|
Parameters rejected by Alipay gateway:
Parameter | Description |
is_success String(1) | Indicates whether the request is accepted by the Alipay gateway. T: accepted F: rejected
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
sign String(32) Required | Sign value
|
error String(48) | Error code that is returned when the request is not successful, to describe the request failure reason. For more information, see the Error Code section in this document.
|
Asynchronous response parameters
Alipay notifies the merchant website of the result data processed through an initiative notification from the server after completing the processing of request data of merchant. These result data are asynchronous notification parameters from the server.
Parameter | Description |
Basic parameter | |
notify_time Timestamp | The time when the notification is sent. The time format is yyyy-MM-dd HH:mm:ss.
|
notify_type String | Notification type
|
notify_id String | Notification ID, used by the partner system to verify the notification
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
sign String | Sign value
|
Business parameter | |
out_trade_no String(64) | Unique order ID in the order system in corresponding merchant's website, other than Alipay trade number. Uniqueness of this parameter in merchant's website need to be guaranteed. This is a parameter transmitted upon corresponding request, which need to be returned in its orginal shape.
|
out_return_no String(64) | The refund order ID in the partner system. If the merchant initiates the refund request on the Alipay website, this parameter is to be filled with an automatically generated number by Alipay.
|
refund_status String(64) | The refund status. The value can be REFUND_SUCCESS for a successful refund or REFUND_FAIL for a failed refund.
|
currency String(8) | The refund currency
|
return_amount Number(9,2) | The refund amount in the refund currency
|
trans_refund_fee Number(9,2) | The estimated refund amount in the original transaction currency, for reference only.
|
error_code String | The reason for a refund with status of REFUND_FAIL. This field is nulll when the refund_status is REFUND_SUCCESS.
|
Error codes
Error code | Description |
SYSTEM_ERROR | Alipay system is not available. Try again later. |
ILLEGAL_SIGN | Illegal signature. Use the legal signature and try again. |
INVALID_PARAMETER | Parameter value error. Check each request parameter according to the API specification. |
ILLEGAL_ARGUMENT | Parameter name error. Check each request parameter according to the API specification. Contact Alipay technical support if this error persists. |
ILLEGAL_PARTNER | Incorrect partner ID. Ensure that the value of the partner parameter matches the partner value provided by Alipay. Contact Alipay technical support if this error persists. |
ILLEGAL_EXTERFACE | Interface configure error. Ensure that the service parameter has the same value with the one in API specification. Contact Alipay technical support if this error persists. |
ILLEGAL_PARTNER_EXTERFACE | The partner ID does not have access privilege. Contact Alipay technical support. |
ILLEGAL_SIGN_TYPE | Illegal sign type. Ensure that the value of sign_type is among MD5, RSA and RSA2. Contact Alipay technical support if this error persists |
HAS_NO_PRIVILEGE | Has no privilege. Contact Alipay technical support. |
REASON_TRADE_BEEN_FREEZEN | Corresponding trade has been frozen due to security issues. Contact Alipay technical support. |
TRADE_NOT_EXIST | Cannot find the corresponding trade according to the value of partner_trans_id. Action:
|
TRADE_STATUS_ERROR | Corresponding trade status is not allowed for the current operation. Action:
|
REFUND_AMT_RESTRICTION | The value of refund_amount is more than the original trade amount, or the total refund amount is more than the original trade amount, which cannot be processed by Alipay. The merchant needs to check if the returned amount is correct. |
REQUEST_AMOUNT_EXCEED | The same with the REFUND_AMT_RESTRICTION error code. The merchant needs to check if the return amount is correct. |
RETURN_AMOUNT_EXCEED | The same with the REFUND_AMT_RESTRICTION error code. The merchant needs to check if the returned amount is correct. |
REFUND_CHARGE_ERROR | The refund is failed because the payment is in progress. Try again later. |
Samples
Request
Asynchronous refund request:
https://intlmapi.alipay.com/gateway.do?service=alipay.acquire.overseas.spot.refund&sign_type=MD5&partner=208xxxxxxxxx5500&_input_charset=UTF-8¬ify_url=https%3A%2F%2Fwww.mikascoffee.com%2Fnotify¤cy=HKD&partner_trans_id=partner_trans_id_2019010_000037&partner_refund_id=partner_trans_id_2019010_003252&refund_amount=0.01&refund_reson=%E4%B9%B0%E5%AE%B6%E4%B8%BB%E5%8A%A8%E9%80%80%E6%AC%BE&sign=33faf8e4ffc26188d71c1af74b5ca8d0
Synchronous refund request:
https://intlmapi.alipay.com/gateway.do?service=alipay.acquire.overseas.spot.refund&sign_type=MD5&partner=208xxxxxxxxx5500&_input_charset=UTF-8¬ify_url=https%3A%2F%2Fwww.mikascoffee.com%2Fnotify¤cy=HKD&partner_trans_id=partner_trans_id_2019010_000036&partner_refund_id=partner_trans_id_2019010_003252&refund_amount=0.01&refund_reson=%E4%B9%B0%E5%AE%B6%E4%B8%BB%E5%8A%A8%E9%80%80%E6%AC%BE&is_sync=Y&sign=15c29ae88de4cbaa7b90d219cf3467b3
Response
Synchronous response
Request succeeds, and the business processing succeeds:
<alipay>
<is_success>T</is_success>
<request>
<param name="partner_trans_id">partner_trans_id_2019010_000035</param>
<param name="partner">2088021966645500</param>
<param name="service">alipay.acquire.overseas.spot.refund</param>
<param name="_input_charset">UTF-8</param>
<param name="sign">3798890cf14f36bceb764eb3a3a44ab7</param>
<param name="refund_amount">0.01</param>
<param name="currency">HKD</param>
<param name="notify_url">https://www.mikascoffee.com/notify</param>
<param name="is_sync">Y</param>
<param name="sign_type">MD5</param>
<param name="partner_refund_id">partner_refund_id_20190904_160211</param>
</request>
<response>
<alipay>
<alipay_trans_id>2019091022001414270571637760</alipay_trans_id>
<currency>HKD</currency>
<partner_refund_id>partner_refund_id_20190904_160211</partner_refund_id>
<partner_trans_id>partner_trans_id_2019010_000035</partner_trans_id>
<refund_amount>0.01</refund_amount>
<result_code>SUCCESS</result_code>
</alipay>
</response>
<sign>acaa2e792c7473b9a20639b515c374e9</sign>
<sign_type>MD5</sign_type>
</alipay>
Request is failed:
<?xml version="1.0" encoding="UTF-8"?>
<alipay>
<is_success>F</is_success>
<error>ILLEGAL_SIGN</error>
<sign>02f6b289c46b8d0c1ea62b4f78637c1a</sign>
<sign_type>MD5</sign_type>
</alipay>
Asynchronous response
https://www.mikascoffee.com/notify
trans_refund_fee=0.01
notify_type=refund_status_sync
return_amount=0.01
notify_time=2019-09-11 03:06:12
out_trade_no=partner_trans_id_2019010_000037
refund_status=REFUND_SUCCESS
sign=$$$
out_return_no=partner_trans_id_2019010_003252
currency=HKD
sign_type=MD5
notify_id=201xxxxxxxxxxxxxxxxxxxxxxxxxxx5508