1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupIntentPaymentMethodOptionsCard {
5 pub mandate_options: Option<stripe_shared::SetupIntentPaymentMethodOptionsCardMandateOptions>,
7 pub network: Option<SetupIntentPaymentMethodOptionsCardNetwork>,
11 pub request_three_d_secure: Option<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>,
16}
17#[doc(hidden)]
18pub struct SetupIntentPaymentMethodOptionsCardBuilder {
19 mandate_options:
20 Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsCardMandateOptions>>,
21 network: Option<Option<SetupIntentPaymentMethodOptionsCardNetwork>>,
22 request_three_d_secure: Option<Option<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>>,
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 SetupIntentPaymentMethodOptionsCard {
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<SetupIntentPaymentMethodOptionsCard>,
49 builder: SetupIntentPaymentMethodOptionsCardBuilder,
50 }
51
52 impl Visitor for Place<SetupIntentPaymentMethodOptionsCard> {
53 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
54 Ok(Box::new(Builder {
55 out: &mut self.out,
56 builder: SetupIntentPaymentMethodOptionsCardBuilder::deser_default(),
57 }))
58 }
59 }
60
61 impl MapBuilder for SetupIntentPaymentMethodOptionsCardBuilder {
62 type Out = SetupIntentPaymentMethodOptionsCard;
63 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
64 Ok(match k {
65 "mandate_options" => Deserialize::begin(&mut self.mandate_options),
66 "network" => Deserialize::begin(&mut self.network),
67 "request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure),
68 _ => <dyn Visitor>::ignore(),
69 })
70 }
71
72 fn deser_default() -> Self {
73 Self {
74 mandate_options: Deserialize::default(),
75 network: Deserialize::default(),
76 request_three_d_secure: Deserialize::default(),
77 }
78 }
79
80 fn take_out(&mut self) -> Option<Self::Out> {
81 let (Some(mandate_options), Some(network), Some(request_three_d_secure)) = (
82 self.mandate_options.take(),
83 self.network.take(),
84 self.request_three_d_secure.take(),
85 ) else {
86 return None;
87 };
88 Some(Self::Out { mandate_options, network, request_three_d_secure })
89 }
90 }
91
92 impl Map for Builder<'_> {
93 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
94 self.builder.key(k)
95 }
96
97 fn finish(&mut self) -> Result<()> {
98 *self.out = self.builder.take_out();
99 Ok(())
100 }
101 }
102
103 impl ObjectDeser for SetupIntentPaymentMethodOptionsCard {
104 type Builder = SetupIntentPaymentMethodOptionsCardBuilder;
105 }
106
107 impl FromValueOpt for SetupIntentPaymentMethodOptionsCard {
108 fn from_value(v: Value) -> Option<Self> {
109 let Value::Object(obj) = v else {
110 return None;
111 };
112 let mut b = SetupIntentPaymentMethodOptionsCardBuilder::deser_default();
113 for (k, v) in obj {
114 match k.as_str() {
115 "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
116 "network" => b.network = FromValueOpt::from_value(v),
117 "request_three_d_secure" => {
118 b.request_three_d_secure = FromValueOpt::from_value(v)
119 }
120 _ => {}
121 }
122 }
123 b.take_out()
124 }
125 }
126};
127#[derive(Clone, Eq, PartialEq)]
131#[non_exhaustive]
132pub enum SetupIntentPaymentMethodOptionsCardNetwork {
133 Amex,
134 CartesBancaires,
135 Diners,
136 Discover,
137 EftposAu,
138 Girocard,
139 Interac,
140 Jcb,
141 Link,
142 Mastercard,
143 Unionpay,
144 Unknown,
145 Visa,
146 _Unknown(String),
149}
150impl SetupIntentPaymentMethodOptionsCardNetwork {
151 pub fn as_str(&self) -> &str {
152 use SetupIntentPaymentMethodOptionsCardNetwork::*;
153 match self {
154 Amex => "amex",
155 CartesBancaires => "cartes_bancaires",
156 Diners => "diners",
157 Discover => "discover",
158 EftposAu => "eftpos_au",
159 Girocard => "girocard",
160 Interac => "interac",
161 Jcb => "jcb",
162 Link => "link",
163 Mastercard => "mastercard",
164 Unionpay => "unionpay",
165 Unknown => "unknown",
166 Visa => "visa",
167 _Unknown(v) => v,
168 }
169 }
170}
171
172impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardNetwork {
173 type Err = std::convert::Infallible;
174 fn from_str(s: &str) -> Result<Self, Self::Err> {
175 use SetupIntentPaymentMethodOptionsCardNetwork::*;
176 match s {
177 "amex" => Ok(Amex),
178 "cartes_bancaires" => Ok(CartesBancaires),
179 "diners" => Ok(Diners),
180 "discover" => Ok(Discover),
181 "eftpos_au" => Ok(EftposAu),
182 "girocard" => Ok(Girocard),
183 "interac" => Ok(Interac),
184 "jcb" => Ok(Jcb),
185 "link" => Ok(Link),
186 "mastercard" => Ok(Mastercard),
187 "unionpay" => Ok(Unionpay),
188 "unknown" => Ok(Unknown),
189 "visa" => Ok(Visa),
190 v => {
191 tracing::warn!(
192 "Unknown value '{}' for enum '{}'",
193 v,
194 "SetupIntentPaymentMethodOptionsCardNetwork"
195 );
196 Ok(_Unknown(v.to_owned()))
197 }
198 }
199 }
200}
201impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardNetwork {
202 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
203 f.write_str(self.as_str())
204 }
205}
206
207impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardNetwork {
208 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
209 f.write_str(self.as_str())
210 }
211}
212#[cfg(feature = "serialize")]
213impl serde::Serialize for SetupIntentPaymentMethodOptionsCardNetwork {
214 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
215 where
216 S: serde::Serializer,
217 {
218 serializer.serialize_str(self.as_str())
219 }
220}
221impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardNetwork {
222 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
223 crate::Place::new(out)
224 }
225}
226
227impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsCardNetwork> {
228 fn string(&mut self, s: &str) -> miniserde::Result<()> {
229 use std::str::FromStr;
230 self.out =
231 Some(SetupIntentPaymentMethodOptionsCardNetwork::from_str(s).expect("infallible"));
232 Ok(())
233 }
234}
235
236stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardNetwork);
237#[cfg(feature = "deserialize")]
238impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardNetwork {
239 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
240 use std::str::FromStr;
241 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
242 Ok(Self::from_str(&s).expect("infallible"))
243 }
244}
245#[derive(Clone, Eq, PartialEq)]
250#[non_exhaustive]
251pub enum SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
252 Any,
253 Automatic,
254 Challenge,
255 Unknown(String),
257}
258impl SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
259 pub fn as_str(&self) -> &str {
260 use SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::*;
261 match self {
262 Any => "any",
263 Automatic => "automatic",
264 Challenge => "challenge",
265 Unknown(v) => v,
266 }
267 }
268}
269
270impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
271 type Err = std::convert::Infallible;
272 fn from_str(s: &str) -> Result<Self, Self::Err> {
273 use SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::*;
274 match s {
275 "any" => Ok(Any),
276 "automatic" => Ok(Automatic),
277 "challenge" => Ok(Challenge),
278 v => {
279 tracing::warn!(
280 "Unknown value '{}' for enum '{}'",
281 v,
282 "SetupIntentPaymentMethodOptionsCardRequestThreeDSecure"
283 );
284 Ok(Unknown(v.to_owned()))
285 }
286 }
287 }
288}
289impl std::fmt::Display for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
290 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
291 f.write_str(self.as_str())
292 }
293}
294
295impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
296 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
297 f.write_str(self.as_str())
298 }
299}
300#[cfg(feature = "serialize")]
301impl serde::Serialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
302 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
303 where
304 S: serde::Serializer,
305 {
306 serializer.serialize_str(self.as_str())
307 }
308}
309impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
310 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
311 crate::Place::new(out)
312 }
313}
314
315impl miniserde::de::Visitor
316 for crate::Place<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>
317{
318 fn string(&mut self, s: &str) -> miniserde::Result<()> {
319 use std::str::FromStr;
320 self.out = Some(
321 SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::from_str(s)
322 .expect("infallible"),
323 );
324 Ok(())
325 }
326}
327
328stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardRequestThreeDSecure);
329#[cfg(feature = "deserialize")]
330impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure {
331 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
332 use std::str::FromStr;
333 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
334 Ok(Self::from_str(&s).expect("infallible"))
335 }
336}