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

WeChat small program broom code payment


May 18, 2021 WeChat Mini Program Development Document


Table of contents


Sweep code payment

(1) Pay callback interface

After the business party calls the WeChat charge interface, it receives a notice of the result of the charge.

1, request parameters

The name of the argument Type Required Note
appid string Y Small program
appidmch_id string Y Pay the merchant number
nonce_str string Y Random string
encrypted_data string Y Use AESCBCPKCS7PADDING
string Y Iv for decryption
sign string Y Signature of 1 to 5 fields

The decrypted parameters are as follows:

The name of the argument Type Required Note
Openid string Y The user's openid under the appid of the small program
bank_type string Y The type of payment
total_fee Int Y Total payment, in points
trade_state string Y Payment status: SUCCESS/FAIL
trade_msg string N Returned when payment failed
transaction_id string Y WeChat payment slip number
out_trade_no string Y Ride code business square number
attach string N Deduction API's entry, brought back as is
time_end string Y Payment is completed in the form of yyyyYMdhmmss, e.g. 9:10:10:10 on December 25, 2009 expressed as 20091225091010
qrcode string Y QR code

2, return parameters

The name of the argument Type Required Note
errcode Int Y 0 is a success
errmsg string N The error message
nonce_str string Y Bring it back as is

3, sample code

{"appid":"test","mch_id":"123456","nonce_str":"abcdefg","encrypted_data":"jfiwajeofjiefef","iv":"afweifwefe"}

Decrypted data:

{"openid":"fafwefawef","bank_type":"CFT","total_fee":100,"trade_state":"SUCCESS",...}

(2) WeChat charge interface (WeChat API interface)

Used to receive information obtained by the service party based on the scanning interface to the user for a fee-free charge.

1, request parameters

The name of the argument Type Required Note
qrcode string Y Ride code data, base64 is required
total_fee Int Y Total payment, divided into units (after offer)
original_fee Int Y Total payment, divided into units (before offer)
machine_ip string N The code sweeper is connected to the IP
machine_latitude float N Sweeper GPS latitude
machine_longitude float N The GPS longse longness of the code sweeper
body string Y Bus/subway withholding
start_time string Y On/off time, e.g. 20091225091010
end_time string N Get off time, format the same, suitable for secondary brushing scenes
line_name string Y Rides
trade_scene string Y METRO/BUS
start_qrcode string N When the second brush code is passed in, the QR code used for the first brush code is passed in
out_order_no string N The business side customizes the order number, which needs to be guaranteed to be unique
attach string N The business side customizes the data, and the statement and query interfaces are returned as is

2, return parameters

The name of the argument Type Required Note
errcode Int 32Y Return code
errmsg string N Return information

3, sample code

Ginseng:

{"qrcode":"afefawefwef",....}

Return

{"errcode":0,....}