Skip to main content

stripe_shared/
setup_attempt_payment_method_details_card.rs

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