forked from objcoding/wxpay
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaccount.go
More file actions
50 lines (42 loc) · 853 Bytes
/
account.go
File metadata and controls
50 lines (42 loc) · 853 Bytes
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
package wxpay
import (
"io/ioutil"
"log"
)
type Account struct {
appID string
mchID string
apiKey string
certData []byte
isSandbox bool
}
// 创建微信支付账号
func NewAccount(appID string, mchID string, apiKey string, isSanbox bool) *Account {
return &Account{
appID: appID,
mchID: mchID,
apiKey: apiKey,
isSandbox: isSanbox,
}
}
func (a *Account) AppID() (appID string) {
return a.appID
}
func (a *Account) MchID() (mchID string) {
return a.mchID
}
func (a *Account) ApiKey() (apiKey string) {
return a.apiKey
}
func (a *Account) SetCertData(certData []byte) {
a.certData = certData
}
// 设置证书
func (a *Account) LoadCertDataFromFile(certPath string) {
certData, err := ioutil.ReadFile(certPath)
if err != nil {
log.Println("读取证书失败")
return
}
a.certData = certData
}