Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

alipay.marketing.card.template.modify

Use this interface to modify membership card templates.

Request

Service address

Environment

HTTPS request URL

Production environment

https://openapi.alipay.com/gateway.do

Request parameters

Parameter

Description

Basic parameter

app_id

String (32) Required

A unique ID that is assigned by Alipay to identify an app

Example:2014072300007148

method

String (128) Required

The interface name

Example:alipay.marketing.card.template.modify

format

String (40) 

Request format. Only JSON is supported.

Example:JSON

charset

String (10) Required

The charset with which the request data are encoded. UTF-8, GBK, and GB2312 are supported. 

Example:UTF-8

sign_type

String (10) Required

The signature algorithm used by the merchant to generate the pre-sign string. RSA and RSA2 are supported. RSA2 is preferred.

Example:RSA2

sign

String (344) Required

The signature value. See Signature for details.

Example:2118ac8fad6bc1d9e88a6cd017c18d37

timestamp

String (19) Required

The time when the request is sent. The format is yyyy-MM-dd HH:mm:ss.

Example:2014-07-24 03:07:50

version

String (3) Required

The interface version. The value is fixed as 1.0.

Example:1.0

biz_content

String Required

Collection of request parameters. The maximum length is not limited. Except for common parameters, all other request parameters must be passed in to this parameter.

Business parameter

request_id

