加强检查支付配置

This commit is contained in:
Binary Wang 2017-05-30 10:35:42 +08:00
parent 4cf3f5c363
commit 69ca699829

View File

@ -1,5 +1,6 @@
package com.github.binarywang.wxpay.config; package com.github.binarywang.wxpay.config;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.ssl.SSLContexts; import org.apache.http.ssl.SSLContexts;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
@ -143,13 +144,17 @@ public class WxPayConfig {
} }
public SSLContext initSSLContext() { public SSLContext initSSLContext() {
if (null == mchId) { if (StringUtils.isBlank(mchId)) {
throw new IllegalArgumentException("请确保商户号mch_id已设置"); throw new IllegalArgumentException("请确保商户号mchId已设置");
}
if (StringUtils.isBlank(this.keyPath)) {
throw new IllegalArgumentException("请确保证书文件地址keyPath已配置");
} }
File file = new File(this.keyPath); File file = new File(this.keyPath);
if (!file.exists()) { if (!file.exists()) {
throw new RuntimeException("证书文件" + file.getPath() + "】不存在!"); throw new RuntimeException("证书文件" + file.getPath() + "】不存在!");
} }
try { try {