feat: add private key
This commit is contained in:
@@ -15,14 +15,3 @@ func DefaultProvider() container.ProviderContainer {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Debug bool
|
||||
NotifyURL string
|
||||
|
||||
AppId string
|
||||
MchId string
|
||||
SerialNo string
|
||||
APIv3Key string
|
||||
PrivateKey string
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
w "quyun/providers/wechat"
|
||||
|
||||
"github.com/go-pay/gopay"
|
||||
"github.com/go-pay/gopay/wechat/v3"
|
||||
"go.ipao.vip/atom/container"
|
||||
@@ -17,13 +19,19 @@ func Provide(opts ...opt.Option) error {
|
||||
if err := o.UnmarshalConfig(&config); err != nil {
|
||||
return err
|
||||
}
|
||||
return container.Container.Provide(func() (*Client, error) {
|
||||
return container.Container.Provide(func(wechatConfig *w.Config) (*Client, error) {
|
||||
// NewClientV3 初始化微信客户端 v3
|
||||
// mchid:商户ID 或者服务商模式的 sp_mchid
|
||||
// serialNo:商户证书的证书序列号
|
||||
// apiV3Key:apiV3Key,商户平台获取
|
||||
// privateKey:私钥 apiclient_key.pem 读取后的内容
|
||||
client, err := wechat.NewClientV3(config.MchId, config.SerialNo, config.APIv3Key, config.PrivateKey)
|
||||
// 1、你最多可同时使用3个有效证书,为减少风险,建议及时作废不使用的API证书;
|
||||
// 2、API证书包括:私钥文件及公钥证书(配对使用),仅保存在申请证书的电脑本地,无法从系统下载;
|
||||
// 3、私钥文件名为“prikey_序列号”,公钥证书名为“pubkey_序列号”,序列号请查看上述列表。若无法找到证书文件,可申请新证书。
|
||||
client, err := wechat.NewClientV3(
|
||||
w.Pay.MchID, w.Pay.SerialNo, w.Pay.ApiV3Key, w.Pay.PrivateKey,
|
||||
wechatConfig.MchId, wechatConfig.SerialNo, wechatConfig.APIv3Key, wechatConfig.PrivateKey
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user