String (64Required

The unique ID assigned by the ISV/merchant to identify a request.

Example:2016072100000000001

template_id

String (32) Required

The unique ID that is assigned by Alipay to identify a membership card template. This parameter is obtained from the template creation interface.

Example:201607180000001

biz_no_prefix

String (16)

Prefix of the membership card number. A card number consists of biz_no_prefix and biz_no_suffix. biz_no_prefix is generated by the merchant and biz_no_suffix is generated in real time.

Example:prex

write_off_type

String (32) Required

Type of the membership card code that is used for redemption. 

See the following list for details about each code type.

Static code

  • qrcode: QR code. The code value is the value of external_card_no assigned by the merchant when issuing the card.
  • barcode: Barcode. The code value is the value of external_card_no assigned by the merchant.

Alipay dynamic code

  • dqrcode: Dynamic QR code generated by Alipay. The code value can be used in alipay.marketing.card.query.
  • dbarcode: Dynamic barcode generated by AlipayThe code value can be used in alipay.marketing.card.query.

The codes expire after two minutes since generation.

Merchant dynamic code

  • mdqrcodeDynamic QR code generated by the merchant. The code value is assigned by the merchant.
  • mdbarcodeDynamic barcode generated by the merchant. The code value is assigned by the merchant.

The code validity period is subject to the merchant.

To use merchant dynamic codes, contact Alipay Technical Support for the related documents.

Example:qrcode

template_style_info

TemplateStyleInfoDTO Required

Template style information. For more information, see template_style_info.

template_benefit_info

TemplateBenefitInfoDTO

Membership card privileges. The information in this parameter is displayed in the "Member benefits" module on the membership card page. For more information, see template_benefit_info.

column_info_list

TemplateColumnInfoDTO[] Required

Information about modules that are to be displayed on the membership card. For more information, see column_info_list.

field_rule_list

TemplateFieldRuleDTO[] Required

List of rules about the membership card fields information.

For example, if the card validity period is two years since issuance, then rule_name = DATE_IN_FUTURE. For more information, see field_rule_list.

card_action_list

TemplateActionInfoDTO[]

List of card action points. An action point is the clickable area on the card. A card can have up to four action points. Duplicated action points are not displayed. For more information, see card_action_list.

open_card_conf

TemplateOpenCardConfDTO

Used to configure information about issuing the membership card. For more information, see open_card_conf.

card_level_conf

TemplateCardLevelConfDTO[]

Used to configure the card level. For more information, see card_level_conf.

mdcode_notify_conf

TemplateMdcodeNotifyConfDTO

Used to configure related information needed for notifying merchants to generate dynamic QR code when the customer uses the membership card.

This parameter specifies the notification data that are sent to the merchant when the user opens the electronic membership card.

Note: This field is required when the value of write_off_type is mdbarcode or mdqrcode. For more information, see mdcode_notify_conf.

card_spec_tag

String (20)

Special tag of the card, which is used only for certain situations. Usually can be ignored.

template_style_info

Parameter

Description

card_show_name

String (10) Required

Card name displayed in the wallet.

Example:Huabei Joint Card

logo_id

String (1000) Required

ID of the logo image obtained after using alipay.offline.material.image.upload to upload the image. The image must conform to the following standards:

  • Maximum file size: 1 MB.
  • Format: BMP, PNG, JPEG, JPG, and GIF.
  • Image size: Square shape with at least 500*500 pixels.
  • Merchant's logo is preferred.

Example:1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC

background_id

String (1000) Required

ID of the background image obtained after using alipay.offline.material.image.upload to upload the image. The image must conform to the following standards:

  • Max file size: 2 MB.
  • Format: BMP, PNG, JPEG, JPG, and GIF.
  • Image size: At least 1020*643 pixels.
  • The image cannot be morphed or have round corners.

Example:1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC

 bg_color

String (32) Required

Font color. Only applies to texts in the card details information.

Example:rgb(55,112,179)

front_text_list_enable

Boolean (5)

This parameter decides whether texts are to be displayed in the card front. The default value is false, which means the text is not to be displayed. Texts consist of label and value, and are defined when creating or updating the card. Texts are to be displayed in lines and at most four lines are supported. 

Example:false

front_image_enable

Boolean (5)

This parameter decides whether the ID photo is to be displayed in the card front. The default value is false, which means the image is not to be displayed. The image ID is obtained when creating or updating the card. 

Example:false

feature_descriptions

String (4000)

Information about the card features that can be previewed by the user when opening the card.

Example:Fee-free installment with Huabei card.

slogan

String (100)

Slogan

Example:Membership privileges incoming

slogan_img_id

String (100)

ID of the slogan image obtained after using alipay.offline.material.image.upload to upload the image.

Example:1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC

brand_name

String (100)

Brand name

Example:Alipay

banner_img_id

String (1000)

ID of the banner image obtained after using alipay.offline.material.image.upload to upload the image.

Example:1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC

banner_url

String (256)

Redirection address of the banner.

Example:http://www.alipay.com

column_info_layout

String (10)

Module information layout. Possible values are:

  • list: list style layout
  • grid: grid style layout

If empty, the default value is list.

Example:list

template_benefit_info

Parameter

Description

title

String (16) Required

Privilege title

Example:Deal discount

benefit_desc

String (1000) Required

Privilege description

Example:A discount exists for every deal

start_date

String (64) Required

Start time of the privilege

Example:2016-07-18 15:17:23

end_date

String (64) Required

End time of the privilege

Example:2016-07-34 12:12:12

column_info_list

Parameter

Description

code

String (32) Required

Module code, including standard module codes and customized module code:

Standard module codes are specified by Alipay and include the following code values:

  • BALANCE: Balance in the membership card.
  • POINT: Point.
  • LEVEL: Card level
  • TELEPHONE: Phone number

Customized module codes are specified by merchants to display customized functions and features. Duplicated module codes are not allowed.

Example:BENEFIT_INFO

operate_type (32)

Module operation type. Possible values:

  • openNative: indicates that the module is with a subpage that can be opened to show the information specified by descs of the more_info field.
  • openWeb: indicates that the module is with a URL that can be opened.
  • staticinfo: indicates that the module shows information in static text.

Notes:

  • If this field is not specified, the default value is staticinfo.
  • Use staticinfo for standard modules.

Example:openWeb

title

String (16) Required

Module title

Example:Member exculsive

value

String (16)

The value of the field assigned by code. For example, the value of BALANCE.

Example:80

more_info

MoreInfoDTO (2048)

Extended information. For more information, see more_info.

icon_id

String (1000)

If the value of template_style_info.column_info_layout is grid, this parameter is the icon ID of the grid. The icon ID is obtained after uploaded the image using alipay.offline.material.image.upload.

Example:1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC

tag

String (3)

If the value of template_style_info.column_info_layout is grid, this parameter is the tag of the grid.

Example:Hot

more_info

Parameter

Description

title

String (16) Required

Subpage title of the openNative module. This field is valid only when the value of operate_type is openNative.

Example:Member exclusive privilege

url

String (256)

URL address of the openweb module. This field is required when the value of operate_type is openweb.

Example:www.alipay.com

params
String (1024)

Extended parameter, which must contain the value in URL. Format: JSON. This field is required when the value of operate_type is openweb.

descs

String[] (1000)

Descriptions to be shown on the subpage of the openNative module. This field is required when the value of operate_type is openNative.

Example:You have 30% off on your birthday

field_rule_list

Parameter

Description

field_name

String (64) Required

Field names. Possible values:

  • Balance: the balance
  • Point: the points, with a type of integer
  • Level: the level, with a type of string.
  • OpenDate: the date when the card is issued
  • ValidDate: the date when the card expires

Example:Balance

rule_name

String (64) Required

Rule name. Possible values:

  • ASSIGN_FROM_REQUEST: use the value of rule_value as the key, which indicates that values of fields are to be obtained from card_info of the alipay.marketing.card.open interface.
  • DATE_IN_FUTURE: a date in the future will be generated, in the format of YYYY-MM-DD. To use this parameter, the value of field_name must be OpenDate or ValidDate, with a value of 10m or 10d (10m means 10 months and 10d means 10 days).
  • CONST: a constant value that is assigned when the card template is created. Use the value of rule_value.

Example:ASSIGN_FROM_REQUEST

rule_value

String (512) Required

The value of this field depends on the rule_name field.

If rule_name is CONST, the value of rule_value is used directly as the card information.

If rule_name is DATE_IN_FUTURE, the value is 10m or 10d.

If rule_name is ASSIGN_FROM_REQUEST, the value is obtained from the alipay.marketing.card.open interface.

Example:Balance

card_action_list

Parameter

Description

code

String (32) Required

Code of the card action point. Customized by the merchant.

Example:TO_CLOCK_IN

text

String (6) Required

Texts displayed at the card action point.

Example:Clock in

url_type

String (20)

Redirection URL type. Possible values are:

  • url: indicates that the redirection URL is an HTTP(S) address or Alipay schema address.
  • miniAppUrl: indicates that the redirection URL is a redirection address to the specified Alipay mini program page.

If this field is not specified, the default value is url.

Example:url

url

String (1024)

Action point redirection URL, which is an HTTP(S) address or Alipay schema address of the action point. This field is required when url_type is url or empty.

Example:https://merchant.ali.com/ee/clock_in.do

mini_app_url

TemplateOpenCardConfDTO (999)

Action point redirection URL, which is a redirection URL to a specified Alipay mini program page. This field is required when url_type is miniAppUrl. For more information, see mini_app_url.

mini_app_url

Parameter

Description

mini_app_id

String (20) Required

ID of the mini program

Example:2018xxxxxxx

mini_page_param

String (20) 

Used to specify the Alipay mini program page that the customer is redirected from the action point. If this field is not specified, the customer is redirected to the Alipay mini program homepage.

mini_query_param

String (50) 

Merchant customized parameter. The value of this parameter is passed in to the mini-app page with a name of "query".

Example:abcxxxxxx

display_on_list

String (5)

Used to decide whether the action point button is to be displayed in the list page. If this field is not specified, the default value is false to indicate that the action point button is not to be displayed. Up to two action points can be added in the list page.

Example:false

open_card_conf

Parameter

Description

open_card_source_type

String (20) Required

The party that issues the membership card. Possible values are:

  • ISV: independent software vendor
  • MER: merchant

Example:ISV

source_app_id

String (32) Required

App ID of the service provider that provides the card issuance page.

Example:201609191111111

open_card_url

String (256) Required

Card issuing link, which starts with http or https.

Example:https://www.alipay.com

conf

String (4000)

Reserved parameter for future use

card_rights

TemplateRightsContentDTO[] (3)

Card privilege information. For more information, see card_rights.

card_rights

Parameter

Description

title

String (10) Required

Privilege title

Example:Gifts for points

detail

String (20)

Privilege details

Example:Check your points anytime and redeem gifts

card_level_conf

Parameter

Description

level

String (64) Required

Membership level. Must be consistent with the value of level in alipay.marketing.card.open.

Example:VIP1

level_show_name

String (64) Required

Displayed name of the membership level

Example:Gold

level_icon

String (64) Required

ID of membership level icon image. Use the image that is uploaded by using alipay.offline.material.image.upload.

Example:1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC

level_desc

String (4000) Required

Membership level description

Example:Free parking for Gold members

mdcode_notify_conf

Parameter

Description

url

String (1024) Required

URL used to receive the code issuing notification. Use HTTPS URLs. When a member opens the electronic card, Alipay sends a POST request to this URL to notify the merchant to generate a code.

Example:https://www.ali123.com/ant/mdcode

ext_params

String (1024)

Extended parameters, which is in a "key":value" format.

The POST request that is sent by Alipay to the address specified by url are including all the parameters in ext_params.

Example:{"param1":"value1","param2":"value2"}

Response

Parameter

Description

Basic parameter

code

String Required

Gateway return code, which indicates whether the request is accepted by Alipay gateway.

Example:40004

msg

String Required

Description of the gateway return code

Example:Business Failed

sub_code

String

Processing result of the request

Example:ACQ.TRADE_HAS_SUCCESS

sub_msg

String

Description of the processing result of the request

Example:Payment for the transaction is completed.

sign

String Required

The signature value. See Signature for details.

Example:DZXh8eeTuAHoYE3w1J+POiPhfDxOYBfUNn1lkeT/V7P4zJdyojWEa6IZs6Hz0yDW5Cp/viufUb5I0/V5WENS3OYR8zRedqo6D+fUTdLHdc+EFyCkiQhBxIzgngPdPdfp1PIS7BdhhzrsZHbRqb7o4k3Dxc+AAnFauu4V6Zdwczo=

Business parameter

template_id

String (32) Required

The unique ID assigned by Alipay to identify a membership card template

Example:201607180000001

Business error code

Error code

Description

Solution

INVALID_PARAMETER

The parameters are invalid.

Use correct request parameters and try again.

SYSTEM_ERROR

System error

Try again later.

TEMPLATE_NOT_EXIT

The template does not exist.

Check whether the template ID is correct. 

Sample

Request sample

JAVA

copy
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do","app_id","your private_key","json","GBK","alipay_public_key","RSA2");
AlipayMarketingCardTemplateModifyRequest request = new AlipayMarketingCardTemplateModifyRequest();
request.setBizContent("{" +
"\"request_id\":\"2016072100000000001\"," +
"\"template_id\":\"201607180000001\"," +
"\"biz_no_prefix\":\"prex\"," +
"\"write_off_type\":\"qrcode\"," +
"\"template_style_info\":{" +
"\"card_show_name\":\"Huabei Joint Card\"," +
"\"logo_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"color\":\"rgb(55,112,179)\"," +
"\"background_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"bg_color\":\"rgb(55,112,179)\"," +
"\"front_text_list_enable\":false," +
"\"front_image_enable\":false," +
"        \"feature_descriptions\":[" +
"          \"With the Huabei Card, you can enjoy free installments\"" +
"        ]," +
"\"slogan\":\"Benefits more than you can imagine.\"," +
"\"slogan_img_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"brand_name\":\"Coca Cola\"," +
"\"banner_img_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"banner_url\":\"http://www.baidu.com\"," +
"\"column_info_layout\":\"list\"" +
"    }," +
"      \"template_benefit_info\":[{" +
"        \"title\":\"Discount for every purchase\"," +
"          \"benefit_desc\":[" +
"            \"Discount for every purchase\"" +
"          ]," +
"\"start_date\":\"2016-07-18 15:17:23\"," +
"\"end_date\":\"2016-07-34 12:12:12\"" +
"        }]," +
"      \"column_info_list\":[{" +
"        \"code\":\"BENEFIT_INFO\"," +
"\"operate_type\":\"openWeb\"," +
"\"title\":\"Only for members\"," +
"\"value\":\"80\"," +
"\"more_info\":{" +
"\"title\":\"Member benefits\"," +
"\"url\":\"http://www.baidu.com\"," +
"\"params\":\"{}\"," +
"            \"descs\":[" +
"              \"30% off on your birthday\"" +
"            ]" +
"        }," +
"\"icon_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"tag\":\"Popular\"," +
"\"group_title\":\"School helper\"" +
"        }]," +
"      \"field_rule_list\":[{" +
"        \"field_name\":\"Balance\"," +
"\"rule_name\":\"ASSIGN_FROM_REQUEST\"," +
"\"rule_value\":\"Balance\"" +
"        }]," +
"      \"shop_ids\":[" +
"        \"2015122900077000000002409504\"" +
"      ]," +
"      \"card_action_list\":[{" +
"        \"code\":\"TO_CLOCK_IN\"," +
"\"text\":\"Clock in\"," +
"\"url_type\":\"url\"," +
"\"url\":\"https://merchant.ali.com/ee/clock_in.do\"," +
"\"mini_app_url\":{" +
"\"mini_app_id\":\"2018xxxxxxx\"," +
"\"mini_page_param\":\"xxxxxxxx\"," +
"\"mini_query_param\":\"abcxxxxxx\"," +
"\"display_on_list\":\"false\"" +
"        }" +
"        }]," +
"\"open_card_conf\":{" +
"\"open_card_source_type\":\"ISV\"," +
"\"source_app_id\":\"201609191111111\"," +
"\"open_card_url\":\"https://www.alipay.com\"," +
"\"conf\":\"\\\"\\\"\"," +
"        \"card_rights\":[{" +
"          \"title\":\"Points for gifts\"," +
"\"detail\":\"Check your points anytime,use your points for gifts\"" +
"          }]" +
"    }," +
"      \"pub_channels\":[{" +
"        \"pub_channel\":\"SHOP_DETAIL\"," +
"\"ext_info\":\"\\\"key\\\":\\\"value\\\"\"" +
"        }]," +
"      \"card_level_conf\":[{" +
"        \"level\":\"VIP1\"," +
"\"level_show_name\":\"Golden member\"," +
"\"level_icon\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"level_desc\":\"Free parking for golden members\"" +
"        }]," +
"\"mdcode_notify_conf\":{" +
"\"url\":\"https://www.ali123.com/ant/mdcode\"," +
"\"ext_params\":\"{\\\"param1\\\":\\\"value1\\\",\\\"param2\\\":\\\"value2\\\"}\"" +
"    }," +
"\"card_spec_tag\":\"NONE\"" +
"  }");
AlipayMarketingCardTemplateModifyResponse response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("Call succeeds");
} else {
System.out.println("Call fails");
}
       

