fix wechatpay

This commit is contained in:
liangzai 2025-06-09 18:23:18 +08:00
parent 1967a02d1a
commit 0ebec3760d
4 changed files with 5 additions and 4 deletions

View File

@ -47,6 +47,7 @@ Wxpay:
MchPrivateKeyPath: "etc/merchant/apiclient_key.pem"
MchPublicKeyID: "PUB_KEY_ID_0116826351362025060900382267001601"
MchPublicKeyPath: "etc/merchant/pub_key.pem"
MchPlatformRAS: "1FFEC3F62E31885FAB4C91ADCB8D7557E9488781"
NotifyUrl: "https://6m4685017o.goho.co/api/v1/pay/wechat/callback"
RefundNotifyUrl: "https://6m4685017o.goho.co/api/v1/wechat/refund_callback"
Applepay:

View File

@ -48,6 +48,7 @@ Wxpay:
MchPrivateKeyPath: "etc/merchant/apiclient_key.pem"
MchPublicKeyID: "PUB_KEY_ID_0116826351362025060900382267001601"
MchPublicKeyPath: "etc/merchant/pub_key.pem"
MchPlatformRAS: "1FFEC3F62E31885FAB4C91ADCB8D7557E9488781"
NotifyUrl: "https://www.quannengcha.com/api/v1/pay/wechat/callback"
RefundNotifyUrl: "https://www.quannengcha.com/api/v1/wechat/refund_callback"
Applepay:

View File

@ -63,6 +63,7 @@ type WxpayConfig struct {
MchPrivateKeyPath string
MchPublicKeyID string
MchPublicKeyPath string
MchPlatformRAS string
NotifyUrl string
RefundNotifyUrl string
}

View File

@ -119,7 +119,7 @@ func newWechatPayServiceWithWxPayPubKey(c config.Config, userAuthModel model.Use
panic(fmt.Sprintf("初始化失败,服务停止: %v", err))
}
// 从文件中加载微信支付平台证书
// 从文件中加载支付公钥
mchPublicKey, err := utils.LoadPublicKeyWithPath(mchPublicKeyPath)
if err != nil {
logx.Errorf("加载微信支付平台证书失败: %v", err)
@ -136,11 +136,9 @@ func newWechatPayServiceWithWxPayPubKey(c config.Config, userAuthModel model.Use
panic(fmt.Sprintf("初始化失败,服务停止: %v", err))
}
// 初始化 notify.Handler
certificateVisitor := downloader.MgrInstance().GetCertificateVisitor(mchID)
notifyHandler := notify.NewNotifyHandler(
mchAPIv3Key,
verifiers.NewSHA256WithRSACombinedVerifier(certificateVisitor, mchPublicKeyID, *mchPublicKey))
verifiers.NewSHA256WithRSAPubkeyVerifier(mchPublicKeyID, *mchPublicKey))
logx.Infof("微信支付客户端初始化成功(微信支付公钥方式)")
return &WechatPayService{