支付宝卡包——创建卡劵模板(alipay.pass.template.add)

简介: 接口名称:卡券模板创建接口英文名称:alipay.pass.template.add上一步:[url]https://openclub.alipay.com/read.php?tid=12967&fid=72&page=1#anchor3[/url]下一步:[url]https://openclub.alipay.com/read.php?tid=13242&fid=72[/url]一、注意事项该接口用于进行创建支付宝卡劵模板。

接口名称:卡券模板创建接口

英文名称:alipay.pass.template.add

上一步:[url]https://openclub.alipay.com/read.php?tid=12967&fid=72&page=1#anchor3[/url]

下一步:[url]https://openclub.alipay.com/read.php?tid=13242&fid=72[/url]

一、注意事项

该接口用于进行创建支付宝卡劵模板。

1、tpl_content设置的content传值为pass.json中的参数信息;

具体content参数说明详见:[url]https://docs.open.alipay.com/199/105249/[/url]

2、content参数中建议使用双$符号标志自定义参数,目的是为后续调用流程更便利。

建议必须设置自定义参数的数据为:code、channelID、serialNumber,headFields,详见接口调用代码示例。

二、参数说明

1、unique_id:支付宝有唯一性校验,请保证每次请求该值唯一;

2、tpl_content:content(即pass.json内容,必传)、icon、logo(图片url地址,必传)、strip(图片的url地址);

3、content:模板中的自定义参数以双$符号标志,即$ serialNumber $表示自定义参数名为serialNumber,供发布卡券时使用

三、接口请求示例

Java版本请求示例

public static void main(String[] args) throws AlipayApiException {
		AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, AlipayConfig.format, AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type); 
        AlipayPassTemplateAddRequest request = new AlipayPassTemplateAddRequest();
        request.setBizContent(
        //unique_id参数支付宝有唯一性校验,请保证每次请求该值唯一
         "{"unique_id":"2018062914123889695078785","
         + ""tpl_content":"
         + "{"logo":"https://alipass.alipay.com//temps/free/logo.png","
         + ""strip":"https://alipass.alipay.com//temps/free/strip.png","
         + ""icon":"http://alipassprod.test.alipay.net/temps/free/icon.png","
         + ""content":{"
         + ""evoucherInfo":"
         + "{"title":"可可优惠券","
         + ""type":"coupon","
         + ""product":"free","
         + ""startDate":"$validStartDate$","
         + ""endDate":"$validEndDate$","
         + ""operation":"
         + "[{"format":"barcode","message":"$code$","messageEncoding":"UTF-8","altText":"$code$"}],"
         + ""einfo":{"
         + ""logoText":"$logoText$","
         + ""headFields":"
         + "[{"key":"status","label":"状态","value":"$useStateDesc$","type":"text"}],"
         + ""primaryFields":"
         + "[{"key":"strip","label":"","value":"$discountInfo$","type":"text"}],"
         + ""secondaryFields":"
         + "[{"key":"validDate","label":"有效期至:","value":"$validEndDate$","type":"text"}],"
         + ""auxiliaryFields":[],"
         + ""backFields":"
         + "[{"key":"description","label":"详情描述","value":"1.该优惠有效期:截止至20200601日;n2.凭此券可以享受以下优惠:n享门市价优惠n不与其他优惠同享。详询商家。","type":"text"},"
         + "{"key":"shops","label":"可用门店","value":"","type":"text"},"
         + "{"key":"disclaimer","label":"负责声明","value":"除特殊注明外,本优惠不能与其他优惠同时享受;本优惠最终解释权归商家所有,如有疑问请与商家联系。提示:为了使您得到更好的服务,请在进店时出示本券。","type":"text"}"
         + "]},"
         + ""remindInfo":{"offset":"2"}},"
         + ""merchant":{"mname":"hodewu","mtel":"","minfo":""},"
         + ""platform":{"channelID":"$channelID$","webServiceUrl":""},"
         + ""style":{"backgroundColor":"RGB(255,126,0)"},"
         + ""fileInfo":"
         + "{"formatVersion":"2","canShare":true,"canBuy":false,"canPresent":true,"serialNumber":"$serialNumber$","supportTaxi":"true","taxiSchemaUrl":"alipays://platformapi/startapp?appId=20000130&sourceId=20000030&showTitleBar=YES&showToolBar=NO&showLoading=NO&safePayEnabled=YES&readTitle=YES&backBehavior=back&url=/www/index.html"},"
        + ""appInfo":"
        + "{"app":{},"label":"","message":""},"
        + ""source":"alipassprod","
        + ""alipayVerify":[]"
        + "}}}");
         AlipayPassTemplateAddResponse response = null;
        try {
            response = alipayClient.execute(request);
            System.out.println(response.getBody());
        } catch (AlipayApiException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
         if(response.isSuccess()){
         System.out.println("调用成功");
         } else {
         System.out.println("调用失败");
         }
}

