-
Notifications
You must be signed in to change notification settings - Fork 448
/
setupintent.go
302 lines (259 loc) · 14.9 KB
/
setupintent.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
package stripe
import (
"encoding/json"
)
// SetupIntentCancellationReason is the list of allowed values for the cancelation reason.
type SetupIntentCancellationReason string
// List of values that SetupIntentCancellationReason can take.
const (
SetupIntentCancellationReasonAbandoned SetupIntentCancellationReason = "abandoned"
SetupIntentCancellationReasonFailedInvoice SetupIntentCancellationReason = "failed_invoice"
SetupIntentCancellationReasonFraudulent SetupIntentCancellationReason = "fraudulent"
SetupIntentCancellationReasonRequestedByCustomer SetupIntentCancellationReason = "requested_by_customer"
)
// SetupIntentNextActionType is the list of allowed values for the next action's type.
type SetupIntentNextActionType string
// List of values that SetupIntentNextActionType can take.
const (
SetupIntentNextActionTypeRedirectToURL SetupIntentNextActionType = "redirect_to_url"
)
// SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule is the list of allowed values
// for payment_schedule on mandate_options.
type SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule string
// List of values that SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule can take.
const (
SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleCombined SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "combined"
SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleInterval SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "interval"
SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentScheduleSporadic SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule = "sporadic"
)
// SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsTransactionType is the list of allowed values for
// transaction_type on mandate_options.
type SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsTransactionType string
// List of values that SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsTransactionType can take.
const (
SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypeBusiness SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "business"
SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypePersonal SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "personal"
)
// SetupIntentPaymentMethodOptionsACSSDebitVerificationMethod is the list of allowed values for
// verification_method on acss_debit.
type SetupIntentPaymentMethodOptionsACSSDebitVerificationMethod string
// List of values that SetupIntentPaymentMethodOptionsACSSDebitVerificationMethod can take.
const (
SetupIntentPaymentMethodOptionsACSSDebitVerificationMethodAutomatic SetupIntentPaymentMethodOptionsACSSDebitVerificationMethod = "automatic"
SetupIntentPaymentMethodOptionsACSSDebitVerificationMethodInstant SetupIntentPaymentMethodOptionsACSSDebitVerificationMethod = "instant"
SetupIntentPaymentMethodOptionsACSSDebitVerificationMethodMicrodeposits SetupIntentPaymentMethodOptionsACSSDebitVerificationMethod = "microdeposits"
)
// SetupIntentPaymentMethodOptionsCardRequestThreeDSecure is the list of allowed values controlling
// when to request 3D Secure on a SetupIntent.
type SetupIntentPaymentMethodOptionsCardRequestThreeDSecure string
// List of values that SetupIntentNextActionType can take.
const (
SetupIntentPaymentMethodOptionsCardRequestThreeDSecureAny SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "any"
SetupIntentPaymentMethodOptionsCardRequestThreeDSecureAutomatic SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "automatic"
)
// SetupIntentStatus is the list of allowed values for the setup intent's status.
type SetupIntentStatus string
// List of values that SetupIntentStatus can take.
const (
SetupIntentStatusCanceled SetupIntentStatus = "canceled"
SetupIntentStatusProcessing SetupIntentStatus = "processing"
SetupIntentStatusRequiresAction SetupIntentStatus = "requires_action"
SetupIntentStatusRequiresConfirmation SetupIntentStatus = "requires_confirmation"
SetupIntentStatusRequiresPaymentMethod SetupIntentStatus = "requires_payment_method"
SetupIntentStatusSucceeded SetupIntentStatus = "succeeded"
)
// SetupIntentUsage is the list of allowed values for the setup intent's usage.
type SetupIntentUsage string
// List of values that SetupIntentUsage can take.
const (
SetupIntentUsageOffSession SetupIntentUsage = "off_session"
SetupIntentUsageOnSession SetupIntentUsage = "on_session"
)
// SetupIntentCancelParams is the set of parameters that can be used when canceling a setup intent.
type SetupIntentCancelParams struct {
Params `form:"*"`
CancellationReason *string `form:"cancellation_reason"`
}
// SetupIntentConfirmParams is the set of parameters that can be used when confirming a setup intent.
type SetupIntentConfirmParams struct {
Params `form:"*"`
MandateData *SetupIntentMandateDataParams `form:"mandate_data"`
PaymentMethod *string `form:"payment_method"`
PaymentMethodOptions *SetupIntentPaymentMethodOptionsParams `form:"payment_method_options"`
ReturnURL *string `form:"return_url"`
}
// SetupIntentMandateDataCustomerAcceptanceOfflineParams is the set of parameters for the customer
// acceptance of an offline mandate.
type SetupIntentMandateDataCustomerAcceptanceOfflineParams struct {
}
// SetupIntentMandateDataCustomerAcceptanceOnlineParams is the set of parameters for the customer
// acceptance of an online mandate.
type SetupIntentMandateDataCustomerAcceptanceOnlineParams struct {
IPAddress *string `form:"ip_address"`
UserAgent *string `form:"user_agent"`
}
// SetupIntentMandateDataCustomerAcceptanceParams is the set of parameters for the customer
// acceptance of a mandate.
type SetupIntentMandateDataCustomerAcceptanceParams struct {
AcceptedAt int64 `form:"accepted_at"`
Offline *SetupIntentMandateDataCustomerAcceptanceOfflineParams `form:"offline"`
Online *SetupIntentMandateDataCustomerAcceptanceOnlineParams `form:"online"`
Type MandateCustomerAcceptanceType `form:"type"`
}
// SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsParams is the set of parameters for
// mandate_options on acss_debit.
type SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsParams struct {
CustomMandateURL *string `form:"custom_mandate_url"`
IntervalDescription *string `form:"interval_description"`
PaymentSchedule *string `form:"payment_schedule"`
TransactionType *string `form:"transaction_type"`
}
// SetupIntentPaymentMethodOptionsACSSDebitParams is the set of parameters for acss debit on
// payment_method_options.
type SetupIntentPaymentMethodOptionsACSSDebitParams struct {
Currency *string `form:"currency"`
MandateOptions *SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsParams `form:"mandate_options"`
VerificationMethod *string `form:"verification_method"`
}
// SetupIntentMandateDataParams is the set of parameters controlling the creation of the mandate
// associated with this SetupIntent.
type SetupIntentMandateDataParams struct {
CustomerAcceptance *SetupIntentMandateDataCustomerAcceptanceParams `form:"customer_acceptance"`
}
// SetupIntentPaymentMethodOptionsCardParams represents the card-specific options applied to a
// SetupIntent.
type SetupIntentPaymentMethodOptionsCardParams struct {
MOTO *bool `form:"moto"`
RequestThreeDSecure *string `form:"request_three_d_secure"`
}
// SetupIntentPaymentMethodOptionsParams represents the type-specific payment method options
// applied to a SetupIntent.
type SetupIntentPaymentMethodOptionsParams struct {
ACSSDebit *SetupIntentPaymentMethodOptionsACSSDebitParams `form:"acss_debit"`
Card *SetupIntentPaymentMethodOptionsCardParams `form:"card"`
}
// SetupIntentSingleUseParams represents the single-use mandate-specific parameters.
type SetupIntentSingleUseParams struct {
Amount *int64 `form:"amount"`
Currency *string `form:"currency"`
}
// SetupIntentParams is the set of parameters that can be used when handling a setup intent.
type SetupIntentParams struct {
Params `form:"*"`
Confirm *bool `form:"confirm"`
Customer *string `form:"customer"`
Description *string `form:"description"`
MandateData *SetupIntentMandateDataParams `form:"mandate_data"`
OnBehalfOf *string `form:"on_behalf_of"`
PaymentMethod *string `form:"payment_method"`
PaymentMethodOptions *SetupIntentPaymentMethodOptionsParams `form:"payment_method_options"`
PaymentMethodTypes []*string `form:"payment_method_types"`
ReturnURL *string `form:"return_url"`
SingleUse *SetupIntentSingleUseParams `form:"single_use"`
Usage *string `form:"usage"`
}
// SetupIntentListParams is the set of parameters that can be used when listing setup intents.
// For more details see https://stripe.com/docs/api#list_payouts.
type SetupIntentListParams struct {
ListParams `form:"*"`
Created *int64 `form:"created"`
CreatedRange *RangeQueryParams `form:"created"`
Customer *string `form:"customer"`
PaymentMethod *string `form:"payment_method"`
}
// SetupIntentNextActionRedirectToURL represents the resource for the next action of type
// "redirect_to_url".
type SetupIntentNextActionRedirectToURL struct {
ReturnURL string `json:"return_url"`
URL string `json:"url"`
}
// SetupIntentNextActionUseStripeSDK represents the resource for the next action of type
// "use_stripe_sdk".
type SetupIntentNextActionUseStripeSDK struct{}
// SetupIntentNextActionVerifyWithMicrodeposits represents the resource for the next action
// of type "verify_with_microdeposits".
type SetupIntentNextActionVerifyWithMicrodeposits struct {
ArrivalDate int64 `json:"arrival_date"`
HostedVerificationURL string `json:"hosted_verification_url"`
}
// SetupIntentNextAction represents the type of action to take on a setup intent.
type SetupIntentNextAction struct {
RedirectToURL *SetupIntentNextActionRedirectToURL `json:"redirect_to_url"`
Type SetupIntentNextActionType `json:"type"`
UseStripeSDK *SetupIntentNextActionUseStripeSDK `json:"use_stripe_sdk"`
VerifyWithMicrodeposits *SetupIntentNextActionVerifyWithMicrodeposits `json:"verify_with_microdeposits"`
}
// SetupIntentPaymentMethodOptionsACSSDebitMandateOptions describe the mandate options for
// acss debit associated with a setup intent.
type SetupIntentPaymentMethodOptionsACSSDebitMandateOptions struct {
CustomMandateURL string `json:"custom_mandate_url"`
IntervalDescription string `json:"interval_description"`
PaymentSchedule SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsPaymentSchedule `json:"payment_schedule"`
TransactionType SetupIntentPaymentMethodOptionsACSSDebitMandateOptionsTransactionType `json:"transaction_type"`
}
// SetupIntentPaymentMethodOptionsACSSDebit represents the ACSS debit-specific options applied
// to a SetupIntent.
type SetupIntentPaymentMethodOptionsACSSDebit struct {
Currency string `json:"currency"`
MandateOptions *SetupIntentPaymentMethodOptionsACSSDebitMandateOptions `json:"mandate_options"`
VerificationMethod SetupIntentPaymentMethodOptionsACSSDebitVerificationMethod `json:"verification_method"`
}
// SetupIntentPaymentMethodOptionsCard represents the card-specific options applied to a
// SetupIntent.
type SetupIntentPaymentMethodOptionsCard struct {
RequestThreeDSecure SetupIntentPaymentMethodOptionsCardRequestThreeDSecure `json:"request_three_d_secure"`
}
// SetupIntentPaymentMethodOptions represents the type-specific payment method options applied to a
// SetupIntent.
type SetupIntentPaymentMethodOptions struct {
ACSSDebit *SetupIntentPaymentMethodOptionsACSSDebit `json:"acss_debit"`
Card *SetupIntentPaymentMethodOptionsCard `json:"card"`
}
// SetupIntent is the resource representing a Stripe payout.
// For more details see https://stripe.com/docs/api#payment_intents.
type SetupIntent struct {
APIResource
Application *Application `json:"application"`
CancellationReason SetupIntentCancellationReason `json:"cancellation_reason"`
ClientSecret string `json:"client_secret"`
Created int64 `json:"created"`
Customer *Customer `json:"customer"`
Description string `json:"description"`
ID string `json:"id"`
LastSetupError *Error `json:"last_setup_error"`
LatestAttempt *SetupAttempt `json:"latest_attempt"`
Livemode bool `json:"livemode"`
Mandate *Mandate `json:"mandate"`
Metadata map[string]string `json:"metadata"`
NextAction *SetupIntentNextAction `json:"next_action"`
Object string `json:"object"`
OnBehalfOf *Account `json:"on_behalf_of"`
PaymentMethod *PaymentMethod `json:"payment_method"`
PaymentMethodOptions *SetupIntentPaymentMethodOptions `json:"payment_method_options"`
PaymentMethodTypes []string `json:"payment_method_types"`
SingleUseMandate *Mandate `json:"single_use_mandate"`
Status SetupIntentStatus `json:"status"`
Usage SetupIntentUsage `json:"usage"`
}
// SetupIntentList is a list of setup intents as retrieved from a list endpoint.
type SetupIntentList struct {
APIResource
ListMeta
Data []*SetupIntent `json:"data"`
}
// UnmarshalJSON handles deserialization of a SetupIntent.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (p *SetupIntent) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type setupIntent SetupIntent
var v setupIntent
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = SetupIntent(v)
return nil
}