场景:
将剩余的未领取的红包资金退回红包发送方。
调用流程:
需要注意的点:
1.商户系统调用红包退回接口
alipay.fund.coupon.order.refund完成红包剩余资金的退回,这个是提供给商户用的接口层面的退款。此外,支付宝端提供超时自动退款能力,用于将剩余资金全部退回,自助签约默认超时退款时间为48小 时;支付宝自动退款能力也有异步通知,会通知到支付接口的异步通知地址。
2.异步通知示例:
[url]https://www.merchant.com/receive_notify.htm?notify_type=trade_status_sync¬ify_id=91722adff935e8cfa58b3aabf4dead6ibe¬ify_time=2017-02-16[/url] 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=null&amount=null&status=null&gmt_create=null&gmt_trans=null&payer_logon_id=null&payer_user_id=null
3.out_request_no参数是商户本次资金操作的请求流水号 ,这里请不要使用和支付接口相同的参数值,同一商户每次不同的资金操作请求,商户请求流水号不要重复。
代码示例:
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json","UTF-8", AlipayConfig.alipay_public_key,"RSA");
AlipayFundCouponOrderRefundRequest request = new AlipayFundCouponOrderRefundRequest();
request.setBizContent("{" +
"\"auth_no\":\"2018022310002001400250708573\"," +
"\"out_request_no\":\"20180222112830333\"," +
"\"amount\":0.01," +
"\"remark\":\"红包退款\"" +
"}");
AlipayFundCouponOrderRefundResponse response;
try {
response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("调用成功"+response.getBody());
} else {
System.out.println("调用失败"+response.getBody());
}
} catch (AlipayApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
}
如果大家还有什么疑问欢迎帖子下面跟帖追问吐槽