fix: 微信支付,创建失败,问题修复。
This commit is contained in:
@@ -59,13 +59,16 @@ public class WxPayConfiguration {
|
||||
log.info("使用私钥路径配置: {}", wxPayProperties.getPrivateKeyPath());
|
||||
}
|
||||
|
||||
// 商户证书配置(V3 API必须,apiclient_cert.pem)
|
||||
if (wxPayProperties.getPrivateCertContent() != null && !wxPayProperties.getPrivateCertContent().isEmpty()) {
|
||||
payConfig.setPrivateCertContent(wxPayProperties.getPrivateCertContent().getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
// 商户证书配置(apiclient_cert.pem),有真实PEM内容才设置,避免占位符导致v3请求构造异常
|
||||
String privateCertContent = wxPayProperties.getPrivateCertContent();
|
||||
if (privateCertContent != null && privateCertContent.startsWith("-----BEGIN CERTIFICATE-----")) {
|
||||
payConfig.setPrivateCertContent(privateCertContent.getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
log.info("使用商户证书内容配置");
|
||||
} else if (wxPayProperties.getPrivateCertPath() != null) {
|
||||
payConfig.setPrivateCertPath(wxPayProperties.getPrivateCertPath());
|
||||
log.info("使用商户证书路径配置: {}", wxPayProperties.getPrivateCertPath());
|
||||
} else {
|
||||
log.info("未配置商户证书,将使用私钥直接签名");
|
||||
}
|
||||
|
||||
WxPayService wxPayService = new WxPayServiceImpl();
|
||||
|
||||
Reference in New Issue
Block a user