提交 fa881ba7 作者: xiaowang

修复:文件找不到问题

上级 c8e5417c
...@@ -6,5 +6,8 @@ package com.mmc.payment.constant; ...@@ -6,5 +6,8 @@ package com.mmc.payment.constant;
* 概要: * 概要:
*/ */
public interface WechatConstant { public interface WechatConstant {
// 本地调试
// String privateKeyPath = "src/main/resources/apiclient_key.pem";
// 服务器
String privateKeyPath = "src/main/resources/apiclient_key.pem"; String privateKeyPath = "src/main/resources/apiclient_key.pem";
} }
package com.mmc.payment.util; package com.mmc.payment.util;
import com.mmc.payment.constant.UserSystemConstant; import com.mmc.payment.constant.UserSystemConstant;
import com.mmc.payment.constant.WechatConstant;
import com.wechat.pay.java.core.Config; import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig; import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationConfig; import com.wechat.pay.java.core.notification.NotificationConfig;
...@@ -25,7 +24,7 @@ public class WxConfigUtils { ...@@ -25,7 +24,7 @@ public class WxConfigUtils {
Config config = Config config =
new RSAAutoCertificateConfig.Builder() new RSAAutoCertificateConfig.Builder()
.merchantId(userSystemConstant.getMchid()) .merchantId(userSystemConstant.getMchid())
.privateKeyFromPath(WechatConstant.privateKeyPath) .privateKeyFromPath(this.getFilePath())
.merchantSerialNumber(userSystemConstant.getMchNumber()) .merchantSerialNumber(userSystemConstant.getMchNumber())
.apiV3Key(userSystemConstant.getApiv3Key()) .apiV3Key(userSystemConstant.getApiv3Key())
.build(); .build();
...@@ -39,11 +38,17 @@ public class WxConfigUtils { ...@@ -39,11 +38,17 @@ public class WxConfigUtils {
NotificationConfig config = NotificationConfig config =
new RSAAutoCertificateConfig.Builder() new RSAAutoCertificateConfig.Builder()
.merchantId(userSystemConstant.getMchid()) .merchantId(userSystemConstant.getMchid())
.privateKeyFromPath(WechatConstant.privateKeyPath) .privateKeyFromPath(this.getFilePath())
.merchantSerialNumber(userSystemConstant.getMchNumber()) .merchantSerialNumber(userSystemConstant.getMchNumber())
.apiV3Key(userSystemConstant.getApiv3Key()) .apiV3Key(userSystemConstant.getApiv3Key())
.build(); .build();
return config; return config;
} }
private String getFilePath() {
String path = this.getClass().getClassLoader().getResource("").getPath();
String privateKeyPath = path + "apiclient_key.pem";
return privateKeyPath;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论