mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-17 13:49:26 +08:00
🆕 #1529 微信支付退款增加支持单品退款和对应查询的接口
This commit is contained in:
@@ -256,6 +256,33 @@ public interface WxPayService {
|
||||
*/
|
||||
WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 申请退款API(支持单品).
|
||||
* 详见 https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_103&index=3
|
||||
*
|
||||
* 应用场景
|
||||
* 当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后,按照退款规则将支付款按原路退到买家帐号上。
|
||||
*
|
||||
* 注意:
|
||||
* 1、交易时间超过一年的订单无法提交退款;
|
||||
* 2、微信支付退款支持单笔交易分多次退款,多次退款需要提交原支付订单的商户订单号和设置不同的退款单号。申请退款总金额不能超过订单金额。 一笔退款失败后重新提交,请不要更换退款单号,请使用原商户退款单号。
|
||||
* 3、请求频率限制:150qps,即每秒钟正常的申请退款请求次数不超过150次
|
||||
* 错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款申请请求不超过6次
|
||||
* 4、每个支付订单的部分退款次数不能超过50次
|
||||
* 5、本接口支持单品优惠订单全额退款和单品优惠订单部分退款,推荐使用本接口,如果使用不支持单品优惠部分退款的历史接口,请看https://pay.weixin.qq.com/wiki/doc/api/jsapi_sl.php?chapter=9_4
|
||||
*
|
||||
* 接口地址
|
||||
* https://api.mch.weixin.qq.com/secapi/pay/refundv2
|
||||
* https://api2.mch.weixin.qq.com/secapi/pay/refundv2(备用域名)见跨城冗灾方案
|
||||
* </pre>
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @return 退款操作结果 wx pay refund result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
WxPayRefundResult refundV2(WxPayRefundRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 微信支付-查询退款.
|
||||
@@ -293,6 +320,29 @@ public interface WxPayService {
|
||||
*/
|
||||
WxPayRefundQueryResult refundQuery(WxPayRefundQueryRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 微信支付-查询退款API(支持单品).
|
||||
* 应用场景
|
||||
* 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
|
||||
* 注意:
|
||||
* 1、本接口支持查询单品优惠相关退款信息,且仅支持按微信退款单号或商户退款单号查询,若继续调用老查询退款接口,
|
||||
* 请见https://pay.weixin.qq.com/wiki/doc/api/jsapi_sl.php?chapter=9_5
|
||||
* 2、请求频率限制:300qps,即每秒钟正常的退款查询请求次数不超过300次
|
||||
* 3、错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款查询请求不超过6次
|
||||
*
|
||||
* 接口地址
|
||||
* https://api.mch.weixin.qq.com/pay/refundqueryv2
|
||||
* https://api2.mch.weixin.qq.com/pay/refundqueryv2(备用域名)见跨城冗灾方案
|
||||
* 详见 https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_104&index=4
|
||||
* </pre>
|
||||
*
|
||||
* @param request 微信退款单号
|
||||
* @return 退款信息 wx pay refund query result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
WxPayRefundQueryResult refundQueryV2(WxPayRefundQueryRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* 解析支付结果通知.
|
||||
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7
|
||||
|
||||
@@ -128,6 +128,22 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPayRefundResult refundV2(WxPayRefundRequest request) throws WxPayException {
|
||||
request.checkAndSign(this.getConfig());
|
||||
|
||||
String url = this.getPayBaseUrl() + "/secapi/pay/refundv2";
|
||||
if (this.getConfig().isUseSandboxEnv()) {
|
||||
url = this.getConfig().getPayBaseUrl() + "/sandboxnew/pay/refundv2";
|
||||
}
|
||||
|
||||
String responseContent = this.post(url, request.toXML(), true);
|
||||
WxPayRefundResult result = BaseWxPayResult.fromXML(responseContent, WxPayRefundResult.class);
|
||||
result.composePromotionDetails();
|
||||
result.checkResult(this, request.getSignType(), true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, String outRefundNo, String refundId)
|
||||
throws WxPayException {
|
||||
@@ -152,6 +168,18 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPayRefundQueryResult refundQueryV2(WxPayRefundQueryRequest request) throws WxPayException {
|
||||
request.checkAndSign(this.getConfig());
|
||||
|
||||
String url = this.getPayBaseUrl() + "/pay/refundqueryv2";
|
||||
String responseContent = this.post(url, request.toXML(), false);
|
||||
WxPayRefundQueryResult result = BaseWxPayResult.fromXML(responseContent, WxPayRefundQueryResult.class);
|
||||
result.composePromotionDetails();
|
||||
result.checkResult(this, request.getSignType(), true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException {
|
||||
return this.parseOrderNotifyResult(xmlData, null);
|
||||
|
||||
Reference in New Issue
Block a user