-
Notifications
You must be signed in to change notification settings - Fork 21
/
tokens.go
86 lines (73 loc) · 2.82 KB
/
tokens.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
package tokens
import (
"time"
"github.com/checkout/checkout-sdk-go/common"
)
const tokensPath = "tokens"
type TokenType string
const (
Card TokenType = "card"
ApplePay TokenType = "applepay"
GooglePay TokenType = "googlepay"
)
type (
CardTokenRequest struct {
Type TokenType `json:"type" binding:"required"`
Number string `json:"number" binding:"required"`
ExpiryMonth int `json:"expiry_month" binding:"required"`
ExpiryYear int `json:"expiry_year" binding:"required"`
Name string `json:"name,omitempty"`
CVV string `json:"cvv,omitempty"`
BillingAddress *common.Address `json:"billing_address,omitempty"`
Phone *common.Phone `json:"phone,omitempty"`
}
WalletTokenRequest struct {
Type TokenType `json:"type" binding:"required"`
TokenData TokenData `json:"token_data" binding:"required"`
}
)
type (
TokenData interface {
GetType() TokenType
}
ApplePayTokenData struct {
Version string `json:"version,omitempty"`
Data string `json:"data,omitempty"`
Signature string `json:"signature,omitempty"`
Header map[string]string `json:"header,omitempty"`
}
GooglePayTokenData struct {
Signature string `json:"signature,omitempty"`
ProtocolVersion string `json:"protocolVersion,omitempty"`
SignedMessage string `json:"signedMessage,omitempty"`
}
)
func (t *ApplePayTokenData) GetType() TokenType {
return ApplePay
}
func (t *GooglePayTokenData) GetType() TokenType {
return GooglePay
}
type (
CardTokenResponse struct {
HttpMetadata common.HttpMetadata
Type TokenType `json:"type,omitempty"`
Token string `json:"token" binding:"required"`
ExpiresOn *time.Time `json:"expires_on,omitempty"`
ExpiryMonth int `json:"expiry_month,omitempty"`
ExpiryYear int `json:"expiry_year,omitempty"`
Scheme string `json:"scheme,omitempty"`
Last4 string `json:"last4,omitempty"`
Bin string `json:"bin,omitempty"`
CardType common.CardType `json:"card_type,omitempty"`
CardCategory common.CardCategory `json:"card_category,omitempty"`
Issuer string `json:"issuer,omitempty"`
IssuerCountry string `json:"issuer_country,omitempty"`
ProductID string `json:"product_id,omitempty"`
ProductType string `json:"product_type,omitempty"`
TokenFormat string `json:"token_format,omitempty"`
Name string `json:"name,omitempty"`
BillingAddress *common.Address `json:"billing_address,omitempty"`
Phone *common.Phone `json:"phone,omitempty"`
}
)