-
Notifications
You must be signed in to change notification settings - Fork 0
/
register_card.go
60 lines (43 loc) · 1.56 KB
/
register_card.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
package gogojudo
import (
"bytes"
"encoding/json"
"net/http"
)
type RegisterCardModel struct {
// Required Fields
CV2 string `json:"cv2"` // CV2 from the credit card, also known as the card verification value (CVV) or security code. The 3 or 4 digit number on the back of a card
CardNumber string `json:"cardNumber"` // The unique number printed on a credit card, should be submitted without any whitespace or non-numeric characters
ConsumerReference string `json:"yourConsumerReference,omitempty"`
PaymentReference string `json:"yourPaymentReference,omitempty"`
// Dates
ExpiryDate string `json:"expiryDate,omitempty"`
StartDate string `json:"startDate,omitempty"`
IssueNumber int `json:"issue_number,omitempty"`
// Address
CardAddress string `json:"card_address,omitempty"`
// Other Details
ClientDetails map[string]interface{} `json:"client_details,omitempty"`
JudoID string `json:"judo_id,omitempty"`
Currency string `json:"currency,omitempty"`
}
type RegisterCardResponse struct {
}
func (jp *JudoPay) RegisterCard(rcp RegisterCardModel) (ret RegisterCardResponse, err error) {
requestBody, err := json.Marshal(rcp)
if err != nil {
return ret, err
}
request, err := http.NewRequest(http.MethodPost, jp.APIUrl.String(), bytes.NewBuffer(requestBody))
jp.SetHeaders(request)
if err != nil {
return ret, err
}
resp, err := jp.HttpClient.Do(request)
if err != nil {
return ret, err
}
defer resp.Body.Close()
json.NewDecoder(resp.Body).Decode(&ret)
return ret, nil
}