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

alipay.acquire.query

Call this interface to query transaction status and other details.

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 parameters

service

String Required

Service Name

Example:alipay.acquire.query

partner

String(16)

Partner ID that is composed of 16 digits beginning with 2088.

Example:2088101125328850

_input_charset

String Required

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

Example:UTF-8

sign_type

String Required

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

Example:RSA

sign

String Required

Sign value

Example:31a008138e2f26a6414119984553e538

alipay_ca_request
String

Signature type.

  • 1: Certificate signature
  • 2: Other key signatures

If this is null, the default value shall be 2.

Example:2

Business parameters

out_trade_no

String(64) Required

Unique order No. in Alipay’s merchant’s website

Example:HZ0120131127001

trade_no
String(64)

The trade serial number of the trade in Alipay system.16 bits at least and 64 bits at most. If out_trade_no and  trade_no are transmitted at the same time, trade_no shall govern.

Example:2013112611001004680 073956707

Response

ParameterDescription
Basic parameters

is_success
String Required

Request succeeds or not. Successful request does not mean the business is accepted and processed successfully.

  • T means success
  • F means failure

Example:T

sign_type

String

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

Example:MD5

sign
String

Sign value

Example:630c9331f0946bde8e164564d1f7aeeb

error
String

  • This parameter does not exist if request succeeds;
  • This parameter will be error code if request fails. Please refer to Access Errors and System Errors.

Example:ILLEGAL_SIGN

Business parameter

result_code
String(32) Required

Response code of refund processing result.

  • SUCCESS: successful refund
  • FAIL: unsuccessful refund
  • UNKNOWN: unknown result

Example:SUCCESS

trade_no
String(64)

Trade number of the trade in Alipay system16 bits at least and 64 bits at most

Example:2013111511001004390000105126

out_trade_no
String(64)

Unique order ID in order system in corresponding merchant’s website other than Alipay trade number.Uniqueness of this parameter in merchant’s website shall be guaranteed. This is a parameter transmitted upon corresponding request, which shall be returned in its original shape.

Example:3406822113320232

buyer_user_id
String(24)

Unique Alipay user ID corresponding to Buyer’s Alipay logon ID.16 numbers beginning with 2088

Example:2088102114647394

buyer_logon_id
String(100)

Buyer’s Alipay logon ID, may be email or phone number.

Example:ali***@alitest.com

partner
String(16)

Unique Alipay user number corresponding to authorized Alipay account number. Composed of 16 numbers beginning with 2088.

Example:2088101126765726

trade_status
String(32)

Current trade status.

Example:TRADE_CLOSED

detail_error_code
String(48)

Give cause description to the response code returned. Please refer to Business errors. If the response code of result_code is SUCCESS, this parameter shall not be returned.

Example:TRADE_NOT_EXIST

detail_error_des
String(64)

Give literal statement as to the detailed error code. If the response code of result_code is S UCCESS, this parameter shall not be returned.

Example:TRADE_NOT_EXIST

fund_bill_list
List

Information about the payment channel used in this trade shall be in the format of xml and may include the child node (<TradeFundBill>) of muti-channel information. Please refer to fund_bill_list. If the list of payment documents is required to be returned, partner and Alipay shall reach an agreement on return upon signing contract; the system gives tacit consent to not return this parameter.

Example:See Response sample

total_fee
String

Order amount paid in this trade, unit: RMB (Yuan).

Example:20

total_price
Number

The pricing in foreign currency. If the transaction is priced in RMB, this parameter is null

Example:10

currency
String(8)

The currency used for settlement.

Example:CNY

trans_currency
String(8)

Pricing currency of the transaction

Example:CNY

exchange_rate
String

Exchange rate of foreign currency and CNY (RMB).

Example:6.0939

send_pay_date
String

The time of transferring payment to seller’s account, format: yyyy-MM-dd HH:mm:ss.

Example:2014-07-21 11:43:42

extend_info_list
Object

The extend information list of the trade, XML format, can include multiple extension child node<ExtendInfo>. The Child node please refer to extend_info_list.

Example:See Response sample

fund_bill_list

ParameterDescription

fund_channel
String

Payment channel, please refer to Payment Channels.

Example:10

amount
String

Amount paid through the designated payment channel, Unit: Yuan

Example:70.00

extend_info_list

ParameterDescription

Key
String Required

Now only support:

  • SHOP_ID: The serial number of brands store that under the shop.
  • TERMINAL_ID: terminal device id.

Example:SHOP_ID

Value
String

The value of  extend information

Example:BJ_ZZ_001

Error codes

Business response codes

Error codeDescription
ORDER_FAILThe ordering fails.
ORDER_SUCCESS_PAY_SUCCESSBoth the ordering and the payment succeed.
ORDER_SUCCESS_PAY_FAILThe ordering succeeds, but the payment fails.
ORDER_SUCCESS_PAY_INPROCESSThe ordering succeeds and the payment is under processing.
UNKNOWNThe processing result is unknown.

Business errors

