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.take(),
97                self.target_date.take(),
98                self.verification_method.take(),
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(Clone, Eq, PartialEq)]
157#[non_exhaustive]
158pub enum CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
159    None,
160    OffSession,
161    OnSession,
162    /// An unrecognized value from Stripe. Should not be used as a request parameter.
163    Unknown(String),
164}
165impl CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
166    pub fn as_str(&self) -> &str {
167        use CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage::*;
168        match self {
169            None => "none",
170            OffSession => "off_session",
171            OnSession => "on_session",
172            Unknown(v) => v,
173        }
174    }
175}
176
177impl std::str::FromStr for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
178    type Err = std::convert::Infallible;
179    fn from_str(s: &str) -> Result<Self, Self::Err> {
180        use CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage::*;
181        match s {
182            "none" => Ok(None),
183            "off_session" => Ok(OffSession),
184            "on_session" => Ok(OnSession),
185            v => {
186                tracing::warn!(
187                    "Unknown value '{}' for enum '{}'",
188                    v,
189                    "CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage"
190                );
191                Ok(Unknown(v.to_owned()))
192            }
193        }
194    }
195}
196impl std::fmt::Display for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
197    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
198        f.write_str(self.as_str())
199    }
200}
201
202impl std::fmt::Debug for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
203    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
204        f.write_str(self.as_str())
205    }
206}
207#[cfg(feature = "serialize")]
208impl serde::Serialize for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
209    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
210    where
211        S: serde::Serializer,
212    {
213        serializer.serialize_str(self.as_str())
214    }
215}
216impl miniserde::Deserialize for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
217    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
218        crate::Place::new(out)
219    }
220}
221
222impl miniserde::de::Visitor
223    for crate::Place<CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage>
224{
225    fn string(&mut self, s: &str) -> miniserde::Result<()> {
226        use std::str::FromStr;
227        self.out = Some(
228            CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage::from_str(s)
229                .expect("infallible"),
230        );
231        Ok(())
232    }
233}
234
235stripe_types::impl_from_val_with_from_str!(
236    CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage
237);
238#[cfg(feature = "deserialize")]
239impl<'de> serde::Deserialize<'de> for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
240    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
241        use std::str::FromStr;
242        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
243        Ok(Self::from_str(&s).expect("infallible"))
244    }
245}
246/// Bank account verification method.
247#[derive(Clone, Eq, PartialEq)]
248#[non_exhaustive]
249pub enum CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
250    Automatic,
251    Instant,
252    /// An unrecognized value from Stripe. Should not be used as a request parameter.
253    Unknown(String),
254}
255impl CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
256    pub fn as_str(&self) -> &str {
257        use CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod::*;
258        match self {
259            Automatic => "automatic",
260            Instant => "instant",
261            Unknown(v) => v,
262        }
263    }
264}
265
266impl std::str::FromStr for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
267    type Err = std::convert::Infallible;
268    fn from_str(s: &str) -> Result<Self, Self::Err> {
269        use CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod::*;
270        match s {
271            "automatic" => Ok(Automatic),
272            "instant" => Ok(Instant),
273            v => {
274                tracing::warn!(
275                    "Unknown value '{}' for enum '{}'",
276                    v,
277                    "CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod"
278                );
279                Ok(Unknown(v.to_owned()))
280            }
281        }
282    }
283}
284impl std::fmt::Display for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
285    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
286        f.write_str(self.as_str())
287    }
288}
289
290impl std::fmt::Debug for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
291    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
292        f.write_str(self.as_str())
293    }
294}
295#[cfg(feature = "serialize")]
296impl serde::Serialize for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
297    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
298    where
299        S: serde::Serializer,
300    {
301        serializer.serialize_str(self.as_str())
302    }
303}
304impl miniserde::Deserialize for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
305    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
306        crate::Place::new(out)
307    }
308}
309
310impl miniserde::de::Visitor
311    for crate::Place<CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod>
312{
313    fn string(&mut self, s: &str) -> miniserde::Result<()> {
314        use std::str::FromStr;
315        self.out = Some(
316            CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod::from_str(s)
317                .expect("infallible"),
318        );
319        Ok(())
320    }
321}
322
323stripe_types::impl_from_val_with_from_str!(
324    CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod
325);
326#[cfg(feature = "deserialize")]
327impl<'de> serde::Deserialize<'de> for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
328    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
329        use std::str::FromStr;
330        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
331        Ok(Self::from_str(&s).expect("infallible"))
332    }
333}