stripe_shared/
checkout_au_becs_debit_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 CheckoutAuBecsDebitPaymentMethodOptions {
5    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
6    ///
7    /// 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.
8    /// 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.
9    ///
10    /// 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.
11    ///
12    /// 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).
13    pub setup_future_usage: Option<CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage>,
14    /// Controls when Stripe will attempt to debit the funds from the customer's account.
15    /// The date must be a string in YYYY-MM-DD format.
16    /// The date must be in the future and between 3 and 15 calendar days from now.
17    pub target_date: Option<String>,
18}
19#[doc(hidden)]
20pub struct CheckoutAuBecsDebitPaymentMethodOptionsBuilder {
21    setup_future_usage: Option<Option<CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage>>,
22    target_date: Option<Option<String>>,
23}
24
25#[allow(
26    unused_variables,
27    irrefutable_let_patterns,
28    clippy::let_unit_value,
29    clippy::match_single_binding,
30    clippy::single_match
31)]
32const _: () = {
33    use miniserde::de::{Map, Visitor};
34    use miniserde::json::Value;
35    use miniserde::{Deserialize, Result, make_place};
36    use stripe_types::miniserde_helpers::FromValueOpt;
37    use stripe_types::{MapBuilder, ObjectDeser};
38
39    make_place!(Place);
40
41    impl Deserialize for CheckoutAuBecsDebitPaymentMethodOptions {
42        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
43            Place::new(out)
44        }
45    }
46
47    struct Builder<'a> {
48        out: &'a mut Option<CheckoutAuBecsDebitPaymentMethodOptions>,
49        builder: CheckoutAuBecsDebitPaymentMethodOptionsBuilder,
50    }
51
52    impl Visitor for Place<CheckoutAuBecsDebitPaymentMethodOptions> {
53        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
54            Ok(Box::new(Builder {
55                out: &mut self.out,
56                builder: CheckoutAuBecsDebitPaymentMethodOptionsBuilder::deser_default(),
57            }))
58        }
59    }
60
61    impl MapBuilder for CheckoutAuBecsDebitPaymentMethodOptionsBuilder {
62        type Out = CheckoutAuBecsDebitPaymentMethodOptions;
63        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
64            Ok(match k {
65                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
66                "target_date" => Deserialize::begin(&mut self.target_date),
67
68                _ => <dyn Visitor>::ignore(),
69            })
70        }
71
72        fn deser_default() -> Self {
73            Self { setup_future_usage: Deserialize::default(), target_date: Deserialize::default() }
74        }
75
76        fn take_out(&mut self) -> Option<Self::Out> {
77            let (Some(setup_future_usage), Some(target_date)) =
78                (self.setup_future_usage, self.target_date.take())
79            else {
80                return None;
81            };
82            Some(Self::Out { setup_future_usage, target_date })
83        }
84    }
85
86    impl Map for Builder<'_> {
87        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
88            self.builder.key(k)
89        }
90
91        fn finish(&mut self) -> Result<()> {
92            *self.out = self.builder.take_out();
93            Ok(())
94        }
95    }
96
97    impl ObjectDeser for CheckoutAuBecsDebitPaymentMethodOptions {
98        type Builder = CheckoutAuBecsDebitPaymentMethodOptionsBuilder;
99    }
100
101    impl FromValueOpt for CheckoutAuBecsDebitPaymentMethodOptions {
102        fn from_value(v: Value) -> Option<Self> {
103            let Value::Object(obj) = v else {
104                return None;
105            };
106            let mut b = CheckoutAuBecsDebitPaymentMethodOptionsBuilder::deser_default();
107            for (k, v) in obj {
108                match k.as_str() {
109                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
110                    "target_date" => b.target_date = FromValueOpt::from_value(v),
111
112                    _ => {}
113                }
114            }
115            b.take_out()
116        }
117    }
118};
119/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
120///
121/// 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.
122/// 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.
123///
124/// 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.
125///
126/// 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).
127#[derive(Copy, Clone, Eq, PartialEq)]
128pub enum CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
129    None,
130}
131impl CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
132    pub fn as_str(self) -> &'static str {
133        use CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage::*;
134        match self {
135            None => "none",
136        }
137    }
138}
139
140impl std::str::FromStr for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
141    type Err = stripe_types::StripeParseError;
142    fn from_str(s: &str) -> Result<Self, Self::Err> {
143        use CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage::*;
144        match s {
145            "none" => Ok(None),
146            _ => Err(stripe_types::StripeParseError),
147        }
148    }
149}
150impl std::fmt::Display for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
151    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
152        f.write_str(self.as_str())
153    }
154}
155
156impl std::fmt::Debug for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
157    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
158        f.write_str(self.as_str())
159    }
160}
161#[cfg(feature = "serialize")]
162impl serde::Serialize for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
163    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
164    where
165        S: serde::Serializer,
166    {
167        serializer.serialize_str(self.as_str())
168    }
169}
170impl miniserde::Deserialize for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
171    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
172        crate::Place::new(out)
173    }
174}
175
176impl miniserde::de::Visitor
177    for crate::Place<CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage>
178{
179    fn string(&mut self, s: &str) -> miniserde::Result<()> {
180        use std::str::FromStr;
181        self.out = Some(
182            CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage::from_str(s)
183                .map_err(|_| miniserde::Error)?,
184        );
185        Ok(())
186    }
187}
188
189stripe_types::impl_from_val_with_from_str!(CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage);
190#[cfg(feature = "deserialize")]
191impl<'de> serde::Deserialize<'de> for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
192    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
193        use std::str::FromStr;
194        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
195        Self::from_str(&s).map_err(|_| {
196            serde::de::Error::custom(
197                "Unknown value for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage",
198            )
199        })
200    }
201}