stripe_shared/
payment_method_options_twint.rs

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