async-stripe-shared 1.0.0-rc.6

API bindings for the Stripe HTTP API
Documentation
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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
/// You can store multiple cards on a customer in order to charge the customer
/// later. You can also store multiple debit cards on a recipient in order to
/// transfer to those cards later.
///
/// Related guide: [Card payments with Sources](https://docs.stripe.com/sources/cards)
///
/// For more details see <<https://stripe.com/docs/api/cards/object>>.
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct Card {
    pub account: Option<stripe_types::Expandable<stripe_shared::Account>>,
    /// City/District/Suburb/Town/Village.
    pub address_city: Option<String>,
    /// Billing address country, if provided when creating card.
    pub address_country: Option<String>,
    /// Address line 1 (Street address/PO Box/Company name).
    pub address_line1: Option<String>,
    /// If `address_line1` was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.
    pub address_line1_check: Option<String>,
    /// Address line 2 (Apartment/Suite/Unit/Building).
    pub address_line2: Option<String>,
    /// State/County/Province/Region.
    pub address_state: Option<String>,
    /// ZIP or postal code.
    pub address_zip: Option<String>,
    /// If `address_zip` was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.
    pub address_zip_check: Option<String>,
    /// This field indicates whether this payment method can be shown again to its customer in a checkout flow.
    /// Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow.
    /// The field defaults to “unspecified”.
    pub allow_redisplay: Option<CardAllowRedisplay>,
    /// A set of available payout methods for this card.
    /// Only values from this set should be passed as the `method` when creating a payout.
    pub available_payout_methods: Option<Vec<CardAvailablePayoutMethods>>,
    /// Card brand.
    /// Can be `American Express`, `Cartes Bancaires`, `Diners Club`, `Discover`, `Eftpos Australia`, `Girocard`, `JCB`, `MasterCard`, `UnionPay`, `Visa`, or `Unknown`.
    pub brand: String,
    /// Two-letter ISO code representing the country of the card.
    /// You could use this attribute to get a sense of the international breakdown of cards you've collected.
    pub country: Option<String>,
    /// Three-letter [ISO code for currency](https://www.iso.org/iso-4217-currency-codes.html) in lowercase.
    /// Must be a [supported currency](https://docs.stripe.com/currencies).
    /// Only applicable on accounts (not customers or recipients).
    /// The card can be used as a transfer destination for funds in this currency.
    /// This property is only available when returned as an [External Account](/api/external_account_cards/object) where [controller.is_controller](/api/accounts/object#account_object-controller-is_controller) is `true`.
    pub currency: Option<stripe_types::Currency>,
    /// The customer that this card belongs to.
    /// This attribute will not be in the card object if the card belongs to an account or recipient instead.
    pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>,
    /// If a CVC was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.
    /// A result of unchecked indicates that CVC was provided but hasn't been checked yet.
    /// Checks are typically performed when attaching a card to a Customer object, or when creating a charge.
    /// For more details, see [Check if a card is valid without a charge](https://support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge).
    pub cvc_check: Option<String>,
    /// Whether this card is the default external account for its currency.
    /// This property is only available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `application`, which includes Custom accounts.
    pub default_for_currency: Option<bool>,
    /// A high-level description of the type of cards issued in this range.
    /// (For internal use only and not typically available in standard API requests.).
    pub description: Option<String>,
    /// (For tokenized numbers only.) The last four digits of the device account number.
    pub dynamic_last4: Option<String>,
    /// Two-digit number representing the card's expiration month.
    pub exp_month: i64,
    /// Four-digit number representing the card's expiration year.
    pub exp_year: i64,
    /// Uniquely identifies this particular card number.
    /// You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example.
    /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number.
    ///
    /// *As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.*.
    pub fingerprint: Option<String>,
    /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`.
    pub funding: String,
    /// Unique identifier for the object.
    pub id: stripe_shared::CardId,
    /// Issuer identification number of the card.
    /// (For internal use only and not typically available in standard API requests.).
    pub iin: Option<String>,
    /// The name of the card's issuing bank.
    /// (For internal use only and not typically available in standard API requests.).
    pub issuer: Option<String>,
    /// The last four digits of the card.
    pub last4: String,
    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
    /// This can be useful for storing additional information about the object in a structured format.
    pub metadata: Option<std::collections::HashMap<String, String>>,
    /// Cardholder name.
    pub name: Option<String>,
    pub networks: Option<stripe_shared::TokenCardNetworks>,
    /// Status of a card based on the card issuer.
    pub regulated_status: Option<CardRegulatedStatus>,
    /// For external accounts that are cards, possible values are `new` and `errored`.
    /// If a payout fails, the status is set to `errored` and [scheduled payouts](https://stripe.com/docs/payouts#payout-schedule) are stopped until account details are updated.
    pub status: Option<String>,
    /// If the card number is tokenized, this is the method that was used.
    /// Can be `android_pay` (includes Google Pay), `apple_pay`, `masterpass`, `visa_checkout`, or null.
    pub tokenization_method: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for Card {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("Card").finish_non_exhaustive()
    }
}
#[doc(hidden)]
pub struct CardBuilder {
    account: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
    address_city: Option<Option<String>>,
    address_country: Option<Option<String>>,
    address_line1: Option<Option<String>>,
    address_line1_check: Option<Option<String>>,
    address_line2: Option<Option<String>>,
    address_state: Option<Option<String>>,
    address_zip: Option<Option<String>>,
    address_zip_check: Option<Option<String>>,
    allow_redisplay: Option<Option<CardAllowRedisplay>>,
    available_payout_methods: Option<Option<Vec<CardAvailablePayoutMethods>>>,
    brand: Option<String>,
    country: Option<Option<String>>,
    currency: Option<Option<stripe_types::Currency>>,
    customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>,
    cvc_check: Option<Option<String>>,
    default_for_currency: Option<Option<bool>>,
    description: Option<Option<String>>,
    dynamic_last4: Option<Option<String>>,
    exp_month: Option<i64>,
    exp_year: Option<i64>,
    fingerprint: Option<Option<String>>,
    funding: Option<String>,
    id: Option<stripe_shared::CardId>,
    iin: Option<Option<String>>,
    issuer: Option<Option<String>>,
    last4: Option<String>,
    metadata: Option<Option<std::collections::HashMap<String, String>>>,
    name: Option<Option<String>>,
    networks: Option<Option<stripe_shared::TokenCardNetworks>>,
    regulated_status: Option<Option<CardRegulatedStatus>>,
    status: Option<Option<String>>,
    tokenization_method: Option<Option<String>>,
}

#[allow(
    unused_variables,
    irrefutable_let_patterns,
    clippy::let_unit_value,
    clippy::match_single_binding,
    clippy::single_match
)]
const _: () = {
    use miniserde::de::{Map, Visitor};
    use miniserde::json::Value;
    use miniserde::{Deserialize, Result, make_place};
    use stripe_types::miniserde_helpers::FromValueOpt;
    use stripe_types::{MapBuilder, ObjectDeser};

    make_place!(Place);

    impl Deserialize for Card {
        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
            Place::new(out)
        }
    }

    struct Builder<'a> {
        out: &'a mut Option<Card>,
        builder: CardBuilder,
    }

    impl Visitor for Place<Card> {
        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
            Ok(Box::new(Builder { out: &mut self.out, builder: CardBuilder::deser_default() }))
        }
    }

    impl MapBuilder for CardBuilder {
        type Out = Card;
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            Ok(match k {
                "account" => Deserialize::begin(&mut self.account),
                "address_city" => Deserialize::begin(&mut self.address_city),
                "address_country" => Deserialize::begin(&mut self.address_country),
                "address_line1" => Deserialize::begin(&mut self.address_line1),
                "address_line1_check" => Deserialize::begin(&mut self.address_line1_check),
                "address_line2" => Deserialize::begin(&mut self.address_line2),
                "address_state" => Deserialize::begin(&mut self.address_state),
                "address_zip" => Deserialize::begin(&mut self.address_zip),
                "address_zip_check" => Deserialize::begin(&mut self.address_zip_check),
                "allow_redisplay" => Deserialize::begin(&mut self.allow_redisplay),
                "available_payout_methods" => {
                    Deserialize::begin(&mut self.available_payout_methods)
                }
                "brand" => Deserialize::begin(&mut self.brand),
                "country" => Deserialize::begin(&mut self.country),
                "currency" => Deserialize::begin(&mut self.currency),
                "customer" => Deserialize::begin(&mut self.customer),
                "cvc_check" => Deserialize::begin(&mut self.cvc_check),
                "default_for_currency" => Deserialize::begin(&mut self.default_for_currency),
                "description" => Deserialize::begin(&mut self.description),
                "dynamic_last4" => Deserialize::begin(&mut self.dynamic_last4),
                "exp_month" => Deserialize::begin(&mut self.exp_month),
                "exp_year" => Deserialize::begin(&mut self.exp_year),
                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
                "funding" => Deserialize::begin(&mut self.funding),
                "id" => Deserialize::begin(&mut self.id),
                "iin" => Deserialize::begin(&mut self.iin),
                "issuer" => Deserialize::begin(&mut self.issuer),
                "last4" => Deserialize::begin(&mut self.last4),
                "metadata" => Deserialize::begin(&mut self.metadata),
                "name" => Deserialize::begin(&mut self.name),
                "networks" => Deserialize::begin(&mut self.networks),
                "regulated_status" => Deserialize::begin(&mut self.regulated_status),
                "status" => Deserialize::begin(&mut self.status),
                "tokenization_method" => Deserialize::begin(&mut self.tokenization_method),
                _ => <dyn Visitor>::ignore(),
            })
        }

        fn deser_default() -> Self {
            Self {
                account: Some(None),
                address_city: Some(None),
                address_country: Some(None),
                address_line1: Some(None),
                address_line1_check: Some(None),
                address_line2: Some(None),
                address_state: Some(None),
                address_zip: Some(None),
                address_zip_check: Some(None),
                allow_redisplay: Some(None),
                available_payout_methods: Some(None),
                brand: None,
                country: Some(None),
                currency: Some(None),
                customer: Some(None),
                cvc_check: Some(None),
                default_for_currency: Some(None),
                description: Some(None),
                dynamic_last4: Some(None),
                exp_month: None,
                exp_year: None,
                fingerprint: Some(None),
                funding: None,
                id: None,
                iin: Some(None),
                issuer: Some(None),
                last4: None,
                metadata: Some(None),
                name: Some(None),
                networks: Some(None),
                regulated_status: Some(None),
                status: Some(None),
                tokenization_method: Some(None),
            }
        }

        fn take_out(&mut self) -> Option<Self::Out> {
            let (
                Some(account),
                Some(address_city),
                Some(address_country),
                Some(address_line1),
                Some(address_line1_check),
                Some(address_line2),
                Some(address_state),
                Some(address_zip),
                Some(address_zip_check),
                Some(allow_redisplay),
                Some(available_payout_methods),
                Some(brand),
                Some(country),
                Some(currency),
                Some(customer),
                Some(cvc_check),
                Some(default_for_currency),
                Some(description),
                Some(dynamic_last4),
                Some(exp_month),
                Some(exp_year),
                Some(fingerprint),
                Some(funding),
                Some(id),
                Some(iin),
                Some(issuer),
                Some(last4),
                Some(metadata),
                Some(name),
                Some(networks),
                Some(regulated_status),
                Some(status),
                Some(tokenization_method),
            ) = (
                self.account.take(),
                self.address_city.take(),
                self.address_country.take(),
                self.address_line1.take(),
                self.address_line1_check.take(),
                self.address_line2.take(),
                self.address_state.take(),
                self.address_zip.take(),
                self.address_zip_check.take(),
                self.allow_redisplay.take(),
                self.available_payout_methods.take(),
                self.brand.take(),
                self.country.take(),
                self.currency.take(),
                self.customer.take(),
                self.cvc_check.take(),
                self.default_for_currency,
                self.description.take(),
                self.dynamic_last4.take(),
                self.exp_month,
                self.exp_year,
                self.fingerprint.take(),
                self.funding.take(),
                self.id.take(),
                self.iin.take(),
                self.issuer.take(),
                self.last4.take(),
                self.metadata.take(),
                self.name.take(),
                self.networks.take(),
                self.regulated_status.take(),
                self.status.take(),
                self.tokenization_method.take(),
            )
            else {
                return None;
            };
            Some(Self::Out {
                account,
                address_city,
                address_country,
                address_line1,
                address_line1_check,
                address_line2,
                address_state,
                address_zip,
                address_zip_check,
                allow_redisplay,
                available_payout_methods,
                brand,
                country,
                currency,
                customer,
                cvc_check,
                default_for_currency,
                description,
                dynamic_last4,
                exp_month,
                exp_year,
                fingerprint,
                funding,
                id,
                iin,
                issuer,
                last4,
                metadata,
                name,
                networks,
                regulated_status,
                status,
                tokenization_method,
            })
        }
    }

    impl Map for Builder<'_> {
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            self.builder.key(k)
        }

        fn finish(&mut self) -> Result<()> {
            *self.out = self.builder.take_out();
            Ok(())
        }
    }

    impl ObjectDeser for Card {
        type Builder = CardBuilder;
    }

    impl FromValueOpt for Card {
        fn from_value(v: Value) -> Option<Self> {
            let Value::Object(obj) = v else {
                return None;
            };
            let mut b = CardBuilder::deser_default();
            for (k, v) in obj {
                match k.as_str() {
                    "account" => b.account = FromValueOpt::from_value(v),
                    "address_city" => b.address_city = FromValueOpt::from_value(v),
                    "address_country" => b.address_country = FromValueOpt::from_value(v),
                    "address_line1" => b.address_line1 = FromValueOpt::from_value(v),
                    "address_line1_check" => b.address_line1_check = FromValueOpt::from_value(v),
                    "address_line2" => b.address_line2 = FromValueOpt::from_value(v),
                    "address_state" => b.address_state = FromValueOpt::from_value(v),
                    "address_zip" => b.address_zip = FromValueOpt::from_value(v),
                    "address_zip_check" => b.address_zip_check = FromValueOpt::from_value(v),
                    "allow_redisplay" => b.allow_redisplay = FromValueOpt::from_value(v),
                    "available_payout_methods" => {
                        b.available_payout_methods = FromValueOpt::from_value(v)
                    }
                    "brand" => b.brand = FromValueOpt::from_value(v),
                    "country" => b.country = FromValueOpt::from_value(v),
                    "currency" => b.currency = FromValueOpt::from_value(v),
                    "customer" => b.customer = FromValueOpt::from_value(v),
                    "cvc_check" => b.cvc_check = FromValueOpt::from_value(v),
                    "default_for_currency" => b.default_for_currency = FromValueOpt::from_value(v),
                    "description" => b.description = FromValueOpt::from_value(v),
                    "dynamic_last4" => b.dynamic_last4 = FromValueOpt::from_value(v),
                    "exp_month" => b.exp_month = FromValueOpt::from_value(v),
                    "exp_year" => b.exp_year = FromValueOpt::from_value(v),
                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
                    "funding" => b.funding = FromValueOpt::from_value(v),
                    "id" => b.id = FromValueOpt::from_value(v),
                    "iin" => b.iin = FromValueOpt::from_value(v),
                    "issuer" => b.issuer = FromValueOpt::from_value(v),
                    "last4" => b.last4 = FromValueOpt::from_value(v),
                    "metadata" => b.metadata = FromValueOpt::from_value(v),
                    "name" => b.name = FromValueOpt::from_value(v),
                    "networks" => b.networks = FromValueOpt::from_value(v),
                    "regulated_status" => b.regulated_status = FromValueOpt::from_value(v),
                    "status" => b.status = FromValueOpt::from_value(v),
                    "tokenization_method" => b.tokenization_method = FromValueOpt::from_value(v),
                    _ => {}
                }
            }
            b.take_out()
        }
    }
};
#[cfg(feature = "serialize")]
impl serde::Serialize for Card {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        use serde::ser::SerializeStruct;
        let mut s = s.serialize_struct("Card", 34)?;
        s.serialize_field("account", &self.account)?;
        s.serialize_field("address_city", &self.address_city)?;
        s.serialize_field("address_country", &self.address_country)?;
        s.serialize_field("address_line1", &self.address_line1)?;
        s.serialize_field("address_line1_check", &self.address_line1_check)?;
        s.serialize_field("address_line2", &self.address_line2)?;
        s.serialize_field("address_state", &self.address_state)?;
        s.serialize_field("address_zip", &self.address_zip)?;
        s.serialize_field("address_zip_check", &self.address_zip_check)?;
        s.serialize_field("allow_redisplay", &self.allow_redisplay)?;
        s.serialize_field("available_payout_methods", &self.available_payout_methods)?;
        s.serialize_field("brand", &self.brand)?;
        s.serialize_field("country", &self.country)?;
        s.serialize_field("currency", &self.currency)?;
        s.serialize_field("customer", &self.customer)?;
        s.serialize_field("cvc_check", &self.cvc_check)?;
        s.serialize_field("default_for_currency", &self.default_for_currency)?;
        s.serialize_field("description", &self.description)?;
        s.serialize_field("dynamic_last4", &self.dynamic_last4)?;
        s.serialize_field("exp_month", &self.exp_month)?;
        s.serialize_field("exp_year", &self.exp_year)?;
        s.serialize_field("fingerprint", &self.fingerprint)?;
        s.serialize_field("funding", &self.funding)?;
        s.serialize_field("id", &self.id)?;
        s.serialize_field("iin", &self.iin)?;
        s.serialize_field("issuer", &self.issuer)?;
        s.serialize_field("last4", &self.last4)?;
        s.serialize_field("metadata", &self.metadata)?;
        s.serialize_field("name", &self.name)?;
        s.serialize_field("networks", &self.networks)?;
        s.serialize_field("regulated_status", &self.regulated_status)?;
        s.serialize_field("status", &self.status)?;
        s.serialize_field("tokenization_method", &self.tokenization_method)?;

        s.serialize_field("object", "card")?;
        s.end()
    }
}
/// This field indicates whether this payment method can be shown again to its customer in a checkout flow.
/// Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow.
/// The field defaults to “unspecified”.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum CardAllowRedisplay {
    Always,
    Limited,
    Unspecified,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl CardAllowRedisplay {
    pub fn as_str(&self) -> &str {
        use CardAllowRedisplay::*;
        match self {
            Always => "always",
            Limited => "limited",
            Unspecified => "unspecified",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for CardAllowRedisplay {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use CardAllowRedisplay::*;
        match s {
            "always" => Ok(Always),
            "limited" => Ok(Limited),
            "unspecified" => Ok(Unspecified),
            v => {
                tracing::warn!("Unknown value '{}' for enum '{}'", v, "CardAllowRedisplay");
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for CardAllowRedisplay {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for CardAllowRedisplay {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CardAllowRedisplay {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(CardAllowRedisplay)).finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for CardAllowRedisplay {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl miniserde::Deserialize for CardAllowRedisplay {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

impl miniserde::de::Visitor for crate::Place<CardAllowRedisplay> {
    fn string(&mut self, s: &str) -> miniserde::Result<()> {
        use std::str::FromStr;
        self.out = Some(CardAllowRedisplay::from_str(s).expect("infallible"));
        Ok(())
    }
}

stripe_types::impl_from_val_with_from_str!(CardAllowRedisplay);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for CardAllowRedisplay {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}
/// A set of available payout methods for this card.
/// Only values from this set should be passed as the `method` when creating a payout.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum CardAvailablePayoutMethods {
    Instant,
    Standard,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl CardAvailablePayoutMethods {
    pub fn as_str(&self) -> &str {
        use CardAvailablePayoutMethods::*;
        match self {
            Instant => "instant",
            Standard => "standard",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for CardAvailablePayoutMethods {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use CardAvailablePayoutMethods::*;
        match s {
            "instant" => Ok(Instant),
            "standard" => Ok(Standard),
            v => {
                tracing::warn!("Unknown value '{}' for enum '{}'", v, "CardAvailablePayoutMethods");
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for CardAvailablePayoutMethods {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for CardAvailablePayoutMethods {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CardAvailablePayoutMethods {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(CardAvailablePayoutMethods)).finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for CardAvailablePayoutMethods {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl miniserde::Deserialize for CardAvailablePayoutMethods {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

impl miniserde::de::Visitor for crate::Place<CardAvailablePayoutMethods> {
    fn string(&mut self, s: &str) -> miniserde::Result<()> {
        use std::str::FromStr;
        self.out = Some(CardAvailablePayoutMethods::from_str(s).expect("infallible"));
        Ok(())
    }
}

stripe_types::impl_from_val_with_from_str!(CardAvailablePayoutMethods);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for CardAvailablePayoutMethods {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}
/// Status of a card based on the card issuer.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum CardRegulatedStatus {
    Regulated,
    Unregulated,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl CardRegulatedStatus {
    pub fn as_str(&self) -> &str {
        use CardRegulatedStatus::*;
        match self {
            Regulated => "regulated",
            Unregulated => "unregulated",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for CardRegulatedStatus {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use CardRegulatedStatus::*;
        match s {
            "regulated" => Ok(Regulated),
            "unregulated" => Ok(Unregulated),
            v => {
                tracing::warn!("Unknown value '{}' for enum '{}'", v, "CardRegulatedStatus");
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for CardRegulatedStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for CardRegulatedStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for CardRegulatedStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(CardRegulatedStatus)).finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for CardRegulatedStatus {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl miniserde::Deserialize for CardRegulatedStatus {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

impl miniserde::de::Visitor for crate::Place<CardRegulatedStatus> {
    fn string(&mut self, s: &str) -> miniserde::Result<()> {
        use std::str::FromStr;
        self.out = Some(CardRegulatedStatus::from_str(s).expect("infallible"));
        Ok(())
    }
}

stripe_types::impl_from_val_with_from_str!(CardRegulatedStatus);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for CardRegulatedStatus {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}
impl stripe_types::Object for Card {
    type Id = stripe_shared::CardId;
    fn id(&self) -> &Self::Id {
        &self.id
    }

    fn into_id(self) -> Self::Id {
        self.id
    }
}
stripe_types::def_id!(CardId);