Login expired. Please log in again.

Feedback

0/300

Feedback

Submitted successfully

ok

Feedback

Network exception, please try again later

ok

Query Order API

Latest update time:2019.11.20 Release notes


This API allows inquiry of all payment orders made from WeChat. After receiving a status code using this API, merchants can proceed with the next step in service logic.

Tips:

The following are situations when to use the Query Order API:


1. The Merchant doesn’t receive any payment due to an exception in the Merchant's backend, network or server;

2. A system error or unknown transaction status is returned after calling the payment interface;

3. USERPAYING status is returned after calling the Quick Pay API;

4. To confirm payment status before calling the Close Order API or Revoke Order API.

API intro

Request Url: https://api.mch.weixin.qq.com/pay/orderquery

Request Method: POST

Certificate Requirements: No certificate is required.

Applicable Object: Common modeInstitutional mode

Request Parameter

Field Name ID Type Required Description
Official Account ID appid String(32) Yes Specifies an Official Account ID assigned by WeChat
Example:wx8888888888888888
Merchant ID mch_id String(32) Yes Specifies merchant ID assigned by WeChat Payment
Example:1900000109
Sub Official Account ID sub_appid String(32) No Specifies an Sub Official Account ID assigned by WeChat.
Specifies Sub merchant ID of institution's sub-merchant assigned by WeChat Pay
Note: Only for Institutional mode
Example:wx8888888888888888
Sub  Merchant ID sub_mch_id String(32) Yes Specifies Sub merchant ID assigned by WeChat Payment
Specifies Sub merchant ID of institution's sub-merchant assigned by WeChat Pay
Note: Only for Institutional mode
Example:1900000109
WeChat Order Number transaction_id String(32) Choose one to submit

WeChat order number is preferred.

Example: 4200000000002104083200000488

Merchant Order Number out_trade_no String(32) Specifies an internal order number created by the Merchant's system. This field is required when transaction_id is not provided.
Example: 1217752501201407033233368018
Random string nonce_str String(32) Yes 32 characters or fewer. For more information, see Random String Algorithm .
Example:5K8264ILTKCH16CQ2502SI8ZNMTM67VS
Signature sign String(64) Yes Specifies a signature. For more information, see Signature Algorithm .
Example:C380BEC2BFD727A4B6845133519F3AD6
Sign type sign_type String(32) No Currently HMAC-SHA256 and MD5 are supported, default is MD5. This field is only required when sign_type is HMAC-SHA256.
Example:HMAC-SHA256

Example:


<xml>
  <appid>wx2421b1c4370ec43b</appid>
  <mch_id>10000100</mch_id>
  <nonce_str>f6868b9b16bf4893958afd4a46d73422</nonce_str>
  <out_trade_no>1678371718207317</out_trade_no>
  <sign>6D3B28F0CA86C4756E40366D341BC395</sign>
  <sub_mch_id>452532745</sub_mch_id>
</xml>                  
    
{
JAVA示例代码
}
    

Notes: Parameters are escaped in XML files and CDATA tags are used to illustrate that data is not parsed by XML parser.

Return Data

Field Name ID Type Required Description
Return Status Code return_code String(16) Yes Set to SUCCESS or FAIL
Specifies communicating label instead of transaction label. The status of the transaction is determined by the value of the result_code field.
Example:SUCCESS
Return Data return_msg String(128) No If not empty, this is the error description. If not empty, this is the error description
Signature Failure
Parameter format checking error
Example:Signature Failure

If return_code is SUCCESS, return data will also include the following fields:


Field Name ID Type Required Description
Official Account ID appid String(32) Yes The Official Account ID submitted when calling the interface
Example:wx8888888888888888
Merchant ID mch_id String(32) Yes The Merchant ID submitted when calling the interface
Example:1900000109
Sub Official Account ID sub_appid String(32) No The Sub Official Account ID submitted when calling the interface
Specifies Sub merchant ID of institution's sub-merchant assigned by WeChat Pay
Note: Only for Institutional mode
Example:wx8888888888888888
Sub  Merchant ID sub_mch_id String(32) Yes The Sub Merchant ID submitted when calling the interface
Specifies Sub merchant ID of institution's sub-merchant assigned by WeChat Pay
Note: Only for Institutional mode
Example:1900000109
Random String nonce_str String(32) Yes 32 characters or fewer
Example: 5K8264ILTKCH16CQ2502SI8ZNMTM67VS
Signature sign String(64) Yes Specifies a signature. For more information, see Signature Algorithm .
Example:C380BEC2BFD727A4B6845133519F3AD6
Service Result result_code String(16) Yes Set to SUCCESS or FAIL
Example:SUCCESS
Error Code err_code String(32) No Please refer to Error Codes
Example:SYSTEMERROR
Error Code Description err_code_des String(128) No The detailed description of error
Example:System error

If both return_code, result_code and trade_state are SUCCESS, return data will also include the following fields. If trade_state is fail, only out_trade_no and attach will be returned.


