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    /// Estimated date to debit the customer's bank account. A date string in YYYY-MM-DD format.
12    pub expected_debit_date: Option<String>,
13    /// Uniquely identifies this particular bank account.
14    /// You can use this attribute to check whether two bank accounts are the same.
15    pub fingerprint: Option<String>,
16    /// Last four characters of the IBAN.
17    pub last4: Option<String>,
18    /// Find the ID of the mandate used for this payment under the [payment_method_details.sepa_debit.mandate](https://docs.stripe.com/api/charges/object#charge_object-payment_method_details-sepa_debit-mandate) property on the Charge.
19    /// Use this mandate ID to [retrieve the Mandate](https://docs.stripe.com/api/mandates/retrieve).
20    pub mandate: Option<String>,
21}
22#[doc(hidden)]
23pub struct PaymentMethodDetailsSepaDebitBuilder {
24    bank_code: Option<Option<String>>,
25    branch_code: Option<Option<String>>,
26    country: Option<Option<String>>,
27    expected_debit_date: Option<Option<String>>,
28    fingerprint: Option<Option<String>>,
29    last4: Option<Option<String>>,
30    mandate: Option<Option<String>>,
31}
32
33#[allow(
34    unused_variables,
35    irrefutable_let_patterns,
36    clippy::let_unit_value,
37    clippy::match_single_binding,
38    clippy::single_match
39)]
40const _: () = {
41    use miniserde::de::{Map, Visitor};
42    use miniserde::json::Value;
43    use miniserde::{Deserialize, Result, make_place};
44    use stripe_types::miniserde_helpers::FromValueOpt;
45    use stripe_types::{MapBuilder, ObjectDeser};
46
47    make_place!(Place);
48
49    impl Deserialize for PaymentMethodDetailsSepaDebit {
50        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
51            Place::new(out)
52        }
53    }
54
55    struct Builder<'a> {
56        out: &'a mut Option<PaymentMethodDetailsSepaDebit>,
57        builder: PaymentMethodDetailsSepaDebitBuilder,
58    }
59
60    impl Visitor for Place<PaymentMethodDetailsSepaDebit> {
61        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
62            Ok(Box::new(Builder {
63                out: &mut self.out,
64                builder: PaymentMethodDetailsSepaDebitBuilder::deser_default(),
65            }))
66        }
67    }
68
69    impl MapBuilder for PaymentMethodDetailsSepaDebitBuilder {
70        type Out = PaymentMethodDetailsSepaDebit;
71        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72            Ok(match k {
73                "bank_code" => Deserialize::begin(&mut self.bank_code),
74                "branch_code" => Deserialize::begin(&mut self.branch_code),
75                "country" => Deserialize::begin(&mut self.country),
76                "expected_debit_date" => Deserialize::begin(&mut self.expected_debit_date),
77                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
78                "last4" => Deserialize::begin(&mut self.last4),
79                "mandate" => Deserialize::begin(&mut self.mandate),
80                _ => <dyn Visitor>::ignore(),
81            })
82        }
83
84        fn deser_default() -> Self {
85            Self {
86                bank_code: Deserialize::default(),
87                branch_code: Deserialize::default(),
88                country: Deserialize::default(),
89                expected_debit_date: Deserialize::default(),
90                fingerprint: Deserialize::default(),
91                last4: Deserialize::default(),
92                mandate: Deserialize::default(),
93            }
94        }
95
96        fn take_out(&mut self) -> Option<Self::Out> {
97            let (
98                Some(bank_code),
99                Some(branch_code),
100                Some(country),
101                Some(expected_debit_date),
102                Some(fingerprint),
103                Some(last4),
104                Some(mandate),
105            ) = (
106                self.bank_code.take(),
107                self.branch_code.take(),
108                self.country.take(),
109                self.expected_debit_date.take(),
110                self.fingerprint.take(),
111                self.last4.take(),
112                self.mandate.take(),
113            )
114            else {
115                return None;
116            };
117            Some(Self::Out {
118                bank_code,
119                branch_code,
120                country,
121                expected_debit_date,
122                fingerprint,
123                last4,
124                mandate,
125            })
126        }
127    }
128
129    impl Map for Builder<'_> {
130        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
131            self.builder.key(k)
132        }
133
134        fn finish(&mut self) -> Result<()> {
135            *self.out = self.builder.take_out();
136            Ok(())
137        }
138    }
139
140    impl ObjectDeser for PaymentMethodDetailsSepaDebit {
141        type Builder = PaymentMethodDetailsSepaDebitBuilder;
142    }
143
144    impl FromValueOpt for PaymentMethodDetailsSepaDebit {
145        fn from_value(v: Value) -> Option<Self> {
146            let Value::Object(obj) = v else {
147                return None;
148            };
149            let mut b = PaymentMethodDetailsSepaDebitBuilder::deser_default();
150            for (k, v) in obj {
151                match k.as_str() {
152                    "bank_code" => b.bank_code = FromValueOpt::from_value(v),
153                    "branch_code" => b.branch_code = FromValueOpt::from_value(v),
154                    "country" => b.country = FromValueOpt::from_value(v),
155                    "expected_debit_date" => b.expected_debit_date = FromValueOpt::from_value(v),
156                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
157                    "last4" => b.last4 = FromValueOpt::from_value(v),
158                    "mandate" => b.mandate = FromValueOpt::from_value(v),
159                    _ => {}
160                }
161            }
162            b.take_out()
163        }
164    }
165};