1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodDetailsInteracPresent {
5 pub brand: Option<String>,
7 pub cardholder_name: Option<String>,
12 pub country: Option<String>,
15 pub description: Option<String>,
18 pub emv_auth_data: Option<String>,
20 pub exp_month: i64,
22 pub exp_year: i64,
24 pub fingerprint: Option<String>,
30 pub funding: Option<String>,
32 pub generated_card: Option<String>,
35 pub iin: Option<String>,
38 pub issuer: Option<String>,
41 pub last4: Option<String>,
43 pub network: Option<String>,
46 pub network_transaction_id: Option<String>,
50 pub preferred_locales: Option<Vec<String>>,
52 pub read_method: Option<PaymentMethodDetailsInteracPresentReadMethod>,
54 pub receipt: Option<stripe_shared::PaymentMethodDetailsInteracPresentReceipt>,
56}
57#[doc(hidden)]
58pub struct PaymentMethodDetailsInteracPresentBuilder {
59 brand: Option<Option<String>>,
60 cardholder_name: Option<Option<String>>,
61 country: Option<Option<String>>,
62 description: Option<Option<String>>,
63 emv_auth_data: Option<Option<String>>,
64 exp_month: Option<i64>,
65 exp_year: Option<i64>,
66 fingerprint: Option<Option<String>>,
67 funding: Option<Option<String>>,
68 generated_card: Option<Option<String>>,
69 iin: Option<Option<String>>,
70 issuer: Option<Option<String>>,
71 last4: Option<Option<String>>,
72 network: Option<Option<String>>,
73 network_transaction_id: Option<Option<String>>,
74 preferred_locales: Option<Option<Vec<String>>>,
75 read_method: Option<Option<PaymentMethodDetailsInteracPresentReadMethod>>,
76 receipt: Option<Option<stripe_shared::PaymentMethodDetailsInteracPresentReceipt>>,
77}
78
79#[allow(
80 unused_variables,
81 irrefutable_let_patterns,
82 clippy::let_unit_value,
83 clippy::match_single_binding,
84 clippy::single_match
85)]
86const _: () = {
87 use miniserde::de::{Map, Visitor};
88 use miniserde::json::Value;
89 use miniserde::{make_place, Deserialize, Result};
90 use stripe_types::miniserde_helpers::FromValueOpt;
91 use stripe_types::{MapBuilder, ObjectDeser};
92
93 make_place!(Place);
94
95 impl Deserialize for PaymentMethodDetailsInteracPresent {
96 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
97 Place::new(out)
98 }
99 }
100
101 struct Builder<'a> {
102 out: &'a mut Option<PaymentMethodDetailsInteracPresent>,
103 builder: PaymentMethodDetailsInteracPresentBuilder,
104 }
105
106 impl Visitor for Place<PaymentMethodDetailsInteracPresent> {
107 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
108 Ok(Box::new(Builder {
109 out: &mut self.out,
110 builder: PaymentMethodDetailsInteracPresentBuilder::deser_default(),
111 }))
112 }
113 }
114
115 impl MapBuilder for PaymentMethodDetailsInteracPresentBuilder {
116 type Out = PaymentMethodDetailsInteracPresent;
117 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
118 Ok(match k {
119 "brand" => Deserialize::begin(&mut self.brand),
120 "cardholder_name" => Deserialize::begin(&mut self.cardholder_name),
121 "country" => Deserialize::begin(&mut self.country),
122 "description" => Deserialize::begin(&mut self.description),
123 "emv_auth_data" => Deserialize::begin(&mut self.emv_auth_data),
124 "exp_month" => Deserialize::begin(&mut self.exp_month),
125 "exp_year" => Deserialize::begin(&mut self.exp_year),
126 "fingerprint" => Deserialize::begin(&mut self.fingerprint),
127 "funding" => Deserialize::begin(&mut self.funding),
128 "generated_card" => Deserialize::begin(&mut self.generated_card),
129 "iin" => Deserialize::begin(&mut self.iin),
130 "issuer" => Deserialize::begin(&mut self.issuer),
131 "last4" => Deserialize::begin(&mut self.last4),
132 "network" => Deserialize::begin(&mut self.network),
133 "network_transaction_id" => Deserialize::begin(&mut self.network_transaction_id),
134 "preferred_locales" => Deserialize::begin(&mut self.preferred_locales),
135 "read_method" => Deserialize::begin(&mut self.read_method),
136 "receipt" => Deserialize::begin(&mut self.receipt),
137
138 _ => <dyn Visitor>::ignore(),
139 })
140 }
141
142 fn deser_default() -> Self {
143 Self {
144 brand: Deserialize::default(),
145 cardholder_name: Deserialize::default(),
146 country: Deserialize::default(),
147 description: Deserialize::default(),
148 emv_auth_data: Deserialize::default(),
149 exp_month: Deserialize::default(),
150 exp_year: Deserialize::default(),
151 fingerprint: Deserialize::default(),
152 funding: Deserialize::default(),
153 generated_card: Deserialize::default(),
154 iin: Deserialize::default(),
155 issuer: Deserialize::default(),
156 last4: Deserialize::default(),
157 network: Deserialize::default(),
158 network_transaction_id: Deserialize::default(),
159 preferred_locales: Deserialize::default(),
160 read_method: Deserialize::default(),
161 receipt: Deserialize::default(),
162 }
163 }
164
165 fn take_out(&mut self) -> Option<Self::Out> {
166 let (
167 Some(brand),
168 Some(cardholder_name),
169 Some(country),
170 Some(description),
171 Some(emv_auth_data),
172 Some(exp_month),
173 Some(exp_year),
174 Some(fingerprint),
175 Some(funding),
176 Some(generated_card),
177 Some(iin),
178 Some(issuer),
179 Some(last4),
180 Some(network),
181 Some(network_transaction_id),
182 Some(preferred_locales),
183 Some(read_method),
184 Some(receipt),
185 ) = (
186 self.brand.take(),
187 self.cardholder_name.take(),
188 self.country.take(),
189 self.description.take(),
190 self.emv_auth_data.take(),
191 self.exp_month,
192 self.exp_year,
193 self.fingerprint.take(),
194 self.funding.take(),
195 self.generated_card.take(),
196 self.iin.take(),
197 self.issuer.take(),
198 self.last4.take(),
199 self.network.take(),
200 self.network_transaction_id.take(),
201 self.preferred_locales.take(),
202 self.read_method,
203 self.receipt.take(),
204 )
205 else {
206 return None;
207 };
208 Some(Self::Out {
209 brand,
210 cardholder_name,
211 country,
212 description,
213 emv_auth_data,
214 exp_month,
215 exp_year,
216 fingerprint,
217 funding,
218 generated_card,
219 iin,
220 issuer,
221 last4,
222 network,
223 network_transaction_id,
224 preferred_locales,
225 read_method,
226 receipt,
227 })
228 }
229 }
230
231 impl<'a> Map for Builder<'a> {
232 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
233 self.builder.key(k)
234 }
235
236 fn finish(&mut self) -> Result<()> {
237 *self.out = self.builder.take_out();
238 Ok(())
239 }
240 }
241
242 impl ObjectDeser for PaymentMethodDetailsInteracPresent {
243 type Builder = PaymentMethodDetailsInteracPresentBuilder;
244 }
245
246 impl FromValueOpt for PaymentMethodDetailsInteracPresent {
247 fn from_value(v: Value) -> Option<Self> {
248 let Value::Object(obj) = v else {
249 return None;
250 };
251 let mut b = PaymentMethodDetailsInteracPresentBuilder::deser_default();
252 for (k, v) in obj {
253 match k.as_str() {
254 "brand" => b.brand = FromValueOpt::from_value(v),
255 "cardholder_name" => b.cardholder_name = FromValueOpt::from_value(v),
256 "country" => b.country = FromValueOpt::from_value(v),
257 "description" => b.description = FromValueOpt::from_value(v),
258 "emv_auth_data" => b.emv_auth_data = FromValueOpt::from_value(v),
259 "exp_month" => b.exp_month = FromValueOpt::from_value(v),
260 "exp_year" => b.exp_year = FromValueOpt::from_value(v),
261 "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
262 "funding" => b.funding = FromValueOpt::from_value(v),
263 "generated_card" => b.generated_card = FromValueOpt::from_value(v),
264 "iin" => b.iin = FromValueOpt::from_value(v),
265 "issuer" => b.issuer = FromValueOpt::from_value(v),
266 "last4" => b.last4 = FromValueOpt::from_value(v),
267 "network" => b.network = FromValueOpt::from_value(v),
268 "network_transaction_id" => {
269 b.network_transaction_id = FromValueOpt::from_value(v)
270 }
271 "preferred_locales" => b.preferred_locales = FromValueOpt::from_value(v),
272 "read_method" => b.read_method = FromValueOpt::from_value(v),
273 "receipt" => b.receipt = FromValueOpt::from_value(v),
274
275 _ => {}
276 }
277 }
278 b.take_out()
279 }
280 }
281};
282#[derive(Copy, Clone, Eq, PartialEq)]
284pub enum PaymentMethodDetailsInteracPresentReadMethod {
285 ContactEmv,
286 ContactlessEmv,
287 ContactlessMagstripeMode,
288 MagneticStripeFallback,
289 MagneticStripeTrack2,
290}
291impl PaymentMethodDetailsInteracPresentReadMethod {
292 pub fn as_str(self) -> &'static str {
293 use PaymentMethodDetailsInteracPresentReadMethod::*;
294 match self {
295 ContactEmv => "contact_emv",
296 ContactlessEmv => "contactless_emv",
297 ContactlessMagstripeMode => "contactless_magstripe_mode",
298 MagneticStripeFallback => "magnetic_stripe_fallback",
299 MagneticStripeTrack2 => "magnetic_stripe_track2",
300 }
301 }
302}
303
304impl std::str::FromStr for PaymentMethodDetailsInteracPresentReadMethod {
305 type Err = stripe_types::StripeParseError;
306 fn from_str(s: &str) -> Result<Self, Self::Err> {
307 use PaymentMethodDetailsInteracPresentReadMethod::*;
308 match s {
309 "contact_emv" => Ok(ContactEmv),
310 "contactless_emv" => Ok(ContactlessEmv),
311 "contactless_magstripe_mode" => Ok(ContactlessMagstripeMode),
312 "magnetic_stripe_fallback" => Ok(MagneticStripeFallback),
313 "magnetic_stripe_track2" => Ok(MagneticStripeTrack2),
314 _ => Err(stripe_types::StripeParseError),
315 }
316 }
317}
318impl std::fmt::Display for PaymentMethodDetailsInteracPresentReadMethod {
319 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
320 f.write_str(self.as_str())
321 }
322}
323
324impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReadMethod {
325 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
326 f.write_str(self.as_str())
327 }
328}
329#[cfg(feature = "serialize")]
330impl serde::Serialize for PaymentMethodDetailsInteracPresentReadMethod {
331 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
332 where
333 S: serde::Serializer,
334 {
335 serializer.serialize_str(self.as_str())
336 }
337}
338impl miniserde::Deserialize for PaymentMethodDetailsInteracPresentReadMethod {
339 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
340 crate::Place::new(out)
341 }
342}
343
344impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsInteracPresentReadMethod> {
345 fn string(&mut self, s: &str) -> miniserde::Result<()> {
346 use std::str::FromStr;
347 self.out = Some(
348 PaymentMethodDetailsInteracPresentReadMethod::from_str(s)
349 .map_err(|_| miniserde::Error)?,
350 );
351 Ok(())
352 }
353}
354
355stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsInteracPresentReadMethod);
356#[cfg(feature = "deserialize")]
357impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsInteracPresentReadMethod {
358 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
359 use std::str::FromStr;
360 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
361 Self::from_str(&s).map_err(|_| {
362 serde::de::Error::custom(
363 "Unknown value for PaymentMethodDetailsInteracPresentReadMethod",
364 )
365 })
366 }
367}