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::{make_place, Deserialize, Result};
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
89                _ => <dyn Visitor>::ignore(),
90            })
91        }
92
93        fn deser_default() -> Self {
94            Self {
95                financial_connections: Deserialize::default(),
96                mandate_options: Deserialize::default(),
97                preferred_settlement_speed: Deserialize::default(),
98                setup_future_usage: Deserialize::default(),
99                target_date: Deserialize::default(),
100                verification_method: Deserialize::default(),
101            }
102        }
103
104        fn take_out(&mut self) -> Option<Self::Out> {
105            let (
106                Some(financial_connections),
107                Some(mandate_options),
108                Some(preferred_settlement_speed),
109                Some(setup_future_usage),
110                Some(target_date),
111                Some(verification_method),
112            ) = (
113                self.financial_connections.take(),
114                self.mandate_options,
115                self.preferred_settlement_speed,
116                self.setup_future_usage,
117                self.target_date.take(),
118                self.verification_method,
119            )
120            else {
121                return None;
122            };
123            Some(Self::Out {
124                financial_connections,
125                mandate_options,
126                preferred_settlement_speed,
127                setup_future_usage,
128                target_date,
129                verification_method,
130            })
131        }
132    }
133
134    impl Map for Builder<'_> {
135        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
136            self.builder.key(k)
137        }
138
139        fn finish(&mut self) -> Result<()> {
140            *self.out = self.builder.take_out();
141            Ok(())
142        }
143    }
144
145    impl ObjectDeser for PaymentIntentPaymentMethodOptionsUsBankAccount {
146        type Builder = PaymentIntentPaymentMethodOptionsUsBankAccountBuilder;
147    }
148
149    impl FromValueOpt for PaymentIntentPaymentMethodOptionsUsBankAccount {
150        fn from_value(v: Value) -> Option<Self> {
151            let Value::Object(obj) = v else {
152                return None;
153            };
154            let mut b = PaymentIntentPaymentMethodOptionsUsBankAccountBuilder::deser_default();
155            for (k, v) in obj {
156                match k.as_str() {
157                    "financial_connections" => {
158                        b.financial_connections = FromValueOpt::from_value(v)
159                    }
160                    "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
161                    "preferred_settlement_speed" => {
162                        b.preferred_settlement_speed = FromValueOpt::from_value(v)
163                    }
164                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
165                    "target_date" => b.target_date = FromValueOpt::from_value(v),
166                    "verification_method" => b.verification_method = FromValueOpt::from_value(v),
167
168                    _ => {}
169                }
170            }
171            b.take_out()
172        }
173    }
174};
175/// Preferred transaction settlement speed
176#[derive(Copy, Clone, Eq, PartialEq)]
177pub enum PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed {
178    Fastest,
179    Standard,
180}
181impl PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed {
182    pub fn as_str(self) -> &'static str {
183        use PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed::*;
184        match self {
185            Fastest => "fastest",
186            Standard => "standard",
187        }
188    }
189}
190
191impl std::str::FromStr for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed {
192    type Err = stripe_types::StripeParseError;
193    fn from_str(s: &str) -> Result<Self, Self::Err> {
194        use PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed::*;
195        match s {
196            "fastest" => Ok(Fastest),
197            "standard" => Ok(Standard),
198            _ => Err(stripe_types::StripeParseError),
199        }
200    }
201}
202impl std::fmt::Display for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed {
203    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
204        f.write_str(self.as_str())
205    }
206}
207
208impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed {
209    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
210        f.write_str(self.as_str())
211    }
212}
213#[cfg(feature = "serialize")]
214impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed {
215    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
216    where
217        S: serde::Serializer,
218    {
219        serializer.serialize_str(self.as_str())
220    }
221}
222impl miniserde::Deserialize
223    for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed
224{
225    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
226        crate::Place::new(out)
227    }
228}
229
230impl miniserde::de::Visitor
231    for crate::Place<PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>
232{
233    fn string(&mut self, s: &str) -> miniserde::Result<()> {
234        use std::str::FromStr;
235        self.out = Some(
236            PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed::from_str(s)
237                .map_err(|_| miniserde::Error)?,
238        );
239        Ok(())
240    }
241}
242
243stripe_types::impl_from_val_with_from_str!(
244    PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed
245);
246#[cfg(feature = "deserialize")]
247impl<'de> serde::Deserialize<'de>
248    for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed
249{
250    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
251        use std::str::FromStr;
252        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
253        Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed"))
254    }
255}
256/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
257///
258/// 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.
259/// 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.
260///
261/// 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.
262///
263/// 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).
264#[derive(Copy, Clone, Eq, PartialEq)]
265pub enum PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage {
266    None,
267    OffSession,
268    OnSession,
269}
270impl PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage {
271    pub fn as_str(self) -> &'static str {
272        use PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage::*;
273        match self {
274            None => "none",
275            OffSession => "off_session",
276            OnSession => "on_session",
277        }
278    }
279}
280
281impl std::str::FromStr for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage {
282    type Err = stripe_types::StripeParseError;
283    fn from_str(s: &str) -> Result<Self, Self::Err> {
284        use PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage::*;
285        match s {
286            "none" => Ok(None),
287            "off_session" => Ok(OffSession),
288            "on_session" => Ok(OnSession),
289            _ => Err(stripe_types::StripeParseError),
290        }
291    }
292}
293impl std::fmt::Display for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage {
294    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
295        f.write_str(self.as_str())
296    }
297}
298
299impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage {
300    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
301        f.write_str(self.as_str())
302    }
303}
304#[cfg(feature = "serialize")]
305impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage {
306    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
307    where
308        S: serde::Serializer,
309    {
310        serializer.serialize_str(self.as_str())
311    }
312}
313impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage {
314    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
315        crate::Place::new(out)
316    }
317}
318
319impl miniserde::de::Visitor
320    for crate::Place<PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>
321{
322    fn string(&mut self, s: &str) -> miniserde::Result<()> {
323        use std::str::FromStr;
324        self.out = Some(
325            PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage::from_str(s)
326                .map_err(|_| miniserde::Error)?,
327        );
328        Ok(())
329    }
330}
331
332stripe_types::impl_from_val_with_from_str!(
333    PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage
334);
335#[cfg(feature = "deserialize")]
336impl<'de> serde::Deserialize<'de>
337    for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage
338{
339    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
340        use std::str::FromStr;
341        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
342        Self::from_str(&s).map_err(|_| {
343            serde::de::Error::custom(
344                "Unknown value for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage",
345            )
346        })
347    }
348}
349/// Bank account verification method.
350#[derive(Copy, Clone, Eq, PartialEq)]
351pub enum PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
352    Automatic,
353    Instant,
354    Microdeposits,
355}
356impl PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
357    pub fn as_str(self) -> &'static str {
358        use PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod::*;
359        match self {
360            Automatic => "automatic",
361            Instant => "instant",
362            Microdeposits => "microdeposits",
363        }
364    }
365}
366
367impl std::str::FromStr for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
368    type Err = stripe_types::StripeParseError;
369    fn from_str(s: &str) -> Result<Self, Self::Err> {
370        use PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod::*;
371        match s {
372            "automatic" => Ok(Automatic),
373            "instant" => Ok(Instant),
374            "microdeposits" => Ok(Microdeposits),
375            _ => Err(stripe_types::StripeParseError),
376        }
377    }
378}
379impl std::fmt::Display for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
380    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
381        f.write_str(self.as_str())
382    }
383}
384
385impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
386    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
387        f.write_str(self.as_str())
388    }
389}
390#[cfg(feature = "serialize")]
391impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
392    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
393    where
394        S: serde::Serializer,
395    {
396        serializer.serialize_str(self.as_str())
397    }
398}
399impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod {
400    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
401        crate::Place::new(out)
402    }
403}
404
405impl miniserde::de::Visitor
406    for crate::Place<PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>
407{
408    fn string(&mut self, s: &str) -> miniserde::Result<()> {
409        use std::str::FromStr;
410        self.out = Some(
411            PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s)
412                .map_err(|_| miniserde::Error)?,
413        );
414        Ok(())
415    }
416}
417
418stripe_types::impl_from_val_with_from_str!(
419    PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod
420);
421#[cfg(feature = "deserialize")]
422impl<'de> serde::Deserialize<'de>
423    for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod
424{
425    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
426        use std::str::FromStr;
427        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
428        Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod"))
429    }
430}