stripe_shared/
three_d_secure_details_charge.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct ThreeDSecureDetailsCharge {
5    /// For authenticated transactions: how the customer was authenticated by
6    /// the issuing bank.
7    pub authentication_flow: Option<ThreeDSecureDetailsChargeAuthenticationFlow>,
8    /// The Electronic Commerce Indicator (ECI). A protocol-level field
9    /// indicating what degree of authentication was performed.
10    pub electronic_commerce_indicator: Option<ThreeDSecureDetailsChargeElectronicCommerceIndicator>,
11    /// The exemption requested via 3DS and accepted by the issuer at authentication time.
12    pub exemption_indicator: Option<ThreeDSecureDetailsChargeExemptionIndicator>,
13    /// Whether Stripe requested the value of `exemption_indicator` in the transaction. This will depend on
14    /// the outcome of Stripe's internal risk assessment.
15    pub exemption_indicator_applied: Option<bool>,
16    /// Indicates the outcome of 3D Secure authentication.
17    pub result: Option<ThreeDSecureDetailsChargeResult>,
18    /// Additional information about why 3D Secure succeeded or failed based
19    /// on the `result`.
20    pub result_reason: Option<ThreeDSecureDetailsChargeResultReason>,
21    /// The 3D Secure 1 XID or 3D Secure 2 Directory Server Transaction ID
22    /// (dsTransId) for this payment.
23    pub transaction_id: Option<String>,
24    /// The version of 3D Secure that was used.
25    pub version: Option<ThreeDSecureDetailsChargeVersion>,
26}
27#[doc(hidden)]
28pub struct ThreeDSecureDetailsChargeBuilder {
29    authentication_flow: Option<Option<ThreeDSecureDetailsChargeAuthenticationFlow>>,
30    electronic_commerce_indicator:
31        Option<Option<ThreeDSecureDetailsChargeElectronicCommerceIndicator>>,
32    exemption_indicator: Option<Option<ThreeDSecureDetailsChargeExemptionIndicator>>,
33    exemption_indicator_applied: Option<Option<bool>>,
34    result: Option<Option<ThreeDSecureDetailsChargeResult>>,
35    result_reason: Option<Option<ThreeDSecureDetailsChargeResultReason>>,
36    transaction_id: Option<Option<String>>,
37    version: Option<Option<ThreeDSecureDetailsChargeVersion>>,
38}
39
40#[allow(
41    unused_variables,
42    irrefutable_let_patterns,
43    clippy::let_unit_value,
44    clippy::match_single_binding,
45    clippy::single_match
46)]
47const _: () = {
48    use miniserde::de::{Map, Visitor};
49    use miniserde::json::Value;
50    use miniserde::{Deserialize, Result, make_place};
51    use stripe_types::miniserde_helpers::FromValueOpt;
52    use stripe_types::{MapBuilder, ObjectDeser};
53
54    make_place!(Place);
55
56    impl Deserialize for ThreeDSecureDetailsCharge {
57        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
58            Place::new(out)
59        }
60    }
61
62    struct Builder<'a> {
63        out: &'a mut Option<ThreeDSecureDetailsCharge>,
64        builder: ThreeDSecureDetailsChargeBuilder,
65    }
66
67    impl Visitor for Place<ThreeDSecureDetailsCharge> {
68        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
69            Ok(Box::new(Builder {
70                out: &mut self.out,
71                builder: ThreeDSecureDetailsChargeBuilder::deser_default(),
72            }))
73        }
74    }
75
76    impl MapBuilder for ThreeDSecureDetailsChargeBuilder {
77        type Out = ThreeDSecureDetailsCharge;
78        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
79            Ok(match k {
80                "authentication_flow" => Deserialize::begin(&mut self.authentication_flow),
81                "electronic_commerce_indicator" => {
82                    Deserialize::begin(&mut self.electronic_commerce_indicator)
83                }
84                "exemption_indicator" => Deserialize::begin(&mut self.exemption_indicator),
85                "exemption_indicator_applied" => {
86                    Deserialize::begin(&mut self.exemption_indicator_applied)
87                }
88                "result" => Deserialize::begin(&mut self.result),
89                "result_reason" => Deserialize::begin(&mut self.result_reason),
90                "transaction_id" => Deserialize::begin(&mut self.transaction_id),
91                "version" => Deserialize::begin(&mut self.version),
92                _ => <dyn Visitor>::ignore(),
93            })
94        }
95
96        fn deser_default() -> Self {
97            Self {
98                authentication_flow: Deserialize::default(),
99                electronic_commerce_indicator: Deserialize::default(),
100                exemption_indicator: Deserialize::default(),
101                exemption_indicator_applied: Deserialize::default(),
102                result: Deserialize::default(),
103                result_reason: Deserialize::default(),
104                transaction_id: Deserialize::default(),
105                version: Deserialize::default(),
106            }
107        }
108
109        fn take_out(&mut self) -> Option<Self::Out> {
110            let (
111                Some(authentication_flow),
112                Some(electronic_commerce_indicator),
113                Some(exemption_indicator),
114                Some(exemption_indicator_applied),
115                Some(result),
116                Some(result_reason),
117                Some(transaction_id),
118                Some(version),
119            ) = (
120                self.authentication_flow.take(),
121                self.electronic_commerce_indicator.take(),
122                self.exemption_indicator.take(),
123                self.exemption_indicator_applied,
124                self.result.take(),
125                self.result_reason.take(),
126                self.transaction_id.take(),
127                self.version.take(),
128            )
129            else {
130                return None;
131            };
132            Some(Self::Out {
133                authentication_flow,
134                electronic_commerce_indicator,
135                exemption_indicator,
136                exemption_indicator_applied,
137                result,
138                result_reason,
139                transaction_id,
140                version,
141            })
142        }
143    }
144
145    impl Map for Builder<'_> {
146        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
147            self.builder.key(k)
148        }
149
150        fn finish(&mut self) -> Result<()> {
151            *self.out = self.builder.take_out();
152            Ok(())
153        }
154    }
155
156    impl ObjectDeser for ThreeDSecureDetailsCharge {
157        type Builder = ThreeDSecureDetailsChargeBuilder;
158    }
159
160    impl FromValueOpt for ThreeDSecureDetailsCharge {
161        fn from_value(v: Value) -> Option<Self> {
162            let Value::Object(obj) = v else {
163                return None;
164            };
165            let mut b = ThreeDSecureDetailsChargeBuilder::deser_default();
166            for (k, v) in obj {
167                match k.as_str() {
168                    "authentication_flow" => b.authentication_flow = FromValueOpt::from_value(v),
169                    "electronic_commerce_indicator" => {
170                        b.electronic_commerce_indicator = FromValueOpt::from_value(v)
171                    }
172                    "exemption_indicator" => b.exemption_indicator = FromValueOpt::from_value(v),
173                    "exemption_indicator_applied" => {
174                        b.exemption_indicator_applied = FromValueOpt::from_value(v)
175                    }
176                    "result" => b.result = FromValueOpt::from_value(v),
177                    "result_reason" => b.result_reason = FromValueOpt::from_value(v),
178                    "transaction_id" => b.transaction_id = FromValueOpt::from_value(v),
179                    "version" => b.version = FromValueOpt::from_value(v),
180                    _ => {}
181                }
182            }
183            b.take_out()
184        }
185    }
186};
187/// For authenticated transactions: how the customer was authenticated by
188/// the issuing bank.
189#[derive(Clone, Eq, PartialEq)]
190#[non_exhaustive]
191pub enum ThreeDSecureDetailsChargeAuthenticationFlow {
192    Challenge,
193    Frictionless,
194    /// An unrecognized value from Stripe. Should not be used as a request parameter.
195    Unknown(String),
196}
197impl ThreeDSecureDetailsChargeAuthenticationFlow {
198    pub fn as_str(&self) -> &str {
199        use ThreeDSecureDetailsChargeAuthenticationFlow::*;
200        match self {
201            Challenge => "challenge",
202            Frictionless => "frictionless",
203            Unknown(v) => v,
204        }
205    }
206}
207
208impl std::str::FromStr for ThreeDSecureDetailsChargeAuthenticationFlow {
209    type Err = std::convert::Infallible;
210    fn from_str(s: &str) -> Result<Self, Self::Err> {
211        use ThreeDSecureDetailsChargeAuthenticationFlow::*;
212        match s {
213            "challenge" => Ok(Challenge),
214            "frictionless" => Ok(Frictionless),
215            v => {
216                tracing::warn!(
217                    "Unknown value '{}' for enum '{}'",
218                    v,
219                    "ThreeDSecureDetailsChargeAuthenticationFlow"
220                );
221                Ok(Unknown(v.to_owned()))
222            }
223        }
224    }
225}
226impl std::fmt::Display for ThreeDSecureDetailsChargeAuthenticationFlow {
227    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
228        f.write_str(self.as_str())
229    }
230}
231
232impl std::fmt::Debug for ThreeDSecureDetailsChargeAuthenticationFlow {
233    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
234        f.write_str(self.as_str())
235    }
236}
237#[cfg(feature = "serialize")]
238impl serde::Serialize for ThreeDSecureDetailsChargeAuthenticationFlow {
239    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
240    where
241        S: serde::Serializer,
242    {
243        serializer.serialize_str(self.as_str())
244    }
245}
246impl miniserde::Deserialize for ThreeDSecureDetailsChargeAuthenticationFlow {
247    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
248        crate::Place::new(out)
249    }
250}
251
252impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeAuthenticationFlow> {
253    fn string(&mut self, s: &str) -> miniserde::Result<()> {
254        use std::str::FromStr;
255        self.out =
256            Some(ThreeDSecureDetailsChargeAuthenticationFlow::from_str(s).expect("infallible"));
257        Ok(())
258    }
259}
260
261stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeAuthenticationFlow);
262#[cfg(feature = "deserialize")]
263impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeAuthenticationFlow {
264    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
265        use std::str::FromStr;
266        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
267        Ok(Self::from_str(&s).expect("infallible"))
268    }
269}
270/// The Electronic Commerce Indicator (ECI). A protocol-level field
271/// indicating what degree of authentication was performed.
272#[derive(Clone, Eq, PartialEq)]
273#[non_exhaustive]
274pub enum ThreeDSecureDetailsChargeElectronicCommerceIndicator {
275    V01,
276    V02,
277    V05,
278    V06,
279    V07,
280    /// An unrecognized value from Stripe. Should not be used as a request parameter.
281    Unknown(String),
282}
283impl ThreeDSecureDetailsChargeElectronicCommerceIndicator {
284    pub fn as_str(&self) -> &str {
285        use ThreeDSecureDetailsChargeElectronicCommerceIndicator::*;
286        match self {
287            V01 => "01",
288            V02 => "02",
289            V05 => "05",
290            V06 => "06",
291            V07 => "07",
292            Unknown(v) => v,
293        }
294    }
295}
296
297impl std::str::FromStr for ThreeDSecureDetailsChargeElectronicCommerceIndicator {
298    type Err = std::convert::Infallible;
299    fn from_str(s: &str) -> Result<Self, Self::Err> {
300        use ThreeDSecureDetailsChargeElectronicCommerceIndicator::*;
301        match s {
302            "01" => Ok(V01),
303            "02" => Ok(V02),
304            "05" => Ok(V05),
305            "06" => Ok(V06),
306            "07" => Ok(V07),
307            v => {
308                tracing::warn!(
309                    "Unknown value '{}' for enum '{}'",
310                    v,
311                    "ThreeDSecureDetailsChargeElectronicCommerceIndicator"
312                );
313                Ok(Unknown(v.to_owned()))
314            }
315        }
316    }
317}
318impl std::fmt::Display for ThreeDSecureDetailsChargeElectronicCommerceIndicator {
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 ThreeDSecureDetailsChargeElectronicCommerceIndicator {
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 ThreeDSecureDetailsChargeElectronicCommerceIndicator {
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 ThreeDSecureDetailsChargeElectronicCommerceIndicator {
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<ThreeDSecureDetailsChargeElectronicCommerceIndicator> {
345    fn string(&mut self, s: &str) -> miniserde::Result<()> {
346        use std::str::FromStr;
347        self.out = Some(
348            ThreeDSecureDetailsChargeElectronicCommerceIndicator::from_str(s).expect("infallible"),
349        );
350        Ok(())
351    }
352}
353
354stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeElectronicCommerceIndicator);
355#[cfg(feature = "deserialize")]
356impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeElectronicCommerceIndicator {
357    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
358        use std::str::FromStr;
359        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
360        Ok(Self::from_str(&s).expect("infallible"))
361    }
362}
363/// The exemption requested via 3DS and accepted by the issuer at authentication time.
364#[derive(Clone, Eq, PartialEq)]
365#[non_exhaustive]
366pub enum ThreeDSecureDetailsChargeExemptionIndicator {
367    LowRisk,
368    None,
369    /// An unrecognized value from Stripe. Should not be used as a request parameter.
370    Unknown(String),
371}
372impl ThreeDSecureDetailsChargeExemptionIndicator {
373    pub fn as_str(&self) -> &str {
374        use ThreeDSecureDetailsChargeExemptionIndicator::*;
375        match self {
376            LowRisk => "low_risk",
377            None => "none",
378            Unknown(v) => v,
379        }
380    }
381}
382
383impl std::str::FromStr for ThreeDSecureDetailsChargeExemptionIndicator {
384    type Err = std::convert::Infallible;
385    fn from_str(s: &str) -> Result<Self, Self::Err> {
386        use ThreeDSecureDetailsChargeExemptionIndicator::*;
387        match s {
388            "low_risk" => Ok(LowRisk),
389            "none" => Ok(None),
390            v => {
391                tracing::warn!(
392                    "Unknown value '{}' for enum '{}'",
393                    v,
394                    "ThreeDSecureDetailsChargeExemptionIndicator"
395                );
396                Ok(Unknown(v.to_owned()))
397            }
398        }
399    }
400}
401impl std::fmt::Display for ThreeDSecureDetailsChargeExemptionIndicator {
402    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
403        f.write_str(self.as_str())
404    }
405}
406
407impl std::fmt::Debug for ThreeDSecureDetailsChargeExemptionIndicator {
408    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
409        f.write_str(self.as_str())
410    }
411}
412#[cfg(feature = "serialize")]
413impl serde::Serialize for ThreeDSecureDetailsChargeExemptionIndicator {
414    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
415    where
416        S: serde::Serializer,
417    {
418        serializer.serialize_str(self.as_str())
419    }
420}
421impl miniserde::Deserialize for ThreeDSecureDetailsChargeExemptionIndicator {
422    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
423        crate::Place::new(out)
424    }
425}
426
427impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeExemptionIndicator> {
428    fn string(&mut self, s: &str) -> miniserde::Result<()> {
429        use std::str::FromStr;
430        self.out =
431            Some(ThreeDSecureDetailsChargeExemptionIndicator::from_str(s).expect("infallible"));
432        Ok(())
433    }
434}
435
436stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeExemptionIndicator);
437#[cfg(feature = "deserialize")]
438impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeExemptionIndicator {
439    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
440        use std::str::FromStr;
441        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
442        Ok(Self::from_str(&s).expect("infallible"))
443    }
444}
445/// Indicates the outcome of 3D Secure authentication.
446#[derive(Clone, Eq, PartialEq)]
447#[non_exhaustive]
448pub enum ThreeDSecureDetailsChargeResult {
449    AttemptAcknowledged,
450    Authenticated,
451    Exempted,
452    Failed,
453    NotSupported,
454    ProcessingError,
455    /// An unrecognized value from Stripe. Should not be used as a request parameter.
456    Unknown(String),
457}
458impl ThreeDSecureDetailsChargeResult {
459    pub fn as_str(&self) -> &str {
460        use ThreeDSecureDetailsChargeResult::*;
461        match self {
462            AttemptAcknowledged => "attempt_acknowledged",
463            Authenticated => "authenticated",
464            Exempted => "exempted",
465            Failed => "failed",
466            NotSupported => "not_supported",
467            ProcessingError => "processing_error",
468            Unknown(v) => v,
469        }
470    }
471}
472
473impl std::str::FromStr for ThreeDSecureDetailsChargeResult {
474    type Err = std::convert::Infallible;
475    fn from_str(s: &str) -> Result<Self, Self::Err> {
476        use ThreeDSecureDetailsChargeResult::*;
477        match s {
478            "attempt_acknowledged" => Ok(AttemptAcknowledged),
479            "authenticated" => Ok(Authenticated),
480            "exempted" => Ok(Exempted),
481            "failed" => Ok(Failed),
482            "not_supported" => Ok(NotSupported),
483            "processing_error" => Ok(ProcessingError),
484            v => {
485                tracing::warn!(
486                    "Unknown value '{}' for enum '{}'",
487                    v,
488                    "ThreeDSecureDetailsChargeResult"
489                );
490                Ok(Unknown(v.to_owned()))
491            }
492        }
493    }
494}
495impl std::fmt::Display for ThreeDSecureDetailsChargeResult {
496    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
497        f.write_str(self.as_str())
498    }
499}
500
501impl std::fmt::Debug for ThreeDSecureDetailsChargeResult {
502    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
503        f.write_str(self.as_str())
504    }
505}
506#[cfg(feature = "serialize")]
507impl serde::Serialize for ThreeDSecureDetailsChargeResult {
508    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
509    where
510        S: serde::Serializer,
511    {
512        serializer.serialize_str(self.as_str())
513    }
514}
515impl miniserde::Deserialize for ThreeDSecureDetailsChargeResult {
516    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
517        crate::Place::new(out)
518    }
519}
520
521impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeResult> {
522    fn string(&mut self, s: &str) -> miniserde::Result<()> {
523        use std::str::FromStr;
524        self.out = Some(ThreeDSecureDetailsChargeResult::from_str(s).expect("infallible"));
525        Ok(())
526    }
527}
528
529stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeResult);
530#[cfg(feature = "deserialize")]
531impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeResult {
532    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
533        use std::str::FromStr;
534        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
535        Ok(Self::from_str(&s).expect("infallible"))
536    }
537}
538/// Additional information about why 3D Secure succeeded or failed based
539/// on the `result`.
540#[derive(Clone, Eq, PartialEq)]
541#[non_exhaustive]
542pub enum ThreeDSecureDetailsChargeResultReason {
543    Abandoned,
544    Bypassed,
545    Canceled,
546    CardNotEnrolled,
547    NetworkNotSupported,
548    ProtocolError,
549    Rejected,
550    /// An unrecognized value from Stripe. Should not be used as a request parameter.
551    Unknown(String),
552}
553impl ThreeDSecureDetailsChargeResultReason {
554    pub fn as_str(&self) -> &str {
555        use ThreeDSecureDetailsChargeResultReason::*;
556        match self {
557            Abandoned => "abandoned",
558            Bypassed => "bypassed",
559            Canceled => "canceled",
560            CardNotEnrolled => "card_not_enrolled",
561            NetworkNotSupported => "network_not_supported",
562            ProtocolError => "protocol_error",
563            Rejected => "rejected",
564            Unknown(v) => v,
565        }
566    }
567}
568
569impl std::str::FromStr for ThreeDSecureDetailsChargeResultReason {
570    type Err = std::convert::Infallible;
571    fn from_str(s: &str) -> Result<Self, Self::Err> {
572        use ThreeDSecureDetailsChargeResultReason::*;
573        match s {
574            "abandoned" => Ok(Abandoned),
575            "bypassed" => Ok(Bypassed),
576            "canceled" => Ok(Canceled),
577            "card_not_enrolled" => Ok(CardNotEnrolled),
578            "network_not_supported" => Ok(NetworkNotSupported),
579            "protocol_error" => Ok(ProtocolError),
580            "rejected" => Ok(Rejected),
581            v => {
582                tracing::warn!(
583                    "Unknown value '{}' for enum '{}'",
584                    v,
585                    "ThreeDSecureDetailsChargeResultReason"
586                );
587                Ok(Unknown(v.to_owned()))
588            }
589        }
590    }
591}
592impl std::fmt::Display for ThreeDSecureDetailsChargeResultReason {
593    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
594        f.write_str(self.as_str())
595    }
596}
597
598impl std::fmt::Debug for ThreeDSecureDetailsChargeResultReason {
599    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
600        f.write_str(self.as_str())
601    }
602}
603#[cfg(feature = "serialize")]
604impl serde::Serialize for ThreeDSecureDetailsChargeResultReason {
605    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
606    where
607        S: serde::Serializer,
608    {
609        serializer.serialize_str(self.as_str())
610    }
611}
612impl miniserde::Deserialize for ThreeDSecureDetailsChargeResultReason {
613    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
614        crate::Place::new(out)
615    }
616}
617
618impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeResultReason> {
619    fn string(&mut self, s: &str) -> miniserde::Result<()> {
620        use std::str::FromStr;
621        self.out = Some(ThreeDSecureDetailsChargeResultReason::from_str(s).expect("infallible"));
622        Ok(())
623    }
624}
625
626stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeResultReason);
627#[cfg(feature = "deserialize")]
628impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeResultReason {
629    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
630        use std::str::FromStr;
631        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
632        Ok(Self::from_str(&s).expect("infallible"))
633    }
634}
635/// The version of 3D Secure that was used.
636#[derive(Clone, Eq, PartialEq)]
637#[non_exhaustive]
638pub enum ThreeDSecureDetailsChargeVersion {
639    V1_0_2,
640    V2_1_0,
641    V2_2_0,
642    /// An unrecognized value from Stripe. Should not be used as a request parameter.
643    Unknown(String),
644}
645impl ThreeDSecureDetailsChargeVersion {
646    pub fn as_str(&self) -> &str {
647        use ThreeDSecureDetailsChargeVersion::*;
648        match self {
649            V1_0_2 => "1.0.2",
650            V2_1_0 => "2.1.0",
651            V2_2_0 => "2.2.0",
652            Unknown(v) => v,
653        }
654    }
655}
656
657impl std::str::FromStr for ThreeDSecureDetailsChargeVersion {
658    type Err = std::convert::Infallible;
659    fn from_str(s: &str) -> Result<Self, Self::Err> {
660        use ThreeDSecureDetailsChargeVersion::*;
661        match s {
662            "1.0.2" => Ok(V1_0_2),
663            "2.1.0" => Ok(V2_1_0),
664            "2.2.0" => Ok(V2_2_0),
665            v => {
666                tracing::warn!(
667                    "Unknown value '{}' for enum '{}'",
668                    v,
669                    "ThreeDSecureDetailsChargeVersion"
670                );
671                Ok(Unknown(v.to_owned()))
672            }
673        }
674    }
675}
676impl std::fmt::Display for ThreeDSecureDetailsChargeVersion {
677    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
678        f.write_str(self.as_str())
679    }
680}
681
682impl std::fmt::Debug for ThreeDSecureDetailsChargeVersion {
683    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
684        f.write_str(self.as_str())
685    }
686}
687#[cfg(feature = "serialize")]
688impl serde::Serialize for ThreeDSecureDetailsChargeVersion {
689    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
690    where
691        S: serde::Serializer,
692    {
693        serializer.serialize_str(self.as_str())
694    }
695}
696impl miniserde::Deserialize for ThreeDSecureDetailsChargeVersion {
697    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
698        crate::Place::new(out)
699    }
700}
701
702impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeVersion> {
703    fn string(&mut self, s: &str) -> miniserde::Result<()> {
704        use std::str::FromStr;
705        self.out = Some(ThreeDSecureDetailsChargeVersion::from_str(s).expect("infallible"));
706        Ok(())
707    }
708}
709
710stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeVersion);
711#[cfg(feature = "deserialize")]
712impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeVersion {
713    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
714        use std::str::FromStr;
715        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
716        Ok(Self::from_str(&s).expect("infallible"))
717    }
718}