forked from checkout/checkout-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session_sources.go
108 lines (88 loc) · 2.97 KB
/
session_sources.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 sources
import (
"github.com/PaddleHQ/checkout-sdk-go/common"
)
type SessionSourceType string
const (
Card SessionSourceType = "card"
Id SessionSourceType = "id"
Token SessionSourceType = "token"
NetworkToken SessionSourceType = "network_token"
)
type SessionScheme string
const (
Visa SessionScheme = "visa"
Mastercard SessionScheme = "mastercard"
Jcb SessionScheme = "jcb"
Amex SessionScheme = "amex"
Diners SessionScheme = "diners"
CartesBancaires SessionScheme = "cartes_bancaires"
)
type (
SessionSource interface {
GetType() SessionSourceType
}
SessionSourceInfo struct {
Type SessionSourceType `json:"type,omitempty"`
Scheme SessionScheme `json:"scheme,omitempty"`
BillingAddress *SessionAddress `json:"billing_address,omitempty"`
HomePhone *common.Phone `json:"home_phone,omitempty"`
MobilePhone *common.Phone `json:"mobile_phone,omitempty"`
WorkPhone *common.Phone `json:"work_phone,omitempty"`
Email string `json:"email,omitempty"`
}
sessionCardSource struct {
SessionSourceInfo
Number string `json:"number,omitempty"`
ExpiryMonth int `json:"expiry_month,omitempty"`
ExpiryYear int `json:"expiry_year,omitempty"`
Name string `json:"name,omitempty"`
Stored bool `json:"stored,omitempty"`
StoreForFutureUse bool `json:"store_for_future_use,omitempty"`
}
sessionIdSource struct {
SessionSourceInfo
Id string `json:"id,omitempty"`
}
sessionTokenSource struct {
SessionSourceInfo
Token string `json:"token,omitempty"`
StoreForFutureUse bool `json:"store_for_future_use,omitempty"`
}
sessionNetworkTokenSource struct {
SessionSourceInfo
Token string `json:"token,omitempty"`
ExpiryMonth int `json:"expiry_month,omitempty"`
ExpiryYear int `json:"expiry_year,omitempty"`
Name string `json:"name,omitempty"`
Stored bool `json:"stored,omitempty"`
}
)
func NewSessionCardSource() *sessionCardSource {
return &sessionCardSource{SessionSourceInfo: SessionSourceInfo{Type: Card}}
}
func NewSessionIdSource() *sessionIdSource {
return &sessionIdSource{SessionSourceInfo: SessionSourceInfo{Type: Id}}
}
func NewSessionTokenSource() *sessionTokenSource {
return &sessionTokenSource{SessionSourceInfo: SessionSourceInfo{Type: Token}}
}
func NewSessionNetworkTokenSource() *sessionNetworkTokenSource {
return &sessionNetworkTokenSource{SessionSourceInfo: SessionSourceInfo{Type: NetworkToken}}
}
func (s *sessionCardSource) GetType() SessionSourceType {
return s.Type
}
func (s *sessionIdSource) GetType() SessionSourceType {
return s.Type
}
func (s *sessionTokenSource) GetType() SessionSourceType {
return s.Type
}
func (s *sessionNetworkTokenSource) GetType() SessionSourceType {
return s.Type
}
type SessionAddress struct {
common.Address
AddressLine3 string `json:"address_line3,omitempty"`
}