stripe_shared/
payment_method_details_card_present.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodDetailsCardPresent {
5    /// The authorized amount
6    pub amount_authorized: Option<i64>,
7    /// Card brand.
8    /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `link`, `mastercard`, `unionpay`, `visa`, or `unknown`.
9    pub brand: Option<String>,
10    /// The [product code](https://stripe.com/docs/card-product-codes) that identifies the specific program or product associated with a card.
11    pub brand_product: Option<String>,
12    /// When using manual capture, a future timestamp after which the charge will be automatically refunded if uncaptured.
13    pub capture_before: Option<stripe_types::Timestamp>,
14    /// The cardholder name as read from the card, in [ISO 7813](https://en.wikipedia.org/wiki/ISO/IEC_7813) format.
15    /// May include alphanumeric characters, special characters and first/last name separator (`/`).
16    /// In some cases, the cardholder name may not be available depending on how the issuer has configured the card.
17    /// Cardholder name is typically not available on swipe or contactless payments, such as those made with Apple Pay and Google Pay.
18    pub cardholder_name: Option<String>,
19    /// Two-letter ISO code representing the country of the card.
20    /// You could use this attribute to get a sense of the international breakdown of cards you've collected.
21    pub country: Option<String>,
22    /// A high-level description of the type of cards issued in this range.
23    /// (For internal use only and not typically available in standard API requests.).
24    pub description: Option<String>,
25    /// Authorization response cryptogram.
26    pub emv_auth_data: Option<String>,
27    /// Two-digit number representing the card's expiration month.
28    pub exp_month: i64,
29    /// Four-digit number representing the card's expiration year.
30    pub exp_year: i64,
31    /// Uniquely identifies this particular card number.
32    /// You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example.
33    /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number.
34    ///
35    /// *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.*.
36    pub fingerprint: Option<String>,
37    /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`.
38    pub funding: Option<String>,
39    /// ID of a card PaymentMethod generated from the card_present PaymentMethod that may be attached to a Customer for future transactions.
40    /// Only present if it was possible to generate a card PaymentMethod.
41    pub generated_card: Option<String>,
42    /// Issuer identification number of the card.
43    /// (For internal use only and not typically available in standard API requests.).
44    pub iin: Option<String>,
45    /// Whether this [PaymentIntent](https://stripe.com/docs/api/payment_intents) is eligible for incremental authorizations.
46    /// Request support using [request_incremental_authorization_support](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method_options-card_present-request_incremental_authorization_support).
47    pub incremental_authorization_supported: bool,
48    /// The name of the card's issuing bank.
49    /// (For internal use only and not typically available in standard API requests.).
50    pub issuer: Option<String>,
51    /// The last four digits of the card.
52    pub last4: Option<String>,
53    /// Identifies which network this charge was processed on.
54    /// Can be `amex`, `cartes_bancaires`, `diners`, `discover`, `eftpos_au`, `interac`, `jcb`, `link`, `mastercard`, `unionpay`, `visa`, or `unknown`.
55    pub network: Option<String>,
56    /// This is used by the financial networks to identify a transaction.
57    /// Visa calls this the Transaction ID, Mastercard calls this the Trace ID, and American Express calls this the Acquirer Reference Data.
58    /// This value will be present if it is returned by the financial network in the authorization response, and null otherwise.
59    pub network_transaction_id: Option<String>,
60    /// Details about payments collected offline.
61    pub offline: Option<stripe_shared::PaymentMethodDetailsCardPresentOffline>,
62    /// Defines whether the authorized amount can be over-captured or not
63    pub overcapture_supported: bool,
64    /// EMV tag 5F2D. Preferred languages specified by the integrated circuit chip.
65    pub preferred_locales: Option<Vec<String>>,
66    /// How card details were read in this transaction.
67    pub read_method: Option<PaymentMethodDetailsCardPresentReadMethod>,
68    /// A collection of fields required to be displayed on receipts. Only required for EMV transactions.
69    pub receipt: Option<stripe_shared::PaymentMethodDetailsCardPresentReceipt>,
70    pub wallet: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardPresentCommonWallet>,
71}
72#[doc(hidden)]
73pub struct PaymentMethodDetailsCardPresentBuilder {
74    amount_authorized: Option<Option<i64>>,
75    brand: Option<Option<String>>,
76    brand_product: Option<Option<String>>,
77    capture_before: Option<Option<stripe_types::Timestamp>>,
78    cardholder_name: Option<Option<String>>,
79    country: Option<Option<String>>,
80    description: Option<Option<String>>,
81    emv_auth_data: Option<Option<String>>,
82    exp_month: Option<i64>,
83    exp_year: Option<i64>,
84    fingerprint: Option<Option<String>>,
85    funding: Option<Option<String>>,
86    generated_card: Option<Option<String>>,
87    iin: Option<Option<String>>,
88    incremental_authorization_supported: Option<bool>,
89    issuer: Option<Option<String>>,
90    last4: Option<Option<String>>,
91    network: Option<Option<String>>,
92    network_transaction_id: Option<Option<String>>,
93    offline: Option<Option<stripe_shared::PaymentMethodDetailsCardPresentOffline>>,
94    overcapture_supported: Option<bool>,
95    preferred_locales: Option<Option<Vec<String>>>,
96    read_method: Option<Option<PaymentMethodDetailsCardPresentReadMethod>>,
97    receipt: Option<Option<stripe_shared::PaymentMethodDetailsCardPresentReceipt>>,
98    wallet: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardPresentCommonWallet>>,
99}
100
101#[allow(
102    unused_variables,
103    irrefutable_let_patterns,
104    clippy::let_unit_value,
105    clippy::match_single_binding,
106    clippy::single_match
107)]
108const _: () = {
109    use miniserde::de::{Map, Visitor};
110    use miniserde::json::Value;
111    use miniserde::{make_place, Deserialize, Result};
112    use stripe_types::miniserde_helpers::FromValueOpt;
113    use stripe_types::{MapBuilder, ObjectDeser};
114
115    make_place!(Place);
116
117    impl Deserialize for PaymentMethodDetailsCardPresent {
118        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
119            Place::new(out)
120        }
121    }
122
123    struct Builder<'a> {
124        out: &'a mut Option<PaymentMethodDetailsCardPresent>,
125        builder: PaymentMethodDetailsCardPresentBuilder,
126    }
127
128    impl Visitor for Place<PaymentMethodDetailsCardPresent> {
129        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
130            Ok(Box::new(Builder {
131                out: &mut self.out,
132                builder: PaymentMethodDetailsCardPresentBuilder::deser_default(),
133            }))
134        }
135    }
136
137    impl MapBuilder for PaymentMethodDetailsCardPresentBuilder {
138        type Out = PaymentMethodDetailsCardPresent;
139        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
140            Ok(match k {
141                "amount_authorized" => Deserialize::begin(&mut self.amount_authorized),
142                "brand" => Deserialize::begin(&mut self.brand),
143                "brand_product" => Deserialize::begin(&mut self.brand_product),
144                "capture_before" => Deserialize::begin(&mut self.capture_before),
145                "cardholder_name" => Deserialize::begin(&mut self.cardholder_name),
146                "country" => Deserialize::begin(&mut self.country),
147                "description" => Deserialize::begin(&mut self.description),
148                "emv_auth_data" => Deserialize::begin(&mut self.emv_auth_data),
149                "exp_month" => Deserialize::begin(&mut self.exp_month),
150                "exp_year" => Deserialize::begin(&mut self.exp_year),
151                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
152                "funding" => Deserialize::begin(&mut self.funding),
153                "generated_card" => Deserialize::begin(&mut self.generated_card),
154                "iin" => Deserialize::begin(&mut self.iin),
155                "incremental_authorization_supported" => {
156                    Deserialize::begin(&mut self.incremental_authorization_supported)
157                }
158                "issuer" => Deserialize::begin(&mut self.issuer),
159                "last4" => Deserialize::begin(&mut self.last4),
160                "network" => Deserialize::begin(&mut self.network),
161                "network_transaction_id" => Deserialize::begin(&mut self.network_transaction_id),
162                "offline" => Deserialize::begin(&mut self.offline),
163                "overcapture_supported" => Deserialize::begin(&mut self.overcapture_supported),
164                "preferred_locales" => Deserialize::begin(&mut self.preferred_locales),
165                "read_method" => Deserialize::begin(&mut self.read_method),
166                "receipt" => Deserialize::begin(&mut self.receipt),
167                "wallet" => Deserialize::begin(&mut self.wallet),
168
169                _ => <dyn Visitor>::ignore(),
170            })
171        }
172
173        fn deser_default() -> Self {
174            Self {
175                amount_authorized: Deserialize::default(),
176                brand: Deserialize::default(),
177                brand_product: Deserialize::default(),
178                capture_before: Deserialize::default(),
179                cardholder_name: Deserialize::default(),
180                country: Deserialize::default(),
181                description: Deserialize::default(),
182                emv_auth_data: Deserialize::default(),
183                exp_month: Deserialize::default(),
184                exp_year: Deserialize::default(),
185                fingerprint: Deserialize::default(),
186                funding: Deserialize::default(),
187                generated_card: Deserialize::default(),
188                iin: Deserialize::default(),
189                incremental_authorization_supported: Deserialize::default(),
190                issuer: Deserialize::default(),
191                last4: Deserialize::default(),
192                network: Deserialize::default(),
193                network_transaction_id: Deserialize::default(),
194                offline: Deserialize::default(),
195                overcapture_supported: Deserialize::default(),
196                preferred_locales: Deserialize::default(),
197                read_method: Deserialize::default(),
198                receipt: Deserialize::default(),
199                wallet: Deserialize::default(),
200            }
201        }
202
203        fn take_out(&mut self) -> Option<Self::Out> {
204            let (
205                Some(amount_authorized),
206                Some(brand),
207                Some(brand_product),
208                Some(capture_before),
209                Some(cardholder_name),
210                Some(country),
211                Some(description),
212                Some(emv_auth_data),
213                Some(exp_month),
214                Some(exp_year),
215                Some(fingerprint),
216                Some(funding),
217                Some(generated_card),
218                Some(iin),
219                Some(incremental_authorization_supported),
220                Some(issuer),
221                Some(last4),
222                Some(network),
223                Some(network_transaction_id),
224                Some(offline),
225                Some(overcapture_supported),
226                Some(preferred_locales),
227                Some(read_method),
228                Some(receipt),
229                Some(wallet),
230            ) = (
231                self.amount_authorized,
232                self.brand.take(),
233                self.brand_product.take(),
234                self.capture_before,
235                self.cardholder_name.take(),
236                self.country.take(),
237                self.description.take(),
238                self.emv_auth_data.take(),
239                self.exp_month,
240                self.exp_year,
241                self.fingerprint.take(),
242                self.funding.take(),
243                self.generated_card.take(),
244                self.iin.take(),
245                self.incremental_authorization_supported,
246                self.issuer.take(),
247                self.last4.take(),
248                self.network.take(),
249                self.network_transaction_id.take(),
250                self.offline,
251                self.overcapture_supported,
252                self.preferred_locales.take(),
253                self.read_method,
254                self.receipt.take(),
255                self.wallet,
256            )
257            else {
258                return None;
259            };
260            Some(Self::Out {
261                amount_authorized,
262                brand,
263                brand_product,
264                capture_before,
265                cardholder_name,
266                country,
267                description,
268                emv_auth_data,
269                exp_month,
270                exp_year,
271                fingerprint,
272                funding,
273                generated_card,
274                iin,
275                incremental_authorization_supported,
276                issuer,
277                last4,
278                network,
279                network_transaction_id,
280                offline,
281                overcapture_supported,
282                preferred_locales,
283                read_method,
284                receipt,
285                wallet,
286            })
287        }
288    }
289
290    impl<'a> Map for Builder<'a> {
291        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
292            self.builder.key(k)
293        }
294
295        fn finish(&mut self) -> Result<()> {
296            *self.out = self.builder.take_out();
297            Ok(())
298        }
299    }
300
301    impl ObjectDeser for PaymentMethodDetailsCardPresent {
302        type Builder = PaymentMethodDetailsCardPresentBuilder;
303    }
304
305    impl FromValueOpt for PaymentMethodDetailsCardPresent {
306        fn from_value(v: Value) -> Option<Self> {
307            let Value::Object(obj) = v else {
308                return None;
309            };
310            let mut b = PaymentMethodDetailsCardPresentBuilder::deser_default();
311            for (k, v) in obj {
312                match k.as_str() {
313                    "amount_authorized" => b.amount_authorized = FromValueOpt::from_value(v),
314                    "brand" => b.brand = FromValueOpt::from_value(v),
315                    "brand_product" => b.brand_product = FromValueOpt::from_value(v),
316                    "capture_before" => b.capture_before = FromValueOpt::from_value(v),
317                    "cardholder_name" => b.cardholder_name = FromValueOpt::from_value(v),
318                    "country" => b.country = FromValueOpt::from_value(v),
319                    "description" => b.description = FromValueOpt::from_value(v),
320                    "emv_auth_data" => b.emv_auth_data = FromValueOpt::from_value(v),
321                    "exp_month" => b.exp_month = FromValueOpt::from_value(v),
322                    "exp_year" => b.exp_year = FromValueOpt::from_value(v),
323                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
324                    "funding" => b.funding = FromValueOpt::from_value(v),
325                    "generated_card" => b.generated_card = FromValueOpt::from_value(v),
326                    "iin" => b.iin = FromValueOpt::from_value(v),
327                    "incremental_authorization_supported" => {
328                        b.incremental_authorization_supported = FromValueOpt::from_value(v)
329                    }
330                    "issuer" => b.issuer = FromValueOpt::from_value(v),
331                    "last4" => b.last4 = FromValueOpt::from_value(v),
332                    "network" => b.network = FromValueOpt::from_value(v),
333                    "network_transaction_id" => {
334                        b.network_transaction_id = FromValueOpt::from_value(v)
335                    }
336                    "offline" => b.offline = FromValueOpt::from_value(v),
337                    "overcapture_supported" => {
338                        b.overcapture_supported = FromValueOpt::from_value(v)
339                    }
340                    "preferred_locales" => b.preferred_locales = FromValueOpt::from_value(v),
341                    "read_method" => b.read_method = FromValueOpt::from_value(v),
342                    "receipt" => b.receipt = FromValueOpt::from_value(v),
343                    "wallet" => b.wallet = FromValueOpt::from_value(v),
344
345                    _ => {}
346                }
347            }
348            b.take_out()
349        }
350    }
351};
352/// How card details were read in this transaction.
353#[derive(Copy, Clone, Eq, PartialEq)]
354pub enum PaymentMethodDetailsCardPresentReadMethod {
355    ContactEmv,
356    ContactlessEmv,
357    ContactlessMagstripeMode,
358    MagneticStripeFallback,
359    MagneticStripeTrack2,
360}
361impl PaymentMethodDetailsCardPresentReadMethod {
362    pub fn as_str(self) -> &'static str {
363        use PaymentMethodDetailsCardPresentReadMethod::*;
364        match self {
365            ContactEmv => "contact_emv",
366            ContactlessEmv => "contactless_emv",
367            ContactlessMagstripeMode => "contactless_magstripe_mode",
368            MagneticStripeFallback => "magnetic_stripe_fallback",
369            MagneticStripeTrack2 => "magnetic_stripe_track2",
370        }
371    }
372}
373
374impl std::str::FromStr for PaymentMethodDetailsCardPresentReadMethod {
375    type Err = stripe_types::StripeParseError;
376    fn from_str(s: &str) -> Result<Self, Self::Err> {
377        use PaymentMethodDetailsCardPresentReadMethod::*;
378        match s {
379            "contact_emv" => Ok(ContactEmv),
380            "contactless_emv" => Ok(ContactlessEmv),
381            "contactless_magstripe_mode" => Ok(ContactlessMagstripeMode),
382            "magnetic_stripe_fallback" => Ok(MagneticStripeFallback),
383            "magnetic_stripe_track2" => Ok(MagneticStripeTrack2),
384            _ => Err(stripe_types::StripeParseError),
385        }
386    }
387}
388impl std::fmt::Display for PaymentMethodDetailsCardPresentReadMethod {
389    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
390        f.write_str(self.as_str())
391    }
392}
393
394impl std::fmt::Debug for PaymentMethodDetailsCardPresentReadMethod {
395    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
396        f.write_str(self.as_str())
397    }
398}
399#[cfg(feature = "serialize")]
400impl serde::Serialize for PaymentMethodDetailsCardPresentReadMethod {
401    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
402    where
403        S: serde::Serializer,
404    {
405        serializer.serialize_str(self.as_str())
406    }
407}
408impl miniserde::Deserialize for PaymentMethodDetailsCardPresentReadMethod {
409    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
410        crate::Place::new(out)
411    }
412}
413
414impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsCardPresentReadMethod> {
415    fn string(&mut self, s: &str) -> miniserde::Result<()> {
416        use std::str::FromStr;
417        self.out = Some(
418            PaymentMethodDetailsCardPresentReadMethod::from_str(s).map_err(|_| miniserde::Error)?,
419        );
420        Ok(())
421    }
422}
423
424stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardPresentReadMethod);
425#[cfg(feature = "deserialize")]
426impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardPresentReadMethod {
427    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
428        use std::str::FromStr;
429        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
430        Self::from_str(&s).map_err(|_| {
431            serde::de::Error::custom("Unknown value for PaymentMethodDetailsCardPresentReadMethod")
432        })
433    }
434}