接口名称:红包退回接口
英文名称:alipay.fund.coupon.order.refund
产品首页:[url]https://openclub.alipay.com/read.php?tid=12180&fid=72[/url]
上一步:[url]https://openclub.alipay.com/read.php?tid=13609&fid=72[/url]
下一步:[url]https://openclub.alipay.com/read.php?tid=13612&fid=72[/url]
一、注意事项
1、未领取的红包,可通过红包退回接口。
2、当收发现金红包支付宝退款时,是有异步通知的,通知地址是支付接口的异步通知地址;
3、异步说明:
(1)红包退回接口调用进行退款的异步通知是通过红包退回接口设置的notify_url地址进行接收;
(2)无论是全额退款,还是部分退款,只要退款成功,notify_type=fund_stdtrustee_refund.success就会触发异步通知;
(3)没有调用接口,而是超时退款的异步通知是根据支付接口设置的notify_url地址进行接收;
二、参数说明
1、auth_no:发放红包时产生的支付宝资金订单号(支付接口返回的auth_no);
2、out_request_no:商户本次资金操作的请求流水号;
3、amount:退款金额;
三、接口请求示例
JAVA版请求示例
public static void main(String[] args) throws AlipayApiException { //在SDK调用前需要进行初始化 AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, AlipayConfig.format, AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type); AlipayFundCouponOrderRefundRequest request = new AlipayFundCouponOrderRefundRequest(); AlipayFundCouponOrderRefundModel model = new AlipayFundCouponOrderRefundModel(); //支付时传入的支付宝的资金授权订单号 model.setAuthNo("2018081710002001860231318890"); //商户本次资金操作的请求流水号 model.setOutRequestNo("refund20171228254"); model.setAmount("0.01"); model.setRemark("支付后,剩余红包退款"); request.setBizModel(model); request.setNotifyUrl("http://退款异步发送地址"); AlipayFundCouponOrderRefundResponse response=alipayClient.execute(request); System.out.println(response.getBody()); }
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 AlipayFundCouponOrderDisburseRequest (); $request = new AlipayFundCouponOrderRefundRequest (); request.setNotifyUrl("http://退款异步发送地址"); $request->setBizContent("{" . ""auth_no":"2018081710002001860231318890"," . ""out_request_no":"refund20171228254"," . ""amount":0.01," . ""remark":"支付后,剩余红包退款"" . "}"); $result = $aop->execute ( $request); var_dump($result);
.NET版本请求示例
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayFundCouponOrderRefundRequest request = new AlipayFundCouponOrderRefundRequest(); request.BizContent="{" + ""auth_no":"2018081710002001860231318890"," + ""out_request_no":"refund20171228254"," + ""amount":0.01," + ""remark":"支付后,剩余红包退款"" + " }"; request.setNotifyUrl("http://退款异步发送地址"); AlipayFundCouponOrderRefundResponse response=client.execute(request); Response.Write(response.Body);
四、异步通知
触发通知类型
异步通知示例
支付成功后,触发异步通知,notify_url地址接收通知如下
https://退款接口设置的异步地址?notify_type=fund_stdtrustee_refund.success¬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=REFUND&amount=退款金额&status=null&gmt_create=null&gmt_trans=null&payer_logon_id=null&payer_user_id=null
五、显示效果
总的流程页面账单显示如下:
如果还是报错,请按如下方式进行提问:
正确提问方式:使用环境(沙箱还是正式环境)+接口名称(中文+英文)+ 请求参数 + 报错信息详情