File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
weixin-java-pay/src/main/java/com/github/binarywang/wxpay Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 18
18
*/
19
19
@ Data
20
20
public class WxPayConfig {
21
+ private static final String DEFAULT_PAY_BASE_URL = "https://api.mch.weixin.qq.com" ;
22
+
23
+ /**
24
+ * 微信支付接口请求地址域名部分.
25
+ */
26
+ private String payBaseUrl = DEFAULT_PAY_BASE_URL ;
21
27
22
28
/**
23
29
* http请求连接超时时间.
@@ -96,6 +102,18 @@ public class WxPayConfig {
96
102
private String httpProxyUsername ;
97
103
private String httpProxyPassword ;
98
104
105
+ /**
106
+ * 返回所设置的微信支付接口请求地址域名.
107
+ * @return 微信支付接口请求地址域名
108
+ */
109
+ public String getPayBaseUrl () {
110
+ if (StringUtils .isEmpty (this .payBaseUrl )) {
111
+ return DEFAULT_PAY_BASE_URL ;
112
+ }
113
+
114
+ return this .payBaseUrl ;
115
+ }
116
+
99
117
/**
100
118
* 初始化ssl.
101
119
*
Original file line number Diff line number Diff line change 47
47
* @author <a href="https://github.com/binarywang">Binary Wang</a>
48
48
*/
49
49
public abstract class BaseWxPayServiceImpl implements WxPayService {
50
- private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com" ;
51
50
private static final String TOTAL_FUND_COUNT = "资金流水总笔数" ;
52
51
53
52
/**
@@ -89,10 +88,10 @@ public void setConfig(WxPayConfig config) {
89
88
@ Override
90
89
public String getPayBaseUrl () {
91
90
if (this .getConfig ().isUseSandboxEnv ()) {
92
- return PAY_BASE_URL + "/sandboxnew" ;
91
+ return this . getConfig (). getPayBaseUrl () + "/sandboxnew" ;
93
92
}
94
93
95
- return PAY_BASE_URL ;
94
+ return this . getConfig (). getPayBaseUrl () ;
96
95
}
97
96
98
97
@ Override
@@ -101,7 +100,7 @@ public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayExceptio
101
100
102
101
String url = this .getPayBaseUrl () + "/secapi/pay/refund" ;
103
102
if (this .getConfig ().isUseSandboxEnv ()) {
104
- url = PAY_BASE_URL + "/sandboxnew/pay/refund" ;
103
+ url = this . getConfig (). getPayBaseUrl () + "/sandboxnew/pay/refund" ;
105
104
}
106
105
107
106
String responseContent = this .post (url , request .toXML (), true );
You can’t perform that action at this time.
0 commit comments