提交 fa881ba7 作者: xiaowang

修复:文件找不到问题

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