mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-01-22 21:02:03 +08:00
🎨 #3838 【微信支付】为starter添加了退款结果回调 URL 的配置支持,允许开发者在配置文件中统一配置退款通知地址
This commit is contained in:
13
README.md
13
README.md
@@ -133,10 +133,10 @@
|
|||||||
**Spring Boot 配置示例:**
|
**Spring Boot 配置示例:**
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
# 使用 HttpClient 5.x(推荐,MP/CP/Channel/QiDian 模块默认)
|
# 使用 HttpClient 5.x(推荐,MP/MiniApp/CP/Channel/QiDian 模块默认)
|
||||||
wx.mp.config-storage.http-client-type=HttpComponents
|
wx.mp.config-storage.http-client-type=HttpComponents
|
||||||
|
|
||||||
# 使用 HttpClient 4.x(兼容模式,MiniApp 模块默认)
|
# 使用 HttpClient 4.x(兼容模式)
|
||||||
wx.mp.config-storage.http-client-type=HttpClient
|
wx.mp.config-storage.http-client-type=HttpClient
|
||||||
|
|
||||||
# 使用 OkHttp
|
# 使用 OkHttp
|
||||||
@@ -153,11 +153,10 @@ wx.mp.config-storage.http-client-type=HTTP_COMPONENTS # 注意使用大写下
|
|||||||
```
|
```
|
||||||
|
|
||||||
**注意事项:**
|
**注意事项:**
|
||||||
1. **MiniApp 模块**已提供 `HttpComponents`(HttpClient 5.x)类型的配置选项,但当前默认仍为 HttpClient 4.x;如需启用 HttpClient 5.x,请确保所使用的集成模块(如 `wx-java-miniapp-spring-boot-starter`、`wx-java-miniapp-solon-plugin`)版本已支持该选项
|
1. **MP、MiniApp、Channel、QiDian 模块**已完整支持 HttpClient 5.x,默认推荐使用
|
||||||
2. **MP、Channel、QiDian 模块**已完整支持 HttpClient 5.x,默认推荐使用
|
2. **CP 模块**的支持情况取决于具体使用的 Starter 版本,请参考对应模块文档
|
||||||
3. **CP 模块**的支持情况取决于具体使用的 Starter 版本,请参考对应模块文档
|
3. 如需使用 OkHttp 或 Jodd-http,需在项目中添加对应的依赖(scope为provided)
|
||||||
4. 如需使用 OkHttp 或 Jodd-http,需在项目中添加对应的依赖(scope为provided)
|
4. HttpClient 4.x 和 HttpClient 5.x 可以共存,按需配置即可
|
||||||
5. HttpClient 4.x 和 HttpClient 5.x 可以共存,按需配置即可
|
|
||||||
|
|
||||||
|
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class WxPayAutoConfiguration {
|
|||||||
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
|
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
|
||||||
payConfig.setUseSandboxEnv(this.properties.isUseSandboxEnv());
|
payConfig.setUseSandboxEnv(this.properties.isUseSandboxEnv());
|
||||||
payConfig.setNotifyUrl(StringUtils.trimToNull(this.properties.getNotifyUrl()));
|
payConfig.setNotifyUrl(StringUtils.trimToNull(this.properties.getNotifyUrl()));
|
||||||
|
payConfig.setRefundNotifyUrl(StringUtils.trimToNull(this.properties.getRefundNotifyUrl()));
|
||||||
//以下是apiv3以及支付分相关
|
//以下是apiv3以及支付分相关
|
||||||
payConfig.setServiceId(StringUtils.trimToNull(this.properties.getServiceId()));
|
payConfig.setServiceId(StringUtils.trimToNull(this.properties.getServiceId()));
|
||||||
payConfig.setPayScoreNotifyUrl(StringUtils.trimToNull(this.properties.getPayScoreNotifyUrl()));
|
payConfig.setPayScoreNotifyUrl(StringUtils.trimToNull(this.properties.getPayScoreNotifyUrl()));
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ public class WxPayProperties {
|
|||||||
*/
|
*/
|
||||||
private String notifyUrl;
|
private String notifyUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款结果异步回调地址,通知url必须为直接可访问的url,不能携带参数.
|
||||||
|
*/
|
||||||
|
private String refundNotifyUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付分授权回调地址
|
* 微信支付分授权回调地址
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class WxPayAutoConfiguration {
|
|||||||
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
|
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
|
||||||
payConfig.setUseSandboxEnv(this.properties.isUseSandboxEnv());
|
payConfig.setUseSandboxEnv(this.properties.isUseSandboxEnv());
|
||||||
payConfig.setNotifyUrl(StringUtils.trimToNull(this.properties.getNotifyUrl()));
|
payConfig.setNotifyUrl(StringUtils.trimToNull(this.properties.getNotifyUrl()));
|
||||||
|
payConfig.setRefundNotifyUrl(StringUtils.trimToNull(this.properties.getRefundNotifyUrl()));
|
||||||
//以下是apiv3以及支付分相关
|
//以下是apiv3以及支付分相关
|
||||||
payConfig.setServiceId(StringUtils.trimToNull(this.properties.getServiceId()));
|
payConfig.setServiceId(StringUtils.trimToNull(this.properties.getServiceId()));
|
||||||
payConfig.setPayScoreNotifyUrl(StringUtils.trimToNull(this.properties.getPayScoreNotifyUrl()));
|
payConfig.setPayScoreNotifyUrl(StringUtils.trimToNull(this.properties.getPayScoreNotifyUrl()));
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ public class WxPayProperties {
|
|||||||
*/
|
*/
|
||||||
private String notifyUrl;
|
private String notifyUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款结果异步回调地址,通知url必须为直接可访问的url,不能携带参数
|
||||||
|
*/
|
||||||
|
private String refundNotifyUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付分回调地址
|
* 微信支付分回调地址
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -230,7 +230,9 @@ public class WxPayRefundRequest extends BaseWxPayRequest {
|
|||||||
if (StringUtils.isBlank(this.getOpUserId())) {
|
if (StringUtils.isBlank(this.getOpUserId())) {
|
||||||
this.setOpUserId(config.getMchId());
|
this.setOpUserId(config.getMchId());
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isBlank(this.getNotifyUrl())) {
|
||||||
|
this.setNotifyUrl(config.getRefundNotifyUrl());
|
||||||
|
}
|
||||||
super.checkAndSign(config);
|
super.checkAndSign(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,9 +97,13 @@ public class WxPayConfig {
|
|||||||
*/
|
*/
|
||||||
private String subMchId;
|
private String subMchId;
|
||||||
/**
|
/**
|
||||||
* 微信支付异步回掉地址,通知url必须为直接可访问的url,不能携带参数.
|
* 微信支付异步回调地址,通知url必须为直接可访问的url,不能携带参数.
|
||||||
*/
|
*/
|
||||||
private String notifyUrl;
|
private String notifyUrl;
|
||||||
|
/**
|
||||||
|
* 退款结果异步回调地址,通知url必须为直接可访问的url,不能携带参数.
|
||||||
|
*/
|
||||||
|
private String refundNotifyUrl;
|
||||||
/**
|
/**
|
||||||
* 交易类型.
|
* 交易类型.
|
||||||
* <pre>
|
* <pre>
|
||||||
|
|||||||
@@ -263,6 +263,9 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayRefundV3Result refundV3(WxPayRefundV3Request request) throws WxPayException {
|
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 url = String.format("%s/v3/refund/domestic/refunds", this.getPayBaseUrl());
|
||||||
String response = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
|
String response = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
|
||||||
return GSON.fromJson(response, WxPayRefundV3Result.class);
|
return GSON.fromJson(response, WxPayRefundV3Result.class);
|
||||||
@@ -270,6 +273,9 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayRefundV3Result partnerRefundV3(WxPayPartnerRefundV3Request request) throws WxPayException {
|
public WxPayRefundV3Result partnerRefundV3(WxPayPartnerRefundV3Request request) throws WxPayException {
|
||||||
|
if (StringUtils.isBlank(request.getNotifyUrl())) {
|
||||||
|
request.setNotifyUrl(this.getConfig().getRefundNotifyUrl());
|
||||||
|
}
|
||||||
if (StringUtils.isBlank(request.getSubMchid())) {
|
if (StringUtils.isBlank(request.getSubMchid())) {
|
||||||
request.setSubMchid(this.getConfig().getSubMchId());
|
request.setSubMchid(this.getConfig().getSubMchId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user