stripe_shared/
setup_attempt_payment_method_details_card.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupAttemptPaymentMethodDetailsCard {
5    /// Card brand.
6    /// Can be `amex`, `cartes_bancaires`, `diners`, `discover`, `eftpos_au`, `jcb`, `link`, `mastercard`, `unionpay`, `visa` or `unknown`.
7    pub brand: Option<String>,
8    /// Check results by Card networks on Card address and CVC at the time of authorization
9    pub checks: Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardChecks>,
10    /// Two-letter ISO code representing the country of the card.
11    /// You could use this attribute to get a sense of the international breakdown of cards you've collected.
12    pub country: Option<String>,
13    /// A high-level description of the type of cards issued in this range.
14    /// (For internal use only and not typically available in standard API requests.).
15    pub description: Option<String>,
16    /// Two-digit number representing the card's expiration month.
17    pub exp_month: Option<i64>,
18    /// Four-digit number representing the card's expiration year.
19    pub exp_year: Option<i64>,
20    /// Uniquely identifies this particular card number.
21    /// You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example.
22    /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number.
23    ///
24    /// *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.*.
25    pub fingerprint: Option<String>,
26    /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`.
27    pub funding: Option<String>,
28    /// Issuer identification number of the card.
29    /// (For internal use only and not typically available in standard API requests.).
30    pub iin: Option<String>,
31    /// The name of the card's issuing bank.
32    /// (For internal use only and not typically available in standard API requests.).
33    pub issuer: Option<String>,
34    /// The last four digits of the card.
35    pub last4: Option<String>,
36    /// Identifies which network this charge was processed on.
37    /// Can be `amex`, `cartes_bancaires`, `diners`, `discover`, `eftpos_au`, `interac`, `jcb`, `link`, `mastercard`, `unionpay`, `visa`, or `unknown`.
38    pub network: Option<String>,
39    /// Populated if this authorization used 3D Secure authentication.
40    pub three_d_secure: Option<stripe_shared::ThreeDSecureDetails>,
41    /// If this Card is part of a card wallet, this contains the details of the card wallet.
42    pub wallet: Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardWallet>,
43}
44#[doc(hidden)]
45pub struct SetupAttemptPaymentMethodDetailsCardBuilder {
46    brand: Option<Option<String>>,
47    checks: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardChecks>>,
48    country: Option<Option<String>>,
49    description: Option<Option<String>>,
50    exp_month: Option<Option<i64>>,
51    exp_year: Option<Option<i64>>,
52    fingerprint: Option<Option<String>>,
53    funding: Option<Option<String>>,
54    iin: Option<Option<String>>,
55    issuer: Option<Option<String>>,
56    last4: Option<Option<String>>,
57    network: Option<Option<String>>,
58    three_d_secure: Option<Option<stripe_shared::ThreeDSecureDetails>>,
59    wallet: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardWallet>>,
60}
61
62#[allow(
63    unused_variables,
64    irrefutable_let_patterns,
65    clippy::let_unit_value,
66    clippy::match_single_binding,
67    clippy::single_match
68)]
69const _: () = {
70    use miniserde::de::{Map, Visitor};
71    use miniserde::json::Value;
72    use miniserde::{make_place, Deserialize, Result};
73    use stripe_types::miniserde_helpers::FromValueOpt;
74    use stripe_types::{MapBuilder, ObjectDeser};
75
76    make_place!(Place);
77
78    impl Deserialize for SetupAttemptPaymentMethodDetailsCard {
79        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
80            Place::new(out)
81        }
82    }
83
84    struct Builder<'a> {
85        out: &'a mut Option<SetupAttemptPaymentMethodDetailsCard>,
86        builder: SetupAttemptPaymentMethodDetailsCardBuilder,
87    }
88
89    impl Visitor for Place<SetupAttemptPaymentMethodDetailsCard> {
90        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
91            Ok(Box::new(Builder {
92                out: &mut self.out,
93                builder: SetupAttemptPaymentMethodDetailsCardBuilder::deser_default(),
94            }))
95        }
96    }
97
98    impl MapBuilder for SetupAttemptPaymentMethodDetailsCardBuilder {
99        type Out = SetupAttemptPaymentMethodDetailsCard;
100        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
101            Ok(match k {
102                "brand" => Deserialize::begin(&mut self.brand),
103                "checks" => Deserialize::begin(&mut self.checks),
104                "country" => Deserialize::begin(&mut self.country),
105                "description" => Deserialize::begin(&mut self.description),
106                "exp_month" => Deserialize::begin(&mut self.exp_month),
107                "exp_year" => Deserialize::begin(&mut self.exp_year),
108                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
109                "funding" => Deserialize::begin(&mut self.funding),
110                "iin" => Deserialize::begin(&mut self.iin),
111                "issuer" => Deserialize::begin(&mut self.issuer),
112                "last4" => Deserialize::begin(&mut self.last4),
113                "network" => Deserialize::begin(&mut self.network),
114                "three_d_secure" => Deserialize::begin(&mut self.three_d_secure),
115                "wallet" => Deserialize::begin(&mut self.wallet),
116
117                _ => <dyn Visitor>::ignore(),
118            })
119        }
120
121        fn deser_default() -> Self {
122            Self {
123                brand: Deserialize::default(),
124                checks: Deserialize::default(),
125                country: Deserialize::default(),
126                description: Deserialize::default(),
127                exp_month: Deserialize::default(),
128                exp_year: Deserialize::default(),
129                fingerprint: Deserialize::default(),
130                funding: Deserialize::default(),
131                iin: Deserialize::default(),
132                issuer: Deserialize::default(),
133                last4: Deserialize::default(),
134                network: Deserialize::default(),
135                three_d_secure: Deserialize::default(),
136                wallet: Deserialize::default(),
137            }
138        }
139
140        fn take_out(&mut self) -> Option<Self::Out> {
141            let (
142                Some(brand),
143                Some(checks),
144                Some(country),
145                Some(description),
146                Some(exp_month),
147                Some(exp_year),
148                Some(fingerprint),
149                Some(funding),
150                Some(iin),
151                Some(issuer),
152                Some(last4),
153                Some(network),
154                Some(three_d_secure),
155                Some(wallet),
156            ) = (
157                self.brand.take(),
158                self.checks.take(),
159                self.country.take(),
160                self.description.take(),
161                self.exp_month,
162                self.exp_year,
163                self.fingerprint.take(),
164                self.funding.take(),
165                self.iin.take(),
166                self.issuer.take(),
167                self.last4.take(),
168                self.network.take(),
169                self.three_d_secure.take(),
170                self.wallet,
171            )
172            else {
173                return None;
174            };
175            Some(Self::Out {
176                brand,
177                checks,
178                country,
179                description,
180                exp_month,
181                exp_year,
182                fingerprint,
183                funding,
184                iin,
185                issuer,
186                last4,
187                network,
188                three_d_secure,
189                wallet,
190            })
191        }
192    }
193
194    impl Map for Builder<'_> {
195        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
196            self.builder.key(k)
197        }
198
199        fn finish(&mut self) -> Result<()> {
200            *self.out = self.builder.take_out();
201            Ok(())
202        }
203    }
204
205    impl ObjectDeser for SetupAttemptPaymentMethodDetailsCard {
206        type Builder = SetupAttemptPaymentMethodDetailsCardBuilder;
207    }
208
209    impl FromValueOpt for SetupAttemptPaymentMethodDetailsCard {
210        fn from_value(v: Value) -> Option<Self> {
211            let Value::Object(obj) = v else {
212                return None;
213            };
214            let mut b = SetupAttemptPaymentMethodDetailsCardBuilder::deser_default();
215            for (k, v) in obj {
216                match k.as_str() {
217                    "brand" => b.brand = FromValueOpt::from_value(v),
218                    "checks" => b.checks = FromValueOpt::from_value(v),
219                    "country" => b.country = FromValueOpt::from_value(v),
220                    "description" => b.description = FromValueOpt::from_value(v),
221                    "exp_month" => b.exp_month = FromValueOpt::from_value(v),
222                    "exp_year" => b.exp_year = FromValueOpt::from_value(v),
223                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
224                    "funding" => b.funding = FromValueOpt::from_value(v),
225                    "iin" => b.iin = FromValueOpt::from_value(v),
226                    "issuer" => b.issuer = FromValueOpt::from_value(v),
227                    "last4" => b.last4 = FromValueOpt::from_value(v),
228                    "network" => b.network = FromValueOpt::from_value(v),
229                    "three_d_secure" => b.three_d_secure = FromValueOpt::from_value(v),
230                    "wallet" => b.wallet = FromValueOpt::from_value(v),
231
232                    _ => {}
233                }
234            }
235            b.take_out()
236        }
237    }
238};