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

WeChat small program user contract (optional)


May 18, 2021 WeChat Mini Program Development Document


Table of contents


User contracting (optional)

WeChat background to inform the owner of the user log off / contract.

1, request parameters

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

encrypted_data decrypted data

The name of the argument Type Required Note
Openid string Y User openid
cardid string N The owner's user ID

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

Request:

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

encrypted_data is decrypted:

{"openid":"1234","cardid":"1234"}

Return:

{"errcode":0,"nonce_str":"abcdefg","encrypted_data":"jfiwajeofjiefef","iv":"afweifwefe"}