Skip to main content

stripe_shared/
payment_intent_payment_method_options_card.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 PaymentIntentPaymentMethodOptionsCard {
6    /// Controls when the funds will be captured from the customer's account.
7    pub capture_method: Option<PaymentIntentPaymentMethodOptionsCardCaptureMethod>,
8    /// Installment details for this payment.
9    ///
10    /// For more information, see the [installments integration guide](https://docs.stripe.com/payments/installments).
11    pub installments: Option<stripe_shared::PaymentMethodOptionsCardInstallments>,
12    /// Configuration options for setting up an eMandate for cards issued in India.
13    pub mandate_options: Option<stripe_shared::PaymentMethodOptionsCardMandateOptions>,
14    /// Selected network to process this payment intent on.
15    /// Depends on the available networks of the card attached to the payment intent.
16    /// Can be only set confirm-time.
17    pub network: Option<PaymentIntentPaymentMethodOptionsCardNetwork>,
18    /// Request ability to [capture beyond the standard authorization validity window](https://docs.stripe.com/payments/extended-authorization) for this PaymentIntent.
19    pub request_extended_authorization:
20        Option<PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>,
21    /// Request ability to [increment the authorization](https://docs.stripe.com/payments/incremental-authorization) for this PaymentIntent.
22    pub request_incremental_authorization:
23        Option<PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>,
24    /// Request ability to make [multiple captures](https://docs.stripe.com/payments/multicapture) for this PaymentIntent.
25    pub request_multicapture: Option<PaymentIntentPaymentMethodOptionsCardRequestMulticapture>,
26    /// Request ability to [overcapture](https://docs.stripe.com/payments/overcapture) for this PaymentIntent.
27    pub request_overcapture: Option<PaymentIntentPaymentMethodOptionsCardRequestOvercapture>,
28    /// 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).
29    /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option.
30    /// If not provided, this value defaults to `automatic`.
31    /// 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.
32    pub request_three_d_secure: Option<PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>,
33    /// When enabled, using a card that is attached to a customer will require the CVC to be provided again (i.e.
34    /// using the cvc_token parameter).
35    pub require_cvc_recollection: Option<bool>,
36    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
37    ///
38    /// 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.
39    /// 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.
40    ///
41    /// 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.
42    ///
43    /// 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).
44    pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsCardSetupFutureUsage>,
45    /// Provides information about a card payment that customers see on their statements.
46    /// Concatenated with the Kana prefix (shortened Kana descriptor) or Kana statement descriptor that’s set on the account to form the complete statement descriptor.
47    /// Maximum 22 characters.
48    /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 22 characters.
49    pub statement_descriptor_suffix_kana: Option<String>,
50    /// Provides information about a card payment that customers see on their statements.
51    /// Concatenated with the Kanji prefix (shortened Kanji descriptor) or Kanji statement descriptor that’s set on the account to form the complete statement descriptor.
52    /// Maximum 17 characters.
53    /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 17 characters.
54    pub statement_descriptor_suffix_kanji: Option<String>,
55}
56#[cfg(feature = "redact-generated-debug")]
57impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCard {
58    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
59        f.debug_struct("PaymentIntentPaymentMethodOptionsCard").finish_non_exhaustive()
60    }
61}
62#[doc(hidden)]
63pub struct PaymentIntentPaymentMethodOptionsCardBuilder {
64    capture_method: Option<Option<PaymentIntentPaymentMethodOptionsCardCaptureMethod>>,
65    installments: Option<Option<stripe_shared::PaymentMethodOptionsCardInstallments>>,
66    mandate_options: Option<Option<stripe_shared::PaymentMethodOptionsCardMandateOptions>>,
67    network: Option<Option<PaymentIntentPaymentMethodOptionsCardNetwork>>,
68    request_extended_authorization:
69        Option<Option<PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>>,
70    request_incremental_authorization:
71        Option<Option<PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>>,
72    request_multicapture: Option<Option<PaymentIntentPaymentMethodOptionsCardRequestMulticapture>>,
73    request_overcapture: Option<Option<PaymentIntentPaymentMethodOptionsCardRequestOvercapture>>,
74    request_three_d_secure:
75        Option<Option<PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>>,
76    require_cvc_recollection: Option<Option<bool>>,
77    setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsCardSetupFutureUsage>>,
78    statement_descriptor_suffix_kana: Option<Option<String>>,
79    statement_descriptor_suffix_kanji: Option<Option<String>>,
80}
81
82#[allow(
83    unused_variables,
84    irrefutable_let_patterns,
85    clippy::let_unit_value,
86    clippy::match_single_binding,
87    clippy::single_match
88)]
89const _: () = {
90    use miniserde::de::{Map, Visitor};
91    use miniserde::json::Value;
92    use miniserde::{Deserialize, Result, make_place};
93    use stripe_types::miniserde_helpers::FromValueOpt;
94    use stripe_types::{MapBuilder, ObjectDeser};
95
96    make_place!(Place);
97
98    impl Deserialize for PaymentIntentPaymentMethodOptionsCard {
99        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
100            Place::new(out)
101        }
102    }
103
104    struct Builder<'a> {
105        out: &'a mut Option<PaymentIntentPaymentMethodOptionsCard>,
106        builder: PaymentIntentPaymentMethodOptionsCardBuilder,
107    }
108
109    impl Visitor for Place<PaymentIntentPaymentMethodOptionsCard> {
110        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
111            Ok(Box::new(Builder {
112                out: &mut self.out,
113                builder: PaymentIntentPaymentMethodOptionsCardBuilder::deser_default(),
114            }))
115        }
116    }
117
118    impl MapBuilder for PaymentIntentPaymentMethodOptionsCardBuilder {
119        type Out = PaymentIntentPaymentMethodOptionsCard;
120        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
121            Ok(match k {
122                "capture_method" => Deserialize::begin(&mut self.capture_method),
123                "installments" => Deserialize::begin(&mut self.installments),
124                "mandate_options" => Deserialize::begin(&mut self.mandate_options),
125                "network" => Deserialize::begin(&mut self.network),
126                "request_extended_authorization" => {
127                    Deserialize::begin(&mut self.request_extended_authorization)
128                }
129                "request_incremental_authorization" => {
130                    Deserialize::begin(&mut self.request_incremental_authorization)
131                }
132                "request_multicapture" => Deserialize::begin(&mut self.request_multicapture),
133                "request_overcapture" => Deserialize::begin(&mut self.request_overcapture),
134                "request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure),
135                "require_cvc_recollection" => {
136                    Deserialize::begin(&mut self.require_cvc_recollection)
137                }
138                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
139                "statement_descriptor_suffix_kana" => {
140                    Deserialize::begin(&mut self.statement_descriptor_suffix_kana)
141                }
142                "statement_descriptor_suffix_kanji" => {
143                    Deserialize::begin(&mut self.statement_descriptor_suffix_kanji)
144                }
145                _ => <dyn Visitor>::ignore(),
146            })
147        }
148
149        fn deser_default() -> Self {
150            Self {
151                capture_method: Deserialize::default(),
152                installments: Deserialize::default(),
153                mandate_options: Deserialize::default(),
154                network: Deserialize::default(),
155                request_extended_authorization: Deserialize::default(),
156                request_incremental_authorization: Deserialize::default(),
157                request_multicapture: Deserialize::default(),
158                request_overcapture: Deserialize::default(),
159                request_three_d_secure: Deserialize::default(),
160                require_cvc_recollection: Deserialize::default(),
161                setup_future_usage: Deserialize::default(),
162                statement_descriptor_suffix_kana: Deserialize::default(),
163                statement_descriptor_suffix_kanji: Deserialize::default(),
164            }
165        }
166
167        fn take_out(&mut self) -> Option<Self::Out> {
168            let (
169                Some(capture_method),
170                Some(installments),
171                Some(mandate_options),
172                Some(network),
173                Some(request_extended_authorization),
174                Some(request_incremental_authorization),
175                Some(request_multicapture),
176                Some(request_overcapture),
177                Some(request_three_d_secure),
178                Some(require_cvc_recollection),
179                Some(setup_future_usage),
180                Some(statement_descriptor_suffix_kana),
181                Some(statement_descriptor_suffix_kanji),
182            ) = (
183                self.capture_method.take(),
184                self.installments.take(),
185                self.mandate_options.take(),
186                self.network.take(),
187                self.request_extended_authorization.take(),
188                self.request_incremental_authorization.take(),
189                self.request_multicapture.take(),
190                self.request_overcapture.take(),
191                self.request_three_d_secure.take(),
192                self.require_cvc_recollection,
193                self.setup_future_usage.take(),
194                self.statement_descriptor_suffix_kana.take(),
195                self.statement_descriptor_suffix_kanji.take(),
196            )
197            else {
198                return None;
199            };
200            Some(Self::Out {
201                capture_method,
202                installments,
203                mandate_options,
204                network,
205                request_extended_authorization,
206                request_incremental_authorization,
207                request_multicapture,
208                request_overcapture,
209                request_three_d_secure,
210                require_cvc_recollection,
211                setup_future_usage,
212                statement_descriptor_suffix_kana,
213                statement_descriptor_suffix_kanji,
214            })
215        }
216    }
217
218    impl Map for Builder<'_> {
219        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
220            self.builder.key(k)
221        }
222
223        fn finish(&mut self) -> Result<()> {
224            *self.out = self.builder.take_out();
225            Ok(())
226        }
227    }
228
229    impl ObjectDeser for PaymentIntentPaymentMethodOptionsCard {
230        type Builder = PaymentIntentPaymentMethodOptionsCardBuilder;
231    }
232
233    impl FromValueOpt for PaymentIntentPaymentMethodOptionsCard {
234        fn from_value(v: Value) -> Option<Self> {
235            let Value::Object(obj) = v else {
236                return None;
237            };
238            let mut b = PaymentIntentPaymentMethodOptionsCardBuilder::deser_default();
239            for (k, v) in obj {
240                match k.as_str() {
241                    "capture_method" => b.capture_method = FromValueOpt::from_value(v),
242                    "installments" => b.installments = FromValueOpt::from_value(v),
243                    "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
244                    "network" => b.network = FromValueOpt::from_value(v),
245                    "request_extended_authorization" => {
246                        b.request_extended_authorization = FromValueOpt::from_value(v)
247                    }
248                    "request_incremental_authorization" => {
249                        b.request_incremental_authorization = FromValueOpt::from_value(v)
250                    }
251                    "request_multicapture" => b.request_multicapture = FromValueOpt::from_value(v),
252                    "request_overcapture" => b.request_overcapture = FromValueOpt::from_value(v),
253                    "request_three_d_secure" => {
254                        b.request_three_d_secure = FromValueOpt::from_value(v)
255                    }
256                    "require_cvc_recollection" => {
257                        b.require_cvc_recollection = FromValueOpt::from_value(v)
258                    }
259                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
260                    "statement_descriptor_suffix_kana" => {
261                        b.statement_descriptor_suffix_kana = FromValueOpt::from_value(v)
262                    }
263                    "statement_descriptor_suffix_kanji" => {
264                        b.statement_descriptor_suffix_kanji = FromValueOpt::from_value(v)
265                    }
266                    _ => {}
267                }
268            }
269            b.take_out()
270        }
271    }
272};
273/// Controls when the funds will be captured from the customer's account.
274#[derive(Clone, Eq, PartialEq)]
275#[non_exhaustive]
276pub enum PaymentIntentPaymentMethodOptionsCardCaptureMethod {
277    Manual,
278    /// An unrecognized value from Stripe. Should not be used as a request parameter.
279    Unknown(String),
280}
281impl PaymentIntentPaymentMethodOptionsCardCaptureMethod {
282    pub fn as_str(&self) -> &str {
283        use PaymentIntentPaymentMethodOptionsCardCaptureMethod::*;
284        match self {
285            Manual => "manual",
286            Unknown(v) => v,
287        }
288    }
289}
290
291impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardCaptureMethod {
292    type Err = std::convert::Infallible;
293    fn from_str(s: &str) -> Result<Self, Self::Err> {
294        use PaymentIntentPaymentMethodOptionsCardCaptureMethod::*;
295        match s {
296            "manual" => Ok(Manual),
297            v => {
298                tracing::warn!(
299                    "Unknown value '{}' for enum '{}'",
300                    v,
301                    "PaymentIntentPaymentMethodOptionsCardCaptureMethod"
302                );
303                Ok(Unknown(v.to_owned()))
304            }
305        }
306    }
307}
308impl std::fmt::Display for PaymentIntentPaymentMethodOptionsCardCaptureMethod {
309    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
310        f.write_str(self.as_str())
311    }
312}
313
314#[cfg(not(feature = "redact-generated-debug"))]
315impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardCaptureMethod {
316    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
317        f.write_str(self.as_str())
318    }
319}
320#[cfg(feature = "redact-generated-debug")]
321impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardCaptureMethod {
322    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
323        f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsCardCaptureMethod))
324            .finish_non_exhaustive()
325    }
326}
327#[cfg(feature = "serialize")]
328impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardCaptureMethod {
329    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
330    where
331        S: serde::Serializer,
332    {
333        serializer.serialize_str(self.as_str())
334    }
335}
336impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardCaptureMethod {
337    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
338        crate::Place::new(out)
339    }
340}
341
342impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardCaptureMethod> {
343    fn string(&mut self, s: &str) -> miniserde::Result<()> {
344        use std::str::FromStr;
345        self.out = Some(
346            PaymentIntentPaymentMethodOptionsCardCaptureMethod::from_str(s).expect("infallible"),
347        );
348        Ok(())
349    }
350}
351
352stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardCaptureMethod);
353#[cfg(feature = "deserialize")]
354impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardCaptureMethod {
355    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
356        use std::str::FromStr;
357        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
358        Ok(Self::from_str(&s).expect("infallible"))
359    }
360}
361/// Selected network to process this payment intent on.
362/// Depends on the available networks of the card attached to the payment intent.
363/// Can be only set confirm-time.
364#[derive(Clone, Eq, PartialEq)]
365#[non_exhaustive]
366pub enum PaymentIntentPaymentMethodOptionsCardNetwork {
367    Amex,
368    CartesBancaires,
369    Diners,
370    Discover,
371    EftposAu,
372    Girocard,
373    Interac,
374    Jcb,
375    Link,
376    Mastercard,
377    Unionpay,
378    Unknown,
379    Visa,
380    /// An unrecognized value from Stripe. Should not be used as a request parameter.
381    /// This variant is prefixed with an underscore to avoid conflicts with Stripe's 'Unknown' variant.
382    _Unknown(String),
383}
384impl PaymentIntentPaymentMethodOptionsCardNetwork {
385    pub fn as_str(&self) -> &str {
386        use PaymentIntentPaymentMethodOptionsCardNetwork::*;
387        match self {
388            Amex => "amex",
389            CartesBancaires => "cartes_bancaires",
390            Diners => "diners",
391            Discover => "discover",
392            EftposAu => "eftpos_au",
393            Girocard => "girocard",
394            Interac => "interac",
395            Jcb => "jcb",
396            Link => "link",
397            Mastercard => "mastercard",
398            Unionpay => "unionpay",
399            Unknown => "unknown",
400            Visa => "visa",
401            _Unknown(v) => v,
402        }
403    }
404}
405
406impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardNetwork {
407    type Err = std::convert::Infallible;
408    fn from_str(s: &str) -> Result<Self, Self::Err> {
409        use PaymentIntentPaymentMethodOptionsCardNetwork::*;
410        match s {
411            "amex" => Ok(Amex),
412            "cartes_bancaires" => Ok(CartesBancaires),
413            "diners" => Ok(Diners),
414            "discover" => Ok(Discover),
415            "eftpos_au" => Ok(EftposAu),
416            "girocard" => Ok(Girocard),
417            "interac" => Ok(Interac),
418            "jcb" => Ok(Jcb),
419            "link" => Ok(Link),
420            "mastercard" => Ok(Mastercard),
421            "unionpay" => Ok(Unionpay),
422            "unknown" => Ok(Unknown),
423            "visa" => Ok(Visa),
424            v => {
425                tracing::warn!(
426                    "Unknown value '{}' for enum '{}'",
427                    v,
428                    "PaymentIntentPaymentMethodOptionsCardNetwork"
429                );
430                Ok(_Unknown(v.to_owned()))
431            }
432        }
433    }
434}
435impl std::fmt::Display for PaymentIntentPaymentMethodOptionsCardNetwork {
436    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
437        f.write_str(self.as_str())
438    }
439}
440
441#[cfg(not(feature = "redact-generated-debug"))]
442impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardNetwork {
443    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
444        f.write_str(self.as_str())
445    }
446}
447#[cfg(feature = "redact-generated-debug")]
448impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardNetwork {
449    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
450        f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsCardNetwork))
451            .finish_non_exhaustive()
452    }
453}
454#[cfg(feature = "serialize")]
455impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardNetwork {
456    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
457    where
458        S: serde::Serializer,
459    {
460        serializer.serialize_str(self.as_str())
461    }
462}
463impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardNetwork {
464    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
465        crate::Place::new(out)
466    }
467}
468
469impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardNetwork> {
470    fn string(&mut self, s: &str) -> miniserde::Result<()> {
471        use std::str::FromStr;
472        self.out =
473            Some(PaymentIntentPaymentMethodOptionsCardNetwork::from_str(s).expect("infallible"));
474        Ok(())
475    }
476}
477
478stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardNetwork);
479#[cfg(feature = "deserialize")]
480impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardNetwork {
481    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
482        use std::str::FromStr;
483        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
484        Ok(Self::from_str(&s).expect("infallible"))
485    }
486}
487/// Request ability to [capture beyond the standard authorization validity window](https://docs.stripe.com/payments/extended-authorization) for this PaymentIntent.
488#[derive(Clone, Eq, PartialEq)]
489#[non_exhaustive]
490pub enum PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization {
491    IfAvailable,
492    Never,
493    /// An unrecognized value from Stripe. Should not be used as a request parameter.
494    Unknown(String),
495}
496impl PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization {
497    pub fn as_str(&self) -> &str {
498        use PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization::*;
499        match self {
500            IfAvailable => "if_available",
501            Never => "never",
502            Unknown(v) => v,
503        }
504    }
505}
506
507impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization {
508    type Err = std::convert::Infallible;
509    fn from_str(s: &str) -> Result<Self, Self::Err> {
510        use PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization::*;
511        match s {
512            "if_available" => Ok(IfAvailable),
513            "never" => Ok(Never),
514            v => {
515                tracing::warn!(
516                    "Unknown value '{}' for enum '{}'",
517                    v,
518                    "PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization"
519                );
520                Ok(Unknown(v.to_owned()))
521            }
522        }
523    }
524}
525impl std::fmt::Display for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization {
526    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
527        f.write_str(self.as_str())
528    }
529}
530
531#[cfg(not(feature = "redact-generated-debug"))]
532impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization {
533    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
534        f.write_str(self.as_str())
535    }
536}
537#[cfg(feature = "redact-generated-debug")]
538impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization {
539    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
540        f.debug_struct(stringify!(
541            PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization
542        ))
543        .finish_non_exhaustive()
544    }
545}
546#[cfg(feature = "serialize")]
547impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization {
548    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
549    where
550        S: serde::Serializer,
551    {
552        serializer.serialize_str(self.as_str())
553    }
554}
555impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization {
556    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
557        crate::Place::new(out)
558    }
559}
560
561impl miniserde::de::Visitor
562    for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>
563{
564    fn string(&mut self, s: &str) -> miniserde::Result<()> {
565        use std::str::FromStr;
566        self.out = Some(
567            PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization::from_str(s)
568                .expect("infallible"),
569        );
570        Ok(())
571    }
572}
573
574stripe_types::impl_from_val_with_from_str!(
575    PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization
576);
577#[cfg(feature = "deserialize")]
578impl<'de> serde::Deserialize<'de>
579    for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization
580{
581    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
582        use std::str::FromStr;
583        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
584        Ok(Self::from_str(&s).expect("infallible"))
585    }
586}
587/// Request ability to [increment the authorization](https://docs.stripe.com/payments/incremental-authorization) for this PaymentIntent.
588#[derive(Clone, Eq, PartialEq)]
589#[non_exhaustive]
590pub enum PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization {
591    IfAvailable,
592    Never,
593    /// An unrecognized value from Stripe. Should not be used as a request parameter.
594    Unknown(String),
595}
596impl PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization {
597    pub fn as_str(&self) -> &str {
598        use PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization::*;
599        match self {
600            IfAvailable => "if_available",
601            Never => "never",
602            Unknown(v) => v,
603        }
604    }
605}
606
607impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization {
608    type Err = std::convert::Infallible;
609    fn from_str(s: &str) -> Result<Self, Self::Err> {
610        use PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization::*;
611        match s {
612            "if_available" => Ok(IfAvailable),
613            "never" => Ok(Never),
614            v => {
615                tracing::warn!(
616                    "Unknown value '{}' for enum '{}'",
617                    v,
618                    "PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization"
619                );
620                Ok(Unknown(v.to_owned()))
621            }
622        }
623    }
624}
625impl std::fmt::Display for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization {
626    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
627        f.write_str(self.as_str())
628    }
629}
630
631#[cfg(not(feature = "redact-generated-debug"))]
632impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization {
633    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
634        f.write_str(self.as_str())
635    }
636}
637#[cfg(feature = "redact-generated-debug")]
638impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization {
639    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
640        f.debug_struct(stringify!(
641            PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization
642        ))
643        .finish_non_exhaustive()
644    }
645}
646#[cfg(feature = "serialize")]
647impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization {
648    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
649    where
650        S: serde::Serializer,
651    {
652        serializer.serialize_str(self.as_str())
653    }
654}
655impl miniserde::Deserialize
656    for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization
657{
658    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
659        crate::Place::new(out)
660    }
661}
662
663impl miniserde::de::Visitor
664    for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>
665{
666    fn string(&mut self, s: &str) -> miniserde::Result<()> {
667        use std::str::FromStr;
668        self.out = Some(
669            PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization::from_str(s)
670                .expect("infallible"),
671        );
672        Ok(())
673    }
674}
675
676stripe_types::impl_from_val_with_from_str!(
677    PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization
678);
679#[cfg(feature = "deserialize")]
680impl<'de> serde::Deserialize<'de>
681    for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization
682{
683    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
684        use std::str::FromStr;
685        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
686        Ok(Self::from_str(&s).expect("infallible"))
687    }
688}
689/// Request ability to make [multiple captures](https://docs.stripe.com/payments/multicapture) for this PaymentIntent.
690#[derive(Clone, Eq, PartialEq)]
691#[non_exhaustive]
692pub enum PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
693    IfAvailable,
694    Never,
695    /// An unrecognized value from Stripe. Should not be used as a request parameter.
696    Unknown(String),
697}
698impl PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
699    pub fn as_str(&self) -> &str {
700        use PaymentIntentPaymentMethodOptionsCardRequestMulticapture::*;
701        match self {
702            IfAvailable => "if_available",
703            Never => "never",
704            Unknown(v) => v,
705        }
706    }
707}
708
709impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
710    type Err = std::convert::Infallible;
711    fn from_str(s: &str) -> Result<Self, Self::Err> {
712        use PaymentIntentPaymentMethodOptionsCardRequestMulticapture::*;
713        match s {
714            "if_available" => Ok(IfAvailable),
715            "never" => Ok(Never),
716            v => {
717                tracing::warn!(
718                    "Unknown value '{}' for enum '{}'",
719                    v,
720                    "PaymentIntentPaymentMethodOptionsCardRequestMulticapture"
721                );
722                Ok(Unknown(v.to_owned()))
723            }
724        }
725    }
726}
727impl std::fmt::Display for PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
728    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
729        f.write_str(self.as_str())
730    }
731}
732
733#[cfg(not(feature = "redact-generated-debug"))]
734impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
735    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
736        f.write_str(self.as_str())
737    }
738}
739#[cfg(feature = "redact-generated-debug")]
740impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
741    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
742        f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsCardRequestMulticapture))
743            .finish_non_exhaustive()
744    }
745}
746#[cfg(feature = "serialize")]
747impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
748    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
749    where
750        S: serde::Serializer,
751    {
752        serializer.serialize_str(self.as_str())
753    }
754}
755impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
756    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
757        crate::Place::new(out)
758    }
759}
760
761impl miniserde::de::Visitor
762    for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestMulticapture>
763{
764    fn string(&mut self, s: &str) -> miniserde::Result<()> {
765        use std::str::FromStr;
766        self.out = Some(
767            PaymentIntentPaymentMethodOptionsCardRequestMulticapture::from_str(s)
768                .expect("infallible"),
769        );
770        Ok(())
771    }
772}
773
774stripe_types::impl_from_val_with_from_str!(
775    PaymentIntentPaymentMethodOptionsCardRequestMulticapture
776);
777#[cfg(feature = "deserialize")]
778impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestMulticapture {
779    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
780        use std::str::FromStr;
781        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
782        Ok(Self::from_str(&s).expect("infallible"))
783    }
784}
785/// Request ability to [overcapture](https://docs.stripe.com/payments/overcapture) for this PaymentIntent.
786#[derive(Clone, Eq, PartialEq)]
787#[non_exhaustive]
788pub enum PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
789    IfAvailable,
790    Never,
791    /// An unrecognized value from Stripe. Should not be used as a request parameter.
792    Unknown(String),
793}
794impl PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
795    pub fn as_str(&self) -> &str {
796        use PaymentIntentPaymentMethodOptionsCardRequestOvercapture::*;
797        match self {
798            IfAvailable => "if_available",
799            Never => "never",
800            Unknown(v) => v,
801        }
802    }
803}
804
805impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
806    type Err = std::convert::Infallible;
807    fn from_str(s: &str) -> Result<Self, Self::Err> {
808        use PaymentIntentPaymentMethodOptionsCardRequestOvercapture::*;
809        match s {
810            "if_available" => Ok(IfAvailable),
811            "never" => Ok(Never),
812            v => {
813                tracing::warn!(
814                    "Unknown value '{}' for enum '{}'",
815                    v,
816                    "PaymentIntentPaymentMethodOptionsCardRequestOvercapture"
817                );
818                Ok(Unknown(v.to_owned()))
819            }
820        }
821    }
822}
823impl std::fmt::Display for PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
824    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
825        f.write_str(self.as_str())
826    }
827}
828
829#[cfg(not(feature = "redact-generated-debug"))]
830impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
831    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
832        f.write_str(self.as_str())
833    }
834}
835#[cfg(feature = "redact-generated-debug")]
836impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
837    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
838        f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsCardRequestOvercapture))
839            .finish_non_exhaustive()
840    }
841}
842#[cfg(feature = "serialize")]
843impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
844    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
845    where
846        S: serde::Serializer,
847    {
848        serializer.serialize_str(self.as_str())
849    }
850}
851impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
852    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
853        crate::Place::new(out)
854    }
855}
856
857impl miniserde::de::Visitor
858    for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestOvercapture>
859{
860    fn string(&mut self, s: &str) -> miniserde::Result<()> {
861        use std::str::FromStr;
862        self.out = Some(
863            PaymentIntentPaymentMethodOptionsCardRequestOvercapture::from_str(s)
864                .expect("infallible"),
865        );
866        Ok(())
867    }
868}
869
870stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardRequestOvercapture);
871#[cfg(feature = "deserialize")]
872impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestOvercapture {
873    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
874        use std::str::FromStr;
875        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
876        Ok(Self::from_str(&s).expect("infallible"))
877    }
878}
879/// 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).
880/// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option.
881/// If not provided, this value defaults to `automatic`.
882/// 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.
883#[derive(Clone, Eq, PartialEq)]
884#[non_exhaustive]
885pub enum PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
886    Any,
887    Automatic,
888    Challenge,
889    /// An unrecognized value from Stripe. Should not be used as a request parameter.
890    Unknown(String),
891}
892impl PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
893    pub fn as_str(&self) -> &str {
894        use PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure::*;
895        match self {
896            Any => "any",
897            Automatic => "automatic",
898            Challenge => "challenge",
899            Unknown(v) => v,
900        }
901    }
902}
903
904impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
905    type Err = std::convert::Infallible;
906    fn from_str(s: &str) -> Result<Self, Self::Err> {
907        use PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure::*;
908        match s {
909            "any" => Ok(Any),
910            "automatic" => Ok(Automatic),
911            "challenge" => Ok(Challenge),
912            v => {
913                tracing::warn!(
914                    "Unknown value '{}' for enum '{}'",
915                    v,
916                    "PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure"
917                );
918                Ok(Unknown(v.to_owned()))
919            }
920        }
921    }
922}
923impl std::fmt::Display for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
924    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
925        f.write_str(self.as_str())
926    }
927}
928
929#[cfg(not(feature = "redact-generated-debug"))]
930impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
931    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
932        f.write_str(self.as_str())
933    }
934}
935#[cfg(feature = "redact-generated-debug")]
936impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
937    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
938        f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure))
939            .finish_non_exhaustive()
940    }
941}
942#[cfg(feature = "serialize")]
943impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
944    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
945    where
946        S: serde::Serializer,
947    {
948        serializer.serialize_str(self.as_str())
949    }
950}
951impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
952    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
953        crate::Place::new(out)
954    }
955}
956
957impl miniserde::de::Visitor
958    for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>
959{
960    fn string(&mut self, s: &str) -> miniserde::Result<()> {
961        use std::str::FromStr;
962        self.out = Some(
963            PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure::from_str(s)
964                .expect("infallible"),
965        );
966        Ok(())
967    }
968}
969
970stripe_types::impl_from_val_with_from_str!(
971    PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure
972);
973#[cfg(feature = "deserialize")]
974impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure {
975    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
976        use std::str::FromStr;
977        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
978        Ok(Self::from_str(&s).expect("infallible"))
979    }
980}
981/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
982///
983/// 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.
984/// 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.
985///
986/// 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.
987///
988/// 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).
989#[derive(Clone, Eq, PartialEq)]
990#[non_exhaustive]
991pub enum PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
992    None,
993    OffSession,
994    OnSession,
995    /// An unrecognized value from Stripe. Should not be used as a request parameter.
996    Unknown(String),
997}
998impl PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
999    pub fn as_str(&self) -> &str {
1000        use PaymentIntentPaymentMethodOptionsCardSetupFutureUsage::*;
1001        match self {
1002            None => "none",
1003            OffSession => "off_session",
1004            OnSession => "on_session",
1005            Unknown(v) => v,
1006        }
1007    }
1008}
1009
1010impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
1011    type Err = std::convert::Infallible;
1012    fn from_str(s: &str) -> Result<Self, Self::Err> {
1013        use PaymentIntentPaymentMethodOptionsCardSetupFutureUsage::*;
1014        match s {
1015            "none" => Ok(None),
1016            "off_session" => Ok(OffSession),
1017            "on_session" => Ok(OnSession),
1018            v => {
1019                tracing::warn!(
1020                    "Unknown value '{}' for enum '{}'",
1021                    v,
1022                    "PaymentIntentPaymentMethodOptionsCardSetupFutureUsage"
1023                );
1024                Ok(Unknown(v.to_owned()))
1025            }
1026        }
1027    }
1028}
1029impl std::fmt::Display for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
1030    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1031        f.write_str(self.as_str())
1032    }
1033}
1034
1035#[cfg(not(feature = "redact-generated-debug"))]
1036impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
1037    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1038        f.write_str(self.as_str())
1039    }
1040}
1041#[cfg(feature = "redact-generated-debug")]
1042impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
1043    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1044        f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsCardSetupFutureUsage))
1045            .finish_non_exhaustive()
1046    }
1047}
1048#[cfg(feature = "serialize")]
1049impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
1050    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1051    where
1052        S: serde::Serializer,
1053    {
1054        serializer.serialize_str(self.as_str())
1055    }
1056}
1057impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
1058    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1059        crate::Place::new(out)
1060    }
1061}
1062
1063impl miniserde::de::Visitor
1064    for crate::Place<PaymentIntentPaymentMethodOptionsCardSetupFutureUsage>
1065{
1066    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1067        use std::str::FromStr;
1068        self.out = Some(
1069            PaymentIntentPaymentMethodOptionsCardSetupFutureUsage::from_str(s).expect("infallible"),
1070        );
1071        Ok(())
1072    }
1073}
1074
1075stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardSetupFutureUsage);
1076#[cfg(feature = "deserialize")]
1077impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage {
1078    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1079        use std::str::FromStr;
1080        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1081        Ok(Self::from_str(&s).expect("infallible"))
1082    }
1083}