stripe_shared/
payment_intent_payment_method_options_eps.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentPaymentMethodOptionsEps {
5    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
6    ///
7    /// 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.
8    /// 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.
9    ///
10    /// 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.
11    ///
12    /// 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).
13    pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage>,
14}
15#[doc(hidden)]
16pub struct PaymentIntentPaymentMethodOptionsEpsBuilder {
17    setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage>>,
18}
19
20#[allow(
21    unused_variables,
22    irrefutable_let_patterns,
23    clippy::let_unit_value,
24    clippy::match_single_binding,
25    clippy::single_match
26)]
27const _: () = {
28    use miniserde::de::{Map, Visitor};
29    use miniserde::json::Value;
30    use miniserde::{Deserialize, Result, make_place};
31    use stripe_types::miniserde_helpers::FromValueOpt;
32    use stripe_types::{MapBuilder, ObjectDeser};
33
34    make_place!(Place);
35
36    impl Deserialize for PaymentIntentPaymentMethodOptionsEps {
37        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
38            Place::new(out)
39        }
40    }
41
42    struct Builder<'a> {
43        out: &'a mut Option<PaymentIntentPaymentMethodOptionsEps>,
44        builder: PaymentIntentPaymentMethodOptionsEpsBuilder,
45    }
46
47    impl Visitor for Place<PaymentIntentPaymentMethodOptionsEps> {
48        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
49            Ok(Box::new(Builder {
50                out: &mut self.out,
51                builder: PaymentIntentPaymentMethodOptionsEpsBuilder::deser_default(),
52            }))
53        }
54    }
55
56    impl MapBuilder for PaymentIntentPaymentMethodOptionsEpsBuilder {
57        type Out = PaymentIntentPaymentMethodOptionsEps;
58        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
59            Ok(match k {
60                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
61                _ => <dyn Visitor>::ignore(),
62            })
63        }
64
65        fn deser_default() -> Self {
66            Self { setup_future_usage: Deserialize::default() }
67        }
68
69        fn take_out(&mut self) -> Option<Self::Out> {
70            let (Some(setup_future_usage),) = (self.setup_future_usage,) else {
71                return None;
72            };
73            Some(Self::Out { setup_future_usage })
74        }
75    }
76
77    impl Map for Builder<'_> {
78        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
79            self.builder.key(k)
80        }
81
82        fn finish(&mut self) -> Result<()> {
83            *self.out = self.builder.take_out();
84            Ok(())
85        }
86    }
87
88    impl ObjectDeser for PaymentIntentPaymentMethodOptionsEps {
89        type Builder = PaymentIntentPaymentMethodOptionsEpsBuilder;
90    }
91
92    impl FromValueOpt for PaymentIntentPaymentMethodOptionsEps {
93        fn from_value(v: Value) -> Option<Self> {
94            let Value::Object(obj) = v else {
95                return None;
96            };
97            let mut b = PaymentIntentPaymentMethodOptionsEpsBuilder::deser_default();
98            for (k, v) in obj {
99                match k.as_str() {
100                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
101                    _ => {}
102                }
103            }
104            b.take_out()
105        }
106    }
107};
108/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
109///
110/// 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.
111/// 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.
112///
113/// 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.
114///
115/// 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).
116#[derive(Copy, Clone, Eq, PartialEq)]
117pub enum PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage {
118    None,
119}
120impl PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage {
121    pub fn as_str(self) -> &'static str {
122        use PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage::*;
123        match self {
124            None => "none",
125        }
126    }
127}
128
129impl std::str::FromStr for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage {
130    type Err = stripe_types::StripeParseError;
131    fn from_str(s: &str) -> Result<Self, Self::Err> {
132        use PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage::*;
133        match s {
134            "none" => Ok(None),
135            _ => Err(stripe_types::StripeParseError),
136        }
137    }
138}
139impl std::fmt::Display for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage {
140    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
141        f.write_str(self.as_str())
142    }
143}
144
145impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage {
146    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
147        f.write_str(self.as_str())
148    }
149}
150#[cfg(feature = "serialize")]
151impl serde::Serialize for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage {
152    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
153    where
154        S: serde::Serializer,
155    {
156        serializer.serialize_str(self.as_str())
157    }
158}
159impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage {
160    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
161        crate::Place::new(out)
162    }
163}
164
165impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage> {
166    fn string(&mut self, s: &str) -> miniserde::Result<()> {
167        use std::str::FromStr;
168        self.out = Some(
169            PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage::from_str(s)
170                .map_err(|_| miniserde::Error)?,
171        );
172        Ok(())
173    }
174}
175
176stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage);
177#[cfg(feature = "deserialize")]
178impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage {
179    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
180        use std::str::FromStr;
181        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
182        Self::from_str(&s).map_err(|_| {
183            serde::de::Error::custom(
184                "Unknown value for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage",
185            )
186        })
187    }
188}