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