Error codeDescription
TRADE_SETTLE_ERRORVerification of royalty distribution information fails.
TRADE_BUYER_NOT_MATCHThe buyer is unmatched.
CONTEXT_INCONSISTENTTrade information has been altered.
TRADE_HAS_SUCCESSThe payment of trade has been made.
TRADE_HAS_CLOSEThe trade has been closed.
REASON_ILLEGAL_STATUSThe trade status is illegal.
EXIST_FORBIDDEN_WORDBanned words are included in order information.
PARTNER_ERRORPartner information is incorrect.
ACCESS_FORBIDDENHas no right to use the product.
SELLER_NOT_EXISTThe seller does not exist.
BUYER_NOT_EXISTThe buyer does not exist.
BUYER_ENABLE_STATUS_FORBIDThe buyer status is illegal and the trade cannot be continued.
BUYER_SELLER_EQUALThe seller and the buyer have the same account and the trade cannot be conducted.
INVALID_PARAMETERParameter is invalid.
UN_SUPPORT_BIZ_TYPEUnsupported business type
INVALID_RECEIVE_ACCOUNTThe seller is not included in receiving account list.
BUYER_PAYMENT_AMOUNT_DAY_LIMIT_ERRORThe buyer’s payment on the payment day exceeds limit.
ERROR_BUYER_CERTIFY_LEVEL_LIMITThe buyer fails to pass verification conducted by People’s Bank of China.
ERROR_SELLER_CERTIFY_LEVEL_LIMITThe seller fails to pass verification conducted by People’s Bank of China.
CLIENT_VERSION_NOT_MATCHThe wallet version is obsolete. Please update it to the latest version before use.
AUTH_NO_ERROR

Authorization number is wrong for which the possible reasons include:

  • The merchant owning the authorization number is not the same as the request merchant;
  • The payer owning the authorization number is not the same as the request payer;
  • The available capital under the authorization number is less than the request unlocked capital;
  • The status of the authorization number is not authorized;

The receiver owning the authorization number is not the same as the request receiver.

BUYER_BANKCARD_BALANCE_NOT_ENOUGHBuyer bankcard balance is not enough.
PULL_MOBILE_CASHIER_FAILFail to pull mobile cashier.
PAYMENT_FAILFail to payment.
MOBILE_PAYMENT_SWITCH_OFFWireless switch is closed, unable to pay.
SOUNDWAVE_PARSER_FAILSoundwave/barcode parse fail.
ERROR_BALANCE_PAYMENT_DISABLEBalance payment function is closed.
ORDER_UN_SUPPORT_PROMOTEThis order does not support the specified discount.
BUYER_BALANCE_NOT_ENOUGHBuyer balance is not enough.
SELLER_BEEN_BLOCKEDSeller account is blocked.
BEYOND_PAY_RESTRICTIONBeyond pay restriction.
BEYOND_PER_RECEIPT_RESTRICTIONThe seller amount receivable more than month restriction.
TOTAL_FEE_EXCEEDOrder amount exceed the limit.
VOUNCHER_NOT_EXISTMerchant coupons does not exist.
BUYER_PAYMENT_COUNT_DAY_LIMIT_ERRORBuyer payment count of one day exceed the limit.
BUYER_PAYMENT_COUNT_MONTH_LIMIT_ERRORBuyer payment count of one month exceed the limit.
CLIENT_NOT_ONLINEUser client is not online, so that unable pull mobile cashier.
TRADE_STATUS_ERRORTrade status error.
BUYER_PAYMENT_AMOUNT_MONTH_LIMIT_ERRORBuyer payment amount of one month exceed the limit.
PRODUCT_AMOUNT_LIMIT_ERRORProduct amount exceed the limit.
PAYMENT_REQUEST_HAS_RISKPayment has risk.
DUPLICATE_PAY_CURRENCY_NOT_EQUALDuplicate payment currency is inconsistent with the first payment currency.
AGREEMENT_NOT_EXISTAgreement information is not exist.
AGREEMENT_INVALIDAgreement is invalid.
AGREEMENT_ERRORAbnormal agreement information.
NO_PAYMENT_INSTRUMENTS_AVAILABLEThere is not available payment instruments.
USER_LOGONID_DUPThe user’s logonid is duplicated with other people (special case when a user is using cell phone number as logon id)
EXCHANGE_AMOUNT_OR_CURRENCY_ERRORThe exchange amount or currency is error

Access errors

Error codeDescription
ILLEGAL_SIGNIllegal signature.
ILLEGAL_DYN_MD5_KEYDynamic key information is incorrect.
ILLEGAL_ENCRYPTEncryption is incorrect.
ILLEGAL_ARGUMENTParameter is incorrect.
ILLEGAL_SERVICEService parameter is incorrect.
ILLEGAL_USERUser ID is incorrect.
ILLEGAL_PARTNERPartner ID is incorrect.
ILLEGAL_EXTERFACEInterface configuration is incorrect.
ILLEGAL_PARTNER_EXTERFACEPartner’s interface information is incorrect.
ILLEGAL_SECURITY_PROFILEMatching private key configuration has not been found.
ILLEGAL_AGENTAgency ID is incorrect.
ILLEGAL_SIGN_TYPEThe signature type is incorrect.
ILLEGAL_CHARSETThe character set is illegal.
HAS_NO_PRIVILEGEHas no right to visit.
INVALID_CHARACTER_SETThe character set is invalid.

