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.take(),
111                self.address_postal_code_check.take(),
112                self.authentication_exemption.take(),
113                self.cvc_check.take(),
114                self.expiry_check.take(),
115                self.postal_code.take(),
116                self.three_d_secure.take(),
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(Clone, Eq, PartialEq)]
176#[non_exhaustive]
177pub enum IssuingAuthorizationVerificationDataAddressLine1Check {
178    Match,
179    Mismatch,
180    NotProvided,
181    /// An unrecognized value from Stripe. Should not be used as a request parameter.
182    Unknown(String),
183}
184impl IssuingAuthorizationVerificationDataAddressLine1Check {
185    pub fn as_str(&self) -> &str {
186        use IssuingAuthorizationVerificationDataAddressLine1Check::*;
187        match self {
188            Match => "match",
189            Mismatch => "mismatch",
190            NotProvided => "not_provided",
191            Unknown(v) => v,
192        }
193    }
194}
195
196impl std::str::FromStr for IssuingAuthorizationVerificationDataAddressLine1Check {
197    type Err = std::convert::Infallible;
198    fn from_str(s: &str) -> Result<Self, Self::Err> {
199        use IssuingAuthorizationVerificationDataAddressLine1Check::*;
200        match s {
201            "match" => Ok(Match),
202            "mismatch" => Ok(Mismatch),
203            "not_provided" => Ok(NotProvided),
204            v => {
205                tracing::warn!(
206                    "Unknown value '{}' for enum '{}'",
207                    v,
208                    "IssuingAuthorizationVerificationDataAddressLine1Check"
209                );
210                Ok(Unknown(v.to_owned()))
211            }
212        }
213    }
214}
215impl std::fmt::Display for IssuingAuthorizationVerificationDataAddressLine1Check {
216    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
217        f.write_str(self.as_str())
218    }
219}
220
221impl std::fmt::Debug for IssuingAuthorizationVerificationDataAddressLine1Check {
222    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
223        f.write_str(self.as_str())
224    }
225}
226#[cfg(feature = "serialize")]
227impl serde::Serialize for IssuingAuthorizationVerificationDataAddressLine1Check {
228    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
229    where
230        S: serde::Serializer,
231    {
232        serializer.serialize_str(self.as_str())
233    }
234}
235impl miniserde::Deserialize for IssuingAuthorizationVerificationDataAddressLine1Check {
236    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
237        crate::Place::new(out)
238    }
239}
240
241impl miniserde::de::Visitor
242    for crate::Place<IssuingAuthorizationVerificationDataAddressLine1Check>
243{
244    fn string(&mut self, s: &str) -> miniserde::Result<()> {
245        use std::str::FromStr;
246        self.out = Some(
247            IssuingAuthorizationVerificationDataAddressLine1Check::from_str(s).expect("infallible"),
248        );
249        Ok(())
250    }
251}
252
253stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataAddressLine1Check);
254#[cfg(feature = "deserialize")]
255impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataAddressLine1Check {
256    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
257        use std::str::FromStr;
258        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
259        Ok(Self::from_str(&s).expect("infallible"))
260    }
261}
262/// Whether the cardholder provided a postal code and if it matched the cardholder’s `billing.address.postal_code`.
263#[derive(Clone, Eq, PartialEq)]
264#[non_exhaustive]
265pub enum IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
266    Match,
267    Mismatch,
268    NotProvided,
269    /// An unrecognized value from Stripe. Should not be used as a request parameter.
270    Unknown(String),
271}
272impl IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
273    pub fn as_str(&self) -> &str {
274        use IssuingAuthorizationVerificationDataAddressPostalCodeCheck::*;
275        match self {
276            Match => "match",
277            Mismatch => "mismatch",
278            NotProvided => "not_provided",
279            Unknown(v) => v,
280        }
281    }
282}
283
284impl std::str::FromStr for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
285    type Err = std::convert::Infallible;
286    fn from_str(s: &str) -> Result<Self, Self::Err> {
287        use IssuingAuthorizationVerificationDataAddressPostalCodeCheck::*;
288        match s {
289            "match" => Ok(Match),
290            "mismatch" => Ok(Mismatch),
291            "not_provided" => Ok(NotProvided),
292            v => {
293                tracing::warn!(
294                    "Unknown value '{}' for enum '{}'",
295                    v,
296                    "IssuingAuthorizationVerificationDataAddressPostalCodeCheck"
297                );
298                Ok(Unknown(v.to_owned()))
299            }
300        }
301    }
302}
303impl std::fmt::Display for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
304    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
305        f.write_str(self.as_str())
306    }
307}
308
309impl std::fmt::Debug for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
310    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
311        f.write_str(self.as_str())
312    }
313}
314#[cfg(feature = "serialize")]
315impl serde::Serialize for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
316    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
317    where
318        S: serde::Serializer,
319    {
320        serializer.serialize_str(self.as_str())
321    }
322}
323impl miniserde::Deserialize for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
324    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
325        crate::Place::new(out)
326    }
327}
328
329impl miniserde::de::Visitor
330    for crate::Place<IssuingAuthorizationVerificationDataAddressPostalCodeCheck>
331{
332    fn string(&mut self, s: &str) -> miniserde::Result<()> {
333        use std::str::FromStr;
334        self.out = Some(
335            IssuingAuthorizationVerificationDataAddressPostalCodeCheck::from_str(s)
336                .expect("infallible"),
337        );
338        Ok(())
339    }
340}
341
342stripe_types::impl_from_val_with_from_str!(
343    IssuingAuthorizationVerificationDataAddressPostalCodeCheck
344);
345#[cfg(feature = "deserialize")]
346impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataAddressPostalCodeCheck {
347    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
348        use std::str::FromStr;
349        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
350        Ok(Self::from_str(&s).expect("infallible"))
351    }
352}
353/// Whether the cardholder provided a CVC and if it matched Stripe’s record.
354#[derive(Clone, Eq, PartialEq)]
355#[non_exhaustive]
356pub enum IssuingAuthorizationVerificationDataCvcCheck {
357    Match,
358    Mismatch,
359    NotProvided,
360    /// An unrecognized value from Stripe. Should not be used as a request parameter.
361    Unknown(String),
362}
363impl IssuingAuthorizationVerificationDataCvcCheck {
364    pub fn as_str(&self) -> &str {
365        use IssuingAuthorizationVerificationDataCvcCheck::*;
366        match self {
367            Match => "match",
368            Mismatch => "mismatch",
369            NotProvided => "not_provided",
370            Unknown(v) => v,
371        }
372    }
373}
374
375impl std::str::FromStr for IssuingAuthorizationVerificationDataCvcCheck {
376    type Err = std::convert::Infallible;
377    fn from_str(s: &str) -> Result<Self, Self::Err> {
378        use IssuingAuthorizationVerificationDataCvcCheck::*;
379        match s {
380            "match" => Ok(Match),
381            "mismatch" => Ok(Mismatch),
382            "not_provided" => Ok(NotProvided),
383            v => {
384                tracing::warn!(
385                    "Unknown value '{}' for enum '{}'",
386                    v,
387                    "IssuingAuthorizationVerificationDataCvcCheck"
388                );
389                Ok(Unknown(v.to_owned()))
390            }
391        }
392    }
393}
394impl std::fmt::Display for IssuingAuthorizationVerificationDataCvcCheck {
395    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
396        f.write_str(self.as_str())
397    }
398}
399
400impl std::fmt::Debug for IssuingAuthorizationVerificationDataCvcCheck {
401    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
402        f.write_str(self.as_str())
403    }
404}
405#[cfg(feature = "serialize")]
406impl serde::Serialize for IssuingAuthorizationVerificationDataCvcCheck {
407    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
408    where
409        S: serde::Serializer,
410    {
411        serializer.serialize_str(self.as_str())
412    }
413}
414impl miniserde::Deserialize for IssuingAuthorizationVerificationDataCvcCheck {
415    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
416        crate::Place::new(out)
417    }
418}
419
420impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationVerificationDataCvcCheck> {
421    fn string(&mut self, s: &str) -> miniserde::Result<()> {
422        use std::str::FromStr;
423        self.out =
424            Some(IssuingAuthorizationVerificationDataCvcCheck::from_str(s).expect("infallible"));
425        Ok(())
426    }
427}
428
429stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataCvcCheck);
430#[cfg(feature = "deserialize")]
431impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataCvcCheck {
432    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
433        use std::str::FromStr;
434        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
435        Ok(Self::from_str(&s).expect("infallible"))
436    }
437}
438/// Whether the cardholder provided an expiry date and if it matched Stripe’s record.
439#[derive(Clone, Eq, PartialEq)]
440#[non_exhaustive]
441pub enum IssuingAuthorizationVerificationDataExpiryCheck {
442    Match,
443    Mismatch,
444    NotProvided,
445    /// An unrecognized value from Stripe. Should not be used as a request parameter.
446    Unknown(String),
447}
448impl IssuingAuthorizationVerificationDataExpiryCheck {
449    pub fn as_str(&self) -> &str {
450        use IssuingAuthorizationVerificationDataExpiryCheck::*;
451        match self {
452            Match => "match",
453            Mismatch => "mismatch",
454            NotProvided => "not_provided",
455            Unknown(v) => v,
456        }
457    }
458}
459
460impl std::str::FromStr for IssuingAuthorizationVerificationDataExpiryCheck {
461    type Err = std::convert::Infallible;
462    fn from_str(s: &str) -> Result<Self, Self::Err> {
463        use IssuingAuthorizationVerificationDataExpiryCheck::*;
464        match s {
465            "match" => Ok(Match),
466            "mismatch" => Ok(Mismatch),
467            "not_provided" => Ok(NotProvided),
468            v => {
469                tracing::warn!(
470                    "Unknown value '{}' for enum '{}'",
471                    v,
472                    "IssuingAuthorizationVerificationDataExpiryCheck"
473                );
474                Ok(Unknown(v.to_owned()))
475            }
476        }
477    }
478}
479impl std::fmt::Display for IssuingAuthorizationVerificationDataExpiryCheck {
480    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
481        f.write_str(self.as_str())
482    }
483}
484
485impl std::fmt::Debug for IssuingAuthorizationVerificationDataExpiryCheck {
486    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
487        f.write_str(self.as_str())
488    }
489}
490#[cfg(feature = "serialize")]
491impl serde::Serialize for IssuingAuthorizationVerificationDataExpiryCheck {
492    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
493    where
494        S: serde::Serializer,
495    {
496        serializer.serialize_str(self.as_str())
497    }
498}
499impl miniserde::Deserialize for IssuingAuthorizationVerificationDataExpiryCheck {
500    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
501        crate::Place::new(out)
502    }
503}
504
505impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationVerificationDataExpiryCheck> {
506    fn string(&mut self, s: &str) -> miniserde::Result<()> {
507        use std::str::FromStr;
508        self.out =
509            Some(IssuingAuthorizationVerificationDataExpiryCheck::from_str(s).expect("infallible"));
510        Ok(())
511    }
512}
513
514stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataExpiryCheck);
515#[cfg(feature = "deserialize")]
516impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataExpiryCheck {
517    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
518        use std::str::FromStr;
519        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
520        Ok(Self::from_str(&s).expect("infallible"))
521    }
522}