stripe_shared/
invoices_payment_method_options.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct InvoicesPaymentMethodOptions {
5    /// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent.
6    pub acss_debit: Option<stripe_shared::InvoicePaymentMethodOptionsAcssDebit>,
7    /// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice’s PaymentIntent.
8    pub bancontact: Option<stripe_shared::InvoicePaymentMethodOptionsBancontact>,
9    /// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice’s PaymentIntent.
10    pub card: Option<stripe_shared::InvoicePaymentMethodOptionsCard>,
11    /// If paying by `customer_balance`, this sub-hash contains details about the Bank transfer payment method options to pass to the invoice’s PaymentIntent.
12    pub customer_balance: Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalance>,
13    /// If paying by `konbini`, this sub-hash contains details about the Konbini payment method options to pass to the invoice’s PaymentIntent.
14    pub konbini: Option<stripe_shared::InvoicePaymentMethodOptionsKonbini>,
15    /// If paying by `payto`, this sub-hash contains details about the PayTo payment method options to pass to the invoice’s PaymentIntent.
16    pub payto: Option<stripe_shared::InvoicePaymentMethodOptionsPayto>,
17    /// If paying by `sepa_debit`, this sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice’s PaymentIntent.
18    pub sepa_debit: Option<stripe_shared::InvoicePaymentMethodOptionsSepaDebit>,
19    /// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent.
20    pub us_bank_account: Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccount>,
21}
22#[doc(hidden)]
23pub struct InvoicesPaymentMethodOptionsBuilder {
24    acss_debit: Option<Option<stripe_shared::InvoicePaymentMethodOptionsAcssDebit>>,
25    bancontact: Option<Option<stripe_shared::InvoicePaymentMethodOptionsBancontact>>,
26    card: Option<Option<stripe_shared::InvoicePaymentMethodOptionsCard>>,
27    customer_balance: Option<Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalance>>,
28    konbini: Option<Option<stripe_shared::InvoicePaymentMethodOptionsKonbini>>,
29    payto: Option<Option<stripe_shared::InvoicePaymentMethodOptionsPayto>>,
30    sepa_debit: Option<Option<stripe_shared::InvoicePaymentMethodOptionsSepaDebit>>,
31    us_bank_account: Option<Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccount>>,
32}
33
34#[allow(
35    unused_variables,
36    irrefutable_let_patterns,
37    clippy::let_unit_value,
38    clippy::match_single_binding,
39    clippy::single_match
40)]
41const _: () = {
42    use miniserde::de::{Map, Visitor};
43    use miniserde::json::Value;
44    use miniserde::{Deserialize, Result, make_place};
45    use stripe_types::miniserde_helpers::FromValueOpt;
46    use stripe_types::{MapBuilder, ObjectDeser};
47
48    make_place!(Place);
49
50    impl Deserialize for InvoicesPaymentMethodOptions {
51        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
52            Place::new(out)
53        }
54    }
55
56    struct Builder<'a> {
57        out: &'a mut Option<InvoicesPaymentMethodOptions>,
58        builder: InvoicesPaymentMethodOptionsBuilder,
59    }
60
61    impl Visitor for Place<InvoicesPaymentMethodOptions> {
62        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
63            Ok(Box::new(Builder {
64                out: &mut self.out,
65                builder: InvoicesPaymentMethodOptionsBuilder::deser_default(),
66            }))
67        }
68    }
69
70    impl MapBuilder for InvoicesPaymentMethodOptionsBuilder {
71        type Out = InvoicesPaymentMethodOptions;
72        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
73            Ok(match k {
74                "acss_debit" => Deserialize::begin(&mut self.acss_debit),
75                "bancontact" => Deserialize::begin(&mut self.bancontact),
76                "card" => Deserialize::begin(&mut self.card),
77                "customer_balance" => Deserialize::begin(&mut self.customer_balance),
78                "konbini" => Deserialize::begin(&mut self.konbini),
79                "payto" => Deserialize::begin(&mut self.payto),
80                "sepa_debit" => Deserialize::begin(&mut self.sepa_debit),
81                "us_bank_account" => Deserialize::begin(&mut self.us_bank_account),
82                _ => <dyn Visitor>::ignore(),
83            })
84        }
85
86        fn deser_default() -> Self {
87            Self {
88                acss_debit: Deserialize::default(),
89                bancontact: Deserialize::default(),
90                card: Deserialize::default(),
91                customer_balance: Deserialize::default(),
92                konbini: Deserialize::default(),
93                payto: Deserialize::default(),
94                sepa_debit: Deserialize::default(),
95                us_bank_account: Deserialize::default(),
96            }
97        }
98
99        fn take_out(&mut self) -> Option<Self::Out> {
100            let (
101                Some(acss_debit),
102                Some(bancontact),
103                Some(card),
104                Some(customer_balance),
105                Some(konbini),
106                Some(payto),
107                Some(sepa_debit),
108                Some(us_bank_account),
109            ) = (
110                self.acss_debit.take(),
111                self.bancontact.take(),
112                self.card.take(),
113                self.customer_balance.take(),
114                self.konbini,
115                self.payto.take(),
116                self.sepa_debit,
117                self.us_bank_account.take(),
118            )
119            else {
120                return None;
121            };
122            Some(Self::Out {
123                acss_debit,
124                bancontact,
125                card,
126                customer_balance,
127                konbini,
128                payto,
129                sepa_debit,
130                us_bank_account,
131            })
132        }
133    }
134
135    impl Map for Builder<'_> {
136        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
137            self.builder.key(k)
138        }
139
140        fn finish(&mut self) -> Result<()> {
141            *self.out = self.builder.take_out();
142            Ok(())
143        }
144    }
145
146    impl ObjectDeser for InvoicesPaymentMethodOptions {
147        type Builder = InvoicesPaymentMethodOptionsBuilder;
148    }
149
150    impl FromValueOpt for InvoicesPaymentMethodOptions {
151        fn from_value(v: Value) -> Option<Self> {
152            let Value::Object(obj) = v else {
153                return None;
154            };
155            let mut b = InvoicesPaymentMethodOptionsBuilder::deser_default();
156            for (k, v) in obj {
157                match k.as_str() {
158                    "acss_debit" => b.acss_debit = FromValueOpt::from_value(v),
159                    "bancontact" => b.bancontact = FromValueOpt::from_value(v),
160                    "card" => b.card = FromValueOpt::from_value(v),
161                    "customer_balance" => b.customer_balance = FromValueOpt::from_value(v),
162                    "konbini" => b.konbini = FromValueOpt::from_value(v),
163                    "payto" => b.payto = FromValueOpt::from_value(v),
164                    "sepa_debit" => b.sepa_debit = FromValueOpt::from_value(v),
165                    "us_bank_account" => b.us_bank_account = FromValueOpt::from_value(v),
166                    _ => {}
167                }
168            }
169            b.take_out()
170        }
171    }
172};