System errors

Error codeDescription
SYSTEM_ERRORAlipay system failed to process the request due to temporary internal glitch.
SESSION_TIMEOUTSession timeout
ILLEGAL_TARGET_SERVICEWrong  target_service
ILLEGAL_ACCESS_SWITCH_SYSTEMMerchant is not allowed to visit system of this type.
EXTERFACE_IS_CLOSEDThe interface has been closed.

Trade status

CodeDescription
WAIT_BUYER_PAYThe trade has been established and is waiting for the buyer to make payment.
TRADE_CLOSED
  • Trade closed whose payment has not been completed within specified time;
  • Trades closed whose payment has been fully returned when the trade completes.
TRADE_SUCCESSThe trade succeeds and is operable, such as multi-level royalty distribution, refund, etc.
TRADE_PENDINGWait for the seller to collect payment (if the seller’s account is frozen after the buyer has made the payment).
TRADE_FINISHEDThe trade succeeds and finishes and is not operable.

Payment channel

CodePayment channel
00Alipay Coupon
10Alipay balance
60Alipay pre-deposit card
30Points
70Credit payment
40Discount coupon
80Prepaid card
90Credit payment (consumption credit)
100Special Alipay account for financial management
101Merchant’s shop card
102Merchant’s discount coupon
103Blank note
104Red envelope

Samples

Request sample

https://mapi.alipay.com/gateway.do?sign=31a008138e2f26a6414119984553e538&trade_no=2013112611001004680073956707&_input_charset=UTF-8&sign_type=MD5&service=alipay.acquire.query&partner=2088101125328850&alipay_ca_request=2&out_trade_no=HZ0120131127001

Response sample

Example of Payment Documents Information:

copy
<fund_bill_list>
    <TradeFundBill>
        <amount>70.00</amount>
        <fund_channel>10</fund_channel>
    </TradeFundBill>
    <TradeFundBill>
        <amount>20.00</amount>  
        <fund_channel>00</fund_channel>
    </TradeFundBill>
    <TradeFundBill>
        <amount>10.00</amount>
        <fund_channel>30</fund_channel>
    </TradeFundBill>
</fund_bill_list>

The example of returned extend information:

copy
<extend_info_list> 
    <ExtendInfo>
        <key>SHOP_ID</key> 
        <value>BJ_ZZ_001</value> 
    </ExtendInfo> 
    <ExtendInfo> 
        <key>TERMINAL_ID</key> 
        <value>12345</value> 
    </ExtendInfo> 
</extend_info_list>

Response sample

Business is accepted and processed normally, and query is conducted successfully:

copy
<?xml  version="1.0" encoding="utf-8"?>
  <alipay>
  <is_success>T</is_success>
  <request>
  <param  name="sign">c7d17d40111b8264975a6bfba77962cb</param>
  <param  name="_input_charset">UTF-8</param>
  <param  name="sign_type">MD5</param>
  <param  name="service">alipay.acquire.query</param>
  <param  name="partner">2088101126765726</param>
  <param  name="out_trade_no">3406822113320232</param>
  <param  name="alipay_ca_request">2</param>
  </request>
  <response>
  <alipay>
  <result_code>SUCCESS</result_code>
  <buyer_logon_id>ali***@alitest.com</buyer_logon_id>
  <buyer_user_id>2088102114647394</buyer_user_id>
  <out_trade_no>3406822113320232</out_trade_no>
  <partner>2088101126765726</partner>
  <trade_no>2013111511001004390000105126</trade_no>
  <trade_status>TRADE_CLOSED</trade_status>
  </alipay>
  </response>
  <sign>630c9331f0946bde8e164564d1f7aeeb</sign>
  <sign_type>MD5</sign_type>
  </alipay>

Request succeeds, business processing fails:

copy
<?xml  version="1.0" encoding="utf-8"?>
  <alipay>
  <is_success>T</is_success>
  <request>
  <param  name="sign">c7d17d40111b8264975a6bfba77962cb</param>
  <param  name="_input_charset">UTF-8</param>
  <param  name="sign_type">MD5</param>
  <param  name="service">alipay.acquire.query</param>
  <param  name="partner">2088101126765726</param>
  <param  name="out_trade_no">3406822113320232</param>
  <param  name="alipay_ca_request">2</param>
  </request>
  <response>
  </alipay>
  <result_code>FAIL</result_code>
  <detail_error_code>TRADE_NOT_EXIST</detail_error_code>
  <detail_error_des>trade  does not exist</detail_error_des>
  <alipay>
  <response>
  <sign>d24b14dad80461060ad7ffb8a5993a13</sign>
  <sign_type>MD5</sign_type>
  </alipay>

Output when Request fails or the data accessed is wrong:

copy
<?xml  version="1.0" encoding="utf-8"?>
<alipay>
  <is_success>F</is_success>
  <error>ILLEGAL_SIGN</error>
</alipay>