feat: complete wechat pay

This commit is contained in:
Rogee
2025-04-30 19:26:53 +08:00
parent 11288471d4
commit 67d6f3ec33
10 changed files with 44 additions and 21 deletions

View File

@@ -48,10 +48,12 @@ type Config struct {
}
type Pay struct {
MchID string
SerialNo string
MechName string
NotifyURL string
ApiV3Key string
PrivateKey string
MchID string
SerialNo string
MechName string
NotifyURL string
ApiV3Key string
PrivateKey string
PublicKeyID string
PublicKey string
}

View File

@@ -4,13 +4,13 @@ import (
"context"
"crypto/rsa"
"encoding/json"
"errors"
"time"
w "quyun/providers/wechat"
"github.com/go-pay/gopay"
"github.com/go-pay/gopay/wechat/v3"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"go.ipao.vip/atom/container"
"go.ipao.vip/atom/opt"
@@ -40,6 +40,11 @@ func Provide(opts ...opt.Option) error {
client.DebugSwitch = gopay.DebugOn
}
err = client.AutoVerifySignByPublicKey([]byte(wechatConfig.Pay.PublicKey), wechatConfig.Pay.PublicKeyID)
if err != nil {
return nil, errors.Wrap(err, "AutoVerifySignByPublicKey")
}
return &Client{
payClient: client,
config: wechatConfig,