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