forked from checkout/checkout-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sessions_responses.go
184 lines (164 loc) · 8.58 KB
/
sessions_responses.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package sessions
import (
"time"
"github.com/PaddleHQ/checkout-sdk-go/common"
"github.com/PaddleHQ/checkout-sdk-go/sessions/channels"
"github.com/PaddleHQ/checkout-sdk-go/sessions/sources"
)
type ChallengeCancelReason string
const (
CardHolderCancel ChallengeCancelReason = "cardholder_cancel"
TransactionTimedOut ChallengeCancelReason = "transaction_timed_out"
ChallengeTimedOut ChallengeCancelReason = "challenge_timed_out"
TransactionError ChallengeCancelReason = "transaction_error"
SdkTimedOut ChallengeCancelReason = "sdk_timed_out"
Unknown ChallengeCancelReason = "unknown"
)
type SessionInterface string
const (
NativeUi SessionInterface = "native_ui"
Html SessionInterface = "html"
)
type ResponseCode string
const (
Y ResponseCode = "Y"
N ResponseCode = "N"
U ResponseCode = "U"
A ResponseCode = "A"
C ResponseCode = "C"
D ResponseCode = "D"
R ResponseCode = "R"
I ResponseCode = "I"
)
type (
SessionResponse struct {
Accepted *SessionDetails `json:"accepted,omitempty"`
Created *SessionDetails `json:"created,omitempty"`
}
SessionDetails struct {
HttpMetadata common.HttpMetadata
Id string `json:"id,omitempty"`
SessionSecret string `json:"session_secret,omitempty"`
TransactionId string `json:"transaction_id,omitempty"`
Scheme sources.SessionScheme `json:"scheme,omitempty"`
Amount int64 `json:"amount,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
Completed bool `json:"completed,omitempty"`
Challenged bool `json:"challenged,omitempty"`
AuthenticationType AuthenticationType `json:"authentication_type,omitempty"`
AuthenticationCategory Category `json:"authentication_category,omitempty"`
Certificates *DsPublicKeys `json:"certificates,omitempty"`
Status SessionStatus `json:"status,omitempty"`
StatusReason StatusReason `json:"status_reason,omitempty"`
Approved bool `json:"approved,omitempty"`
ProtocolVersion string `json:"protocol_version,omitempty"`
Reference string `json:"reference,omitempty"`
TransactionType TransactionType `json:"transaction_type,omitempty"`
NextActions []NextAction `json:"next_actions,omitempty"`
Ds *Ds `json:"ds,omitempty"`
Acs *Acs `json:"acs,omitempty"`
ResponseCode ResponseCode `json:"response_code,omitempty"`
ResponseStatusReason string `json:"response_status_reason,omitempty"`
Pareq string `json:"pareq,omitempty"`
Cryptogram string `json:"cryptogram,omitempty"`
Eci string `json:"eci,omitempty"`
Xid string `json:"xid,omitempty"`
CardholderInfo string `json:"cardholder_info,omitempty"`
Card *CardInfo `json:"card,omitempty"`
Recurring *Recurring `json:"recurring,omitempty"`
Installment *Installment `json:"installment,omitempty"`
CustomerIp string `json:"customer_ip,omitempty"`
AuthenticationDate *time.Time `json:"authentication_date,omitempty"`
Exemption *ThreeDsExemption `json:"exemption,omitempty"`
FlowType common.ThreeDsFlowType `json:"flow_type,omitempty"`
ChallengeIndicator common.ChallengeIndicator `json:"challenge_indicator,omitempty"`
SchemeInfo *SchemeInfo `json:"scheme_info,omitempty"`
Links map[string]common.Link `json:"_links"`
}
GetSessionResponse struct {
SessionDetails
}
Update3dsMethodCompletionResponse struct {
HttpMetadata common.HttpMetadata
Id string `json:"id,omitempty"`
SessionSecret string `json:"session_secret,omitempty"`
TransactionId string `json:"transaction_id,omitempty"`
Scheme sources.SessionScheme `json:"scheme,omitempty"`
Amount int64 `json:"amount,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
Completed bool `json:"completed,omitempty"`
Challenged bool `json:"challenged,omitempty"`
AuthenticationType AuthenticationType `json:"authentication_type,omitempty"`
AuthenticationCategory Category `json:"authentication_category,omitempty"`
Certificates *DsPublicKeys `json:"certificates,omitempty"`
Status SessionStatus `json:"status,omitempty"`
StatusReason StatusReason `json:"status_reason,omitempty"`
Approved bool `json:"approved,omitempty"`
ProtocolVersion string `json:"protocol_version,omitempty"`
Reference string `json:"reference,omitempty"`
TransactionType TransactionType `json:"transaction_type,omitempty"`
NextActions []NextAction `json:"next_actions,omitempty"`
Ds *Ds `json:"ds,omitempty"`
Acs *Acs `json:"acs,omitempty"`
ResponseCode ResponseCode `json:"response_code,omitempty"`
ResponseStatusReason string `json:"response_status_reason,omitempty"`
Pareq string `json:"pareq,omitempty"`
Cryptogram string `json:"cryptogram,omitempty"`
Eci string `json:"eci,omitempty"`
Xid string `json:"xid,omitempty"`
Card *CardInfo `json:"card,omitempty"`
Links map[string]common.Link `json:"_links"`
}
)
func (r *SessionResponse) MapResponse(response *SessionDetails) {
switch response.HttpMetadata.StatusCode {
case 201:
r.Created = response
case 202:
r.Accepted = response
}
}
type (
CardInfo struct {
InstrumentId string `json:"instrument_id,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
DsPublicKeys struct {
DsPublic string `json:"ds_public,omitempty"`
CaPublic string `json:"ca_public,omitempty"`
}
Ds struct {
DsId string `json:"ds_id,omitempty"`
ReferenceNumber string `json:"reference_number,omitempty"`
TransactionId string `json:"transaction_id,omitempty"`
}
Acs struct {
ReferenceNumber string `json:"reference_number,omitempty"`
TransactionId string `json:"transaction_id,omitempty"`
OperatorId string `json:"operator_id,omitempty"`
Url string `json:"url,omitempty"`
SignedContent string `json:"signed_content,omitempty"`
ChallengeMandated bool `json:"challenge_mandated,omitempty"`
AuthenticationType string `json:"authentication_type,omitempty"`
ChallengeCancelReason ChallengeCancelReason `json:"challenge_cancel_reason,omitempty"`
Interface SessionInterface `json:"interface,omitempty"`
UiTemplate channels.UIElements `json:"ui_template,omitempty"`
ChallengeCancelReasonCode string `json:"challenge_cancel_reason_code,omitempty"`
}
ThreeDsExemption struct {
Requested string `json:"requested,omitempty"`
Applied common.Exemption `json:"applied,omitempty"`
Code string `json:"code,omitempty"`
TrustedBeneficiary *TrustedBeneficiary `json:"trusted_beneficiary,omitempty"`
}
TrustedBeneficiary struct {
Status string `json:"status,omitempty"`
Source string `json:"source,omitempty"`
}
SchemeInfo struct {
Name sources.SessionScheme `json:"name,omitempty"`
Score string `json:"score,omitempty"`
Avalgo string `json:"avalgo,omitempty"`
}
)