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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(payment_methods): use existing field value of `nick_name` in db if not sent during request (#5105)
Chethan Raoea74f3e537ac
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 204d7eb243..53b0063c6e 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -656,21 +656,32 @@ pub async fn add_payment_method(.attach_printable("Failed while updating card metadata changes"))?};+ let existing_pm_data = get_card_details_without_locker_fallback(+ &existing_pm,+ key_store.key.peek(),+ &state,+ )+ .await?;+let updated_card = Some(api::CardDetailFromLocker {scheme: existing_pm.scheme.clone(),last4_digits: Some(card.card_number.get_last4()),- issuer_country: card.card_issuing_country,+ issuer_country: card+ .card_issuing_country+ .or(existing_pm_data.issuer_country),card_isin: Some(card.card_number.get_card_isin()),card_number: Some(card.card_number),expiry_month: Some(card.card_exp_month),expiry_year: Some(card.card_exp_year),card_token: None,card_fingerprint: None,- card_holder_name: card.card_holder_name,- nick_name: card.nick_name,- card_network: card.card_network,- card_issuer: card.card_issuer,- card_type: card.card_type,+ card_holder_name: card+ .card_holder_name+ .or(existing_pm_data.card_holder_name),+ nick_name: card.nick_name.or(existing_pm_data.nick_name),+ card_network: card.card_network.or(existing_pm_data.card_network),+ card_issuer: card.card_issuer.or(existing_pm_data.card_issuer),+ card_type: card.card_type.or(existing_pm_data.card_type),saved_to_locker: true,});diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rsindex a63d84777c..161a9a4353 100644--- a/crates/router/src/core/payments/tokenization.rs+++ b/crates/router/src/core/payments/tokenization.rs@@ -7,7 +7,7 @@ use common_utils::{id_type, pii,};use error_stack::{report, ResultExt};-use masking::ExposeInterface;+use masking::{ExposeInterface, PeekInterface};use router_env::{instrument, metrics::add_attributes, tracing};use super::helpers;@@ -468,21 +468,34 @@ where))?};+ let existing_pm_data = payment_methods::cards::get_card_details_without_locker_fallback(+ &existing_pm,+ key_store.key.peek(),+ state,+ )+ .await?;+let updated_card = Some(CardDetailFromLocker {scheme: existing_pm.scheme.clone(),last4_digits: Some(card.card_number.get_last4()),- issuer_country: card.card_issuing_country,+ issuer_country: card+ .card_issuing_country+ .or(existing_pm_data.issuer_country),card_isin: Some(card.card_number.get_card_isin()),card_number: Some(card.card_number),expiry_month: Some(card.card_exp_month),expiry_year: Some(card.card_exp_year),card_token: None,card_fingerprint: None,- card_holder_name: card.card_holder_name,- nick_name: card.nick_name,- card_network: card.card_network,- card_issuer: card.card_issuer,- card_type: card.card_type,+ card_holder_name: card+ .card_holder_name+ .or(existing_pm_data.card_holder_name),+ nick_name: card.nick_name.or(existing_pm_data.nick_name),+ card_network: card+ .card_network+ .or(existing_pm_data.card_network),+ card_issuer: card.card_issuer.or(existing_pm_data.card_issuer),+ card_type: card.card_type.or(existing_pm_data.card_type),saved_to_locker: true,});