May 19, 2021 WeChat Mini Program Development Document
Base library version 1.1.0 starts to support, and low versions need to be compatible
Add vouchers in bulk.
Object parameter description:
Parameters | Type | Required | Description |
---|---|---|---|
cardList | ObjectArray | Is | A list of vouchers that need to be added, and the description of the objects in the list can be found in the description of the request object |
success | Function | Whether | The interface calls a successful callback function |
fail | Function | Whether | The interface calls the failed callback function |
complete | Function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Parameters | Type | Description |
---|---|---|
cardId | String | Voucher ID |
cardExt | String | The extended parameters of the voucher |
CardExt description
Parameters | Type | Required | Whether to participate in the signature | Description |
---|---|---|---|---|
code | String | Whether | Is | User-collected code, only custom code mode vouchers must be filled in, non-custom code mode vouchers can not be filled in, details |
Openid | String | Whether | Is | Specify the recipient's openid, which only the user can claim. bind_openid ticket with the field true must be filled in, and the bind_openid field is false and cannot be filled in. |
timestamp | Number | Is | Is | Timestamp, East 8th District Time, UTC plus 8, in seconds |
nonce_str | String | Whether | Is | Random strings, passed in by developer settings, enhance security (which can be replayed if not filled in). R andom string, not longer than 32 bits. Case letters and numbers are recommended, and nonce_str for different addition requests must be generated dynamically, which will result in a collection failure if repeated. |
fixed_begintimestamp | Number | Whether | Whether | The actual pick-up time of the voucher in the third-party system is the East 8th District timestamp (UTC plus 8, accurate to seconds). When the validity class of the card is DATE_TYPE_FIX_TERM, it is dedicated to identify the actual effective time of the voucher, which is used to solve the problem of the start time in the merchant system and the out-of-order time of receiving WeChat voucher. |
outer_str | String | Whether | Whether | Pick channel parameters to identify the channel value for this collection. |
signature | String | Is | - | Signature, the merchant will be the parameters in the interface list in the specified way to sign, the signature method to use SHA1, the specific signature scheme see: card signature |
Note: CardExt needs to serialize JSON into strings
Callback results:
The type of callback | errMsg | Description |
---|---|---|
success | addCard:ok | The addition of the voucher was successful |
fail | addCard:fail cancel | The user cancels the addition of the voucher |
fail | addCard:fail (detail message) | The addition of the voucher failed, where the detail message is the detailed reason for the failure returned in the background |
success returns parameters:
Parameters | Type | Description |
---|---|---|
cardList | ObjectArray | Card coupons add a list of results, the list of object descriptions please see the return object description |
Returns the description of the object
Parameters | Type | Description |
---|---|---|
code | String | Encrypt code, for the user to receive the code of the voucher encrypted string, decrypt please refer to: code decoding interface |
cardId | String | The ID to which the user receives the voucher |
cardExt | String | The extended parameters that the user receives to the voucher are the same as those passed in at the time of the call |
isSuccess | Boolean | Whether it was successful |
Example code:
wx.addCard({
cardList: [
{
cardId: '',
cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}'
}, {
cardId: '',
cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}'
}
],
success: function(res) {
console.log(res.cardList) // 卡券添加结果
}
})
Base library version 1.1.0 starts to support, and low versions need to be compatible
Check the voucher in the WeChat package.
Object parameter description:
Parameters | Type | Required | Description |
---|---|---|---|
cardList | ObjectArray | Is | A list of vouchers that need to be opened, detailed in the parameters in the list, can be found in the openCard request object description |
success | Function | Whether | The interface calls a successful callback function |
fail | Function | Whether | The interface calls the failed callback function |
complete | Function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
OpenCard requests an object description
Parameters | Type | Description |
---|---|---|
cardId | String | The voucher ID that needs to be opened |
code | String | The encrypted code in the return object of addCard is obtained by decryption, please refer to: code decoding interface |
Example code:
wx.openCard({
cardList: [
{
cardId: '',
code: ''
}, {
cardId: '',
code: ''
}
],
success: function(res) {
}
})
tip
: Currently only certification programs can use the voucher interface, can refer to the
guidelines
for certification.
tip
: For more information, please check
the WeChat voucher interface documentation