diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index ad612ed6f3be..889ec8636c7c 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -4559,6 +4559,12 @@ pub async fn filter_payment_methods( if payment_attempt .and_then(|attempt| attempt.mandate_details.as_ref()) .is_some() + || payment_intent + .and_then(|intent| intent.setup_future_usage) + .map(|future_usage| { + future_usage == common_enums::FutureUsage::OffSession + }) + .unwrap_or(false) { context_values.push(dir::DirValue::PaymentType( euclid::enums::PaymentType::NewMandate, @@ -4577,7 +4583,14 @@ pub async fn filter_payment_methods( payment_attempt .map(|attempt| { - attempt.mandate_data.is_none() && attempt.mandate_details.is_none() + attempt.mandate_data.is_none() + && attempt.mandate_details.is_none() + && payment_intent + .and_then(|intent| intent.setup_future_usage) + .map(|future_usage| { + future_usage == common_enums::FutureUsage::OnSession + }) + .unwrap_or(false) }) .and_then(|res| { res.then(|| { diff --git a/crates/router/src/core/payment_methods/utils.rs b/crates/router/src/core/payment_methods/utils.rs index 604e8c706262..8ff7135d0c21 100644 --- a/crates/router/src/core/payment_methods/utils.rs +++ b/crates/router/src/core/payment_methods/utils.rs @@ -429,16 +429,20 @@ fn construct_supported_connectors_for_update_mandate_node( } } - Ok(Some( - builder - .make_any_aggregator( - &agg_nodes, - Some("any node for card and non card pm"), - None::<()>, - Some(domain_id), - ) - .map_err(KgraphError::GraphConstructionError)?, - )) + if !agg_nodes.is_empty() { + Ok(Some( + builder + .make_any_aggregator( + &agg_nodes, + Some("any node for card and non card pm"), + None::<()>, + Some(domain_id), + ) + .map_err(KgraphError::GraphConstructionError)?, + )) + } else { + Ok(None) + } } fn construct_supported_connectors_for_mandate_node(