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): card vault not found error (#9839)

Ankit Kumar Gupta408a36669ac9
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 3348cd2a8c..bb1e52d9f5 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -1708,7 +1708,6 @@ pub async fn update_customer_payment_method(
pm.locker_id.as_ref().unwrap_or(&pm.payment_method_id),
)
.await
- .change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error getting card from locker")?;
if card_update.card_exp_month.is_some() || card_update.card_exp_year.is_some() {
@@ -1937,8 +1936,16 @@ pub async fn get_card_from_locker(
api_enums::LockerChoice::HyperswitchCardVault,
)
.await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed while getting card from hyperswitch card vault")
+ .map_err(|err| match err.current_context() {
+ errors::VaultError::FetchCardFailed => {
+ err.change_context(errors::ApiErrorResponse::GenericNotFoundError {
+ message: "Card not found in vault".to_string(),
+ })
+ }
+ _ => err
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Error getting card from card vault"),
+ })
.inspect_err(|_| {
metrics::CARD_LOCKER_FAILURES.add(
1,
@@ -4616,7 +4623,6 @@ pub async fn get_card_details_from_locker(
pm.locker_id.as_ref().unwrap_or(pm.get_id()),
)
.await
- .change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error getting card from card vault")?;
payment_methods::get_card_detail(pm, card)