1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentPaymentMethodOptionsAcssDebit {
5 pub mandate_options:
6 Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>,
7 pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>,
16 pub target_date: Option<String>,
20 pub verification_method: Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>,
22}
23#[doc(hidden)]
24pub struct PaymentIntentPaymentMethodOptionsAcssDebitBuilder {
25 mandate_options:
26 Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>>,
27 setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>>,
28 target_date: Option<Option<String>>,
29 verification_method:
30 Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>>,
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 PaymentIntentPaymentMethodOptionsAcssDebit {
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<PaymentIntentPaymentMethodOptionsAcssDebit>,
57 builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder,
58 }
59
60 impl Visitor for Place<PaymentIntentPaymentMethodOptionsAcssDebit> {
61 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
62 Ok(Box::new(Builder {
63 out: &mut self.out,
64 builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default(),
65 }))
66 }
67 }
68
69 impl MapBuilder for PaymentIntentPaymentMethodOptionsAcssDebitBuilder {
70 type Out = PaymentIntentPaymentMethodOptionsAcssDebit;
71 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72 Ok(match k {
73 "mandate_options" => Deserialize::begin(&mut self.mandate_options),
74 "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
75 "target_date" => Deserialize::begin(&mut self.target_date),
76 "verification_method" => Deserialize::begin(&mut self.verification_method),
77 _ => <dyn Visitor>::ignore(),
78 })
79 }
80
81 fn deser_default() -> Self {
82 Self {
83 mandate_options: Deserialize::default(),
84 setup_future_usage: Deserialize::default(),
85 target_date: Deserialize::default(),
86 verification_method: Deserialize::default(),
87 }
88 }
89
90 fn take_out(&mut self) -> Option<Self::Out> {
91 let (
92 Some(mandate_options),
93 Some(setup_future_usage),
94 Some(target_date),
95 Some(verification_method),
96 ) = (
97 self.mandate_options.take(),
98 self.setup_future_usage,
99 self.target_date.take(),
100 self.verification_method,
101 )
102 else {
103 return None;
104 };
105 Some(Self::Out {
106 mandate_options,
107 setup_future_usage,
108 target_date,
109 verification_method,
110 })
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 PaymentIntentPaymentMethodOptionsAcssDebit {
126 type Builder = PaymentIntentPaymentMethodOptionsAcssDebitBuilder;
127 }
128
129 impl FromValueOpt for PaymentIntentPaymentMethodOptionsAcssDebit {
130 fn from_value(v: Value) -> Option<Self> {
131 let Value::Object(obj) = v else {
132 return None;
133 };
134 let mut b = PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default();
135 for (k, v) in obj {
136 match k.as_str() {
137 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
138 "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
139 "target_date" => b.target_date = FromValueOpt::from_value(v),
140 "verification_method" => b.verification_method = FromValueOpt::from_value(v),
141 _ => {}
142 }
143 }
144 b.take_out()
145 }
146 }
147};
148#[derive(Copy, Clone, Eq, PartialEq)]
157pub enum PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
158 None,
159 OffSession,
160 OnSession,
161}
162impl PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
163 pub fn as_str(self) -> &'static str {
164 use PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::*;
165 match self {
166 None => "none",
167 OffSession => "off_session",
168 OnSession => "on_session",
169 }
170 }
171}
172
173impl std::str::FromStr for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
174 type Err = stripe_types::StripeParseError;
175 fn from_str(s: &str) -> Result<Self, Self::Err> {
176 use PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::*;
177 match s {
178 "none" => Ok(None),
179 "off_session" => Ok(OffSession),
180 "on_session" => Ok(OnSession),
181 _ => Err(stripe_types::StripeParseError),
182 }
183 }
184}
185impl std::fmt::Display for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
186 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
187 f.write_str(self.as_str())
188 }
189}
190
191impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
192 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
193 f.write_str(self.as_str())
194 }
195}
196#[cfg(feature = "serialize")]
197impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
198 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
199 where
200 S: serde::Serializer,
201 {
202 serializer.serialize_str(self.as_str())
203 }
204}
205impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
206 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
207 crate::Place::new(out)
208 }
209}
210
211impl miniserde::de::Visitor
212 for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>
213{
214 fn string(&mut self, s: &str) -> miniserde::Result<()> {
215 use std::str::FromStr;
216 self.out = Some(
217 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::from_str(s)
218 .map_err(|_| miniserde::Error)?,
219 );
220 Ok(())
221 }
222}
223
224stripe_types::impl_from_val_with_from_str!(
225 PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage
226);
227#[cfg(feature = "deserialize")]
228impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage {
229 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
230 use std::str::FromStr;
231 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
232 Self::from_str(&s).map_err(|_| {
233 serde::de::Error::custom(
234 "Unknown value for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage",
235 )
236 })
237 }
238}
239#[derive(Copy, Clone, Eq, PartialEq)]
241pub enum PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
242 Automatic,
243 Instant,
244 Microdeposits,
245}
246impl PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
247 pub fn as_str(self) -> &'static str {
248 use PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
249 match self {
250 Automatic => "automatic",
251 Instant => "instant",
252 Microdeposits => "microdeposits",
253 }
254 }
255}
256
257impl std::str::FromStr for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
258 type Err = stripe_types::StripeParseError;
259 fn from_str(s: &str) -> Result<Self, Self::Err> {
260 use PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::*;
261 match s {
262 "automatic" => Ok(Automatic),
263 "instant" => Ok(Instant),
264 "microdeposits" => Ok(Microdeposits),
265 _ => Err(stripe_types::StripeParseError),
266 }
267 }
268}
269impl std::fmt::Display for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
270 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
271 f.write_str(self.as_str())
272 }
273}
274
275impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
276 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
277 f.write_str(self.as_str())
278 }
279}
280#[cfg(feature = "serialize")]
281impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
282 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
283 where
284 S: serde::Serializer,
285 {
286 serializer.serialize_str(self.as_str())
287 }
288}
289impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
290 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
291 crate::Place::new(out)
292 }
293}
294
295impl miniserde::de::Visitor
296 for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>
297{
298 fn string(&mut self, s: &str) -> miniserde::Result<()> {
299 use std::str::FromStr;
300 self.out = Some(
301 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s)
302 .map_err(|_| miniserde::Error)?,
303 );
304 Ok(())
305 }
306}
307
308stripe_types::impl_from_val_with_from_str!(
309 PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod
310);
311#[cfg(feature = "deserialize")]
312impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod {
313 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
314 use std::str::FromStr;
315 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
316 Self::from_str(&s).map_err(|_| {
317 serde::de::Error::custom(
318 "Unknown value for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod",
319 )
320 })
321 }
322}