场景:
用户点击红包进行领取。
调用流程:
需要注意的点:
1.在调用接口时,必须传入发送红包时产生的支付宝授权资金订单号或商户授权资金订单号,用于关联该红包。红包金额会进入领取人的支付宝余额。
2.如果能获取到用户的user_id,我们强烈建议传递payee_user_id参数;能用payee_user_id就别用payee_logon_id;payee_logon_id存在用户被抢夺的场景,对于这种场景,我们是直接报错的,以杜绝资金打错账户。
3.异步通知示例:
[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&payee_logon_id=null&payee_user_id=null
代码示例:
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"); AlipayFundCouponOrderDisburseRequest request = new AlipayFundCouponOrderDisburseRequest();request.setBizContent("{" +"\"out_order_no\":\"201802230908111\"," +"\"deduct_auth_no\":\"2018022310002001400250708573\"," +"\"deduct_out_order_no\":\"20180223090730111\"," +"\"out_request_no\":\"201802230908111\"," +"\"order_title\":\"红包打款\"," +"\"amount\":0.01," +"\"payee_user_id\":\"2088xxxxxxxxxxxx\"" +" }"); AlipayFundCouponOrderDisburseResponse 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 { }
如果大家还有什么疑问欢迎帖子下面跟帖追问吐槽