From 352e342b38a3ad36bd9aff657156e723f6d2d543 Mon Sep 17 00:00:00 2001 From: shashank_attarde Date: Wed, 13 Mar 2024 17:11:31 +0530 Subject: [PATCH] fix(payment_methods): set requires-cvv to false for cards in customer payment methods list if making an off-session payment --- crates/router/src/core/payment_methods/cards.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 847950d4f451..4c38e41e9bb4 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -2736,6 +2736,16 @@ pub async fn list_customer_payment_method( } }; + let off_session_payment_flag = payment_intent + .as_ref() + .map(|pi| { + matches!( + pi.setup_future_usage, + Some(common_enums::FutureUsage::OffSession) + ) + }) + .unwrap_or(false); + let customer = db .find_customer_by_customer_id_merchant_id( customer_id, @@ -2872,7 +2882,8 @@ pub async fn list_customer_payment_method( bank_transfer: pmd, bank: bank_details, surcharge_details: None, - requires_cvv, + requires_cvv: requires_cvv + && !(off_session_payment_flag && pm.connector_mandate_details.is_some()), last_used_at: Some(pm.last_used_at), default_payment_method_set: customer.default_payment_method_id.is_some() && customer.default_payment_method_id == Some(pm.payment_method_id),