Skip to main content

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