async-stripe-shared 1.0.0-rc.6

API bindings for the Stripe HTTP API
Documentation
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct PaymentMethodDetailsInteracPresentReceipt {
    /// The type of account being debited or credited
    pub account_type: Option<PaymentMethodDetailsInteracPresentReceiptAccountType>,
    /// The Application Cryptogram, a unique value generated by the card to authenticate the transaction with issuers.
    pub application_cryptogram: Option<String>,
    /// The Application Identifier (AID) on the card used to determine which networks are eligible to process the transaction.
    /// Referenced from EMV tag 9F12, data encoded on the card's chip.
    pub application_preferred_name: Option<String>,
    /// Identifier for this transaction.
    pub authorization_code: Option<String>,
    /// EMV tag 8A. A code returned by the card issuer.
    pub authorization_response_code: Option<String>,
    /// Describes the method used by the cardholder to verify ownership of the card.
    /// One of the following: `approval`, `failure`, `none`, `offline_pin`, `offline_pin_and_signature`, `online_pin`, or `signature`.
    pub cardholder_verification_method: Option<String>,
    /// Similar to the application_preferred_name, identifying the applications (AIDs) available on the card.
    /// Referenced from EMV tag 84.
    pub dedicated_file_name: Option<String>,
    /// A 5-byte string that records the checks and validations that occur between the card and the terminal.
    /// These checks determine how the terminal processes the transaction and what risk tolerance is acceptable.
    /// Referenced from EMV Tag 95.
    pub terminal_verification_results: Option<String>,
    /// An indication of which steps were completed during the card read process.
    /// Referenced from EMV Tag 9B.
    pub transaction_status_information: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReceipt {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("PaymentMethodDetailsInteracPresentReceipt").finish_non_exhaustive()
    }
}
#[doc(hidden)]
pub struct PaymentMethodDetailsInteracPresentReceiptBuilder {
    account_type: Option<Option<PaymentMethodDetailsInteracPresentReceiptAccountType>>,
    application_cryptogram: Option<Option<String>>,
    application_preferred_name: Option<Option<String>>,
    authorization_code: Option<Option<String>>,
    authorization_response_code: Option<Option<String>>,
    cardholder_verification_method: Option<Option<String>>,
    dedicated_file_name: Option<Option<String>>,
    terminal_verification_results: Option<Option<String>>,
    transaction_status_information: Option<Option<String>>,
}

