# Creating Friend's Vouchers

# 1 Style of Friend's Vouchers

Big changes have been made to the style of Friend's Vouchers. The vouchers have a neat and eye-catching design with more striking background, with merchants' elements highlighted more clearly. Text description and images can be inserted to give the merchants more exposure.

# 2 API Instructions

Before developing vouchers, you need to create vouchers. Generate a card_id by entering the voucher content, and then issue and redeem the vouchers upon approval. The following must be considered before the creation of vouchers.

# 2.1 Selecting a Right Threshold Type

Friend's Voucher supports both threshold-independent and threshold-dependent vouchers. Details and Voucher Title fields will be constructed automatically based on the threshold types entered by merchants. You can chose the best combination of threshold types to maximize the campaign effect.

Entering the threshold field as specified will ensure that the vouchers are approved quickly. Any vouchers with a threshold type other than the following types will be rejected.

In addition, Weixin backend sets different inventory prices for vouchers with different thresholds. The pricing criteria are as follows:

   (1) Threshold-independent vouchers: 0.2 tokens per voucher.
 (2) Vouchers with "Applicable to" and "/Minimum Purchase Amount" specified: 0.4 tokens per voucher; vouchers with only "Using with other vouchers is not allowed" selected: 0.2 tokens per voucher.

Fields for Different Threshold Types

Weixin backend determines the style and display of vouchers according to different threshold fields entered by developers. In the following table, we use a 50-CNY price-reduction voucher and an egg tart exchange voucher as examples to describe different display logic based on different thresholds.

Threshold Type Supported Voucher Conditions Abstract Title
Threshold-independent Price-reduction vouchers/Exchange vouchers Threshold field is not specified. No minimum purchase amount is required, and the voucher is available for all commodities. 50-CNY voucher or an apple
Valid/Invalid for specific categories Price-reduction vouchers Enter Egg tart in accept_category and Cake in reject_category. Valid for egg tarts and invalid for cakes. 50 CNY off for egg tarts (the value of accept_catagory contains 5 Chinese characters at most), or 50-CNY price-reduction voucher (the value of accept_catagory contains more than 5 Chinese characters).
Valid with minimum purchase amount Price-reduction vouchers/Exchange vouchers The least_cost field is set to 500. Valid with a minimum purchase amount of 500 CNY. 50 CNY off 500 CNY for all commodities
Valid after purchase (exchange vouchers only) Exchange vouchers The object_use_for field is specified. Valid for cakes only Buy cakes and get egg tarts
Using with other vouchers is not allowed Price-reduction vouchers/Exchange vouchers The can_use_with_other_discount field is set to false. The voucher cannot be used with other vouchers 50-CNY price-reduction voucher

Notes:

  1. Threshold field is used to join the title and voucher description, and affects the merchant's pricing for the voucher inventory. Enter the fields as required and preview the generated vouchers.

  2. The threshold field cannot be changed once set. Therefore, enter it carefully and preview the results in time.

  3. When both least_cost and accept_category are specified, the values are joined like this: "50 CNY off 500 CNY for down jackets[TH1]" (the value of accept_catagory contains 5 Chinese characters at most), and "50 CNY off 500 CNY" (the value of accept_catagory contains more than 5 Chinese characters).

# 2.2 Selecting an Appropriate Code Display Type

The codes of vouchers can be displayed in five modes: QR code with numeric code, QR code without numeric code, barcode with numeric code, barcode without numeric code, only numeric code, and no code (for vouchers only).

The redemption methods vary with code display types. Vouchers that are displayed as QR code and barcode can be redeemed by scanning the code. Vouchers that are displayed as code only are redeemed by entering the code. Those without code can be used only for online purchases and must be redeemed via a custom page developed by the merchant.

Developers must pass in different code_type parameters for different code display types during voucher creation.

Type Field Name Redemption Method
QR code/Barcode with numeric code CODE_TYPE_QRCODE/CODE_TYPE_BARCODE Suitable for redemption via code scanning/entering
QR code without numeric code CODE_TYPE_ONLY_QRCODE Suitable for redemption via code scanning
Only numeric code CODE_TYPE_TEXT Only applicable to redemption via code entering
No code CODE_TYPE_NONE Only applicable to online redemption. No entry to the QR code is displayed on the voucher page.

# 2.3 Recording Users' Voucher Receipt Behaviors

There are multiple ways to record users' voucher receipt behaviors:

  1. After a user receives a voucher, an event is pushed to the developer. The voucher receipt event includes the voucher ID, code, the recipient's OpenID. Voucher redemption event is also pushed to the developer. For more information, see Voucher-Related Event Push.

  2. Get the code status by calling the "Query Code" API to check whether the voucher is receipt, redeemed, or deleted. If the code has been received by a user and is valid, you can obtain the recipient's OpenID.

  3. When a redirection from the voucher details page to an external link occurs, the voucher ID, code and other information are automatically passed by the Weixin backend. For details, see Parameters Contained by External Redirect URL.

