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

fix(payment_methods): unmask last4 digits of card when listing payment methods for customer (#3617)

Chethan Rao834142e69087
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 152232d2de..4f6d6b4c62 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -248,11 +248,7 @@ pub async fn add_payment_method(
Ok(pm) => {
let updated_card = Some(api::CardDetailFromLocker {
scheme: None,
- last4_digits: Some(
- card.card_number
- .to_string()
- .split_off(card.card_number.to_string().len() - 4),
- ),
+ last4_digits: Some(card.card_number.clone().get_last4()),
issuer_country: None,
card_number: Some(card.card_number),
expiry_month: Some(card.card_exp_month),