|
38 | 38 | */ |
39 | 39 | public class WxMpPayServiceImpl implements WxMpPayService { |
40 | 40 |
|
| 41 | + private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; |
41 | 42 | private static final List<String> TRADE_TYPES = Lists.newArrayList("JSAPI", |
42 | 43 | "NATIVE", "APP"); |
43 | 44 | private WxMpService wxMpService; |
@@ -77,7 +78,7 @@ public WxMpPayResult getJSSDKPayResult(String transactionId, |
77 | 78 | } |
78 | 79 | request.append("</xml>"); |
79 | 80 |
|
80 | | - String url = "https://api.mch.weixin.qq.com/pay/orderquery"; |
| 81 | + String url = PAY_BASE_URL + "/pay/orderquery"; |
81 | 82 | String responseContent = this.wxMpService.post(url, request.toString()); |
82 | 83 | XStream xstream = XStreamInitializer.getInstance(); |
83 | 84 | xstream.alias("xml", WxMpPayResult.class); |
@@ -119,7 +120,7 @@ public WxMpPayRefundResult refundPay(Map<String, String> parameters) |
119 | 120 | } |
120 | 121 | request.append("</xml>"); |
121 | 122 |
|
122 | | - String url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; |
| 123 | + String url = PAY_BASE_URL + "/secapi/pay/refund"; |
123 | 124 | String responseContent = this.wxMpService.post(url, request.toString()); |
124 | 125 | XStream xstream = XStreamInitializer.getInstance(); |
125 | 126 | xstream.processAnnotations(WxMpPayRefundResult.class); |
@@ -163,10 +164,10 @@ public WxRedpackResult sendRedpack(WxSendRedpackRequest request) |
163 | 164 | this.wxMpService.getWxMpConfigStorage().getPartnerKey()); |
164 | 165 | request.setSign(sign); |
165 | 166 |
|
166 | | - String url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack"; |
| 167 | + String url = PAY_BASE_URL + "/mmpaymkttransfers/sendredpack"; |
167 | 168 | if (request.getAmtType() != null) { |
168 | 169 | //裂变红包 |
169 | | - url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendgroupredpack"; |
| 170 | + url = PAY_BASE_URL + "/mmpaymkttransfers/sendgroupredpack"; |
170 | 171 | } |
171 | 172 |
|
172 | 173 | String responseContent = this.wxMpService.post(url, xstream.toXML(request)); |
@@ -245,7 +246,7 @@ public WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request) |
245 | 246 | this.wxMpService.getWxMpConfigStorage().getPartnerKey()); |
246 | 247 | request.setSign(sign); |
247 | 248 |
|
248 | | - String url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; |
| 249 | + String url = PAY_BASE_URL + "/pay/unifiedorder"; |
249 | 250 |
|
250 | 251 | String responseContent = this.wxMpService.post(url, xstream.toXML(request)); |
251 | 252 | WxUnifiedOrderResult result = (WxUnifiedOrderResult) xstream |
@@ -282,8 +283,7 @@ private void checkParameters(WxUnifiedOrderRequest request) { |
282 | 283 | } |
283 | 284 |
|
284 | 285 | if (!TRADE_TYPES.contains(request.getTradeType())) { |
285 | | - throw new IllegalArgumentException( |
286 | | -"trade_type目前必须为" + TRADE_TYPES + "其中之一"); |
| 286 | + throw new IllegalArgumentException("trade_type目前必须为" + TRADE_TYPES + "其中之一"); |
287 | 287 |
|
288 | 288 | } |
289 | 289 |
|
|
0 commit comments