From 5c32b3739e2c5895fe7f5cf8cc92f917c2639eac Mon Sep 17 00:00:00 2001 From: Chethan Rao <70657455+Chethan-rao@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:47:16 +0530 Subject: [PATCH] fix: remove error propagation if card name not found in locker in case of temporary token (#3006) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/router/src/core/payments/helpers.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 266792f98758..7a8a76e1123a 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1381,18 +1381,19 @@ pub async fn retrieve_payment_method_with_temporary_token( let name_on_card = if card.card_holder_name.clone().expose().is_empty() { card_token_data - .and_then(|token_data| { + .and_then(|token_data| token_data.card_holder_name.clone()) + .filter(|name_on_card| !name_on_card.clone().expose().is_empty()) + .map(|name_on_card| { is_card_updated = true; - token_data.card_holder_name.clone() + name_on_card }) - .filter(|name_on_card| !name_on_card.clone().expose().is_empty()) - .ok_or(errors::ApiErrorResponse::MissingRequiredField { - field_name: "card_holder_name", - })? } else { - card.card_holder_name.clone() + Some(card.card_holder_name.clone()) }; - updated_card.card_holder_name = name_on_card; + + if let Some(name_on_card) = name_on_card { + updated_card.card_holder_name = name_on_card; + } if let Some(cvc) = card_cvc { is_card_updated = true;