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