.NET

copy
IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", "app_id", "merchant_private_key", "json", "1.0", "RSA2", "alipay_public_key", "GBK", false);
AlipayMarketingCardTemplateModifyRequest  request= new AlipayMarketingCardTemplateModifyRequest() ;
request.BizContent="{" +
"\"request_id\":\"2016072100000000001\"," +
"\"template_id\":\"201607180000001\"," +
"\"biz_no_prefix\":\"prex\"," +
"\"write_off_type\":\"qrcode\"," +
"\"template_style_info\":{" +
"\"card_show_name\":\"Huabei Joint Card\"," +
"\"logo_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"color\":\"rgb(55,112,179)\"," +
"\"background_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"bg_color\":\"rgb(55,112,179)\"," +
"\"front_text_list_enable\":false," +
"\"front_image_enable\":false," +
"        \"feature_descriptions\":[" +
"          \"With the Huabei Card, you can enjoy free installments\"" +
"        ]," +
"\"slogan\":\"Benefits more than you can imagine.\"," +
"\"slogan_img_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"brand_name\":\"Coca Cola\"," +
"\"banner_img_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"banner_url\":\"http://www.baidu.com\"," +
"\"column_info_layout\":\"list\"" +
"    }," +
"      \"template_benefit_info\":[{" +
"        \"title\":\"Discount for every purchase\"," +
"          \"benefit_desc\":[" +
"            \"Discount for every purchase\"" +
"          ]," +
"\"start_date\":\"2016-07-18 15:17:23\"," +
"\"end_date\":\"2016-07-34 12:12:12\"" +
"        }]," +
"      \"column_info_list\":[{" +
"        \"code\":\"BENEFIT_INFO\"," +
"\"operate_type\":\"openWeb\"," +
"\"title\":\"Only for members\"," +
"\"value\":\"80\"," +
"\"more_info\":{" +
"\"title\":\"Member benefits\"," +
"\"url\":\"http://www.baidu.com\"," +
"\"params\":\"{}\"," +
"            \"descs\":[" +
"              \"30% off on your birthday\"" +
"            ]" +
"        }," +
"\"icon_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"tag\":\"Popular\"," +
"\"group_title\":\"School helper\"" +
"        }]," +
"      \"field_rule_list\":[{" +
"        \"field_name\":\"Balance\"," +
"\"rule_name\":\"ASSIGN_FROM_REQUEST\"," +
"\"rule_value\":\"Balance\"" +
"        }]," +
"      \"shop_ids\":[" +
"        \"2015122900077000000002409504\"" +
"      ]," +
"      \"card_action_list\":[{" +
"        \"code\":\"TO_CLOCK_IN\"," +
"\"text\":\"打卡\"," +
"\"url_type\":\"url\"," +
"\"url\":\"https://merchant.ali.com/ee/clock_in.do\"," +
"\"mini_app_url\":{" +
"\"mini_app_id\":\"2018xxxxxxx\"," +
"\"mini_page_param\":\"xxxxxxxx\"," +
"\"mini_query_param\":\"abcxxxxxx\"," +
"\"display_on_list\":\"false\"" +
"        }" +
"        }]," +
"\"open_card_conf\":{" +
"\"open_card_source_type\":\"ISV\"," +
"\"source_app_id\":\"201609191111111\"," +
"\"open_card_url\":\"https://www.alipay.com\"," +
"\"conf\":\"\\\"\\\"\"," +
"        \"card_rights\":[{" +
"          \"title\":\"Points for gifts\"," +
"\"detail\":\"Check your points anytime,use your points for gifts\"" +
"          }]" +
"    }," +
"      \"pub_channels\":[{" +
"        \"pub_channel\":\"SHOP_DETAIL\"," +
"\"ext_info\":\"\\\"key\\\":\\\"value\\\"\"" +
"        }]," +
"      \"card_level_conf\":[{" +
"        \"level\":\"VIP1\"," +
"\"level_show_name\":\"Golden member\"," +
"\"level_icon\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," +
"\"level_desc\":\"Free parking for golden members\"" +
"        }]," +
"\"mdcode_notify_conf\":{" +
"\"url\":\"https://www.ali123.com/ant/mdcode\"," +
"\"ext_params\":\"{\\\"param1\\\":\\\"value1\\\",\\\"param2\\\":\\\"value2\\\"}\"" +
"    }," +
"\"card_spec_tag\":\"NONE\"" +
"  }";
AlipayMarketingCardTemplateModifyResponse response=client.execute(request);
Console.WriteLine(response.Body);

