48 lines
844 B
Go
48 lines
844 B
Go
package wechat
|
|
|
|
import (
|
|
"go.ipao.vip/atom/container"
|
|
"go.ipao.vip/atom/opt"
|
|
)
|
|
|
|
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, error) {
|
|
return &config, nil
|
|
}, o.DiOptions()...)
|
|
}
|
|
|
|
const DefaultPrefix = "WeChat"
|
|
|
|
func DefaultProvider() container.ProviderContainer {
|
|
return container.ProviderContainer{
|
|
Provider: Provide,
|
|
Options: []opt.Option{
|
|
opt.Prefix(DefaultPrefix),
|
|
},
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|