Skip to content

Commit 3e9063d

Browse files
committed
微信支付starter支持配置退款结果回调URL
1 parent 82f4eb8 commit 3e9063d

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

spring-boot-starters/wx-java-pay-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/pay/config/WxPayAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public WxPayService wxPayService() {
5151
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
5252
payConfig.setUseSandboxEnv(this.properties.isUseSandboxEnv());
5353
payConfig.setNotifyUrl(StringUtils.trimToNull(this.properties.getNotifyUrl()));
54+
payConfig.setRefundNotifyUrl(StringUtils.trimToNull(this.properties.getRefundNotifyUrl()));
5455
//以下是apiv3以及支付分相关
5556
payConfig.setServiceId(StringUtils.trimToNull(this.properties.getServiceId()));
5657
payConfig.setPayScoreNotifyUrl(StringUtils.trimToNull(this.properties.getPayScoreNotifyUrl()));

spring-boot-starters/wx-java-pay-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/pay/properties/WxPayProperties.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public class WxPayProperties {
6464
*/
6565
private String notifyUrl;
6666

67+
/**
68+
* 退款结果异步回调地址,通知url必须为直接可访问的url,不能携带参数
69+
*/
70+
private String refundNotifyUrl;
71+
6772
/**
6873
* 微信支付分回调地址
6974
*/

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ public void checkAndSign(WxPayConfig config) throws WxPayException {
230230
if (StringUtils.isBlank(this.getOpUserId())) {
231231
this.setOpUserId(config.getMchId());
232232
}
233-
233+
if (StringUtils.isBlank(this.getNotifyUrl())) {
234+
this.setNotifyUrl(config.getRefundNotifyUrl());
235+
}
234236
super.checkAndSign(config);
235237
}
236238

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public class WxPayConfig {
100100
* 微信支付异步回掉地址,通知url必须为直接可访问的url,不能携带参数.
101101
*/
102102
private String notifyUrl;
103+
/**
104+
* 退款结果异步回调地址,通知url必须为直接可访问的url,不能携带参数.
105+
*/
106+
private String refundNotifyUrl;
103107
/**
104108
* 交易类型.
105109
* <pre>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,19 @@ public WxPayRefundResult refundV2(WxPayRefundRequest request) throws WxPayExcept
263263

264264
@Override
265265
public WxPayRefundV3Result refundV3(WxPayRefundV3Request request) throws WxPayException {
266+
if (StringUtils.isBlank(request.getNotifyUrl())) {
267+
request.setNotifyUrl(this.getConfig().getRefundNotifyUrl());
268+
}
266269
String url = String.format("%s/v3/refund/domestic/refunds", this.getPayBaseUrl());
267270
String response = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
268271
return GSON.fromJson(response, WxPayRefundV3Result.class);
269272
}
270273

271274
@Override
272275
public WxPayRefundV3Result partnerRefundV3(WxPayPartnerRefundV3Request request) throws WxPayException {
276+
if (StringUtils.isBlank(request.getNotifyUrl())) {
277+
request.setNotifyUrl(this.getConfig().getRefundNotifyUrl());
278+
}
273279
if (StringUtils.isBlank(request.getSubMchid())) {
274280
request.setSubMchid(this.getConfig().getSubMchId());
275281
}

0 commit comments

Comments
 (0)