stripe_shared/
payment_intent_payment_method_options_au_becs_debit.rs

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