# 2.4 Using Custom Entries

In order to meet the needs of merchants for feature expansion, three new custom entries in vouchers are added to allow customer to directly go to merchants' custom URLs.

The differences between the three custom entries are as follows:

Type Example Fields When to display
Entry to usage page Use Now center_title, center_sub_title, and center_url It covers the QR code entry button and is grayed out for any voucher that has not become available.
Entry to service page Online Mall custom_url_name, custom_url_sub_title, custom_url Only displayed when a voucher within the validity period is received by a user (for any voucher that is transfered to another user or has been redeemed, the entry is not displayed).
Entry to promotional page Buy Again promotion_url_name, promotion_url_sub_title, promotion_url The entry is always displayed whether the voucher is normal, is transfered to others or has been redeemed.

# 3 API Calling Process

To create Friend's Vouchers, strictly follow the following API calling process to call appropriate APIs.

Developers must call the following APIs according to the preceding process.

# 4 API Details

# 4.1 Uploading Images

See the "Upload Images" API. You need to call this API to upload merchant's logo to the Weixin server, and obtain the logo_url for creating vouchers.

Notes:

  1. The image for upload can not be larger than 1 MB, and can only be JPG files.

  2. The image URL obtained by calling the API can only be used in the relevant Weixin business scenarios.

  3. Only image URL returned by the Weixin server can be uploaded. Otherwise, an error occurs.

# 4.2 Weixin Store API

See the Weixin Store API Documentation. Populate the field location_id_list in the "Create Voucher" API with the obtained store IDs to set the stores supporting the voucher.

# 4.3 Selecting Voucher Background Color

See the documentation for the "Select Voucher Background Color" API. Select the appropriate color value to make the voucher more distinct. Enter the color value (e.g. Color010) in the color filed when creating the voucher in the following step.

# 4.4 Creating Friend's Vouchers

This API is the most important of all creation APIs.

Friend's Vouchers are advanced vouchers that are derived from native vouchers. Different from other vouchers, Friend's Vouchers are displayed with promotion details that contain text description and images by using the advanced_info field, making service and product abstract information prominent.

API Description

Developers need to call this API to create Friend's Vouchers, and enter the merchant information, logo, stores, and related discount and usage fields. After a voucher is created, the card ID is obtained for voucher issuance.

API Request Format

HTTP request method: POST https://api.weixin.qq.com/card/create?access_token=ACCESS_TOKEN

Parameters

Parameter Required Description
access_token Yes The credential for API call
POST data Yes JSON data

Example of POST data of a price-reduction voucher

{
    "card": {
        "card_type": "CASH",
        "cash": {
            "base_info": {
                "logo_url": "http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7hicFNjakmx ibMLGWpXrEXB33367o7zHN0CwngnQY7zb7g/0",
                "brand_name": "Weixin Restaurant",
                "code_type": "CODE_TYPE_TEXT",
                "color": "Color010",
                "service_phone": "020-88888888",
                "description": "Using with other vouchers is not allowed. Ask the merchant for an invoice for the group purchase during check-out.",
                "date_info": {
                    "type": "DATE_TYPE_FIX_TIME_RANGE",
                    "begin_timestamp": 1447397802,
                    "end_timestamp": 1449893532
                },
                "can_share": false,
                "can_give_friend": false,
                "location_id_list": [
                    272981040,
                    400183234
                ],
                "use_limit":50,
                "get_limit": 3,
                "center_title": "Quick redemption",
                "center_sub_title": "",
                "center_url": "www.qq.com",
                "custom_url_name": "Use Now",
                "custom_url": "http://www.qq.com",
                "custom_url_sub_title": "6 Chinese characterstips",
                "promotion_url_name": "More discounts",
                "promotion_url": "http://www.qq.com"
            },
            "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 for the taste of everyone at 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"
                ],
                "consume_share_self_num": 1,
                "consume_share_card_list": [],
                "share_friends": true
            },
            "reduce_cost": 10
        }
    }}

Example of POST data of an exchange voucher

{
    "card": {
        "card_type": "GIFT",
        "gift": {
            "base_info": {
                ...
            },
            "advanced_info": {
                ...
            },
            "gift_name": "Apple",
            "gift_num": 1,
            "gift_unit": "gift(s)": "Get one apple"
        }
    }}

JSON structure of a Friend's Voucher

The settings of the preceding fields (except for the base_info field) are the same for price-reduction vouchers and exchange vouchers. Therefore, the JSON structure of the exchange voucher is not shown.

