From 0ebec3760d9a5acc2bbd0dd0bc08e63a18bd0995 Mon Sep 17 00:00:00 2001 From: liangzai <2440983361@qq.com> Date: Mon, 9 Jun 2025 18:23:18 +0800 Subject: [PATCH] fix wechatpay --- app/main/api/etc/main.dev.yaml | 1 + app/main/api/etc/main.yaml | 1 + app/main/api/internal/config/config.go | 1 + app/main/api/internal/service/wechatpayService.go | 6 ++---- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/main/api/etc/main.dev.yaml b/app/main/api/etc/main.dev.yaml index b12b6f1..e5b0143 100644 --- a/app/main/api/etc/main.dev.yaml +++ b/app/main/api/etc/main.dev.yaml @@ -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: diff --git a/app/main/api/etc/main.yaml b/app/main/api/etc/main.yaml index e0dca16..15157e7 100644 --- a/app/main/api/etc/main.yaml +++ b/app/main/api/etc/main.yaml @@ -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: diff --git a/app/main/api/internal/config/config.go b/app/main/api/internal/config/config.go index c0692cb..2cc6ef2 100644 --- a/app/main/api/internal/config/config.go +++ b/app/main/api/internal/config/config.go @@ -63,6 +63,7 @@ type WxpayConfig struct { MchPrivateKeyPath string MchPublicKeyID string MchPublicKeyPath string + MchPlatformRAS string NotifyUrl string RefundNotifyUrl string } diff --git a/app/main/api/internal/service/wechatpayService.go b/app/main/api/internal/service/wechatpayService.go index 1c489a5..8e97a5f 100644 --- a/app/main/api/internal/service/wechatpayService.go +++ b/app/main/api/internal/service/wechatpayService.go @@ -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{