Skip to main content

stripe_shared/
payment_method_details_interac_present_receipt.rs

1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct PaymentMethodDetailsInteracPresentReceipt {
6    /// The type of account being debited or credited
7    pub account_type: Option<PaymentMethodDetailsInteracPresentReceiptAccountType>,
8    /// The Application Cryptogram, a unique value generated by the card to authenticate the transaction with issuers.
9    pub application_cryptogram: Option<String>,
10    /// The Application Identifier (AID) on the card used to determine which networks are eligible to process the transaction.
11    /// Referenced from EMV tag 9F12, data encoded on the card's chip.
12    pub application_preferred_name: Option<String>,
13    /// Identifier for this transaction.
14    pub authorization_code: Option<String>,
15    /// EMV tag 8A. A code returned by the card issuer.
16    pub authorization_response_code: Option<String>,
17    /// Describes the method used by the cardholder to verify ownership of the card.
18    /// One of the following: `approval`, `failure`, `none`, `offline_pin`, `offline_pin_and_signature`, `online_pin`, or `signature`.
19    pub cardholder_verification_method: Option<String>,
20    /// Similar to the application_preferred_name, identifying the applications (AIDs) available on the card.
21    /// Referenced from EMV tag 84.
22    pub dedicated_file_name: Option<String>,
23    /// A 5-byte string that records the checks and validations that occur between the card and the terminal.
24    /// These checks determine how the terminal processes the transaction and what risk tolerance is acceptable.
25    /// Referenced from EMV Tag 95.
26    pub terminal_verification_results: Option<String>,
27    /// An indication of which steps were completed during the card read process.
28    /// Referenced from EMV Tag 9B.
29    pub transaction_status_information: Option<String>,
30}
31#[cfg(feature = "redact-generated-debug")]
32impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReceipt {
33    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
34        f.debug_struct("PaymentMethodDetailsInteracPresentReceipt").finish_non_exhaustive()
35    }
36}
37#[doc(hidden)]
38pub struct PaymentMethodDetailsInteracPresentReceiptBuilder {
39    account_type: Option<Option<PaymentMethodDetailsInteracPresentReceiptAccountType>>,
40    application_cryptogram: Option<Option<String>>,
41    application_preferred_name: Option<Option<String>>,
42    authorization_code: Option<Option<String>>,
43    authorization_response_code: Option<Option<String>>,
44    cardholder_verification_method: Option<Option<String>>,
45    dedicated_file_name: Option<Option<String>>,
46    terminal_verification_results: Option<Option<String>>,
47    transaction_status_information: Option<Option<String>>,
48}
49
50#[allow(
51    unused_variables,
52    irrefutable_let_patterns,
53    clippy::let_unit_value,
54    clippy::match_single_binding,
55    clippy::single_match
56)]
57const _: () = {
58    use miniserde::de::{Map, Visitor};
59    use miniserde::json::Value;
60    use miniserde::{Deserialize, Result, make_place};
61    use stripe_types::miniserde_helpers::FromValueOpt;
62    use stripe_types::{MapBuilder, ObjectDeser};
63
64    make_place!(Place);
65
66    impl Deserialize for PaymentMethodDetailsInteracPresentReceipt {
67        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
68            Place::new(out)
69        }
70    }
71
72    struct Builder<'a> {
73        out: &'a mut Option<PaymentMethodDetailsInteracPresentReceipt>,
74        builder: PaymentMethodDetailsInteracPresentReceiptBuilder,
75    }
76
77    impl Visitor for Place<PaymentMethodDetailsInteracPresentReceipt> {
78        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
79            Ok(Box::new(Builder {
80                out: &mut self.out,
81                builder: PaymentMethodDetailsInteracPresentReceiptBuilder::deser_default(),
82            }))
83        }
84    }
85
86    impl MapBuilder for PaymentMethodDetailsInteracPresentReceiptBuilder {
87        type Out = PaymentMethodDetailsInteracPresentReceipt;
88        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89            Ok(match k {
90                "account_type" => Deserialize::begin(&mut self.account_type),
91                "application_cryptogram" => Deserialize::begin(&mut self.application_cryptogram),
92                "application_preferred_name" => {
93                    Deserialize::begin(&mut self.application_preferred_name)
94                }
95                "authorization_code" => Deserialize::begin(&mut self.authorization_code),
96                "authorization_response_code" => {
97                    Deserialize::begin(&mut self.authorization_response_code)
98                }
99                "cardholder_verification_method" => {
100                    Deserialize::begin(&mut self.cardholder_verification_method)
101                }
102                "dedicated_file_name" => Deserialize::begin(&mut self.dedicated_file_name),
103                "terminal_verification_results" => {
104                    Deserialize::begin(&mut self.terminal_verification_results)
105                }
106                "transaction_status_information" => {
107                    Deserialize::begin(&mut self.transaction_status_information)
108                }
109                _ => <dyn Visitor>::ignore(),
110            })
111        }
112
113        fn deser_default() -> Self {
114            Self {
115                account_type: Some(None),
116                application_cryptogram: Some(None),
117                application_preferred_name: Some(None),
118                authorization_code: Some(None),
119                authorization_response_code: Some(None),
120                cardholder_verification_method: Some(None),
121                dedicated_file_name: Some(None),
122                terminal_verification_results: Some(None),
123                transaction_status_information: Some(None),
124            }
125        }
126
127        fn take_out(&mut self) -> Option<Self::Out> {
128            let (
129                Some(account_type),
130                Some(application_cryptogram),
131                Some(application_preferred_name),
132                Some(authorization_code),
133                Some(authorization_response_code),
134                Some(cardholder_verification_method),
135                Some(dedicated_file_name),
136                Some(terminal_verification_results),
137                Some(transaction_status_information),
138            ) = (
139                self.account_type.take(),
140                self.application_cryptogram.take(),
141                self.application_preferred_name.take(),
142                self.authorization_code.take(),
143                self.authorization_response_code.take(),
144                self.cardholder_verification_method.take(),
145                self.dedicated_file_name.take(),
146                self.terminal_verification_results.take(),
147                self.transaction_status_information.take(),
148            )
149            else {
150                return None;
151            };
152            Some(Self::Out {
153                account_type,
154                application_cryptogram,
155                application_preferred_name,
156                authorization_code,
157                authorization_response_code,
158                cardholder_verification_method,
159                dedicated_file_name,
160                terminal_verification_results,
161                transaction_status_information,
162            })
163        }
164    }
165
166    impl Map for Builder<'_> {
167        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
168            self.builder.key(k)
169        }
170
171        fn finish(&mut self) -> Result<()> {
172            *self.out = self.builder.take_out();
173            Ok(())
174        }
175    }
176
177    impl ObjectDeser for PaymentMethodDetailsInteracPresentReceipt {
178        type Builder = PaymentMethodDetailsInteracPresentReceiptBuilder;
179    }
180
181    impl FromValueOpt for PaymentMethodDetailsInteracPresentReceipt {
182        fn from_value(v: Value) -> Option<Self> {
183            let Value::Object(obj) = v else {
184                return None;
185            };
186            let mut b = PaymentMethodDetailsInteracPresentReceiptBuilder::deser_default();
187            for (k, v) in obj {
188                match k.as_str() {
189                    "account_type" => b.account_type = FromValueOpt::from_value(v),
190                    "application_cryptogram" => {
191                        b.application_cryptogram = FromValueOpt::from_value(v)
192                    }
193                    "application_preferred_name" => {
194                        b.application_preferred_name = FromValueOpt::from_value(v)
195                    }
196                    "authorization_code" => b.authorization_code = FromValueOpt::from_value(v),
197                    "authorization_response_code" => {
198                        b.authorization_response_code = FromValueOpt::from_value(v)
199                    }
200                    "cardholder_verification_method" => {
201                        b.cardholder_verification_method = FromValueOpt::from_value(v)
202                    }
203                    "dedicated_file_name" => b.dedicated_file_name = FromValueOpt::from_value(v),
204                    "terminal_verification_results" => {
205                        b.terminal_verification_results = FromValueOpt::from_value(v)
206                    }
207                    "transaction_status_information" => {
208                        b.transaction_status_information = FromValueOpt::from_value(v)
209                    }
210                    _ => {}
211                }
212            }
213            b.take_out()
214        }
215    }
216};
217/// The type of account being debited or credited
218#[derive(Clone, Eq, PartialEq)]
219#[non_exhaustive]
220pub enum PaymentMethodDetailsInteracPresentReceiptAccountType {
221    Checking,
222    Savings,
223    Unknown,
224    /// An unrecognized value from Stripe. Should not be used as a request parameter.
225    /// This variant is prefixed with an underscore to avoid conflicts with Stripe's 'Unknown' variant.
226    _Unknown(String),
227}
228impl PaymentMethodDetailsInteracPresentReceiptAccountType {
229    pub fn as_str(&self) -> &str {
230        use PaymentMethodDetailsInteracPresentReceiptAccountType::*;
231        match self {
232            Checking => "checking",
233            Savings => "savings",
234            Unknown => "unknown",
235            _Unknown(v) => v,
236        }
237    }
238}
239
240impl std::str::FromStr for PaymentMethodDetailsInteracPresentReceiptAccountType {
241    type Err = std::convert::Infallible;
242    fn from_str(s: &str) -> Result<Self, Self::Err> {
243        use PaymentMethodDetailsInteracPresentReceiptAccountType::*;
244        match s {
245            "checking" => Ok(Checking),
246            "savings" => Ok(Savings),
247            "unknown" => Ok(Unknown),
248            v => {
249                tracing::warn!(
250                    "Unknown value '{}' for enum '{}'",
251                    v,
252                    "PaymentMethodDetailsInteracPresentReceiptAccountType"
253                );
254                Ok(_Unknown(v.to_owned()))
255            }
256        }
257    }
258}
259impl std::fmt::Display for PaymentMethodDetailsInteracPresentReceiptAccountType {
260    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
261        f.write_str(self.as_str())
262    }
263}
264
265#[cfg(not(feature = "redact-generated-debug"))]
266impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReceiptAccountType {
267    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
268        f.write_str(self.as_str())
269    }
270}
271#[cfg(feature = "redact-generated-debug")]
272impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReceiptAccountType {
273    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
274        f.debug_struct(stringify!(PaymentMethodDetailsInteracPresentReceiptAccountType))
275            .finish_non_exhaustive()
276    }
277}
278#[cfg(feature = "serialize")]
279impl serde::Serialize for PaymentMethodDetailsInteracPresentReceiptAccountType {
280    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
281    where
282        S: serde::Serializer,
283    {
284        serializer.serialize_str(self.as_str())
285    }
286}
287impl miniserde::Deserialize for PaymentMethodDetailsInteracPresentReceiptAccountType {
288    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
289        crate::Place::new(out)
290    }
291}
292
293impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsInteracPresentReceiptAccountType> {
294    fn string(&mut self, s: &str) -> miniserde::Result<()> {
295        use std::str::FromStr;
296        self.out = Some(
297            PaymentMethodDetailsInteracPresentReceiptAccountType::from_str(s).expect("infallible"),
298        );
299        Ok(())
300    }
301}
302
303stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsInteracPresentReceiptAccountType);
304#[cfg(feature = "deserialize")]
305impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsInteracPresentReceiptAccountType {
306    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
307        use std::str::FromStr;
308        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
309        Ok(Self::from_str(&s).expect("infallible"))
310    }
311}