# catalog
3.Weixin Mini Program Card Opening Assembly
# Weixin Mini Program
# Scene introduction
When merchants conduct marketing activities within Weixin Mini Program, they can issue coupons as rewards and vouchers to users, and users can quickly present the packages for use and cancel them.
At the same time, some ticketing class Weixin Mini Program can also be purchased after the user's ticket for the user to add to the card package, convenient for users to show use.
# step
- The developer must have a certificate authority Service Account and a certified Weixin Mini Program account;
- Developers must apply for an open platform account and bind Weixin Mini Program and Service Account under the same open platform account. For an introduction to open platforms, refer to: WeChat Open platform ;
- Read the explaination of the voucher interface and Create the voucher Interface to create a voucher and obtain a card_id;
- Calling the wx.addcard interface within Weixin Mini Program and processing the successful callback;
- The card_id and code obtained in the third step request decoding the code interface to get the real code;
- Record the openid in the user Weixin Mini Program, the code received by the user, and the card_id;
- Handles the card receipt event, recording the user's openid in Service Account, the user's received code and card_id.
# Interface Dxplaination
Please refer to: wx.addcard
# Note
- The api_ticket in the signature involved in the wx.addcard interface must be passed into the ticket obtained by creating the card coupon Service Account;
- After a user collects a voucher, the voucher collection event is pushed to the developer server, which the developer must handle. See voucher event notification ;
- The developer can determine the source of the user's voucher through outer_str;
- This function only supports 1.1.0 version and above the base library version, Weixin Mini Program must make a version judgment and compatible with the lower version.
# Weixin Mini Program
# Scene introduction
Developers can invoke this interface to allow users to view and present their WeChat vouchers within Weixin Mini Program.
# step
1.When the user enters Weixin Mini Program, the developer must obtain the card_id and code (real code) of the card voucher that the user has received; 2. Call wx.openCard to open a user's card voucher for the user to view, use.
# Interface Dxplaination
Please refer to: wx.openCard interface
# Note
- Currently, the Weixin Mini Program page is automatically returned when a card is collected. If a developer encourages the user to proceed on the card after receiving the card, they must call wx.opencard in the callback of the function wx.addcard;
- After wx.addcard successfully returns the parameter code is encrypted field, must decrypt before calling wx.opencard, see decoding code interface for details;
# Weixin Mini Program Card Opening Assembly
# Scene introduction
Developers can develop their own membership module in Weixin Mini Program and embed the card opening process in it, and WeChat coupons provide "card opening component functions" for card opening within the Mini Program.
When the user enters the card open component within Weixin Mini Program, the user can quickly pull and prefill the information that the user previously filled out in WeChat to open the card, allowing the user to "open the card with one click."
For merchants, the card opening component combines "open card registration" and "add to card package," which can quickly open cards while eliminating mobile phone verification and other aspects, improving the card opening rate.
At present, card opening components are divided into jump-transition card opening components and non-jump-transition card open components.
NOTE:
- Weixin Mini Program To call the card opening component, Service Account must have WeChat voucher function, for details see: WeChat voucher explaination]] .
- Developers must first understand the basic knowledge of card voucher development after the call, please see: WeChat card voucher interface explaination .
# step
Jump to Transition One-Click Card steps
- Create a membership card. Select how to activate your membership card "wx_activate": true, "wx_activate_after_submit": true, and in theactivate_app_brand_user_name、activate_app_brand_passPass in information about the activation Weixin Mini Program page and get card_id. See: Create a membership card interface ;
- Set the card opening field that the user fills out when the card opens, both mandatory and optional. See: Set the card open field interface for details
- Get the parameters required for the card open component;
- Determine whether new and existing users and client versions decide whether to call the card open plug-in interface;
- Calls a card opening plug-in for the user to open the card, and handles the callback of the card opening plug;
- Get the user's card opening information and activate the user' membership card;
The exact process is shown here:
Non-Jump Switch One-Click Card Opening Steps
- Create a membership card. Select how to activate your membership card "wx_activate": true, "wx_activate_after_submit": false, and get the card_id. See: Create a member card interface
- Set the card opening field that the user fills out when the card opens, both mandatory and optional. See: Set the card open field interface for details
- Get the parameters required for the card open component;
- Determine whether new and existing users and client versions decide whether to call the card open plug-in interface;
- Calls a card opening plug-in for the user to open the card, and handles the callback of the card opening plug;
- Get user card details;
# Interface Dxplaination
# Interface 1: Get card open plug-in parameters
Interface Dxplaination
Developers can obtain the parameters required to call the card open plug-in through this interface.
Dxplaination of request parameters
parameter | Parameter explaination |
---|---|
access_token | Create token for card Service Account |
JSON | Request data |
URL | https://api.weixin.qq.com/card/membercard/activate/geturl?access_token= ACCESS_TOKEN |
{ "card_id" : "pbLatji6o5g7hJh8Otuvux4y1ty0", "outer_str" : "123" }
parameter | Is it compulsory? | Parameter explaination |
---|---|---|
card_id | yes | The card_id of the membership card |
outer_str | no | Channel value, which is used to calculate channel parameters for this receipt |
{ "errcode": 0, "errmsg": "ok", "url": "https://mp.weixin.qq.com/bizmall/activatemembercard? action=preshow&&enxxxxxxx=MjM5Mzc0OTEwMA%3D%3D#wechat_redirect" }
Return parameter explaination
parameter | Parameter explaination |
---|---|
errcode | Error code |
errmsg | Error information, used to locate the cause of the error |
url | The url returned with the parameters needed to invoke the plug-in |
Note 1. The parameters returned by this interface must be filled in the open card plug-in interface intact, and the urldecode operation must be done;
# Interface 2: Weixin Mini Program in the open card plug-in interface
Interface Dxplaination
1.Developers through the interface can be in their own Weixin Mini Program to open the card plug-in;
2.This interface is the Weixin Mini Program interface, and developers must first understand how the Mini Program interface is invoked: see: card event notification ;
- Base Library 1.3.0 Starts support, with lower versions requiring compatibility
4.IOS WeChat Guest Account 6.5.9 version is supported, Android Guest Account will soon be supported in 6.5.10 version, please use iOS Guest Account to debug
Open another Weixin Mini Program associated under the same Service Account.
OBJECT Parameter Dxplaination:
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
appId | String | yes | To open the official plug-in AppID, fixed as wxeb490c6f9b154ef9, can not be changed |
extraData | Object | no | The data that needs to be passed to the target Weixin Mini Program, the target Mini Program can get the data in ApageonLaunch (), ApageonShow (). |
success | Function | no | The interface calls a successful callback function |
fail | Function | no | A callback function that fails to call an interface |
complete | Function | no | The interface calls a callback function that ends (both successful and failed calls are executed) |
Success Returns Parameter Dxplaination:
Parameter Name Type Dxplaination errMsgString Call Result
Example code:
wx.navigateToMiniProgram({ appId: ‘wxeb490c6f9b154ef9’, // 固定为此appid,不可改动 extraData: data, // 包括encrypt_card_id outer_str biz三个字段,须从step3中获得的链接中获取参数 success: function() { }, fail: function() { }, complete: function() { } })
Return instructions
In ApageonShow to determine the data returned from the membership card Weixin Mini Program data
- Determine if data.referrerInfo.appId is open card Weixin Mini Program appId 'wxeb490c6f9b154ef9', if not abort
- Determine whether there is data.referrerInfo.extraData whether there is data, if there is no data, indicating that the user is not activated directly left swipe / click the return key to return, or the user has activated
- If the user activates successfully, the activate_ticketcard_idcode parameter can be obtained from data.referrerInfo.extraData for the next action
Bug & Tip Tip: Calling this API on the developer tools does not actually jump to another Weixin Mini Program, but the developer tools will verify that the call jumps successfully Tip: Developer tools support debugging for "Jump Weixin Mini Program handles receiving parameters"
# Interface 3: Get information submitted when a user opens a card (Jump to the card opening component)
Interface Dxplaination
Developers can obtain the value of fields filled out when a user opens a card through this interface.
Dxplaination of request parameters
parameter | Parameter explaination |
---|---|
access_token | Create token for card Service Account |
JSON | Request data |
URL | https://api.weixin.qq.com/card/membercard/activatetempinfo/get?access_token=TOKEN |
{ "activate_ticket" : "abcdefg" }
parameter | Is it compulsory? | Parameter explaination |
---|---|---|
activate_ticket | yes | Jump-to-switch card opening component After a card is opened, the activation note in the callback can be used to obtain user card opening information |
{
"errcode": 0,
"errmsg": "ok",
"info": {
"common_field_list": [
{
"name": "USER_FORM_INFO_FLAG_MOBILE",
"value": "15*****518"
},
{
"name": "USER_FORM_INFO_FLAG_NAME",
"value": "HK"
},
{
"name": "USER_FORM_INFO_FLAG_EDUCATION_BACKGROUND",
"value": "研究生"
}
],
"custom_field_list": []
}
}
Return parameter explaination
type | describe |
---|---|
Parameter Name | Introductions |
errcode | Error code, 0 is normal |
errmsg | Error message |
info | Member Information |
custom_field_list | Membership card membership information categories set by the developer, such as hobbies. |
name | Category Name of Member Information |
value | Membership card information category value, such as rating value, etc. |
value_list | Return when you fill in an item for multiple choice |
value_list | Return when you fill in an item for multiple choice |
common_field_list | Officially defined categories of information |
Common_field_id_list, which enables developers to use the following option types
parameter | Introductions |
---|---|
USER_FORM_INFO_FLAG_MOBILE | Mobile phone number |
USER_FORM_INFO_FLAG_SEX | gender |
USER_FORM_INFO_FLAG_NAME | Full name |
USER_FORM_INFO_FLAG_BIRTHDAY | birthday |
USER_FORM_INFO_FLAG_IDCARD | ID |
USER_FORM_INFO_FLAG_EMAIL | mailbox |
USER_FORM_INFO_FLAG_LOCATION | Detailed address |
USER_FORM_INFO_FLAG_EDUCATION_BACKGRO | educational background |
USER_FORM_INFO_FLAG_INDUSTRY | industry |
USER_FORM_INFO_FLAG_INCOME | income |
USER_FORM_INFO_FLAG_HABIT | Hobby |
- Note 1. This interface only jump type open card components can be called, non-jump transition open card component callback does not contain activate_ticket
# Interface 4: Get information submitted when a user opens a card (non-transition card opening component)
Interface Dxplaination
Developers can obtain the value of fields filled out when a user opens a card through this interface.
Dxplaination of request parameters
parameter | Parameter explaination |
---|---|
access_token | Create token for card Service Account |
JSON | Request data |
URL | https://api.weixin.qq.com/card/code/get?access_token=TOKEN |
{ "card_id" : "abcdefg", "code" : "abcdefg" }
parameter | Is it compulsory? | Parameter explaination |
---|---|---|
card_id | no | Voucher id, non - custom code type membership card does not need to fill in |
code | yes | The code of the membership card |
- Return data
{
"errcode": 0,
"errmsg": "ok",
"openid": "obLatjjwDxxxxdoGIdwNqRXw",
"nickname": "Fourier",
"membership_number": "316510891298",
"bonus": 460,
"sex": "MALE",
"user_info": {
"common_field_list": [
{
"name": "USER_FORM_INFO_FLAG_MOBILE",
"value": "1552xxxx8888"
},
{
"name": "USER_FORM_INFO_FLAG_NAME",
"value": "微信"
}
],
"custom_field_list": []
},
"user_card_status": "NORMAL"
}
Parameter Name | Introductions |
---|---|
errcode | Error code, 0 is normal |
errmsg | Error message |
openid | User's unique identifier in this Service Account |
nickname | User nickname |
bonus | Points Information |
balance | Balance information |
sex | User gender |
user_info | Member Information |
custom_field_list | Membership card membership information categories set by the developer, such as hobbies. |
common_field_list | Officially defined categories of information, such as points. |
name | Category Name of Member Information |
value | Membership card information category value, such as rating value, etc. |
user_card_status | Current user membership card status, NORMAL Normal Expire Expired GIFTING GIFT_SUCC GIFT GIFT_TIMEOUT GIFT GIFT TIMEOUT DELETE DELETED, UNAVAILABLE Expired |
Common_field_id_list, which enables developers to use the following option types
parameter | Introductions |
---|---|
USER_FORM_INFO_FLAG_MOBILE | Mobile phone number |
USER_FORM_INFO_FLAG_SEX | gender |
USER_FORM_INFO_FLAG_NAME | Full name |
USER_FORM_INFO_FLAG_BIRTHDAY | birthday |
USER_FORM_INFO_FLAG_IDCARD | ID |
USER_FORM_INFO_FLAG_EMAIL | mailbox |
USER_FORM_INFO_FLAG_LOCATION | Detailed address |
USER_FORM_INFO_FLAG_EDUCATION_BACKGRO | educational background |
USER_FORM_INFO_FLAG_INDUSTRY | industry |
USER_FORM_INFO_FLAG_INCOME | income |
USER_FORM_INFO_FLAG_HABIT | Hobby |
# Interface 5: Activating a user's membership card (Jump to the card open component)
Interface Dxplaination
Developers can obtain the value of fields filled out when a user opens a card through this interface.
Dxplaination of request parameters
parameter | Parameter explaination |
---|---|
access_token | Create token for card Service Account |
JSON | Request data |
URL | https://api.weixin.qq.com/card/membercard/activate?access_token=TOKEN |
{
"init_bonus": 100,
"init_bonus_record":"旧积分同步",
"init_balance": 200,
"membership_number": "AAA00000001",
"code": "12312313",
"card_id": "xxxx_card_id",
"background_pic_url": "https://mmbiz.qlogo.cn/mmbiz/0?wx_fmt=jpeg",
"init_custom_field_value1": "xxxxx"
}
parameter | Is it compulsory? | type | describe |
---|---|---|---|
membership_number | yes | string(20) | The member card number, which is entered by the developer, is displayed as a serial number in the user's card package. Can be equal to Code. |
code | yes | string(20) | The code received by the user |
card_id | no | string(32) | Voucher ID, custom code Voucher required |
background_pic_url | no | string(128) | For merchants to customize the logo for a member card, you must first call the upload image interface to upload the logo to the CDN, otherwise you will report an error. Please follow the WeChat custom logo design specification for a Member Card |
activate_begin_time | no | unsigned int | The effective start time after activation. If you do not fill in the default data_info at the time of creation. Unix timestamp format. |
activate_end_time | no | unsigned int | Valid expiration time after activation. If you do not fill in the default data_info at the time of creation. Unix timestamp format. |
init_bonus | no | int | Initial points, not filled with 0. init_bonus_record |
init_balance | no | int | The initial balance, not filled, is 0. |
init_custom_field_value1 | no | string(12) | The custom_field1 field defines the initial value of the type, limited to 4 characters and 12 bytes. |
init_custom_field_value2 | no | string(12) | When created, the custom_field2 field defines the initial value of the type, limited to 4 characters, 12 bytes. |
init_custom_field_value3 | no | string(12) | The custom_field3 field defines the initial value of the type, limited to 4 characters and 12 bytes. |
Return data
{
"init_bonus": 100,
"init_bonus_record":"旧积分同步",
"init_balance": 200,
"membership_number": "AAA00000001",
"code": "12312313",
"card_id": "xxxx_card_id",
"background_pic_url": "https://mmbiz.qlogo.cn/mmbiz/0?wx_fmt=jpeg",
"init_custom_field_value1": "xxxxx"
}
Parameter Name | Introductions |
---|---|
errcode | Error code, 0 is normal |
errmsg | Error message |
# Note
- New and old members judge: if the user has received WeChat membership card,Developers can obtain the user's unionid via and to obtain the users' unionid, and the user can associate the user''s previous member accounts after authorizing to log in to Weixin Mini Program;
- New and old version judgment: developers must design two sets of processes for members to open cards, iOS 6.5.9 & Android 6.5.10And above WeChat version can be called to open the card component, the lower version must develop Weixin Mini Program their own registration page, with the completion of the registration to receive members card
# Weixin Mini Program
# Scene introduction
When creating a card and voucher, the merchant can set the service entrance in the card and voucher into the Weixin Mini Program service.
# step
- Developers must bind Weixin Mini Program to Service Account. For binding instructions, see Bind service numbers and Mini Program
- Create a card coupon, and set the cell in the card to the path corresponding to Weixin Mini Program;
- Processing the information obtained when jumping Weixin Mini Program;
# Interface Dxplaination
- Create a membership card
{ "card": {
"card_type": "MEMBER_CARD",
"member_card": {
"base_info": {
"custom_url_name": "立即使用",
"custom_url": "http://www.qq.com",
"custom_app_brand_user_name": "gh_86a091e50ad4@app",
"custom_app_brand_pass":"API/cardPage",
"custom_url_sub_title": "6个汉字tips",
"promotion_url_name": "更多优惠",
"promotion_url": "http://www.qq.com",
"promotion_app_brand_user_name": "gh_86a091e50ad4@app",
"promotion_app_brand_pass":"API/cardPage"
}
}
}
Field Name | Field Description | Field Examples |
---|---|---|
custom_app_brand_user_name | Custom user_name using the entry jump Weixin Mini Program, formatted as original id + @ app | gh_86a091e50ad4@app |
custom_app_brand_pass | Custom Use Entry Weixin Mini Program Page Address | API/cardPage |
center_app_brand_user_name | User_name for Weixin Mini Program | gh_86a091e50ad4@app |
center_app_brand_pass | Custom Centered Use Entry Weixin Mini Program Page Address | API/cardPage |
promotion_app_brand_user_name | User_name for Weixin Mini Program | gh_86a091e50ad4@app |
promotion_app_brand_pass | Custom Marketing Portal Weixin Mini Program Page Address | API/cardPage |
activate_app_brand_user_name | The user_name of Weixin Mini Program, | gh_86a091e50ad4@app |
activate_app_brand_pass | Activate Weixin Mini Program page address | API/cardPage |
custom_field1、custom_field2 custom_field3 | Information category field at the top of the member card, containing the following two fields | |
app_brand_user_name | Custom information category Weixin Mini Program user_name, formatted as original id + @ app | gh_86a091e50ad4@app |
app_brand_pass | Page path for custom information category Weixin Mini Program | API/cardPage |
custom_cell1、custom_cell2 | A custom entry for membership cards that contains the following two fields | |
app_brand_user_name | Custom entry Weixin Mini Program user_name, formatted as original id + @ app | gh_86a091e50ad4@app |
app_brand_pass | Page path for custom entry Weixin Mini Program | API/cardPage |
bonus_app_brand_user_name | Weixin Mini Program user_name corresponding to the integral information category, formatted as original id + @ app | gh_86a091e50ad4@app |
bonus_app_brand_pass | Page path of integration entry Weixin Mini Program | API/cardPage |
balance_app_brand_user_name | Weixin Mini Program user_name corresponding to the balance information category, formatted as original id + @ app | gh_86a091e50ad4@app |
balance_app_brand_pass | Page path for balance entry Weixin Mini Program | API/cardPage |
\ * You need to call the card coupon update interface to update the corresponding Weixin Mini Program page to the corresponding jump outside the chain structure, the original jump H5 field is retained.
- Get a jump parameter
After making a jump from the Weixin Mini Program card, the developer can retrieve the card_id, the encrypt_code, and the user's Service Account openid from the apponshow query or by calling the decoding code interface to decode the encrypted_code into real code.