fix
This commit is contained in:
@@ -137,15 +137,10 @@ func newWechatPayServiceWithWxPayPubKey(c config.Config, userAuthModel model.Use
|
||||
}
|
||||
|
||||
// 初始化 notify.Handler
|
||||
// 使用公钥方式时,certificateVisitor 可能为 nil,直接使用公钥验证器
|
||||
// 使用微信支付公钥方式时,使用 NewSHA256WithRSAPubkeyVerifier
|
||||
notifyHandler := notify.NewNotifyHandler(
|
||||
mchAPIv3Key,
|
||||
verifiers.NewSHA256WithRSACombinedVerifier(nil, mchPublicKeyID, *mchPublicKey))
|
||||
|
||||
if notifyHandler == nil {
|
||||
logx.Errorf("创建 notifyHandler 失败")
|
||||
panic("初始化失败,服务停止: notifyHandler 为 nil")
|
||||
}
|
||||
verifiers.NewSHA256WithRSAPubkeyVerifier(mchPublicKeyID, *mchPublicKey))
|
||||
|
||||
logx.Infof("微信支付客户端初始化成功(微信支付公钥方式)")
|
||||
return &WechatPayService{
|
||||
@@ -299,9 +294,6 @@ func (w *WechatPayService) CreateWechatOrder(ctx context.Context, amount float64
|
||||
|
||||
// HandleWechatPayNotification 处理微信支付回调
|
||||
func (w *WechatPayService) HandleWechatPayNotification(ctx context.Context, req *http.Request) (*payments.Transaction, error) {
|
||||
if w.notifyHandler == nil {
|
||||
return nil, fmt.Errorf("微信支付通知处理器未初始化")
|
||||
}
|
||||
transaction := new(payments.Transaction)
|
||||
_, err := w.notifyHandler.ParseNotifyRequest(ctx, req, transaction)
|
||||
if err != nil {
|
||||
@@ -313,9 +305,6 @@ func (w *WechatPayService) HandleWechatPayNotification(ctx context.Context, req
|
||||
|
||||
// HandleRefundNotification 处理微信退款回调
|
||||
func (w *WechatPayService) HandleRefundNotification(ctx context.Context, req *http.Request) (*refunddomestic.Refund, error) {
|
||||
if w.notifyHandler == nil {
|
||||
return nil, fmt.Errorf("微信支付通知处理器未初始化")
|
||||
}
|
||||
refund := new(refunddomestic.Refund)
|
||||
_, err := w.notifyHandler.ParseNotifyRequest(ctx, req, refund)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user