#[allow(
    unused_variables,
    irrefutable_let_patterns,
    clippy::let_unit_value,
    clippy::match_single_binding,
    clippy::single_match
)]
const _: () = {
    use miniserde::de::{Map, Visitor};
    use miniserde::json::Value;
    use miniserde::{Deserialize, Result, make_place};
    use stripe_types::miniserde_helpers::FromValueOpt;
    use stripe_types::{MapBuilder, ObjectDeser};

    make_place!(Place);

    impl Deserialize for PaymentMethodDetailsInteracPresentReceipt {
        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
            Place::new(out)
        }
    }

    struct Builder<'a> {
        out: &'a mut Option<PaymentMethodDetailsInteracPresentReceipt>,
        builder: PaymentMethodDetailsInteracPresentReceiptBuilder,
    }

    impl Visitor for Place<PaymentMethodDetailsInteracPresentReceipt> {
        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
            Ok(Box::new(Builder {
                out: &mut self.out,
                builder: PaymentMethodDetailsInteracPresentReceiptBuilder::deser_default(),
            }))
        }
    }

    impl MapBuilder for PaymentMethodDetailsInteracPresentReceiptBuilder {
        type Out = PaymentMethodDetailsInteracPresentReceipt;
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            Ok(match k {
                "account_type" => Deserialize::begin(&mut self.account_type),
                "application_cryptogram" => Deserialize::begin(&mut self.application_cryptogram),
                "application_preferred_name" => {
                    Deserialize::begin(&mut self.application_preferred_name)
                }
                "authorization_code" => Deserialize::begin(&mut self.authorization_code),
                "authorization_response_code" => {
                    Deserialize::begin(&mut self.authorization_response_code)
                }
                "cardholder_verification_method" => {
                    Deserialize::begin(&mut self.cardholder_verification_method)
                }
                "dedicated_file_name" => Deserialize::begin(&mut self.dedicated_file_name),
                "terminal_verification_results" => {
                    Deserialize::begin(&mut self.terminal_verification_results)
                }
                "transaction_status_information" => {
                    Deserialize::begin(&mut self.transaction_status_information)
                }
                _ => <dyn Visitor>::ignore(),
            })
        }

        fn deser_default() -> Self {
            Self {
                account_type: Some(None),
                application_cryptogram: Some(None),
                application_preferred_name: Some(None),
                authorization_code: Some(None),
                authorization_response_code: Some(None),
                cardholder_verification_method: Some(None),
                dedicated_file_name: Some(None),
                terminal_verification_results: Some(None),
                transaction_status_information: Some(None),
            }
        }

        fn take_out(&mut self) -> Option<Self::Out> {
            let (
                Some(account_type),
                Some(application_cryptogram),
                Some(application_preferred_name),
                Some(authorization_code),
                Some(authorization_response_code),
                Some(cardholder_verification_method),
                Some(dedicated_file_name),
                Some(terminal_verification_results),
                Some(transaction_status_information),
            ) = (
                self.account_type.take(),
                self.application_cryptogram.take(),
                self.application_preferred_name.take(),
                self.authorization_code.take(),
                self.authorization_response_code.take(),
                self.cardholder_verification_method.take(),
                self.dedicated_file_name.take(),
                self.terminal_verification_results.take(),
                self.transaction_status_information.take(),
            )
            else {
                return None;
            };
            Some(Self::Out {
                account_type,
                application_cryptogram,
                application_preferred_name,
                authorization_code,
                authorization_response_code,
                cardholder_verification_method,
                dedicated_file_name,
                terminal_verification_results,
                transaction_status_information,
            })
        }
    }

    impl Map for Builder<'_> {
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            self.builder.key(k)
        }

        fn finish(&mut self) -> Result<()> {
            *self.out = self.builder.take_out();
            Ok(())
        }
    }

    impl ObjectDeser for PaymentMethodDetailsInteracPresentReceipt {
        type Builder = PaymentMethodDetailsInteracPresentReceiptBuilder;
    }

    impl FromValueOpt for PaymentMethodDetailsInteracPresentReceipt {
        fn from_value(v: Value) -> Option<Self> {
            let Value::Object(obj) = v else {
                return None;
            };
            let mut b = PaymentMethodDetailsInteracPresentReceiptBuilder::deser_default();
            for (k, v) in obj {
                match k.as_str() {
                    "account_type" => b.account_type = FromValueOpt::from_value(v),
                    "application_cryptogram" => {
                        b.application_cryptogram = FromValueOpt::from_value(v)
                    }
                    "application_preferred_name" => {
                        b.application_preferred_name = FromValueOpt::from_value(v)
                    }
                    "authorization_code" => b.authorization_code = FromValueOpt::from_value(v),
                    "authorization_response_code" => {
                        b.authorization_response_code = FromValueOpt::from_value(v)
                    }
                    "cardholder_verification_method" => {
                        b.cardholder_verification_method = FromValueOpt::from_value(v)
                    }
                    "dedicated_file_name" => b.dedicated_file_name = FromValueOpt::from_value(v),
                    "terminal_verification_results" => {
                        b.terminal_verification_results = FromValueOpt::from_value(v)
                    }
                    "transaction_status_information" => {
                        b.transaction_status_information = FromValueOpt::from_value(v)
                    }
                    _ => {}
                }
            }
            b.take_out()
        }
    }
};
/// The type of account being debited or credited
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentMethodDetailsInteracPresentReceiptAccountType {
    Checking,
    Savings,
    Unknown,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    /// This variant is prefixed with an underscore to avoid conflicts with Stripe's 'Unknown' variant.
    _Unknown(String),
}
impl PaymentMethodDetailsInteracPresentReceiptAccountType {
    pub fn as_str(&self) -> &str {
        use PaymentMethodDetailsInteracPresentReceiptAccountType::*;
        match self {
            Checking => "checking",
            Savings => "savings",
            Unknown => "unknown",
            _Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for PaymentMethodDetailsInteracPresentReceiptAccountType {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use PaymentMethodDetailsInteracPresentReceiptAccountType::*;
        match s {
            "checking" => Ok(Checking),
            "savings" => Ok(Savings),
            "unknown" => Ok(Unknown),
            v => {
                tracing::warn!(
                    "Unknown value '{}' for enum '{}'",
                    v,
                    "PaymentMethodDetailsInteracPresentReceiptAccountType"
                );
                Ok(_Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for PaymentMethodDetailsInteracPresentReceiptAccountType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReceiptAccountType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReceiptAccountType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(PaymentMethodDetailsInteracPresentReceiptAccountType))
            .finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentMethodDetailsInteracPresentReceiptAccountType {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl miniserde::Deserialize for PaymentMethodDetailsInteracPresentReceiptAccountType {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsInteracPresentReceiptAccountType> {
    fn string(&mut self, s: &str) -> miniserde::Result<()> {
        use std::str::FromStr;
        self.out = Some(
            PaymentMethodDetailsInteracPresentReceiptAccountType::from_str(s).expect("infallible"),
        );
        Ok(())
    }
}

stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsInteracPresentReceiptAccountType);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsInteracPresentReceiptAccountType {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}