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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
use serde::{Deserialize, Serialize};
use crate::client::{Client, Response};
use crate::ids::{SetupAttemptId, SetupIntentId};
use crate::params::{Expand, Expandable, List, Object, Paginable, RangeQuery, Timestamp};
use crate::resources::{
Account, ApiErrors, Application, Customer, Mandate, PaymentMethod, SetupIntent,
ThreeDSecureDetails,
};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttempt {
pub id: SetupAttemptId,
pub application: Option<Expandable<Application>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attach_to_self: Option<bool>,
pub created: Timestamp,
pub customer: Option<Expandable<Customer>>,
pub flow_directions: Option<Vec<SetupAttemptFlowDirections>>,
pub livemode: bool,
pub on_behalf_of: Option<Expandable<Account>>,
pub payment_method: Expandable<PaymentMethod>,
pub payment_method_details: SetupAttemptPaymentMethodDetails,
pub setup_error: Option<Box<ApiErrors>>,
pub setup_intent: Expandable<SetupIntent>,
pub status: String,
pub usage: String,
}
impl SetupAttempt {
pub fn list(client: &Client, params: &ListSetupAttempts<'_>) -> Response<List<SetupAttempt>> {
client.get_query("/setup_attempts", ¶ms)
}
}
impl Object for SetupAttempt {
type Id = SetupAttemptId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"setup_attempt"
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetails {
#[serde(skip_serializing_if = "Option::is_none")]
pub acss_debit: Option<SetupAttemptPaymentMethodDetailsAcssDebit>,
#[serde(skip_serializing_if = "Option::is_none")]
pub au_becs_debit: Option<SetupAttemptPaymentMethodDetailsAuBecsDebit>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bacs_debit: Option<SetupAttemptPaymentMethodDetailsBacsDebit>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bancontact: Option<SetupAttemptPaymentMethodDetailsBancontact>,
#[serde(skip_serializing_if = "Option::is_none")]
pub blik: Option<SetupAttemptPaymentMethodDetailsBlik>,
#[serde(skip_serializing_if = "Option::is_none")]
pub boleto: Option<SetupAttemptPaymentMethodDetailsBoleto>,
#[serde(skip_serializing_if = "Option::is_none")]
pub card: Option<SetupAttemptPaymentMethodDetailsCard>,
#[serde(skip_serializing_if = "Option::is_none")]
pub card_present: Option<SetupAttemptPaymentMethodDetailsCardPresent>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ideal: Option<SetupAttemptPaymentMethodDetailsIdeal>,
#[serde(skip_serializing_if = "Option::is_none")]
pub klarna: Option<SetupAttemptPaymentMethodDetailsKlarna>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link: Option<SetupAttemptPaymentMethodDetailsLink>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sepa_debit: Option<SetupAttemptPaymentMethodDetailsSepaDebit>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sofort: Option<SetupAttemptPaymentMethodDetailsSofort>,
#[serde(rename = "type")]
pub type_: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub us_bank_account: Option<SetupAttemptPaymentMethodDetailsUsBankAccount>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsAcssDebit {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsAuBecsDebit {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsBacsDebit {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsBancontact {
pub bank_code: Option<String>,
pub bank_name: Option<String>,
pub bic: Option<String>,
pub generated_sepa_debit: Option<Expandable<PaymentMethod>>,
pub generated_sepa_debit_mandate: Option<Expandable<Mandate>>,
pub iban_last4: Option<String>,
pub preferred_language: Option<SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage>,
pub verified_name: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsBlik {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsBoleto {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsCard {
pub three_d_secure: Option<ThreeDSecureDetails>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsCardPresent {
pub generated_card: Option<Expandable<PaymentMethod>>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsIdeal {
pub bank: Option<SetupAttemptPaymentMethodDetailsIdealBank>,
pub bic: Option<SetupAttemptPaymentMethodDetailsIdealBic>,
pub generated_sepa_debit: Option<Expandable<PaymentMethod>>,
pub generated_sepa_debit_mandate: Option<Expandable<Mandate>>,
pub iban_last4: Option<String>,
pub verified_name: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsKlarna {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsLink {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsSepaDebit {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsSofort {
pub bank_code: Option<String>,
pub bank_name: Option<String>,
pub bic: Option<String>,
pub generated_sepa_debit: Option<Expandable<PaymentMethod>>,
pub generated_sepa_debit_mandate: Option<Expandable<Mandate>>,
pub iban_last4: Option<String>,
pub preferred_language: Option<SetupAttemptPaymentMethodDetailsSofortPreferredLanguage>,
pub verified_name: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsUsBankAccount {}
#[derive(Clone, Debug, Serialize)]
pub struct ListSetupAttempts<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created: Option<RangeQuery<Timestamp>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ending_before: Option<SetupAttemptId>,
#[serde(skip_serializing_if = "Expand::is_empty")]
pub expand: &'a [&'a str],
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u64>,
pub setup_intent: SetupIntentId,
#[serde(skip_serializing_if = "Option::is_none")]
pub starting_after: Option<SetupAttemptId>,
}
impl<'a> ListSetupAttempts<'a> {
pub fn new(setup_intent: SetupIntentId) -> Self {
ListSetupAttempts {
created: Default::default(),
ending_before: Default::default(),
expand: Default::default(),
limit: Default::default(),
setup_intent,
starting_after: Default::default(),
}
}
}
impl Paginable for ListSetupAttempts<'_> {
type O = SetupAttempt;
fn set_last(&mut self, item: Self::O) {
self.starting_after = Some(item.id());
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptFlowDirections {
Inbound,
Outbound,
}
impl SetupAttemptFlowDirections {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptFlowDirections::Inbound => "inbound",
SetupAttemptFlowDirections::Outbound => "outbound",
}
}
}
impl AsRef<str> for SetupAttemptFlowDirections {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptFlowDirections {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for SetupAttemptFlowDirections {
fn default() -> Self {
Self::Inbound
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
De,
En,
Fr,
Nl,
}
impl SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::De => "de",
SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::En => "en",
SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::Fr => "fr",
SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::Nl => "nl",
}
}
}
impl AsRef<str> for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
fn default() -> Self {
Self::De
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptPaymentMethodDetailsIdealBank {
AbnAmro,
AsnBank,
Bunq,
Handelsbanken,
Ing,
Knab,
Moneyou,
Rabobank,
Regiobank,
Revolut,
SnsBank,
TriodosBank,
VanLanschot,
}
impl SetupAttemptPaymentMethodDetailsIdealBank {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptPaymentMethodDetailsIdealBank::AbnAmro => "abn_amro",
SetupAttemptPaymentMethodDetailsIdealBank::AsnBank => "asn_bank",
SetupAttemptPaymentMethodDetailsIdealBank::Bunq => "bunq",
SetupAttemptPaymentMethodDetailsIdealBank::Handelsbanken => "handelsbanken",
SetupAttemptPaymentMethodDetailsIdealBank::Ing => "ing",
SetupAttemptPaymentMethodDetailsIdealBank::Knab => "knab",
SetupAttemptPaymentMethodDetailsIdealBank::Moneyou => "moneyou",
SetupAttemptPaymentMethodDetailsIdealBank::Rabobank => "rabobank",
SetupAttemptPaymentMethodDetailsIdealBank::Regiobank => "regiobank",
SetupAttemptPaymentMethodDetailsIdealBank::Revolut => "revolut",
SetupAttemptPaymentMethodDetailsIdealBank::SnsBank => "sns_bank",
SetupAttemptPaymentMethodDetailsIdealBank::TriodosBank => "triodos_bank",
SetupAttemptPaymentMethodDetailsIdealBank::VanLanschot => "van_lanschot",
}
}
}
impl AsRef<str> for SetupAttemptPaymentMethodDetailsIdealBank {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptPaymentMethodDetailsIdealBank {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for SetupAttemptPaymentMethodDetailsIdealBank {
fn default() -> Self {
Self::AbnAmro
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptPaymentMethodDetailsIdealBic {
#[serde(rename = "ABNANL2A")]
Abnanl2a,
#[serde(rename = "ASNBNL21")]
Asnbnl21,
#[serde(rename = "BUNQNL2A")]
Bunqnl2a,
#[serde(rename = "FVLBNL22")]
Fvlbnl22,
#[serde(rename = "HANDNL2A")]
Handnl2a,
#[serde(rename = "INGBNL2A")]
Ingbnl2a,
#[serde(rename = "KNABNL2H")]
Knabnl2h,
#[serde(rename = "MOYONL21")]
Moyonl21,
#[serde(rename = "RABONL2U")]
Rabonl2u,
#[serde(rename = "RBRBNL21")]
Rbrbnl21,
#[serde(rename = "REVOLT21")]
Revolt21,
#[serde(rename = "SNSBNL2A")]
Snsbnl2a,
#[serde(rename = "TRIONL2U")]
Trionl2u,
}
impl SetupAttemptPaymentMethodDetailsIdealBic {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptPaymentMethodDetailsIdealBic::Abnanl2a => "ABNANL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Asnbnl21 => "ASNBNL21",
SetupAttemptPaymentMethodDetailsIdealBic::Bunqnl2a => "BUNQNL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Fvlbnl22 => "FVLBNL22",
SetupAttemptPaymentMethodDetailsIdealBic::Handnl2a => "HANDNL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Ingbnl2a => "INGBNL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Knabnl2h => "KNABNL2H",
SetupAttemptPaymentMethodDetailsIdealBic::Moyonl21 => "MOYONL21",
SetupAttemptPaymentMethodDetailsIdealBic::Rabonl2u => "RABONL2U",
SetupAttemptPaymentMethodDetailsIdealBic::Rbrbnl21 => "RBRBNL21",
SetupAttemptPaymentMethodDetailsIdealBic::Revolt21 => "REVOLT21",
SetupAttemptPaymentMethodDetailsIdealBic::Snsbnl2a => "SNSBNL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Trionl2u => "TRIONL2U",
}
}
}
impl AsRef<str> for SetupAttemptPaymentMethodDetailsIdealBic {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptPaymentMethodDetailsIdealBic {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for SetupAttemptPaymentMethodDetailsIdealBic {
fn default() -> Self {
Self::Abnanl2a
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
De,
En,
Fr,
Nl,
}
impl SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::De => "de",
SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::En => "en",
SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::Fr => "fr",
SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::Nl => "nl",
}
}
}
impl AsRef<str> for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
fn default() -> Self {
Self::De
}
}