-
Notifications
You must be signed in to change notification settings - Fork 448
/
setupattempt.go
177 lines (152 loc) · 9.44 KB
/
setupattempt.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
package stripe
import (
"encoding/json"
)
// SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlow indicates the type of 3D Secure authentication performed.
type SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlow string
// List of values that SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlow can take.
const (
SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlowChallenge SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlow = "challenge"
SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlowFrictionless SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlow = "frictionless"
)
// SetupAttemptPaymentMethodDetailsCardThreeDSecureResult indicates the outcome of 3D Secure authentication.
type SetupAttemptPaymentMethodDetailsCardThreeDSecureResult string
// List of values that SetupAttemptPaymentMethodDetailsCardThreeDSecureResult can take.
const (
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultAttemptAcknowledged SetupAttemptPaymentMethodDetailsCardThreeDSecureResult = "attempt_acknowledged"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultAuthenticated SetupAttemptPaymentMethodDetailsCardThreeDSecureResult = "authenticated"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultFailed SetupAttemptPaymentMethodDetailsCardThreeDSecureResult = "failed"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultNotSupported SetupAttemptPaymentMethodDetailsCardThreeDSecureResult = "not_supported"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultProcessingError SetupAttemptPaymentMethodDetailsCardThreeDSecureResult = "processing_error"
)
// SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason represents dditional information about why 3D Secure succeeded or failed
type SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason string
// List of values that SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason can take.
const (
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReasonAbandoned SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason = "abandoned"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReasonBypassed SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason = "bypassed"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReasonCanceled SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason = "canceled"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReasonCardNotEnrolled SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason = "card_not_enrolled"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReasonNetworkNotSupported SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason = "network_not_supported"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReasonProtocolError SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason = "protocol_error"
SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReasonRejected SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason = "rejected"
)
// SetupAttemptPaymentMethodDetailsType is the type of the payment method associated with the setup attempt's payment method details.
type SetupAttemptPaymentMethodDetailsType string
// List of values that SetupAttemptPaymentMethodDetailsType can take.
const (
SetupAttemptPaymentMethodDetailsTypeCard SetupAttemptPaymentMethodDetailsType = "card"
)
// SetupAttemptUsage is the list of allowed values for usage.
type SetupAttemptUsage string
// List of values that SetupAttemptUsage can take.
const (
SetupAttemptUsageOffSession SetupAttemptUsage = "off_session"
SetupAttemptUsageOnSession SetupAttemptUsage = "on_session"
)
// SetupAttemptStatus is the list of allowed values for the setup attempt's status.
type SetupAttemptStatus string
// List of values that SetupAttemptStatus can take.
const (
SetupAttemptStatusAbandoned SetupAttemptStatus = "abandoned"
SetupAttemptStatusFailed SetupAttemptStatus = "failed"
SetupAttemptStatusProcessing SetupAttemptStatus = "processing"
SetupAttemptStatusRequiresAction SetupAttemptStatus = "requires_action"
SetupAttemptStatusRequiresConfirmation SetupAttemptStatus = "requires_confirmation"
SetupAttemptStatusSucceeded SetupAttemptStatus = "succeeded"
)
// SetupAttemptListParams is the set of parameters that can be used when listing setup attempts.
type SetupAttemptListParams struct {
ListParams `form:"*"`
Created *int64 `form:"created"`
CreatedRange *RangeQueryParams `form:"created"`
SetupIntent *string `form:"setup_intent"`
}
// SetupAttemptPaymentMethodDetailsCardThreeDSecure represents details about 3DS associated with the setup attempt's payment method.
type SetupAttemptPaymentMethodDetailsCardThreeDSecure struct {
AuthenticationFlow SetupAttemptPaymentMethodDetailsCardThreeDSecureAuthenticationFlow `json:"authentication_flow"`
Result SetupAttemptPaymentMethodDetailsCardThreeDSecureResult `json:"result"`
ResultReason SetupAttemptPaymentMethodDetailsCardThreeDSecureResultReason `json:"result_reason"`
Version string `json:"version"`
}
// SetupAttemptPaymentMethodDetailsBancontact represents details about the Bancontact PaymentMethod.
type SetupAttemptPaymentMethodDetailsBancontact struct {
BankCode string `json:"bank_code"`
BankName string `json:"bank_name"`
Bic string `json:"bic"`
GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"`
GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"`
IbanLast4 string `json:"iban_last4"`
PreferredLanguage string `json:"preferred_language"`
VerifiedName string `json:"verified_name"`
}
// SetupAttemptPaymentMethodDetailsCard represents details about the Card PaymentMethod.
type SetupAttemptPaymentMethodDetailsCard struct {
ThreeDSecure *SetupAttemptPaymentMethodDetailsCardThreeDSecure `json:"three_d_secure"`
}
// SetupAttemptPaymentMethodDetailsIdeal represents details about the Bancontact PaymentMethod.
type SetupAttemptPaymentMethodDetailsIdeal struct {
Bank string `json:"bank"`
Bic string `json:"bic"`
GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"`
GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"`
IbanLast4 string `json:"iban_last4"`
VerifiedName string `json:"verified_name"`
}
// SetupAttemptPaymentMethodDetailsSofort represents details about the Bancontact PaymentMethod.
type SetupAttemptPaymentMethodDetailsSofort struct {
BankCode string `json:"bank_code"`
BankName string `json:"bank_name"`
Bic string `json:"bic"`
GeneratedSepaDebit *PaymentMethod `json:"generated_sepa_debit"`
GeneratedSepaDebitMandate *Mandate `json:"generated_sepa_debit_mandate"`
IbanLast4 string `json:"iban_last4"`
PreferredLanguage string `json:"preferred_language"`
VerifiedName string `json:"verified_name"`
}
// SetupAttemptPaymentMethodDetails represents the details about the PaymentMethod associated with the setup attempt.
type SetupAttemptPaymentMethodDetails struct {
Bancontact *SetupAttemptPaymentMethodDetailsBancontact `json:"bancontact"`
Card *SetupAttemptPaymentMethodDetailsCard `json:"card"`
Ideal *SetupAttemptPaymentMethodDetailsIdeal `json:"ideal"`
Sofort *SetupAttemptPaymentMethodDetailsSofort `json:"sofort"`
Type SetupAttemptPaymentMethodDetailsType `json:"type"`
}
// SetupAttempt is the resource representing a Stripe setup attempt.
type SetupAttempt struct {
APIResource
Application *Application `json:"application"`
Created int64 `json:"created"`
Customer *Customer `json:"customer"`
ID string `json:"id"`
Livemode bool `json:"livemode"`
Object string `json:"object"`
OnBehalfOf *Account `json:"on_behalf_of"`
PaymentMethod *PaymentMethod `json:"payment_method"`
PaymentMethodDetails *SetupAttemptPaymentMethodDetails `json:"payment_method_details"`
SetupError *Error `json:"setup_error"`
Status SetupAttemptStatus `json:"status"`
Usage SetupAttemptUsage `json:"usage"`
}
// SetupAttemptList is a list of setup attempts as retrieved from a list endpoint.
type SetupAttemptList struct {
APIResource
ListMeta
Data []*SetupAttempt `json:"data"`
}
// UnmarshalJSON handles deserialization of a SetupAttempt.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (p *SetupAttempt) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type setupAttempt SetupAttempt
var v setupAttempt
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = SetupAttempt(v)
return nil
}