营销活动送红包接入说明(Java版)

简介: 营销活动送红包注意事项:[url]https://openclub.alipay.com/read.php?tid=12196&fid=71[/url]一、JAVA示例demoJAVA版demo:download:营销活动送红包Java版.

营销活动送红包注意事项:[url]https://openclub.alipay.com/read.php?tid=12196&fid=71[/url]

一、JAVA示例demo

JAVA版demo:download:营销活动送红包Java版.zip

二、调用接口

1、创建现金活动接口请求示例

public static void main(String[] args) throws AlipayApiException {AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.URL ,AlipayConfig.APPID,AlipayConfig.RSA_PRIVATE_KEY,"json",AlipayConfig.CHARSET,AlipayConfig.ALIPAY_PUBLIC_KEY,AlipayConfig.SIGNTYPE );	AlipayMarketingCampaignCashCreateRequest request = new AlipayMarketingCampaignCashCreateRequest();		        request.setBizContent("{" +				"\"coupon_name\":\"煜雨创建营销活动送红包\"," +           //prize_type现金红包的发放形式,fixed为固定金额,random为随机金额         				"\"prize_type\":\"random\"," +            //total_money活动发放的现金总金额,最小金额1.00元				"\"total_money\":\"1.20\"," +            //total_num红包发放个数,最小1个,最大10000000个;必须设置为整数				"\"total_num\":\"1\"," +				"\"prize_msg\":\"煜雨\"," +				"\"start_time\":\"NowTime\"," +				"\"end_time\":\"2018-09-18 12:48:30\"," +				"\"merchant_link\":\"https://www.baidu.com\"," +				"\"send_freqency\":\"D2|L10\"" +				"}");	request.setNotifyUrl("http://106.14.187.178/opendevtools/notify/do/fd2fe5b6-394b-4001-a5a9-7dd0ef1eb2d1");	AlipayMarketingCampaignCashCreateResponse response = alipayClient.execute(request);								if(response.isSuccess()){					System.out.println("调用成功");							} else {					System.out.println("调用失败");		}					System.out.println(response.getBody());   //打印完整的响应报文信息					System.out.println("支付链接"+response.getPayUrl());  //打印支付链接	}

接口调用成功示例:

调用成功{"alipay_marketing_campaign_cash_create_response":{"code":"10000","msg":"Success","crowd_no":"w0OhdveSbymE1uPfrbG_EEfbDdRkgBfOkWg6XF1qZ17MnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180830159410190701192603150004","pay_url":"http%3A%2F%2Fauthcenter%2Ealipaydev%2Ecom%3Fgoto%3Dhttp%3A%2F%2Fpromoprod%2Ealipaydev%2Ecom%2Fquery%2FopenCashCrowdPay%2Ehtm%3FcrowdNo%3Dw0OhdveSbymE1uPfrbG%5FEEfbDdRkgBfOkWg6XF1qZ17MnSZ96O%2DzxUfKlHp5cxmx"},"sign":"BG3D58zG/c/guiR18hjErSThF7T15I6cTtJ4YuGT3s5SxeRHhRGRdmhovwjicNR7YQMRPlr7TWmRcxZfAFqIbytW83MzWAQd266znxskeWtPqh5/pOINI4bl9AxAxEfy5x+6wsp/gwwL6YRNJKZbP/0Pl5Vq2bWIevpcMxhRI5iv/F5o4dPhzrXqMG1sPDc+UeY/Y4RGQAtdFa3hOHik1GrKP8umB+235FIYV/hwi9a/WAKjM1o0SpHHfRT18oa5ct/RY5DgRmBPIJUPqu/92nYsgs1hZAZa0g3JCW10VqPyMvcnxJP9UCJadxUJg8AnIa03vkQYM3Yqq2YvRdFlaw=="}支付链接:http%3A%2F%2Fauthcenter%2Ealipaydev%2Ecom%3Fgoto%3Dhttp%3A%2F%2Fpromoprod%2Ealipaydev%2Ecom%2Fquery%2FopenCashCrowdPay%2Ehtm%3FcrowdNo%3Dw0OhdveSbymE1uPfrbG%5FEEfbDdRkgBfOkWg6XF1qZ17MnSZ96O%2DzxUfKlHp5cxmx

参数说明:

1>.prize_type:现金红包的发放形式,fixed为固定金额,random为随机金额;

2>.total_money:活动发放的现金总金额,最小金额1.00元

3>.total_num:红包发放个数,最小1个,最大10000000个;必须设置为整数。

4>.pay_url:支付url,有效期为24小时,需要商家先对其进行UrlDecode处理,然后使用卖家账号登录支付。

 

支付流程:

将支付链接pay_url进行decode处理,然后在浏览器直接访问该url使用卖家账号

2、触发现金红包活动接口请求示例

public static void main(String[] args) throws AlipayApiException {AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.URL ,AlipayConfig.APPID,AlipayConfig.RSA_PRIVATE_KEY,"json",AlipayConfig.CHARSET,AlipayConfig.ALIPAY_PUBLIC_KEY,AlipayConfig.Sign_Type);     AlipayMarketingCampaignCashTriggerRequest request = new AlipayMarketingCampaignCashTriggerRequest();	        request.setBizContent("{" +        //user_id用户唯一标识,可通用户信息授权接口获取		    "\"user_id\":\"2088102174701092\"," +		    "\"crowd_no\":\"eHPLr-8bu0Y38JNVd3gldY4e50c_CcaYsm039bIsTafMnSZ96O-zxUfKlHp5cxmx\"," +		    "\"login_id\":\"dvnvqi3054@sandbox.com\"," +        //order_price单位为分		    "\"order_price\":\"1\"," +		    "\"out_biz_no\":\"20180210145831454\"" +		    "}");   AlipayMarketingCampaignCashTriggerResponse response = alipayClient.execute(request);             		     if(response.isSuccess()){				 	System.out.println("调用成功");			} else {				 	System.out.println("调用失败");			}				 System.out.println(response.getBody());//打印完整的响应报文信息		}

接口调用成功示例:

调用成功{"alipay_marketing_campaign_cash_trigger_response":{"code":"10000","msg":"Success","biz_no":"20180508110070001502090000070793","coupon_name":"煜雨创建营销活动送红包","out_biz_no":"2018021014584545454","partner_id":"2088102170119260","prize_amount":"0.02","prize_msg":"煜雨小哥哥在测试","repeat_trigger_flag":"false","trigger_result":"true"},"sign":"XXX"}

参数说明:

1>.user_id:用户唯一标识,可通过用户信息授权接口获取;

2>.order_price:设置发送红包的金额,单位为分,100代表1元;

3>.login_id:用户登录账号名:邮箱或手机号。user_id与login_id至少有一个非空,都非空时以user_id为准。

3、更改现金活动状态接口请求示例

public static void main(String[] args) throws AlipayApiException {AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.URL ,AlipayConfig.APPID,AlipayConfig.RSA_PRIVATE_KEY,"json",AlipayConfig.CHARSET,AlipayConfig.ALIPAY_PUBLIC_KEY,"RSA2");		AlipayMarketingCampaignCashStatusModifyRequest request = new AlipayMarketingCampaignCashStatusModifyRequest();		        request.setBizContent("{" +		    "\"crowd_no\":\"w0OhdveSbymE1uPfrbG_EEfbDdRkgBfOkWg6XF1qZ17MnSZ96O-zxUfKlHp5cxmx\"," +	//camp_status只能设置为PAUSE或者READY或者CLOSED            "\"camp_status\":\"CLOSED\"" +  //PAUSE或者READY或者CLOSED		    "}");		AlipayMarketingCampaignCashStatusModifyResponse response = alipayClient.execute(request);								if(response.isSuccess()){					System.out.println("调用成功");	            } else {					System.out.println("调用失败");                }					System.out.println(response.getBody());//打印完整的响应报文信息				}

接口调用成功示例:

调用成功{"alipay_marketing_campaign_cash_status_modify_response":{"code":"10000","msg":"Success"},"sign":"GnpwpMfUdFwQIyyqqdNCTP6obNctCaJ+RE7DwfAYABJTRz5ulLZ6ZZ7jYbur+h//hfG4FNAcKkJ5+yWNWGDj+fWRH25NUoyfZM0PTghWqhZaCuOMTnCn7R5Pm+jVwHDu9ngl8JNY816xD9TcQtqFaUdUufGFxGo/9eY8hmnubSdpp9/6iZn09x//TJPPu4DNU0nWELO3NtDOA/qftg9zWmoE5/sFxqTYbgcLOA71EceTZQ/4DwWpavatOhewATUWflVXP9DwWjBNeONFzUuBwl6BJZOCw3H9ldhC+37x4HDiXoK2E68NZaZRMincmWayrY4SHBq20SHvQUR/VqnOxw=="}

参数说明:

camp_status:修改后的活动状态,只能设置为PAUSE或者READY或者CLOSED。

4、现金活动列表查询接口请求示例

public static void main(String[] args) throws AlipayApiException {AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.URL ,AlipayConfig.APPID,AlipayConfig.RSA_PRIVATE_KEY,"json",AlipayConfig.CHARSET,AlipayConfig.ALIPAY_PUBLIC_KEY,AlipayConfig.SIGNTYPE );		AlipayMarketingCampaignCashListQueryRequest request = new AlipayMarketingCampaignCashListQueryRequest();		request.setBizContent("{" +    //要查询的活动状态,不填默认返回所有类型。 		可填:ALL:所有类型的活动 	CREATED:已创建未打款 PAID:已打款 READY:活动已开始 		PAUSE:活动已暂停 CLOSED:活动已结束 	SETTLE:活动已清算		    "\"camp_status\":\"ALL\"," +				    "\"page_size\":\"10\"," +		    "\"page_index\":\"1\"" +		    "}");AlipayMarketingCampaignCashListQueryResponse response = alipayClient.execute(request);												if(response.isSuccess()){					System.out.println("调用成功");					} else {					System.out.println("调用失败");									}					System.out.println(response.getBody());//打印完整的响应报文信息				}

接口调用成功示例:

调用成功{"alipay_marketing_campaign_cash_list_query_response":{"code":"10000","msg":"Success","camp_list":[{"camp_status":"READY","coupon_name":"煜雨创建营销活动送红包","crowd_no":"w0OhdveSbymE1uPfrbG_EEfbDdRkgBfOkWg6XF1qZ17MnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180830159410190701192603150004"},{"camp_status":"READY","coupon_name":"煜雨创建营销活动送红包","crowd_no":"HBEKgV6IoDNNYu9QPWuRfOTbl9onIBXJZNxcovy8Ip7MnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180807169410190701192605875004"},{"camp_status":"CLOSED","coupon_name":"煜雨创建营销活动送红包","crowd_no":"eHPLr-8bu0Y38JNVd3gldY4e50c_CcaYsm039bIsTafMnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180508189410190701192602170004"},{"camp_status":"CLOSED","coupon_name":"煜雨创建营销活动送红包","crowd_no":"ytn7dvcdDr4ZppanSialdE6zaP6FAl46POVbeB41ad7MnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180508199410190701192600293004"},{"camp_status":"CLOSED","coupon_name":"煜雨创建营销活动送红包","crowd_no":"ytn7dvcdDr4ZppanSialdOcIA8xg4-BhoUcNjxy6nsXMnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180508199410190701192606860004"},{"camp_status":"CLOSED","coupon_name":"煜雨创建营销活动送红包","crowd_no":"eHPLr-8bu0Y38JNVd3gldWAacNVCrHVoyD8Jhip9tk7MnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180508189410190701192604835004"},{"camp_status":"CLOSED","coupon_name":"煜雨创建营销活动送红包","crowd_no":"KwX4a_mS09qjJRH1sLBDyluNVmLumCnob8LmRao4-YHMnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180424139410190701192607007004"},{"camp_status":"CLOSED","coupon_name":"煜雨创建营销活动送红包","crowd_no":"uuhmrarf657_c9c8gP3LesE7PeQbvTss-XwgIiZMNbPMnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180424129410190701192605930004"},{"camp_status":"CLOSED","coupon_name":"煜雨创建营销活动送红包","crowd_no":"H00vSqh2Pn3L6-nmXEODBLUpCKBnQU-8p-vWLGypX4HMnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180403179410190701192608233004"},{"camp_status":"CLOSED","coupon_name":"煜雨创建营销活动送红包","crowd_no":"uuhmrarf657_c9c8gP3LeqLttrpGR4wi92Qsw4NU-3TMnSZ96O-zxUfKlHp5cxmx","origin_crowd_no":"20180424129410190701192606722004"}],"page_index":"1","page_size":"10","total_size":"26"},"sign":"pl7kRAEawvWw8MaepR1VrZrmLhjD3FpvHxhA31zOROGa18WgWOnPQb8q0Ev7fkPVojnjE3T+o4Yuldnjl15W0b9ozjk1/pOat7Tro5GNSadMKzj4fQMV0Cb3XdwEMypAf17+hNIILj+Jh55HJFH1tCSKbQLlsnTZqnolrZnztxGQnvmfewnoxQ/9PO+o0W7/DztqKAWYpLDSlU5Z+zKHuFR4d/28wY+F7Pq1bFSQ1MpF038BSlDB0YCrFXkxyVJy7MkxtzNzPs2v1wbZn9/XifZojX5/dHc2TjLoN5c89oaOhdDEr50qs7diNhbFIlRQlLi9vZ4I6aNyJjBY5dQtLQ=="}

参数说明:

camp_status要查询的活动状态,不填默认返回所有类型。

5、现金活动详情查询接口请求示例

public static void main(String[] args) throws AlipayApiException {AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.URL ,AlipayConfig.APPID,AlipayConfig.RSA_PRIVATE_KEY,"json",AlipayConfig.CHARSET,AlipayConfig.ALIPAY_PUBLIC_KEY,AlipayConfig.SIGNTYPE );		AlipayMarketingCampaignCashDetailQueryRequest request = new AlipayMarketingCampaignCashDetailQueryRequest();		        request.setBizContent("{" +		    "\"crowd_no\":\"w0OhdveSbymE1uPfrbG_EEfbDdRkgBfOkWg6XF1qZ17MnSZ96O-zxUfKlHp5cxmx\"" +		    "}");		AlipayMarketingCampaignCashDetailQueryResponse response = alipayClient.execute(request);								if(response.isSuccess()){					System.out.println("调用成功");}                 else {					System.out.println("调用失败");					}					System.out.println(response.getBody());//打印完整的响应报文信息				}

接口调用成功示例:

调用成功{"alipay_marketing_campaign_cash_detail_query_response":{"code":"10000","msg":"Success","camp_status":"READY","coupon_name":"煜雨创建营销活动送红包","crowd_no":"w0OhdveSbymE1uPfrbG_EEfbDdRkgBfOkWg6XF1qZ17MnSZ96O-zxUfKlHp5cxmx","end_time":"2018-09-18 12:48:30","origin_crowd_no":"20180830159410190701192603150004","prize_msg":"煜雨","prize_type":"random","send_amount":"0.00","start_time":"2018-08-30 15:25:27","total_amount":"1.20"},"sign":"XBcs6KCmwa/RRKDDf+Bq/yJmnCUBfnqMHbZ3hneoMaMglKJ+qZsSMjceL5SZ/jH17DUpLLk9Us7y1plCgVBPJmJNkj9PVoqLn+ezWdgQXK8Jk0STCrgnZf/gO2W9WHUg0v5wcvDb2R10D4qbneLQxjCv3hx4lrg2GEp88wlopMDuhOuZnY9cIk3aGKKA+A/SO5tzCb4yggYReSQQdnRJEeM4wI5LJyXQGkEvOv+CO42dgaJoudD2sx9yzCdJ0gKt8QyqoIIBFeXsO9dDz9U3I8+xE5GV54Y2Fcmb1aIK01mYP8KLqfUnzYEzTpqmWJU2Yh3Lqnmf3h2QzAd3QEJHjA=="}

三、显示效果

商户创建完成并生效红包活动后,可在支付宝商家红包后台查看发放情况并下载账单(账单将以T+1时效更新)。

商家红包后台地址:[url]https://hb.alipay.com/mhb/giftList.htm[/url]

钱包中可查询红包的账单信息:

红包说明是固定格式:沙箱环境是:沙箱环境-现金红包;正式环境是:公司名称-现金红包

 

如果还是报错,请按如下方式进行提问:

正确提问方式:使用环境(沙箱还是正式环境)+接口名称(中文+英文)+ 请求参数 + 报错信息详情

目录
相关文章
|
7月前
|
JavaScript Java 测试技术
基于Java的江苏融汇房地产营销策划有限公司的宣传网站的设计与实现(源码+lw+部署文档+讲解等)
基于Java的江苏融汇房地产营销策划有限公司的宣传网站的设计与实现(源码+lw+部署文档+讲解等)
55 0
基于Java的江苏融汇房地产营销策划有限公司的宣传网站的设计与实现(源码+lw+部署文档+讲解等)
|
监控 Java API
JAVA实现接入企业微信报警
JAVA实现接入企业微信报警
629 0
JAVA实现接入企业微信报警
|
Java 程序员
Java面向对象8——接口(内含IDEA中有关创建接口的创建说明)
上一次我们说了抽象方法的存在是因为父类可以抽取子类中的共性方法,但是共性方法内实现方法不同所以要将共性方法写成抽象方法,那么如果子类中有一个“另类”不需要这个方法的话,我们就无法使用抽象方法了,而是要使用接口,哪个子类需要用,就继承该接口
385 0
Java面向对象8——接口(内含IDEA中有关创建接口的创建说明)
|
Java
Java运算符讲解附例子说明(大全)
Java运算符分为六大:算术运算符、赋值运算符、比较运算符、逻辑运算符、条件(三目)运算符、位运算符
99 0
Java运算符讲解附例子说明(大全)
|
小程序 Java 测试技术
【Java 微信公众号开发】① 介绍、测试号、接入
微信公众号是开发者或商家在微信公众平台上申请的应用账号。该帐号与 QQ 账号互通,平台上实现和特定群体的文字、图片、语音、视频的全方位沟通、互动 ,形成了一种主流的线上线下微信互动营销方式。 微信公众号是用户在微信公众平台注册的一个账号。账号开通后,可在微信公众号里发视频、图片、文字等推销你的商品或分享生活经验等。 微信公众号类似于一个网站。可作为公司名片、个人名片,可做成商城、互动社区等。管理员可通过微信公众平台发送文章,关注了微信公众号的用户可查看到管理员发送的文章。
701 0
【Java 微信公众号开发】① 介绍、测试号、接入
|
Java
把GBK源码文件转UTF8的JAVA代码说明
把GBK源码文件转UTF8的JAVA代码说明
141 0
|
小程序 Java
Java——静态字段和实例字段的初始化说明(概念理解+应用举例)
Java——静态字段和实例字段的初始化说明(概念理解+应用举例)
Java——静态字段和实例字段的初始化说明(概念理解+应用举例)
|
运维 前端开发 安全
人人都是 Serverless 架构师 | “盲盒抽奖”创意营销活动实践
当 Serverless 与低代码这两个不同的技术共同相交于同一个业务时会有怎样的价值展现?本文以 “盲盒抽奖” 这个 Serverless Devs 做过的创意营销活动为例,为大家讲述 Serverless 和低代码是如何搭配来满足一个业务诉求的。
人人都是 Serverless 架构师 | “盲盒抽奖”创意营销活动实践