feat(card_network): add additional enum variants (#671)

This commit is contained in:
Narayan Bhat
2023-02-27 18:47:50 +05:30
committed by GitHub
parent ff86417eee
commit db8bc16421
5 changed files with 17 additions and 5 deletions

View File

@ -12,6 +12,7 @@ aci = "aci" # Name of a connector
encrypter = "encrypter" # Used by the `ring` crate
nin = "nin" # National identification number, a field used by PayU connector
substituters = "substituters" # Present in `flake.nix`
hypo_noe_lb_fur_niederosterreich_u_wien = "hypo_noe_lb_fur_niederosterreich_u_wien" # Present in openapi/generated.json
FO = "FO" # Faroe Islands (the) country code
[files]

View File

@ -700,11 +700,18 @@ pub enum BankNames {
strum::EnumString,
frunk::LabelledGeneric,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum CardNetwork {
Visa,
Mastercard,
AmericanExpress,
JCB,
DinersClub,
Discover,
CartesBancaires,
UnionPay,
Interac,
RuPay,
Maestro,
}
impl From<AttemptStatus> for IntentStatus {

View File

@ -358,7 +358,7 @@ pub struct Card {
#[schema(value_type = String, example = "242")]
pub card_cvc: Secret<String>,
pub card_issuer: Option<String>,
pub card_network: Option<String>,
pub card_network: Option<api_enums::CardNetwork>,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
@ -418,7 +418,10 @@ impl From<&PaymentMethodData> for AdditionalPaymentData {
match pm_data {
PaymentMethodData::Card(card_data) => Self::Card {
card_issuer: card_data.card_issuer.to_owned(),
card_network: card_data.card_network.to_owned(),
card_network: card_data
.card_network
.as_ref()
.map(|card_network| card_network.to_string()),
},
PaymentMethodData::BankRedirect(bank_redirect_data) => match bank_redirect_data {
BankRedirectData::Eps { bank_name, .. } => Self::BankRedirect {

View File

@ -148,6 +148,7 @@ pub fn validate_for_valid_refunds(
.get_required_value("connector")?
.parse_enum("connector")
.change_context(errors::ApiErrorResponse::IncorrectConnectorNameGiven)?;
let payment_method_type = payment_attempt
.payment_method_type
.clone()

View File

@ -193,7 +193,7 @@ mod payments_test {
card_holder_name: "JohnDoe".to_string().into(),
card_cvc: "123".to_string().into(),
card_issuer: Some("HDFC".to_string()),
card_network: Some("Visa".to_string()),
card_network: Some(api_models::enums::CardNetwork::Visa),
}
}