-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
98 lines (82 loc) · 2.43 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"fmt"
"github.com/ArtisanCloud/PowerDouYin/src/kernel"
"github.com/ArtisanCloud/PowerDouYin/src/miniProgram"
"github.com/ArtisanCloud/PowerDouYin/src/payment"
fmt2 "github.com/ArtisanCloud/PowerLibs/v3/fmt"
"os"
)
func GetMiniProgramConfig() *miniProgram.UserConfig {
return &miniProgram.UserConfig{
AppID: os.Getenv("miniprogram_app_id"), // 小程序、公众号或者企业微信的appid
Secret: os.Getenv("miniprogram_secret"), // 商户号 appID
ResponseType: os.Getenv("array"),
Log: miniProgram.Log{
Level: "debug",
File: "./wechat.log",
},
Cache: kernel.NewRedisClient(&kernel.RedisOptions{
Addr: "127.0.0.1:6379",
Password: "",
DB: 1,
}),
HttpDebug: true,
//Debug: true,
//"sandbox": true,
}
}
func GetPaymentConfig() *payment.UserConfig {
return &payment.UserConfig{
//"corp_id": os.Getenv("corp_id"),
//"secret": os.Getenv("secret"),
AppID: os.Getenv("app_id"),
MchID: os.Getenv("mch_id"),
MchApiV3Key: os.Getenv("mch_api_v3_key"),
Key: os.Getenv("key"),
CertPath: os.Getenv("wx_cert_path"),
KeyPath: os.Getenv("wx_key_path"),
SerialNo: os.Getenv("serial_no"),
CertificateKeyPath: os.Getenv("certificate_key_path"),
WechatPaySerial: os.Getenv("wechat_pay_serial"),
RSAPublicKeyPath: os.Getenv("rsa_public_key_path"),
ResponseType: os.Getenv("array"),
Log: payment.Log{
Level: "debug",
File: "./wechat.log",
},
Http: payment.Http{
Timeout: 30.0,
BaseURI: "https://api.mch.weixin.qq.com",
},
Cache: kernel.NewRedisClient(&kernel.RedisOptions{
Addr: "127.0.0.1:6379",
Password: "",
DB: 1,
}),
NotifyURL: os.Getenv("notify_url"),
HttpDebug: true,
//Debug: true,
//"sandbox": true,
// server config
//Token: os.Getenv("token"),
//AESKey: os.Getenv("aes_key"),
}
}
func main() {
fmt.Printf("hello Wechat! \n")
// init payment app
configPayment := GetPaymentConfig()
paymentApp, err := payment.NewPayment(configPayment)
if err != nil {
fmt.Println(err.Error())
}
fmt2.Dump("payment config:", paymentApp.GetConfig().All())
// init miniProgram app
configMiniProgram := GetMiniProgramConfig()
miniProgramApp, err := miniProgram.NewMiniProgram(configMiniProgram)
if err != nil {
fmt.Println(err.Error())
}
fmt2.Dump("miniprogram config:", miniProgramApp.GetConfig().All())
}