fix(payment_methods): use existing field value of nick_name in db if not sent during request (#5105)

This commit is contained in:
Chethan Rao
2024-06-25 15:27:15 +05:30
committed by GitHub
parent 2cf2123edd
commit ea74f3e537
2 changed files with 37 additions and 13 deletions

View File

@ -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,
});