Member Card Upgrade Notice
From May 15, 2016, the Weixin Coupons Team started to upgrade the member card capabilities to help merchants better manage their members.
-The primary entries to member cards were optimized on Weixin, so that members can locate the cards quickly in stores.
-Different card backgrounds can be customized based on membership levels.
-By scanning code in stores, new users can receive cards and existing users can open cards quickly to enjoy such features as ordering meals and making purchases.
-Issue membership invitation messages to users immediately after they make payments using Weixin to enroll new members quickly.
-New member card categories are added. As of April 20, 2016, only the merchants who provide products and services falling under the supported member card categories can create member cards. The existing member cards are not affected. For more information, please see"Update of Supported Weixin Member Card Categories"
Contents
1. What's New in the Member Card
4. Details of the "Create Member Card" API
4.2 Obtaining Member Card Review Results
5.2 Adding One or More Coupons a Web Page
5.3 Issuing Member Cards via Gallery
5.4 Issuing Member Cards via an Official Account Message
5.5 Recording Users' Card Receipt Behaviors
5.6 Collecting Issuance Channel Data
7. Updating Member Information
# 1. What's New in the Member Card
Based on the native capabilities, Weixin Cards & Offers Team adds capabilities such as card background customization, an in-store QR code scanning solution, post-payment message templates, and member tag-based group messages, and upgrades the Cards & Offers messaging capability to help merchants manage members in a better way.
-(a) Supported custom backgrounds specified by developers.
-(b) Upgraded cards & offers messages. Loyalty point/Balance changes are automatically sent via message templates that may carry promotion information.
(a)
(b)
# 2. Instructions
Before reading this part, read Homepage, Getting Started, and Weixin Coupon APIs to ensure that you understand basic terms and call methods of the Weixin Official Accounts Platform and coupon APIs.
Generally, for the calling order of member card APIs, see the following procedure:
# 3. How to Use Member Cards
In-Store QR Code Scanning Quick Pay with Member Cards Connecting Member Cards to CRM
Connecting Member Cards to the Payment System Linking Old Members Top-Up with Member Cards
<a href="https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&key=1479824356&version=1&lang=zh_CN&platform=2 "Card Activation Component"" target="_blank">Card Activation Component
Connecting Cards & Offers to Mini Programs
# 4. Details of the "Create Member Card" API
# 4.1 Creating Member Cards
Developers can call this API to create a member card, and obtain card_id to issue the member card. Before calling this API, read the "Upload Image" API and Homepage in the description of "Create Coupon" API, and quickly record required information displayed on the member card.
API Request Format
HTTP request method: POSTURL:https://api.weixin.qq.com/card/create?access_token=ACCESS_TOKEN
Parameters
Parameter | Required | Description |
---|---|---|
access_token | Yes | Credential for calling the API |
POST data | Yes | JSON data |
POST data example:
{
"card": {
"card_type": "MEMBER_CARD",
"member_card": {
"background_pic_url": "https://mmbiz.qlogo.cn/mmbiz/",
"base_info": {
"logo_url": "http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZ/0",
"brand_name": "Hai Di Lao",
"code_type": "CODE_TYPE_TEXT",
"title": "Hai Di Lao Member Card",
"color": "Color010",
"notice": "Present this coupon to the waiter at the time of use",
"service_phone": "020-88888888",
"description": "Using with other coupons is not allowed",
"date_info": {
"type": "DATE_TYPE_PERMANENT"
},
"sku": {
"quantity": 50000000
},
"get_limit": 3,
"use_custom_code": false,
"can_give_friend": true,
"location_id_list": [
123,
12321
],
"custom_url_name": "Use Now",
"custom_url": "http://weixin.qq.com",
"custom_url_sub_title": "6 Chinese characterstips",
"promotion_url_name": "Promotion Entrance 1",
"promotion_url": "http://www.qq.com",
"need_push_on_view": true
},
"advanced_info": {
"use_condition": {
"accept_category": "Shoes",
"reject_category": "Adidas",
"can_use_with_other_discount": true
},
"abstract": {
"abstract": "Weixin Restaurant introduces a variety of new dishes. We look forward to your visit!",
"icon_url_list": [
"http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sj
piby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0"
]
},
"text_image_list": [
{
"image_url": "http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sjpiby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0",
"text": "This dish is cooked in a unique way with selective ingredients to tickle the taste buds of diners to the greatest extent. "
},
{
"image_url": "http://mmbiz.qpic.cn/mmbiz/p98FjXy8LacgHxp3sJ3vn97bGLz0ib0Sfz1bjiaoOYA027iasqSG0sj piby4vce3AtaPu6cIhBHkt6IjlkY9YnDsfw/0",
"text": "This dish offers balanced nutrition to cater to the public's taste. It is suitable for all ages."
}
],
"time_limit": [
{
"type": "MONDAY",
"begin_hour":0,
"end_hour":10,
"begin_minute":10,
"end_minute":59
},
{
"type": "HOLIDAY"
}
],
"business_service": [
"BIZ_SERVICE_FREE_WIFI",
"BIZ_SERVICE_WITH_PET",
"BIZ_SERVICE_FREE_PARK",
"BIZ_SERVICE_DELIVER"
]
},
"supply_bonus": true,
"supply_balance": false,
"prerogative": "test_prerogative",
"auto_activate": true,
"custom_field1": {
"name_type": "FIELD_NAME_TYPE_LEVEL",
"url": "http://www.qq.com"
},
"activate_url": "http://www.qq.com",
"custom_cell1": {
"name": "Entrance 2",
"tips": "It is displayed after activation.",
"url": "http://www.qq.com"
},
"bonus_rule": {
"cost_money_unit": 100,
"increase_bonus": 1,
"max_increase_bonus": 200,
"init_increase_bonus": 10,
"cost_bonus_unit": 5,
"reduce_money": 100,
"least_money_to_use_bonus": 1000,
"max_reduce_bonus": 50
},
"discount": 10
}
}
}
Table of the API's fields
Parameters
Parameter | Required | Type | Description |
---|---|---|---|
card_type | Yes | string | The type of the member card |
background_pic_ur l | No | string (128) | Merchant-customized member card background image. the "Upload Image" API should be called first to upload the background image to the CDN, otherwise an error is returned. The card should be designed by following the Weixin member card custom background design specifications and must be less than 1000*600 pixels. |
base_info | Yes | JSON | Basic coupon data. See the table below. This field is applicable to all cards/coupons. |
prerogative | Yes | strin g(3072) | Describes privileges of the member card. It supports a maximum of 1024 Chinese characters. |
auto_activate | No | bool | When it is set to true, the system automatically activates a member card claimed by a user, without calling the activation API. For details, see Automatic Activation. |
wx_activate | No | bool | When it is set to true, the member card supports quick activation. In this case, do not pass in the activate_url field. Otherwise, the setting of wx_activate fails. In addition, after wx_activate is specified, you still need to call the activation API to specify activation items to make the member card take effect. For details, see Quick Activation. |
supply_bonus | Yes | bool | Specifies whether to display loyalty points. It can be set to true or false. If it is set to true, all the fields related to loyalty points must be specified. When set to true, this field cannot be changed to false. |
bonus_url | No | string (128) | Specifies an external redirect URL to view loyalty points. This field is applicable only when loyalty points cannot be synchronized via the activation API. |
supply_balance | Yes | bool | Specifies whether top-up is allowed. It can be set to true or false. If it is set to true, all the fields related to stored top-up must be specified. When set to true, this field cannot be changed to false. This field is available only when the top-up feature is activated. For details, see Obtaining Privileges. |
balance_url | No | string (128) | Specifies an external redirect URL to view balance details. This field is applicable only when the balance cannot be synchronized via the activation API. |
custom_field1 | No | JSON structure | A custom member information item. It is displayed after the member card is activated. It includes name_type (name) and url fields. |
custom_field2 | No | JSON structure | A custom member information item. It is displayed after the member card is activated. It includes name_type (name) and url fields. |
custom_field3 | No | JSON structure | A custom member information item. It is displayed after the member card is activated. It includes name_type (name) and url fields. |
name_type | No | string (24) | A semi-custom name of a member information item. When a developer changes a value of this type of information, the developer can select to trigger a system message template to notify the user. FIELD_NAME_TYPE_LEVEL indicates the level. FIELD_NAME_TYPE_COUPON indicates the coupon. FIELD_NAME_TYPE_STAMP indicates the stamp. FIELD_NAME_TYPE_DISCOUNT indicates the discount. FIELD_NAME_TYPE_ACHIEVEMEN indicates the achievement. FIELD_NAME_TYPE_MILEAGE indicates the mileage. FIELD_NAME_TYPE_SET_POINTS indicates set points. FIELD_NAME_TYPE_TIMS indicates the number of times. |
name | No | string (24) | A custom name of a member information item. When a developer changes a value of this type of information, no system message template is triggered to notify the user. |
url | No | string (128) | The external redirect URL of an item |
bonus_cleared | No | string (128) | Rules for clearing loyalty points |
bonus_rules | No | string (128) | Rules for calculating loyalty points |
balance_rules | No | string (128) | Top-up rules |
activate_url | No | string (128) | The URL for activating the member card |
activate_app_brand_user_name | No | string (128) | user_name of the Mini Program to which the redirection is made from the URL for activating the member card. The Mini Program must be linked to the Official Account. |
activate_app_brand_pass | No | string (128) | The path of the Mini Program to which the redirection is made from the URL for activating the member card. |
custom_cell1 | No | JSON structure | A custom member information item. It is displayed after the member card is activated. |
name | Yes | string (15) | Entry name |
tips | Yes | string (18) | Tips displayed on the right of the entry. It supports a maximum of six Chinese characters |
url | Yes | string (128) | The URL redirected to the entry |
bonus_rule | No | JSON structure | [TH1]Rules for calculating loyalty points |
cost_money_unit | No | int | The purchase amount (accurate to cent) |
increase_bonus | No | int | The increased loyalty points |
max_increase_bonus | No | int | The upper limit of loyalty points that a user can get per time |
init_increase_bonus | No | int | The initial loyalty points |
cost_bonus_unit | No | int | [TH2]Indicates the loyalty points must be used in an increment of 5. |
reduce_money | No | int | Indicates XX CNY can be redeemed (accurate to cent) |
least_money_to_use_bonus | No | int | A redemption criterion. It specifies the minimum amount (accurate to cent) that is required for redeeming loyalty points. |
max_reduce_bonus | No | int | A redemption criterion. It specifies the maximum number of loyalty points that can be redeemed per purchase. |
discount | No | int | The discount offered for this member card. The value 10 indicates a 10% discount. |
base_info:
Parameter | Required | Type | Description |
---|---|---|---|
logo_url | Yes | string (128) | Merchant logo of coupon. Recommended dimension: 300*300 pixels. |
code_type | Yes | string (16) | Code type. CODE_TYPE_TEXT: text; CODE_TYPE_BARCODE: barcode; CODE_TYPE_QRCODE: QR code; CODE_TYPE_ONLY_QRCODE: QR code without numeric code; CODE_TYPE_ONLY_BARCODE: barcode without numeric code; CODE_TYPE_NONE: No QR code and barcode. |
pay_info | No | JSON | The structural body of the payment feature. For details, see the structure of swipe_card. |
swipe_card | No | JSON | The structural body of the Quick Pay feature. It includes the is_swipe_card field. |
is_swipe_card | No | bool | Specifies whether to display the WeChat Pay interface when the member card is used. |
is_pay_and_qrcode | No | bool | Specifies whether the central button on the member card supports both WeChat Pay and the QR code of the member card. |
brand_name | Yes | string | Merchant name, with a maximum length of 12 characters. |
title | Yes | string | Coupon title, with a maximum length of 9 Chinese characters (18 English characters). A combination of coupon attributes, service items and amount is recommended. |
color | Yes | string | Coupon color. Enter a value between Color010 and Color100. |
notice | Yes | string | Coupon usage tip, with a maximum length of 16 Chinese characters (32 English characters). |
description | Yes | string | Coupon usage instructions, with a maximum length of 1024 Chinese characters (2048 English characters). |
sku | Yes | JSON | Product information |
quantity | Yes | int | Coupon inventory. Maximum is 100,000,000. Cannot be 0. |
date_info | Yes | JSON | Information of coupon validity period |
type | Yes | string | The type of service time. It supports a fixed time range, a fixed date, and permanent time (DATE_TYPE_PERMANENT). |
begin_timestamp | No | int | Start time of validity period. This field only takes effect when type = DATE_TYPE_FIX_TIME_RANGE. It is the number of seconds that have elapsed since 00:00:00 1/1/1970 (UTC+8). |
end_timestamp | No | int | End time of validity period (UTC+8, in seconds). This field only takes effect when type = DATE_TYPE_FIX_TIME_RANGE. |
fixed_term | No | int Indicates the number of days during which the received coupon is valid, and only takes effect when type = DATE_TYPE_FIX_TERM. Enter 0 if the coupon becomes valid on the day of its receipt. | |
fixed_begin_term | No | int | Indicates the number of days after which the received coupon becomes valid, and only takes effect when type = DATE_TYPE_FIX_TERM. |
use_custom_code | No | bool | Whether to use custom code. Enter "true" or "false". Default is "false". Generally, developers owning a coupon code system select custom codes. For more information, see "Whether to use custom code". |
bind_openid | No | bool | Whether to specify the users to receive the coupons. Enter "true" or "false" (default). |
service_phone | No | string (24) | Customer service phone number. |
location_id_list | No | array | ID of store location. Obtain the value by calling the POI Store Management API. |
use_all_locations | No | bool | Specifies whether the member card is supported in all stores. After it is specified, any changes to the stores will be synced to the card. |
center_title | No | string (18) | The entry button centered in the middle of the card. It is only displayed when the card status is normal. |
center_sub_title | No | string (24) | Words shown below the entry button. It is only displayed when the card is activated and available. |
center_url | No | string (128) | URL centered on the top of the card. It is only displayed when the card is activated and available. |
custom_url_name | No | string (15) | Title of the custom external redirect link |
custom_url | No | string (128) | Custom redirect URL |
custom_url_sub_title | No | string (18) | Words shown to the right of the entry button |
promotion_url_name | No | string (15) | Title of custom entry button to promotional page |
promotion_url | No | string (128) | URL of external redirect link |
promotion_url_sub_title | No | string (18) | Words shown to the right of the entry button to the promotional page |
get_limit | No | int | The Maximum number of coupons that each user can claim. One member card for one person is recommended. |
can_share | No | bool | Indicates whether the coupon claiming page is sharable. It is set to true by default. |
can_give_friend | No | bool | Indicates whether the card can be gifted. Enter "true" (default). |
need_push_on_view | No | bool | Specifies whether to push an event if the user taps to open the member card. It is set to false by default. For details, see Event of Opening Member Card. |
advanced_info
Parameter | Required | Type | Description |
---|---|---|---|
advanced_info | No | JSON structure | Advanced field specific to general coupons |
use_condition | No | JSON structure | Indicates the usage condition of a coupon. If it is left empty, "No minimum purchase amount/Available for all commodities" is indicated on the coupon, and "Using with other coupons is allowed" is displayed in the usage instructions. |
accept_category | No | string (512) | Specifies the product categories the coupon applies to. This field is only applicable to cash coupons. "Only for xxx" is shown on the coupon when this field is specified. |
reject_category | No | string (512) | Specifies the product categories the coupon does not apply to. This field is only applicable to cash coupons. "Not for xxx" is shown on the coupon when this field is specified. |
least_cost | No | int | Indicates the minimum purchase amount required to use the coupon (exchange/cash coupons). "For an order not below xx CNY" is shown on the coupon when this field is specified. |
object_use_for | No | string (512) | Indicates the product categories that need to be purchased before the exchange coupon can be used. "Available after purchase of xxx" is shown on the coupon when the field is specified. |
can_use_with_other_discount | No | bool | Indicates whether the coupon can be used with other coupons. If it is "false", "Using with other coupons is not allowed" is shown in the usage instructions. If it is "true", "Using with other coupons is allowed" is shown. Default is "true". |
abstract | No | JSON structure | Cover abstract structure name |
abstract | No | string (24) | Cover abstract description |
icon_url_list | No | string (128) | Cover image list. Only one cover image URL is allowed. Enter the image URL obtained by uploading the image with "Upload Image" API. If a non-CDN URL is entered, an error occurs. Recommended image dimension is 850*350 pixels. |
text_image_list | No | JSON structure | List of details (text and images), which are displayed in the details page. General coupon developers must pass at least one details list. |
image_url | No | string (128) | Image URL. Enter the image URL obtained by uploading the image using "Upload Image" API. Otherwise, an error occurs. |
text | No | string (512) | Details (text and image) description |
business_service | No | arry | Merchant service type: BIZ_SERVICE_DELIVER: food delivery; BIZ_SERVICE_FREE_PARK: parking lot; BIZ_SERVICE_WITH_PET: pets are allowed; BIZ_SERVICE_FREE_WIFI: Free WiFi is available. Multiple choices are allowed. |
time_limit | No | JSON structure | Time period to which the coupon usage is limited. It is composed of the following fields. |
type | No | string (24) | The limit type. It can be set to enumerated values, including MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, and SUNDAY. This field controls only what is displayed, not the actual use logic. If it is not specified, nothing is displayed by default. |
begin_hour | No | int | Start time (hour) under the current limit type. For example, if Monday is entered for "type", and 10 is entered for this field, the coupon is available from 10:00 every Monday. |
begin_minute | No | int | Start time (minute) under the current limit type. For example, if Monday is entered for "type", 10 is entered for "begin_hour", and 59 is entered for this field, the coupon is available from 10:59 every Monday. |
end_hour | No | int | End time (hour) under the current limit type. For example, if Monday is entered for "type", and 20 is entered for this field, the coupon is available between 10:00 and 20:00 every Monday. |
end_minute | No | int | End time (minute) under the current limit type. For example, if Monday is entered for "type", 10 is entered for "begin_hour", and 59 is entered for this field, the coupon is available between 10:59 and 00:59 every Monday. |
Response Description
{
"errcode":0,
"errmsg":"ok",
"card_id":"p1Pj9jr90_SQRaVqYI239Ka1erkI"
}
Parameter | Description |
---|---|
errcode | Error code. 0 indicates a successful request. |
errmsg | Error message |
card_id | Coupon ID |
Notes
*1. Member cards can be created only for some categories. If a member card is to be created for an unsupported category, an error code is returned. For the supported items, see Update of Supported Weixin Member Card Categories.
2. When creating a member card, you need to specify the information item to be displayed after the member card is activated. Currently, the loyalty points, balance, level, coupons, mileage, stamp, achievements, and discounts can be displayed. A maximum of three member information items can be displayed on Weixin 6.2 and later. To be specific, a maximum of three fields among supply_bonus, supply_balance, custom_field1, custom_field2, and custom_field3 can be selected during creation of a member card.
3. When creating coupons, you must specify a time stamp earlier than January 19, 2038. To specify a longer validity period, you can select Permanently Effective.
# 4.2 Obtaining Member Card Review Results
After a member card is created by calling the API, the system automatically submits the member card for review. The review results are sent as events within three business days to the developer. In addition, the status of the member card can be queried by calling an API.
Coupon Approval Event
When the generated coupons are approved, Weixin pushes the event to the URL entered by the developer. For details, see Coupon-related Event Push. After approval, The member card can be officially put into use .
# 4.3 Setting Test Whitelist
If a member card is not approved, the developer can whitelist the tester's Weixin ID for them to claim the card. Note that the information of the card claimed in the whitelisted state is not updated with coupons in real time. For details, see Issuing Coupons.
# 5 Details of the "Issue Member Card" API
Weixin Member Cards can be claimed by scanning a QR code, by tapping a link on a web page (For details, see JS-SDK Description Documentation), or from Gallery, a broadcast message of an Official Account, or a message passively replied by an Official Account. Developers can choose one or more issuance methods as described below.
Notes
A member card issued by calling the API is a "card set" without information such as the number, loyalty points, and balance. Such information needs to be updated by calling the member card activation or linking API after the user claims the member card.
The credential for calling the member card activation or linking API is code and card_id. Before calling the "Issue Member Card" API, the developer needs to record the relationship between the code and the member's OpenID via the API or card claiming event.
# 5.1 Creating QR Codes
Create a QR code for the member card and print and place it in the store, so that customers can scan it to claim member cards. You can scan the following QR code to try to claim it. If you have claimed it before, you can scan it to quickly open the member card. For details about this API, see Issuing Coupons.
# 5.2 Adding One or More Coupons in a Web Page
Weixin provides the addCard API for merchants to call at front-end webpage. This API can be used to add one or more coupons to the user's Cards & Offers. See JS-SDK Documentation for details.
(Weixin Scan > Cards & Offers > addcard API)
# 5.3 Issuing Member Cards via Gallery
Introduction to Gallery
The gallery allows developers to call an API to generate an HTML5 page for coupon receipt and obtain the page link required to issue coupons. For details about the API, see Issuing Coupons.
# 5.4 Issuing Member Cards via an Official Account Message
The developer can send a member card to a user by using a broadcast message of an Official Account or a customer service message. For details, see Issuing Coupons.
# 5.5 Recording Users' Card Receipt Behaviors
After a user receives a member card, Weixin pushes a member card receipt event to the developer server. In this way, the developer can record a relationship between the user's OpenID and the code of the member card, and distinguish between receipt channels (see section 1.5) based on parameters in the event.
For details, see Coupon-related Event Push.
# 5.6 Collecting Issuance Channel Data
The outer_id field is added to help developers collect statistics about card issuance data of each channel. After different values of outer_id are entered in the JSON structure of card_ext, when users receive cards, the corresponding values of outer_id are passed into Coupon-related Event Push messages, which are pushed to the developer server.
Example: Set outer_id to 1 in the QR code issuance mode.
{
"action_name": "QR_CARD",
"action_info": {
"card": {
"card_id": "pFS7Fjg8kV1IdDz01r4SQwMkuCKc",
"code": "198374613512",
"openid": "oFS7Fjl0WsZ9AMZqrI80nbIq8xrA",
"expire_seconds": 1800,
"is_unique_code": false,
"outer_id": 1
}
}
}
Get the event XML file
<xml>
<ToUserName>< ![CDATA[toUser] ]></ToUserName>
<FromUserName>< ![CDATA[FromUser] ]></FromUserName>
<FriendUserName>< ![CDATA[FriendUser] ]></FriendUserName>
<CreateTime>123456789</CreateTime>
<MsgType>< ![CDATA[event] ]></MsgType>
<Event>< ![CDATA[user_get_card] ]></Event>
<CardId>< ![CDATA[cardid] ]></CardId>
<IsGiveByFriend>1</IsGiveByFriend>
<UserCardCode>< ![CDATA[12312312] ]></UserCardCode>
<OuterId>1</OuterId>
</xml>
# 6 Activating Member Cards
After a user receives a member card, you can call this API to activate the member card, and specify initial values for member information, such as the loyalty points, balance, level, and number of the member card. Currently, Weixin member cards can be activated in three ways: API-based activation, quick activation, and automatic activation.
Notes
1. Developers can select an appropriate activation procedure based on service scenarios. Only one of the three activation methods can be selected.
2. To activate a member card, developers need to pass in the code that is obtained when a user receives the member card, and specify the member card number membership_number according to the code.
# 6.1 API-based Activation
Description
In the API-based activation method, developers need to develop a web page for users to enter information. Usually, two activation procedures are available:
A user must enter information before claiming a member card. After the member card is claimed, the developer calls the activation API to activate the member card for the user.
A user claims a member card and then taps the member card activation button to go to an information page set by the developer. After the user enters required information, the developer calls the activation API to activate the member card for the user.
API details
API Request Format
HTTP request method: POSTURL:https://api.weixin.qq.com/card/membercard/activate?access_token=TOKEN
Parameters
Parameter | Required | Description |
---|---|---|
access_token | Yes | Credential for calling the API |
POST data | Yes | JSON data |
{
"init_bonus": 100,
"init_bonus_record":" Initial points synchronization",
"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 | Required | Type | Description |
---|---|---|---|
membership_number | Yes | string (20) | The member card number entered by developer and displayed as a serial number in user's Cards & Offers. It can be the same as the code value. |
code | Yes | string (20) | The code obtained by the user upon the card receipt. |
card_id | No | string (32) | Card ID. It is required for a card with a custom code. |
background_pic_url | No | string (128) | Merchant-customized member card background image. The "Upload Image" API should be called first to upload the background image to the CDN, otherwise an error is returned. The card should be designed by following the Weixin member card custom background design specifications. |
activate_begin_time | No | unsigned int | The start time of validity of card after its activation.(expressed as a Unix timestamp). It defaults to the data_info upon card creation if left empty. |
activate_end_time | No | unsigned int | The end time of validity of card after its activation.(expressed as a Unix timestamp). It defaults to the data_info upon card creation if left empty. |
init_bonus | No | int | Initial loyalty points. It defaults to 0 if left empty. |
init_bonus_record | No | string(32) | Describes the synchronization of loyalty points. |
init_balance | No | int | Initial balance. It defaults to 0 if left empty. |
init_custom_field_value1 | No | string (12) | The initial value of custom_field1 when the card is created. It should not be longer than 12 bytes. |
init_custom_field_value2 | No | string (12) | The initial value of custom_field2 when the card is created. It should not be longer than 12 bytes. |
init_custom_field_value3 | No | string (12) | The initial value of custom_field3 when the card is created. It should not be longer than 12 bytes. |
Response Description
Example:
{
"errcode":0,
"errmsg":"ok"
}
Parameter | Description |
---|---|
errcode | Error code. 0 indicates a successful request. |
errmsg | Error message |
# 6.2 Quick Activation
6.2.1 Common Quick Activation
Quick activation is a convenient activation solution provided by Weixin. After claiming a member card, a user can tap "Activate the Member Card" to go to the official information page. Weixin automatically pulls activation information previously entered by the user, so the user does not need to re-enter the activation information, and the mobile number does not need to be re-verified. In this way, the member card is quickly activated, and the activation rate of member cards is increased. For the specific procedure, see the following figure.
Step 1: Enter the wx_activate field in the creation API
API Description
To allow quick activation in Weixin, set wx_activate to "true" in member_card when creating a member card. For details, see the "Create Member Card" API.
If a merchant uses custom member card numbers, the developer can navigate users to the merchant's page after they enters relevant information and activate member cards for the users.
Parameters
Parameter | Required | Description |
---|---|---|
member_card | ||
wx_activate | No | It can be set to true or false. |
POST data example:
{
"card": {
························
························
"member_card": {
"wx_activate": true
}
}
}
Notes
1. If auto_activate is specified, both activate_url and the quick activation API do not take effect.
2. If activate_url field is specified, the quick activation API do not take effect.
3. Specify only one of activate_url, auto_activate, and wx_activate.
Step 2. Set the card activation API
After specifying wx_activate during member card creation, developers need to call this API to set options required for users to activate the member cards. Otherwise, the settings for quick activation do not take effect.
API Request Format
HTTP request method: POST
URL:https://api.weixin.qq.com/card/membercard/activateuserform/set?access_token=TOKEN
Parameters
Parameter | Required | Description |
---|---|---|
access_token | Yes | Credential for calling the API |
POST data | Yes | JSON data |
{
"card_id": "pbLatjnrwUUdZI641gKdTMJzHGfc",
"service_statement": {
"name": "Membership rules",
"url": "https://www.qq.com"
},
"bind_old_card": {
"name": "Links old members",
"url": "https://www.qq.com"
},
"required_form": {
"can_modify": false,
"rich_field_list": [
{
"type": "FORM_FIELD_RADIO",
"name": "Hobbies",
"values": [
"Piano",
"Dance",
"Football"
]
},
{
"type": "FORM_FIELD_SELECT",
"name": "Interests",
"values": [
"Guo Jingming",
"Han Han",
"Nanpai Sanshu"
]
},
{
"type": "FORM_FIELD_CHECK_BOX",
"name": "Occupation",
"values": [
"Racing driver",
"Traveler"
]
}
],
"common_field_id_list": [
"USER_FORM_INFO_FLAG_MOBILE"
]
},
"optional_form": {
"can_modify": false,
"common_field_id_list": [
"USER_FORM_INFO_FLAG_LOCATION",
"USER_FORM_INFO_FLAG_BIRTHDAY"
],
"custom_field_list": [
"Favorite movie"
]
}}
Parameter | Required | Type | Description |
---|---|---|---|
card_id | Yes | string (32) | Card ID |
required_form | No | JSON structure | Required for member card activation. |
optional_form | No | JSON structure | Optional for member card activation. |
can_modify | No | bool | Specifies whether fields in the current structure (required_form or optional_form) can be modified after member card activation. When it is set to true, merchants need to receive corresponding event notifications and process the modification events. |
common_field_id_list | No | arry | Options formatted by Weixin. For details, see the following table. |
custom_field_list | No | arry | Custom option name. Developers can define a maximum of five custom options, including required and optional options. |
rich_field_list | No | arry | Custom rich text options, including the three fields in the following cell. Developers can define a maximum of five custom options, including required and optional options. |
type | No | string (21) | The type of the rich text. FORM_FIELD_RADIO: custom single-select option. FORM_FIELD_SELECT: custom option. FORM_FIELD_CHECK_BOX: custom multi-select option. |
name | No | string (21) | Field name |
values | No | arry | Option |
service_statement | No | JSON structure | Service statement. It is used in membership rules for merchants. |
name | No | string (21) | The name of the membership statement field |
url | No | string (128) | Custom URL, starting with http:// or https://. |
bind_old_card | No | JSON structure | The URL to link an old member |
name | No | string (32) | Link name. |
url | No | string (128) | Custom URL, starting with http:// or https://. |
common_field_id_list supports the following options:
Field Value | Description |
---|---|
USER_FORM_INFO_FLAG_MOBILE | Mobile number |
USER_FORM_INFO_FLAG_SEX | Gender |
USER_FORM_INFO_FLAG_NAME | Name |
USER_FORM_INFO_FLAG_BIRTHDAY | Birthday |
USER_FORM_INFO_FLAG_IDCARD | ID card |
USER_FORM_INFO_FLAG_EMAIL | |
USER_FORM_INFO_FLAG_LOCATION | Address |
USER_FORM_INFO_FLAG_EDUCATION_BACKGRO | Education background |
USER_FORM_INFO_FLAG_INDUSTRY | Industry |
USER_FORM_INFO_FLAG_INCOME | Income |
USER_FORM_INFO_FLAG_HABIT | Hobbies |
Step 3: Receive a member information event notification
After a user enters and submits member information, an event is pushed to the merchant. After receiving the event notification, the developer can call the activation API to pass in information such as the member card number and initial loyalty points or call the member information pulling API to obtain the member information to manage the member card.
Example of pushing an XML data packet
<xml>
<ToUserName> < ![CDATA[gh_3fcea188bf78] ]></ToUserName>
<FromUserName>< ![CDATA[obLatjlaNQKb8FqOvt1M1x1lIBFE] ]></FromUserName>
<CreateTime>1432668700</CreateTime>
<MsgType>< ![CDATA[event] ]></MsgType>
<Event>< ![CDATA[submit_membercard_user_info] ]></Event>
<CardId>< ![CDATA[pbLatjtZ7v1BG_ZnTjbW85GYc_E8] ]></CardId>
<UserCardCode>< ![CDATA[018255396048] ]></UserCardCode>
</xml>
Parameters
Parameter | Description |
---|---|
ToUserName | Developer's Weixin ID |
FromUserName | Sender ID (OpenID) |
CreateTime | Creation time of message (integer) |
MsgType | Message type (event) |
CardId | Coupon ID |
UserCardCode | Coupon code |
Step 4: Synchronize member data
After receiving the event notification, the developer can call the activation API to pass in information such as the member card number and initial loyalty points or call the member information pulling API to obtain the member information. For details, see the "Activation Member Card" API.
Step 5: Call the member information pulling API
API Description
This API allows developers to query member information by CardID and code.
API Request Format
HTTP request method: POSTURL:https://api.weixin.qq.com/card/membercard/userinfo/get?access_token=TOKEN
Parameters
Parameter | Required | Description |
---|---|---|
POST data | Yes | JSON data |
access_token | Yes | Credential for calling the API |
POST Data
{
"card_id": "pbLatjtZ7v1BG_ZnTjbW85GYc_E8",
"code": "916679873278"
}
Response Data
{
"errcode": 0,
"errmsg": "ok",
"openid": "obLatjjwDolFj******wNqRXw",
"nickname": "*******",
"membership_number": "658*****445",
"bonus": 995,
"sex": "MALE",
"user_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": "postgraduate"
}
],
"custom_field_list": [
{
"name": "Hobbies",
"value": "Piano",
"value_list": []
},
{
"name": "Interests",
"value": "Guo Jingming",
"value_list": []
},
{
"name": "Occupation",
"value": "",
"value_list": [
"Racing driver",
"Traveler"
]
}
]
},
"user_card_status": "NORMAL",
"has_active": false
}
Parameter | Description |
---|---|
errcode | Error code. 0 indicates a successful request. |
errmsg | Error message |
openid | User's unique identifier in this Official Account |
nickname | User alias |
bonus | Loyalty points |
balance | Balance |
sex | User gender |
user_info | Member information |
custom_field_list | The list of member information items set by developer, such as Level. |
name | Member information item name |
value | Member information item value, such as Level. |
value_list | Response value for a multi-choice item |
user_card_status | Current status of member card. NORMAL: Normal; EXPIRE: Expired; GIFTING: Transferring to another user; GIFT_SUCC: Transferred successfully; GIFT_TIMEOUT: Transfer timed out; DELETE: Deleted; UNAVAILABLE: Unavailable. |
has_active | Specifies whether this member card is activated. true indicates that this member card is activated. false indicates that this member card is not activated. |
6.2.2 Redirect-based Quick Activation
Redirect-based quick activation allows merchants to redirect users to a merchant-defined web page after the users submit member information for activation. In redirect-based quick activation, member cards are activated by merchants. Merchants can provide logics for activation, activation bonuses, and activation condition determining on the destination web pages. This also ensures that member cards are activated in a timely manner. It is applicable to merchants who use custom member card numbers.
Step 1: Enter fields related to redirect-based quick activation in the creation or update API.
To redirect users to a merchant-defined web page after activation, merchants need to specify the following parameters for the creation or update API.
{
"card": {
"member_card": {
························
························
"wx_activate": true, "wx_activate_after_submit" : true,
//Specifies whether to enable redirect-based quick activation. "wx_activate_after_submit_url": "https://qq.com"
// The URL to which users are redirected after they submit information }
}
}
Parameter | Required | Type | Description |
---|---|---|---|
member_card | Yes | JSON structure | The structural body of the member card. |
wx_activate | No | bool | Specifies whether to enable quick activation. It can be set to true or false. |
wx_activate_after_submit | No | bool | Specifies whether to enable redirect-based quick activation. It can be set to true or false. |
wx_activate_after_submit_url | No | bool | The destination URL for redirect-based quick activation, starting with http:// or https://. |
Step 2. Set the card activation API
For details, see 6.2.1.
Step 3: Obtain the information submitted by users
After entering and submitting information for activation, users are redirected to a merchant-defined web page. The Merchant can obtain the user-entered information from the web page, check the activation qualification of the users, and confirm the information.
The specific operations are as follows:
After users submit information, Weixin appends the merchant's URL with user-entered information obtaining parameters such as activate_ticket, openid, and card_id and encrypts code-encrypt_code. For example, if the wx_activate_after_submit_url field specified by the merchant is www.qq.com, the obtained URL is www.qq.com&card_id=pbLatjvFdsLDUMoN8JqcsGeiMHKk&encrypt_code=Bupk8bb9xxxxxx3rdXV6fClBVtkHQplYohdzGvgDl4%3D&outer_str=&openid=obLatjjwDxxxxxxxoGIdwNqRXw&activate_ticket=fDZv9eMQAFfrNr3XBoqhb%2F%2BMSDM0yjDF6CdiUhC%2BOlEaxb0clsUxxxxxxxxxxxd6yQsjRMRu4kAcKTibYLN5tmHBdll1b6zQRsLF53MpKjGU%3D.
Developers can obtain the user-entered information from activate_ticket for logic determination on the developer's page.
API Description
This API allows developers to obtain user-entered information from activate_ticket.
API Request Format
HTTP request method: POSTURL:https://api.weixin.qq.com/card/membercard/activatetempinfo/get?access_token=TOKEN
Parameters
Parameter | Required | Description |
---|---|---|
POST data | Yes | JSON data |
access_token | Yes | Credential for calling the API |
POST Data
{
"activate_ticket" : "abcdefg"
}
Response Data
{
"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": "Postgraduate"
}
],
"custom_field_list": []
}
}
Notes:
1. When calling this API, developers need to use the AppID of the member card. Otherwise, an error occurs.
2. After obtaining the ticket from the URL, developers need to call urldecode.
Step 4: Activate the member card by calling the activation API
After receiving the event notification, the developer can call the activation API to pass in information such as the member card number and initial loyalty points or call the member information pulling API to obtain the member information. For details, see the "Activation Member Card" API.
# 6.3 Automatic Activation
API Description
To allow automatic activation of member cards, set auto_activate to "true" in base_info when creating a member card to obtain card_id. For details, see the "Create Member Card" API.
It should be noted that after auto_activate is specified, both quick activation settings and the activation URL specified in the API-based activation are not displayed. After users claim the member cards, the system automatically activates the member cards for the users, and information such as loyalty points and balance is displayed as "0". Developers can update member information by calling the "Update Member Information" API.
Parameters
Parameter | Required | Description |
---|---|---|
member_card | ||
auto_activate | No | It can be set to true or false. |
# 7 Updating Member Information
After a member paid with the member card, the developer can call this API to update the member's information. To facilitate subsequent notification and other extended features, the developer needs to notify Weixin of each information change after payment.
API Request Format
HTTP request method: POSTURL:https://api.weixin.qq.com/card/membercard/updateuser?access_token=TOKEN
Parameters
Parameter | Required | Description |
---|---|---|
access_token | Yes | Credential for calling the API |
POST data | Yes | JSON data |
{
"code": "179011264953",
"card_id": "p1Pj9jr90_SQRaVqYI239Ka1erkI",
"background_pic_url": "https://mmbiz.qlogo.cn/mmbiz/0?wx_fmt=jpeg",
"record_bonus": "Get 3 points for spending 30 CNY",
"bonus": 3000,
"add_bonus": 30,
"balance": 3000,
"add_balance": -30,
"record_balance": "Purchased a cup of caramel macchiato. Deducted 30 CNY.",
"custom_field_value1": "xxxxx",
"custom_field_value2": "xxxxx",
"notify_optional": {
"is_notify_bonus": true,
"is_notify_balance": true,
"is_notify_custom_field1":true
}
}
Parameters:
Parameter | Required | Type | Sample Value | Description |
---|---|---|---|---|
code | Yes | string (20) | 1231123 | Card code |
card_id | Yes | string (32) | p1Pj9jr90_SQ RaVqYI239Ka1erkI | Card ID |
background_pic_url | No | string (128) | https://mmbiz.qlogo.cn/ | The custom member card background allocated to a single member card when the merchant activates the member card |
bonus | No | int | 100 | The value of the loyalty points to be specified, which will be displayed directly. |
add_bonus | No | int | 100 | Added or deducted loyalty points. A negative value indicates that the loyalty points are deducted. |
record_bonus | No | string (42) | 3 points is added for spending 30 CNY | The merchant-defined loyalty points change record, with a maximum of 14 Chinese characters. |
balance | No | int | 100 | The value of the balance to be specified, which is displayed directly on the card. |
add_balance | No | int | 100 | Added or deducted balance. A negative value indicates that the balance is deducted. |
record_balance | No | string (42) | 30 CNY is deducted for purchasing a cup of caramel macchiato | The merchant-defined balance change record, with a maximum of 14 Chinese characters. |
custom_field_value1 | No | string (12) | Platinum | The updated value of custom_field1 when the card is created. It should not be longer than 12 bytes. |
custom_field_value2 | No | string (12) | 20% off | The updated value of custom_field2 when the card is created. It should not be longer than 12 bytes. |
custom_field_value3 | No | string (12) | 500 | The updated value of custom_field3 when the card is created. It should not be longer than 12 bytes. |
notify_optional | No | JSON | -- | Controls the structural body of a native message, including the message control field of each field. |
is_notify_bonus | No | bool | true | Specifies whether to trigger a system message template when the loyalty points change. It is true by default. |
is_notify_balance | No | bool | true | Specifies whether to trigger a system message template when the balance changes. It is true by default. |
is_notify_custom_field1 | No | bool | false | Specifies whether to trigger a system message template when the custom group 1 changes. It is false by default. The same rule applies to the custom group 2 and the custom group 3. |
Response Description
Example:
{
"errcode": 0,
"errmsg": "ok",
"result_bonus": 100,
"result_balance": 200,
"openid": "oFS7Fjl0WsZ9AMZqrI80nbIq8xrA"
}
Parameter | Description |
---|---|
errcode | Error code. 0 indicates a successful request. |
errmsg | Error message |
result_bonus | The total number of current loyalty points. |
result_balance | The total amount of the current balance. |
openid | The OpenID of the user. |
Notes
Developers can pass in both add_bonus and bonus to solve the idempotence issue caused by synchronization failure. When both add_bonus and bonus are passed in, add_bonus is a variable in loyalty points change messages, and bonus is the total loyalty points displayed on the card. The same rule applies to a balance change.
Developers can pass in is_notify_bonus to avoid sending a message for a special loyalty points change. The same rule applies to a special balance change.