The WeChat backend requests QR code source data from the business provider, and the frontend can generate ride codes based on this source data.
1. Request Parameters
| Parameter Name | Type | Required | Remarks |
|---|---|---|---|
| appid | string | Y | Mini Program |
| appidmch_id | string | Y | Payment Merchant ID |
| nonce_str | string | Y | Random string |
| encrypted_data | string | Y | Encrypted using AES-CBC-PKCS7-PADDING |
| iv | string | Y | IV used for decryption (base64 encoded) |
| sign | string | Y | Signature of fields 1 to 5 |
Decrypted data of encrypted_data
| Parameter Name | Type | Required | Remarks |
|---|---|---|---|
| openid | string | Y | User openid |
| idcard_id | string | Y | Third-party User ID (if registration exists) |
| user_public_key | string | Y | User public key, hex format, 130 bytes in total |
2. Response Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| errcode | int | Y | 0 indicates success |
| errmsg | string | N | Error message |
| nonce_str | string | Y | Returned as-is |
| encrypted_data | string | Y | Using AESCBCPKCS7PADDING |
Decrypted data of encrypted_data
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| base64_svr_data | string | Y | Base64-encoded binary stream of the concatenated fields 1-15 per the Ministry of Transport ride code standard, for network transmission |
3. Sample Code
Request:
{"appid":"test","mch_id":"123456","nonce_str":"abcdefg","encrypted_data":"jfiwajeofjiefef","iv":"afweifwefe"}
After decrypting encrypted_data:
{"openid":"1234","user_public_key":"123123","card_id":"2342343"}
Response:
{"errcode":0,"nonce_str":"abcdefg","encrypted_data":"jfiwajeofjiefef","iv":"afweifwefe"}
Decrypted data of encrypted_data:
{"base64_svr_data":"xxafdafd"}