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.take(), 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(Clone, Eq, PartialEq)]
127#[non_exhaustive]
128pub enum PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
129    None,
130    OffSession,
131    OnSession,
132    /// An unrecognized value from Stripe. Should not be used as a request parameter.
133    Unknown(String),
134}
135impl PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
136    pub fn as_str(&self) -> &str {
137        use PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage::*;
138        match self {
139            None => "none",
140            OffSession => "off_session",
141            OnSession => "on_session",
142            Unknown(v) => v,
143        }
144    }
145}
146
147impl std::str::FromStr for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
148    type Err = std::convert::Infallible;
149    fn from_str(s: &str) -> Result<Self, Self::Err> {
150        use PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage::*;
151        match s {
152            "none" => Ok(None),
153            "off_session" => Ok(OffSession),
154            "on_session" => Ok(OnSession),
155            v => {
156                tracing::warn!(
157                    "Unknown value '{}' for enum '{}'",
158                    v,
159                    "PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage"
160                );
161                Ok(Unknown(v.to_owned()))
162            }
163        }
164    }
165}
166impl std::fmt::Display for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
167    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
168        f.write_str(self.as_str())
169    }
170}
171
172impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
173    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
174        f.write_str(self.as_str())
175    }
176}
177#[cfg(feature = "serialize")]
178impl serde::Serialize for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
179    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
180    where
181        S: serde::Serializer,
182    {
183        serializer.serialize_str(self.as_str())
184    }
185}
186impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage {
187    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
188        crate::Place::new(out)
189    }
190}
191
192impl miniserde::de::Visitor
193    for crate::Place<PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage>
194{
195    fn string(&mut self, s: &str) -> miniserde::Result<()> {
196        use std::str::FromStr;
197        self.out = Some(
198            PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage::from_str(s)
199                .expect("infallible"),
200        );
201        Ok(())
202    }
203}
204
205stripe_types::impl_from_val_with_from_str!(
206    PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage
207);
208#[cfg(feature = "deserialize")]
209impl<'de> serde::Deserialize<'de>
210    for PaymentIntentPaymentMethodOptionsNzBankAccountSetupFutureUsage
211{
212    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
213        use std::str::FromStr;
214        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
215        Ok(Self::from_str(&s).expect("infallible"))
216    }
217}