catalog
3 Place coupons through the card shelves
4 Group distribution of coupons
4.2 Graphic message to group out coupons
4.3 Send voucher messages according to group sizes
4.4 Group Card Voucher Message Based on OpenID List
4.5 Customer Service message to issue coupons
5 Distribution channel data statistics
# 1 Create QR code interface
Developers can call this interface to generate a QR code for a voucher to be added to the wallet after the user scans it.
Custom Code code card coupon call interface, POST data need to specify code, non-custom code do not need to specify, specify openid same. The specified QR code can only be scanned and collected once by the user.
After obtaining the ticket, the developer can exchange for the image details .
Dxplaination of Interface Call Request
HTTP request mode: POST URL: https://api.weixin.qq.com/card/qrcode/create?access_token=TOKEN
Parameter explaination
parameter | Do I have to? | Introductions |
---|---|---|
POST data | yes | JSON data |
access_token | yes | Call Interface Credentials |
POST data
Developers can set up scanning two-dimensional code to receive a single card coupon, at this time the POST data is:
{
"action_name": "QR_CARD",
"expire_seconds": 1800,
"action_info": {
"card": {
"card_id": "pFS7Fjg8kV1IdDz01r4SQwMkuCKc",
"code": "198374613512",
"openid": "oFS7Fjl0WsZ9AMZqrI80nbIq8xrA",
"is_unique_code": false ,
"outer_str":"12b"
}
}
}
When the developer sets up scanning the two-dimensional code to receive multiple card coupons, the POST data at this time is:
{
"action_name": "QR_MULTIPLE_CARD",
"action_info": {
"multiple_card": {
"card_list": [
{
"card_id": "p1Pj9jgj3BcomSgtuW8B1wl-wo88",
"code":"2392583481",
"outer_str":"12b"
},
{
"card_id": "p1Pj9jgj3BcomSgtuW8B1wl-wo98",
"code":"2392583482",
"outer_str":"12b"
}
]
}
}
}
Parameter explaination
Parameter Name | Required to fill in | type | Example values | describe |
---|---|---|---|---|
code | no | string(20) | 110201201245 | Code code, use_custom_code field is true card coupons must be filled in, non-custom code and import code mode card coupons do not need to fill in. |
card_id | no | string(32) | pFS7Fjg8kV1IdD z01r4SQwMkuCKc | Voucher ID. |
openid | no | string(32) | oXch-jkrxp42VQu8ld weCwDt97qo | Specifies the recipient's openid, which only the user can collect. Vouchers whose bind_openid field is true must be filled in, not specified openid. |
expire_seconds | no | unsigned int | 60 | Specify the validity time of the QR code, which ranges from 60 to 1800 seconds. Without a placeholder, it is considered valid for 365 days |
is_unique_code | no | bool | false | Specify the issue of two-dimensional code, generated two-dimensional code randomly assigned a code, after receiving can not be scanned again. Fill in true or false. Default false, pay attention to fill in the field, the card voucher must pass the audit and inventory is not 0. |
outer_id | no | int | 12 | Collection scenario value, used for data statistics for collection channels. The default value is 0, the field type is integer, and the length limit is 60 digits. This custom scene value is included in the event push triggered after the user collects the voucher. |
outer_str | no | string(128) | 13b | Upgrade version of outer_id field, character string type, the user will receive the card for the first time, through the event pushed to the merchant; For the card's two-dimensional code, each time the user opens the card and clicks on any URL, the value will be spelled into the URL, so that developers can locate the source of the code |
Return Parameters
{
"errcode": 0,
"errmsg": "ok",
"ticket": "gQHB8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL0JIV3lhX3psZmlvSDZmWGVMMTZvAAIEsNnKVQMEIAMAAA==", //获取ticket后需调用换取二维码接口获取二维码图片,详情见字段说明。
"expire_seconds": 1800,
"url": "http://weixin.qq.com/q/BHWya_zlfioH6fXeL16o ",
"show_qrcode_url": " https://mp.weixin.qq.com/cgi-bin/showqrcode? ticket=gQH98DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL0czVzRlSWpsamlyM2plWTNKVktvAAIE6SfgVQMEgDPhAQ%3D%3D"
}
Parameter explaination
Parameter Name | describe |
---|---|
errcode | Error code |
errmsg | Error message |
ticket | The binary code ticket obtained, with this ticket call through the ticket for the binary code interface can be exchanged in the valid time. |
url | After the QR code image is resolved, the developer can generate the required QR code image according to that address |
show_qrcode_url | The QR code shows the address. Click to jump to the QR code page |
Notes:
1.Custom code of the card voucher, the generated code can only be received once a time, if the developer wants to use their own string code system and want to use WeChat
Delivery, must first import custom code;
- Receive a number of two-dimensional code at a time to fill in a maximum of 5 card_id, otherwise the error.
# 2 HTML5 Online voucher (JS-SDK interface)
WeChat JS-SDK only supports use in WeChat built-in browsers, other browser calls are invalid.
WeChat Provides an addCard interface that can be invoked by a merchant's front-end web page to add one or more card coupons to a user's card pack.For more information, see JS-SDK Dxplaination Document
# 3 Place coupons through the card shelves
Summary of the Coupon Shelf
The card coupon shelf supports the developer to generate a card coupon H5 page through the calling interface, and obtain the page link to carry out the card coupon delivery action. At present, the card coupon shelf only supports non-custom code of the card coupon, custom code of the card coupon need to call the import code interface to import the code to normal use.
# 3.1 Create shelf interface
Interface Dxplaination
Developers need to call this interface to create a shelf link for coupons to be delivered. When creating a shelf, you need to fill in the scene field for the route to be placed.
Dxplaination of Interface Call Request
HTTP request method: POST URL:https://api.weixin.qq.com/card/landingpage/create?access_token=$TOKEN
Dxplaination of request parameters
parameter | Do I have to? | Introductions |
---|---|---|
access_token | yes | Call Interface Credentials |
buffer | yes | File data flow |
POST data
{
"banner":"http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7h
icFN",
"page_title": "惠城优惠大派送",
"can_share": true,
"scene": "SCENE_NEAR_BY",
"card_list": [
{
"card_id": "pXch-jnOlGtbuWwIO2NDftZeynRE",
"thumb_url": "www.qq.com/a.jpg"
},
{
"card_id": "pXch-jnAN-ZBoRbiwgqBZ1RV60fI", "thumb_url": "www.qq.com/b.jpg" }
]}
Parameter explaination
field | Introductions | Is it compulsory? |
---|---|---|
banner | Page banner image link, must call, the recommended size is 640\ * 300. | yes |
title | Title of the page. | yes |
can_share | Whether the page can be shared, fill in true / false | yes |
scene | The scenario value of the projected page;SCENE_NEAR_BY NEAR SCENE_MENU CUSTOM MENU SCENE_QRCODE SCENE_ARTICLE Service Account ARTICLE SCENE_H5 h5 page SCENE_IVR CUSTOM_SCENE_CARD_CUSTOM_CELL CARD COUPON CUSTOM CELL | yes |
card_list | Card voucher list, each item has two fields | yes |
card_id | The card_id to be placed on the page | yes |
thumb_url | Thumbnail url | yes |
Returning data instructions
{
"errcode":0,
"errmsg":"ok",
"url":"www.test.url",
"page_id":1
}
Field Dxplaination
field | Introductions |
---|---|
errcode | Error code, 0 is normal. |
errmsg | Error message. |
url | The shelf link. |
page_id | Shelf ID. The sole identification of the shelves. |
# 4 Group distribution of coupons
Please pay special attention to the developers, the current group card voucher interface only supports the delivery of non-custom Code card vouchers.Custom code merchants who want to use this function need to call the import code interface to import custom code into the WeChat server.
The difference between custom code and non-custom code is See Whether to Custom Code.
# 4.1 Import custom code (for custom code merchants only)
Introduction to the interface
This module is only for custom code merchants, non-custom code developers please automatically ignore.Developers can import custom code ahead of time to the WeChat server to get the same delivery capabilities as non-custom code merchants, such as group distribution, coupons under customer service messages, and so on.
The card voucher after importing the code is equivalent to the non-custom code card voucher at the time of delivery.
Newly created coupons
If a developer intends to create a new code-importable voucher in a different way than previously, we recommend that developers use the following process to create their pre-existing code-import vouchers, otherwise they will report an error.
- Step 1: Create card voucher pre-store mode card voucher, set the initial value of inventory quantity to 0, enter the get_custom_code_mode field;*
Step 2: After the voucher has passed the audit, call to import the code interface and to verify the code .
Step 3: Call to manage the voucher , and make the voucher inventory less than or equal to the number of imported codes.(To avoid confusion, it is recommended to set equal)
Non-New Creation Card Voucher If a developer already has a voucher and wants to change it to stored code mode, it is recommended that the developer update the voucher according to the following process.
- Step 1: Call to import the code interface to import a certain amount of custom code and to verify the code * Step 2: Call to manage the voucher Fill in the get_custom_code_mode field;* Step 3: Call to modify the inventory interface Set the voucher inventory quantity to a number equal to the number of imported codes.
4.1.1 Fill in / update required fields for import code Interface explaination Customized code's coupons support API creation only. When creating, be sure to include the following fields in base_info (see the interface documentation CreateCard to create a voucher interface for details). Add the following two specified fields before you can call the code import interface for code import
Fields | Examples | Instructions |
---|---|---|
base_info | ||
Get_custom_code_mode | GET_CUSTOM_CODE_MODE_DEPOSIT | After filling in this field, custom code vouchers can import code and put in the action. |
Use_custom_code | true | Set card voucher to custom code |
JSON Sample When Creating Card Vouchers
{
"card": {
"card_type": "GROUPON",
"groupon": {
"base_info": {
··········
"use_custom_code":true,
"get_custom_code_mode":"GET_CUSTOM_CODE_MODE_DEPOSIT",
},
"advanced_info": {
··········
},
"deal_detail": "示例"
}
}
}
JSON Example When Updating Card Voucher
{
"card_id":"ph_gmt7cUVrlRk8swPwx7aDyF-pg",
"groupon": {
"base_info": {
·········
"get_custom_code_mode":"GET_CUSTOM_CODE_MODE_DEPOSIT",
·········
}
}
}
NOTE:
Create / update fill in get_custom_code_mode, must check the relationship between the number of inventory and the number of imported code, when the number of imported code is less than the number of inventory, an error will be reported.
4.1.2 Import code interface
After the custom code card voucher is successfully created and approved, the custom code must be imported into the WeChat background by calling the import code interface according to the agreed number with the issuer.
Interface Dxplaination
Developers can call the interface to import custom code into the WeChat card voucher background, by WeChat side agent to store and send the code.
Note: 1) The maximum number of incoming code for a single call to the interface is 100.
2) Each code cannot be an empty string.
3) After the import, the system will automatically determine whether the inventory set by the provider is consistent with the actual amount of imported code.
4) Import failure Supports repeat imports, prompting success.
Dxplaination of Interface Call Request
HTTP request mode: POST URL: http://api.weixin.qq.com/card/code/deposit?access_token=ACCESS_TOKEN
Dxplaination of request parameters
parameter | Do I have to? | Introductions |
---|---|---|
access_token | yes | Call Interface Credentials |
buffer | yes | File data flow |
POST data
{
"card_id": "pDF3iY0_dVjb_Pua96MMewA96qvA",
"code": [
"11111",
"22222",
"33333",
"44444",
"55555"
]
}
Field Dxplaination
field | Introductions | Is it compulsory? |
---|---|---|
card_id | The voucher ID that needs to import code. | yes |
code | Need to import WeChat card voucher background custom code, the upper limit is 100. | yes |
Returning data instructions
{
"errcode":0,
"errmsg":"ok"
}
Field Dxplaination
field | Introductions |
---|---|
errcode | Error code, 0 is normal; 40109: More than 100 codes |
errmsg | Error message. |
succ_code | Number of Successes |
duplicate_code | Duplicate imported code is automatically filtered. |
fail_code | Number of failures. |
4. 1. 3 Query import code number interface
Interface Dxplaination
Support developers to call this interface to query the number of code import WeChat background success.
Dxplaination of Interface Call Request
HTTP request mode: POST URL: http://api.weixin.qq.com/card/code/getdepositcount?access_token=ACCESS_TOKEN
Dxplaination of request parameters
parameter | Do I have to? | Introductions |
---|---|---|
access_token | yes | Call Interface Credentials |
POST data
{
"card_id" : " pDF3iY0_dVjb_Pua96MMewA96qvA "
}
Field Dxplaination
field | Introductions | Is it compulsory? |
---|---|---|
card_id | The voucher ID for the import code. | yes |
Returning data instructions
{
"errcode":0,
"errmsg":"ok",
"count":123
}
Field Dxplaination
field | Introductions |
---|---|
errcode | Error code, 0 is normal. |
errmsg | Error message. |
count | The number of codes that have been successfully deposited. |
4.1.4 Verify the code interface
In order to avoid import errors, it is strongly recommended that developers check the code interface to verify the background of the code import WeChat when querying the number of code.
Interface Dxplaination
Support for developers to call this interface to query the background of code import WeChat.
Dxplaination of Interface Call Request
HTTP request mode: POST URL: http://api.weixin.qq.com/card/code/checkcode?access_token=ACCESS_TOKEN
Dxplaination of request parameters
parameter | Do I have to? | Introductions |
---|---|---|
access_token | yes | Call Interface Credentials |
POST data
{
"card_id": "pDF3iY0_dVjb_Pua96MMewA96qvA",
"code": [
"11111",
"22222",
"33333",
"44444",
"55555"
]
}
Field Dxplaination
field | Introductions | Is it compulsory? |
---|---|---|
card_id | The voucher ID for the import code. | yes |
code | Already WeChat card voucher background custom code, the upper limit is 100. | yes |
Returning data instructions
{
"errcode":0,
"errmsg":"ok"
"exist_code":["11111","22222","33333"],
"not_exist_code":["44444","55555"]
}
Field Dxplaination
field | Introductions |
---|---|
errcode | Error code, 0 is normal; 40109: More than 100 codes |
errmsg | Error message. |
exist_code | The code has been successfully deposited. |
not_exist_code | No code is stored. |
# 4.2 Graphic message to group out coupons
Supports developers to call this interface to obtain standard format code for barcode embedding graphic messages, and to populate the return code Add temporary material in the content field, you can get embedded card coupons graphic message material.
Special note: At present, the interface only supports the card voucher filled with non-custom code, and the card voucher with custom code needs to be called after code import.
Dxplaination of Interface Call Request
HTTP request mode: POST URL: https://api.weixin.qq.com/card/mpnews/gethtml?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":"p1Pj9jr90_SQRaVqYI239Ka1erkI"}
Parameter Name | Required to fill in | type | Example values | describe |
---|---|---|---|---|
card_id | no | string(32) | pFS7Fjg8kV1IdDz01r4SQwMkuCKc | Voucher ID. |
Return data
{
"errcode":0,
"errmsg":"ok",
"content":"<iframeclass=\"res_iframecard_iframejs_editor_card\"data-src=\"http: \/\/mp.weixin.qq.com\/bizmall\/appmsgcard?action=show&biz=MjM5OTAwODk4MA%3D%3D&cardid=p1Pj9jnXTLf2nF7lccYScFUYqJ0&wechat_card_js=1#wechat_redirect\">"
}
Parameter Name | describe |
---|---|
errcode | Error code |
errmsg | Error message |
content | Returns a piece of HTML code that can be embedded directly into the body of a graphic message. You can embed this code in the content field of the upload graphic message material interface. |
# 4.3 Send voucher messages according to group sizes
Supports calling this interface to send voucher messages to a specified group of users.See homepage for details
At present, the interface only supports the card voucher filled with non-custom code, and the card voucher with custom code needs to be imported before calling.
# 4.4 Group Card Voucher Message Based on OpenID List
Support for sending native card vouchers based on OpenID.Subscription number is not available, Service Account has interface permissions after authentication.See for more details on the group interface according to the OpenID list
At present, the interface only supports the card voucher filled with non-custom code, and the card voucher with custom code needs to be imported before calling.
# 4.5 Customer Service message to issue coupons
Developers are able to call this interface to issue coupons.Subscription number is not available, Service Account is available after authentication.See Customer Service Message
At present, the interface only supports the card voucher filled with non-custom code, and the card voucher with custom code needs to be imported before calling.
# 4.6 Preview Interface
Developers are able to call this interface to issue coupons.Subscription number is not available, Service Account is available after authentication.For more information, see
# 5 Distribution channel data statistics
In order to facilitate the development of statistical channels of the card voucher data, the new field outer_str (the original outer_id).Fill the different set outer_str (original outer_id) into the card_ext JSON structure, and when the user collects a card, the corresponding set outer-id is brought into the card event push to the developer server.
Example: Set outer_str to 12 b in a binary code delivery mode
{
"action_name": "QR_CARD",
"action_info": {
"card": {
"card_id": "pFS7Fjg8kV1IdDz01r4SQwMkuCKc",
"code": "198374613512",
"openid": "oFS7Fjl0WsZ9AMZqrI80nbIq8xrA",
"expire_seconds": "1800",
"is_unique_code": false ,
"outer_str" : "12b"
}
}
}
Pick up 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>
<OuterStr>12b</OuterStr>
</xml>
# 6 Set a test whitelist
Interface Dxplaination
Because the card voucher has audit requirements, in order to facilitate Service Account debugging, you can set up some test accounts, these accounts can receive the card voucher that has not passed the audit, and experience the whole process.
Developers' Note
1. At the same time, it supports "openid" and "username" two fields to set a white list, and the total number is capped at 10.
2. Set the test white list interface to the full set, that is, when the test list changes, it is necessary to call the interface to re-pass the ID of all the testers.
3. The expiration status of the voucher will be ignored when a white-list user collects the voucher, so please note to the developer.
Dxplaination of Interface Call Request
HTTP request mode: POST URL: https://api.weixin.qq.com/card/testwhitelist/set?access_token=TOKEN
Parameter explaination
parameter | Do I have to? | Introductions |
---|---|---|
access_token | yes | Call Interface Credentials |
POST data | yes | Json data |
POST data
{
"openid": [
"o1Pj9jmZvwSyyyyyyBa4aULW2mA",
"o1Pj9jmZvxxxxxxxxxULW2mA"
],
"username": [
"afdvvf",
"abcd"
]
}
Parameter explaination
Parameter Name | Required to fill in | type | Example values | describe |
---|---|---|---|---|
openid | no | string(20) | o1Pj9jmZvwSyyyyyyBa4aULW2mA | The openid list for the test. |
username | no | string(32) | eddy | List of WeChat numbers for the test. |
Return instructions
{ "errcode":0, "errmsg":"ok"}
Parameter Name | describe |
---|---|
errcode | Error code, 0 is normal. |
errmsg | Error message. |