支付宝卡包——创建卡劵模板(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' 
目录
相关文章
|
3月前
|
人工智能 安全 API
喂饭级图文指南!OpenClaw(Clawdbot)阿里云/本地部署+5705个Skill集成与验真,避开几百个恶意插件
2026年,OpenClaw(原Clawdbot、Moltbot)凭借开放的Skill生态成为AI助手领域的焦点——ClawHub平台汇聚的5705个技能覆盖办公自动化、智能家居、开发辅助等全场景需求,让用户只需简单配置,就能解锁AI助手的无限可能。但光鲜背后暗藏致命风险:Koi Security审计发现至少341个恶意Skill,Bitdefender扫描显示近20%的Skill存在安全漏洞,VirusTotal对3016个Skill的深度分析更是揭露数百个含恶意特征的插件。
1106 0
|
C#
C#一分钟浅谈:委托与事件的实现方式
本文详细介绍了C#编程中委托与事件的基础知识及应用场景。首先解释了委托的概念,包括定义与使用方法;接着介绍了事件这一基于委托的特殊类型,展示了如何在类中定义事件及跨类订阅与处理事件;最后讨论了常见问题如事件未处理异常、重复订阅及内存泄漏等,并提出了相应的解决方案。通过本文,读者将全面掌握委托与事件的使用技巧,提升应用程序的设计与开发水平。
523 7
|
存储 人工智能 关系型数据库
云数据库是什么数据库?
云数据库是部署在云计算环境中的数据库服务,用户无需自行搭建硬件和软件环境,通过互联网即可便捷使用。相比传统数据库,云数据库降低了成本和使用门槛,具备强大的扩展性和灵活性,支持多种数据存储模型,并借鉴了关系型数据库的特性如ACID事务处理。它能够应对海量数据和高并发访问需求,适应数字化时代的挑战,未来还将融合更多新技术,进一步提升其功能和应用范围。
907 2
|
机器学习/深度学习 TensorFlow 算法框架/工具
《池化技术:深度学习热点背后的神秘力量,探寻最大池化与平均池化如何引领图像革命》
【8月更文挑战第21天】池化技术是深度学习中关键的特征提取手段,通过下采样减少数据维度和计算量,同时保持核心特征。主要分为最大池化和平均池化:前者选取局部区域的最大值,保留显著特征并具平移不变性;后者计算区域平均值,平滑噪声并稳定输出。两者依据任务需求选择,如图像分类偏好最大池化以突出关键特征,而去噪任务则倾向平均池化以平滑图像。
609 0
|
网络协议 应用服务中间件 nginx
性能提升-如何设置Windows操作系统TIME_WAIT状态的TCP连接快速回收时间?
性能提升-如何设置Windows操作系统TIME_WAIT状态的TCP连接快速回收时间?
837 0
|
存储 编解码 负载均衡
通俗易懂讲解 nginx-rtmp-module 是干嘛的?
通俗易懂讲解 nginx-rtmp-module 是干嘛的?
550 0
|
网络安全 网络架构
一文带大家,彻底了解【NAT技术-网络地址转换】
一文带大家,彻底了解【NAT技术-网络地址转换】
1605 0
一文带大家,彻底了解【NAT技术-网络地址转换】
|
SQL 程序员 测试技术
SqlServer的with(nolock)关键字的用法介绍
数据库写查询语句的时候,为了提升查询性能,往往会在查询的表后面加一个nolock,或者是with(nolock),其目的就是查询的时候是不锁定表,从而提高查询速度的目的。但如果同一时间有多个用户访问同一资源的时候,如果并发用户对该资源做了修改。则会对其他用户访问该数据造成数据不一致的情况
SqlServer的with(nolock)关键字的用法介绍
|
存储 编解码 缓存
Hi3516开发笔记(十):Qt从VPSS中获取通道图像数据存储为jpg文件
上一篇已经将himpp套入qt的基础上进行开发。那么qt中拿到frame则是很关键的交互,这是qt与海思可能编解码交叉开发的关键步骤。
Hi3516开发笔记(十):Qt从VPSS中获取通道图像数据存储为jpg文件