|
|
@@ -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));
|
|
|
@@ -118,20 +134,17 @@ public class WXPay {
|
|
|
String signTypeInData = reqData.get(WXPayConstants.FIELD_SIGN_TYPE);
|
|
|
WXPayConstants.SignType signType;
|
|
|
if (signTypeInData == null) {
|
|
|
- signType = WXPayConstants.SignType.MD5;
|
|
|
- }
|
|
|
- else {
|
|
|
+ //signType = WXPayConstants.SignType.MD5;
|
|
|
+ signType = this.signType;//修改为默认类型
|
|
|
+ } 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 +154,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 +174,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 +193,7 @@ public class WXPay {
|
|
|
|
|
|
/**
|
|
|
* 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
|
|
|
+ *
|
|
|
* @param xmlStr API返回的XML格式数据
|
|
|
* @return Map类型数据
|
|
|
* @throws Exception
|
|
|
@@ -188,23 +204,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 +224,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:提交刷卡支付<br>
|
|
|
* 场景:刷卡支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -224,9 +237,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 +248,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 +258,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 提交刷卡支付,针对软POS,尽可能做成功
|
|
|
* 内置重试机制,最多60s
|
|
|
+ *
|
|
|
* @param reqData
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
@@ -256,13 +270,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 +294,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 +349,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 +374,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:查询订单<br>
|
|
|
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -379,9 +387,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 +398,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 +409,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:撤销订单<br>
|
|
|
* 场景:刷卡支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -414,9 +423,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 +434,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 +445,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:关闭订单<br>
|
|
|
* 场景:公共号支付、扫码支付、APP支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -448,18 +458,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 +480,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:申请退款<br>
|
|
|
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -483,9 +494,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 +505,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 +516,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:退款查询<br>
|
|
|
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -517,9 +529,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 +540,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 +551,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)<br>
|
|
|
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -552,10 +565,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 +577,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 +585,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 +599,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:交易保障<br>
|
|
|
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -599,9 +612,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 +623,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 +634,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:转换短链接<br>
|
|
|
* 场景:刷卡支付、扫码支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -633,6 +647,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:转换短链接<br>
|
|
|
* 场景:刷卡支付、扫码支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -641,8 +656,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 +667,7 @@ public class WXPay {
|
|
|
/**
|
|
|
* 作用:授权码查询OPENID接口<br>
|
|
|
* 场景:刷卡支付
|
|
|
+ *
|
|
|
* @param reqData 向wxpay post的请求数据
|
|
|
* @return API返回数据
|
|
|
* @throws Exception
|
|
|
@@ -665,9 +680,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 +691,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);
|