Skip to main content
Version: Next

Taro.addCard(option)

Adds cards and offers in batch. It can be used only in Mini Programs or cultural interaction Mini Games that complete verification. For more documents, see API Documentation for WeChat Cards & Offers.

cardExt Description The extended parameter of the card or offer. It must be passed as a JSON-serialized string.

Reference

Type

(option: Option) => Promise<SuccessCallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
cardListRequestInfo[]YesThe list of cards and offers to be added
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

RequestInfo

PropertyTypeDescription
cardExtstringThe extended parameter of the card or offer. It must be passed as a JSON-serialized string.
cardIdstringThe ID of the card or offer

SuccessCallbackResult

PropertyTypeDescription
cardListAddCardResponseInfo[]The list of cards and offers to be added
errMsgstringCall result

AddCardResponseInfo

PropertyTypeDescription
cardExtstringThe extended parameter of the card or offer. See description above for the composition of this parameter.
cardIdstringThe ID of the card or offer claimed by the user
codestringEncrypted code. It is a string obtained after the code of the card or offer claimed by the user is encrypted. To decrypt the code, see Code Decryption API.
isSuccessbooleanIndicates whether the card or offer is successfully claimed

Sample Code

Taro.addCard({
cardList: [
{
cardId: '',
cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}'
}, {
cardId: '',
cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}'
}
],
success: function (res) {
console.log(res.cardList) // The results of card and offer addition
}
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.addCard✔️