forked from thealish/paymego
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cards.go
108 lines (101 loc) · 2.38 KB
/
cards.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
99
100
101
102
103
104
105
106
107
108
package paymego
import (
"context"
"net/http"
)
func (s SubscribeAPI) CardsGetVerifyCode(
ctx context.Context,
requestID,
token string,
) (*CardsGetVerifyCodeResponse, error) {
request, err := newCardsGetVerifyCodeRequest(requestID, token)
if err != nil {
return nil, err
}
response := CardsGetVerifyCodeResponse{}
err = s.do(ctx, request, http.MethodPost, &response, false)
return &response, nil
}
func (s SubscribeAPI) CardsCreate(
ctx context.Context,
requestID string,
save bool,
cardNumber,
cardExpiration string,
) (*CardsCreateResponse, error) {
request, err := newCardsCreateRequest(requestID, cardNumber, cardExpiration, save)
if err != nil {
return nil, err
}
response := CardsCreateResponse{}
err = s.do(ctx, request, http.MethodPost, &response, false)
if err != nil {
return nil, err
}
return &response, err
}
func (s SubscribeAPI) CardsVerify(
ctx context.Context,
requestID,
code,
token string,
) (*CardsVerifyResponse, error) {
request, err := newCardsVerifyRequest(requestID, token, code)
if err != nil {
return nil, err
}
response := CardsVerifyResponse{}
err = s.do(ctx, request, http.MethodPost, &response, false)
if err != nil {
return nil, err
}
return &response, err
}
func (s SubscribeAPI) CardsCheck(
ctx context.Context,
requestID,
token string,
) (*CardsCheckResponse, error) {
request, err := newCardsCheckRequest(requestID, token)
if err != nil {
return nil, err
}
response := CardsCheckResponse{}
err = s.do(ctx, request, http.MethodPost, &response, true)
if err != nil {
return nil, err
}
return &response, err
}
func (s SubscribeAPI) CardsRemove(
ctx context.Context,
requestID,
token string,
) (*CardsRemoveResponse, error) {
request, err := newCardsRemoveRequest(requestID, token)
if err != nil {
return nil, err
}
response := CardsRemoveResponse{}
err = s.do(ctx, request, http.MethodPost, &response, true)
if err != nil {
return nil, err
}
return &response, err
}
func (s SubscribeAPI) CardsCheckBalance(
ctx context.Context,
requestID, token string,
amount int,
) (CardsCheckBalanceResponse, error) {
request, err := newCardsCheckBalanceRequest(requestID, token, amount)
if err != nil {
return CardsCheckBalanceResponse{}, err
}
var response CardsCheckBalanceResponse
err = s.do(ctx, request, http.MethodPost, &response, true)
if err != nil {
return CardsCheckBalanceResponse{}, err
}
return response, err
}