stripe_shared/
payment_intent_payment_method_options_card.rs

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