stripe_shared/
checkout_card_payment_method_options.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct CheckoutCardPaymentMethodOptions {
5    pub installments: Option<stripe_shared::CheckoutCardInstallmentsOptions>,
6    /// Request ability to [capture beyond the standard authorization validity window](/payments/extended-authorization) for this CheckoutSession.
7    pub request_extended_authorization:
8        Option<CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization>,
9    /// Request ability to [increment the authorization](/payments/incremental-authorization) for this CheckoutSession.
10    pub request_incremental_authorization:
11        Option<CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization>,
12    /// Request ability to make [multiple captures](/payments/multicapture) for this CheckoutSession.
13    pub request_multicapture: Option<CheckoutCardPaymentMethodOptionsRequestMulticapture>,
14    /// Request ability to [overcapture](/payments/overcapture) for this CheckoutSession.
15    pub request_overcapture: Option<CheckoutCardPaymentMethodOptionsRequestOvercapture>,
16    /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication).
17    /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option.
18    /// If not provided, this value defaults to `automatic`.
19    /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure/authentication-flow#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
20    pub request_three_d_secure: CheckoutCardPaymentMethodOptionsRequestThreeDSecure,
21    pub restrictions:
22        Option<stripe_shared::PaymentPagesPrivateCardPaymentMethodOptionsResourceRestrictions>,
23    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
24    ///
25    /// If you provide a Customer with the PaymentIntent, you can use this parameter to [attach the payment method](/payments/save-during-payment) to the Customer after the PaymentIntent is confirmed and the customer completes any required actions.
26    /// If you don't provide a Customer, you can still [attach](/api/payment_methods/attach) the payment method to a Customer after the transaction completes.
27    ///
28    /// If the payment method is `card_present` and isn't a digital wallet, Stripe creates and attaches a [generated_card](/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card to the Customer instead.
29    ///
30    /// When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](/strong-customer-authentication).
31    pub setup_future_usage: Option<CheckoutCardPaymentMethodOptionsSetupFutureUsage>,
32    /// Provides information about a card payment that customers see on their statements.
33    /// Concatenated with the Kana prefix (shortened Kana descriptor) or Kana statement descriptor that’s set on the account to form the complete statement descriptor.
34    /// Maximum 22 characters.
35    /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 22 characters.
36    pub statement_descriptor_suffix_kana: Option<String>,
37    /// Provides information about a card payment that customers see on their statements.
38    /// Concatenated with the Kanji prefix (shortened Kanji descriptor) or Kanji statement descriptor that’s set on the account to form the complete statement descriptor.
39    /// Maximum 17 characters.
40    /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 17 characters.
41    pub statement_descriptor_suffix_kanji: Option<String>,
42}
43#[doc(hidden)]
44pub struct CheckoutCardPaymentMethodOptionsBuilder {
45    installments: Option<Option<stripe_shared::CheckoutCardInstallmentsOptions>>,
46    request_extended_authorization:
47        Option<Option<CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization>>,
48    request_incremental_authorization:
49        Option<Option<CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization>>,
50    request_multicapture: Option<Option<CheckoutCardPaymentMethodOptionsRequestMulticapture>>,
51    request_overcapture: Option<Option<CheckoutCardPaymentMethodOptionsRequestOvercapture>>,
52    request_three_d_secure: Option<CheckoutCardPaymentMethodOptionsRequestThreeDSecure>,
53    restrictions: Option<
54        Option<stripe_shared::PaymentPagesPrivateCardPaymentMethodOptionsResourceRestrictions>,
55    >,
56    setup_future_usage: Option<Option<CheckoutCardPaymentMethodOptionsSetupFutureUsage>>,
57    statement_descriptor_suffix_kana: Option<Option<String>>,
58    statement_descriptor_suffix_kanji: Option<Option<String>>,
59}
60
61#[allow(
62    unused_variables,
63    irrefutable_let_patterns,
64    clippy::let_unit_value,
65    clippy::match_single_binding,
66    clippy::single_match
67)]
68const _: () = {
69    use miniserde::de::{Map, Visitor};
70    use miniserde::json::Value;
71    use miniserde::{make_place, Deserialize, Result};
72    use stripe_types::miniserde_helpers::FromValueOpt;
73    use stripe_types::{MapBuilder, ObjectDeser};
74
75    make_place!(Place);
76
77    impl Deserialize for CheckoutCardPaymentMethodOptions {
78        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
79            Place::new(out)
80        }
81    }
82
83    struct Builder<'a> {
84        out: &'a mut Option<CheckoutCardPaymentMethodOptions>,
85        builder: CheckoutCardPaymentMethodOptionsBuilder,
86    }
87
88    impl Visitor for Place<CheckoutCardPaymentMethodOptions> {
89        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
90            Ok(Box::new(Builder {
91                out: &mut self.out,
92                builder: CheckoutCardPaymentMethodOptionsBuilder::deser_default(),
93            }))
94        }
95    }
96
97    impl MapBuilder for CheckoutCardPaymentMethodOptionsBuilder {
98        type Out = CheckoutCardPaymentMethodOptions;
99        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
100            Ok(match k {
101                "installments" => Deserialize::begin(&mut self.installments),
102                "request_extended_authorization" => {
103                    Deserialize::begin(&mut self.request_extended_authorization)
104                }
105                "request_incremental_authorization" => {
106                    Deserialize::begin(&mut self.request_incremental_authorization)
107                }
108                "request_multicapture" => Deserialize::begin(&mut self.request_multicapture),
109                "request_overcapture" => Deserialize::begin(&mut self.request_overcapture),
110                "request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure),
111                "restrictions" => Deserialize::begin(&mut self.restrictions),
112                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
113                "statement_descriptor_suffix_kana" => {
114                    Deserialize::begin(&mut self.statement_descriptor_suffix_kana)
115                }
116                "statement_descriptor_suffix_kanji" => {
117                    Deserialize::begin(&mut self.statement_descriptor_suffix_kanji)
118                }
119
120                _ => <dyn Visitor>::ignore(),
121            })
122        }
123
124        fn deser_default() -> Self {
125            Self {
126                installments: Deserialize::default(),
127                request_extended_authorization: Deserialize::default(),
128                request_incremental_authorization: Deserialize::default(),
129                request_multicapture: Deserialize::default(),
130                request_overcapture: Deserialize::default(),
131                request_three_d_secure: Deserialize::default(),
132                restrictions: Deserialize::default(),
133                setup_future_usage: Deserialize::default(),
134                statement_descriptor_suffix_kana: Deserialize::default(),
135                statement_descriptor_suffix_kanji: Deserialize::default(),
136            }
137        }
138
139        fn take_out(&mut self) -> Option<Self::Out> {
140            let (
141                Some(installments),
142                Some(request_extended_authorization),
143                Some(request_incremental_authorization),
144                Some(request_multicapture),
145                Some(request_overcapture),
146                Some(request_three_d_secure),
147                Some(restrictions),
148                Some(setup_future_usage),
149                Some(statement_descriptor_suffix_kana),
150                Some(statement_descriptor_suffix_kanji),
151            ) = (
152                self.installments,
153                self.request_extended_authorization,
154                self.request_incremental_authorization,
155                self.request_multicapture,
156                self.request_overcapture,
157                self.request_three_d_secure,
158                self.restrictions.take(),
159                self.setup_future_usage,
160                self.statement_descriptor_suffix_kana.take(),
161                self.statement_descriptor_suffix_kanji.take(),
162            )
163            else {
164                return None;
165            };
166            Some(Self::Out {
167                installments,
168                request_extended_authorization,
169                request_incremental_authorization,
170                request_multicapture,
171                request_overcapture,
172                request_three_d_secure,
173                restrictions,
174                setup_future_usage,
175                statement_descriptor_suffix_kana,
176                statement_descriptor_suffix_kanji,
177            })
178        }
179    }
180
181    impl<'a> Map for Builder<'a> {
182        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
183            self.builder.key(k)
184        }
185
186        fn finish(&mut self) -> Result<()> {
187            *self.out = self.builder.take_out();
188            Ok(())
189        }
190    }
191
192    impl ObjectDeser for CheckoutCardPaymentMethodOptions {
193        type Builder = CheckoutCardPaymentMethodOptionsBuilder;
194    }
195
196    impl FromValueOpt for CheckoutCardPaymentMethodOptions {
197        fn from_value(v: Value) -> Option<Self> {
198            let Value::Object(obj) = v else {
199                return None;
200            };
201            let mut b = CheckoutCardPaymentMethodOptionsBuilder::deser_default();
202            for (k, v) in obj {
203                match k.as_str() {
204                    "installments" => b.installments = FromValueOpt::from_value(v),
205                    "request_extended_authorization" => {
206                        b.request_extended_authorization = FromValueOpt::from_value(v)
207                    }
208                    "request_incremental_authorization" => {
209                        b.request_incremental_authorization = FromValueOpt::from_value(v)
210                    }
211                    "request_multicapture" => b.request_multicapture = FromValueOpt::from_value(v),
212                    "request_overcapture" => b.request_overcapture = FromValueOpt::from_value(v),
213                    "request_three_d_secure" => {
214                        b.request_three_d_secure = FromValueOpt::from_value(v)
215                    }
216                    "restrictions" => b.restrictions = FromValueOpt::from_value(v),
217                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
218                    "statement_descriptor_suffix_kana" => {
219                        b.statement_descriptor_suffix_kana = FromValueOpt::from_value(v)
220                    }
221                    "statement_descriptor_suffix_kanji" => {
222                        b.statement_descriptor_suffix_kanji = FromValueOpt::from_value(v)
223                    }
224
225                    _ => {}
226                }
227            }
228            b.take_out()
229        }
230    }
231};
232/// Request ability to [capture beyond the standard authorization validity window](/payments/extended-authorization) for this CheckoutSession.
233#[derive(Copy, Clone, Eq, PartialEq)]
234pub enum CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
235    IfAvailable,
236    Never,
237}
238impl CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
239    pub fn as_str(self) -> &'static str {
240        use CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization::*;
241        match self {
242            IfAvailable => "if_available",
243            Never => "never",
244        }
245    }
246}
247
248impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
249    type Err = stripe_types::StripeParseError;
250    fn from_str(s: &str) -> Result<Self, Self::Err> {
251        use CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization::*;
252        match s {
253            "if_available" => Ok(IfAvailable),
254            "never" => Ok(Never),
255            _ => Err(stripe_types::StripeParseError),
256        }
257    }
258}
259impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
260    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
261        f.write_str(self.as_str())
262    }
263}
264
265impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
266    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
267        f.write_str(self.as_str())
268    }
269}
270#[cfg(feature = "serialize")]
271impl serde::Serialize for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
272    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
273    where
274        S: serde::Serializer,
275    {
276        serializer.serialize_str(self.as_str())
277    }
278}
279impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
280    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
281        crate::Place::new(out)
282    }
283}
284
285impl miniserde::de::Visitor
286    for crate::Place<CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization>
287{
288    fn string(&mut self, s: &str) -> miniserde::Result<()> {
289        use std::str::FromStr;
290        self.out = Some(
291            CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization::from_str(s)
292                .map_err(|_| miniserde::Error)?,
293        );
294        Ok(())
295    }
296}
297
298stripe_types::impl_from_val_with_from_str!(
299    CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization
300);
301#[cfg(feature = "deserialize")]
302impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
303    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
304        use std::str::FromStr;
305        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
306        Self::from_str(&s).map_err(|_| {
307            serde::de::Error::custom(
308                "Unknown value for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization",
309            )
310        })
311    }
312}
313/// Request ability to [increment the authorization](/payments/incremental-authorization) for this CheckoutSession.
314#[derive(Copy, Clone, Eq, PartialEq)]
315pub enum CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
316    IfAvailable,
317    Never,
318}
319impl CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
320    pub fn as_str(self) -> &'static str {
321        use CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization::*;
322        match self {
323            IfAvailable => "if_available",
324            Never => "never",
325        }
326    }
327}
328
329impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
330    type Err = stripe_types::StripeParseError;
331    fn from_str(s: &str) -> Result<Self, Self::Err> {
332        use CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization::*;
333        match s {
334            "if_available" => Ok(IfAvailable),
335            "never" => Ok(Never),
336            _ => Err(stripe_types::StripeParseError),
337        }
338    }
339}
340impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
341    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
342        f.write_str(self.as_str())
343    }
344}
345
346impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
347    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
348        f.write_str(self.as_str())
349    }
350}
351#[cfg(feature = "serialize")]
352impl serde::Serialize for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
353    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
354    where
355        S: serde::Serializer,
356    {
357        serializer.serialize_str(self.as_str())
358    }
359}
360impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
361    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
362        crate::Place::new(out)
363    }
364}
365
366impl miniserde::de::Visitor
367    for crate::Place<CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization>
368{
369    fn string(&mut self, s: &str) -> miniserde::Result<()> {
370        use std::str::FromStr;
371        self.out = Some(
372            CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization::from_str(s)
373                .map_err(|_| miniserde::Error)?,
374        );
375        Ok(())
376    }
377}
378
379stripe_types::impl_from_val_with_from_str!(
380    CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization
381);
382#[cfg(feature = "deserialize")]
383impl<'de> serde::Deserialize<'de>
384    for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization
385{
386    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
387        use std::str::FromStr;
388        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
389        Self::from_str(&s).map_err(|_| {
390            serde::de::Error::custom(
391                "Unknown value for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization",
392            )
393        })
394    }
395}
396/// Request ability to make [multiple captures](/payments/multicapture) for this CheckoutSession.
397#[derive(Copy, Clone, Eq, PartialEq)]
398pub enum CheckoutCardPaymentMethodOptionsRequestMulticapture {
399    IfAvailable,
400    Never,
401}
402impl CheckoutCardPaymentMethodOptionsRequestMulticapture {
403    pub fn as_str(self) -> &'static str {
404        use CheckoutCardPaymentMethodOptionsRequestMulticapture::*;
405        match self {
406            IfAvailable => "if_available",
407            Never => "never",
408        }
409    }
410}
411
412impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestMulticapture {
413    type Err = stripe_types::StripeParseError;
414    fn from_str(s: &str) -> Result<Self, Self::Err> {
415        use CheckoutCardPaymentMethodOptionsRequestMulticapture::*;
416        match s {
417            "if_available" => Ok(IfAvailable),
418            "never" => Ok(Never),
419            _ => Err(stripe_types::StripeParseError),
420        }
421    }
422}
423impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestMulticapture {
424    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
425        f.write_str(self.as_str())
426    }
427}
428
429impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsRequestMulticapture {
430    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
431        f.write_str(self.as_str())
432    }
433}
434#[cfg(feature = "serialize")]
435impl serde::Serialize for CheckoutCardPaymentMethodOptionsRequestMulticapture {
436    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
437    where
438        S: serde::Serializer,
439    {
440        serializer.serialize_str(self.as_str())
441    }
442}
443impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsRequestMulticapture {
444    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
445        crate::Place::new(out)
446    }
447}
448
449impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsRequestMulticapture> {
450    fn string(&mut self, s: &str) -> miniserde::Result<()> {
451        use std::str::FromStr;
452        self.out = Some(
453            CheckoutCardPaymentMethodOptionsRequestMulticapture::from_str(s)
454                .map_err(|_| miniserde::Error)?,
455        );
456        Ok(())
457    }
458}
459
460stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsRequestMulticapture);
461#[cfg(feature = "deserialize")]
462impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsRequestMulticapture {
463    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
464        use std::str::FromStr;
465        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
466        Self::from_str(&s).map_err(|_| {
467            serde::de::Error::custom(
468                "Unknown value for CheckoutCardPaymentMethodOptionsRequestMulticapture",
469            )
470        })
471    }
472}
473/// Request ability to [overcapture](/payments/overcapture) for this CheckoutSession.
474#[derive(Copy, Clone, Eq, PartialEq)]
475pub enum CheckoutCardPaymentMethodOptionsRequestOvercapture {
476    IfAvailable,
477    Never,
478}
479impl CheckoutCardPaymentMethodOptionsRequestOvercapture {
480    pub fn as_str(self) -> &'static str {
481        use CheckoutCardPaymentMethodOptionsRequestOvercapture::*;
482        match self {
483            IfAvailable => "if_available",
484            Never => "never",
485        }
486    }
487}
488
489impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestOvercapture {
490    type Err = stripe_types::StripeParseError;
491    fn from_str(s: &str) -> Result<Self, Self::Err> {
492        use CheckoutCardPaymentMethodOptionsRequestOvercapture::*;
493        match s {
494            "if_available" => Ok(IfAvailable),
495            "never" => Ok(Never),
496            _ => Err(stripe_types::StripeParseError),
497        }
498    }
499}
500impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestOvercapture {
501    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
502        f.write_str(self.as_str())
503    }
504}
505
506impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsRequestOvercapture {
507    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
508        f.write_str(self.as_str())
509    }
510}
511#[cfg(feature = "serialize")]
512impl serde::Serialize for CheckoutCardPaymentMethodOptionsRequestOvercapture {
513    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
514    where
515        S: serde::Serializer,
516    {
517        serializer.serialize_str(self.as_str())
518    }
519}
520impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsRequestOvercapture {
521    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
522        crate::Place::new(out)
523    }
524}
525
526impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsRequestOvercapture> {
527    fn string(&mut self, s: &str) -> miniserde::Result<()> {
528        use std::str::FromStr;
529        self.out = Some(
530            CheckoutCardPaymentMethodOptionsRequestOvercapture::from_str(s)
531                .map_err(|_| miniserde::Error)?,
532        );
533        Ok(())
534    }
535}
536
537stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsRequestOvercapture);
538#[cfg(feature = "deserialize")]
539impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsRequestOvercapture {
540    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
541        use std::str::FromStr;
542        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
543        Self::from_str(&s).map_err(|_| {
544            serde::de::Error::custom(
545                "Unknown value for CheckoutCardPaymentMethodOptionsRequestOvercapture",
546            )
547        })
548    }
549}
550/// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication).
551/// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option.
552/// If not provided, this value defaults to `automatic`.
553/// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure/authentication-flow#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
554#[derive(Copy, Clone, Eq, PartialEq)]
555pub enum CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
556    Any,
557    Automatic,
558    Challenge,
559}
560impl CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
561    pub fn as_str(self) -> &'static str {
562        use CheckoutCardPaymentMethodOptionsRequestThreeDSecure::*;
563        match self {
564            Any => "any",
565            Automatic => "automatic",
566            Challenge => "challenge",
567        }
568    }
569}
570
571impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
572    type Err = stripe_types::StripeParseError;
573    fn from_str(s: &str) -> Result<Self, Self::Err> {
574        use CheckoutCardPaymentMethodOptionsRequestThreeDSecure::*;
575        match s {
576            "any" => Ok(Any),
577            "automatic" => Ok(Automatic),
578            "challenge" => Ok(Challenge),
579            _ => Err(stripe_types::StripeParseError),
580        }
581    }
582}
583impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
584    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
585        f.write_str(self.as_str())
586    }
587}
588
589impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
590    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
591        f.write_str(self.as_str())
592    }
593}
594#[cfg(feature = "serialize")]
595impl serde::Serialize for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
596    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
597    where
598        S: serde::Serializer,
599    {
600        serializer.serialize_str(self.as_str())
601    }
602}
603impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
604    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
605        crate::Place::new(out)
606    }
607}
608
609impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsRequestThreeDSecure> {
610    fn string(&mut self, s: &str) -> miniserde::Result<()> {
611        use std::str::FromStr;
612        self.out = Some(
613            CheckoutCardPaymentMethodOptionsRequestThreeDSecure::from_str(s)
614                .map_err(|_| miniserde::Error)?,
615        );
616        Ok(())
617    }
618}
619
620stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsRequestThreeDSecure);
621#[cfg(feature = "deserialize")]
622impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
623    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
624        use std::str::FromStr;
625        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
626        Self::from_str(&s).map_err(|_| {
627            serde::de::Error::custom(
628                "Unknown value for CheckoutCardPaymentMethodOptionsRequestThreeDSecure",
629            )
630        })
631    }
632}
633/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
634///
635/// If you provide a Customer with the PaymentIntent, you can use this parameter to [attach the payment method](/payments/save-during-payment) to the Customer after the PaymentIntent is confirmed and the customer completes any required actions.
636/// If you don't provide a Customer, you can still [attach](/api/payment_methods/attach) the payment method to a Customer after the transaction completes.
637///
638/// If the payment method is `card_present` and isn't a digital wallet, Stripe creates and attaches a [generated_card](/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card to the Customer instead.
639///
640/// When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](/strong-customer-authentication).
641#[derive(Copy, Clone, Eq, PartialEq)]
642pub enum CheckoutCardPaymentMethodOptionsSetupFutureUsage {
643    None,
644    OffSession,
645    OnSession,
646}
647impl CheckoutCardPaymentMethodOptionsSetupFutureUsage {
648    pub fn as_str(self) -> &'static str {
649        use CheckoutCardPaymentMethodOptionsSetupFutureUsage::*;
650        match self {
651            None => "none",
652            OffSession => "off_session",
653            OnSession => "on_session",
654        }
655    }
656}
657
658impl std::str::FromStr for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
659    type Err = stripe_types::StripeParseError;
660    fn from_str(s: &str) -> Result<Self, Self::Err> {
661        use CheckoutCardPaymentMethodOptionsSetupFutureUsage::*;
662        match s {
663            "none" => Ok(None),
664            "off_session" => Ok(OffSession),
665            "on_session" => Ok(OnSession),
666            _ => Err(stripe_types::StripeParseError),
667        }
668    }
669}
670impl std::fmt::Display for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
671    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
672        f.write_str(self.as_str())
673    }
674}
675
676impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
677    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
678        f.write_str(self.as_str())
679    }
680}
681#[cfg(feature = "serialize")]
682impl serde::Serialize for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
683    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
684    where
685        S: serde::Serializer,
686    {
687        serializer.serialize_str(self.as_str())
688    }
689}
690impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
691    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
692        crate::Place::new(out)
693    }
694}
695
696impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsSetupFutureUsage> {
697    fn string(&mut self, s: &str) -> miniserde::Result<()> {
698        use std::str::FromStr;
699        self.out = Some(
700            CheckoutCardPaymentMethodOptionsSetupFutureUsage::from_str(s)
701                .map_err(|_| miniserde::Error)?,
702        );
703        Ok(())
704    }
705}
706
707stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsSetupFutureUsage);
708#[cfg(feature = "deserialize")]
709impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
710    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
711        use std::str::FromStr;
712        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
713        Self::from_str(&s).map_err(|_| {
714            serde::de::Error::custom(
715                "Unknown value for CheckoutCardPaymentMethodOptionsSetupFutureUsage",
716            )
717        })
718    }
719}