支付宝卡包——创建卡劵模板(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' 
目录
相关文章
vue3+vite项目中使用svg图标
vue3+vite项目中使用svg图标
1619 0
|
监控 负载均衡 算法
构建高效微服务架构的五大核心组件
【4月更文挑战第6天】随着现代业务需求的多样化和复杂性增加,传统的单体应用已无法满足快速迭代与灵活部署的需求。微服务架构应运而生,以其高度模块化、独立部署和可伸缩性成为企业转型的关键。本文聚焦于构建高效微服务架构的核心组件,从服务发现、配置管理、负载均衡、容错处理到服务监控五个方面进行深入剖析,旨在提供一套全面的技术指南以支持后端开发的最佳实践。
|
算法 Python
Python算法——广度优先搜索
Python算法——广度优先搜索
495 0
|
7月前
|
运维 安全 网络安全
等保测评全面解析
等保测评是依据国家信息安全等级保护制度,对信息系统安全保护状况进行检测评估的活动。其目标是确保信息系统在各阶段符合安全等级要求,保障系统保密性、完整性和可用性。测评涵盖技术与管理两方面:技术层面包括物理环境、网络通信、设备计算及应用数据安全;管理层面涉及制度、机构、人员及建设运维管理。测评流程分为准备、方案设计、现场测评和报告编制四个阶段。实践中需做好测评前准备、测评中配合以及测评后整改优化,以持续提升信息安全水平。
755 0
|
10月前
|
云安全 边缘计算 监控
R9-9950X服务器 超越频率桎梏,企业级稳定性的新标杆!
德迅云安全推出的R9 9950X服务器专为多线程、高负载场景优化,基于AMD Ryzen 9系列的Zen 4架构,采用5nm工艺和CCD/CIOD分离设计,具备16核32线程全大核策略,确保高效能与低功耗。其自适应功耗管理和强化供电设计,保障了在企业级应用中的卓越稳定性和持续性能。搭配德迅卫士主机安全软件,提供实时监控、远程防护及资产清点等全面安全措施,适用于云计算、虚拟化和边缘计算等场景,为企业带来可靠的高性能解决方案。
|
安全 物联网 API
TEE是什么?现有TEE解决方案
TEE是什么?现有TEE解决方案
1767 0
|
机器学习/深度学习 人工智能 数据可视化
10个用于可解释AI的Python库
10个用于可解释AI的Python库
271 0
|
网络架构
合理设置 WLAN 频道以减少干扰
【8月更文挑战第24天】
494 0