stripe_shared/
payment_intent_payment_method_options_nz_bank_account.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentPaymentMethodOptionsNzBankAccount {
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<PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage>,
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 PaymentIntentPaymentMethodOptionsNzBankAccountBuilder {
21    setup_future_usage:
22        Option<Option<PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage>>,
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 PaymentIntentPaymentMethodOptionsNzBankAccount {
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<PaymentIntentPaymentMethodOptionsNzBankAccount>,
50        builder: PaymentIntentPaymentMethodOptionsNzBankAccountBuilder,
51    }
52
53    impl Visitor for Place<PaymentIntentPaymentMethodOptionsNzBankAccount> {
54        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
55            Ok(Box::new(Builder {
56                out: &mut self.out,
57                builder: PaymentIntentPaymentMethodOptionsNzBankAccountBuilder::deser_default(),
58            }))
59        }
60    }
61
62    impl MapBuilder for PaymentIntentPaymentMethodOptionsNzBankAccountBuilder {
63        type Out = PaymentIntentPaymentMethodOptionsNzBankAccount;
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                _ => <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 PaymentIntentPaymentMethodOptionsNzBankAccount {
98        type Builder = PaymentIntentPaymentMethodOptionsNzBankAccountBuilder;
99    }
100
101    impl FromValueOpt for PaymentIntentPaymentMethodOptionsNzBankAccount {
102        fn from_value(v: Value) -> Option<Self> {
103            let Value::Object(obj) = v else {
104                return None;
105            };
106            let mut b = PaymentIntentPaymentMethodOptionsNzBankAccountBuilder::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            b.take_out()
115        }
116    }
117};
118/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
119///
120/// 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.
121/// 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.
122///
123/// 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.
124///
125/// 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).
126#[derive(Copy, Clone, Eq, PartialEq)]
127pub enum PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
128    None,
129    OffSession,
130    OnSession,
131}
132impl PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
133    pub fn as_str(self) -> &'static str {
134        use PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage::*;
135        match self {
136            None => "none",
137            OffSession => "off_session",
138            OnSession => "on_session",
139        }
140    }
141}
142
143impl std::str::FromStr for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
144    type Err = stripe_types::StripeParseError;
145    fn from_str(s: &str) -> Result<Self, Self::Err> {
146        use PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage::*;
147        match s {
148            "none" => Ok(None),
149            "off_session" => Ok(OffSession),
150            "on_session" => Ok(OnSession),
151            _ => Err(stripe_types::StripeParseError),
152        }
153    }
154}
155impl std::fmt::Display for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
156    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
157        f.write_str(self.as_str())
158    }
159}
160
161impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
162    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
163        f.write_str(self.as_str())
164    }
165}
166#[cfg(feature = "serialize")]
167impl serde::Serialize for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
168    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
169    where
170        S: serde::Serializer,
171    {
172        serializer.serialize_str(self.as_str())
173    }
174}
175impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
176    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
177        crate::Place::new(out)
178    }
179}
180
181impl miniserde::de::Visitor
182    for crate::Place<PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage>
183{
184    fn string(&mut self, s: &str) -> miniserde::Result<()> {
185        use std::str::FromStr;
186        self.out = Some(
187            PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage::from_str(s)
188                .map_err(|_| miniserde::Error)?,
189        );
190        Ok(())
191    }
192}
193
194stripe_types::impl_from_val_with_from_str!(
195    PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage
196);
197#[cfg(feature = "deserialize")]
198impl<'de> serde::Deserialize<'de>
199    for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage
200{
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 PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage",
207            )
208        })
209    }
210}