资金原路退回,如将红包中未领取的金额退还给红包发送者,参数详情点击参考文档 我这边分享一下java版的示例供大家参考,适用于jdk版本1.5及以上的开发环境
1.代码示例:
AlipayFundCouponOrderRefund{
public static void main(String[] args) throws AlipayApiException {
//在SDK调用前需要进行初始化
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", Config.appId, Config.privateKey, "json","utf-8", Config.alipayPulicKey, "RSA");
AlipayFundCouponOrderRefundRequest request = new AlipayFundCouponOrderRefundRequest();
AlipayFundCouponOrderRefundModel model = new AlipayFundCouponOrderRefundModel();
//支付时传入的支付宝的资金授权订单号
model.setAuthNo("2017122810002001950287006752");
//商户本次资金操作的请求流水号
model.setOutRequestNo("refund20171228254");
model.setAmount("0.01");
model.setRemark("红包退款");
request.setBizModel(model);
AlipayFundCouponOrderRefundResponse response=alipayClient.execute(request);
System.out.println(response.getBody());
}
}
2.请求成功返回:
{"alipay_fund_coupon_order_refund_response":{"code":"10000","msg":"Success","amount":"0.01","auth_no":"2017122810002001950287006752","gmt_trans":"2017-12-28 10:39:25","operation_id":"20171228312616259502","out_request_no":"refund20171228254","status":"SUCCESS"},"sign":"XXXX"}
3.每次退款OutRequestNo必须修改,否则会报“本次资金操作的请求流水号与之前有重复”
{"alipay_fund_coupon_order_refund_response":{"code":"40004","msg":"Business Failed","sub_code":"UNIQUE_VIOLATION","sub_msg":"退款失败,商户本次资金操作的请求流水号与之前有重复","out_request_no":"refund20171228254"},"sign":"XXXX"}
4.退款资金不能大于红包剩余资金
{"alipay_fund_coupon_order_refund_response":{"code":"40004","msg":"Business Failed","sub_code":"MONEY_NOT_ENOUGH","sub_msg":"本次操作退款的金额超过剩余可退款金额","out_request_no":"refund201712282541"},"sign":"XXXX"}
如有其它问题,欢迎论坛评论留言,如有不足之处也欢迎多多吐槽!!!