stripe_shared/
payment_intent_payment_method_options_us_bank_account.rs

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