Field Name ID Type Required Description
Device ID device_info String(32) No Specifies the ID of the terminal device with from which the Merchant submitted their order
Example: 013467007045764
User Tag openid String(128) Yes Specifies the user id of the Payer provided by the WeChat system, it is unique to each appid instance.
About how to get openid, please refer to get openid api.
Example: wxd930ea5d5a258f4fo
Follows Official Account or not is_subscribe String(1) No For users who pay for transactions related to an official account, the value in this field states whether the user is current following the official account
Y: Follows
N: Doesn’t follow
Example: Y
Sub User Tag sub_openid String(128) No Specifies the user id of the Payer provided by the WeChat system, it is unique to each appid instance.
Specifies Sub merchant ID of institution's sub-merchant assigned by WeChat Pay
About how to get sub_openid, please refer to get openid api.
Note: Only for Institutional mode
Example: wxd930ea5d5a258f4f
Follows Sub Official Account or not sub_is_subscribe String(1) Yes For users who pay for transactions related to an sub official account, the value in this field states whether the user is current following the official account
Y: Follows
N: Doesn’t follow
Specifies Sub merchant ID of institution's sub-merchant assigned by WeChat Pay
Note: Only for Institutional mode
Example: Y
Transaction Type trade_type String(16) Yes

The transaction type submitted. The value could be JSAPI, NATIVE, or APP.
Example: JSAPI

Transaction Status trade_state String(32) Yes

1. SUCCESS: Payment successful
2. REFUND: Order to be refunded
3. NOTPAY: Order not paid
4. CLOSED: Order closed
5. REVOKED: Order revoked
6. USERPAYING: Awaiting user topay
7. PAYERROR: Payment failed (payment status failed to be returned by bank or other reasons).
Example: SUCCESS

Payment Bank bank_type String(32) Yes

String states bank_type.
Example: CMC

Total Amount total_fee int Yes

Specifies the total amount for a transaction. For more information, see Payment Amount.
Example: 100

Currency Type fee_type String(8) No Complies with ISO 4217 standards and uses 3 characters based code. For more information, see Currency Type.
Example: USD
Cash Payment Amount cash_fee int Yes Specifies the total cash payment amount of a transaction. For more information, see Payment Amount.
Example: 100
Cash Type cash_fee_type String(16) Yes Complies with ISO 4217 standards and uses CNY (Chinese yuan) by default. For more information, see Currency Type.
Example: CNY
WeChat Order Number transaction_id String(32) Yes Specifies the WeChat payment order id
Example: 4200000000002104083200000488
Merchant Order Number out_trade_no String(32) Yes Specifies the order number created within the Merchants' system, which is consistent with request.
Example: 1217752501201407033233368018
Merchant's Data Package attach String(128) No Specifies merchant's data package, which is returned as it is.
Example: 123456
Payment End Time time_end String(14) Yes Specifies transaction creation time in the format of yyyyMMddHHmmss, such as 20091225091010 for Dec 25, 2009 09:10:10. For more information, see Section 4.2 Time Protocol.
Example: 20141030133525
Description of Trade Status trade_state_desc String(256) Yes

Description of the current transaction status and guild for the next step.
Example: Payment failed, please create a new order

Exchange Rate rate String(16) Yes The value is 10 to the 8th power times of the exchange rate from foreign currency to RMB. For example, the exchange rate from foreign currency to RMB is 6.5, the value will be 650000000
Example: 650000000

Example:


<xml>
   <return_code><![CDATA[SUCCESS]]></return_code>
   <return_msg><![CDATA[OK]]></return_msg>
   <result_code><![CDATA[SUCCESS]]></result_code>
   <mch_id><![CDATA[10000100]]></mch_id>
   <appid><![CDATA[wx2421b1c4370ec43b]]></appid>
   <sub_mch_id><![CDATA[375907253]]></sub_mch_id> 
   <nonce_str><![CDATA[R2bkCd5bRJ8tBLN3]]></nonce_str>
   <sign><![CDATA[A5B986A3FBB3609A182C7F38F7CEC02C]]></sign>
   <openid><![CDATA[oUpF8uN95-Ptaags6E_roPHg7AG0]]></openid>
   <is_subscribe><![CDATA[N]]></is_subscribe>
   <trade_type><![CDATA[MICROPAY]]></trade_type>
   <bank_type><![CDATA[OTHERS]]></bank_type>
   <fee_type><![CDATA[CAD]]></fee_type> 
   <total_fee>2238</total_fee>
   <cash_fee_type><![CDATA[CNY]]></cash_fee_type>
   <cash_fee>11560</cash_fee>>
   <transaction_id><![CDATA[4200001137204318031621608237]]></transaction_id>
   <out_trade_no><![CDATA[NO20211012215248466958150050]]></out_trade_no>
   <attach><![CDATA[]]></attach>
   <time_end><![CDATA[20211105230556]]></time_end>
   <rate><![CDATA[516532998]]></rate>
</xml> 

Release notes

关闭
V1.0
2019.11.20
1. Query Order API released online

About  WeChat  Pay

Powered By Tencent & Tenpay Copyright©

2005-2024 Tenpay All Rights Reserved.

Contact Us
Wechat Pay Global

WeChat Pay Global