forex_refund
Call this interface to refund a transaction.
To initiate multiple refund transactions by using a same partner ID (partner
), send the refund requests with an interval of at least 3 seconds.
Request
Service address
Environment | HTTPS request URL |
Production environment | |
Test environment |
Request parameters
Parameter | Description |
Basic parameter | |
service String | Interface name
|
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. UTF-8 is supported.
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
sign String | Sign value
|
notify_url URL(200) | The URL for receiving asynchronous notifications after the payment is completed.
|
Business parameter | |
out_return_no Required | The unique refund ID for the refund request
|
out_trade_no Required | The payment ID for the original payment transaction
|
return_amount | The amount to refund in the settlement currency. The value is in the range of 0.01 – 1000000.00, with at most 2 digits after the decimal point.
|
currency Required | The currency for the refund. Only HKD is supported.
|
gmt_return Required | Refund transaction time, with a format of yyyy-MM-dd HH:mm:ss. Use GMT+8.
|
reason Required | Reason for the refund
|
is_sync Required | 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
Parameter | Description |
is_success String | If the value of If the value of
|
error String | Error message
|
Asynchronous response
Parameter | Description |
Basic parameter | |
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
sign String | Sign value
|
Business parameter | |
notify_type String | Notification type, with a value of refund_status_sync
|
notify_id String(34) | Notification ID, used by the partner system to verify the notification
|
notify_time Timestamp | The time in GMT+8 when the notification is sent. The time format is yyyy-MM-dd HH:mm:ss.
|
refund_status String(32) | The refund status. The value can be REFUND_SUCCESS for a successful refund or REFUND_FAIL for a failed refund.
|
out_trade_no String(64) | The unique transaction ID that is assigned by the partner. This parameter is transmitted by the corresponding request and needs to be returned with the original value.
|
out_return_no String(64) | Refund ID of the partner |
error_code String(64) | Error code that is returned when the request is failed, to describe the request failure reason. For more information, see the Error Code section in this document.
|
currency String(3) | The refund currency
|
return_amount Number(9,2) | Refund amount
|
Error codes
Business errors
Returned result | Description |
REFUNDMENT_VALID_DATE_EXCEED | Cannot refund after the specified refund time. |
SYSTEM_EXCEPTION | System exception |
ILLEGAL_ARGUMENT | Illegal argument |
REPEATED_REFUNDMENT_REQUEST | Duplicated refund request |
RETURN_AMOUNT_EXCEED | Refund amount is over the payment amount |
CURRENCY_NOT_SAME | Different currency from the payment currency |
PURCHASE_TRADE_NOT_EXIST | The payment transaction does not exist |
REFUND_CHARGE_ERROR | The refund is failed because the payment is in progress. Please try again later. |
Access errors
Returned result | Description |
SYSTEM_EXCEPTION | Alipay system error |
ILLEGAL_ARGUMENT | Incorrect parameter |
ILLEGAL_SIGN | Illegal signature |
ILLEGAL_SERVICE | The service parameter is incorrect |
ILLEGAL_PARTNER | Incorrect partner ID |
ILLEGAL_SIGN_TYPE | Signature is of wrong type. |
ILLEGAL_PARTNER_EXTERFACE | Service is not activated for this account |
ILLEGAL_DYN_MD5_KEY | Dynamic key information is incorrect |
ILLEGAL_ENCRYPT | Encryption is incorrect. |
ILLEGAL_USER | User ID is incorrect. |
ILLEGAL_EXTERFACE | Interface configuration is incorrect. |
ILLEGAL_AGENT | Agency ID is incorrect. |
HAS_NO_PRIVILEGE | No right to visit |
INVALID_CHARACTER_SET | The character set is invalid. |
System errors
Returned result | Description |
SYSTEM_ERROR | Alipay system error |
SESSION_TIMEOUT | Session timeout |
ILLEGAL_TARGET_SERVICE | Wrong target service |
ILLEGAL_ACCESS_SWITCH_SYSTEM | Merchant is not allowed to visit system of this type. |
EXTERFACE_IS_CLOSED | The interface has been closed. |
Samples
Request
Asynchronous refund request:
https://intlmapi.alipay.com/gateway.do?service=forex_refund&partner=208xxxxxxxxx5500&_input_charset=UTF-8&sign_type=MD5¬ify_url=https%3A%2F%2Fwww.mikascoffee.com%2Fnotify¤cy=HKD&out_return_no=out_return_no_20190904_142347&out_trade_no=out_trade_no_20190910_140255&return_amount=0.01&gmt_return=20190910140255&reason=%E4%B9%B0%E5%AE%B6%E4%B8%BB%E5%8A%A8%E8%A6%81%E6%B1%82%E9%80%80%E6%AC%BE&sign=e1b27f1dedde149830e22da63091da7c
Synchronous refund request:
https://intlmapi.alipay.com/gateway.do?service=forex_refund&partner=208xxxxxxxxx5500&_input_charset=UTF-8&sign_type=MD5¬ify_url=https%3A%2F%2Fwww.mikascoffee.com%2Fnotify¤cy=HKD&out_return_no=out_return_no_20190904_142347&out_trade_no=out_trade_no_20190910_140255&return_amount=0.01&gmt_return=20190910140255&reason=%E4%B9%B0%E5%AE%B6%E4%B8%BB%E5%8A%A8%E8%A6%81%E6%B1%82%E9%80%80%E6%AC%BE&is_sync=Y&sign=83079e3e6540bf8efef87b1e76f4dbbf
Response
Synchronous response
<?xml version="1.0" encoding="GBK"?>
<alipay>
<is_success>T</is_success>
</alipay>
Asynchronous response
https://www.mikascoffee.com/notify
notify_type=refund_status_sync
return_amount=0.01
notify_time=2019-09-10 14:52:46
out_trade_no=out_trade_no_20190910_140255
refund_status=REFUND_SUCCESS
sign=$$$
out_return_no=out_return_no_20190904_142347
currency=HKD
sign_type=MD5
notify_id=201xxxxxxxxxxxxxxxxxxxxxxxxxxx1673