stripe_shared/
setup_attempt_payment_method_details_ideal.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupAttemptPaymentMethodDetailsIdeal {
5    /// The customer's bank.
6    /// Can be one of `abn_amro`, `asn_bank`, `bunq`, `buut`, `finom`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`.
7    pub bank: Option<SetupAttemptPaymentMethodDetailsIdealBank>,
8    /// The Bank Identifier Code of the customer's bank.
9    pub bic: Option<SetupAttemptPaymentMethodDetailsIdealBic>,
10    /// The ID of the SEPA Direct Debit PaymentMethod which was generated by this SetupAttempt.
11    pub generated_sepa_debit: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
12    /// The mandate for the SEPA Direct Debit PaymentMethod which was generated by this SetupAttempt.
13    pub generated_sepa_debit_mandate: Option<stripe_types::Expandable<stripe_shared::Mandate>>,
14    /// Last four characters of the IBAN.
15    pub iban_last4: Option<String>,
16    /// Owner's verified full name. Values are verified or provided by iDEAL directly
17    /// (if supported) at the time of authorization or settlement. They cannot be set or mutated.
18    pub verified_name: Option<String>,
19}
20#[doc(hidden)]
21pub struct SetupAttemptPaymentMethodDetailsIdealBuilder {
22    bank: Option<Option<SetupAttemptPaymentMethodDetailsIdealBank>>,
23    bic: Option<Option<SetupAttemptPaymentMethodDetailsIdealBic>>,
24    generated_sepa_debit: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
25    generated_sepa_debit_mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>,
26    iban_last4: Option<Option<String>>,
27    verified_name: Option<Option<String>>,
28}
29
30#[allow(
31    unused_variables,
32    irrefutable_let_patterns,
33    clippy::let_unit_value,
34    clippy::match_single_binding,
35    clippy::single_match
36)]
37const _: () = {
38    use miniserde::de::{Map, Visitor};
39    use miniserde::json::Value;
40    use miniserde::{Deserialize, Result, make_place};
41    use stripe_types::miniserde_helpers::FromValueOpt;
42    use stripe_types::{MapBuilder, ObjectDeser};
43
44    make_place!(Place);
45
46    impl Deserialize for SetupAttemptPaymentMethodDetailsIdeal {
47        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
48            Place::new(out)
49        }
50    }
51
52    struct Builder<'a> {
53        out: &'a mut Option<SetupAttemptPaymentMethodDetailsIdeal>,
54        builder: SetupAttemptPaymentMethodDetailsIdealBuilder,
55    }
56
57    impl Visitor for Place<SetupAttemptPaymentMethodDetailsIdeal> {
58        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
59            Ok(Box::new(Builder {
60                out: &mut self.out,
61                builder: SetupAttemptPaymentMethodDetailsIdealBuilder::deser_default(),
62            }))
63        }
64    }
65
66    impl MapBuilder for SetupAttemptPaymentMethodDetailsIdealBuilder {
67        type Out = SetupAttemptPaymentMethodDetailsIdeal;
68        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
69            Ok(match k {
70                "bank" => Deserialize::begin(&mut self.bank),
71                "bic" => Deserialize::begin(&mut self.bic),
72                "generated_sepa_debit" => Deserialize::begin(&mut self.generated_sepa_debit),
73                "generated_sepa_debit_mandate" => {
74                    Deserialize::begin(&mut self.generated_sepa_debit_mandate)
75                }
76                "iban_last4" => Deserialize::begin(&mut self.iban_last4),
77                "verified_name" => Deserialize::begin(&mut self.verified_name),
78                _ => <dyn Visitor>::ignore(),
79            })
80        }
81
82        fn deser_default() -> Self {
83            Self {
84                bank: Deserialize::default(),
85                bic: Deserialize::default(),
86                generated_sepa_debit: Deserialize::default(),
87                generated_sepa_debit_mandate: Deserialize::default(),
88                iban_last4: Deserialize::default(),
89                verified_name: Deserialize::default(),
90            }
91        }
92
93        fn take_out(&mut self) -> Option<Self::Out> {
94            let (
95                Some(bank),
96                Some(bic),
97                Some(generated_sepa_debit),
98                Some(generated_sepa_debit_mandate),
99                Some(iban_last4),
100                Some(verified_name),
101            ) = (
102                self.bank.take(),
103                self.bic.take(),
104                self.generated_sepa_debit.take(),
105                self.generated_sepa_debit_mandate.take(),
106                self.iban_last4.take(),
107                self.verified_name.take(),
108            )
109            else {
110                return None;
111            };
112            Some(Self::Out {
113                bank,
114                bic,
115                generated_sepa_debit,
116                generated_sepa_debit_mandate,
117                iban_last4,
118                verified_name,
119            })
120        }
121    }
122
123    impl Map for Builder<'_> {
124        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
125            self.builder.key(k)
126        }
127
128        fn finish(&mut self) -> Result<()> {
129            *self.out = self.builder.take_out();
130            Ok(())
131        }
132    }
133
134    impl ObjectDeser for SetupAttemptPaymentMethodDetailsIdeal {
135        type Builder = SetupAttemptPaymentMethodDetailsIdealBuilder;
136    }
137
138    impl FromValueOpt for SetupAttemptPaymentMethodDetailsIdeal {
139        fn from_value(v: Value) -> Option<Self> {
140            let Value::Object(obj) = v else {
141                return None;
142            };
143            let mut b = SetupAttemptPaymentMethodDetailsIdealBuilder::deser_default();
144            for (k, v) in obj {
145                match k.as_str() {
146                    "bank" => b.bank = FromValueOpt::from_value(v),
147                    "bic" => b.bic = FromValueOpt::from_value(v),
148                    "generated_sepa_debit" => b.generated_sepa_debit = FromValueOpt::from_value(v),
149                    "generated_sepa_debit_mandate" => {
150                        b.generated_sepa_debit_mandate = FromValueOpt::from_value(v)
151                    }
152                    "iban_last4" => b.iban_last4 = FromValueOpt::from_value(v),
153                    "verified_name" => b.verified_name = FromValueOpt::from_value(v),
154                    _ => {}
155                }
156            }
157            b.take_out()
158        }
159    }
160};
161/// The customer's bank.
162/// Can be one of `abn_amro`, `asn_bank`, `bunq`, `buut`, `finom`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`.
163#[derive(Clone, Eq, PartialEq)]
164#[non_exhaustive]
165pub enum SetupAttemptPaymentMethodDetailsIdealBank {
166    AbnAmro,
167    AsnBank,
168    Bunq,
169    Buut,
170    Finom,
171    Handelsbanken,
172    Ing,
173    Knab,
174    Moneyou,
175    N26,
176    Nn,
177    Rabobank,
178    Regiobank,
179    Revolut,
180    SnsBank,
181    TriodosBank,
182    VanLanschot,
183    Yoursafe,
184    /// An unrecognized value from Stripe. Should not be used as a request parameter.
185    Unknown(String),
186}
187impl SetupAttemptPaymentMethodDetailsIdealBank {
188    pub fn as_str(&self) -> &str {
189        use SetupAttemptPaymentMethodDetailsIdealBank::*;
190        match self {
191            AbnAmro => "abn_amro",
192            AsnBank => "asn_bank",
193            Bunq => "bunq",
194            Buut => "buut",
195            Finom => "finom",
196            Handelsbanken => "handelsbanken",
197            Ing => "ing",
198            Knab => "knab",
199            Moneyou => "moneyou",
200            N26 => "n26",
201            Nn => "nn",
202            Rabobank => "rabobank",
203            Regiobank => "regiobank",
204            Revolut => "revolut",
205            SnsBank => "sns_bank",
206            TriodosBank => "triodos_bank",
207            VanLanschot => "van_lanschot",
208            Yoursafe => "yoursafe",
209            Unknown(v) => v,
210        }
211    }
212}
213
214impl std::str::FromStr for SetupAttemptPaymentMethodDetailsIdealBank {
215    type Err = std::convert::Infallible;
216    fn from_str(s: &str) -> Result<Self, Self::Err> {
217        use SetupAttemptPaymentMethodDetailsIdealBank::*;
218        match s {
219            "abn_amro" => Ok(AbnAmro),
220            "asn_bank" => Ok(AsnBank),
221            "bunq" => Ok(Bunq),
222            "buut" => Ok(Buut),
223            "finom" => Ok(Finom),
224            "handelsbanken" => Ok(Handelsbanken),
225            "ing" => Ok(Ing),
226            "knab" => Ok(Knab),
227            "moneyou" => Ok(Moneyou),
228            "n26" => Ok(N26),
229            "nn" => Ok(Nn),
230            "rabobank" => Ok(Rabobank),
231            "regiobank" => Ok(Regiobank),
232            "revolut" => Ok(Revolut),
233            "sns_bank" => Ok(SnsBank),
234            "triodos_bank" => Ok(TriodosBank),
235            "van_lanschot" => Ok(VanLanschot),
236            "yoursafe" => Ok(Yoursafe),
237            v => {
238                tracing::warn!(
239                    "Unknown value '{}' for enum '{}'",
240                    v,
241                    "SetupAttemptPaymentMethodDetailsIdealBank"
242                );
243                Ok(Unknown(v.to_owned()))
244            }
245        }
246    }
247}
248impl std::fmt::Display for SetupAttemptPaymentMethodDetailsIdealBank {
249    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
250        f.write_str(self.as_str())
251    }
252}
253
254impl std::fmt::Debug for SetupAttemptPaymentMethodDetailsIdealBank {
255    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
256        f.write_str(self.as_str())
257    }
258}
259#[cfg(feature = "serialize")]
260impl serde::Serialize for SetupAttemptPaymentMethodDetailsIdealBank {
261    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
262    where
263        S: serde::Serializer,
264    {
265        serializer.serialize_str(self.as_str())
266    }
267}
268impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsIdealBank {
269    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
270        crate::Place::new(out)
271    }
272}
273
274impl miniserde::de::Visitor for crate::Place<SetupAttemptPaymentMethodDetailsIdealBank> {
275    fn string(&mut self, s: &str) -> miniserde::Result<()> {
276        use std::str::FromStr;
277        self.out =
278            Some(SetupAttemptPaymentMethodDetailsIdealBank::from_str(s).expect("infallible"));
279        Ok(())
280    }
281}
282
283stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsIdealBank);
284#[cfg(feature = "deserialize")]
285impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsIdealBank {
286    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
287        use std::str::FromStr;
288        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
289        Ok(Self::from_str(&s).expect("infallible"))
290    }
291}
292/// The Bank Identifier Code of the customer's bank.
293#[derive(Clone, Eq, PartialEq)]
294#[non_exhaustive]
295pub enum SetupAttemptPaymentMethodDetailsIdealBic {
296    Abnanl2a,
297    Asnbnl21,
298    Bitsnl2a,
299    Bunqnl2a,
300    Buutnl2a,
301    Fnomnl22,
302    Fvlbnl22,
303    Handnl2a,
304    Ingbnl2a,
305    Knabnl2h,
306    Moyonl21,
307    Nnbanl2g,
308    Ntsbdeb1,
309    Rabonl2u,
310    Rbrbnl21,
311    Revoie23,
312    Revolt21,
313    Snsbnl2a,
314    Trionl2u,
315    /// An unrecognized value from Stripe. Should not be used as a request parameter.
316    Unknown(String),
317}
318impl SetupAttemptPaymentMethodDetailsIdealBic {
319    pub fn as_str(&self) -> &str {
320        use SetupAttemptPaymentMethodDetailsIdealBic::*;
321        match self {
322            Abnanl2a => "ABNANL2A",
323            Asnbnl21 => "ASNBNL21",
324            Bitsnl2a => "BITSNL2A",
325            Bunqnl2a => "BUNQNL2A",
326            Buutnl2a => "BUUTNL2A",
327            Fnomnl22 => "FNOMNL22",
328            Fvlbnl22 => "FVLBNL22",
329            Handnl2a => "HANDNL2A",
330            Ingbnl2a => "INGBNL2A",
331            Knabnl2h => "KNABNL2H",
332            Moyonl21 => "MOYONL21",
333            Nnbanl2g => "NNBANL2G",
334            Ntsbdeb1 => "NTSBDEB1",
335            Rabonl2u => "RABONL2U",
336            Rbrbnl21 => "RBRBNL21",
337            Revoie23 => "REVOIE23",
338            Revolt21 => "REVOLT21",
339            Snsbnl2a => "SNSBNL2A",
340            Trionl2u => "TRIONL2U",
341            Unknown(v) => v,
342        }
343    }
344}
345
346impl std::str::FromStr for SetupAttemptPaymentMethodDetailsIdealBic {
347    type Err = std::convert::Infallible;
348    fn from_str(s: &str) -> Result<Self, Self::Err> {
349        use SetupAttemptPaymentMethodDetailsIdealBic::*;
350        match s {
351            "ABNANL2A" => Ok(Abnanl2a),
352            "ASNBNL21" => Ok(Asnbnl21),
353            "BITSNL2A" => Ok(Bitsnl2a),
354            "BUNQNL2A" => Ok(Bunqnl2a),
355            "BUUTNL2A" => Ok(Buutnl2a),
356            "FNOMNL22" => Ok(Fnomnl22),
357            "FVLBNL22" => Ok(Fvlbnl22),
358            "HANDNL2A" => Ok(Handnl2a),
359            "INGBNL2A" => Ok(Ingbnl2a),
360            "KNABNL2H" => Ok(Knabnl2h),
361            "MOYONL21" => Ok(Moyonl21),
362            "NNBANL2G" => Ok(Nnbanl2g),
363            "NTSBDEB1" => Ok(Ntsbdeb1),
364            "RABONL2U" => Ok(Rabonl2u),
365            "RBRBNL21" => Ok(Rbrbnl21),
366            "REVOIE23" => Ok(Revoie23),
367            "REVOLT21" => Ok(Revolt21),
368            "SNSBNL2A" => Ok(Snsbnl2a),
369            "TRIONL2U" => Ok(Trionl2u),
370            v => {
371                tracing::warn!(
372                    "Unknown value '{}' for enum '{}'",
373                    v,
374                    "SetupAttemptPaymentMethodDetailsIdealBic"
375                );
376                Ok(Unknown(v.to_owned()))
377            }
378        }
379    }
380}
381impl std::fmt::Display for SetupAttemptPaymentMethodDetailsIdealBic {
382    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
383        f.write_str(self.as_str())
384    }
385}
386
387impl std::fmt::Debug for SetupAttemptPaymentMethodDetailsIdealBic {
388    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
389        f.write_str(self.as_str())
390    }
391}
392#[cfg(feature = "serialize")]
393impl serde::Serialize for SetupAttemptPaymentMethodDetailsIdealBic {
394    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
395    where
396        S: serde::Serializer,
397    {
398        serializer.serialize_str(self.as_str())
399    }
400}
401impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsIdealBic {
402    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
403        crate::Place::new(out)
404    }
405}
406
407impl miniserde::de::Visitor for crate::Place<SetupAttemptPaymentMethodDetailsIdealBic> {
408    fn string(&mut self, s: &str) -> miniserde::Result<()> {
409        use std::str::FromStr;
410        self.out = Some(SetupAttemptPaymentMethodDetailsIdealBic::from_str(s).expect("infallible"));
411        Ok(())
412    }
413}
414
415stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsIdealBic);
416#[cfg(feature = "deserialize")]
417impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsIdealBic {
418    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
419        use std::str::FromStr;
420        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
421        Ok(Self::from_str(&s).expect("infallible"))
422    }
423}