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