single_trade_query
Call this interface to obtain the information of a particular transaction, such as the transaction ID, out_trade_no, and transaction status.
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
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, GBK, and GB2312 are supported.
|
sign_type String | Sign type. RSA, RSA2 and MD5 are supported. Use uppercase.
|
sign String | Sign value
|
Business parameter | |
trade_no String(64) | The unique transaction ID assigned by Alipay, with a length in the range 16 - 64 bits. If out_trade_no and trade_no appear at the same time, trade_no takes precedence. Note: This field is required when out_trade_no is not provided.
|
out_trade_no String(64) | The unique transaction ID that is assigned by the partner. If both trade_no and out_trade_no appear, trade_no takes precedence. Note: This parameter is required when trade_no is not provided.
|
Notes:
- Only the HTTPS request is supported for this API.
- Do not use the halfwidth quotation mark (") in parameter values.
Response
Synchronous response
Error codes
Business errors
Error code | Description |
TRADE_NOT_EXIST | The trade doesn't exist. Check whether out_trade_no or Alipay trade_no is incorrect. |
ILLEGAL_SIGN | Illegal signature |
ILLEGAL_DYN_MD5_KEY | Dynamic key information is incorrect. |
ILLEGAL_ENCRYPT | Encryption is incorrect. |
ILLEGAL_ARGUMENT | Parameter is incorrect. |
ILLEGAL_SERVICE | Service parameter is incorrect. |
ILLEGAL_USER | User ID is incorrect. |
ILLEGAL_PARTNER | Partner ID is incorrect. |
ILLEGAL_EXTERFACE | Interface configuration is incorrect. |
ILLEGAL_PARTNER_EXTERFACE | Partner's interface information is incorrect. |
ILLEGAL_SECURITY_PROFILE | Matching private key configuration has not been found. |
ILLEGAL_AGENT | Agency ID is incorrect. |
ILLEGAL_SIGN_TYPE | The signature type is incorrect. |
ILLEGAL_CHARSET | The character set is illegal. |
ILLEGAL_CLIENT_IP | Client IP address is illegal |
HAS_NO_PRIVILEGE | No right to visit |
ILLEGAL_DIGEST_TYPE | Digest type is illegal. |
ILLEGAL_DIGEST | Digest is illegal. |
ILLEGAL_FILE_FORMAT | File format is illegal. |
ILLEGAL_ENCODING | Encoding type is illegal. |
EXTERFACE_IS_CLOSED | API is closed. |
ILLEGAL_REQUEST_REFERER | Anti-phishing checks the illegal request. |
ILLEGAL_ANTI_PHISHING_KEY | Anti-phishing checks the illegal timeframe. |
ANTI_PHISHING_KEY_TIMEOUT | Anti-phishing checks the timeframe timeout. |
ILLEGAL_EXTER_INVOKE_IP | IP Anti-phishing checks the illegal IP. |
System errors
Returned result | Description |
SYSTEM_ERROR | Alipay system failed to process the request due to temporary internal glitch. |
SESSION_TIMEOUT | Session timeout |
ILLEGAL_TARGET_SERVICE | Wrong target service |
ILLEGAL_ACCESS_SWITCH_SYSTEM | Merchant is not allowed to visit the system of this type. |
EXTERFACE_IS_CLOSED | The interface has been closed. |
Payment type
Type | Description |
01 | Coupon Fee Pre-payment |
02 | Coupon Fee Payment |
03 | Reminding Payment |
04 | Automatic Sending Goods |
1 | Merchandise |
2 | Service Purchase |
3 | Online Auction |
4 | Donation |
5 | Post Fee Compensation |
6 | Bonus |
7 | Funds Purchase |
8 | Air Ticket |
9 | Go Dutch |
10 | Group Purchase |
11 | Electronic Ticket |
12 | Lottery Ticket |
13 | Auction |
14 | Mobile Payment |
15 | Flowers & Gifts |
16 | Agent Electronic Ticket |
17 | Party Membership Dues |
18 | Foreign Exchange |
19 | Automatic Charge |
20 | Refund of Overseas Payment |
21 | Refund of Instant Payment |
22 | Business Deposit |
24 | Cash Gift |
25 | Rent |
26 | Motopay |
23 | Shopping Chart |
27 | Escrow Payment of Group Purchase |
Transaction status
Status | Description |
WAIT_BUYER_PAY | Transaction awaits user payment. |
WAIT_SELLER_SEND_GOODS | Transaction awaits seller sending goods. |
WAIT_BUYER_CONFIRM_GOODS | Transaction awaits buyer confirming goods. |
TRADE_FINISHED | Transaction is finished successfully. |
TRADE_CLOSED | Transaction is closed during processing (finished, not successfully) |
WAIT_SYS_CONFIRM_PAY | Transaction awaits system confirming the payment. Do not provide the goods to the customer before the payment is confirmed. |
WAIT_SYS_PAY_SELLER | The buyer confirms the goods, and the transaction awaits system to pay to seller. |
TRADE_REFUSE | Transaction is refused. |
TRADE_REFUSE_DEALING | Transaction is refused. |
TRADE_CANCEL | Transaction is cancelled. |
TRADE_PENDING | Transaction is pending. |
TRADE_SUCCESS | Transaction is completed, and is available for refund. |
BUYER_PRE_AUTH | The buyer has paid. (IVR Payment) |
COD_WAIT_SELLER_SEND_GOODS | Transaction awaits the seller to provide the goods to the customer. (COD) |
COD_WAIT_BUYER_PAY | Transaction awaits user payment. (COD) |
COD_WAIT_SYS_PAY_SELLER | Buyer confirms that the goods is received, and the transaction awaits system paying to seller. (COD) |
Additional trade status
Status | Description |
ZHIFUBAO_CONFIRM | The custom service confirms goods for buyer. |
ZHIFUBAO_CANCEL_FP | The custom service cancels the instant payment for buyer. |
DAEMON_CONFIRM_CANCEL_PRE_AUTH | Expiration program cancels the pre-authorization. |
DAEMON_CONFIRM_CLOSE | Expiration program cancels the transaction because the buyer did not pay. |
Samples
Request
Request sample with the out_trade_no field specified:
https://intlmapi.alipay.com/gateway.do?service=single_trade_query&partner=208xxxxxxxxx5500&_input_charset=UTF-8&sign_type=MD5&out_trade_no=out_trade_no_20190826_204556&sign=6d1118194460012bb589620676b5aff2
Request sample with the trade_no field specified:
https://intlmapi.alipay.com/gateway.do?service=single_trade_query&partner=208xxxxxxxxx5500&_input_charset=UTF-8&sign_type=MD5&trade_no=201xxxxxxxxxxxxxxxxxxxxx7821&sign=6c8bdebe125249d86bc0030cedaeb0b3
Response
Request succeeds:
<alipay>
<is_success>T</is_success>
<request>
<param name="partner">208xxxxxxxxx5500</param>
<param name="service">single_trade_query</param>
<param name="_input_charset">UTF-8</param>
<param name="trade_no">201xxxxxxxxxxxxxxxxxxxxx7003</param>
</request>
<response>
<trade>
<buyer_email>186******65</buyer_email>
<buyer_id>208xxxxxxxxx6535</buyer_id>
<discount>0.00</discount>
<flag_trade_locked>0</flag_trade_locked>
<gmt_create>2019-09-10 14:08:34</gmt_create>
<gmt_last_modified_time>2019-09-10 14:08:38</gmt_last_modified_time>
<gmt_payment>2019-09-10 14:08:38</gmt_payment>
<is_total_fee_adjust>F</is_total_fee_adjust>
<operator_role>B</operator_role>
<out_trade_no>out_trade_no_20190910_140243</out_trade_no>
<payment_type>100</payment_type>
<price>0.01</price>
<quantity>1</quantity>
<seller_email>che***@antfin.com</seller_email>
<seller_id>208xxxxxxxxx5500</seller_id>
<subject>Mika's coffee shop</subject>
<to_buyer_fee>0.00</to_buyer_fee>
<to_seller_fee>0.01</to_seller_fee>
<total_fee>0.01</total_fee>
<trade_no>201xxxxxxxxxxxxxxxxxxxxx7003</trade_no>
<trade_status>TRADE_FINISHED</trade_status>
<use_coupon>F</use_coupon>
</trade>
</response>
<sign>4dc773bcfe9d661fbb7d3889bb2d751d</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>
</alipay>