1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct InvoicesPaymentSettings {
5 pub default_mandate: Option<String>,
8 pub payment_method_options: Option<stripe_shared::InvoicesPaymentMethodOptions>,
10 pub payment_method_types: Option<Vec<InvoicesPaymentSettingsPaymentMethodTypes>>,
14}
15#[doc(hidden)]
16pub struct InvoicesPaymentSettingsBuilder {
17 default_mandate: Option<Option<String>>,
18 payment_method_options: Option<Option<stripe_shared::InvoicesPaymentMethodOptions>>,
19 payment_method_types: Option<Option<Vec<InvoicesPaymentSettingsPaymentMethodTypes>>>,
20}
21
22#[allow(
23 unused_variables,
24 irrefutable_let_patterns,
25 clippy::let_unit_value,
26 clippy::match_single_binding,
27 clippy::single_match
28)]
29const _: () = {
30 use miniserde::de::{Map, Visitor};
31 use miniserde::json::Value;
32 use miniserde::{make_place, Deserialize, Result};
33 use stripe_types::miniserde_helpers::FromValueOpt;
34 use stripe_types::{MapBuilder, ObjectDeser};
35
36 make_place!(Place);
37
38 impl Deserialize for InvoicesPaymentSettings {
39 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
40 Place::new(out)
41 }
42 }
43
44 struct Builder<'a> {
45 out: &'a mut Option<InvoicesPaymentSettings>,
46 builder: InvoicesPaymentSettingsBuilder,
47 }
48
49 impl Visitor for Place<InvoicesPaymentSettings> {
50 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
51 Ok(Box::new(Builder {
52 out: &mut self.out,
53 builder: InvoicesPaymentSettingsBuilder::deser_default(),
54 }))
55 }
56 }
57
58 impl MapBuilder for InvoicesPaymentSettingsBuilder {
59 type Out = InvoicesPaymentSettings;
60 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
61 Ok(match k {
62 "default_mandate" => Deserialize::begin(&mut self.default_mandate),
63 "payment_method_options" => Deserialize::begin(&mut self.payment_method_options),
64 "payment_method_types" => Deserialize::begin(&mut self.payment_method_types),
65
66 _ => <dyn Visitor>::ignore(),
67 })
68 }
69
70 fn deser_default() -> Self {
71 Self {
72 default_mandate: Deserialize::default(),
73 payment_method_options: Deserialize::default(),
74 payment_method_types: Deserialize::default(),
75 }
76 }
77
78 fn take_out(&mut self) -> Option<Self::Out> {
79 let (Some(default_mandate), Some(payment_method_options), Some(payment_method_types)) = (
80 self.default_mandate.take(),
81 self.payment_method_options.take(),
82 self.payment_method_types.take(),
83 ) else {
84 return None;
85 };
86 Some(Self::Out { default_mandate, payment_method_options, payment_method_types })
87 }
88 }
89
90 impl Map for Builder<'_> {
91 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
92 self.builder.key(k)
93 }
94
95 fn finish(&mut self) -> Result<()> {
96 *self.out = self.builder.take_out();
97 Ok(())
98 }
99 }
100
101 impl ObjectDeser for InvoicesPaymentSettings {
102 type Builder = InvoicesPaymentSettingsBuilder;
103 }
104
105 impl FromValueOpt for InvoicesPaymentSettings {
106 fn from_value(v: Value) -> Option<Self> {
107 let Value::Object(obj) = v else {
108 return None;
109 };
110 let mut b = InvoicesPaymentSettingsBuilder::deser_default();
111 for (k, v) in obj {
112 match k.as_str() {
113 "default_mandate" => b.default_mandate = FromValueOpt::from_value(v),
114 "payment_method_options" => {
115 b.payment_method_options = FromValueOpt::from_value(v)
116 }
117 "payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
118
119 _ => {}
120 }
121 }
122 b.take_out()
123 }
124 }
125};
126#[derive(Clone, Eq, PartialEq)]
130#[non_exhaustive]
131pub enum InvoicesPaymentSettingsPaymentMethodTypes {
132 AchCreditTransfer,
133 AchDebit,
134 AcssDebit,
135 Affirm,
136 AmazonPay,
137 AuBecsDebit,
138 BacsDebit,
139 Bancontact,
140 Boleto,
141 Card,
142 Cashapp,
143 Crypto,
144 CustomerBalance,
145 Eps,
146 Fpx,
147 Giropay,
148 Grabpay,
149 Ideal,
150 JpCreditTransfer,
151 KakaoPay,
152 Klarna,
153 Konbini,
154 KrCard,
155 Link,
156 Multibanco,
157 NaverPay,
158 NzBankAccount,
159 P24,
160 Payco,
161 Paynow,
162 Paypal,
163 Promptpay,
164 RevolutPay,
165 SepaCreditTransfer,
166 SepaDebit,
167 Sofort,
168 Swish,
169 UsBankAccount,
170 WechatPay,
171 Unknown(String),
173}
174impl InvoicesPaymentSettingsPaymentMethodTypes {
175 pub fn as_str(&self) -> &str {
176 use InvoicesPaymentSettingsPaymentMethodTypes::*;
177 match self {
178 AchCreditTransfer => "ach_credit_transfer",
179 AchDebit => "ach_debit",
180 AcssDebit => "acss_debit",
181 Affirm => "affirm",
182 AmazonPay => "amazon_pay",
183 AuBecsDebit => "au_becs_debit",
184 BacsDebit => "bacs_debit",
185 Bancontact => "bancontact",
186 Boleto => "boleto",
187 Card => "card",
188 Cashapp => "cashapp",
189 Crypto => "crypto",
190 CustomerBalance => "customer_balance",
191 Eps => "eps",
192 Fpx => "fpx",
193 Giropay => "giropay",
194 Grabpay => "grabpay",
195 Ideal => "ideal",
196 JpCreditTransfer => "jp_credit_transfer",
197 KakaoPay => "kakao_pay",
198 Klarna => "klarna",
199 Konbini => "konbini",
200 KrCard => "kr_card",
201 Link => "link",
202 Multibanco => "multibanco",
203 NaverPay => "naver_pay",
204 NzBankAccount => "nz_bank_account",
205 P24 => "p24",
206 Payco => "payco",
207 Paynow => "paynow",
208 Paypal => "paypal",
209 Promptpay => "promptpay",
210 RevolutPay => "revolut_pay",
211 SepaCreditTransfer => "sepa_credit_transfer",
212 SepaDebit => "sepa_debit",
213 Sofort => "sofort",
214 Swish => "swish",
215 UsBankAccount => "us_bank_account",
216 WechatPay => "wechat_pay",
217 Unknown(v) => v,
218 }
219 }
220}
221
222impl std::str::FromStr for InvoicesPaymentSettingsPaymentMethodTypes {
223 type Err = std::convert::Infallible;
224 fn from_str(s: &str) -> Result<Self, Self::Err> {
225 use InvoicesPaymentSettingsPaymentMethodTypes::*;
226 match s {
227 "ach_credit_transfer" => Ok(AchCreditTransfer),
228 "ach_debit" => Ok(AchDebit),
229 "acss_debit" => Ok(AcssDebit),
230 "affirm" => Ok(Affirm),
231 "amazon_pay" => Ok(AmazonPay),
232 "au_becs_debit" => Ok(AuBecsDebit),
233 "bacs_debit" => Ok(BacsDebit),
234 "bancontact" => Ok(Bancontact),
235 "boleto" => Ok(Boleto),
236 "card" => Ok(Card),
237 "cashapp" => Ok(Cashapp),
238 "crypto" => Ok(Crypto),
239 "customer_balance" => Ok(CustomerBalance),
240 "eps" => Ok(Eps),
241 "fpx" => Ok(Fpx),
242 "giropay" => Ok(Giropay),
243 "grabpay" => Ok(Grabpay),
244 "ideal" => Ok(Ideal),
245 "jp_credit_transfer" => Ok(JpCreditTransfer),
246 "kakao_pay" => Ok(KakaoPay),
247 "klarna" => Ok(Klarna),
248 "konbini" => Ok(Konbini),
249 "kr_card" => Ok(KrCard),
250 "link" => Ok(Link),
251 "multibanco" => Ok(Multibanco),
252 "naver_pay" => Ok(NaverPay),
253 "nz_bank_account" => Ok(NzBankAccount),
254 "p24" => Ok(P24),
255 "payco" => Ok(Payco),
256 "paynow" => Ok(Paynow),
257 "paypal" => Ok(Paypal),
258 "promptpay" => Ok(Promptpay),
259 "revolut_pay" => Ok(RevolutPay),
260 "sepa_credit_transfer" => Ok(SepaCreditTransfer),
261 "sepa_debit" => Ok(SepaDebit),
262 "sofort" => Ok(Sofort),
263 "swish" => Ok(Swish),
264 "us_bank_account" => Ok(UsBankAccount),
265 "wechat_pay" => Ok(WechatPay),
266 v => Ok(Unknown(v.to_owned())),
267 }
268 }
269}
270impl std::fmt::Display for InvoicesPaymentSettingsPaymentMethodTypes {
271 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
272 f.write_str(self.as_str())
273 }
274}
275
276impl std::fmt::Debug for InvoicesPaymentSettingsPaymentMethodTypes {
277 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
278 f.write_str(self.as_str())
279 }
280}
281#[cfg(feature = "serialize")]
282impl serde::Serialize for InvoicesPaymentSettingsPaymentMethodTypes {
283 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
284 where
285 S: serde::Serializer,
286 {
287 serializer.serialize_str(self.as_str())
288 }
289}
290impl miniserde::Deserialize for InvoicesPaymentSettingsPaymentMethodTypes {
291 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
292 crate::Place::new(out)
293 }
294}
295
296impl miniserde::de::Visitor for crate::Place<InvoicesPaymentSettingsPaymentMethodTypes> {
297 fn string(&mut self, s: &str) -> miniserde::Result<()> {
298 use std::str::FromStr;
299 self.out = Some(InvoicesPaymentSettingsPaymentMethodTypes::from_str(s).unwrap());
300 Ok(())
301 }
302}
303
304stripe_types::impl_from_val_with_from_str!(InvoicesPaymentSettingsPaymentMethodTypes);
305#[cfg(feature = "deserialize")]
306impl<'de> serde::Deserialize<'de> for InvoicesPaymentSettingsPaymentMethodTypes {
307 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
308 use std::str::FromStr;
309 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
310 Ok(Self::from_str(&s).unwrap())
311 }
312}