catalog

1 What to Know

2 Apply for a sandbox test account

3 Card Vouchers HelloWorld

4 Overview of the voucher interface

5 Introduction to Coupon Terminology

6 Developer Notes

6.1 WeChat Version determination

6.2 Card issuance limits

6.3 Code rules

6.4 Jump to External Chain Parameters Dxplaination

6.5 Contact Us

7 Coupon Bundle Download

# 1 Be aware

To read the interface documentation of the card coupon part, please be sure to read the WeChat public platform developer general instructions document < Must Read Before You Start > and Start Development are two chapters to learn the basic invocation methods of the WeChat Official Platform interface, developer specifications, and handling of exceptions during invocation.

# 2 Apply for a sandbox test account

If you do not have a test account available, you can request a temporary test number for the test through the WeChat interface test number application tool.You can login interface test number application through WeChat scan to get a brand newAppID (Already has voucher creation permissions, including friend vouchers and membership cards) and appsecret are used for voucher interface calls.

Note: The AppID created vouchers will not be approved, only whitelisted users can receive, for small-scale testing, developers can not be used for other purposes.

# 3 Card Vouchers HelloWorld

Developers can quickly complete the process of creating coupons, placing coupons and cancelling coupons through the debug tool. To get a deeper understanding of the coupons interface, you need to read the relevant documentation in detail.

Step 1 Get access_token

Page address: http://mp.weixin.qq.com/debug/

Interface Type: Basic Support

Interface list: Get the access_token interface

Note: The parameter is filled with the developer's AppID and secret

Click to check the question, you can return access_token, access_token is valid for two hours, after two hours must be re-acquired

Interface address: Get the Access token

Step 2: Upload the card coupon logo

Page address: http://mp.weixin.qq.com/debug/

Interface Type: Basic Support

List of Interfaces: Upload Image Material Interface

access_token: access_token obtained in the previous step

Buffer: The picture you choose

Click to check the problem, you can get the picture url, in the next step to create the parameters of the card need

Interface address: Create Card Voucher

Step 3 Create a voucher

Page address: http://mp.weixin.qq.com/debug/

Interface Type: Card Interface

List of Interfaces: Create a Card Interface

access_token: access_token

JSON example:

{ "card": {
  "card_type": "GROUPON",
  "groupon": {
      "base_info": {
          "logo_url": "http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7hicFNjakmx ibMLGWpXrEXB33367o7zHN0CwngnQY7zb7g/0",
          "brand_name":"微信餐厅",
          "code_type":"CODE_TYPE_TEXT",
          "title": "132元双人火锅套餐",
          "sub_title": "周末狂欢必备",
          "color": "Color010",
          "notice": "使用时向服务员出示此券",
          "service_phone": "020-88888888",
          "description": "不可与其他优惠同享\n如需团购券发票,请在消费时向商户提出\n店内均可使用,仅限堂食",
          "date_info": {
              "type": "DATE_TYPE_FIX_TERM",
              "fixed_term": 15 ,
              "fixed_begin_term": 0
          },
          "sku": {
              "quantity": 500000
          },
          "get_limit": 3,
          "use_custom_code": false,
          "bind_openid": false,
          "can_share": true,
        "can_give_friend": true,
          "location_id_list" : [123, 12321, 345345],
          "custom_url_name": "立即使用",
          "custom_url": "http://www.qq.com",
          "custom_url_sub_title": "6个汉字tips",
          "promotion_url_name": "更多优惠",
        "promotion_url": "http://www.qq.com"
      },
      "deal_detail": "以下锅底2选1(有菌王锅、麻辣锅、大骨锅、番茄锅、清补凉锅、酸 菜鱼锅可选):\n大锅1份 12元\n小锅2份 16元 "}
}}

Note: Unix time stamps are used in date_info. Be careful to modify the begin_timestamp to be less than the current time and the end_timestamp to a time after today so that the card validation test can succeed later

Interface address: Create Card Voucher

Step 4 Create QR code for delivery

Page address: http://mp.weixin.qq.com/debug

Interface Type: Card Interface

Interface List: Creating a Binary Ticket Interface

access_token: access_token

JSON example:

{"action_name":
 "QR_CARD",
 "action_info": {
 "card": {
	"card_id": "po_2DjgJ2zrboM6SzK3qNuje5iWQ",
    }
 }
}

Interface address:

Step 5 Show QR codes

Click on the link in the field show_qrcode_url in the return of the previous step, and you can display the card coupon to receive the two-dimensional code.

Example: https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEr8ToAAAAAAAAAASxodHRwOi8vd2V********NjRjVuAAIE3kqwVQMEgDPhAQ==

Open WeChat scan, and then receive the voucher, if the video card voucher failed to pass the audit, then the next step needs to set the test white list, if you can receive ignore the sixth step.

