-
Notifications
You must be signed in to change notification settings - Fork 2
/
cards.go
54 lines (42 loc) · 1.33 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
package paymego
import (
"context"
"time"
"github.com/sirupsen/logrus"
)
// cards check
func (c *SubscribeAPI) CardsCheck(ctx context.Context, requestID, token string, timeout ...time.Duration) (*PaymeResponse, error) {
var requestTimeout time.Duration
if len(timeout) > 0 {
requestTimeout = timeout[0]
} else {
requestTimeout = c.timeout
}
receiptParams := map[string]interface{}{
"token": token,
}
respCheckCard, err := c.sendRequest(ctx, requestID, "cards.check", receiptParams, true, requestTimeout)
if err != nil {
logrus.Errorf("failed cards check(error - %v request-id - %s response - %v)", err, requestID, respCheckCard)
return &PaymeResponse{}, err
}
return respCheckCard, nil
}
// cards remove
func (c *SubscribeAPI) CardsRemove(ctx context.Context, requestID, token string, timeout ...time.Duration) (*PaymeResponse, error) {
var requestTimeout time.Duration
if len(timeout) > 0 {
requestTimeout = timeout[0]
} else {
requestTimeout = c.timeout
}
receiptParams := map[string]interface{}{
"token": token,
}
respCheckCard, err := c.sendRequest(ctx, requestID, "cards.remove", receiptParams, true, requestTimeout)
if err != nil {
logrus.Errorf("failed cards remove (error - %v request-id - %s response - %v)", err, requestID, respCheckCard)
return &PaymeResponse{}, err
}
return respCheckCard, nil
}