Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(payment_methods): store `card_network` in locker (#4425)

Chethan Rao5b54d55c5e0d
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index b806781a64..42145550c8 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -1167,7 +1167,7 @@ pub async fn add_card_hs(
name_on_card: card.card_holder_name.to_owned(),
card_exp_month: card.card_exp_month.to_owned(),
card_exp_year: card.card_exp_year.to_owned(),
- card_brand: None,
+ card_brand: card.card_network.as_ref().map(ToString::to_string),
card_isin: None,
nick_name: card.nick_name.as_ref().map(masking::Secret::peek).cloned(),
},
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index c8763584cc..6a1a779fd1 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -1,4 +1,4 @@
-use std::borrow::Cow;
+use std::{borrow::Cow, str::FromStr};
use api_models::{
mandates::RecurringDetails,
@@ -1779,9 +1779,17 @@ pub async fn retrieve_card_with_permanent_token(
.unwrap_or_default()
.card_cvc
.unwrap_or_default(),
- card_issuer: card.card_brand,
+ card_issuer: None,
nick_name: card.nick_name.map(masking::Secret::new),
- card_network: None,
+ card_network: card
+ .card_brand
+ .map(|card_brand| enums::CardNetwork::from_str(&card_brand))
+ .transpose()
+ .map_err(|e| {
+ logger::error!("Failed to parse card network {}", e);
+ })
+ .ok()
+ .flatten(),
card_type: None,
card_issuing_country: None,
bank_code: None,