Skip to content

Commit 118e4c7

Browse files
committed
提取支付公用接口地址常量
1 parent e9b9209 commit 118e4c7

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
*/
3939
public class WxMpPayServiceImpl implements WxMpPayService {
4040

41+
private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com";
4142
private static final List<String> TRADE_TYPES = Lists.newArrayList("JSAPI",
4243
"NATIVE", "APP");
4344
private WxMpService wxMpService;
@@ -77,7 +78,7 @@ public WxMpPayResult getJSSDKPayResult(String transactionId,
7778
}
7879
request.append("</xml>");
7980

80-
String url = "https://api.mch.weixin.qq.com/pay/orderquery";
81+
String url = PAY_BASE_URL + "/pay/orderquery";
8182
String responseContent = this.wxMpService.post(url, request.toString());
8283
XStream xstream = XStreamInitializer.getInstance();
8384
xstream.alias("xml", WxMpPayResult.class);
@@ -119,7 +120,7 @@ public WxMpPayRefundResult refundPay(Map<String, String> parameters)
119120
}
120121
request.append("</xml>");
121122

122-
String url = "https://api.mch.weixin.qq.com/secapi/pay/refund";
123+
String url = PAY_BASE_URL + "/secapi/pay/refund";
123124
String responseContent = this.wxMpService.post(url, request.toString());
124125
XStream xstream = XStreamInitializer.getInstance();
125126
xstream.processAnnotations(WxMpPayRefundResult.class);
@@ -163,10 +164,10 @@ public WxRedpackResult sendRedpack(WxSendRedpackRequest request)
163164
this.wxMpService.getWxMpConfigStorage().getPartnerKey());
164165
request.setSign(sign);
165166

166-
String url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack";
167+
String url = PAY_BASE_URL + "/mmpaymkttransfers/sendredpack";
167168
if (request.getAmtType() != null) {
168169
//裂变红包
169-
url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendgroupredpack";
170+
url = PAY_BASE_URL + "/mmpaymkttransfers/sendgroupredpack";
170171
}
171172

172173
String responseContent = this.wxMpService.post(url, xstream.toXML(request));
@@ -245,7 +246,7 @@ public WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request)
245246
this.wxMpService.getWxMpConfigStorage().getPartnerKey());
246247
request.setSign(sign);
247248

248-
String url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
249+
String url = PAY_BASE_URL + "/pay/unifiedorder";
249250

250251
String responseContent = this.wxMpService.post(url, xstream.toXML(request));
251252
WxUnifiedOrderResult result = (WxUnifiedOrderResult) xstream
@@ -282,8 +283,7 @@ private void checkParameters(WxUnifiedOrderRequest request) {
282283
}
283284

284285
if (!TRADE_TYPES.contains(request.getTradeType())) {
285-
throw new IllegalArgumentException(
286-
"trade_type目前必须为" + TRADE_TYPES + "其中之一");
286+
throw new IllegalArgumentException("trade_type目前必须为" + TRADE_TYPES + "其中之一");
287287

288288
}
289289

0 commit comments

Comments
 (0)