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): set requires-cvv to false for cards in customer payment methods list if making an off-session payment (#4075)

Shanksdb25dac5c002
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 847950d4f4..4c38e41e9b 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),