🎨 完善微信登录相关工具类
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
|
||||
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount"
|
||||
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment"
|
||||
"log"
|
||||
)
|
||||
|
||||
var WeOfficial *officialAccount.OfficialAccount
|
||||
var WechatPay *payment.Payment
|
||||
|
||||
// InitWeOfficial 初始化微信公众号
|
||||
func InitWeOfficial() {
|
||||
OfficialAccountApp, err := officialAccount.NewOfficialAccount(&officialAccount.UserConfig{
|
||||
AppID: "[appid]", // 公众号、小程序的appid
|
||||
Secret: "[app secret]", //
|
||||
|
||||
Log: officialAccount.Log{
|
||||
Level: "debug",
|
||||
// 可以重定向到你的目录下,如果设置File和Error,默认会在当前目录下的wechat文件夹下生成日志
|
||||
File: "/Users/user/wechat/official-account/info.log",
|
||||
Error: "/Users/user/wechat/official-account/error.log",
|
||||
Stdout: false, // 是否打印在终端
|
||||
},
|
||||
|
||||
HttpDebug: true,
|
||||
Debug: false,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Println("初始化微信公众号 SDK失败", err)
|
||||
}
|
||||
WeOfficial = OfficialAccountApp
|
||||
}
|
||||
|
||||
// InitWechatPay 初始化微信支付
|
||||
func InitWechatPay() {
|
||||
PaymentService, err := payment.NewPayment(&payment.UserConfig{
|
||||
AppID: "[app_id]", // 小程序、公众号或者企业微信的appid
|
||||
MchID: "[mch_id]", // 商户号 appID
|
||||
MchApiV3Key: "[mch_api_v3_key]", // 微信V3接口调用必填
|
||||
Key: "[key]", // 微信V2接口调用必填
|
||||
CertPath: "[wx_cert_path]", // 商户后台支付的Cert证书路径
|
||||
KeyPath: "[wx_key_path]", // 商户后台支付的Key证书路径
|
||||
SerialNo: "[serial_no]", // 商户支付证书序列号
|
||||
NotifyURL: "[notify_url]", // 微信支付回调地址
|
||||
HttpDebug: true,
|
||||
Log: payment.Log{
|
||||
Level: "debug",
|
||||
// 可以重定向到你的目录下,如果设置File和Error,默认会在当前目录下的wechat文件夹下生成日志
|
||||
File: "/Users/user/wechat/payment/info.log",
|
||||
Error: "/Users/user/wechat/payment/error.log",
|
||||
Stdout: false, // 是否打印在终端
|
||||
},
|
||||
Http: payment.Http{
|
||||
Timeout: 30.0,
|
||||
BaseURI: "https://api.mch.weixin.qq.com",
|
||||
},
|
||||
// 可选,不传默认走程序内存
|
||||
Cache: kernel.NewRedisClient(&kernel.UniversalOptions{
|
||||
Addrs: []string{"127.0.0.1:6379"},
|
||||
Password: "",
|
||||
DB: 0,
|
||||
}),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Println("初始化微信支付 SDK失败", err)
|
||||
}
|
||||
WechatPay = PaymentService
|
||||
}
|
Reference in New Issue
Block a user