Voucher info fields

Field Description Required
card_type Voucher type. Only CASH (price-reduction voucher) and GIFT (exchange voucher) are supported. Yes
cash Function name of the price-reduction voucher in JSON structure Yes
reduce_cost Indicates the voucher amount. This filed is only applicable to price-reduction vouchers. It cannot be set to 0. Yes
gift Function name of the exchange voucher in JSON structure Yes
gift_name The name of the product for which the exchange voucher is redeemed, with a maximum length of 6 Chinese characters. Yes
gift_num The quantity of products for which the exchange voucher is redeemed. It supports a maximum of three-digit numbers. No
gift_unit The unit of the quantity of products for which the exchange voucher is redeemed, with a maximum length of two Chinese characters. No
gift Gift details displayed on the exchange voucher Yes

base_info field

Field Description Required
base_info Basic data of the voucher. This field is the same for any types of vouchers. Yes
logo_url Merchant logo. Use the URL obtained by calling the "Upload Image" API. Yes
code_type Type of voucher code. 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 code. Yes
brand_name Merchant name, with a maximum length of 12 characters Yes
color Voucher color. See the documentation for the "Select Voucher Background Color" API. Yes
notice Usage tips displayed on the main page, with a maximum length of 12 characters, such as: Please present your QR code to redeem the voucher. Yes
description Usage instructions, with a maximum length of 1000 characters (line breaks are allowed). Yes
date_info Information of validity period. It is supported only when type is DATE_TYPE_FIX_TIME_RANGE. Yes
begin_timestamp Indicates the start time of validity period, and only takes effect when type = DATE_TYPE_FIX_TIME_RANGE. It is expressed as a Unix timestamp, i.e. the number of seconds that have elapsed since 00:00:00 1/1/1970. Yes
end_timestamp Indicates the end time of validity period, and only takes effect when type = DATE_TYPE_FIX_TIME_RANGE. It is expressed as a Unix timestamp, i.e. the number of seconds that have elapsed since 00:00:00 1/1/1970. Yes
location_id_list Store location ID. See Weixin Store API Documentation. Enter at least one applicable poi_id for Friend's Vouchers. Otherwise, an error occurs. Yes
can_share Specifies whether the voucher can be shared to chats and Moments. This field and the share_friends field are mutually exclusive. When creating a voucher to be shared between friends, set this field to "false". Yes
can_give_friend Specifies whether the voucher is transferable. This field and the share_friends field are mutually exclusive. When creating a voucher to be shared between friends, set this field to "false". Yes
service_phone Customer service phone number No
get_limit Receipt limit. It restricts the number of times a user scans the code or taps the HTML5 page to receive vouchers. No
use_lim it Use limit. It restricts the number of times a Weixin ID can use a voucher. No
center_title URL title centered at the top of the screen. It is usually Quick Redemption or Weixin Checkout that a user taps to open a merchant-developed redemption or payment page. It supports a maximum of 9 Chinese characters. This cell is displayed only when the voucher is normal and within the validity period. No
center_sub_title URL sub-title centered at the top of the screen and displayed under the title. It supports a maximum of 12 Chinese characters. This sub-title is displayed only when the voucher is normal and within the validity period. No
center_url URL centered at the top of the screen. This URL is displayed only when the voucher is normal and within the validity period. No
custom_url_name Merchant's custom entry button name, which is used with the custom_url field. The length is limited to 5 characters. No
custom_url External URL to which a redirection is made through the merchant's custom entry. The content of the target page should match the custom button name. No
custom_url_sub_title Tips shown to the right of the entry button, with a maximum length of 6 characters. No
promotion_url_name Custom entry button to the promotional page No
promotion_url URL of external redirect link No
promotion_url_sub_title Tips shown to the right of the entry button, with a maximum length of 6 characters. No

advanced_info field

The use_condition field is added. For price-reduction vouchers, this field can be used with the least_cost field (valid with minimum purchase), the accept_category or reject_category field (valid/invalid for specific categories), or the can_use_with_other_discount field (using with other vouchers is not allowed).

For exchange vouchers, this field can be used with the least_cost field (valid with minimum purchase), the object_use_for field (valid after purchase), or the can_use_with_other_discount field (using with other vouchers is not allowed).

