paypal_rust/resources/enums/
cvv_code.rs

1use serde::{Deserialize, Serialize};
2
3/// The card verification value code for for Visa, Discover, Mastercard, or American Express.
4#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
5pub enum CvvCode {
6    /// For Visa, Mastercard, Discover, or American Express, error - unrecognized or unknown response.
7    E,
8    /// For Visa, Mastercard, Discover, or American Express, invalid or null.
9    I,
10    /// For Visa, Mastercard, Discover, or American Express, the CVV2/CSC matches.
11    M,
12    ///  For Visa, Mastercard, Discover, or American Express, the CVV2/CSC does not match.
13    N,
14    /// For Visa, Mastercard, Discover, or American Express, it was not processed.
15    P,
16    /// For Visa, Mastercard, Discover, or American Express, the service is not supported.
17    S,
18    /// For Visa, Mastercard, Discover, or American Express, unknown - the issuer is not certified.
19    U,
20    /// For Visa, Mastercard, Discover, or American Express, no response. For Maestro, the service is not available.
21    X,
22    /// For Visa, Mastercard, Discover, or American Express, error.
23    #[serde(rename = "All others")]
24    AllOthers,
25    /// For Maestro, the CVV2 matched.
26    #[serde(rename = "0")]
27    Zero,
28    /// For Maestro, the CVV2 did not match.
29    #[serde(rename = "1")]
30    One,
31    /// For Maestro, the merchant has not implemented CVV2 code handling.
32    #[serde(rename = "2")]
33    Two,
34    /// For Maestro, the merchant has indicated that CVV2 is not present on card.
35    #[serde(rename = "3")]
36    Three,
37    /// For Maestro, the service is not available.
38    #[serde(rename = "4")]
39    Four,
40}
41
42impl CvvCode {
43    pub const fn as_str(self) -> &'static str {
44        match self {
45            Self::E => "E",
46            Self::I => "I",
47            Self::M => "M",
48            Self::N => "N",
49            Self::P => "P",
50            Self::S => "S",
51            Self::U => "U",
52            Self::X => "X",
53            Self::AllOthers => "All others",
54            Self::Zero => "0",
55            Self::One => "1",
56            Self::Two => "2",
57            Self::Three => "3",
58            Self::Four => "4",
59        }
60    }
61}
62
63impl AsRef<str> for CvvCode {
64    fn as_ref(&self) -> &str {
65        self.as_str()
66    }
67}
68
69impl std::fmt::Display for CvvCode {
70    fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
71        self.as_str().fmt(formatter)
72    }
73}