Query Order
Update Time:2025.02.25This API can be used to query all WeChat Pay orders. Merchants can use the Query Order API to query the order status and then complete subsequent business logic.
|
1. API intro
Applicable object: Common mode Institutional mode
Request URL: https://apihk.mch.weixin.qq.com/v3/global/transactions/id/{id}
OR
https://apihk.mch.weixin.qq.com/v3/global/transactions/out-trade-no/{out_trade_no}
Note: The {id} in the URL refers to the actual WeChat order No., while the {out_trade_no} refers to the actual merchant order No., either of which is called.
Request method: GET
Path parameter is a path parameter.
Query parameter needs to be passed in the request URL.
Body parameter needs to be passed in the request JSON.
2. Request Parameters
Name | Variable Name | Type | Required | Description |
---|---|---|---|---|
Merchant ID | mchid | string[1,32] | Yes | Query Merchant ID assigned by WeChat Pay |
Sub-merchant ID | sub_mchid | string[1,32] | Yes | Query Sub-merchant ID assigned by WeChat Pay |
Institution's Merchant ID | sp_mchid | string[1,32] | Yes | Query Institution's Merchant ID assigned by WeChat Pay |
Merchant order No. | out_trade_no | string[1,32] | Choose one | Path Order No. corresponding to the original payment transaction |
WeChat Pay order No. | id | string[1,32] | Path WeChat order No. corresponding to the original payment transaction |
Request Example
Common mode
Institutional mode
3. Response Parameters
Response for successful request:
Name | Variable Name | Type | Required | Description | |||
---|---|---|---|---|---|---|---|
Merchant ID | mchid | string[1,32] | Yes | Merchant ID assigned by WeChat Pay | |||
APPID | appid | string[1,32] | Yes | APPID corresponding to the mobile app applied for by the merchant on the WeChat Open Platform | |||
Institution's Merchant ID | sp_mchid | string[1,32] | Yes | Institution's Merchant ID assigned by WeChat Pay | |||
Sub-merchant ID | sub_mchid | string[1,32] | Yes | Sub-merchant ID assigned by WeChat Pay | |||
Organization APPID | sp_appid | string[1,32] | Yes | APPID corresponding to the Service Account applied for by the institution on the WeChat Official Accounts Platform | |||
Sub-merchant APPID | sub_appid | string[1,32] | No | APPID corresponding to the mobile app applied for by the sub-merchant on the WeChat Open Platform | |||
Merchant order No. | out_trade_no | string[1,32] | Yes | Returned merchant's order No. | |||
WeChat Pay order No. | id | string[1,32] | Yes | WeChat Pay order No. | |||
Merchant data | attach | string[1,127] | No | Additional data, which will be returned unchanged in the query API and payment notifications. This field is mainly used for the custom data in the orders of the merchant. | |||
Transaction type | trade_type | string[1,16] | Yes | In-NATIVE Pay | |||
Paying bank | bank_type | string[1,32] | Yes | Bank type, which is the bank ID in string format. See Bank Type for the list of values. | |||
Payment completion time | success_time | string[1,64] | Yes | The time when the order is paid successfully, in rfc3339 format. For example, 2018-06-08T10:34:56+08:00 represents BJT 10:34:56 June 8, 2018. | |||
Transaction status | trade_state | string[1,32] | Yes | SUCCESS : Payment successful | |||
Transaction status description | trade_state_desc | string[1,256] | Yes | Descriptions on the current order status and instructions for the next operation. | |||
Payer | payer | object | Yes | Payer information. For more information, see the description below. | |||
| |||||||
Order amount | amount | object | Yes | Information on the order amount. For more information, see the description below. | |||
| |||||||
Discount feature | promotion_detail | array | No | Discount feature info. For more information, see the description below. | |||
|
Note: goods_remark is a remark field that is returned unchanged. goods_tag is an order discount tag to distinguish whether an order can be discounted. Both fields are set when the voucher is configured in the WeChat backend.
Response for failed request:
Name | Variable Name | Type | Required | Description | |||
---|---|---|---|---|---|---|---|
Returned status code | code | string[1,32] | Yes | Error code. See the error code list for the enumerated values. | |||
Returned information | message | string[1,256] | Yes | Returned message. It indicates the reason for the error if not empty. | |||
Detailed error description | detail | object | No | It is returned when code is PARAM_ERROR. Details will be described below. | |||
|
Response Example:
SUCCESS
ERROR
4. Error Codes
Error Message | Description | Solution |
---|---|---|
ORDER_NOT_EXIST | This transaction order No. does not exist. | The API can only be used for checking orders where transactions return successfully after payment submission. Check whether the order no. to be viewed is correct. |
SYSTEM_ERROR | System error | System error. Please call the API again to initiate the query. |