响应参数返回示例

{"alipay_pass_template_add_response":{"code":"10000","msg":"Success","result":"{"errorCode":"KP.AE_SUCCESS","errorMsg":"处理成功","tpl_id":"2019013016274826850929194","tpl_params":["useStateDesc","logoText","discountInfo","validEndDate","validStartDate","code","serialNumber","channelID"]}","success":true},"sign":"PuYva+T+UJsS554x2Q73LXqNJHUp3zjK+N1TOyR4oZgMt6cMmA0kkqCb0N8+08iun1C+QGaipSLJ/iNvsTcwghIvsU/vtS2V5Bu9HD0n0B3rMmpS5bjGuNhOF0hnwJlxoZNI1y+Lwo9h5PqyTMyg/eIKTCPE5WRCcNxpVV8MEsCJEbDPNyHTfiBEkh/tQwael7n7fKrBtN1f7xpqqxrySv1GMdX/jtjFY3X/AEl0dztmX/jgGiH89zIxAEThgA9qR6RWLn1k9ioHfE/l3wMfKAjWo5lavAWzXedExu2NswpU1lgF0GpvVjvq6d4cEwaGW51peU/V2jDrsnMBTPqWdQ=="}


PHP版本请求示例

<?php
require_once 'AopSdk.php';
$aop = new AopClient ();
$aop->appId = '填写您的appid';
$aop->rsaPrivateKey = '填写您的私钥';
$aop->alipayrsaPublicKey='填写您的支付宝公钥';
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$date=date("YmdHis");
$arr=range(1000,9999);
shuffle($arr);
$request = new AlipayPassTemplateAddRequest ();
$request->setBizContent(
//unique_id参数支付宝有唯一性校验,请保证每次请求该值唯一
         '{"unique_id":"2018062914123889695078789",'
         . '"tpl_content":{'
         . '"logo":"https://alipass.alipay.com//temps/free/logo.png",'
         . '"strip":"https://alipass.alipay.com//temps/free/strip.png",'
         . '"icon":"http://alipassprod.test.alipay.net/temps/free/icon.png",'
         . '"content":{'
         . '"evoucherInfo":{'
         . '"title":"可可优惠券",'
         . '"type":"coupon",'
         . '"product":"free",'
         . '"startDate":"$validStartDate$",'
         . '"endDate":"$validEndDate$",'
         . '"operation":'
         . '[{"format":"barcode","message":"$code$","messageEncoding":"UTF-8","altText":"$code$"}],'
         . '"einfo":{'
         . '"logoText":"$logoText$",'
         . '"headFields":'
         . '[{"key":"status","label":"状态","value":"$useStateDesc$","type":"text"}],'
         . '"primaryFields":'
         . '[{"key":"strip","label":"","value":"$discountInfo$","type":"text"}],'
         . '"secondaryFields":'
         . '[{"key":"validDate","label":"有效期至:","value":"$validEndDate$","type":"text"}],'
         . '"auxiliaryFields":[],'
         . '"backFields":'
         . '[{"key":"description","label":"详情描述","value":"1.该优惠有效期:截止至2020年06月01日;n2.凭此券可以享受以下优惠:n享门市价优惠n不与其他优惠同享。详询商家。","type":"text"},'
         . '{"key":"shops","label":"可用门店","value":"","type":"text"},'
         . '{"key":"disclaimer","label":"负责声明","value":"除特殊注明外,本优惠不能与其他优惠同时享受;本优惠最终解释权归商家所有,如有疑问请与商家联系。提示:为了使您得到更好的服务,请在进店时出示本券。","type":"text"}'
         . ']},'
         . '"remindInfo":{"offset":"2"}},'
         . '"merchant":{"mname":"hodewu","mtel":"","minfo":""},'
         . '"platform":{"channelID":"$channelID$","webServiceUrl":""},'
         . '"style":{"backgroundColor":"RGB(255,126,0)"},'
         . '"fileInfo":'
         . '{"formatVersion":"2","canShare":true,"canBuy":false,"canPresent":true,"serialNumber":"$serialNumber$","supportTaxi":"true","taxiSchemaUrl":"alipays://platformapi/startapp?appId=20000130&sourceId=20000030&showTitleBar=YES&showToolBar=NO&showLoading=NO&safePayEnabled=YES&readTitle=YES&backBehavior=back&url=/www/index.html"},'
        . '"appInfo":'
        . '{"app":{},"label":"","message":""},'
        . '"source":"alipassprod",'
        . '"alipayVerify":[]'
        . '}}}');
$result = $aop->execute ( $request); 
var_dump($result);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
echo "成功";
} else {
echo "失败";
}

响应参数返回示例

