stripe_shared/
issuing_transaction_network_data.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct IssuingTransactionNetworkData {
5    /// A code created by Stripe which is shared with the merchant to validate the authorization.
6    /// This field will be populated if the authorization message was approved.
7    /// The code typically starts with the letter "S", followed by a six-digit number.
8    /// For example, "S498162".
9    /// Please note that the code is not guaranteed to be unique across authorizations.
10    pub authorization_code: Option<String>,
11    /// The date the transaction was processed by the card network.
12    /// This can be different from the date the seller recorded the transaction depending on when the acquirer submits the transaction to the network.
13    pub processing_date: Option<String>,
14    /// Unique identifier for the authorization assigned by the card network used to match subsequent messages, disputes, and transactions.
15    pub transaction_id: Option<String>,
16}
17#[doc(hidden)]
18pub struct IssuingTransactionNetworkDataBuilder {
19    authorization_code: Option<Option<String>>,
20    processing_date: Option<Option<String>>,
21    transaction_id: Option<Option<String>>,
22}
23
24#[allow(
25    unused_variables,
26    irrefutable_let_patterns,
27    clippy::let_unit_value,
28    clippy::match_single_binding,
29    clippy::single_match
30)]
31const _: () = {
32    use miniserde::de::{Map, Visitor};
33    use miniserde::json::Value;
34    use miniserde::{make_place, Deserialize, Result};
35    use stripe_types::miniserde_helpers::FromValueOpt;
36    use stripe_types::{MapBuilder, ObjectDeser};
37
38    make_place!(Place);
39
40    impl Deserialize for IssuingTransactionNetworkData {
41        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
42            Place::new(out)
43        }
44    }
45
46    struct Builder<'a> {
47        out: &'a mut Option<IssuingTransactionNetworkData>,
48        builder: IssuingTransactionNetworkDataBuilder,
49    }
50
51    impl Visitor for Place<IssuingTransactionNetworkData> {
52        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
53            Ok(Box::new(Builder {
54                out: &mut self.out,
55                builder: IssuingTransactionNetworkDataBuilder::deser_default(),
56            }))
57        }
58    }
59
60    impl MapBuilder for IssuingTransactionNetworkDataBuilder {
61        type Out = IssuingTransactionNetworkData;
62        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
63            Ok(match k {
64                "authorization_code" => Deserialize::begin(&mut self.authorization_code),
65                "processing_date" => Deserialize::begin(&mut self.processing_date),
66                "transaction_id" => Deserialize::begin(&mut self.transaction_id),
67
68                _ => <dyn Visitor>::ignore(),
69            })
70        }
71
72        fn deser_default() -> Self {
73            Self {
74                authorization_code: Deserialize::default(),
75                processing_date: Deserialize::default(),
76                transaction_id: Deserialize::default(),
77            }
78        }
79
80        fn take_out(&mut self) -> Option<Self::Out> {
81            let (Some(authorization_code), Some(processing_date), Some(transaction_id)) = (
82                self.authorization_code.take(),
83                self.processing_date.take(),
84                self.transaction_id.take(),
85            ) else {
86                return None;
87            };
88            Some(Self::Out { authorization_code, processing_date, transaction_id })
89        }
90    }
91
92    impl<'a> Map for Builder<'a> {
93        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
94            self.builder.key(k)
95        }
96
97        fn finish(&mut self) -> Result<()> {
98            *self.out = self.builder.take_out();
99            Ok(())
100        }
101    }
102
103    impl ObjectDeser for IssuingTransactionNetworkData {
104        type Builder = IssuingTransactionNetworkDataBuilder;
105    }
106
107    impl FromValueOpt for IssuingTransactionNetworkData {
108        fn from_value(v: Value) -> Option<Self> {
109            let Value::Object(obj) = v else {
110                return None;
111            };
112            let mut b = IssuingTransactionNetworkDataBuilder::deser_default();
113            for (k, v) in obj {
114                match k.as_str() {
115                    "authorization_code" => b.authorization_code = FromValueOpt::from_value(v),
116                    "processing_date" => b.processing_date = FromValueOpt::from_value(v),
117                    "transaction_id" => b.transaction_id = FromValueOpt::from_value(v),
118
119                    _ => {}
120                }
121            }
122            b.take_out()
123        }
124    }
125};