PHP

copy
$aop = new AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = 'your app_id';
$aop->rsaPrivateKey = 'Please fill in the developer's private key in a line of string, removing the head, tail, and carriage return';
$aop->alipayrsaPublicKey='Please fill in Alipay public key in a line of string';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='GBK';
$aop->format='json';
$request = new AlipayMarketingCardTemplateModifyRequest ();
$request->setBizContent("{" .
"\"request_id\":\"2016072100000000001\"," .
"\"template_id\":\"201607180000001\"," .
"\"biz_no_prefix\":\"prex\"," .
"\"write_off_type\":\"qrcode\"," .
"\"template_style_info\":{" .
"\"card_show_name\":\"Huabei Joint Card\"," .
"\"logo_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," .
"\"color\":\"rgb(55,112,179)\"," .
"\"background_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," .
"\"bg_color\":\"rgb(55,112,179)\"," .
"\"front_text_list_enable\":false," .
"\"front_image_enable\":false," .
"        \"feature_descriptions\":[" .
"          \"With the Huabei Card, you can enjoy free installments\"" .
"        ]," .
"\"slogan\":\"Benefits more than you can imagine\"," .
"\"slogan_img_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," .
"\"brand_name\":\"Coca Cola\"," .
"\"banner_img_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," .
"\"banner_url\":\"http://www.baidu.com\"," .
"\"column_info_layout\":\"list\"" .
"    }," .
"      \"template_benefit_info\":[{" .
"        \"title\":\"Discount for every purchase\"," .
"          \"benefit_desc\":[" .
"            \"Discount for every purchase\"" .
"          ]," .
"\"start_date\":\"2016-07-18 15:17:23\"," .
"\"end_date\":\"2016-07-34 12:12:12\"" .
"        }]," .
"      \"column_info_list\":[{" .
"        \"code\":\"BENEFIT_INFO\"," .
"\"operate_type\":\"openWeb\"," .
"\"title\":\"Only for members\"," .
"\"value\":\"80\"," .
"\"more_info\":{" .
"\"title\":\"Member benefits\"," .
"\"url\":\"http://www.baidu.com\"," .
"\"params\":\"{}\"," .
"            \"descs\":[" .
"              \"30% off on your birthday\"" .
"            ]" .
"        }," .
"\"icon_id\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," .
"\"tag\":\"Popular\"," .
"\"group_title\":\"School helper\"" .
"        }]," .
"      \"field_rule_list\":[{" .
"        \"field_name\":\"Balance\"," .
"\"rule_name\":\"ASSIGN_FROM_REQUEST\"," .
"\"rule_value\":\"Balance\"" .
"        }]," .
"      \"shop_ids\":[" .
"        \"2015122900077000000002409504\"" .
"      ]," .
"      \"card_action_list\":[{" .
"        \"code\":\"TO_CLOCK_IN\"," .
"\"text\":\"Clock in\"," .
"\"url_type\":\"url\"," .
"\"url\":\"https://merchant.ali.com/ee/clock_in.do\"," .
"\"mini_app_url\":{" .
"\"mini_app_id\":\"2018xxxxxxx\"," .
"\"mini_page_param\":\"xxxxxxxx\"," .
"\"mini_query_param\":\"abcxxxxxx\"," .
"\"display_on_list\":\"false\"" .
"        }" .
"        }]," .
"\"open_card_conf\":{" .
"\"open_card_source_type\":\"ISV\"," .
"\"source_app_id\":\"201609191111111\"," .
"\"open_card_url\":\"https://www.alipay.com\"," .
"\"conf\":\"\\\"\\\"\"," .
"        \"card_rights\":[{" .
"          \"title\":\"Points for gifts\"," .
"\"detail\":\"Check your points anytime,use your points for gifts\"" .
"          }]" .
"    }," .
"      \"pub_channels\":[{" .
"        \"pub_channel\":\"SHOP_DETAIL\"," .
"\"ext_info\":\"\\\"key\\\":\\\"value\\\"\"" .
"        }]," .
"      \"card_level_conf\":[{" .
"        \"level\":\"VIP1\"," .
"\"level_show_name\":\"Golden member\"," .
"\"level_icon\":\"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC\"," .
"\"level_desc\":\"Free parking for golden members\"" .
"        }]," .
"\"mdcode_notify_conf\":{" .
"\"url\":\"https://www.ali123.com/ant/mdcode\"," .
"\"ext_params\":\"{\\\"param1\\\":\\\"value1\\\",\\\"param2\\\":\\\"value2\\\"}\"" .
"    }," .
"\"card_spec_tag\":\"NONE\"" .
"  }");
$result = $aop->execute ( $request); 

