Use case:
The merchant can initiate the inquiry of the status for the payments, and decide the next action based on the returned status.
Some use cases that might need to call this API:
Parameter | Type | Mandatory | Length | Description | Sample |
---|---|---|---|---|---|
app_id | String | Y | 32 | An app id assigned to the developer by Alipay | 2014072300007148 |
method | String | Y | 128 | api name | alipay.trade.query |
charset | String | Y | 10 | The char set for request use, like utf-8, gbk, gb2312, etc. | utf-8 |
sign_type | String | Y | 10 | The type of signature algorithm used by the merchant to generate the signature string. Currently RSA and RSA2 are supported. | RSA2 |
sign | String | Y | 256 | Signature string | |
timestamp | String | Y | 19 | The sending time of the request, formatting in “yyyy-MM-dd HH:mm:ss” | 2014-07-24 03:07:50 |
version | String | Y | 3 | The version of this API, hard coded as 1.0 for now. | 1.0 |
app_auth_token | String | N | 40 | Please refer to the section “application authorization” |
Parameter | Type | Mandatory | Length | Description | Sample |
---|---|---|---|---|---|
trade_no | String | N* | 64 | The Alipay trade number. Cannot be empty if out_trade_no is empty, and the system will pick trade_no first if they both exist. | 2014112611001004680073956707 |
out_trade_no | String | N* | 64 | The transaction/order id passed in by the partner/merchant. It must be unique in the merchant system. Cannot be empt if trade_no is empty. | 20150320010101001 |
Sample:
method=alipay.trade.query, app_id=2014072300007148, charset=utf-8, sign_type=RSA2, sign=MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAL4HgSt9hfOpv9MSwgUvfpgOH7WkC7WrTr84m29b0VfnZtK+9jv/YPXYr+22DrxfWJkdPiXJvSjifxPudlqjX21l6/8k79i/4HRCz8DBcdw5jqROfpoq0l3vYfPVqJGwSqaPhtM1Bb4hAD2yLlN2ukfCbshSntUEFd4ozocLolW/AgMBAAECgYBVHTNj8WMQElYTCnHQtMc1AA5/4yxDgKlSyN4F8NBBWSoa9uF/WhFpzFZwWH0dLm+WlRyC/Gs3ZsuYd9SXIFna9mv49+cEfObSzJhvW5DXOVCi+c4Ap3cTsXZiAj8DMsoCb9OjRHNl/BqzN0kl0Wm1diZvXl9YgSRqbzpXzoj4oQJBAOYLSk87XFYodvwr4aL3KFjZZZhHj1Jpp/q61SNgB03aXqZu9m+hk1X4mTGn4rhA7Cl2ZuL+OoxxnJFDw0cbMRcCQQDTeGgx0VUC+O3zAtzMmocjE7WuesRC3IjhU30of4GGjQzIXvKOQCCuUF2DHvIkrB/k2E75n8+TI9matbLS11mZAkEAtSek7/oF/89Dy9dei2/o9PbVu3J22eZcIuVoHMBtYBCbwqLVLBloJiZrtR/JOWHe19Pmt9COGLULH5XmPKOcJwJAUZnP0xFs1XXLFA/Rtd4XMXDklYxn+UjyRMibrintiEcbXKJOxJd4ROtb+kHRvFbzA7J4XxjM14Fo8asVcwiIWQJAVco+9qQzZ7JZzFzk0KTWhQlfbcRByLX25XIPbIes2lmY2uM895yrY/8kbGx2JgD/VGITWwth+uuutXUQ9K6HIw==, timestamp=2014-07-24 03:07:50, biz_content={ "out_trade_no": "201503022001" }
Parameter | Type | Mandatory | Length | Description | Sample |
---|---|---|---|---|---|
trade_no | String | Y | 64 | Alipay Transaction ID. | 2013112011001004330000121536 |
out_trade_no | String | Y | 64 | out_trade_no passed in by the merchant in the request. | 6823789339978248 |
buyer_user_id | String | Y | 16 | The user id associated with the buyer’s Alipay account, in the format of 16 digit number starting with “2088”. | 2088102122524333 |
buyer_logon_id | String | Y | 100 | The buyer’s Alipay account id,part of which will be replaced by ‘*’. | 159****5620 |
trade_status | String | Y | 32 | The current trade status,please refer to “trade status”. | TRADE_CLOSED |
total_amount | String | Y | 11 | The total amount of the payment. | 88.88 |
receipt_amount | Number | N | 11 | The total amount received by the merchant in the settlement, in CNY. | 8.8 |
invoice_amount | Number | N | 11 | The invoice amount in the payment, in CNY. | 10.00 |
buyer_pay_amount | Number | N | 11 | The total amount that the buyer will pay, in CNY. | 13.88 |
point_amount | Number | N | 11 | The total amount that the buyer will pay in the Alipay reward point program, in CNY. | 12.00 |
send_pay_date | String | N | 32 | Payment time as “YYYY-MM-dd HH:mm:ss” when the fund is moved to the merchant’s account. | 2014-07-21 11:43:42 |
alipay_store_id | String | N | 64 | Alipay store id | NJ_S_001 |
terminal_id | String | N | 32 | The terminal id. | NJ_T_001 |
store_id | String | N | 32 | The store id. | NJ_S_001 |
store_name | String | N | 512 | The store name. | 证大五道口店 |
fund_bill_list | TradeFundBill[] | N | The amount info for all the funding channels in a successful payment. | ||
└fund_channel | String | N | The channel for paying. | ALIPAYACCOUNT | |
└amount | Price | N | The amount used via this type of payment instrument. | 10 | |
discount_goods_detail | String | Y | The discount information of the item which have a discounted price in this order. | [{“goods_id”:“STANDARD1026181538”,“goods_name”:“雪碧”,“discount_amount”:“100.00”,“voucher_id”:“2015102600073002039000002D5O”}] | |
industry_sepc_detail | String | N | 4096 | Special information of a indunstry. | {“registration_order_pay”:{“brlx”:“1”,“cblx”:“1”}} |
{ "alipay_trade_query_response": { "code": "10000", "msg": "处理成功", "trade_no": "2013112011001004330000121536", "out_trade_no": "6823789339978248", "trade_status": "TRADE_SUCCESS", "buyer_user_id": "2088102122524333", "buyer_logon_id": "159****5620", "total_fee": "88.88", "receipt_amount": "8.88", "send_pay_date": "2014-11-27 15:45:57", "store_id":"NJ_S_001", "store_name":"证大五道口店", "terminal_id":"NJ_T_001", "fund_bill_list": [ { "fund_channel": "ALIPAYACCOUNT", "amount": "80.00" }, { "fund_channel": "DISCOUNT", "amount": "8.88" } ] }, "sign": "jfAz0Yi0OUvAPqYTzA0DLysx0ri++yf7o/lkHOHaG1Zy2fHBf3j4WM+sJWHZUuyInt6V+wn+6IP9AmwRTKi+GGdWjPrsfBjXqR7H5aBnLhMsAltV7v4cYjhuguAqh4WkaJO6v6CfdybDpzHlxE6Thoucnad+OsjdCXkNd1g3UuU=" }
Sample response of incomplete payment:
{ "alipay_trade_query_response": { "code": "10000", "msg": "处理成功", "trade_no": "2013112011001004330000121536", "out_trade_no": "6823789339978248", "trade_status": "WAIT_BUYER_PAY", "buyer_user_id": "2088102122524333", "buyer_logon_id": "159****5620", "total_amount": "88.88", "store_id":"NJ_S_001", "store_name":"证大五道口店", "terminal_id":"NJ_T_001", }, "sign": "jfAz0Yi0OUvAPqYTzA0DLysx0ri++yf7o/lkHOHaG1Zy2fHBf3j4WM+sJWHZUuyInt6V+wn+6IP9AmwRTKi+GGdWjPrsfBjXqR7H5aBnLhMsAltV7v4cYjhuguAqh4WkaJO6v6CfdybDpzHlxE6Thoucnad+OsjdCXkNd1g3UuU=" }
Sample:
{ "alipay_trade_query_response": { "code": "40004", "msg": "处理失败", "sub_code": "ACQ.TRADE_NOT_EXIST", "sub_desc": "交易不存在" }, "sign": "jfAz0Yi0OUvAPqYTzA0DLysx0ri++yf7o/lkHOHaG1Zy2fHBf3j4WM+sJWHZUuyInt6V+wn+6IP9AmwRTKi+GGdWjPrsfBjXqR7H5aBnLhMsAltV7v4cYjhuguAqh4WkaJO6v6CfdybDpzHlxE6Thoucnad+OsjdCXkNd1g3UuU=" }
Name | Description | Solution |
---|---|---|
ACQ.SYSTEM_ERROR | System error, such as system time out. | Call the inquiry API ASAP, and proceed accordingly with the order’s status. |
ACQ.INVALID_PARAMETER | At least one of the parameters is not valid. | Examine the request parameters and resend the request after fixing the issue. |