paypal_rust/resources/enums/
avs_code.rs

1use serde::{Deserialize, Serialize};
2
3/// The address verification code for Visa, Discover, Mastercard, or American Express transactions.
4#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
5pub enum AvsCode {
6    /// For Visa, Mastercard, or Discover transactions, the address matches but the zip code does not match. For American Express transactions, the card holder address is correct.
7    A,
8    /// For Visa, Mastercard, or Discover transactions, the address matches. International A.
9    B,
10    /// For Visa, Mastercard, or Discover transactions, no values match. International N.
11    C,
12    /// For Visa, Mastercard, or Discover transactions, the address and postal code match. International X.
13    D,
14    /// For Visa, Mastercard, or Discover transactions, not allowed for Internet or phone transactions. For American Express card holder, the name is incorrect but the address and postal code match.
15    E,
16    /// For Visa, Mastercard, or Discover transactions, the address and postal code match. UK-specific X. For American Express card
17    /// holder, the name is incorrect but the address matches.
18    F,
19    /// For Visa, Mastercard, or Discover transactions, global is unavailable. Nothing matches.
20    G,
21    /// For Visa, Mastercard, or Discover transactions, international is unavailable. Not applicable.
22    I,
23    /// For Visa, Mastercard, or Discover transactions, the address and postal code match. For American Express card holder, the name, address, and postal code match.
24    M,
25    /// For Visa, Mastercard, or Discover transactions, nothing matches. For American Express card holder, the address and postal code are both incorrect.
26    N,
27    /// For Visa, Mastercard, or Discover transactions, postal international Z. Postal code only.
28    P,
29    /// For Visa, Mastercard, or Discover transactions, re-try the request. For American Express, the system is unavailable.
30    R,
31    /// For Visa, Mastercard, Discover, or American Express, the service is not supported.
32    S,
33    /// For Visa, Mastercard, or Discover transactions, the service is unavailable. For American Express, information is not available.
34    /// For Maestro, the address is not checked or the acquirer had no response. The service is not available.
35    U,
36    /// For Visa, Mastercard, or Discover transactions, whole ZIP code. For American Express, the card holder name, address, and postal
37    /// code are all incorrect.
38    W,
39    /// For Visa, Mastercard, or Discover transactions, exact match of the address and the nine-digit ZIP code. For American Express,
40    /// the card holder name, address, and postal code are all incorrect.
41    X,
42    ///  For Visa, Mastercard, or Discover transactions, the address and five-digit ZIP code match. For American Express, the card holder
43    /// address and postal code are both correct.
44    Y,
45    /// For Visa, Mastercard, or Discover transactions, the five-digit ZIP code matches but no address. For American Express, only the
46    /// card holder postal code is correct.
47    Z,
48    /// For Maestro, no AVS response was obtained.
49    Null,
50    /// For Maestro, all address information matches.
51    #[serde(rename = "0")]
52    Zero,
53    /// - 1. For Maestro, none of the address information matches.
54    #[serde(rename = "1")]
55    One,
56    /// - 2. For Maestro, part of the address information matches.
57    #[serde(rename = "2")]
58    Two,
59    /// - 3. For Maestro, the merchant did not provide AVS information. It was not processed.
60    #[serde(rename = "3")]
61    Three,
62    /// - 4. For Maestro, the address was not checked or the acquirer had no response. The service is not available.
63    #[serde(rename = "4")]
64    Four,
65}
66
67impl AvsCode {
68    pub const fn as_str(self) -> &'static str {
69        match self {
70            Self::A => "A",
71            Self::B => "B",
72            Self::C => "C",
73            Self::D => "D",
74            Self::E => "E",
75            Self::F => "F",
76            Self::G => "G",
77            Self::I => "I",
78            Self::M => "M",
79            Self::N => "N",
80            Self::P => "P",
81            Self::R => "R",
82            Self::S => "S",
83            Self::U => "U",
84            Self::W => "W",
85            Self::X => "X",
86            Self::Y => "Y",
87            Self::Z => "Z",
88            Self::Null => "Null",
89            Self::Zero => "0",
90            Self::One => "1",
91            Self::Two => "2",
92            Self::Three => "3",
93            Self::Four => "4",
94        }
95    }
96}
97
98impl AsRef<str> for AvsCode {
99    fn as_ref(&self) -> &str {
100        self.as_str()
101    }
102}
103
104impl std::fmt::Display for AvsCode {
105    fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
106        self.as_str().fmt(formatter)
107    }
108}