Compare commits
No commits in common. "b2722abfa95a33bb61b1b796e7f66212da7771e8" and "e9a548d31df5e53dc0e650e2d02f56ca27ab65bf" have entirely different histories.
b2722abfa9
...
e9a548d31d
|
@ -15,23 +15,11 @@ import (
|
|||
"github.com/qit-team/snow-core/log/logger"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var WxClientGroup sync.Map
|
||||
|
||||
func WxClientGroupKey(wxConfig WxPay) string {
|
||||
return fmt.Sprintf("%s%s", wxConfig.AppId, wxConfig.MchId)
|
||||
}
|
||||
|
||||
// InitClient 使用提供的支付请求参数初始化微信客户端
|
||||
func InitClient(wxConfig WxPay) (*wechat.ClientV3, error) {
|
||||
key := WxClientGroupKey(wxConfig)
|
||||
clientCache, ex := WxClientGroup.Load(key)
|
||||
if ex {
|
||||
return clientCache.(*wechat.ClientV3), nil
|
||||
}
|
||||
// NewClientV3 初始化微信客户端 v3
|
||||
// mchid:商户ID 或者服务商模式的 sp_mchid
|
||||
// serialNo:商户证书的证书序列号
|
||||
|
@ -57,7 +45,6 @@ func InitClient(wxConfig WxPay) (*wechat.ClientV3, error) {
|
|||
|
||||
// 打开Debug开关,输出日志,默认是关闭的
|
||||
wxClient.DebugSwitch = gopay.DebugOn
|
||||
WxClientGroup.Store(key, wxClient)
|
||||
return wxClient, nil
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue