Skip to main content

stripe_shared/
payment_intent_payment_method_options_us_bank_account.rs

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