Files
quyun/backend_v1/providers/wechat/config.go
Rogee 557a641f41
Some checks failed
build quyun / Build (push) Failing after 2m50s
feat: migrate serevices
2025-12-19 19:05:12 +08:00

60 lines
1.1 KiB
Go

package wechat
import (
"go.ipao.vip/atom/container"
"go.ipao.vip/atom/opt"
)
const DefaultPrefix = "WeChat"
func DefaultProvider() container.ProviderContainer {
return container.ProviderContainer{
Provider: Provide,
Options: []opt.Option{
opt.Prefix(DefaultPrefix),
},
}
}
func Provide(opts ...opt.Option) error {
o := opt.New(opts...)
var config Config
if err := o.UnmarshalConfig(&config); err != nil {
return err
}
return container.Container.Provide(func() (*Config, *Client, error) {
httpClient := DefaultClient
if config.DevMode {
httpClient = httpClient.DevMode()
}
return &config, New(
WithAppID(config.AppID),
WithAppSecret(config.AppSecret),
WithAESKey(config.EncodingAESKey),
WithToken(config.Token),
WithClient(httpClient),
), nil
}, o.DiOptions()...)
}
type Config struct {
AppID string
AppSecret string
Token string
EncodingAESKey string
DevMode bool
Pay *Pay
}
type Pay struct {
MchID string
SerialNo string
MechName string
NotifyURL string
ApiV3Key string
PrivateKey string
PublicKeyID string
PublicKey string
}