(Connect)

# 8 Manage Membership Card

# 8.1 Pulling member information (points lookup) interface

Interface Dxplaination

Support developers to query membership information based on card_id and Code, including activation data, credit information, and balance information.

Dxplaination of Interface Call Request

HTTP request mode: POST URL: https://api.weixin.qq.com/card/membercard/userinfo/get?access_token=TOKEN

Parameter explaination

parameter Do I have to? Introductions
POST data yes JSON data
access_token yes Call Interface Credentials

POST data

{
   "card_id": "pbLatjtZ7v1BG_ZnTjbW85GYc_E8",
   "code": "916679873278" 
}

Parameter Name Is it compulsory? Introductions
cardid yes Check the cardid of your membership card
code yes The code value received by the query user

Return data

{
    "errcode": 0,
    "errmsg": "ok",
    "openid": "obLatjjwDolFjRRd3doGIdwNqRXw",
    "nickname": "Fourier",
    "membership_number": "316510891298",
    "bonus": 460,
    "sex": "MALE",
    "user_info": {
        "common_field_list": [
            {
                "name": "USER_FORM_INFO_FLAG_MOBILE",
                "value": "15521328888"
            },
            {
                "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 The categories of member card membership information set by the developer, such as levels.
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

# 8.2 Change the Member Card Information Interface

Interface Dxplaination

Supports changing member card surface information as well as card attribute information.

Dxplaination of Interface Call Request

HTTP request mode: POST URL: https://api.weixin.qq.com/card/update?access_token=TOKEN

Parameter explaination

parameter Do I have to? Introductions
POST data yes Json data
access_token yes Call Interface Credentials

POST data

{
    "card_id": "ph_gmt7cUVrlRk8swPwx7aDyF-pg",
    "member_card": {
        "background_pic_url": "https://mmbiz.qlogo.cn/mmbiz/0?wx_fmt=jpeg",
        "base_info": {
            "logo_url": "http:\/\/mmbiz.qpic.cn\/uploads\/allimg\/120216\/1_120216214725_1.jpg",
            "color": "Color010",
            "notice": "使用时向服务员出示此券",
            "service_phone": "020-88888888",
            "description": "不可与其他优惠同享\n如需团购券发票,请在消费时向商户提出\n店内均可使用,仅限堂食\n餐前不可打包,餐后未吃完,可打包\n本团购券不限人数,建议2人使用,超过建议人数须另收酱料费5元/位\n本单谢绝自带酒水饮料",
            "location_id_list": [
                123,
                12321,
                345345
            ]
        },
        "bonus_cleared": "aaaaaaaaaaaaaa",
        "bonus_rules": "aaaaaaaaaaaaaa",
        "prerogative": "",
        "auto_activate": true,
        //也可以填写wx_activate"activate_url":""
    }
}

Support for modifying fields:

Base_info field:

Parameter Name Is there a hearing? type Example values describe
title yes string(27) WeChat Membership Card Membership card title, maximum number of characters is 9 Chinese characters
logo_url no string(128) http://mmbiz .qpic.cn/ The merchant logo of the card coupon is recommended to be 300\ * 300 pixels.
notice no string(48) Please present a 2D code to cancel the card. Using reminders, the number of characters is limited to 16 Chinese characters.
description yes string(3072) You may not share his advantages with him. Use instructions.
service_phone no string(24) 40012234 Call customer service.
color no string(3072) Color010 The color of the voucher.
location_id_list no string(3072) 1234,2314 Support for updating the list of applicable stores.
use_all_locations no bool true Support all stores. After filling in the voucher store, it will be updated as the merchant store updates.
center_title no string(18) Use it now The name of the jump button in the middle of the member card, recommended for use
center_sub_title no string(24) Use when you arrive at the store The middle button of the card explains the wording
center_url no string(128) www.qq.com The middle button of the card corresponds to the url of the jump
custom_url_name no string(16) Use it now Customize the name of the jump entrance.
custom_url no string(128) www.qq.com Custom jump URL.
custom_url_sub_title no string(18) More surprises The prompt appears on the right side of the entrance.
promotion_url_name no string(16) Product description. Custom entry name for a marketing scene.
promotion_url no string(128) www.qq.com; Enter Jump to the address link of the external link.
promotion_url_sub_title no string(18) There's a big deal on sale. The prompt appears on the right side of the marketing entrance.
code_type no string(16) CODE_TYPE _TEXT。 Code code display type, "CODE_TYPE_TEXT" Text "CODE_Type_BARCODE" One-dimensional code "CODE_type_QRCODE" QR code "CODE"ONLY_QRCODE displays QR code only "CODE"TYPE_ONLY_BARCODE displayed one-dimensional code only "Code"TYPE_NONE" does not display any code type
pay_info no string(128) -- Payment function construction, swipe_card structure
swipe_card no string(128) -- Swipe function conformation, including is_swipe_card field
is_swipe_card no bool true WeChat WeChat
is_pay_and_qrcode no bool true Whether to set the button in the middle of the card to support both WeChat payment swipe card and card code
get_limit no int 1 Limit on the number of tickets per person
can_share no bool false Is the voucher native receipt page shareable?
can_give_friend no bool false Are coupons redeemable?
date_info no JSON structure See the above examples Use date, expiration information, expiration time modifications only support the expansion of the validity range
type no int 1 Valid type, only supports changing the timestamp of type 1, does not support filling in 2
begin_timestamp no unsigned int 14300000 A fixed date interval is dedicated to the start time. (in seconds)
end_timestamp no unsigned int 15300000 A fixed-date interval is dedicated to the end time. The end time only supports a later extension.

Changes to the membership card exclusive field:

Note in particular that the following update-enabled fields are not in the structure of base_info.

Parameter Name Is there a hearing? type describe
background_pic_url no string(128) Customized card background diagram for member cards
supply_bonus yes bool Whether to support integration, only support from false to true, the default is false
bonus_cleared no string(3072) Points zero rule.
bonus_rules no string(3072) Points rules.
bonus_url no string(128) The url of the jump to the points information category.
balance_url no string(128) The url of the balance information category jump
supply_balance yes bool Whether to support stored values, only support from false to true, default is false The field must be opened before using stored value function, see: Get special permissions
balance_rules no string(3072) Dxplaination of the storage value.
prerogative no string(3072) A explaination of the privileges.
wx_activate no bool Whether to open a key open card set to true, the card will support a key open card details see a key open card. This option is mutually exclusive with activate_url.
auto_activate no bool Whether to open automatic activation, set to true when the user to receive the card automatically set to activate, see automatic activation details.
activate_url no string(128) Activation link
custom_field1 no JSON structure Customize the member information category, which displays when the member card is activated.
custom_field2 no JSON structure Customize the member information category, which displays when the member card is activated.
custom_field3 no JSON structure Customize the member information category, which displays when the member card is activated.
name_type no string(24) Category name of member information. FIELD_NAME_TYPE_LEVEL LEVEL GRADE FIELD_NAME_TYPE COUPON COUPON FIELD_NAME_TYPE STAMP PRINTING FIELD_NAME_TYPE DISCOUNT DISCOUNT FIELD_NAME_TYPE ACHIEVEMEN ACHIEVEMENT FIELD_NAME_TYPE MILEAGE
url no string(128) Click on the category to jump outside the link url
custom_cell1 no JSON structure Customize the membership information category that displays when the membership card is activated
bonus_rule no JSON structure Integral rule conformation for WeChat billing function
cost_money_unit no int Amount of consumption divided into units
increase_bonus no int Based on the above consumption amount, the amount of points added corresponds to the above amount
max_increase_bonus no int Maximum number of points earned on a single occasion
init_increase_bonus no int Initial points received by users upon activation
cost_bonus_unit no int Each use of x integral.
reduce_money no int Deduct $xx (here divided into units)
least_money_to_use_bonus no int Credit conditions, full xx yuan (here divided into units) available
max_reduce_bonus no int Credit conditions, single maximum use of xx points
discount yes int Discounts, discount offers enjoyed by this membership card

Returning data instructions

Data examples:

{
   "errcode":0,
   "errmsg":"ok",
  "send_check"true
}

Parameter Name describe
errcode Error code, 0 is normal.
errmsg Error message.
send_check Whether this update requires arraignment, true is required, false is not required.

Note for developers

1. Changes to some of the voucher fields are re-submitted for review. See the field explaination for more details. When the update is successful, you can check the results of the update by calling the View voucher details interface;

2. Only fill in the fields that need to be updated. Many developers will fill in fields that do not support modification, such as brandname, when calling the interface, resulting in unsuccessful updates.

3. Once you have changed the card information after calling this interface, be sure to call* Home To verify that the change has been successful.*

# 8.3 Set up to follow recommendations

Features Description

Developers are able to configure a coupon or set a bounce outer link URL at the bottom of messages such as points, balance changes, and member card activation, in the form of a URL or a card coupon as shown below.

8.3.1 Setting to follow the recommended interface Interface explaination Developers can use this interface to set up member activation and to give coupons when a transaction occurs (a change in points, a change in balance). Interface details Interface Invocation Request Dxplaination > Http request method: POST URL: https://api.weixin.qq.com/card/update?access_token=TOKEN Parameter Dxplaination | Parameters | Is it necessary | Dxplaination | | --- | --- | --- | | access_token | Yes | Call Interface Credentials | | POST Data | Yes | Json Data |

Use Messages to Configure Coupons

{
    "card_id": "pbLatjkoa7luhR3zIBjtQiaYtnz4",
    "member_card": {
        "activate_msg_operation": {
   //若指定的是积分、余额等变动消息赠券,则为modify_msg_operation
            "url_cell": {
                "card_id_list": [
                    "pbLatjhcI6XUxJWA0Au3Gaq5eFPs"
                ],
                "end_time": 1492724561,
                "text": "恭喜你获得一张50元代金券",
                "url": "www.qq.com"
            }
        }
    }
}

Field Dxplaination

Field Name Required to fill in Introductions
card_id yes Voucher ID.
member_card yes Member card structures, such as examples
modify_msg_operation no Type of recommendation, representing changes in points balance, etc. Coupons
activate_msg_operation no Type of recommendation, representing member card activation message voucher
url_cell no Recommend content structures such as examples
card_id_list yes Send the card_id list of coupons, do not support the use of ordinary coupons and friends' coupons mixed, up to 10 card_id
end_time no Deadline for display of recommendations
text no Text content
url no Jump link, and card_id_list mutually exclusive, if set the jump url, the user click on the template message details will jump to the link to get the coupon
app_brand_id no Jump link corresponding to Weixin Mini Program AppID, and card_id_list mutually exclusive, if set, the user will click on the template message details after the jump to the Mini Program to get coupons
app_brand_pass no Jump link corresponding to the Weixin Mini Program path, and card_id_list mutually exclusive, if set, the user click on the template message details will jump to the Mini Program to get coupons

Return data

{
   "errcode":0,
   "errmsg":"ok"
}

Field Dxplaination

Field Name Introductions
Error code Error code, 0 is normal;WeChat Payment authority is not opened for merchants.
errmsg Error message

Developers' Note

  1. Supports one member card to set points / balance change message coupons and activate coupons at the same time. Developers must set them separately;

  2. If the developer fills in the card_id_list, and then fills in the url field, the card_id_list content will be invalid;

  3. If the developer sets a URL, it must support receiving coupons on the URL, otherwise it will be regarded as a malicious marketing penalty.

# 8.4 Set up to place coupons after payment

8.4.1 Set up an interface for placing coupons after payment

Merchants who open WeChat to pay can set up in the user Weixin Pay automatically send a request for the user's card message, the user can click on the message to receive a membership card / coupon.

At present, this function only supports the configuration of the main body of the payment merchant number and the production of the membership card, otherwise the error is reported. Developers can log in

"Public platform" - "Service Account settings" , "WeChat Payment Merchant Platform Home" Whether the information of enterprise subject is consistent.

Interface explaination Supports merchants to set rules for placing coupons after payment, and can differentiate between time periods and amount bands to issue membership cards. Interface Invocation Request Dxplaination > HTTP request mode: POST URL: https://api.weixin.qq.com/card/paygiftcard/add?access_token=TOKEN Parameter Dxplaination | Parameters | Is it necessary | Dxplaination | | --- | --- | --- | | POST Data | Yes | Json Data | | access_token | Yes | Call Interface Credentials |

Set up POST data when paying that is a member

{
    "rule_info": {
        "type": "RULE_TYPE_PAY_MEMBER_CARD",
        "base_info": {
            "mchid_list": [
                            "123",
                            "456"
            ],
            "begin_time": 1480317217,
            "end_time": 1580317217
        },
        "member_rule": {
            "card_id": "abcdefg",
            "least_cost": 2,
            "max_cost": 20000,
            "jump_url": "www.qq.com"
        }
         }
  }

Field Dxplaination

Field Name Is it compulsory? Introductions
rule_info yes Post-payment marketing rule structure

Rule_info is a JSON structure that contains the following fields

Field Name Is it compulsory? Introductions
type yes Marketing Rule Type, Pay That Member Fill RULE_TYPE_PAY_MEMBER_CARD
base_info yes Marketing Rule Structure
member_rule no Payments are the membership structure

Base_info is a JSON structure that contains the following fields

Field Name Is it compulsory? Introductions
mchid_list yes A list of merchant numbers is an array structure that suggests words Request 100 fewer merchant codes
begin_time yes Rules Start Time
end_time yes Rules End Time

Member_rule is a JSON structure that is currently set to be filled in when you pay as a member and contains the following fields

Field Name Is it compulsory? Introductions
card_id yes Membership card to be presented card_id
least_cost yes The lower limit of the amount sent to a member card on a single consumption, divided into units
max_cost yes The maximum amount of a single consumption to send a member card is divided into units
jump_url no Merchant customize a link to the card web page, fill it in and click on payment when the member message will jump to the card page of the Merchant
app_brand_id no Merchant custom collar Weixin Mini Program AppID, fill in and click on the payment will be the member message will jump to the merchant Mini Program collar
app_brand_pass no Merchant custom collar Weixin Mini Program path, fill in and click on the payment that will be members of the message will jump to the merchant Mini Program collar

Returning data instructions

Data examples:

  {
    "errcode": 0,
    "errmsg": "ok",
    "rule_id": 1231243,
    "fail_mchid_list": [
        {
            "mchid": "111",
            "errcode": 23112,
            "errmsg": "err",
            "occupy_rule_id": 12332123,
            "occupy_appid": "appid"
        }
    ]
    "succ_mchid_list": [
        "123",
        "456"
    ]
}

Parameter Name describe
errcode Error code, 0 is normal.
errmsg Error message.
rule_id The set of the rule id, for subsequent changes to delete the use
succ_list Set up a successful mchid list
fail_list Set up failed mchid list
mchid The merchant number of the payment
occupy_appid The mchid is currently occupied AppID, the merchant must use the appid to unbind and reset
occupy_rule_id The rule_id currently occupied by the mchid, the merchant must reset the rule_id by modifying or deleting the rule_id

Developers' Note

  1. Membership card receipt messages are sent only once to a new user and are not repeated if the user has received or has received a membership card ;

  2. The ticket AppID primary of the card_id set by this rule must be consistent with the Primary of current mch_id, otherwise error 72001;

Developers can log into "Public Platform" - Service Account Settings , “WeChat Payment Merchant Platform Home” Whether the main information of the enterprise is consistent;

  1. Only coupons of the member card type are supported, otherwise the error is reported: 72003;

4.Set up payment that is, members must confirm the call interface of the AppID must be business card printing appid , otherwise error: 72002;

5.Must ensure that mchid has not been set by other AppID before, otherwise the error is reported 72004, must delete the payment is called after the member rule;

  1. A single set of only 10 mchid, if more than 10 please call this interface multiple times.

Q&A

Q: I already have a business number and Service Account, how do I know if the body of both is the same?

A: In the "public platform" - "Service Account settings," "WeChat payment merchant platform home page" to check whether the enterprise main information is consistent.

**Q: We are the relationship between the group and the subsidiary, and hope to issue the group's Service Account membership card after payment under the subsidiary's merchant number.However, using the AppID of the subsidiary as the mchid configuration rules of the subsidiary, and setting the card_id of the group company reported an error 72002, what can I do?**

A: In this case, you can log on to the WeChat open platformhttps://open.weixin.qq.com/ ] binds the Service Account of all subsidiaries under the Third Party Platform account of the head office, and when the binding is completed, it can implement the configuration of intergroup card issuers and recognize each other's membership (UnionID mechanism).

Q: We are the relationship between the group and the subsidiary, and hope to issue the group's Service Account membership card after payment under the subsidiary's merchant number.But with the group's AppID for the sub-merchant mchid configuration rules, set the group's card_id wrong 72001, how to do?

A: The solution is as above

8.4.2 Remove the rule interface for placing coupons after payment

Remove payment-as-a-membership rules that were previously set up.

Interface Dxplaination

Enable the merchant to delete the previously set rule id

Dxplaination of Interface Call Request

HTTP request mode: POST URL: https://api.weixin.qq.com/card/paygiftcard/delete?access_token=TOKEN

Parameter explaination

parameter Do I have to? Introductions
POST data yes JSON data
access_token yes Call Interface Credentials

POST data

{    "rule_id": 1233}

Field Dxplaination

Field Name Introductions
rule_id Payments are the rule name of membership

Returning data instructions

Data examples:

{
    "errcode": 0,
    "errmsg": "ok"
}

Parameter Name describe
errcode Error code, 0 is normal.
errmsg Error message.

8.4.3 Find out the details of the rules for placing coupons after payment

Interface Dxplaination

You can query the content of a payment or membership rule.

Dxplaination of Interface Call Request

HTTP request mode: POST URL: https://api.weixin.qq.com/card/paygiftcard/getbyid?access_token=TOKEN

Parameter explaination

parameter Do I have to? Introductions
POST data yes Json data
access_token yes Call Interface Credentials

POST data

{    "rule_id": 11233}

Field Dxplaination

Field Name Introductions
rule_id To query the rule id

Returning data instructions

Data examples:

{
    "errcode": 0,
    "errmsg": "ok",
    "rule_info": {
        "type": "RULE_TYPE_PAY_MEMBER_CARD",
        "base_info": {
            "mchid_list": [
                "123",
                "456"
            ],
            "begin_time": 1480317217,
            "end_time": 1580317217,
            "status": "RULE_STATUS_OK",
            "create_time": 1480317217,
            "update_time": 1480317217
        },
        "member_rule": {
            "card_id": "abcdefg",
            "least_cost": 2,
            "max_cost": 20000,
            "jump_url": "www.qq.com"
        }
    }
}

8.4.3 Batch inquiry rules for placing coupons after payment interface

Interface Dxplaination

You can query in bulk the content of a merchant's payment-as-a-member rule

Dxplaination of Interface Call Request

HTTP request mode: POST URL: https://api.weixin.qq.com/card/paygiftcard/batchget?access_token=TOKEN

Parameter explaination

parameter Do I have to? Introductions
POST data yes Json data
access_token yes Call Interface Credentials

POST data

{
    "type": "RULE_TYPE_PAY_MEMBER_CARD",
    "effective": true,
    "offset": 0,
    "count" : 1
}

Field Dxplaination

Field Name Introductions
type Type, fill in RULE_TYPE_PAY_MEMBER_CARD here
effective Do you only ask about the rules that are in effect?
offset Initial variation amount
count Number of queries

Returning data instructions

Data examples:

{
    "errcode": 0,
    "errmsg": "ok",
    "total_count": 4,
    "rule_list": [
        {
            "type": "RULE_TYPE_PAY_MEMBER_CARD",
            "base_info": {
                "mchid_list": [
                    "123",
                    "456"
                    ],
                "begin_time": 1480317217,
                "end_time": 1580317217,
                "status": "RULE_STATUS_OK",
                "create_time": 1480317217,
                "update_time": 1480317217
            },
            "member_rule": {
                "card_id": "abcdefg",
                "least_cost": 2,
                "max_cost": 20000,
                "jump_url": "www.qq.com"
            }
        }
    ]
}

NOTE:

1. The above is the new payment-as-a-member interface protocol, and the old interface can still be called. See the old protocol:

** https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&key=1481363811&version=1&lang=zh_CN&platform=2 **

# 8.5 WeChat Payment Card Support

Membership cards that support swipe types are created through the interface, and users can pull out the swipe interface to pay after clicking on a quick purchase. Here is a diagram:

8.5.1 Create Membership Card Support WeChat Merchants can create a membership card that supports WeChat payment by adding the following fields to the JSON that creates the membership card interface:

{
     "card": {
         "card_type": "MEMBER_CARD",
         "member_card": {
             "base_info": {
                 "pay_info":
                 {
                         "swipe_card":
                         {
                           "is_swipe_card":true
                      }
                    }
             }
         }
     } 
}

For details, see: Create a membership card

8.5.2 Update membership card support WeChat

Merchants can update their existing membership card support WeChat by adding the following fields to the JSON update membership card interface:

{
    "card_id": "ph_gmt7cUVrlRk8swPwx7aDyF-pg",
    "member_card": {
             "base_info": {
                 "pay_info":
                 {
                         "swipe_card":
                         {
                             "is_swipe_card":true
                     }
                   }
              }
     } 
}

For more details, please see: Manage Membership Card

Developers' Note

1.Before setting this function, please confirm whether you have opened WeChat payment, otherwise the interface will report error ( open Weixin Pay )

2.When the user makes payment, the user can query the OPENID interface https://pay.weixin.qq.com/doc/v2/merchant/4011940944 to obtain the user's openid.

Then call the user to get the card coupon interface http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025272&token=&lang=zh_CN to get the openid membership, and the corresponding price.

3.Only WeChat 6.3.18 and above version supports Member card pull out credit card payment, lower than 6.3.18 version will prompt users to upgrade.

# 8.6 Other Interfaces

8.6.1 Modify the inventory interface

Call the Modify Inventory interface to increase or decrease the inventory of a card coupon, see: Manage Card Coupons

8.6.2 Query code interface

Developers can query the basic information of the membership card through the interface, including the recipient's OpenID, membership card status, see:

8.6.3 Get vouchers that the user has received

Support the developer to call the interface to obtain a specified user card package belonging to the AppID under the card voucher, see: Manage Card Voucher

8.6.4 View voucher details

Calling this interface queries the details of the fields that card_id is creating and the audit status of the card voucher.See: Manage Card Vouchers

8.6.5 Bulk query card list

Developers can pull through the interface of the current merchant (AppID) under all the card voucher list, for card voucher management, details see:

8.6.6 Delete membership card

Developers can delete the card_id of the merchant list through this interface, for card voucher management, see:

8.6.7 Set up membership card expiration interface

Developers can through the interface to a user of a card coupon set as invalid, for refunds and other scenarios, see:

# 9 Statistical membership card data

Developers can pull through the interface card data, see:

# 10 I am a third party

A third party can be for access to the merchant generation Membership Card, details refer to: