Skip to main content

stripe_shared/
checkout_card_payment_method_options.rs

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