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::{make_place, Deserialize, Result};
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
76                _ => <dyn Visitor>::ignore(),
77            })
78        }
79
80        fn deser_default() -> Self {
81            Self {
82                financial_connections: Deserialize::default(),
83                setup_future_usage: Deserialize::default(),
84                target_date: Deserialize::default(),
85                verification_method: Deserialize::default(),
86            }
87        }
88
89        fn take_out(&mut self) -> Option<Self::Out> {
90            let (
91                Some(financial_connections),
92                Some(setup_future_usage),
93                Some(target_date),
94                Some(verification_method),
95            ) = (
96                self.financial_connections.take(),
97                self.setup_future_usage,
98                self.target_date.take(),
99                self.verification_method,
100            )
101            else {
102                return None;
103            };
104            Some(Self::Out {
105                financial_connections,
106                setup_future_usage,
107                target_date,
108                verification_method,
109            })
110        }
111    }
112
113    impl<'a> Map for Builder<'a> {
114        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
115            self.builder.key(k)
116        }
117
118        fn finish(&mut self) -> Result<()> {
119            *self.out = self.builder.take_out();
120            Ok(())
121        }
122    }
123
124    impl ObjectDeser for CheckoutUsBankAccountPaymentMethodOptions {
125        type Builder = CheckoutUsBankAccountPaymentMethodOptionsBuilder;
126    }
127
128    impl FromValueOpt for CheckoutUsBankAccountPaymentMethodOptions {
129        fn from_value(v: Value) -> Option<Self> {
130            let Value::Object(obj) = v else {
131                return None;
132            };
133            let mut b = CheckoutUsBankAccountPaymentMethodOptionsBuilder::deser_default();
134            for (k, v) in obj {
135                match k.as_str() {
136                    "financial_connections" => {
137                        b.financial_connections = FromValueOpt::from_value(v)
138                    }
139                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
140                    "target_date" => b.target_date = FromValueOpt::from_value(v),
141                    "verification_method" => b.verification_method = FromValueOpt::from_value(v),
142
143                    _ => {}
144                }
145            }
146            b.take_out()
147        }
148    }
149};
150/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
151///
152/// 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.
153/// 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.
154///
155/// 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.
156///
157/// 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).
158#[derive(Copy, Clone, Eq, PartialEq)]
159pub enum CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
160    None,
161    OffSession,
162    OnSession,
163}
164impl CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
165    pub fn as_str(self) -> &'static str {
166        use CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage::*;
167        match self {
168            None => "none",
169            OffSession => "off_session",
170            OnSession => "on_session",
171        }
172    }
173}
174
175impl std::str::FromStr for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
176    type Err = stripe_types::StripeParseError;
177    fn from_str(s: &str) -> Result<Self, Self::Err> {
178        use CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage::*;
179        match s {
180            "none" => Ok(None),
181            "off_session" => Ok(OffSession),
182            "on_session" => Ok(OnSession),
183            _ => Err(stripe_types::StripeParseError),
184        }
185    }
186}
187impl std::fmt::Display for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
188    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
189        f.write_str(self.as_str())
190    }
191}
192
193impl std::fmt::Debug for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
194    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
195        f.write_str(self.as_str())
196    }
197}
198#[cfg(feature = "serialize")]
199impl serde::Serialize for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
200    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
201    where
202        S: serde::Serializer,
203    {
204        serializer.serialize_str(self.as_str())
205    }
206}
207impl miniserde::Deserialize for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
208    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
209        crate::Place::new(out)
210    }
211}
212
213impl miniserde::de::Visitor
214    for crate::Place<CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage>
215{
216    fn string(&mut self, s: &str) -> miniserde::Result<()> {
217        use std::str::FromStr;
218        self.out = Some(
219            CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage::from_str(s)
220                .map_err(|_| miniserde::Error)?,
221        );
222        Ok(())
223    }
224}
225
226stripe_types::impl_from_val_with_from_str!(
227    CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage
228);
229#[cfg(feature = "deserialize")]
230impl<'de> serde::Deserialize<'de> for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage {
231    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
232        use std::str::FromStr;
233        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
234        Self::from_str(&s).map_err(|_| {
235            serde::de::Error::custom(
236                "Unknown value for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage",
237            )
238        })
239    }
240}
241/// Bank account verification method.
242#[derive(Copy, Clone, Eq, PartialEq)]
243pub enum CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
244    Automatic,
245    Instant,
246}
247impl CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
248    pub fn as_str(self) -> &'static str {
249        use CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod::*;
250        match self {
251            Automatic => "automatic",
252            Instant => "instant",
253        }
254    }
255}
256
257impl std::str::FromStr for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
258    type Err = stripe_types::StripeParseError;
259    fn from_str(s: &str) -> Result<Self, Self::Err> {
260        use CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod::*;
261        match s {
262            "automatic" => Ok(Automatic),
263            "instant" => Ok(Instant),
264            _ => Err(stripe_types::StripeParseError),
265        }
266    }
267}
268impl std::fmt::Display for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
269    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
270        f.write_str(self.as_str())
271    }
272}
273
274impl std::fmt::Debug for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
275    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
276        f.write_str(self.as_str())
277    }
278}
279#[cfg(feature = "serialize")]
280impl serde::Serialize for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
281    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
282    where
283        S: serde::Serializer,
284    {
285        serializer.serialize_str(self.as_str())
286    }
287}
288impl miniserde::Deserialize for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
289    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
290        crate::Place::new(out)
291    }
292}
293
294impl miniserde::de::Visitor
295    for crate::Place<CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod>
296{
297    fn string(&mut self, s: &str) -> miniserde::Result<()> {
298        use std::str::FromStr;
299        self.out = Some(
300            CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod::from_str(s)
301                .map_err(|_| miniserde::Error)?,
302        );
303        Ok(())
304    }
305}
306
307stripe_types::impl_from_val_with_from_str!(
308    CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod
309);
310#[cfg(feature = "deserialize")]
311impl<'de> serde::Deserialize<'de> for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod {
312    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
313        use std::str::FromStr;
314        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
315        Self::from_str(&s).map_err(|_| {
316            serde::de::Error::custom(
317                "Unknown value for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod",
318            )
319        })
320    }
321}