Field Description Required
advanced_info Advanced field specific to benefit vouchers Yes
use_condition Indicates the usage condition of voucher No
accept_category Specifies the product categories the voucher applies to. This field is only applicable to price-reduction vouchers. "Only for xxx" is shown on the voucher when this field is specified. For example, the title is "50 CNY off for xxx" (if a maximum of 5 Chinese characters are entered) or "50-CNY price-reduction voucher" (if more than 5 Chinese characters are entered). No
reject_category Specifies the product categories the voucher does not apply to. This field is only applicable to price-reduction vouchers. "Not for xxx" is shown on the voucher when this field is specified. No
least_cost Indicates the minimum purchase amount required to use the voucher (exchange/price-reduction vouchers). "For an order not below xx CNY" is shown on the voucher when this field is specified. For example, the title is "xx off xx" or "Spend xx and Get xx" (gift_name). No
object_use_for Indicates the product categories that need to be purchased before the exchange voucher can be used. "Available after purchase of xxx" is shown on the voucher when the field is specified. For example, the title is "Buy xx and Get xx" (gift_name). No
can_use_with_other_discount Indicates whether the voucher can be used with other vouchers. If it is "false", "Using with other vouchers is not allowed" is shown in the usage instructions. It defaults to "true". No
abstract Cover abstract structure name Yes
abstract Cover abstract description Yes
icon_url_list 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 size is 850*350 pixels. Yes
text_image_list List of articles, which are displayed in the details page. Benefit voucher developers must pass at least one article list. Yes
image_url Image URL. Enter the image URL obtained by uploading the image using "Upload Image" API. Otherwise, an error occurs. Yes
text Article description, which consists up to 5,000 characters. Yes
business_service 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. No
time_limit Time period to which the voucher usage is limited. No
type Enumerated values of the limit types. Supported values include MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY, and HOLIDAY. This field only specifies whether the time period limit is displayed, instead of the usage logic. If it is left empty, no time period limit is displayed. No
begin_hour Start time (hour) under the current limit type. For example, if MONDAY is entered for "type", and 10 is entered for this field, the voucher is available from 10:00 every Monday. No
begin_minute 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 voucher is available from 10:59 every Monday. No
end_hour End time (hour) under the current limit type. For example, if MONDAY is entered for "type", and 20 is entered for this field, the voucher is available between 10:00 and 20:00 every Monday. No
end_minute 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 voucher is available between 10:00 and 10:59 every Monday. No
consume_share_self_num The quantity of this voucher given way after redemption. Only one voucher is supported. This value id mutually exclusive with consume_share_card_list. No
consume_share_card_list The list of other vouchers given away after redemption. This value id mutually exclusive with consume_share_self_num. No
card_id The card_id of another voucher given away after redemption. The card_id of only one shared voucher is supported. It is required for shared vouchers. No
num The number of vouchers of this card_id given away after redemption. It can be set only to 1. No
share_friends Specifies whether the voucher can be shared to friends. Vouchers can be shared only when this field is set to "true". Yes

Notes:

1.1. Threshold field is used to join the title and voucher description on the voucher page. Ensure the fields are entered as required to avoid errors.

  1. The field "time_limit" only specifies whether the time period limit is displayed, instead of the usage logic. If it is left empty, no time period limit is displayed.

Response Data

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

Fields

Field Description
Error code Error code. 0: normal; 40071: Incorrect format. Refer to the JSON example for troubleshooting.
errmsg Error message
card_id Voucher ID

# 4.5 Pushing Approval Event

When a created voucher is approved, Weixin pushes this event to the URL entered by the developer. For details, see Voucher-Related Event Push.

# 4.6 Setting Weixin Checkout for Friend's Vouchers

Similar to common vouchers, Friend's Vouchers also support Weixin Checkout. A merchant who has activated WeChat Pay can enable Weixin Checkout for Friend's Vouchers by calling the "Set Weixin Checkout" API, thereby facilitating money receiving.

# 5 Help

# 5.1 Error Codes

Error Code Description How to Debug
40079 Incorrect validity period The validity period must be within 90 days.
40141 Incorrect image URL The URL must be obtained by uploading the image to the CDN.
41025 location_list is missing The location_list (poi_id) must be specified during creation of JSON.
42001 Token timed out Obtain the latest token to call the API again. If multiple calling sources are available, the token must be centrally managed.
47001 Incorrect JSON structure Refer to the example for troubleshooting based on the location indicated in the error message

For more error codes, see Common Error Codes.

# 5.2 FAQs

1. Why can't I add Friend's Vouchers to the inventory during creation?

The inventory mechanism for Friend's Vouchers is different from that for other vouchers. Developers must create Friend's Vouchers and then top up the inventory using tokens on MP (merchant backend).

2. Why is a Friend's Voucher effective for only three months?

Different from other vouchers, Friend's Vouchers are time-sensitive and flexible. To ensure the voucher list is updated in real time, each merchant is required to create vouchers that are effective for a maximum of three months (90 days).

3. Can tokens be refunded when a voucher expired?

If there are vouchers with the card_id available in the inventory when they expired, the inventory will be converted into tokens and refunded to the merchant's account in T+1 days (i.e. on the next day).