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

refactor(euclid): remove disabled mcas from eligibility (#10282)

Prajjwal Kumar54be7cf038b8
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index b9cb8bc2b6..33bfd75820 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -959,15 +959,37 @@ pub async fn perform_cgraph_filtering(
.into_context()
.change_context(errors::RoutingError::KgraphAnalysisError)?,
);
+
let cached_cgraph = get_merchant_cgraph(state, key_store, profile_id, transaction_type).await?;
- let mut final_selection = Vec::<routing_types::RoutableConnectorChoice>::new();
+ let db_mcas = state
+ .store
+ .find_merchant_connector_account_by_merchant_id_and_disabled_list(
+ &state.into(),
+ &key_store.merchant_id,
+ false,
+ key_store,
+ )
+ .await
+ .unwrap_or_else(|_| {
+ hyperswitch_domain_models::merchant_connector_account::MerchantConnectorAccounts::new(
+ vec![],
+ )
+ });
+
+ let active_mca_ids: std::collections::HashSet<_> =
+ db_mcas.iter().map(|mca| mca.get_id().clone()).collect();
+
+ let mut final_selection = Vec::new();
+
for choice in chosen {
let routable_connector = choice.connector;
+
let euclid_choice: ast::ConnectorChoice = choice.clone().foreign_into();
let dir_val = euclid_choice
.into_dir_value()
.change_context(errors::RoutingError::KgraphAnalysisError)?;
+
let cgraph_eligible = cached_cgraph
.check_value_validity(
dir_val,
@@ -981,7 +1003,13 @@ pub async fn perform_cgraph_filtering(
let filter_eligible =
eligible_connectors.is_none_or(|list| list.contains(&routable_connector));
- if cgraph_eligible && filter_eligible {
+ let mca_active = choice
+ .merchant_connector_id
+ .as_ref()
+ .map(|id| active_mca_ids.contains(id))
+ .unwrap_or(false);
+
+ if cgraph_eligible && filter_eligible && mca_active {
final_selection.push(choice);
}
}