Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

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

https://intlmapi.alipay.com/gateway.do

Test environment

https://mapi.alipaydev.com/gateway.do

Request parameters

ParameterDescription
Basic parameter

service

String Required

Interface name 

Example:alipay.acquire.overseas.spot.refund

sign

String Required

Sign value

Example:c8il4epm90wyn768fijgqhy8tay37gqa

sign_type
String Required

Sign type. RSA, RSA2 and MD5 are supported. Use uppercase. 

Example:MD5

partner

String(16) Required

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. 

Example:2088*********662

_input_charset

String

The charset with which the request data is encoded. The default value is GBK. UTF-8 is supported.

Example:UTF-8

notify_url

URL(200)

The URL for receiving asynchronous notifications after the payment is completed.

Example:https://www.test.com/alipay/notify_url.php

Operation parameter

partner_trans_id

String(64)

Required

The original partner transaction ID given in the payment request

Example:2010121000000002

alipay_trans_id

String(64)

The Alipay transaction ID 

Example:201311221703338463

partner_refund_id

String(64)

 Required

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.

Example:301012133000002

refund_amount

Number(9,2)

Required

Refund amount, which must be less than or equal to the original transaction amount or the left transaction amount if ever refunded. 

Example:39.25

currency

String(10)

Required

The refund currency. Only HKD is supported.

Example:HKD

refund_reson

String(128)

The reason of refund 

Example:Refund the good

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. 

Example:Y

Note:

Do not use the halfwidth quotation mark (") in parameter values.

Response

Synchronous response parameters

Parameters accepted by Alipay gateway:

ParameterDescription

is_success

String(1) Required

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. 

Example:T

sign_type

String Required

Sign type. RSA, RSA2 and MD5 are supported. Use uppercase. 

Example:MD5

sign

String(32) Required

Sign value

Example:59c7275cf3c82f038b7c0076f9888926

result_code

String(32) Required

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. 

Example:SUCCESS

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.

Example:TRANS_NOT_FOUND

partner_trans_id

String(64) Required

Equal to the partner_trans_id field given in the request

Example:201311221000000002

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.

Example:201311221703338463

partner_refund_id

String(64) Required

The refund order id in the partner system. The partner_refund_id field plus the partner field identifies a refund transaction. 

Example:301012133000002

refund_amount

Number(9,2)

Required

Refund amount, which must be less than or equal to the original transaction amount or the left transaction amount if ever refunded. 

Example:39.25

currency

String(10)

Required

The refund currency. Only HKD is supported.. 

Example:HKD

Parameters rejected by Alipay gateway:

ParameterDescription

is_success

String(1)

Required

Indicates whether the request is accepted by the Alipay gateway.

T: accepted

F: rejected

Example:F

sign_type

String Required

Sign type. RSA, RSA2 and MD5 are supported. Use uppercase. 

Example:MD5

sign

String(32) Required

Sign value

Example:59c7275cf3c82f038b7c0076f9888926

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.

Example:TRANS_NOT_FOUND

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.

ParameterDescription
Basic parameter

notify_time

Timestamp Required

The time when the notification is sent. The time format is yyyy-MM-dd HH:mm:ss. 

Example:2013-11-27 15:45:58

notify_type

String Required

Notification type 

Example:refund_status_sync

notify_id

String Required

Notification ID, used by the partner system to verify the notification 

Example:ac05099524730693a8b 330c5ecf72da978

sign_type

String Required

Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.

Example:MD5

sign

String Required

Sign value

Example:601510b7970e52cc63d b0f44997cf70e

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.

Example:990xxxxxxx8989

out_return_no

String(64) Required

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. 

Example:301012133000002

refund_status

String(64) Required

The refund status. The value can be REFUND_SUCCESS for a successful refund or REFUND_FAIL for a failed refund.

Example:REFUND_SUCCESS

currency

String(8)

The refund currency

Example:HKD

return_amount

Number(9,2)

The refund amount in the refund currency

Example:1.00

trans_refund_fee

Number(9,2)

The estimated refund amount in the original transaction currency, for reference only.

Example:1.00

error_code

String

The reason for a refund with status of REFUND_FAIL. This field is nulll when the refund_status is REFUND_SUCCESS.

Example:ILLEGAL_SIGN

Error codes

Error codeDescription
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:

  1. Ensure that partner_trans_id is correct.
  2. If the issue persists, contact Alipay Technical Support.
TRADE_STATUS_ERROR

Corresponding trade status is not allowed for the current operation.

Action:

  1. Make sure the trade status is correct
  2. If the issue persists, contact Alipay technical support
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&notify_url=https%3A%2F%2Fwww.mikascoffee.com%2Fnotify&currency=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&notify_url=https%3A%2F%2Fwww.mikascoffee.com%2Fnotify&currency=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:

copy
<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:

copy
<?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

copy
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