Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program cloud development SDK documents WeChat payment and query orders


May 20, 2021 WeChat Mini Program Development Document


Table of contents


CloudPay.queryOrder()

Support: Cloud function 2.0.2

Query the order

Description

The interface provides a query for all WeChat payment orders, through which merchants can actively query the status of orders to complete the next step of business logic.

Cases in which the query interface needs to be called:

When the merchant background, network, server, etc. abnormal, the merchant system finally did not receive payment notice;

Description of the parameters

The field name The name of the variable Required Type The sample value Describe
Sub-merchant number sub_mch_id Is String(32) 1900000109 WeChat pays for the assigned sub-merchant number
WeChat order number transaction_id Choose one String(32) 1009660380201506130728806387 WeChat's order number, priority use
Merchant order number out_trade_no String(32) 1217752501201407033233368018 Merchant system internal order number, required within 32 characters, can only be numbers, case letters - , and is unique under the same merchant number.
Random string nonce_str Is String(32) C380BEC2BFD727A4B6845133519F3AD6 Random string, not longer than 32 bits. A random number generation algorithm is recommended

Returns a description of the value

The field name The name of the variable Required Type The sample value Describe
Return the status code returnCode Yes String(16) SUCCESS SUCCESS / FAIL This field is a communication identifier, a non-transaction identifier, and the transaction is successful to see trade_state to determine
returned messages returnMsg no String(128) Signature failed Return information, such as non-empty, for error reasons.Such as signature failure, parameter format verification error

The following fields have returned when returncode is SUCCESS

Field name variable name Required type Sample value describe
APPID of the service provider appid Yes String(32) wxd678efh567hg6787 APPID of the service provider merchant
business number mch_id Yes String(32) 1230000109 WeChat payment distribution merchant
AppID of a small program sub_appid Yes String(32) wx8888888888888888 WeChat allocated small program ID
Submarket sub_mch_id Yes String(32) 1900000109 WeChat payment distribution
Random string nonce_str Yes String(32) 5K8264ILTKCH16CQ2502SI8ZNMTM67VS Random strings, not less than 32 bits.Recommended random number generation algorithm
sign sign Yes String(32) C380BEC2BFD727A4B6845133519F3AD6 Signature, see the signature generating algorithm
Business results result_code Yes String(16) SUCCESS SUCCESS/FAIL
The error code err_code Whether String(32) SYSTEMERROR Error code
The error code description err_code_des Whether String(128) System error Description of the result information

The following fields are returned when both result_code and the following fields are SUCCESS

The field name The name of the variable Required Type The sample value Describe
The device number device_info Whether String(32) 013467007045764 WeChat payment assigned terminal device number,
The user ID Openid Is String(128) oUpF8uMuAJO_M2pxb1Q9zNjWeS6o The user's unique identity under the merchant appid
Whether to pay attention to the public account number is_subscribe Is String(1) Y Whether users pay attention to public accounts, Y-follow, N-don't pay attention
The user sub-identity sub_openid Whether String(128) wxd930ea5d5a258f4f The user's unique identity under the sub-merchant appid
Whether to follow sub-public accounts sub_is_subscribe Whether String(1) Y Whether the user pays attention to the sub-public account, Y-follow, N-does not pay attention
The type of transaction trade_type Is String(16) JSAPI The type of transaction submitted by the calling interface is valued as follows: JSAPI, NATIVE, APP, MICROPAY, as detailed in the parameters
The status of the transaction trade_state Is String(32) SUCCESS SUCCESS - Payment success
REFUND - Transfer to refund
NOTPAY - Unpaid
CLOSED - Closed
REVOKED - Revoked (swipe payment)
USERPAYING -- In user payment
PAYERROR - Payment failure (other reasons, such as bank return failure)
Payment bank bank_type Is String(16) Cmc Bank type, with a string type of bank identity
The order amount total_fee Is Int 100 The total amount of the order, in points
Listed currency fee_type Whether String(8) CNY Currency type, is a three-letter code that complies with ISO 4217, default RMB: CNY, and a list of other values can be found in the currency type
The amount of the order to be closed settlement_total_fee Whether Int 100 When the order uses a top-up-free coupon and returns this parameter, the order amount payable is the order amount - the top-up coupon amount.
The amount paid in cash cash_fee Is Int 100 Cash Payment Amount Order Cash Payment Amount, see Payment Amount
The type of cash payment currency cash_fee_type Whether String(16) CNY Currency type, is a three-letter code that complies with ISO 4217, default RMB: CNY, and a list of other values can be found in the currency type
The amount of the voucher coupon_fee Whether Int 100 The amount of "voucher or discount" is the total amount of the order, the total amount of the order - the amount of the voucher or discount is the amount paid in cash, see the amount paid
The number of vouchers used coupon_count Whether Int 1 Vouchers or reduced number of offers to use
Voucher ID coupon_id_$n Whether String(20) 10000 Vouchers or discount IDs, $n subsumed, numbered from 0
The type of voucher coupon_type_$n Whether String CASH CASH -- Recharge voucher
NO_CASH--- a non-recharge coupon
The no-recharge coupon feature is enabled, and the coupon is returned after the order is used (value: CASH, NO_CASH). $n is the undersem, numbering from 0, for example coupon_type_ $0
The amount of a single voucher coupon_fee_$n Whether Int 100 The amount paid for a single voucher or discount is $n, starting at 0
WeChat pays for the order number transaction_id Is String(32) 1217752501201407033233368018 WeChat pays for the order number
Merchant order number out_trade_no Is String(32) 1217752501201407033233368018 Merchant system internal order number, required within 32 characters, can only be numbers, case letters -
Merchant packets attach Whether String(128) 123456 Merchant packets, returned as is
Payment completion time time_end Is String(14) 20141030133525 Order payment time, format yyyy MMdhmmss, such as December 25, 2009 9:10:10 seconds expressed as 20091225091010. See also time rules for details
Description of the trading status trade_state_desc Is String(256) Payment failed, please re-order payment A description of the current query order status and guidelines for the next step

Error code

Name Describe Reason Solution
ORDERNOTEXIST This trade order number does not exist This transaction order number does not exist in the query system The API can only check that a payment transaction has returned a successful order, and asks the merchant to check that the order number that needs to be queried is correct
SYSTEMERROR System error The background system returned an error System exception, please call again to initiate the query