1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SubscriptionsResourcePaymentSettings {
5 pub payment_method_options: Option<stripe_shared::SubscriptionsResourcePaymentMethodOptions>,
7 pub payment_method_types: Option<Vec<SubscriptionsResourcePaymentSettingsPaymentMethodTypes>>,
10 pub save_default_payment_method:
13 Option<SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod>,
14}
15#[doc(hidden)]
16pub struct SubscriptionsResourcePaymentSettingsBuilder {
17 payment_method_options:
18 Option<Option<stripe_shared::SubscriptionsResourcePaymentMethodOptions>>,
19 payment_method_types:
20 Option<Option<Vec<SubscriptionsResourcePaymentSettingsPaymentMethodTypes>>>,
21 save_default_payment_method:
22 Option<Option<SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod>>,
23}
24
25#[allow(
26 unused_variables,
27 irrefutable_let_patterns,
28 clippy::let_unit_value,
29 clippy::match_single_binding,
30 clippy::single_match
31)]
32const _: () = {
33 use miniserde::de::{Map, Visitor};
34 use miniserde::json::Value;
35 use miniserde::{Deserialize, Result, make_place};
36 use stripe_types::miniserde_helpers::FromValueOpt;
37 use stripe_types::{MapBuilder, ObjectDeser};
38
39 make_place!(Place);
40
41 impl Deserialize for SubscriptionsResourcePaymentSettings {
42 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
43 Place::new(out)
44 }
45 }
46
47 struct Builder<'a> {
48 out: &'a mut Option<SubscriptionsResourcePaymentSettings>,
49 builder: SubscriptionsResourcePaymentSettingsBuilder,
50 }
51
52 impl Visitor for Place<SubscriptionsResourcePaymentSettings> {
53 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
54 Ok(Box::new(Builder {
55 out: &mut self.out,
56 builder: SubscriptionsResourcePaymentSettingsBuilder::deser_default(),
57 }))
58 }
59 }
60
61 impl MapBuilder for SubscriptionsResourcePaymentSettingsBuilder {
62 type Out = SubscriptionsResourcePaymentSettings;
63 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
64 Ok(match k {
65 "payment_method_options" => Deserialize::begin(&mut self.payment_method_options),
66 "payment_method_types" => Deserialize::begin(&mut self.payment_method_types),
67 "save_default_payment_method" => {
68 Deserialize::begin(&mut self.save_default_payment_method)
69 }
70 _ => <dyn Visitor>::ignore(),
71 })
72 }
73
74 fn deser_default() -> Self {
75 Self {
76 payment_method_options: Deserialize::default(),
77 payment_method_types: Deserialize::default(),
78 save_default_payment_method: Deserialize::default(),
79 }
80 }
81
82 fn take_out(&mut self) -> Option<Self::Out> {
83 let (
84 Some(payment_method_options),
85 Some(payment_method_types),
86 Some(save_default_payment_method),
87 ) = (
88 self.payment_method_options.take(),
89 self.payment_method_types.take(),
90 self.save_default_payment_method.take(),
91 )
92 else {
93 return None;
94 };
95 Some(Self::Out {
96 payment_method_options,
97 payment_method_types,
98 save_default_payment_method,
99 })
100 }
101 }
102
103 impl Map for Builder<'_> {
104 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
105 self.builder.key(k)
106 }
107
108 fn finish(&mut self) -> Result<()> {
109 *self.out = self.builder.take_out();
110 Ok(())
111 }
112 }
113
114 impl ObjectDeser for SubscriptionsResourcePaymentSettings {
115 type Builder = SubscriptionsResourcePaymentSettingsBuilder;
116 }
117
118 impl FromValueOpt for SubscriptionsResourcePaymentSettings {
119 fn from_value(v: Value) -> Option<Self> {
120 let Value::Object(obj) = v else {
121 return None;
122 };
123 let mut b = SubscriptionsResourcePaymentSettingsBuilder::deser_default();
124 for (k, v) in obj {
125 match k.as_str() {
126 "payment_method_options" => {
127 b.payment_method_options = FromValueOpt::from_value(v)
128 }
129 "payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
130 "save_default_payment_method" => {
131 b.save_default_payment_method = FromValueOpt::from_value(v)
132 }
133 _ => {}
134 }
135 }
136 b.take_out()
137 }
138 }
139};
140#[derive(Clone, Eq, PartialEq)]
143#[non_exhaustive]
144pub enum SubscriptionsResourcePaymentSettingsPaymentMethodTypes {
145 AchCreditTransfer,
146 AchDebit,
147 AcssDebit,
148 Affirm,
149 AmazonPay,
150 AuBecsDebit,
151 BacsDebit,
152 Bancontact,
153 Boleto,
154 Card,
155 Cashapp,
156 Crypto,
157 Custom,
158 CustomerBalance,
159 Eps,
160 Fpx,
161 Giropay,
162 Grabpay,
163 Ideal,
164 JpCreditTransfer,
165 KakaoPay,
166 Klarna,
167 Konbini,
168 KrCard,
169 Link,
170 Multibanco,
171 NaverPay,
172 NzBankAccount,
173 P24,
174 Payco,
175 Paynow,
176 Paypal,
177 Promptpay,
178 RevolutPay,
179 SepaCreditTransfer,
180 SepaDebit,
181 Sofort,
182 Swish,
183 UsBankAccount,
184 WechatPay,
185 Unknown(String),
187}
188impl SubscriptionsResourcePaymentSettingsPaymentMethodTypes {
189 pub fn as_str(&self) -> &str {
190 use SubscriptionsResourcePaymentSettingsPaymentMethodTypes::*;
191 match self {
192 AchCreditTransfer => "ach_credit_transfer",
193 AchDebit => "ach_debit",
194 AcssDebit => "acss_debit",
195 Affirm => "affirm",
196 AmazonPay => "amazon_pay",
197 AuBecsDebit => "au_becs_debit",
198 BacsDebit => "bacs_debit",
199 Bancontact => "bancontact",
200 Boleto => "boleto",
201 Card => "card",
202 Cashapp => "cashapp",
203 Crypto => "crypto",
204 Custom => "custom",
205 CustomerBalance => "customer_balance",
206 Eps => "eps",
207 Fpx => "fpx",
208 Giropay => "giropay",
209 Grabpay => "grabpay",
210 Ideal => "ideal",
211 JpCreditTransfer => "jp_credit_transfer",
212 KakaoPay => "kakao_pay",
213 Klarna => "klarna",
214 Konbini => "konbini",
215 KrCard => "kr_card",
216 Link => "link",
217 Multibanco => "multibanco",
218 NaverPay => "naver_pay",
219 NzBankAccount => "nz_bank_account",
220 P24 => "p24",
221 Payco => "payco",
222 Paynow => "paynow",
223 Paypal => "paypal",
224 Promptpay => "promptpay",
225 RevolutPay => "revolut_pay",
226 SepaCreditTransfer => "sepa_credit_transfer",
227 SepaDebit => "sepa_debit",
228 Sofort => "sofort",
229 Swish => "swish",
230 UsBankAccount => "us_bank_account",
231 WechatPay => "wechat_pay",
232 Unknown(v) => v,
233 }
234 }
235}
236
237impl std::str::FromStr for SubscriptionsResourcePaymentSettingsPaymentMethodTypes {
238 type Err = std::convert::Infallible;
239 fn from_str(s: &str) -> Result<Self, Self::Err> {
240 use SubscriptionsResourcePaymentSettingsPaymentMethodTypes::*;
241 match s {
242 "ach_credit_transfer" => Ok(AchCreditTransfer),
243 "ach_debit" => Ok(AchDebit),
244 "acss_debit" => Ok(AcssDebit),
245 "affirm" => Ok(Affirm),
246 "amazon_pay" => Ok(AmazonPay),
247 "au_becs_debit" => Ok(AuBecsDebit),
248 "bacs_debit" => Ok(BacsDebit),
249 "bancontact" => Ok(Bancontact),
250 "boleto" => Ok(Boleto),
251 "card" => Ok(Card),
252 "cashapp" => Ok(Cashapp),
253 "crypto" => Ok(Crypto),
254 "custom" => Ok(Custom),
255 "customer_balance" => Ok(CustomerBalance),
256 "eps" => Ok(Eps),
257 "fpx" => Ok(Fpx),
258 "giropay" => Ok(Giropay),
259 "grabpay" => Ok(Grabpay),
260 "ideal" => Ok(Ideal),
261 "jp_credit_transfer" => Ok(JpCreditTransfer),
262 "kakao_pay" => Ok(KakaoPay),
263 "klarna" => Ok(Klarna),
264 "konbini" => Ok(Konbini),
265 "kr_card" => Ok(KrCard),
266 "link" => Ok(Link),
267 "multibanco" => Ok(Multibanco),
268 "naver_pay" => Ok(NaverPay),
269 "nz_bank_account" => Ok(NzBankAccount),
270 "p24" => Ok(P24),
271 "payco" => Ok(Payco),
272 "paynow" => Ok(Paynow),
273 "paypal" => Ok(Paypal),
274 "promptpay" => Ok(Promptpay),
275 "revolut_pay" => Ok(RevolutPay),
276 "sepa_credit_transfer" => Ok(SepaCreditTransfer),
277 "sepa_debit" => Ok(SepaDebit),
278 "sofort" => Ok(Sofort),
279 "swish" => Ok(Swish),
280 "us_bank_account" => Ok(UsBankAccount),
281 "wechat_pay" => Ok(WechatPay),
282 v => {
283 tracing::warn!(
284 "Unknown value '{}' for enum '{}'",
285 v,
286 "SubscriptionsResourcePaymentSettingsPaymentMethodTypes"
287 );
288 Ok(Unknown(v.to_owned()))
289 }
290 }
291 }
292}
293impl std::fmt::Display for SubscriptionsResourcePaymentSettingsPaymentMethodTypes {
294 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
295 f.write_str(self.as_str())
296 }
297}
298
299impl std::fmt::Debug for SubscriptionsResourcePaymentSettingsPaymentMethodTypes {
300 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
301 f.write_str(self.as_str())
302 }
303}
304#[cfg(feature = "serialize")]
305impl serde::Serialize for SubscriptionsResourcePaymentSettingsPaymentMethodTypes {
306 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
307 where
308 S: serde::Serializer,
309 {
310 serializer.serialize_str(self.as_str())
311 }
312}
313impl miniserde::Deserialize for SubscriptionsResourcePaymentSettingsPaymentMethodTypes {
314 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
315 crate::Place::new(out)
316 }
317}
318
319impl miniserde::de::Visitor
320 for crate::Place<SubscriptionsResourcePaymentSettingsPaymentMethodTypes>
321{
322 fn string(&mut self, s: &str) -> miniserde::Result<()> {
323 use std::str::FromStr;
324 self.out = Some(
325 SubscriptionsResourcePaymentSettingsPaymentMethodTypes::from_str(s)
326 .expect("infallible"),
327 );
328 Ok(())
329 }
330}
331
332stripe_types::impl_from_val_with_from_str!(SubscriptionsResourcePaymentSettingsPaymentMethodTypes);
333#[cfg(feature = "deserialize")]
334impl<'de> serde::Deserialize<'de> for SubscriptionsResourcePaymentSettingsPaymentMethodTypes {
335 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
336 use std::str::FromStr;
337 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
338 Ok(Self::from_str(&s).expect("infallible"))
339 }
340}
341#[derive(Clone, Eq, PartialEq)]
344#[non_exhaustive]
345pub enum SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod {
346 Off,
347 OnSubscription,
348 Unknown(String),
350}
351impl SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod {
352 pub fn as_str(&self) -> &str {
353 use SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod::*;
354 match self {
355 Off => "off",
356 OnSubscription => "on_subscription",
357 Unknown(v) => v,
358 }
359 }
360}
361
362impl std::str::FromStr for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod {
363 type Err = std::convert::Infallible;
364 fn from_str(s: &str) -> Result<Self, Self::Err> {
365 use SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod::*;
366 match s {
367 "off" => Ok(Off),
368 "on_subscription" => Ok(OnSubscription),
369 v => {
370 tracing::warn!(
371 "Unknown value '{}' for enum '{}'",
372 v,
373 "SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod"
374 );
375 Ok(Unknown(v.to_owned()))
376 }
377 }
378 }
379}
380impl std::fmt::Display for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod {
381 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
382 f.write_str(self.as_str())
383 }
384}
385
386impl std::fmt::Debug for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod {
387 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
388 f.write_str(self.as_str())
389 }
390}
391#[cfg(feature = "serialize")]
392impl serde::Serialize for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod {
393 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
394 where
395 S: serde::Serializer,
396 {
397 serializer.serialize_str(self.as_str())
398 }
399}
400impl miniserde::Deserialize for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod {
401 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
402 crate::Place::new(out)
403 }
404}
405
406impl miniserde::de::Visitor
407 for crate::Place<SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod>
408{
409 fn string(&mut self, s: &str) -> miniserde::Result<()> {
410 use std::str::FromStr;
411 self.out = Some(
412 SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod::from_str(s)
413 .expect("infallible"),
414 );
415 Ok(())
416 }
417}
418
419stripe_types::impl_from_val_with_from_str!(
420 SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod
421);
422#[cfg(feature = "deserialize")]
423impl<'de> serde::Deserialize<'de> for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod {
424 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
425 use std::str::FromStr;
426 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
427 Ok(Self::from_str(&s).expect("infallible"))
428 }
429}