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