Can scan the following two dimensional code experience WeChat card vouchers:

Step 6 Set up a test whitelist Page address: http://mp.weixin.qq.com/debug Interface Type: Card Interface

Interface List: Set up a test whitelist interface

access_token: access_token

JSON example:

{ "username":["usr1","usr2"] }

Note: where usr1, sur2 is the number of the card to receive the WeChat

Interface address:

Step 7 Delete the card

Page address: http://mp.weixin.qq.com/debug/

Interface Type: Card Interface

List of Interfaces: Cancellation Card Interface

access_token: access_token

JSON example:

{ "code": "759733467744" }

Note: only support the audit through and in the validity of the card interface address:

# 4 Overview of the voucher interface

WeChat The voucher interface mainly sets up a series of interfaces around the creation, collection, delivery, and cancellation of coupons. Developers can choose the appropriate interface according to the effect they want to achieve

Develop to realize voucher applications that are distinctive to the industry.

# 5 Introduction to Coupon Terminology

Here are the key concepts to understand during the voucher development process:

Parameter Name describe
card_id Voucher ID. A card voucher ID corresponds to a class of card vouchers, including the corresponding inventory number of Code.
code Card Voucher Code Code. A unique identifier for a voucher. This serial code is used when the voucher is written off, allowing merchant customization.
openid The user's unique identity under the Service Account.
access_token Call interface credentials, valid time is 7200s, each request to refresh, by obtaining the access_token interface access, developers need to properly save and establish a cache mechanism.
jsapi_ticket The signature ticket used to invoke the JS-SDK interface within WeChat to invoke WeChat's native function, see: JS-SDK section for details
api_ticket A temporary ticket signed when calling the WeChat card ticket interface, valid for 7200 s, and repeated requests remain unchanged within 7200 s, obtained by getting the api_ticket interface.
card_ext Additional information for a scalable card. It is used to attach the basic card information when a card is placed.
outer_str Scenarios of ticketing channels Support merchants custom scene value filled in card_ext card voucher delivery, when the user will receive the corresponding scene value through the event notification merchants.
Event push When a voucher passes approval, a token is collected, a card is deleted, and a card has been written off, the developer is notified of the event by sending a message to the server URL filled in with the public platform developer center.
Custom Entry Through the API to create a card voucher support merchants custom card voucher details page jump outside the chain of the unit, the user jump to the link will be in the link suffix card voucher card_id and encrypted code.

# 6 Developer Notes

# 6.1 WeChat Version determination

Because the card coupon function module is supported only after WeChat 6.0.2 version, the call of JS-SDK by users with lower version is invalid.Therefore, the WeChat team recommends that merchants determine the user's current version number through the user agent and then call the JS-SDK interface to add to the card package. Using the iPhone version as an example, the following version sample information can be obtained through the user agent:

"Mozilla/5.0(iphone;CPU iphone OS 5_1_1 like Mac OS X)     AppleWebKit/534.46(KHTML,like Geocko)Mobile/9B206 MicroMessenger/6.0.2 "

Where 6.0.2 is the version number of the WeChat installed by the user.Merchants can determine whether the version number is higher or equal to 6..0.2.

# 6.2 Card issuance limits

Service Account The session environment only supports raising the voucher under the service number domain name.Pushing coupons from other merchants within a service number session is not supported without platform permission, otherwise users will be prompted when receiving coupons: "No coupons can be delivered without the authorization of the merchant" .There are no such restrictions on service account conversations outside of WeChat Moments or chat environments.

Note

Service Account dialog box and the page link from the service number dialog box are in the session context of that service number.

# 6.3 Code rules

All API POST data only supports UTF-8 encoding, otherwise it will return an error.

In order to meet the merchants based on the expansion of the card voucher itself, allow the card voucher page to add URL jump outside the chain.

The external links that jump out of coupons can have parameters for the coupons information that developers can use to confirm the user's identity within the page.

With fields such as encrypt_code, card_id, openid, outer_str (membership cards only).

Note: encrypt_code to add a password code, need to call cancellation card voucher Get the real code.If the specified url is http://www.qq.com, the user clicks, the jump url is: http://www.qq.com?encrypt_code=ENCRYPT_CODE&card_id=CARDID &openid=xxxx&outer_str=xxxxx

# 6.5 Contact Us

If you encounter a voucher development problem, you can use your mailbox. weixin_card@foxmail.com Contact us. You can also join the developer QQ exchange group 653614989 (seven groups) 642762748 (eight groups), verify that you must specify the business name and business.

# 7 Coupon Bundle Download

Download Card Interface Kit for developers:

  • Create & Sign Tool SDK;

  • The voucher interface calls a flow chart;

  • Add a explaination of interface features;

  • SDK for Android;

  • SDK for iOS;