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
Note:
The decimal place accuracy of amounts, such as the values of return_amount
, depends on the value of currency
. If the value of currency
isJPY
, then the amount must be an integer. For example, 100 JPY. For other currencies, the amount is of two decimal place accuracy. For example, 100.00 USD. Amounts in other formats will cause error, for example, 100.999 USD. The values of parameters such as return_rmb_amount
are also of two decimal places because the currency is CNY. is_sync YNTF
Response
Synchronous response
Parameter | Description |
is_success String | If the value of If the value of
|
error String | 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.
|
Asynchronous response
Parameter | Description |
Basic parameter | |
notify_type String | Notification type
|
notify_time Timestamp | The time when the notification is sent. The time format is yyyy-MM-dd HH:mm:ss.
|
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) | The unique transaction ID that is assigned by the merchant for the refund
|
out_return_no String(64) | Refund ID of the partner |
refund_status String(32) | The refund status. The value can be REFUND_SUCCESS for a successful refund or REFUND_FAIL for a failed refund.
|
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(8) | The currency for the refund
|
return_amount Number(9,2) | Refund amount
|
Error codes
Business errors
Returned result | Description |
REFUNDMENT_VALID_DATE_EXCEED | The refund cannot be performed after the specified refund time period. |
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. |
BUYER_NOT_EXIST | The buyer does not exist. |
REFUND_CHARGE_ERROR | The refund failed because the payment is in progress. Please try again later. |
MORE_THAN_ALLOW_REFUND_FOREX_FEE | The refund amount is more than the refundable amount. |
Access errors
Returned result | Description |
ILLEGAL_SIGN | Illegal signature |
ILLEGAL_SERVICE | 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
Request sample with the return_amount field specified
https://intlmapi.alipay.com/gateway.do?service=forex_refund&partner=2088021017666931&_input_charset=UTF-8&sign_type=MD5¬ify_url=https%3A%2F%2Fwww.mikascoffee.com%2Fnotify¤cy=USD&product_code=NEW_OVERSEAS_SELLER&out_return_no=out_return_no_20190904_142347&out_trade_no=out_trade_no_20190830_204330&return_amount=0.01&gmt_return=20190904142347&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=8080dd500a1ecb05a393e168d57090d2
Request sample with the return_rmb_amount field specified
https://intlmapi.alipay.com/gateway.do?service=forex_refund&partner=2088021017666931&_input_charset=UTF-8&sign_type=MD5¬ify_url=https%3A%2F%2Fwww.mikascoffee.com%2Fnotify¤cy=USD&product_code=NEW_OVERSEAS_SELLER&out_return_no=out_return_no_20190904_142347&out_trade_no=out_trade_no_20190830_204330&return_rmb_amount=0.07&gmt_return=20190904142347&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=4c13c00a832ebbd2a08379dd3d8e2ec6
Response
Synchronous response sample
Success response
<?xml version="1.0" encoding="GBK"?>
<alipay>
<is_success>T</is_success>
</alipay>
Error response
<?xml version="1.0" encoding="utf-8"?>
<alipay>
<is_success>F</is_success>
<error>ILLEGAL_SIGN</error>
</alipay>
Asynchronous response sample
https://www.mikascoffee.com/notify
notify_type=refund_status_sync
return_amount=0.01
notify_time=2019-09-04 18:07:27
out_trade_no=out_trade_no_20190826_204553
refund_status=REFUND_SUCCESS
sign=$$$
out_return_no=out_return_no_20190904_142349
currency=USD
sign_type=MD5
notify_id=201xxxxxxxxxxxxxxxxxxxxxxxxxxxx9467