Skip to content

Commit c4f3834

Browse files
authored
🆕 #3737 【微信支付】增加V3服务商申请退款的接口
1 parent 03114b9 commit c4f3834

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,32 @@ public interface WxPayService {
839839
*/
840840
WxPayRefundV3Result refundV3(WxPayRefundV3Request request) throws WxPayException;
841841

842+
/**
843+
* <pre>
844+
* 微信支付-服务商申请退款.
845+
* 应用场景
846+
* 当交易发生之后一年内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付金额退还给买家,微信支付将在收到退款请求并且验证成功之后,将支付款按原路退还至买家账号上。
847+
*
848+
* 注意:
849+
* 1、交易时间超过一年的订单无法提交退款
850+
* 2、微信支付退款支持单笔交易分多次退款(不超50次),多次退款需要提交原支付订单的商户订单号和设置不同的退款单号。申请退款总金额不能超过订单金额。 一笔退款失败后重新提交,请不要更换退款单号,请使用原商户退款单号
851+
* 3、错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款申请请求不超过6次
852+
* 4、每个支付订单的部分退款次数不能超过50次
853+
* 5、如果同一个用户有多笔退款,建议分不同批次进行退款,避免并发退款导致退款失败
854+
* 6、申请退款接口的返回仅代表业务的受理情况,具体退款是否成功,需要通过退款查询接口获取结果
855+
* 7、一个月之前的订单申请退款频率限制为:5000/min
856+
*
857+
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_9.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_9.shtml</a>
858+
* 接口地址
859+
* https://api.mch.weixin.qq.com/v3/refund/domestic/refunds
860+
* </pre>
861+
*
862+
* @param request 请求对象
863+
* @return 退款操作结果 wx pay refund result
864+
* @throws WxPayException the wx pay exception
865+
*/
866+
WxPayRefundV3Result partnerRefundV3(WxPayPartnerRefundV3Request request) throws WxPayException;
867+
842868
/**
843869
* <pre>
844870
* 微信支付-查询退款.

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ public WxPayRefundV3Result refundV3(WxPayRefundV3Request request) throws WxPayEx
264264
return GSON.fromJson(response, WxPayRefundV3Result.class);
265265
}
266266

267+
@Override
268+
public WxPayRefundV3Result partnerRefundV3(WxPayPartnerRefundV3Request request) throws WxPayException {
269+
if (StringUtils.isBlank(request.getSubMchid())) {
270+
request.setSubMchid(this.getConfig().getSubMchId());
271+
}
272+
String url = String.format("%s/v3/refund/domestic/refunds", this.getPayBaseUrl());
273+
String response = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
274+
return GSON.fromJson(response, WxPayRefundV3Result.class);
275+
}
276+
267277
@Override
268278
public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, String outRefundNo, String refundId)
269279
throws WxPayException {

0 commit comments

Comments
 (0)