-
Notifications
You must be signed in to change notification settings - Fork 165
/
client.go
51 lines (37 loc) · 1.27 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
package refund
import (
"fmt"
"github.com/ArtisanCloud/PowerLibs/object"
payment "github.com/ArtisanCloud/PowerWeChat/src/payment/kernel"
"github.com/ArtisanCloud/PowerWeChat/src/payment/refund/request"
"github.com/ArtisanCloud/PowerWeChat/src/payment/refund/response"
)
type Client struct {
*payment.BaseClient
}
func NewClient(app *payment.ApplicationPaymentInterface) *Client {
return &Client{
payment.NewBaseClient(app),
}
}
// Refund.
// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_9.shtml
func (comp *Client) Refund(options *request.RequestRefund) (*response.ResponseRefund, error) {
result := &response.ResponseRefund{}
body, err := object.StructToHashMap(options)
if err != nil {
return nil, err
}
endpoint := comp.Wrap("/v3/refund/domestic/refunds")
_, err = comp.PlainRequest(endpoint, nil, "POST", body, false, nil, result)
return result, err
}
// Query Refund.
// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml
func (comp *Client) Query(refundOutNO string) (*response.ResponseRefund, error) {
result := &response.ResponseRefund{}
endpoint := fmt.Sprintf("/v3/refund/domestic/refunds/%s", refundOutNO)
endpoint = comp.Wrap(endpoint)
_, err := comp.Request(endpoint, nil, "GET", nil, false, nil, result)
return result, err
}