Skip to content

Commit

Permalink
fix: remove error propagation if card name not found in locker
Browse files Browse the repository at this point in the history
  • Loading branch information
Chethan-rao committed Nov 28, 2023
1 parent 77fc92c commit e965b7d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,21 +1459,24 @@ pub async fn retrieve_card_with_permanent_token(
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("failed to fetch card information from the permanent locker")?;

let name = card
.name_on_card
.get_required_value("name_on_card")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("card holder name was not saved in permanent locker")?;

let name_on_card = if name.clone().expose().is_empty() {
let name_on_card = if let Some(name_on_card) = card.name_on_card.clone() {
if card.name_on_card.unwrap_or_default().expose().is_empty() {
card_token_data
.and_then(|token_data| token_data.card_holder_name.clone())
.filter(|name_on_card| !name_on_card.clone().expose().is_empty())
.ok_or(errors::ApiErrorResponse::MissingRequiredField {
field_name: "card_holder_name",
})?
} else {
name_on_card
}
} else {
card_token_data
.and_then(|token_data| token_data.card_holder_name.clone())
.filter(|name_on_card| !name_on_card.clone().expose().is_empty())
.ok_or(errors::ApiErrorResponse::MissingRequiredField {
field_name: "card_holder_name",
})?
} else {
name
};

let api_card = api::Card {
Expand Down

0 comments on commit e965b7d

Please sign in to comment.