public 'alipay_pass_template_add_response' => 
    object(stdClass)[9]
      public 'code' => string '10000' (length=5)
      public 'msg' => string 'Success' (length=7)
      public 'result' => string '{"errorCode":"KP.AE_SUCCESS","errorMsg":"处理成功","tpl_id":"2019022209351735229484926","tpl_params":["useStateDesc","logoText","discountInfo","validEndDate","validStartDate","code","serialNumber","channelID"]}' (length=214)
      public 'success' 
目录
相关文章
|
7月前
|
供应链 搜索推荐 数据挖掘
拼多多根据ID取商品详情原数据 API (pinduoduo.item_get_app_pro)在电商中的应用
拼多多是一个非常受欢迎的电商平台,它提供了许多API接口来帮助开发者集成和扩展其功能。其中,pinduoduo.item_get_app_pro API接口是用于根据商品ID获取商品详情的。这个API接口在电商应用中具有广泛的应用场景,以下是几个例子: 个性化推荐:电商平台可以根据用户的浏览和购买历史,利用pinduoduo.item_get_app_pro API接口获取商品的详细信息,然后向用户推荐相似或相关的商品。这有助于提高用户的购物体验,增加用户的购买意愿。 库存管理:商家可以利用这个API接口实时查询商品库存情况,以便及时调整销售策略,避免库存积压或缺货。 商品详情页面优化:在商
|
5月前
|
前端开发
支付系统--微信支付21--搭建前端环境,payment-demo-front这个项目文件夹是前端显示文件,payment-demo是后端项目,支付页面常见三个页面:购买课程,我的订单,下载账单
支付系统--微信支付21--搭建前端环境,payment-demo-front这个项目文件夹是前端显示文件,payment-demo是后端项目,支付页面常见三个页面:购买课程,我的订单,下载账单
支付宝卡包——发放卡劵(alipay.pass.instance.add)
接口名称:支付宝pass新建卡券实例接口 英文名称:alipay.pass.instance.add 上一步:[url]https://openclub.alipay.com/read.php?tid=13240&fid=72[/url] 下一步:[url]https://openclub.alipay.com/read.php?tid=13243&fid=72[/url] 一、注意事项 该接口用于将卡劵发放到用户卡包内。
855 12
alipay.data.dataservice.bill.downloadurl.query(查询对账单下载地址) 集成流程
接口名称:查询对账单下载地址接口 英文名称:alipay.data.dataservice.bill.downloadurl.query 用于查询订单是否存在以及订单的详细信息; 一、文档地址 官方文档地址:[url]https://docs.open.alipay.com/api_1/alipay.trade.query/[/url] 二、开发前准备工作 调用步骤:[url]https://openclub.alipay.com/read.php?tid=12194&fid=69[/url] 注意事项:1、支持沙箱测试;2、需签约并添加功能;3、支持第三方调用。
2279 12
|
Java
发放卡券接口(alipay.pass.instance.add)JAVA版本小样
调用这个接口前需要先创建卡券模板,参考该贴:https://openclub.alipay.com/read.php?tid=2135&fid=8 官方接口文档:https://docs.open.alipay.
568 12
|
JSON 数据格式
创建卡券模板接口(alipay.pass.template.add)JAVA版本小样
官方接口文档:https://docs.open.alipay.com/199/105250/  基本操作流程  1.创建应用等流程不概述了,调用该接口主要第一步是模板设计:推荐使用卡券平(https://alipassprod.
834 12
支付宝卡包——核销卡劵(alipay.pass.instance.update)
接口名称:支付宝pass更新卡券实例接口 英文名称:alipay.pass.instance.update 上一步:[url]https://openclub.alipay.com/read.php?tid=13242&fid=72[/url] 下一步:[url]https://openclub.alipay.com/read.php?tid=13244&fid=72[/url] 一、注意事项 该接口主要用于使页面显示核销状态,且该接口还含有失效卡劵、更新卡劵功能。
2021 12
会员卡开卡表单模板配置(alipay.marketing.card.formtemplate.set)JAVA版本demo
官方接口文档:[url]https://docs.open.alipay.com/251/105668/[/url],我这里写的是开卡组件前两步的操作流程,仅供参考 1.调用接口前的准备工作(创建应用等)参考该文档:[url]https://docs.
1214 12
|
Java
会员卡模板查询接口(alipay.marketing.card.template.query)JAVA版本demo
说明:        该接口主要用于查询已创建的会员卡模板参数详细信息,官方接口文档请点击【会员卡模板查询接口】        创建模板接口参考该贴:[url]https://openclub.alipay.
766 12
|
Java
更新卡券接口(alipay.pass.instance.update)JAVA版本小样
使用场景介绍 对于已经发布的卡券,商户可通过此接口进行更新,更新卡券接口包含三大主要功能:核销卡券、失效卡券、更新卡券样式内容  核销卡券功能  核销卡券主要描述开发者如何将发放出去的卡券进行核销,使卡券在用户的支付宝客户端展示为已使用状态。
617 12