🎨 #3838 【微信支付】为starter添加了退款结果回调 URL 的配置支持,允许开发者在配置文件中统一配置退款通知地址

This commit is contained in:
buaazyl
2026-01-09 14:16:06 +08:00
committed by GitHub
parent 2c5a33917e
commit 72fa3b3301
8 changed files with 32 additions and 9 deletions

View File

@@ -230,7 +230,9 @@ public class WxPayRefundRequest extends BaseWxPayRequest {
if (StringUtils.isBlank(this.getOpUserId())) {
this.setOpUserId(config.getMchId());
}
if (StringUtils.isBlank(this.getNotifyUrl())) {
this.setNotifyUrl(config.getRefundNotifyUrl());
}
super.checkAndSign(config);
}

View File

@@ -97,9 +97,13 @@ public class WxPayConfig {
*/
private String subMchId;
/**
* 微信支付异步回地址通知url必须为直接可访问的url不能携带参数.
* 微信支付异步回地址通知url必须为直接可访问的url不能携带参数.
*/
private String notifyUrl;
/**
* 退款结果异步回调地址通知url必须为直接可访问的url不能携带参数.
*/
private String refundNotifyUrl;
/**
* 交易类型.
* <pre>

View File

@@ -263,6 +263,9 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
@Override
public WxPayRefundV3Result refundV3(WxPayRefundV3Request request) throws WxPayException {
if (StringUtils.isBlank(request.getNotifyUrl())) {
request.setNotifyUrl(this.getConfig().getRefundNotifyUrl());
}
String url = String.format("%s/v3/refund/domestic/refunds", this.getPayBaseUrl());
String response = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(response, WxPayRefundV3Result.class);
@@ -270,6 +273,9 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
@Override
public WxPayRefundV3Result partnerRefundV3(WxPayPartnerRefundV3Request request) throws WxPayException {
if (StringUtils.isBlank(request.getNotifyUrl())) {
request.setNotifyUrl(this.getConfig().getRefundNotifyUrl());
}
if (StringUtils.isBlank(request.getSubMchid())) {
request.setSubMchid(this.getConfig().getSubMchId());
}