stripe_shared/
payment_method_details_sepa_debit.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodDetailsSepaDebit {
5    /// Bank code of bank associated with the bank account.
6    pub bank_code: Option<String>,
7    /// Branch code of bank associated with the bank account.
8    pub branch_code: Option<String>,
9    /// Two-letter ISO code representing the country the bank account is located in.
10    pub country: Option<String>,
11    /// Uniquely identifies this particular bank account.
12    /// You can use this attribute to check whether two bank accounts are the same.
13    pub fingerprint: Option<String>,
14    /// Last four characters of the IBAN.
15    pub last4: Option<String>,
16    /// Find the ID of the mandate used for this payment under the [payment_method_details.sepa_debit.mandate](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-sepa_debit-mandate) property on the Charge.
17    /// Use this mandate ID to [retrieve the Mandate](https://stripe.com/docs/api/mandates/retrieve).
18    pub mandate: Option<String>,
19}
20#[doc(hidden)]
21pub struct PaymentMethodDetailsSepaDebitBuilder {
22    bank_code: Option<Option<String>>,
23    branch_code: Option<Option<String>>,
24    country: Option<Option<String>>,
25    fingerprint: Option<Option<String>>,
26    last4: Option<Option<String>>,
27    mandate: 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 PaymentMethodDetailsSepaDebit {
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<PaymentMethodDetailsSepaDebit>,
54        builder: PaymentMethodDetailsSepaDebitBuilder,
55    }
56
57    impl Visitor for Place<PaymentMethodDetailsSepaDebit> {
58        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
59            Ok(Box::new(Builder {
60                out: &mut self.out,
61                builder: PaymentMethodDetailsSepaDebitBuilder::deser_default(),
62            }))
63        }
64    }
65
66    impl MapBuilder for PaymentMethodDetailsSepaDebitBuilder {
67        type Out = PaymentMethodDetailsSepaDebit;
68        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
69            Ok(match k {
70                "bank_code" => Deserialize::begin(&mut self.bank_code),
71                "branch_code" => Deserialize::begin(&mut self.branch_code),
72                "country" => Deserialize::begin(&mut self.country),
73                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
74                "last4" => Deserialize::begin(&mut self.last4),
75                "mandate" => Deserialize::begin(&mut self.mandate),
76                _ => <dyn Visitor>::ignore(),
77            })
78        }
79
80        fn deser_default() -> Self {
81            Self {
82                bank_code: Deserialize::default(),
83                branch_code: Deserialize::default(),
84                country: Deserialize::default(),
85                fingerprint: Deserialize::default(),
86                last4: Deserialize::default(),
87                mandate: Deserialize::default(),
88            }
89        }
90
91        fn take_out(&mut self) -> Option<Self::Out> {
92            let (
93                Some(bank_code),
94                Some(branch_code),
95                Some(country),
96                Some(fingerprint),
97                Some(last4),
98                Some(mandate),
99            ) = (
100                self.bank_code.take(),
101                self.branch_code.take(),
102                self.country.take(),
103                self.fingerprint.take(),
104                self.last4.take(),
105                self.mandate.take(),
106            )
107            else {
108                return None;
109            };
110            Some(Self::Out { bank_code, branch_code, country, fingerprint, last4, mandate })
111        }
112    }
113
114    impl Map for Builder<'_> {
115        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
116            self.builder.key(k)
117        }
118
119        fn finish(&mut self) -> Result<()> {
120            *self.out = self.builder.take_out();
121            Ok(())
122        }
123    }
124
125    impl ObjectDeser for PaymentMethodDetailsSepaDebit {
126        type Builder = PaymentMethodDetailsSepaDebitBuilder;
127    }
128
129    impl FromValueOpt for PaymentMethodDetailsSepaDebit {
130        fn from_value(v: Value) -> Option<Self> {
131            let Value::Object(obj) = v else {
132                return None;
133            };
134            let mut b = PaymentMethodDetailsSepaDebitBuilder::deser_default();
135            for (k, v) in obj {
136                match k.as_str() {
137                    "bank_code" => b.bank_code = FromValueOpt::from_value(v),
138                    "branch_code" => b.branch_code = FromValueOpt::from_value(v),
139                    "country" => b.country = FromValueOpt::from_value(v),
140                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
141                    "last4" => b.last4 = FromValueOpt::from_value(v),
142                    "mandate" => b.mandate = FromValueOpt::from_value(v),
143                    _ => {}
144                }
145            }
146            b.take_out()
147        }
148    }
149};