suochencheng před 7 roky
rodič
revize
5250ed5778

+ 14 - 11
src/main/java/com/izouma/weixin/web/WeiXinController.java

@@ -18,6 +18,7 @@ import com.izouma.weixin.service.WeiXinService;
 import com.izouma.weixin.util.WeixinUtil;
 import com.izouma.weixin.wxpay.MyConfig;
 import com.izouma.weixin.wxpay.WXPay;
+import com.izouma.weixin.wxpay.WXPayConstants;
 import com.izouma.weixin.wxpay.WXPayUtil;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
@@ -211,23 +212,25 @@ public class WeiXinController {
 
             String timeStamp = MbappUtil.create_timestamp();
             String nonceStr = MbappUtil.create_nonce_str();
-            String packageStr = "prepay_id=" + unified.get("prepay_id");
+
             //生成sign签名
             Map<String, String> params = new HashMap<>();
 
-            params.put("appId", config.getAppID());
-            params.put("timeStamp", timeStamp);
-            params.put("nonceStr", nonceStr);
-            params.put("package", packageStr);
+            params.put("appid", config.getAppID());
+            params.put("partnerid", config.getMchID());
+            params.put("prepayid", unified.get("prepay_id"));
+            params.put("timestamp", timeStamp);
+            params.put("noncestr", nonceStr);
+            params.put("package", "Sign=WXPay");
 
             result.put("appId", config.getAppID());
-            result.put("timeStamp", timeStamp);
-            result.put("nonceStr", nonceStr);
-            result.put("myPackage", packageStr);
-            result.put("paySign", WXPayUtil.generateSignature(params, config.getKey()));
+            result.put("partnerid", config.getMchID());
+            result.put("prepayid", unified.get("prepay_id"));
+            result.put("timestamp", timeStamp);
+            result.put("noncestr", nonceStr);
+            result.put("package", "Sign=WXPay");
+            result.put("sign", WXPayUtil.generateSignature(params, config.getKey(), WXPayConstants.SignType.HMACSHA256));
 
-            result.put("prepay_id", unified.get("prepay_id"));
-            result.put("code_url", unified.get("code_url"));
 
 
             WxpayTemp wxpayTemp = new WxpayTemp();

+ 117 - 103
src/main/java/com/izouma/weixin/wxpay/WXPay.java

@@ -16,12 +16,30 @@ public class WXPay {
         this(config, null, true, false);
     }
 
+    // 新增的构造方法
+    public WXPay(final WXPayConfig config, WXPayConstants.SignType signType) throws Exception {
+        this(config, null, true, false, signType);
+    }
+
+    // 新增的构造方法
+    public WXPay(final WXPayConfig config, final String notifyUrl,
+                 final boolean autoReport, final boolean useSandbox,
+                 WXPayConstants.SignType signType) throws Exception {
+        this.config = config;
+        this.notifyUrl = notifyUrl;
+        this.autoReport = autoReport;
+        this.useSandbox = useSandbox;
+        this.signType = signType;
+        this.wxPayRequest = new WXPayRequest(config);
+    }
+
+
     public WXPay(final WXPayConfig config, final boolean autoReport) throws Exception {
         this(config, null, autoReport, false);
     }
 
 
-    public WXPay(final WXPayConfig config, final boolean autoReport, final boolean useSandbox) throws Exception{
+    public WXPay(final WXPayConfig config, final boolean autoReport, final boolean useSandbox) throws Exception {
         this(config, null, autoReport, useSandbox);
     }
 
@@ -40,8 +58,7 @@ public class WXPay {
         this.useSandbox = useSandbox;
         if (useSandbox) {
             this.signType = WXPayConstants.SignType.MD5; // 沙箱环境
-        }
-        else {
+        } else {
             this.signType = WXPayConstants.SignType.HMACSHA256;
         }
         this.wxPayRequest = new WXPayRequest(config);
@@ -60,7 +77,7 @@ public class WXPay {
         if (this.config.getCertStream() == null) {
             throw new Exception("cert stream in config is empty");
         }
-        if (this.config.getWXPayDomain() == null){
+        if (this.config.getWXPayDomain() == null) {
             throw new Exception("config.getWXPayDomain() is null");
         }
 
@@ -87,8 +104,7 @@ public class WXPay {
         reqData.put("nonce_str", WXPayUtil.generateNonceStr());
         if (WXPayConstants.SignType.MD5.equals(this.signType)) {
             reqData.put("sign_type", WXPayConstants.MD5);
-        }
-        else if (WXPayConstants.SignType.HMACSHA256.equals(this.signType)) {
+        } else if (WXPayConstants.SignType.HMACSHA256.equals(this.signType)) {
             reqData.put("sign_type", WXPayConstants.HMACSHA256);
         }
         reqData.put("sign", WXPayUtil.generateSignature(reqData, config.getKey(), this.signType));
@@ -119,19 +135,15 @@ public class WXPay {
         WXPayConstants.SignType signType;
         if (signTypeInData == null) {
             signType = WXPayConstants.SignType.MD5;
-        }
-        else {
+        } else {
             signTypeInData = signTypeInData.trim();
             if (signTypeInData.length() == 0) {
                 signType = WXPayConstants.SignType.MD5;
-            }
-            else if (WXPayConstants.MD5.equals(signTypeInData)) {
+            } else if (WXPayConstants.MD5.equals(signTypeInData)) {
                 signType = WXPayConstants.SignType.MD5;
-            }
-            else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
+            } else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
                 signType = WXPayConstants.SignType.HMACSHA256;
-            }
-            else {
+            } else {
                 throw new Exception(String.format("Unsupported sign_type: %s", signTypeInData));
             }
         }
@@ -141,10 +153,11 @@ public class WXPay {
 
     /**
      * 不需要证书的请求
-     * @param urlSuffix String
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param urlSuffix        String
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 超时时间,单位是毫秒
-     * @param readTimeoutMs 超时时间,单位是毫秒
+     * @param readTimeoutMs    超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
@@ -160,16 +173,17 @@ public class WXPay {
 
     /**
      * 需要证书的请求
-     * @param urlSuffix String
-     * @param reqData 向wxpay post的请求数据  Map
+     *
+     * @param urlSuffix        String
+     * @param reqData          向wxpay post的请求数据  Map
      * @param connectTimeoutMs 超时时间,单位是毫秒
-     * @param readTimeoutMs 超时时间,单位是毫秒
+     * @param readTimeoutMs    超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
     public String requestWithCert(String urlSuffix, Map<String, String> reqData,
                                   int connectTimeoutMs, int readTimeoutMs) throws Exception {
-        String msgUUID= reqData.get("nonce_str");
+        String msgUUID = reqData.get("nonce_str");
         String reqBody = WXPayUtil.mapToXml(reqData);
 
         String resp = this.wxPayRequest.requestWithCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, this.autoReport);
@@ -178,6 +192,7 @@ public class WXPay {
 
     /**
      * 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
+     *
      * @param xmlStr API返回的XML格式数据
      * @return Map类型数据
      * @throws Exception
@@ -188,23 +203,19 @@ public class WXPay {
         Map<String, String> respData = WXPayUtil.xmlToMap(xmlStr);
         if (respData.containsKey(RETURN_CODE)) {
             return_code = respData.get(RETURN_CODE);
-        }
-        else {
+        } else {
             throw new Exception(String.format("No `return_code` in XML: %s", xmlStr));
         }
 
         if (return_code.equals(WXPayConstants.FAIL)) {
             return respData;
-        }
-        else if (return_code.equals(WXPayConstants.SUCCESS)) {
-           if (this.isResponseSignatureValid(respData)) {
-               return respData;
-           }
-           else {
-               throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
-           }
-        }
-        else {
+        } else if (return_code.equals(WXPayConstants.SUCCESS)) {
+            if (this.isResponseSignatureValid(respData)) {
+                return respData;
+            } else {
+                throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
+            }
+        } else {
             throw new Exception(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr));
         }
     }
@@ -212,6 +223,7 @@ public class WXPay {
     /**
      * 作用:提交刷卡支付<br>
      * 场景:刷卡支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -224,9 +236,10 @@ public class WXPay {
     /**
      * 作用:提交刷卡支付<br>
      * 场景:刷卡支付
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
@@ -234,8 +247,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_MICROPAY_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.MICROPAY_URL_SUFFIX;
         }
         String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -245,6 +257,7 @@ public class WXPay {
     /**
      * 提交刷卡支付,针对软POS,尽可能做成功
      * 内置重试机制,最多60s
+     *
      * @param reqData
      * @return
      * @throws Exception
@@ -256,13 +269,14 @@ public class WXPay {
     /**
      * 提交刷卡支付,针对软POS,尽可能做成功
      * 内置重试机制,最多60s
+     *
      * @param reqData
      * @param connectTimeoutMs
      * @return
      * @throws Exception
      */
     public Map<String, String> microPayWithPos(Map<String, String> reqData, int connectTimeoutMs) throws Exception {
-        int remainingTimeMs = 60*1000;
+        int remainingTimeMs = 60 * 1000;
         long startTimestampMs = 0;
         Map<String, String> lastResult = null;
         Exception lastException = null;
@@ -279,57 +293,49 @@ public class WXPay {
                         String errCode = lastResult.get("err_code");
                         if (resultCode.equals("SUCCESS")) {
                             break;
-                        }
-                        else {
+                        } else {
                             // 看错误码,若支付结果未知,则重试提交刷卡支付
                             if (errCode.equals("SYSTEMERROR") || errCode.equals("BANKERROR") || errCode.equals("USERPAYING")) {
-                                remainingTimeMs = remainingTimeMs - (int)(WXPayUtil.getCurrentTimestampMs() - startTimestampMs);
+                                remainingTimeMs = remainingTimeMs - (int) (WXPayUtil.getCurrentTimestampMs() - startTimestampMs);
                                 if (remainingTimeMs <= 100) {
                                     break;
-                                }
-                                else {
+                                } else {
                                     WXPayUtil.getLogger().info("microPayWithPos: try micropay again");
-                                    if (remainingTimeMs > 5*1000) {
-                                        Thread.sleep(5*1000);
-                                    }
-                                    else {
-                                        Thread.sleep(1*1000);
+                                    if (remainingTimeMs > 5 * 1000) {
+                                        Thread.sleep(5 * 1000);
+                                    } else {
+                                        Thread.sleep(1 * 1000);
                                     }
                                     continue;
                                 }
-                            }
-                            else {
+                            } else {
                                 break;
                             }
                         }
-                    }
-                    else {
+                    } else {
                         break;
                     }
-                }
-                catch (Exception ex) {
+                } catch (Exception ex) {
                     lastResult = null;
                     lastException = ex;
                 }
-            }
-            else {
+            } else {
                 break;
             }
         }
 
         if (lastResult == null) {
             throw lastException;
-        }
-        else {
+        } else {
             return lastResult;
         }
     }
 
 
-
     /**
      * 作用:统一下单<br>
      * 场景:公共号支付、扫码支付、APP支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -342,21 +348,21 @@ public class WXPay {
     /**
      * 作用:统一下单<br>
      * 场景:公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
-    public Map<String, String> unifiedOrder(Map<String, String> reqData,  int connectTimeoutMs, int readTimeoutMs) throws Exception {
+    public Map<String, String> unifiedOrder(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_UNIFIEDORDER_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.UNIFIEDORDER_URL_SUFFIX;
         }
-        if(this.notifyUrl != null) {
+        if (this.notifyUrl != null) {
             reqData.put("notify_url", this.notifyUrl);
         }
         String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -367,6 +373,7 @@ public class WXPay {
     /**
      * 作用:查询订单<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -379,9 +386,10 @@ public class WXPay {
     /**
      * 作用:查询订单<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据 int
+     *
+     * @param reqData          向wxpay post的请求数据 int
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
@@ -389,8 +397,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_ORDERQUERY_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.ORDERQUERY_URL_SUFFIX;
         }
         String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -401,6 +408,7 @@ public class WXPay {
     /**
      * 作用:撤销订单<br>
      * 场景:刷卡支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -414,9 +422,10 @@ public class WXPay {
      * 作用:撤销订单<br>
      * 场景:刷卡支付<br>
      * 其他:需要证书
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
@@ -424,8 +433,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_REVERSE_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.REVERSE_URL_SUFFIX;
         }
         String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -436,6 +444,7 @@ public class WXPay {
     /**
      * 作用:关闭订单<br>
      * 场景:公共号支付、扫码支付、APP支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -448,18 +457,18 @@ public class WXPay {
     /**
      * 作用:关闭订单<br>
      * 场景:公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
-    public Map<String, String> closeOrder(Map<String, String> reqData,  int connectTimeoutMs, int readTimeoutMs) throws Exception {
+    public Map<String, String> closeOrder(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_CLOSEORDER_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.CLOSEORDER_URL_SUFFIX;
         }
         String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -470,6 +479,7 @@ public class WXPay {
     /**
      * 作用:申请退款<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -483,9 +493,10 @@ public class WXPay {
      * 作用:申请退款<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付<br>
      * 其他:需要证书
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
@@ -493,8 +504,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_REFUND_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.REFUND_URL_SUFFIX;
         }
         String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -505,6 +515,7 @@ public class WXPay {
     /**
      * 作用:退款查询<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -517,9 +528,10 @@ public class WXPay {
     /**
      * 作用:退款查询<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
@@ -527,8 +539,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_REFUNDQUERY_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.REFUNDQUERY_URL_SUFFIX;
         }
         String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -539,6 +550,7 @@ public class WXPay {
     /**
      * 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -552,10 +564,11 @@ public class WXPay {
      * 作用:对账单下载<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付<br>
      * 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data,
-     *      其中return_code为`SUCCESS`,data为对账单数据。
-     * @param reqData 向wxpay post的请求数据
+     * 其中return_code为`SUCCESS`,data为对账单数据。
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return 经过封装的API返回数据
      * @throws Exception
      */
@@ -563,8 +576,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_DOWNLOADBILL_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.DOWNLOADBILL_URL_SUFFIX;
         }
         String respStr = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs).trim();
@@ -572,8 +584,7 @@ public class WXPay {
         // 出现错误,返回XML数据
         if (respStr.indexOf("<") == 0) {
             ret = WXPayUtil.xmlToMap(respStr);
-        }
-        else {
+        } else {
             // 正常返回csv数据
             ret = new HashMap<String, String>();
             ret.put("return_code", WXPayConstants.SUCCESS);
@@ -587,6 +598,7 @@ public class WXPay {
     /**
      * 作用:交易保障<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -599,9 +611,10 @@ public class WXPay {
     /**
      * 作用:交易保障<br>
      * 场景:刷卡支付、公共号支付、扫码支付、APP支付
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
@@ -609,8 +622,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_REPORT_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.REPORT_URL_SUFFIX;
         }
         String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -621,6 +633,7 @@ public class WXPay {
     /**
      * 作用:转换短链接<br>
      * 场景:刷卡支付、扫码支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -633,6 +646,7 @@ public class WXPay {
     /**
      * 作用:转换短链接<br>
      * 场景:刷卡支付、扫码支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -641,8 +655,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_SHORTURL_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.SHORTURL_URL_SUFFIX;
         }
         String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -653,6 +666,7 @@ public class WXPay {
     /**
      * 作用:授权码查询OPENID接口<br>
      * 场景:刷卡支付
+     *
      * @param reqData 向wxpay post的请求数据
      * @return API返回数据
      * @throws Exception
@@ -665,9 +679,10 @@ public class WXPay {
     /**
      * 作用:授权码查询OPENID接口<br>
      * 场景:刷卡支付
-     * @param reqData 向wxpay post的请求数据
+     *
+     * @param reqData          向wxpay post的请求数据
      * @param connectTimeoutMs 连接超时时间,单位是毫秒
-     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @param readTimeoutMs    读超时时间,单位是毫秒
      * @return API返回数据
      * @throws Exception
      */
@@ -675,8 +690,7 @@ public class WXPay {
         String url;
         if (this.useSandbox) {
             url = WXPayConstants.SANDBOX_AUTHCODETOOPENID_URL_SUFFIX;
-        }
-        else {
+        } else {
             url = WXPayConstants.AUTHCODETOOPENID_URL_SUFFIX;
         }
         String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);

+ 4 - 4
src/main/resources/properties/outsidews.properties

@@ -1,7 +1,7 @@
 projectname=shouyoudianjing
 weixinapi=https://api.weixin.qq.com/sns/oauth2/
-weixinappid=wx8d16412d33eaf19c
-weixinsecret=4c16604a837d8c2929c33a03a5080e60
+weixinappid=wx62f8a9c1d3d70245
+weixinsecret=93f7a97a3e0da3795d3ef53ce6b27099
 aliossid=PXzJyah5rZfWHIIH
 aliosskey=e1MS6j0wypXJrw8CM0hObZu8qKbfah
 aliossendpoit=http://oss-cn-hangzhou.aliyuncs.com
@@ -18,8 +18,8 @@ ALIPAY_CHARSET=utf-8
 ALIPAY_ALIPAY_PUBLIC_KEY=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzW3LltIo9Jjns7PpkQGKMl5TeY2c6/FmjuKtZF08u17vfgt/r7q2IK6m/Y/iHlbKYeK4chfT/fB9HBUAAZ7poleo2mN/8JHv/Wo/LgVec7xwtxq5Eg1EKLTwJhPm5cKhXaH0LGqDrhzkdRX7LS4NvYzmlYqaDb5EhpjianyIwBmjBEMu6dktoyyKsihjI+9U76CEwDApJMG4ptJJmzeK3oeVzyk3k9rqTmvuuBTZ2Ct5ideNXtizVjcdhwCIWsPPPilIhzV1EtywPmhsNIp2T91HUjwHrbBGoDXg/jVzbVn+w3gAZ/9CvEhoFJEnDg3gvE3rDqUuZXJlY+VucPYSuwIDAQAB
 ALIPAY_SELLER=2088102179082444
 ALIPAY_GATEWAY=https://openapi.alipaydev.com/gateway.do
-weixin_mch_id=1480639272
-weixin_mch_secret=
+weixin_mch_id=1531015301
+weixin_mch_secret=bef1ed5569cd41a822308257f388ad19
 weixin_notify_url=
 weixin_cert_path=/home/cert/apiclient_cert.p12
 weixin_notify_url_recharge=