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
124                _ => <dyn Visitor>::ignore(),
125            })
126        }
127
128        fn deser_default() -> Self {
129            Self {
130                capture_method: Deserialize::default(),
131                installments: Deserialize::default(),
132                request_extended_authorization: Deserialize::default(),
133                request_incremental_authorization: Deserialize::default(),
134                request_multicapture: Deserialize::default(),
135                request_overcapture: Deserialize::default(),
136                request_three_d_secure: Deserialize::default(),
137                restrictions: Deserialize::default(),
138                setup_future_usage: Deserialize::default(),
139                statement_descriptor_suffix_kana: Deserialize::default(),
140                statement_descriptor_suffix_kanji: Deserialize::default(),
141            }
142        }
143
144        fn take_out(&mut self) -> Option<Self::Out> {
145            let (
146                Some(capture_method),
147                Some(installments),
148                Some(request_extended_authorization),
149                Some(request_incremental_authorization),
150                Some(request_multicapture),
151                Some(request_overcapture),
152                Some(request_three_d_secure),
153                Some(restrictions),
154                Some(setup_future_usage),
155                Some(statement_descriptor_suffix_kana),
156                Some(statement_descriptor_suffix_kanji),
157            ) = (
158                self.capture_method,
159                self.installments,
160                self.request_extended_authorization,
161                self.request_incremental_authorization,
162                self.request_multicapture,
163                self.request_overcapture,
164                self.request_three_d_secure,
165                self.restrictions.take(),
166                self.setup_future_usage,
167                self.statement_descriptor_suffix_kana.take(),
168                self.statement_descriptor_suffix_kanji.take(),
169            )
170            else {
171                return None;
172            };
173            Some(Self::Out {
174                capture_method,
175                installments,
176                request_extended_authorization,
177                request_incremental_authorization,
178                request_multicapture,
179                request_overcapture,
180                request_three_d_secure,
181                restrictions,
182                setup_future_usage,
183                statement_descriptor_suffix_kana,
184                statement_descriptor_suffix_kanji,
185            })
186        }
187    }
188
189    impl Map for Builder<'_> {
190        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
191            self.builder.key(k)
192        }
193
194        fn finish(&mut self) -> Result<()> {
195            *self.out = self.builder.take_out();
196            Ok(())
197        }
198    }
199
200    impl ObjectDeser for CheckoutCardPaymentMethodOptions {
201        type Builder = CheckoutCardPaymentMethodOptionsBuilder;
202    }
203
204    impl FromValueOpt for CheckoutCardPaymentMethodOptions {
205        fn from_value(v: Value) -> Option<Self> {
206            let Value::Object(obj) = v else {
207                return None;
208            };
209            let mut b = CheckoutCardPaymentMethodOptionsBuilder::deser_default();
210            for (k, v) in obj {
211                match k.as_str() {
212                    "capture_method" => b.capture_method = FromValueOpt::from_value(v),
213                    "installments" => b.installments = FromValueOpt::from_value(v),
214                    "request_extended_authorization" => {
215                        b.request_extended_authorization = FromValueOpt::from_value(v)
216                    }
217                    "request_incremental_authorization" => {
218                        b.request_incremental_authorization = FromValueOpt::from_value(v)
219                    }
220                    "request_multicapture" => b.request_multicapture = FromValueOpt::from_value(v),
221                    "request_overcapture" => b.request_overcapture = FromValueOpt::from_value(v),
222                    "request_three_d_secure" => {
223                        b.request_three_d_secure = FromValueOpt::from_value(v)
224                    }
225                    "restrictions" => b.restrictions = FromValueOpt::from_value(v),
226                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
227                    "statement_descriptor_suffix_kana" => {
228                        b.statement_descriptor_suffix_kana = FromValueOpt::from_value(v)
229                    }
230                    "statement_descriptor_suffix_kanji" => {
231                        b.statement_descriptor_suffix_kanji = FromValueOpt::from_value(v)
232                    }
233
234                    _ => {}
235                }
236            }
237            b.take_out()
238        }
239    }
240};
241/// Controls when the funds will be captured from the customer's account.
242#[derive(Copy, Clone, Eq, PartialEq)]
243pub enum CheckoutCardPaymentMethodOptionsCaptureMethod {
244    Manual,
245}
246impl CheckoutCardPaymentMethodOptionsCaptureMethod {
247    pub fn as_str(self) -> &'static str {
248        use CheckoutCardPaymentMethodOptionsCaptureMethod::*;
249        match self {
250            Manual => "manual",
251        }
252    }
253}
254
255impl std::str::FromStr for CheckoutCardPaymentMethodOptionsCaptureMethod {
256    type Err = stripe_types::StripeParseError;
257    fn from_str(s: &str) -> Result<Self, Self::Err> {
258        use CheckoutCardPaymentMethodOptionsCaptureMethod::*;
259        match s {
260            "manual" => Ok(Manual),
261            _ => Err(stripe_types::StripeParseError),
262        }
263    }
264}
265impl std::fmt::Display for CheckoutCardPaymentMethodOptionsCaptureMethod {
266    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
267        f.write_str(self.as_str())
268    }
269}
270
271impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsCaptureMethod {
272    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
273        f.write_str(self.as_str())
274    }
275}
276#[cfg(feature = "serialize")]
277impl serde::Serialize for CheckoutCardPaymentMethodOptionsCaptureMethod {
278    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
279    where
280        S: serde::Serializer,
281    {
282        serializer.serialize_str(self.as_str())
283    }
284}
285impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsCaptureMethod {
286    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
287        crate::Place::new(out)
288    }
289}
290
291impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsCaptureMethod> {
292    fn string(&mut self, s: &str) -> miniserde::Result<()> {
293        use std::str::FromStr;
294        self.out = Some(
295            CheckoutCardPaymentMethodOptionsCaptureMethod::from_str(s)
296                .map_err(|_| miniserde::Error)?,
297        );
298        Ok(())
299    }
300}
301
302stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsCaptureMethod);
303#[cfg(feature = "deserialize")]
304impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsCaptureMethod {
305    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
306        use std::str::FromStr;
307        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
308        Self::from_str(&s).map_err(|_| {
309            serde::de::Error::custom(
310                "Unknown value for CheckoutCardPaymentMethodOptionsCaptureMethod",
311            )
312        })
313    }
314}
315/// Request ability to [capture beyond the standard authorization validity window](/payments/extended-authorization) for this CheckoutSession.
316#[derive(Copy, Clone, Eq, PartialEq)]
317pub enum CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
318    IfAvailable,
319    Never,
320}
321impl CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
322    pub fn as_str(self) -> &'static str {
323        use CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization::*;
324        match self {
325            IfAvailable => "if_available",
326            Never => "never",
327        }
328    }
329}
330
331impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
332    type Err = stripe_types::StripeParseError;
333    fn from_str(s: &str) -> Result<Self, Self::Err> {
334        use CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization::*;
335        match s {
336            "if_available" => Ok(IfAvailable),
337            "never" => Ok(Never),
338            _ => Err(stripe_types::StripeParseError),
339        }
340    }
341}
342impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
343    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
344        f.write_str(self.as_str())
345    }
346}
347
348impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
349    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
350        f.write_str(self.as_str())
351    }
352}
353#[cfg(feature = "serialize")]
354impl serde::Serialize for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
355    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
356    where
357        S: serde::Serializer,
358    {
359        serializer.serialize_str(self.as_str())
360    }
361}
362impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
363    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
364        crate::Place::new(out)
365    }
366}
367
368impl miniserde::de::Visitor
369    for crate::Place<CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization>
370{
371    fn string(&mut self, s: &str) -> miniserde::Result<()> {
372        use std::str::FromStr;
373        self.out = Some(
374            CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization::from_str(s)
375                .map_err(|_| miniserde::Error)?,
376        );
377        Ok(())
378    }
379}
380
381stripe_types::impl_from_val_with_from_str!(
382    CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization
383);
384#[cfg(feature = "deserialize")]
385impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization {
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 CheckoutCardPaymentMethodOptionsRequestExtendedAuthorization",
392            )
393        })
394    }
395}
396/// Request ability to [increment the authorization](/payments/incremental-authorization) for this CheckoutSession.
397#[derive(Copy, Clone, Eq, PartialEq)]
398pub enum CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
399    IfAvailable,
400    Never,
401}
402impl CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
403    pub fn as_str(self) -> &'static str {
404        use CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization::*;
405        match self {
406            IfAvailable => "if_available",
407            Never => "never",
408        }
409    }
410}
411
412impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
413    type Err = stripe_types::StripeParseError;
414    fn from_str(s: &str) -> Result<Self, Self::Err> {
415        use CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization::*;
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 CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
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 CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
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 CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
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 CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization {
444    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
445        crate::Place::new(out)
446    }
447}
448
449impl miniserde::de::Visitor
450    for crate::Place<CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization>
451{
452    fn string(&mut self, s: &str) -> miniserde::Result<()> {
453        use std::str::FromStr;
454        self.out = Some(
455            CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization::from_str(s)
456                .map_err(|_| miniserde::Error)?,
457        );
458        Ok(())
459    }
460}
461
462stripe_types::impl_from_val_with_from_str!(
463    CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization
464);
465#[cfg(feature = "deserialize")]
466impl<'de> serde::Deserialize<'de>
467    for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization
468{
469    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
470        use std::str::FromStr;
471        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
472        Self::from_str(&s).map_err(|_| {
473            serde::de::Error::custom(
474                "Unknown value for CheckoutCardPaymentMethodOptionsRequestIncrementalAuthorization",
475            )
476        })
477    }
478}
479/// Request ability to make [multiple captures](/payments/multicapture) for this CheckoutSession.
480#[derive(Copy, Clone, Eq, PartialEq)]
481pub enum CheckoutCardPaymentMethodOptionsRequestMulticapture {
482    IfAvailable,
483    Never,
484}
485impl CheckoutCardPaymentMethodOptionsRequestMulticapture {
486    pub fn as_str(self) -> &'static str {
487        use CheckoutCardPaymentMethodOptionsRequestMulticapture::*;
488        match self {
489            IfAvailable => "if_available",
490            Never => "never",
491        }
492    }
493}
494
495impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestMulticapture {
496    type Err = stripe_types::StripeParseError;
497    fn from_str(s: &str) -> Result<Self, Self::Err> {
498        use CheckoutCardPaymentMethodOptionsRequestMulticapture::*;
499        match s {
500            "if_available" => Ok(IfAvailable),
501            "never" => Ok(Never),
502            _ => Err(stripe_types::StripeParseError),
503        }
504    }
505}
506impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestMulticapture {
507    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
508        f.write_str(self.as_str())
509    }
510}
511
512impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsRequestMulticapture {
513    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
514        f.write_str(self.as_str())
515    }
516}
517#[cfg(feature = "serialize")]
518impl serde::Serialize for CheckoutCardPaymentMethodOptionsRequestMulticapture {
519    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
520    where
521        S: serde::Serializer,
522    {
523        serializer.serialize_str(self.as_str())
524    }
525}
526impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsRequestMulticapture {
527    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
528        crate::Place::new(out)
529    }
530}
531
532impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsRequestMulticapture> {
533    fn string(&mut self, s: &str) -> miniserde::Result<()> {
534        use std::str::FromStr;
535        self.out = Some(
536            CheckoutCardPaymentMethodOptionsRequestMulticapture::from_str(s)
537                .map_err(|_| miniserde::Error)?,
538        );
539        Ok(())
540    }
541}
542
543stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsRequestMulticapture);
544#[cfg(feature = "deserialize")]
545impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsRequestMulticapture {
546    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
547        use std::str::FromStr;
548        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
549        Self::from_str(&s).map_err(|_| {
550            serde::de::Error::custom(
551                "Unknown value for CheckoutCardPaymentMethodOptionsRequestMulticapture",
552            )
553        })
554    }
555}
556/// Request ability to [overcapture](/payments/overcapture) for this CheckoutSession.
557#[derive(Copy, Clone, Eq, PartialEq)]
558pub enum CheckoutCardPaymentMethodOptionsRequestOvercapture {
559    IfAvailable,
560    Never,
561}
562impl CheckoutCardPaymentMethodOptionsRequestOvercapture {
563    pub fn as_str(self) -> &'static str {
564        use CheckoutCardPaymentMethodOptionsRequestOvercapture::*;
565        match self {
566            IfAvailable => "if_available",
567            Never => "never",
568        }
569    }
570}
571
572impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestOvercapture {
573    type Err = stripe_types::StripeParseError;
574    fn from_str(s: &str) -> Result<Self, Self::Err> {
575        use CheckoutCardPaymentMethodOptionsRequestOvercapture::*;
576        match s {
577            "if_available" => Ok(IfAvailable),
578            "never" => Ok(Never),
579            _ => Err(stripe_types::StripeParseError),
580        }
581    }
582}
583impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestOvercapture {
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 CheckoutCardPaymentMethodOptionsRequestOvercapture {
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 CheckoutCardPaymentMethodOptionsRequestOvercapture {
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 CheckoutCardPaymentMethodOptionsRequestOvercapture {
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<CheckoutCardPaymentMethodOptionsRequestOvercapture> {
610    fn string(&mut self, s: &str) -> miniserde::Result<()> {
611        use std::str::FromStr;
612        self.out = Some(
613            CheckoutCardPaymentMethodOptionsRequestOvercapture::from_str(s)
614                .map_err(|_| miniserde::Error)?,
615        );
616        Ok(())
617    }
618}
619
620stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsRequestOvercapture);
621#[cfg(feature = "deserialize")]
622impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsRequestOvercapture {
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 CheckoutCardPaymentMethodOptionsRequestOvercapture",
629            )
630        })
631    }
632}
633/// 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).
634/// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option.
635/// If not provided, this value defaults to `automatic`.
636/// 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.
637#[derive(Copy, Clone, Eq, PartialEq)]
638pub enum CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
639    Any,
640    Automatic,
641    Challenge,
642}
643impl CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
644    pub fn as_str(self) -> &'static str {
645        use CheckoutCardPaymentMethodOptionsRequestThreeDSecure::*;
646        match self {
647            Any => "any",
648            Automatic => "automatic",
649            Challenge => "challenge",
650        }
651    }
652}
653
654impl std::str::FromStr for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
655    type Err = stripe_types::StripeParseError;
656    fn from_str(s: &str) -> Result<Self, Self::Err> {
657        use CheckoutCardPaymentMethodOptionsRequestThreeDSecure::*;
658        match s {
659            "any" => Ok(Any),
660            "automatic" => Ok(Automatic),
661            "challenge" => Ok(Challenge),
662            _ => Err(stripe_types::StripeParseError),
663        }
664    }
665}
666impl std::fmt::Display for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
667    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
668        f.write_str(self.as_str())
669    }
670}
671
672impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
673    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
674        f.write_str(self.as_str())
675    }
676}
677#[cfg(feature = "serialize")]
678impl serde::Serialize for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
679    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
680    where
681        S: serde::Serializer,
682    {
683        serializer.serialize_str(self.as_str())
684    }
685}
686impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
687    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
688        crate::Place::new(out)
689    }
690}
691
692impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsRequestThreeDSecure> {
693    fn string(&mut self, s: &str) -> miniserde::Result<()> {
694        use std::str::FromStr;
695        self.out = Some(
696            CheckoutCardPaymentMethodOptionsRequestThreeDSecure::from_str(s)
697                .map_err(|_| miniserde::Error)?,
698        );
699        Ok(())
700    }
701}
702
703stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsRequestThreeDSecure);
704#[cfg(feature = "deserialize")]
705impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsRequestThreeDSecure {
706    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
707        use std::str::FromStr;
708        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
709        Self::from_str(&s).map_err(|_| {
710            serde::de::Error::custom(
711                "Unknown value for CheckoutCardPaymentMethodOptionsRequestThreeDSecure",
712            )
713        })
714    }
715}
716/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
717///
718/// 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.
719/// 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.
720///
721/// 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.
722///
723/// 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).
724#[derive(Copy, Clone, Eq, PartialEq)]
725pub enum CheckoutCardPaymentMethodOptionsSetupFutureUsage {
726    None,
727    OffSession,
728    OnSession,
729}
730impl CheckoutCardPaymentMethodOptionsSetupFutureUsage {
731    pub fn as_str(self) -> &'static str {
732        use CheckoutCardPaymentMethodOptionsSetupFutureUsage::*;
733        match self {
734            None => "none",
735            OffSession => "off_session",
736            OnSession => "on_session",
737        }
738    }
739}
740
741impl std::str::FromStr for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
742    type Err = stripe_types::StripeParseError;
743    fn from_str(s: &str) -> Result<Self, Self::Err> {
744        use CheckoutCardPaymentMethodOptionsSetupFutureUsage::*;
745        match s {
746            "none" => Ok(None),
747            "off_session" => Ok(OffSession),
748            "on_session" => Ok(OnSession),
749            _ => Err(stripe_types::StripeParseError),
750        }
751    }
752}
753impl std::fmt::Display for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
754    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
755        f.write_str(self.as_str())
756    }
757}
758
759impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
760    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
761        f.write_str(self.as_str())
762    }
763}
764#[cfg(feature = "serialize")]
765impl serde::Serialize for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
766    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
767    where
768        S: serde::Serializer,
769    {
770        serializer.serialize_str(self.as_str())
771    }
772}
773impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
774    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
775        crate::Place::new(out)
776    }
777}
778
779impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsSetupFutureUsage> {
780    fn string(&mut self, s: &str) -> miniserde::Result<()> {
781        use std::str::FromStr;
782        self.out = Some(
783            CheckoutCardPaymentMethodOptionsSetupFutureUsage::from_str(s)
784                .map_err(|_| miniserde::Error)?,
785        );
786        Ok(())
787    }
788}
789
790stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsSetupFutureUsage);
791#[cfg(feature = "deserialize")]
792impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsSetupFutureUsage {
793    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
794        use std::str::FromStr;
795        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
796        Self::from_str(&s).map_err(|_| {
797            serde::de::Error::custom(
798                "Unknown value for CheckoutCardPaymentMethodOptionsSetupFutureUsage",
799            )
800        })
801    }
802}