$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
echo "Succeeded";
} else {
echo "Failed";
}

 

HTTP request source code

copy
https://openapi.alipay.com/gateway.do?timestamp=2013-01-01 08:08:08&method=alipay.marketing.card.template.modify&app_id=15653&sign_type=RSA2&sign=ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE&version=1.0&charset=GBK&biz_content=
  {
"request_id":"2016072100000000001",
"template_id":"201607180000001",
"biz_no_prefix":"prex",
"write_off_type":"qrcode",
"template_style_info":{
"card_show_name":"Huabei Joint Card",
"logo_id":"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC",
"color":"rgb(55,112,179)",
"background_id":"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC",
"bg_color":"rgb(55,112,179)",
"front_text_list_enable":false,
"front_image_enable":false,
        "feature_descriptions":[
          "With the Huabei Card, you can enjoy free installments"
        ],
"slogan":"Benefits more than you can imagine",
"slogan_img_id":"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC",
"brand_name":"Coca Cola",
"banner_img_id":"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC",
"banner_url":"http://www.baidu.com",
"column_info_layout":"list"
    },
      "template_benefit_info":[{
        "title":"Discount for every purchase",
          "benefit_desc":[
            "Discount for every purchase"
          ],
"start_date":"2016-07-18 15:17:23",
"end_date":"2016-07-34 12:12:12"
        }],
      "column_info_list":[{
        "code":"BENEFIT_INFO",
"operate_type":"openWeb",
"title":"Only for members",
"value":"80",
"more_info":{
"title":"Member benefits",
"url":"http://www.baidu.com",
"params":"{}",
            "descs":[
              "30% off on your birthday"
            ]
        },
"icon_id":"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC",
"tag":"Popular",
"group_title":"School helper"
        }],
      "field_rule_list":[{
        "field_name":"Balance",
"rule_name":"ASSIGN_FROM_REQUEST",
"rule_value":"Balance"
        }],
      "shop_ids":[
        "2015122900077000000002409504"
      ],
      "card_action_list":[{
        "code":"TO_CLOCK_IN",
"text":"Clock in",
"url_type":"url",
"url":"https://merchant.ali.com/ee/clock_in.do",
"mini_app_url":{
"mini_app_id":"2018xxxxxxx",
"mini_page_param":"xxxxxxxx",
"mini_query_param":"abcxxxxxx",
"display_on_list":"false"
        }
        }],
"open_card_conf":{
"open_card_source_type":"ISV",
"source_app_id":"201609191111111",
"open_card_url":"https://www.alipay.com",
"conf":"\"\"",
        "card_rights":[{
          "title":"Points for gifts",
"detail":"Check your points anytime,use your points for gifts"
          }]
    },
      "pub_channels":[{
        "pub_channel":"SHOP_DETAIL",
"ext_info":"\"key\":\"value\""
        }],
      "card_level_conf":[{
        "level":"VIP1",
"level_show_name":"Golden member",
"level_icon":"1T8Pp00AT7eo9NoAJkMR3AAAACMAAQEC",
"level_desc":"Free parking for golden members"
        }],
"mdcode_notify_conf":{
"url":"https://www.ali123.com/ant/mdcode",
"ext_params":"{\"param1\":\"value1\",\"param2\":\"value2\"}"
    },
"card_spec_tag":"NONE"
  }

//To ensure a secure communication, verify whether the sign value in the response sample is provided by Ant Financial.

Response sample

JSON

copy
{
    "alipay_marketing_card_template_modify_response": {
        "code": "10000",
        "msg": "Success",
        "template_id": "2016071800000000001"
    },
    "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}
       

XML

copy
<alipay_marketing_card_template_modify_response>
<code>10000</code>
<msg>Success</msg>  <template_id>2016071800000000001</template_id>
</alipay_marketing_card_template_modify_response>

Exception sample

JSON

copy
{
    "alipay_marketing_card_template_modify_response": {
        "code": "20000",
        "msg": "Service Currently Unavailable",
        "sub_code": "isp.unknow-error",
        "sub_msg": "System busy"
    },
    "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}