接口名称:红包无线支付接口
英文名称:alipay.fund.coupon.order.app.pay
产品首页:[url]https://openclub.alipay.com/read.php?tid=12180&fid=72[/url]
下一步:[url]https://openclub.alipay.com/read.php?tid=13609&fid=72[/url]
一、注意事项
1、适用于用户在手机移动端商户app中进行红包的发放,可以通过唤起支付宝app进行支付。
2、红包无线支付接口调用方法必须是sdkExecute()。
3、客户端代码调用方式:
(1)红包无线支付Android调用说明:[url]https://docs.open.alipay.com/204/105296/[/url]
(2)红包无线支付IOS调用说明:[url]https://docs.open.alipay.com/204/105295/[/url]
客户端调试工具使用教程:[url]https://openclub.alipay.com/read.php?tid=7695[/url]
支付宝客户端demo:[url]https://docs.open.alipay.com/54/104509[/url]
二、参数说明
1、out_order_no:商户的授权资金订单号,可用于后续打款接口,保持唯一性;
2、out_request_no:商户本次资金操作的请求流水号,同一商户每次不同的资金操作请求,商户请求流水号不要重复;
注:out_order_no不相同的情况下,out_request_no参数值相同可调用成功,建议记录out_order_no参数为准。
3、pay_timeout:最晚付款时间,逾期关闭。取值范围:1m~7d;
三、接口请求示例
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); AlipayFundCouponOrderAppPayRequest request = new AlipayFundCouponOrderAppPayRequest(); AlipayFundCouponOrderAppPayModel model = new AlipayFundCouponOrderAppPayModel(); model.setOutOrderNo("20171228924"); model.setOutRequestNo("jm20171228999"); model.setOrderTitle("jm发送红包"); model.setAmount("0.01"); request.setBizModel(model); //接口调用方式必须使用sdkExecute; AlipayFundCouponOrderAppPayResponse response = alipayClient.sdkExecute(request); if(response.isSuccess()){ System.out.println("调用成功"); } else { System.out.println("调用失败"); } System.out.println(response.getBody()); } }
返回信息:
alipay_sdk=alipay-sdk-java-3.1.0&app_id=2014100900013222&biz_content=%7B%22amount%22%3A%220.01%22%2C%22order_title%22%3A%22jm%E5%8F%91%E9%80%81%E7%BA%A2%E5%8C%85%22%2C%22out_order_no%22%3A%2220171228929%22%2C%22out_request_no%22%3A%22jm20171228999%22%7D&charset=utf-8&format=json&method=alipay.fund.coupon.order.app.pay&sign=WkTIq0Blw9JpgrsXoorFJFX2cmQD5gdb4aRp5CGnsAxTVMl3PLkms16FVyHrbY78tsUSAeknnFh8mHDaPczXc9Vunbc%2FN304752uSLO%2BXoJVY8jjnrqwBmVRGnFQP%2FduPbo0%2BtULJbtEeFIzYnQ%2FqB4bUpPOenSvM8J4NFwi%2BE%2FUzCVj8uO8jEMHCeI4%2BzDq2Yxx4yVu%2BOudu%2BCfin5560kVChQHJqENQL6BRY4yLPkWITMNGyAafUc2rqZ7TB1bOFchh33GL1fkw1IgdAy1ExyhVcCA8mz6aegNk0jqnG%2F5gPRKo9%2BHhD9mRI1WvlAKfgnAus57hIL4BZMi2DCMJw%3D%3D&sign_type=RSA2×tamp=2019-03-06+16%3A32%3A40&version=1.0
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 AlipayFundCouponOrderAppPayRequest (); $request->setBizContent("{" . ""out_order_no":"8077735255938025"," . ""out_request_no":"8077735255634078"," . ""order_title":"jm发送红包"," . ""amount":1," . ""pay_timeout":"1h"" . "}"); // $request->setNotifyUrl('请填写您的异步通知地址'); $result = $aop->sdkExecute ( $request); echo $result;
返回信息:
alipay_sdk=alipay-sdk-php-20180705&app_id=2014100900013222&biz_content=%7B%22out_order_no%22%3A%228077735255938025%22%2C%22out_request_no%22%3A%228077735255634078%22%2C%22order_title%22%3A%22jm%E5%8F%91%E9%80%81%E7%BA%A2%E5%8C%85%22%2C%22amount%22%3A1%2C%22pay_timeout%22%3A%221h%22%7D&charset=utf-8&format=json&method=alipay.fund.coupon.order.app.pay&sign_type=RSA2×tamp=2019-03-06+08%3A36%3A32&version=1.0&sign=aeOhd682TDUX7QbPtG6L1z%2FZ%2B1fVI8TDZ0m3EYljDI3MqtgzKBmm8rnDorR0rAn7GKUduzugAYfgf0Af02xMKezt8u0LaMSxIR%2Byb2uZ8TkIgmzIyD%2BRuuHOhSMfQslIxfOsi6IWzC6Q1GCoqiCOoC%2BFCTn34meDkPTyDpa8XzAkCYyGfh0fmmjNq5foTIhlnYKDcuuv6ch5w%2FFl3czSNRKXQLKkQ8nlXDWoeeqMl4I1U1zpWLCBaBTBZ9dDN4%2BpOmrvzmIchuh1XSfEGFHWzSoBedYIgqVWg%2FxGvJq7henEE3moVu5i9oLLJnyVEBvmJz2g2ZpBma8OhGI9SZTGyA%3D%3D
.NET版请求示例
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayFundCouponOrderAppPayRequest request = new AlipayFundCouponOrderAppPayRequest(); request.BizContent="{" + ""out_order_no":"8077735255938025"," + ""out_request_no":"8077735255634078"," + ""order_title":"jm发送红包"," + ""amount":1," + ""pay_timeout":"1h"" + " }"; AlipayFundCouponOrderAppPayResponse response = client.sdkExecute(request); Response.Write(response.Body);
四、异步通知
触发通知类型
异步通知示例
支付成功后,触发异步通知,notify_url地址接收通知如下:
http://支付接口设置的异步地址?notify_type=fund_auth_pay¬ify_id=91722adff935e8cfa58b3aabf4dead6ibe¬ify_time=2017-02-16 21:46:15&sign_type=RSA2&sign=WcO+t3D8Kg71dTlKwN7r9PzUOXeaBJwp8/FOuSxcuSkXsoVYxBpsAidprySCjHCjmaglNcjoKJQLJ28/Asl93joTW39FX6i07lXhnbPknezAlwmvPdnQuI01HZsZF9V1i6ggZjBiAd5lG8bZtTxZOJ87ub2i9GuJ3Nr/NUc9VeY=&auth_no=null&out_order_no=null&operation_id=null&out_request_no=null&operation_type=PAY&amount=null&status=SUCCESS&gmt_create=null&gmt_trans=null&payer_logon_id=null&payer_user_id=null
五、显示效果
支付宝钱包账单显示效果
如果还是报错,请按如下方式进行提问:
正确提问方式:使用环境(沙箱还是正式环境)+接口名称(中文+英文)+ 请求参数 + 报错信息详情