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

alipay.marketing.card.activateurl.apply

Use this interface to get the membership card activation URL.

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

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

Example:2014072300007148

method

String (128) Required

The interface name

Example:alipay.marketing.card.activateurl.apply

format

String (40) 

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

template_id

String (1024) Required

The ID that is assigned by Alipay to identify a membership card template. The value is the same as that of template_id returned by Alipay in the template creation interface. 

Example:20170228000000000210102000300974

out_string

String (256)

Extended information. The value of this field is presented on the merchant page after the user applies for the membership card.

Example:201928393932

callback

String (10240Required

The callback address after the user confirms to apply for the membership card.

Note: The callback address cannot contain parameters. If you need to pass parameters, use the out_string parameter.

Example:https://alipay.com/card/demo.htm

follow_app_id

String (512)

The app ID in Alipay Life Style Account Platform that the user needs to follow. If Follow the Life Style Account needs to be displayed on the page to receive the membership card, create a Life Style account and bind with the membership card. See Introduction of Alipay Life Style Account Platform for the integration with Alipay Life Style Account Platform.

Example:20150000000000000

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

apply_card_url

String (102400) Required

The membership card activation URL. Decode the URL with URLDecode when using this field. The merchant can promote the URL through Alipay Service Window or transform the URL into an in-store QR code.

Example:https%3A%2F%2Fmemberprod.alipay.com%2Faccount%2Fopenform%2Factivecard.htm%3Fapp_id%3D2017051007191443%26template_id%3D2017053100

Error codes

Returned result

Description

Solution

INVALID_PARAMETER

Incorrect parameters

Check the request parameters and use correct parameters in the request

SYSTEM_ERROR

Alipay system error

Try again later.

CARD_TEMPLATE_NOT_EXIST

The membership card template does not exist.

Check if the template ID is correct. Use the template ID returned in the template creation interface.

OPEN_FORM_TEMPLATE_NOT_EXIST

No configuration exists for the form template.

Use the alipay.marketing.card.formtemplate.set interface to make configurations.

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");
AlipayMarketingCardActivateurlApplyRequest request = new AlipayMarketingCardActivateurlApplyRequest();
request.setBizContent("{" +
"\"template_id\":\"20170228000000000210102000300974\"," +
"\"out_string\":\"201928393932\"," +
"\"callback\":\"https://alipay.com/card/demo.htm\"," +
"\"follow_app_id\":\"20150000000000000\"" +
"}");
AlipayMarketingCardActivateurlApplyResponse response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("The calling is successful.");
} else {
System.out.println("The calling is failed.");
}

.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);
AlipayMarketingCardActivateurlApplyRequest  request= new AlipayMarketingCardActivateurlApplyRequest() ;
request.BizContent="{" +
"\"template_id\":\"20170228000000000210102000300974\"," +
"\"out_string\":\"201928393932\"," +
"\"callback\":\"https://alipay.com/card/demo.htm\"," +
"\"follow_app_id\":\"20150000000000000\"" +
"}";
AlipayMarketingCardActivateurlApplyResponse 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 AlipayMarketingCardActivateurlApplyRequest ();
$request->setBizContent("{" .
"\"template_id\":\"20170228000000000210102000300974\"," .
"\"out_string\":\"201928393932\"," .
"\"callback\":\"https://alipay.com/card/demo.htm\"," .
"\"follow_app_id\":\"20150000000000000\"" .
"}");
$result = $aop->execute ( $request); 

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

HTTP request source code

copy
https://openapi.alipay.com/gateway.do?timestamp=2013-01-01 08:08:08&method=alipay.marketing.card.activateurl.apply&app_id=4519&sign_type=RSA2&sign=ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE&version=1.0&biz_content=
  {
"template_id":"20170228000000000210102000300974",
"out_string":"201928393932",
"callback":"https://alipay.com/card/demo.htm",
"follow_app_id":"20150000000000000"
  }

//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_activateurl_apply_response": {
        "code": "10000",
        "msg": "Success",
        "apply_card_url": "https%3A%2F%2Fmemberprod.alipay.com%2Faccount%2Fopenform%2Factivecard.htm%3Fapp_id%3D2017051007191443%26template_id%3D2017053100"
    },
    "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}

XML

copy
<alipay_marketing_card_activateurl_apply_response>
<code>10000</code>
<msg>Success</msg>  <apply_card_url>https%3A%2F%2Fmemberprod.alipay.com%2Faccount%2Fopenform%2Factivecard.htm%3Fapp_id%3D2017051007191443%26template_id%3D2017053100</apply_card_url>
</alipay_marketing_card_activateurl_apply_response>

Exception sample

JSON

copy
{
    "alipay_marketing_card_activateurl_apply_response": {
        "code": "20000",
        "msg": "Service Currently Unavailable",
        "sub_code": "isp.unknow-error",
        "sub_msg": "The system is busy."
    },
    "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
}