stripe_shared/
issuing_card.rs

1/// You can [create physical or virtual cards](https://stripe.com/docs/issuing) that are issued to cardholders.
2///
3/// For more details see <<https://stripe.com/docs/api/issuing/cards/object>>.
4#[derive(Clone, Debug)]
5#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
6pub struct IssuingCard {
7    /// The brand of the card.
8    pub brand: String,
9    /// The reason why the card was canceled.
10    pub cancellation_reason: Option<IssuingCardCancellationReason>,
11    pub cardholder: stripe_shared::IssuingCardholder,
12    /// Time at which the object was created. Measured in seconds since the Unix epoch.
13    pub created: stripe_types::Timestamp,
14    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
15    /// Supported currencies are `usd` in the US, `eur` in the EU, and `gbp` in the UK.
16    pub currency: stripe_types::Currency,
17    /// The card's CVC.
18    /// For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with [the `expand` parameter](https://stripe.com/docs/api/expanding_objects).
19    /// Additionally, it's only available via the ["Retrieve a card" endpoint](https://stripe.com/docs/api/issuing/cards/retrieve), not via "List all cards" or any other endpoint.
20    pub cvc: Option<String>,
21    /// The expiration month of the card.
22    pub exp_month: i64,
23    /// The expiration year of the card.
24    pub exp_year: i64,
25    /// The financial account this card is attached to.
26    pub financial_account: Option<String>,
27    /// Unique identifier for the object.
28    pub id: stripe_shared::IssuingCardId,
29    /// The last 4 digits of the card number.
30    pub last4: String,
31    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
32    pub livemode: bool,
33    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
34    /// This can be useful for storing additional information about the object in a structured format.
35    pub metadata: std::collections::HashMap<String, String>,
36    /// The full unredacted card number.
37    /// For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with [the `expand` parameter](https://stripe.com/docs/api/expanding_objects).
38    /// Additionally, it's only available via the ["Retrieve a card" endpoint](https://stripe.com/docs/api/issuing/cards/retrieve), not via "List all cards" or any other endpoint.
39    pub number: Option<String>,
40    /// The personalization design object belonging to this card.
41    pub personalization_design:
42        Option<stripe_types::Expandable<stripe_shared::IssuingPersonalizationDesign>>,
43    /// The latest card that replaces this card, if any.
44    pub replaced_by: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>,
45    /// The card this card replaces, if any.
46    pub replacement_for: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>,
47    /// The reason why the previous card needed to be replaced.
48    pub replacement_reason: Option<stripe_shared::IssuingCardReplacementReason>,
49    /// Where and how the card will be shipped.
50    pub shipping: Option<stripe_shared::IssuingCardShipping>,
51    pub spending_controls: stripe_shared::IssuingCardAuthorizationControls,
52    /// Whether authorizations can be approved on this card.
53    /// May be blocked from activating cards depending on past-due Cardholder requirements.
54    /// Defaults to `inactive`.
55    pub status: stripe_shared::IssuingCardStatus,
56    /// The type of the card.
57    #[cfg_attr(feature = "deserialize", serde(rename = "type"))]
58    pub type_: stripe_shared::IssuingCardType,
59    /// Information relating to digital wallets (like Apple Pay and Google Pay).
60    pub wallets: Option<stripe_shared::IssuingCardWallets>,
61}
62#[doc(hidden)]
63pub struct IssuingCardBuilder {
64    brand: Option<String>,
65    cancellation_reason: Option<Option<IssuingCardCancellationReason>>,
66    cardholder: Option<stripe_shared::IssuingCardholder>,
67    created: Option<stripe_types::Timestamp>,
68    currency: Option<stripe_types::Currency>,
69    cvc: Option<Option<String>>,
70    exp_month: Option<i64>,
71    exp_year: Option<i64>,
72    financial_account: Option<Option<String>>,
73    id: Option<stripe_shared::IssuingCardId>,
74    last4: Option<String>,
75    livemode: Option<bool>,
76    metadata: Option<std::collections::HashMap<String, String>>,
77    number: Option<Option<String>>,
78    personalization_design:
79        Option<Option<stripe_types::Expandable<stripe_shared::IssuingPersonalizationDesign>>>,
80    replaced_by: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCard>>>,
81    replacement_for: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCard>>>,
82    replacement_reason: Option<Option<stripe_shared::IssuingCardReplacementReason>>,
83    shipping: Option<Option<stripe_shared::IssuingCardShipping>>,
84    spending_controls: Option<stripe_shared::IssuingCardAuthorizationControls>,
85    status: Option<stripe_shared::IssuingCardStatus>,
86    type_: Option<stripe_shared::IssuingCardType>,
87    wallets: Option<Option<stripe_shared::IssuingCardWallets>>,
88}
89
90#[allow(
91    unused_variables,
92    irrefutable_let_patterns,
93    clippy::let_unit_value,
94    clippy::match_single_binding,
95    clippy::single_match
96)]
97const _: () = {
98    use miniserde::de::{Map, Visitor};
99    use miniserde::json::Value;
100    use miniserde::{make_place, Deserialize, Result};
101    use stripe_types::miniserde_helpers::FromValueOpt;
102    use stripe_types::{MapBuilder, ObjectDeser};
103
104    make_place!(Place);
105
106    impl Deserialize for IssuingCard {
107        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
108            Place::new(out)
109        }
110    }
111
112    struct Builder<'a> {
113        out: &'a mut Option<IssuingCard>,
114        builder: IssuingCardBuilder,
115    }
116
117    impl Visitor for Place<IssuingCard> {
118        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
119            Ok(Box::new(Builder {
120                out: &mut self.out,
121                builder: IssuingCardBuilder::deser_default(),
122            }))
123        }
124    }
125
126    impl MapBuilder for IssuingCardBuilder {
127        type Out = IssuingCard;
128        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
129            Ok(match k {
130                "brand" => Deserialize::begin(&mut self.brand),
131                "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason),
132                "cardholder" => Deserialize::begin(&mut self.cardholder),
133                "created" => Deserialize::begin(&mut self.created),
134                "currency" => Deserialize::begin(&mut self.currency),
135                "cvc" => Deserialize::begin(&mut self.cvc),
136                "exp_month" => Deserialize::begin(&mut self.exp_month),
137                "exp_year" => Deserialize::begin(&mut self.exp_year),
138                "financial_account" => Deserialize::begin(&mut self.financial_account),
139                "id" => Deserialize::begin(&mut self.id),
140                "last4" => Deserialize::begin(&mut self.last4),
141                "livemode" => Deserialize::begin(&mut self.livemode),
142                "metadata" => Deserialize::begin(&mut self.metadata),
143                "number" => Deserialize::begin(&mut self.number),
144                "personalization_design" => Deserialize::begin(&mut self.personalization_design),
145                "replaced_by" => Deserialize::begin(&mut self.replaced_by),
146                "replacement_for" => Deserialize::begin(&mut self.replacement_for),
147                "replacement_reason" => Deserialize::begin(&mut self.replacement_reason),
148                "shipping" => Deserialize::begin(&mut self.shipping),
149                "spending_controls" => Deserialize::begin(&mut self.spending_controls),
150                "status" => Deserialize::begin(&mut self.status),
151                "type" => Deserialize::begin(&mut self.type_),
152                "wallets" => Deserialize::begin(&mut self.wallets),
153
154                _ => <dyn Visitor>::ignore(),
155            })
156        }
157
158        fn deser_default() -> Self {
159            Self {
160                brand: Deserialize::default(),
161                cancellation_reason: Deserialize::default(),
162                cardholder: Deserialize::default(),
163                created: Deserialize::default(),
164                currency: Deserialize::default(),
165                cvc: Deserialize::default(),
166                exp_month: Deserialize::default(),
167                exp_year: Deserialize::default(),
168                financial_account: Deserialize::default(),
169                id: Deserialize::default(),
170                last4: Deserialize::default(),
171                livemode: Deserialize::default(),
172                metadata: Deserialize::default(),
173                number: Deserialize::default(),
174                personalization_design: Deserialize::default(),
175                replaced_by: Deserialize::default(),
176                replacement_for: Deserialize::default(),
177                replacement_reason: Deserialize::default(),
178                shipping: Deserialize::default(),
179                spending_controls: Deserialize::default(),
180                status: Deserialize::default(),
181                type_: Deserialize::default(),
182                wallets: Deserialize::default(),
183            }
184        }
185
186        fn take_out(&mut self) -> Option<Self::Out> {
187            let (
188                Some(brand),
189                Some(cancellation_reason),
190                Some(cardholder),
191                Some(created),
192                Some(currency),
193                Some(cvc),
194                Some(exp_month),
195                Some(exp_year),
196                Some(financial_account),
197                Some(id),
198                Some(last4),
199                Some(livemode),
200                Some(metadata),
201                Some(number),
202                Some(personalization_design),
203                Some(replaced_by),
204                Some(replacement_for),
205                Some(replacement_reason),
206                Some(shipping),
207                Some(spending_controls),
208                Some(status),
209                Some(type_),
210                Some(wallets),
211            ) = (
212                self.brand.take(),
213                self.cancellation_reason,
214                self.cardholder.take(),
215                self.created,
216                self.currency.take(),
217                self.cvc.take(),
218                self.exp_month,
219                self.exp_year,
220                self.financial_account.take(),
221                self.id.take(),
222                self.last4.take(),
223                self.livemode,
224                self.metadata.take(),
225                self.number.take(),
226                self.personalization_design.take(),
227                self.replaced_by.take(),
228                self.replacement_for.take(),
229                self.replacement_reason,
230                self.shipping.take(),
231                self.spending_controls.take(),
232                self.status,
233                self.type_,
234                self.wallets.take(),
235            )
236            else {
237                return None;
238            };
239            Some(Self::Out {
240                brand,
241                cancellation_reason,
242                cardholder,
243                created,
244                currency,
245                cvc,
246                exp_month,
247                exp_year,
248                financial_account,
249                id,
250                last4,
251                livemode,
252                metadata,
253                number,
254                personalization_design,
255                replaced_by,
256                replacement_for,
257                replacement_reason,
258                shipping,
259                spending_controls,
260                status,
261                type_,
262                wallets,
263            })
264        }
265    }
266
267    impl Map for Builder<'_> {
268        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
269            self.builder.key(k)
270        }
271
272        fn finish(&mut self) -> Result<()> {
273            *self.out = self.builder.take_out();
274            Ok(())
275        }
276    }
277
278    impl ObjectDeser for IssuingCard {
279        type Builder = IssuingCardBuilder;
280    }
281
282    impl FromValueOpt for IssuingCard {
283        fn from_value(v: Value) -> Option<Self> {
284            let Value::Object(obj) = v else {
285                return None;
286            };
287            let mut b = IssuingCardBuilder::deser_default();
288            for (k, v) in obj {
289                match k.as_str() {
290                    "brand" => b.brand = FromValueOpt::from_value(v),
291                    "cancellation_reason" => b.cancellation_reason = FromValueOpt::from_value(v),
292                    "cardholder" => b.cardholder = FromValueOpt::from_value(v),
293                    "created" => b.created = FromValueOpt::from_value(v),
294                    "currency" => b.currency = FromValueOpt::from_value(v),
295                    "cvc" => b.cvc = FromValueOpt::from_value(v),
296                    "exp_month" => b.exp_month = FromValueOpt::from_value(v),
297                    "exp_year" => b.exp_year = FromValueOpt::from_value(v),
298                    "financial_account" => b.financial_account = FromValueOpt::from_value(v),
299                    "id" => b.id = FromValueOpt::from_value(v),
300                    "last4" => b.last4 = FromValueOpt::from_value(v),
301                    "livemode" => b.livemode = FromValueOpt::from_value(v),
302                    "metadata" => b.metadata = FromValueOpt::from_value(v),
303                    "number" => b.number = FromValueOpt::from_value(v),
304                    "personalization_design" => {
305                        b.personalization_design = FromValueOpt::from_value(v)
306                    }
307                    "replaced_by" => b.replaced_by = FromValueOpt::from_value(v),
308                    "replacement_for" => b.replacement_for = FromValueOpt::from_value(v),
309                    "replacement_reason" => b.replacement_reason = FromValueOpt::from_value(v),
310                    "shipping" => b.shipping = FromValueOpt::from_value(v),
311                    "spending_controls" => b.spending_controls = FromValueOpt::from_value(v),
312                    "status" => b.status = FromValueOpt::from_value(v),
313                    "type" => b.type_ = FromValueOpt::from_value(v),
314                    "wallets" => b.wallets = FromValueOpt::from_value(v),
315
316                    _ => {}
317                }
318            }
319            b.take_out()
320        }
321    }
322};
323#[cfg(feature = "serialize")]
324impl serde::Serialize for IssuingCard {
325    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
326        use serde::ser::SerializeStruct;
327        let mut s = s.serialize_struct("IssuingCard", 24)?;
328        s.serialize_field("brand", &self.brand)?;
329        s.serialize_field("cancellation_reason", &self.cancellation_reason)?;
330        s.serialize_field("cardholder", &self.cardholder)?;
331        s.serialize_field("created", &self.created)?;
332        s.serialize_field("currency", &self.currency)?;
333        s.serialize_field("cvc", &self.cvc)?;
334        s.serialize_field("exp_month", &self.exp_month)?;
335        s.serialize_field("exp_year", &self.exp_year)?;
336        s.serialize_field("financial_account", &self.financial_account)?;
337        s.serialize_field("id", &self.id)?;
338        s.serialize_field("last4", &self.last4)?;
339        s.serialize_field("livemode", &self.livemode)?;
340        s.serialize_field("metadata", &self.metadata)?;
341        s.serialize_field("number", &self.number)?;
342        s.serialize_field("personalization_design", &self.personalization_design)?;
343        s.serialize_field("replaced_by", &self.replaced_by)?;
344        s.serialize_field("replacement_for", &self.replacement_for)?;
345        s.serialize_field("replacement_reason", &self.replacement_reason)?;
346        s.serialize_field("shipping", &self.shipping)?;
347        s.serialize_field("spending_controls", &self.spending_controls)?;
348        s.serialize_field("status", &self.status)?;
349        s.serialize_field("type", &self.type_)?;
350        s.serialize_field("wallets", &self.wallets)?;
351
352        s.serialize_field("object", "issuing.card")?;
353        s.end()
354    }
355}
356/// The reason why the card was canceled.
357#[derive(Copy, Clone, Eq, PartialEq)]
358pub enum IssuingCardCancellationReason {
359    DesignRejected,
360    Lost,
361    Stolen,
362}
363impl IssuingCardCancellationReason {
364    pub fn as_str(self) -> &'static str {
365        use IssuingCardCancellationReason::*;
366        match self {
367            DesignRejected => "design_rejected",
368            Lost => "lost",
369            Stolen => "stolen",
370        }
371    }
372}
373
374impl std::str::FromStr for IssuingCardCancellationReason {
375    type Err = stripe_types::StripeParseError;
376    fn from_str(s: &str) -> Result<Self, Self::Err> {
377        use IssuingCardCancellationReason::*;
378        match s {
379            "design_rejected" => Ok(DesignRejected),
380            "lost" => Ok(Lost),
381            "stolen" => Ok(Stolen),
382            _ => Err(stripe_types::StripeParseError),
383        }
384    }
385}
386impl std::fmt::Display for IssuingCardCancellationReason {
387    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
388        f.write_str(self.as_str())
389    }
390}
391
392impl std::fmt::Debug for IssuingCardCancellationReason {
393    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
394        f.write_str(self.as_str())
395    }
396}
397#[cfg(feature = "serialize")]
398impl serde::Serialize for IssuingCardCancellationReason {
399    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
400    where
401        S: serde::Serializer,
402    {
403        serializer.serialize_str(self.as_str())
404    }
405}
406impl miniserde::Deserialize for IssuingCardCancellationReason {
407    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
408        crate::Place::new(out)
409    }
410}
411
412impl miniserde::de::Visitor for crate::Place<IssuingCardCancellationReason> {
413    fn string(&mut self, s: &str) -> miniserde::Result<()> {
414        use std::str::FromStr;
415        self.out = Some(IssuingCardCancellationReason::from_str(s).map_err(|_| miniserde::Error)?);
416        Ok(())
417    }
418}
419
420stripe_types::impl_from_val_with_from_str!(IssuingCardCancellationReason);
421#[cfg(feature = "deserialize")]
422impl<'de> serde::Deserialize<'de> for IssuingCardCancellationReason {
423    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
424        use std::str::FromStr;
425        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
426        Self::from_str(&s).map_err(|_| {
427            serde::de::Error::custom("Unknown value for IssuingCardCancellationReason")
428        })
429    }
430}
431impl stripe_types::Object for IssuingCard {
432    type Id = stripe_shared::IssuingCardId;
433    fn id(&self) -> &Self::Id {
434        &self.id
435    }
436
437    fn into_id(self) -> Self::Id {
438        self.id
439    }
440}
441stripe_types::def_id!(IssuingCardId);
442#[derive(Copy, Clone, Eq, PartialEq)]
443pub enum IssuingCardReplacementReason {
444    Damaged,
445    Expired,
446    Lost,
447    Stolen,
448}
449impl IssuingCardReplacementReason {
450    pub fn as_str(self) -> &'static str {
451        use IssuingCardReplacementReason::*;
452        match self {
453            Damaged => "damaged",
454            Expired => "expired",
455            Lost => "lost",
456            Stolen => "stolen",
457        }
458    }
459}
460
461impl std::str::FromStr for IssuingCardReplacementReason {
462    type Err = stripe_types::StripeParseError;
463    fn from_str(s: &str) -> Result<Self, Self::Err> {
464        use IssuingCardReplacementReason::*;
465        match s {
466            "damaged" => Ok(Damaged),
467            "expired" => Ok(Expired),
468            "lost" => Ok(Lost),
469            "stolen" => Ok(Stolen),
470            _ => Err(stripe_types::StripeParseError),
471        }
472    }
473}
474impl std::fmt::Display for IssuingCardReplacementReason {
475    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
476        f.write_str(self.as_str())
477    }
478}
479
480impl std::fmt::Debug for IssuingCardReplacementReason {
481    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
482        f.write_str(self.as_str())
483    }
484}
485impl serde::Serialize for IssuingCardReplacementReason {
486    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
487    where
488        S: serde::Serializer,
489    {
490        serializer.serialize_str(self.as_str())
491    }
492}
493impl miniserde::Deserialize for IssuingCardReplacementReason {
494    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
495        crate::Place::new(out)
496    }
497}
498
499impl miniserde::de::Visitor for crate::Place<IssuingCardReplacementReason> {
500    fn string(&mut self, s: &str) -> miniserde::Result<()> {
501        use std::str::FromStr;
502        self.out = Some(IssuingCardReplacementReason::from_str(s).map_err(|_| miniserde::Error)?);
503        Ok(())
504    }
505}
506
507stripe_types::impl_from_val_with_from_str!(IssuingCardReplacementReason);
508#[cfg(feature = "deserialize")]
509impl<'de> serde::Deserialize<'de> for IssuingCardReplacementReason {
510    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
511        use std::str::FromStr;
512        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
513        Self::from_str(&s)
514            .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardReplacementReason"))
515    }
516}
517#[derive(Copy, Clone, Eq, PartialEq)]
518pub enum IssuingCardStatus {
519    Active,
520    Canceled,
521    Inactive,
522}
523impl IssuingCardStatus {
524    pub fn as_str(self) -> &'static str {
525        use IssuingCardStatus::*;
526        match self {
527            Active => "active",
528            Canceled => "canceled",
529            Inactive => "inactive",
530        }
531    }
532}
533
534impl std::str::FromStr for IssuingCardStatus {
535    type Err = stripe_types::StripeParseError;
536    fn from_str(s: &str) -> Result<Self, Self::Err> {
537        use IssuingCardStatus::*;
538        match s {
539            "active" => Ok(Active),
540            "canceled" => Ok(Canceled),
541            "inactive" => Ok(Inactive),
542            _ => Err(stripe_types::StripeParseError),
543        }
544    }
545}
546impl std::fmt::Display for IssuingCardStatus {
547    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
548        f.write_str(self.as_str())
549    }
550}
551
552impl std::fmt::Debug for IssuingCardStatus {
553    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
554        f.write_str(self.as_str())
555    }
556}
557impl serde::Serialize for IssuingCardStatus {
558    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
559    where
560        S: serde::Serializer,
561    {
562        serializer.serialize_str(self.as_str())
563    }
564}
565impl miniserde::Deserialize for IssuingCardStatus {
566    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
567        crate::Place::new(out)
568    }
569}
570
571impl miniserde::de::Visitor for crate::Place<IssuingCardStatus> {
572    fn string(&mut self, s: &str) -> miniserde::Result<()> {
573        use std::str::FromStr;
574        self.out = Some(IssuingCardStatus::from_str(s).map_err(|_| miniserde::Error)?);
575        Ok(())
576    }
577}
578
579stripe_types::impl_from_val_with_from_str!(IssuingCardStatus);
580#[cfg(feature = "deserialize")]
581impl<'de> serde::Deserialize<'de> for IssuingCardStatus {
582    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
583        use std::str::FromStr;
584        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
585        Self::from_str(&s)
586            .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardStatus"))
587    }
588}
589#[derive(Copy, Clone, Eq, PartialEq)]
590pub enum IssuingCardType {
591    Physical,
592    Virtual,
593}
594impl IssuingCardType {
595    pub fn as_str(self) -> &'static str {
596        use IssuingCardType::*;
597        match self {
598            Physical => "physical",
599            Virtual => "virtual",
600        }
601    }
602}
603
604impl std::str::FromStr for IssuingCardType {
605    type Err = stripe_types::StripeParseError;
606    fn from_str(s: &str) -> Result<Self, Self::Err> {
607        use IssuingCardType::*;
608        match s {
609            "physical" => Ok(Physical),
610            "virtual" => Ok(Virtual),
611            _ => Err(stripe_types::StripeParseError),
612        }
613    }
614}
615impl std::fmt::Display for IssuingCardType {
616    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
617        f.write_str(self.as_str())
618    }
619}
620
621impl std::fmt::Debug for IssuingCardType {
622    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
623        f.write_str(self.as_str())
624    }
625}
626impl serde::Serialize for IssuingCardType {
627    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
628    where
629        S: serde::Serializer,
630    {
631        serializer.serialize_str(self.as_str())
632    }
633}
634impl miniserde::Deserialize for IssuingCardType {
635    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
636        crate::Place::new(out)
637    }
638}
639
640impl miniserde::de::Visitor for crate::Place<IssuingCardType> {
641    fn string(&mut self, s: &str) -> miniserde::Result<()> {
642        use std::str::FromStr;
643        self.out = Some(IssuingCardType::from_str(s).map_err(|_| miniserde::Error)?);
644        Ok(())
645    }
646}
647
648stripe_types::impl_from_val_with_from_str!(IssuingCardType);
649#[cfg(feature = "deserialize")]
650impl<'de> serde::Deserialize<'de> for IssuingCardType {
651    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
652        use std::str::FromStr;
653        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
654        Self::from_str(&s)
655            .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardType"))
656    }
657}