stripe_shared/
checkout_acss_debit_payment_method_options.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct CheckoutAcssDebitPaymentMethodOptions {
5    /// Currency supported by the bank account. Returned when the Session is in `setup` mode.
6    pub currency: Option<CheckoutAcssDebitPaymentMethodOptionsCurrency>,
7    pub mandate_options: Option<stripe_shared::CheckoutAcssDebitMandateOptions>,
8    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
9    ///
10    /// 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.
11    /// 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.
12    ///
13    /// 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.
14    ///
15    /// 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).
16    pub setup_future_usage: Option<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>,
17    /// Controls when Stripe will attempt to debit the funds from the customer's account.
18    /// The date must be a string in YYYY-MM-DD format.
19    /// The date must be in the future and between 3 and 15 calendar days from now.
20    pub target_date: Option<String>,
21    /// Bank account verification method.
22    pub verification_method: Option<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>,
23}
24#[doc(hidden)]
25pub struct CheckoutAcssDebitPaymentMethodOptionsBuilder {
26    currency: Option<Option<CheckoutAcssDebitPaymentMethodOptionsCurrency>>,
27    mandate_options: Option<Option<stripe_shared::CheckoutAcssDebitMandateOptions>>,
28    setup_future_usage: Option<Option<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>>,
29    target_date: Option<Option<String>>,
30    verification_method: Option<Option<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>>,
31}
32
33#[allow(
34    unused_variables,
35    irrefutable_let_patterns,
36    clippy::let_unit_value,
37    clippy::match_single_binding,
38    clippy::single_match
39)]
40const _: () = {
41    use miniserde::de::{Map, Visitor};
42    use miniserde::json::Value;
43    use miniserde::{make_place, Deserialize, Result};
44    use stripe_types::miniserde_helpers::FromValueOpt;
45    use stripe_types::{MapBuilder, ObjectDeser};
46
47    make_place!(Place);
48
49    impl Deserialize for CheckoutAcssDebitPaymentMethodOptions {
50        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
51            Place::new(out)
52        }
53    }
54
55    struct Builder<'a> {
56        out: &'a mut Option<CheckoutAcssDebitPaymentMethodOptions>,
57        builder: CheckoutAcssDebitPaymentMethodOptionsBuilder,
58    }
59
60    impl Visitor for Place<CheckoutAcssDebitPaymentMethodOptions> {
61        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
62            Ok(Box::new(Builder {
63                out: &mut self.out,
64                builder: CheckoutAcssDebitPaymentMethodOptionsBuilder::deser_default(),
65            }))
66        }
67    }
68
69    impl MapBuilder for CheckoutAcssDebitPaymentMethodOptionsBuilder {
70        type Out = CheckoutAcssDebitPaymentMethodOptions;
71        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72            Ok(match k {
73                "currency" => Deserialize::begin(&mut self.currency),
74                "mandate_options" => Deserialize::begin(&mut self.mandate_options),
75                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
76                "target_date" => Deserialize::begin(&mut self.target_date),
77                "verification_method" => Deserialize::begin(&mut self.verification_method),
78
79                _ => <dyn Visitor>::ignore(),
80            })
81        }
82
83        fn deser_default() -> Self {
84            Self {
85                currency: Deserialize::default(),
86                mandate_options: Deserialize::default(),
87                setup_future_usage: Deserialize::default(),
88                target_date: Deserialize::default(),
89                verification_method: Deserialize::default(),
90            }
91        }
92
93        fn take_out(&mut self) -> Option<Self::Out> {
94            let (
95                Some(currency),
96                Some(mandate_options),
97                Some(setup_future_usage),
98                Some(target_date),
99                Some(verification_method),
100            ) = (
101                self.currency,
102                self.mandate_options.take(),
103                self.setup_future_usage,
104                self.target_date.take(),
105                self.verification_method,
106            )
107            else {
108                return None;
109            };
110            Some(Self::Out {
111                currency,
112                mandate_options,
113                setup_future_usage,
114                target_date,
115                verification_method,
116            })
117        }
118    }
119
120    impl<'a> Map for Builder<'a> {
121        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
122            self.builder.key(k)
123        }
124
125        fn finish(&mut self) -> Result<()> {
126            *self.out = self.builder.take_out();
127            Ok(())
128        }
129    }
130
131    impl ObjectDeser for CheckoutAcssDebitPaymentMethodOptions {
132        type Builder = CheckoutAcssDebitPaymentMethodOptionsBuilder;
133    }
134
135    impl FromValueOpt for CheckoutAcssDebitPaymentMethodOptions {
136        fn from_value(v: Value) -> Option<Self> {
137            let Value::Object(obj) = v else {
138                return None;
139            };
140            let mut b = CheckoutAcssDebitPaymentMethodOptionsBuilder::deser_default();
141            for (k, v) in obj {
142                match k.as_str() {
143                    "currency" => b.currency = FromValueOpt::from_value(v),
144                    "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
145                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
146                    "target_date" => b.target_date = FromValueOpt::from_value(v),
147                    "verification_method" => b.verification_method = FromValueOpt::from_value(v),
148
149                    _ => {}
150                }
151            }
152            b.take_out()
153        }
154    }
155};
156/// Currency supported by the bank account. Returned when the Session is in `setup` mode.
157#[derive(Copy, Clone, Eq, PartialEq)]
158pub enum CheckoutAcssDebitPaymentMethodOptionsCurrency {
159    Cad,
160    Usd,
161}
162impl CheckoutAcssDebitPaymentMethodOptionsCurrency {
163    pub fn as_str(self) -> &'static str {
164        use CheckoutAcssDebitPaymentMethodOptionsCurrency::*;
165        match self {
166            Cad => "cad",
167            Usd => "usd",
168        }
169    }
170}
171
172impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsCurrency {
173    type Err = stripe_types::StripeParseError;
174    fn from_str(s: &str) -> Result<Self, Self::Err> {
175        use CheckoutAcssDebitPaymentMethodOptionsCurrency::*;
176        match s {
177            "cad" => Ok(Cad),
178            "usd" => Ok(Usd),
179            _ => Err(stripe_types::StripeParseError),
180        }
181    }
182}
183impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsCurrency {
184    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
185        f.write_str(self.as_str())
186    }
187}
188
189impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsCurrency {
190    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
191        f.write_str(self.as_str())
192    }
193}
194#[cfg(feature = "serialize")]
195impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsCurrency {
196    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
197    where
198        S: serde::Serializer,
199    {
200        serializer.serialize_str(self.as_str())
201    }
202}
203impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsCurrency {
204    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
205        crate::Place::new(out)
206    }
207}
208
209impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitPaymentMethodOptionsCurrency> {
210    fn string(&mut self, s: &str) -> miniserde::Result<()> {
211        use std::str::FromStr;
212        self.out = Some(
213            CheckoutAcssDebitPaymentMethodOptionsCurrency::from_str(s)
214                .map_err(|_| miniserde::Error)?,
215        );
216        Ok(())
217    }
218}
219
220stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsCurrency);
221#[cfg(feature = "deserialize")]
222impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsCurrency {
223    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
224        use std::str::FromStr;
225        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
226        Self::from_str(&s).map_err(|_| {
227            serde::de::Error::custom(
228                "Unknown value for CheckoutAcssDebitPaymentMethodOptionsCurrency",
229            )
230        })
231    }
232}
233/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
234///
235/// 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.
236/// 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.
237///
238/// 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.
239///
240/// 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).
241#[derive(Copy, Clone, Eq, PartialEq)]
242pub enum CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
243    None,
244    OffSession,
245    OnSession,
246}
247impl CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
248    pub fn as_str(self) -> &'static str {
249        use CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::*;
250        match self {
251            None => "none",
252            OffSession => "off_session",
253            OnSession => "on_session",
254        }
255    }
256}
257
258impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
259    type Err = stripe_types::StripeParseError;
260    fn from_str(s: &str) -> Result<Self, Self::Err> {
261        use CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::*;
262        match s {
263            "none" => Ok(None),
264            "off_session" => Ok(OffSession),
265            "on_session" => Ok(OnSession),
266            _ => Err(stripe_types::StripeParseError),
267        }
268    }
269}
270impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
271    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
272        f.write_str(self.as_str())
273    }
274}
275
276impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
277    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
278        f.write_str(self.as_str())
279    }
280}
281#[cfg(feature = "serialize")]
282impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
283    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
284    where
285        S: serde::Serializer,
286    {
287        serializer.serialize_str(self.as_str())
288    }
289}
290impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
291    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
292        crate::Place::new(out)
293    }
294}
295
296impl miniserde::de::Visitor
297    for crate::Place<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>
298{
299    fn string(&mut self, s: &str) -> miniserde::Result<()> {
300        use std::str::FromStr;
301        self.out = Some(
302            CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::from_str(s)
303                .map_err(|_| miniserde::Error)?,
304        );
305        Ok(())
306    }
307}
308
309stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage);
310#[cfg(feature = "deserialize")]
311impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage {
312    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
313        use std::str::FromStr;
314        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
315        Self::from_str(&s).map_err(|_| {
316            serde::de::Error::custom(
317                "Unknown value for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage",
318            )
319        })
320    }
321}
322/// Bank account verification method.
323#[derive(Copy, Clone, Eq, PartialEq)]
324pub enum CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
325    Automatic,
326    Instant,
327    Microdeposits,
328}
329impl CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
330    pub fn as_str(self) -> &'static str {
331        use CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::*;
332        match self {
333            Automatic => "automatic",
334            Instant => "instant",
335            Microdeposits => "microdeposits",
336        }
337    }
338}
339
340impl std::str::FromStr for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
341    type Err = stripe_types::StripeParseError;
342    fn from_str(s: &str) -> Result<Self, Self::Err> {
343        use CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::*;
344        match s {
345            "automatic" => Ok(Automatic),
346            "instant" => Ok(Instant),
347            "microdeposits" => Ok(Microdeposits),
348            _ => Err(stripe_types::StripeParseError),
349        }
350    }
351}
352impl std::fmt::Display for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
353    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
354        f.write_str(self.as_str())
355    }
356}
357
358impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
359    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
360        f.write_str(self.as_str())
361    }
362}
363#[cfg(feature = "serialize")]
364impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
365    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
366    where
367        S: serde::Serializer,
368    {
369        serializer.serialize_str(self.as_str())
370    }
371}
372impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
373    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
374        crate::Place::new(out)
375    }
376}
377
378impl miniserde::de::Visitor
379    for crate::Place<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>
380{
381    fn string(&mut self, s: &str) -> miniserde::Result<()> {
382        use std::str::FromStr;
383        self.out = Some(
384            CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::from_str(s)
385                .map_err(|_| miniserde::Error)?,
386        );
387        Ok(())
388    }
389}
390
391stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsVerificationMethod);
392#[cfg(feature = "deserialize")]
393impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod {
394    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
395        use std::str::FromStr;
396        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
397        Self::from_str(&s).map_err(|_| {
398            serde::de::Error::custom(
399                "Unknown value for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod",
400            )
401        })
402    }
403}