stripe_shared/
issuing_authorization_verification_data.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingAuthorizationVerificationData {
5    /// Whether the cardholder provided an address first line and if it matched the cardholder’s `billing.address.line1`.
6    pub address_line1_check: IssuingAuthorizationVerificationDataAddressLine1Check,
7    /// Whether the cardholder provided a postal code and if it matched the cardholder’s `billing.address.postal_code`.
8    pub address_postal_code_check: IssuingAuthorizationVerificationDataAddressPostalCodeCheck,
9    /// The exemption applied to this authorization.
10    pub authentication_exemption:
11        Option<stripe_shared::IssuingAuthorizationAuthenticationExemption>,
12    /// Whether the cardholder provided a CVC and if it matched Stripe’s record.
13    pub cvc_check: IssuingAuthorizationVerificationDataCvcCheck,
14    /// Whether the cardholder provided an expiry date and if it matched Stripe’s record.
15    pub expiry_check: IssuingAuthorizationVerificationDataExpiryCheck,
16    /// The postal code submitted as part of the authorization used for postal code verification.
17    pub postal_code: Option<String>,
18    /// 3D Secure details.
19    pub three_d_secure: Option<stripe_shared::IssuingAuthorizationThreeDSecure>,
20}
21#[doc(hidden)]
22pub struct IssuingAuthorizationVerificationDataBuilder {
23    address_line1_check: Option<IssuingAuthorizationVerificationDataAddressLine1Check>,
24    address_postal_code_check: Option<IssuingAuthorizationVerificationDataAddressPostalCodeCheck>,
25    authentication_exemption:
26        Option<Option<stripe_shared::IssuingAuthorizationAuthenticationExemption>>,
27    cvc_check: Option<IssuingAuthorizationVerificationDataCvcCheck>,
28    expiry_check: Option<IssuingAuthorizationVerificationDataExpiryCheck>,
29    postal_code: Option<Option<String>>,
30    three_d_secure: Option<Option<stripe_shared::IssuingAuthorizationThreeDSecure>>,
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::{make_place, Deserialize, Result};
44    use stripe_types::miniserde_helpers::FromValueOpt;
45    use stripe_types::{MapBuilder, ObjectDeser};
46
47    make_place!(Place);
48
49    impl Deserialize for IssuingAuthorizationVerificationData {
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<IssuingAuthorizationVerificationData>,
57        builder: IssuingAuthorizationVerificationDataBuilder,
58    }
59
60    impl Visitor for Place<IssuingAuthorizationVerificationData> {
61        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
62            Ok(Box::new(Builder {
63                out: &mut self.out,
64                builder: IssuingAuthorizationVerificationDataBuilder::deser_default(),
65            }))
66        }
67    }
68
69    impl MapBuilder for IssuingAuthorizationVerificationDataBuilder {
70        type Out = IssuingAuthorizationVerificationData;
71        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
72            Ok(match k {
73                "address_line1_check" => Deserialize::begin(&mut self.address_line1_check),
74                "address_postal_code_check" => {
75                    Deserialize::begin(&mut self.address_postal_code_check)
76                }
77                "authentication_exemption" => {
78                    Deserialize::begin(&mut self.authentication_exemption)
79                }
80                "cvc_check" => Deserialize::begin(&mut self.cvc_check),
81                "expiry_check" => Deserialize::begin(&mut self.expiry_check),
82                "postal_code" => Deserialize::begin(&mut self.postal_code),
83                "three_d_secure" => Deserialize::begin(&mut self.three_d_secure),
84
85                _ => <dyn Visitor>::ignore(),
86            })
87        }
88
89        fn deser_default() -> Self {
90            Self {
91                address_line1_check: Deserialize::default(),
92                address_postal_code_check: Deserialize::default(),
93                authentication_exemption: Deserialize::default(),
94                cvc_check: Deserialize::default(),
95                expiry_check: Deserialize::default(),
96                postal_code: Deserialize::default(),
97                three_d_secure: Deserialize::default(),
98            }
99        }
100
101        fn take_out(&mut self) -> Option<Self::Out> {
102            let (
103                Some(address_line1_check),
104                Some(address_postal_code_check),
105                Some(authentication_exemption),
106                Some(cvc_check),
107                Some(expiry_check),
108                Some(postal_code),
109                Some(three_d_secure),
110            ) = (
111                self.address_line1_check,
112                self.address_postal_code_check,
113                self.authentication_exemption,
114                self.cvc_check,
115                self.expiry_check,
116                self.postal_code.take(),
117                self.three_d_secure,
118            )
119            else {
120                return None;
121            };
122            Some(Self::Out {
123                address_line1_check,
124                address_postal_code_check,
125                authentication_exemption,
126                cvc_check,
127                expiry_check,
128                postal_code,
129                three_d_secure,
130            })
131        }
132    }
133
134    impl<'a> Map for Builder<'a> {
135        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
136            self.builder.key(k)
137        }
138
139        fn finish(&mut self) -> Result<()> {
140            *self.out = self.builder.take_out();
141            Ok(())
142        }
143    }
144
145    impl ObjectDeser for IssuingAuthorizationVerificationData {
146        type Builder = IssuingAuthorizationVerificationDataBuilder;
147    }
148
149    impl FromValueOpt for IssuingAuthorizationVerificationData {
150        fn from_value(v: Value) -> Option<Self> {
151            let Value::Object(obj) = v else {
152                return None;
153            };
154            let mut b = IssuingAuthorizationVerificationDataBuilder::deser_default();
155            for (k, v) in obj {
156                match k.as_str() {
157                    "address_line1_check" => b.address_line1_check = FromValueOpt::from_value(v),
158                    "address_postal_code_check" => {
159                        b.address_postal_code_check = FromValueOpt::from_value(v)
160                    }
161                    "authentication_exemption" => {
162                        b.authentication_exemption = FromValueOpt::from_value(v)
163                    }
164                    "cvc_check" => b.cvc_check = FromValueOpt::from_value(v),
165                    "expiry_check" => b.expiry_check = FromValueOpt::from_value(v),
166                    "postal_code" => b.postal_code = FromValueOpt::from_value(v),
167                    "three_d_secure" => b.three_d_secure = FromValueOpt::from_value(v),
168
169                    _ => {}
170                }
171            }
172            b.take_out()
173        }
174    }
175};
176/// Whether the cardholder provided an address first line and if it matched the cardholder’s `billing.address.line1`.
177#[derive(Copy, Clone, Eq, PartialEq)]
178pub enum IssuingAuthorizationVerificationDataAddressLine1Check {
179    Match,
180    Mismatch,
181    NotProvided,
182}
183impl IssuingAuthorizationVerificationDataAddressLine1Check {
184    pub fn as_str(self) -> &'static str {
185        use IssuingAuthorizationVerificationDataAddressLine1Check::*;
186        match self {
187            Match => "match",
188            Mismatch => "mismatch",
189            NotProvided => "not_provided",
190        }
191    }
192}
193
194impl std::str::FromStr for IssuingAuthorizationVerificationDataAddressLine1Check {
195    type Err = stripe_types::StripeParseError;
196    fn from_str(s: &str) -> Result<Self, Self::Err> {
197        use IssuingAuthorizationVerificationDataAddressLine1Check::*;
198        match s {
199            "match" => Ok(Match),
200            "mismatch" => Ok(Mismatch),
201            "not_provided" => Ok(NotProvided),
202            _ => Err(stripe_types::StripeParseError),
203        }
204    }
205}
206impl std::fmt::Display for IssuingAuthorizationVerificationDataAddressLine1Check {
207    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
208        f.write_str(self.as_str())
209    }
210}
211
212impl std::fmt::Debug for IssuingAuthorizationVerificationDataAddressLine1Check {
213    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
214        f.write_str(self.as_str())
215    }
216}
217#[cfg(feature = "serialize")]
218impl serde::Serialize for IssuingAuthorizationVerificationDataAddressLine1Check {
219    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
220    where
221        S: serde::Serializer,
222    {
223        serializer.serialize_str(self.as_str())
224    }
225}
226impl miniserde::Deserialize for IssuingAuthorizationVerificationDataAddressLine1Check {
227    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
228        crate::Place::new(out)
229    }
230}
231
232impl miniserde::de::Visitor
233    for crate::Place<IssuingAuthorizationVerificationDataAddressLine1Check>
234{
235    fn string(&mut self, s: &str) -> miniserde::Result<()> {
236        use std::str::FromStr;
237        self.out = Some(
238            IssuingAuthorizationVerificationDataAddressLine1Check::from_str(s)
239                .map_err(|_| miniserde::Error)?,
240        );
241        Ok(())
242    }
243}
244
245stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataAddressLine1Check);
246#[cfg(feature = "deserialize")]
247impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataAddressLine1Check {
248    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
249        use std::str::FromStr;
250        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
251        Self::from_str(&s).map_err(|_| {
252            serde::de::Error::custom(
253                "Unknown value for IssuingAuthorizationVerificationDataAddressLine1Check",
254            )
255        })
256    }
257}
258/// Whether the cardholder provided a postal code and if it matched the cardholder’s `billing.address.postal_code`.
259#[derive(Copy, Clone, Eq, PartialEq)]
260pub enum IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
261    Match,
262    Mismatch,
263    NotProvided,
264}
265impl IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
266    pub fn as_str(self) -> &'static str {
267        use IssuingAuthorizationVerificationDataAddressPostalCodeCheck::*;
268        match self {
269            Match => "match",
270            Mismatch => "mismatch",
271            NotProvided => "not_provided",
272        }
273    }
274}
275
276impl std::str::FromStr for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
277    type Err = stripe_types::StripeParseError;
278    fn from_str(s: &str) -> Result<Self, Self::Err> {
279        use IssuingAuthorizationVerificationDataAddressPostalCodeCheck::*;
280        match s {
281            "match" => Ok(Match),
282            "mismatch" => Ok(Mismatch),
283            "not_provided" => Ok(NotProvided),
284            _ => Err(stripe_types::StripeParseError),
285        }
286    }
287}
288impl std::fmt::Display for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
289    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
290        f.write_str(self.as_str())
291    }
292}
293
294impl std::fmt::Debug for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
295    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
296        f.write_str(self.as_str())
297    }
298}
299#[cfg(feature = "serialize")]
300impl serde::Serialize for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
301    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
302    where
303        S: serde::Serializer,
304    {
305        serializer.serialize_str(self.as_str())
306    }
307}
308impl miniserde::Deserialize for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
309    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
310        crate::Place::new(out)
311    }
312}
313
314impl miniserde::de::Visitor
315    for crate::Place<IssuingAuthorizationVerificationDataAddressPostalCodeCheck>
316{
317    fn string(&mut self, s: &str) -> miniserde::Result<()> {
318        use std::str::FromStr;
319        self.out = Some(
320            IssuingAuthorizationVerificationDataAddressPostalCodeCheck::from_str(s)
321                .map_err(|_| miniserde::Error)?,
322        );
323        Ok(())
324    }
325}
326
327stripe_types::impl_from_val_with_from_str!(
328    IssuingAuthorizationVerificationDataAddressPostalCodeCheck
329);
330#[cfg(feature = "deserialize")]
331impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
332    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
333        use std::str::FromStr;
334        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
335        Self::from_str(&s).map_err(|_| {
336            serde::de::Error::custom(
337                "Unknown value for IssuingAuthorizationVerificationDataAddressPostalCodeCheck",
338            )
339        })
340    }
341}
342/// Whether the cardholder provided a CVC and if it matched Stripe’s record.
343#[derive(Copy, Clone, Eq, PartialEq)]
344pub enum IssuingAuthorizationVerificationDataCvcCheck {
345    Match,
346    Mismatch,
347    NotProvided,
348}
349impl IssuingAuthorizationVerificationDataCvcCheck {
350    pub fn as_str(self) -> &'static str {
351        use IssuingAuthorizationVerificationDataCvcCheck::*;
352        match self {
353            Match => "match",
354            Mismatch => "mismatch",
355            NotProvided => "not_provided",
356        }
357    }
358}
359
360impl std::str::FromStr for IssuingAuthorizationVerificationDataCvcCheck {
361    type Err = stripe_types::StripeParseError;
362    fn from_str(s: &str) -> Result<Self, Self::Err> {
363        use IssuingAuthorizationVerificationDataCvcCheck::*;
364        match s {
365            "match" => Ok(Match),
366            "mismatch" => Ok(Mismatch),
367            "not_provided" => Ok(NotProvided),
368            _ => Err(stripe_types::StripeParseError),
369        }
370    }
371}
372impl std::fmt::Display for IssuingAuthorizationVerificationDataCvcCheck {
373    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
374        f.write_str(self.as_str())
375    }
376}
377
378impl std::fmt::Debug for IssuingAuthorizationVerificationDataCvcCheck {
379    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
380        f.write_str(self.as_str())
381    }
382}
383#[cfg(feature = "serialize")]
384impl serde::Serialize for IssuingAuthorizationVerificationDataCvcCheck {
385    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
386    where
387        S: serde::Serializer,
388    {
389        serializer.serialize_str(self.as_str())
390    }
391}
392impl miniserde::Deserialize for IssuingAuthorizationVerificationDataCvcCheck {
393    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
394        crate::Place::new(out)
395    }
396}
397
398impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationVerificationDataCvcCheck> {
399    fn string(&mut self, s: &str) -> miniserde::Result<()> {
400        use std::str::FromStr;
401        self.out = Some(
402            IssuingAuthorizationVerificationDataCvcCheck::from_str(s)
403                .map_err(|_| miniserde::Error)?,
404        );
405        Ok(())
406    }
407}
408
409stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataCvcCheck);
410#[cfg(feature = "deserialize")]
411impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataCvcCheck {
412    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
413        use std::str::FromStr;
414        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
415        Self::from_str(&s).map_err(|_| {
416            serde::de::Error::custom(
417                "Unknown value for IssuingAuthorizationVerificationDataCvcCheck",
418            )
419        })
420    }
421}
422/// Whether the cardholder provided an expiry date and if it matched Stripe’s record.
423#[derive(Copy, Clone, Eq, PartialEq)]
424pub enum IssuingAuthorizationVerificationDataExpiryCheck {
425    Match,
426    Mismatch,
427    NotProvided,
428}
429impl IssuingAuthorizationVerificationDataExpiryCheck {
430    pub fn as_str(self) -> &'static str {
431        use IssuingAuthorizationVerificationDataExpiryCheck::*;
432        match self {
433            Match => "match",
434            Mismatch => "mismatch",
435            NotProvided => "not_provided",
436        }
437    }
438}
439
440impl std::str::FromStr for IssuingAuthorizationVerificationDataExpiryCheck {
441    type Err = stripe_types::StripeParseError;
442    fn from_str(s: &str) -> Result<Self, Self::Err> {
443        use IssuingAuthorizationVerificationDataExpiryCheck::*;
444        match s {
445            "match" => Ok(Match),
446            "mismatch" => Ok(Mismatch),
447            "not_provided" => Ok(NotProvided),
448            _ => Err(stripe_types::StripeParseError),
449        }
450    }
451}
452impl std::fmt::Display for IssuingAuthorizationVerificationDataExpiryCheck {
453    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
454        f.write_str(self.as_str())
455    }
456}
457
458impl std::fmt::Debug for IssuingAuthorizationVerificationDataExpiryCheck {
459    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
460        f.write_str(self.as_str())
461    }
462}
463#[cfg(feature = "serialize")]
464impl serde::Serialize for IssuingAuthorizationVerificationDataExpiryCheck {
465    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
466    where
467        S: serde::Serializer,
468    {
469        serializer.serialize_str(self.as_str())
470    }
471}
472impl miniserde::Deserialize for IssuingAuthorizationVerificationDataExpiryCheck {
473    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
474        crate::Place::new(out)
475    }
476}
477
478impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationVerificationDataExpiryCheck> {
479    fn string(&mut self, s: &str) -> miniserde::Result<()> {
480        use std::str::FromStr;
481        self.out = Some(
482            IssuingAuthorizationVerificationDataExpiryCheck::from_str(s)
483                .map_err(|_| miniserde::Error)?,
484        );
485        Ok(())
486    }
487}
488
489stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataExpiryCheck);
490#[cfg(feature = "deserialize")]
491impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataExpiryCheck {
492    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
493        use std::str::FromStr;
494        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
495        Self::from_str(&s).map_err(|_| {
496            serde::de::Error::custom(
497                "Unknown value for IssuingAuthorizationVerificationDataExpiryCheck",
498            )
499        })
500    }
501}