stripe_shared/
payment_intent_payment_method_options_acss_debit.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentPaymentMethodOptionsAcssDebit {
5    pub mandate_options:
6        Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>,
7    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
8    ///
9    /// 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.
10    /// 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.
11    ///
12    /// 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.
13    ///
14    /// 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).
15    pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>,
16    /// Controls when Stripe will attempt to debit the funds from the customer's account.
17    /// The date must be a string in YYYY-MM-DD format.
18    /// The date must be in the future and between 3 and 15 calendar days from now.
19    pub target_date: Option<String>,
20    /// Bank account verification method.
21    pub verification_method: Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>,
22}
23#[doc(hidden)]
24pub struct PaymentIntentPaymentMethodOptionsAcssDebitBuilder {
25    mandate_options:
26        Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>>,
27    setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>>,
28    target_date: Option<Option<String>>,
29    verification_method:
30        Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>>,
31}
32
33#[allow(
34    unused_variables,
35    irrefutable_let_patterns,
36    clippy::let_unit_value,
37    clippy::match_single_binding,
38    clippy::single_match
39)]
40const _: () = {
41    use miniserde::de::{Map, Visitor};
42    use miniserde::json::Value;
43    use miniserde::{Deserialize, Result, make_place};
44    use stripe_types::miniserde_helpers::FromValueOpt;
45    use stripe_types::{MapBuilder, ObjectDeser};
46
47    make_place!(Place);
48
49    impl Deserialize for PaymentIntentPaymentMethodOptionsAcssDebit {
50        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
51            Place::new(out)
52        }
53    }
54
55    struct Builder<'a> {
56        out: &'a mut Option<PaymentIntentPaymentMethodOptionsAcssDebit>,
57        builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder,
58    }
59
60    impl Visitor for Place<PaymentIntentPaymentMethodOptionsAcssDebit> {
61        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
62            Ok(Box::new(Builder {
63                out: &mut self.out,
64                builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default(),
65            }))
66        }
67    }
68
69    impl MapBuilder for PaymentIntentPaymentMethodOptionsAcssDebitBuilder {
70        type Out = PaymentIntentPaymentMethodOptionsAcssDebit;
71        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72            Ok(match k {
73                "mandate_options" => Deserialize::begin(&mut self.mandate_options),
74                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
75                "target_date" => Deserialize::begin(&mut self.target_date),
76                "verification_method" => Deserialize::begin(&mut self.verification_method),
77                _ => <dyn Visitor>::ignore(),
78            })
79        }
80
81        fn deser_default() -> Self {
82            Self {
83                mandate_options: Deserialize::default(),
84                setup_future_usage: Deserialize::default(),
85                target_date: Deserialize::default(),
86                verification_method: Deserialize::default(),
87            }
88        }
89
90        fn take_out(&mut self) -> Option<Self::Out> {
91            let (
92                Some(mandate_options),
93                Some(setup_future_usage),
94                Some(target_date),
95                Some(verification_method),
96            ) = (
97                self.mandate_options.take(),
98                self.setup_future_usage.take(),
99                self.target_date.take(),
100                self.verification_method.take(),
101            )
102            else {
103                return None;
104            };
105            Some(Self::Out {
106                mandate_options,
107                setup_future_usage,
108                target_date,
109                verification_method,
110            })
111        }
112    }
113
114    impl Map for Builder<'_> {
115        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
116            self.builder.key(k)
117        }
118
119        fn finish(&mut self) -> Result<()> {
120            *self.out = self.builder.take_out();
121            Ok(())
122        }
123    }
124
125    impl ObjectDeser for PaymentIntentPaymentMethodOptionsAcssDebit {
126        type Builder = PaymentIntentPaymentMethodOptionsAcssDebitBuilder;
127    }
128
129    impl FromValueOpt for PaymentIntentPaymentMethodOptionsAcssDebit {
130        fn from_value(v: Value) -> Option<Self> {
131            let Value::Object(obj) = v else {
132                return None;
133            };
134            let mut b = PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default();
135            for (k, v) in obj {
136                match k.as_str() {
137                    "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
166    pub fn as_str(&self) -> &str {
167        use PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::*;
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
178    type Err = std::convert::Infallible;
179    fn from_str(s: &str) -> Result<Self, Self::Err> {
180        use PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::*;
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                    "PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage"
190                );
191                Ok(Unknown(v.to_owned()))
192            }
193        }
194    }
195}
196impl std::fmt::Display for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>
224{
225    fn string(&mut self, s: &str) -> miniserde::Result<()> {
226        use std::str::FromStr;
227        self.out = Some(
228            PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::from_str(s)
229                .expect("infallible"),
230        );
231        Ok(())
232    }
233}
234
235stripe_types::impl_from_val_with_from_str!(
236    PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage
237);
238#[cfg(feature = "deserialize")]
239impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
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 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
250    Automatic,
251    Instant,
252    Microdeposits,
253    /// An unrecognized value from Stripe. Should not be used as a request parameter.
254    Unknown(String),
255}
256impl PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
257    pub fn as_str(&self) -> &str {
258        use PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
259        match self {
260            Automatic => "automatic",
261            Instant => "instant",
262            Microdeposits => "microdeposits",
263            Unknown(v) => v,
264        }
265    }
266}
267
268impl std::str::FromStr for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
269    type Err = std::convert::Infallible;
270    fn from_str(s: &str) -> Result<Self, Self::Err> {
271        use PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
272        match s {
273            "automatic" => Ok(Automatic),
274            "instant" => Ok(Instant),
275            "microdeposits" => Ok(Microdeposits),
276            v => {
277                tracing::warn!(
278                    "Unknown value '{}' for enum '{}'",
279                    v,
280                    "PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod"
281                );
282                Ok(Unknown(v.to_owned()))
283            }
284        }
285    }
286}
287impl std::fmt::Display for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
288    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
289        f.write_str(self.as_str())
290    }
291}
292
293impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
294    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
295        f.write_str(self.as_str())
296    }
297}
298#[cfg(feature = "serialize")]
299impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
300    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
301    where
302        S: serde::Serializer,
303    {
304        serializer.serialize_str(self.as_str())
305    }
306}
307impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
308    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
309        crate::Place::new(out)
310    }
311}
312
313impl miniserde::de::Visitor
314    for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>
315{
316    fn string(&mut self, s: &str) -> miniserde::Result<()> {
317        use std::str::FromStr;
318        self.out = Some(
319            PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s)
320                .expect("infallible"),
321        );
322        Ok(())
323    }
324}
325
326stripe_types::impl_from_val_with_from_str!(
327    PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod
328);
329#[cfg(feature = "deserialize")]
330impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
331    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
332        use std::str::FromStr;
333        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
334        Ok(Self::from_str(&s).expect("infallible"))
335    }
336}