forked from vasconcelosvcd/go-cielo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokenization.go
40 lines (31 loc) · 881 Bytes
/
tokenization.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
package cielo
import (
"bytes"
"fmt"
)
//CreateTokenizeCard returns the tokenized card
//Endpoint POST /1/card
func (c *Client) CreateTokenizeCard(creditCard *CreditCard) (*CreditCard, error) {
req, err := c.NewRequest("POST", fmt.Sprintf("%s%s", c.Environment.APIUrl, "/1/card/"), creditCard)
cCard := &CreditCard{}
if err != nil {
return cCard, err
}
err = c.Send(req, creditCard)
if err != nil {
return cCard, err
}
return creditCard, err
}
//CreateTokenizeCard returns some card information
//Endpoint GET /1/card/{TOKEN}
func (c *Client) GetTokenizeCard(cardToken string) (*CreditCard, error) {
buf := bytes.NewBuffer([]byte(""))
req, err := c.NewRequest("GET", fmt.Sprintf("%s%s%s", c.Environment.APIQueryURL, "/1/card/", cardToken), buf)
cCard := &CreditCard{}
if err != nil {
return cCard, err
}
err = c.Send(req, cCard)
return cCard, err
}