-
Notifications
You must be signed in to change notification settings - Fork 152
/
client.go
63 lines (49 loc) · 1.71 KB
/
client.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
package bill
import (
"github.com/ArtisanCloud/PowerLibs/v2/object"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel/power"
"github.com/ArtisanCloud/PowerWeChat/v2/src/payment/bill/response"
payment "github.com/ArtisanCloud/PowerWeChat/v2/src/payment/kernel"
)
type Client struct {
*payment.BaseClient
}
func NewClient(app *payment.ApplicationPaymentInterface) (*Client, error) {
baseClient, err := payment.NewBaseClient(app)
if err != nil {
return nil, err
}
return &Client{
baseClient,
}, nil
}
// Get Trade Bill.
// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_6.shtml
func (comp *Client) GetTradeBill(date string, billType string, tarType string) (*response.ResponseBillGet, error) {
result := &response.ResponseBillGet{}
params := &object.StringMap{
"bill_date": date,
"bill_type": billType,
"tar_type": tarType,
}
endpoint := comp.Wrap("/v3/bill/tradebill")
_, err := comp.Request(endpoint, params, "GET", nil, false, nil, result)
return result, err
}
// Get Flow Bill.
// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_7.shtml
func (comp *Client) GetFlowBill(date string, accountType string, tarType string) (*response.ResponseBillGet, error) {
result := &response.ResponseBillGet{}
params := &object.StringMap{
"bill_date": date,
"account_type": accountType,
"tar_type": tarType,
}
endpoint := comp.Wrap("/v3/bill/fundflowbill")
_, err := comp.Request(endpoint, params, "GET", nil, false, nil, result)
return result, err
}
// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_8.shtml
func (comp *Client) DownloadBill(requestDownload *power.RequestDownload, filePath string) (int64, error) {
return comp.StreamDownload(requestDownload, filePath)
}