修复微信支付,兼容公钥模块
This commit is contained in:
@@ -366,7 +366,7 @@ import com.gxwebsoft.common.core.service.PaymentCacheService;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 构建微信支付配置
|
// 构建微信支付配置
|
||||||
Config config;
|
Config config = null;
|
||||||
if (active.equals("dev")) {
|
if (active.equals("dev")) {
|
||||||
// 开发环境使用自动证书配置
|
// 开发环境使用自动证书配置
|
||||||
// 检查数据库配置是否完整
|
// 检查数据库配置是否完整
|
||||||
@@ -393,10 +393,6 @@ import com.gxwebsoft.common.core.service.PaymentCacheService;
|
|||||||
if (payment.getPubKey() != null && !payment.getPubKey().isEmpty() &&
|
if (payment.getPubKey() != null && !payment.getPubKey().isEmpty() &&
|
||||||
payment.getPubKeyId() != null && !payment.getPubKeyId().isEmpty()) {
|
payment.getPubKeyId() != null && !payment.getPubKeyId().isEmpty()) {
|
||||||
|
|
||||||
System.out.println("=== 检测到公钥配置,使用RSA公钥模式 ===");
|
|
||||||
System.out.println("公钥文件: " + payment.getPubKey());
|
|
||||||
System.out.println("公钥ID: " + payment.getPubKeyId());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 开发环境固定使用 wechatpay_public_key.pem
|
// 开发环境固定使用 wechatpay_public_key.pem
|
||||||
String tenantCertPath = "dev/wechat/" + order.getTenantId();
|
String tenantCertPath = "dev/wechat/" + order.getTenantId();
|
||||||
@@ -404,7 +400,12 @@ import com.gxwebsoft.common.core.service.PaymentCacheService;
|
|||||||
|
|
||||||
System.out.println("开发环境公钥文件路径: " + pubKeyPath);
|
System.out.println("开发环境公钥文件路径: " + pubKeyPath);
|
||||||
|
|
||||||
|
// 检查公钥文件是否存在
|
||||||
if (certificateLoader.certificateExists(pubKeyPath)) {
|
if (certificateLoader.certificateExists(pubKeyPath)) {
|
||||||
|
System.out.println("=== 检测到公钥配置,使用RSA公钥模式 ===");
|
||||||
|
System.out.println("公钥文件: " + payment.getPubKey());
|
||||||
|
System.out.println("公钥ID: " + payment.getPubKeyId());
|
||||||
|
|
||||||
String pubKeyFile = certificateLoader.loadCertificatePath(pubKeyPath);
|
String pubKeyFile = certificateLoader.loadCertificatePath(pubKeyPath);
|
||||||
System.out.println("✅ 开发环境公钥文件加载成功: " + pubKeyFile);
|
System.out.println("✅ 开发环境公钥文件加载成功: " + pubKeyFile);
|
||||||
|
|
||||||
@@ -418,15 +419,17 @@ import com.gxwebsoft.common.core.service.PaymentCacheService;
|
|||||||
.build();
|
.build();
|
||||||
System.out.println("✅ 开发环境RSA公钥配置成功");
|
System.out.println("✅ 开发环境RSA公钥配置成功");
|
||||||
} else {
|
} else {
|
||||||
System.err.println("❌ 公钥文件不存在: " + pubKeyPath);
|
System.out.println("⚠️ 开发环境公钥文件不存在,跳过公钥模式: " + pubKeyPath);
|
||||||
throw new RuntimeException("公钥文件不存在: " + pubKeyPath);
|
// 跳过公钥配置,继续后续的自动证书配置
|
||||||
}
|
}
|
||||||
} catch (Exception pubKeyException) {
|
} catch (Exception e) {
|
||||||
System.err.println("❌ RSA公钥配置失败: " + pubKeyException.getMessage());
|
System.err.println("❌ 开发环境公钥配置检查失败: " + e.getMessage());
|
||||||
pubKeyException.printStackTrace();
|
// 跳过公钥配置,继续后续的自动证书配置
|
||||||
throw new RuntimeException("RSA公钥配置失败: " + pubKeyException.getMessage(), pubKeyException);
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// 如果没有公钥配置或公钥文件不存在,尝试自动证书配置
|
||||||
|
if (config == null) {
|
||||||
// 没有公钥配置,尝试自动证书配置
|
// 没有公钥配置,尝试自动证书配置
|
||||||
try {
|
try {
|
||||||
System.out.println("=== 尝试创建自动证书配置 ===");
|
System.out.println("=== 尝试创建自动证书配置 ===");
|
||||||
|
|||||||
Reference in New Issue
Block a user