You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wechatpayopen/client.go

59 lines
1.5 KiB

2 years ago
package wechatpayopen
import (
"go.dtapp.net/golog"
"go.dtapp.net/gorequest"
)
2 years ago
// ClientConfig 实例配置
type ClientConfig struct {
2 years ago
SpAppid string // 服务商应用ID
SpMchId string // 服务商户号
ApiV2 string // APIv2密钥
ApiV3 string // APIv3密钥
SerialNo string // 序列号
MchSslSerialNo string // pem 证书号
MchSslCer string // pem 内容
MchSslKey string // pem key 内容
2 years ago
}
2 years ago
// Client 实例
2 years ago
type Client struct {
2 years ago
requestClient *gorequest.App // 请求服务
config struct {
spAppid string // 服务商应用ID
spMchId string // 服务商户号
subAppid string // 子商户应用ID
subMchId string // 子商户号
apiV2 string // APIv2密钥
apiV3 string // APIv3密钥
serialNo string // 序列号
mchSslSerialNo string // pem 证书号
mchSslCer string // pem 内容
mchSslKey string // pem key 内容
}
log struct {
2 years ago
status bool // 状态
2 years ago
client *golog.ApiClient // 日志服务
2 years ago
}
2 years ago
}
2 years ago
// NewClient 创建实例化
2 years ago
func NewClient(config *ClientConfig) (*Client, error) {
2 years ago
2 years ago
c := &Client{}
2 years ago
c.config.spAppid = config.SpAppid
c.config.spMchId = config.SpMchId
c.config.apiV2 = config.ApiV2
c.config.apiV3 = config.ApiV3
c.config.serialNo = config.SerialNo
c.config.mchSslSerialNo = config.MchSslSerialNo
c.config.mchSslCer = config.MchSslCer
c.config.mchSslKey = config.MchSslKey
2 years ago
2 years ago
c.requestClient = gorequest.NewHttp()
2 years ago
return c, nil
}