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(core): always route webhooks to UCS for ucs-only connectors (#13299)

Vani Guptab142427f0e06
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index 2f18ed4b2f..e08e332626 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -259,7 +259,7 @@ async fn check_ucs_availability(state: &SessionState) -> UcsAvailability {
}
/// Determines the connector integration type based on UCS configuration or on both
-async fn determine_connector_integration_type(
+pub async fn determine_connector_integration_type(
state: &SessionState,
connector: Connector,
) -> RouterResult<ConnectorIntegrationType> {
@@ -703,14 +703,11 @@ pub async fn should_call_unified_connector_service_for_webhooks(
state: &SessionState,
processor: &Processor,
connector_name: &str,
+ connector_integration_type: ConnectorIntegrationType,
) -> RouterResult<(ExecutionPath, Vec<api_models::webhooks::WebhookFlow>)> {
// Extract context information
let merchant_id = processor.get_account().get_id().get_string_repr();
- let connector_enum = Connector::from_str(connector_name)
- .change_context(errors::ApiErrorResponse::IncorrectConnectorNameGiven)
- .attach_printable_lazy(|| format!("Failed to parse connector name: {}", connector_name))?;
-
let flow_name = "Webhooks";
// Check UCS availability using idiomatic helper
@@ -724,10 +721,6 @@ pub async fn should_call_unified_connector_service_for_webhooks(
flow_name
);
- // Determine connector integration type
- let connector_integration_type =
- determine_connector_integration_type(state, connector_enum).await?;
-
// For webhooks, there is no previous gateway system to consider (webhooks are stateless)
let previous_gateway = None;
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index 8e150bea3e..0b1b49e725 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -205,9 +205,13 @@ fn confirm_path_for_flow(
candidate_path: common_enums::ExecutionPath,
flow: Option<api::WebhookFlow>,
enabled_flows: &[api::WebhookFlow],
+ connector_integration_type: common_enums::ConnectorIntegrationType,
) -> common_enums::ExecutionPath {
- match flow {
- Some(f) if enabled_flows.contains(&f) => candidate_path,
+ match (flow, connector_integration_type) {
+ (_, common_enums::ConnectorIntegrationType::UcsConnector) => {
+ common_enums::ExecutionPath::UnifiedConnectorService
+ }
+ (Some(f), _) if enabled_flows.contains(&f) => candidate_path,
_ => common_enums::ExecutionPath::Direct,
}
}
@@ -283,13 +287,29 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
let connector_name = mca_data.connector_name.clone();
let mca_ref = mca_data.merchant_connector_account.as_ref();
+ let connector_enum = Connector::from_str(&connector_name)
+ .change_context(errors::ApiErrorResponse::IncorrectConnectorNameGiven)
+ .attach_printable_lazy(|| {
+ format!("Failed to parse connector name: {}", connector_name)
+ })?;
+
+ // Determine connector integration type
+ let connector_integration_type =
+ unified_connector_service::determine_connector_integration_type(
+ &state,
+ connector_enum,
+ )
+ .await?;
+
let (candidate_path, enabled_flows) =
unified_connector_service::should_call_unified_connector_service_for_webhooks(
&state,
platform.get_processor(),
&connector_name,
+ connector_integration_type,
)
.await?;
+
logger::info!(
connector = %connector_name,
?candidate_path,
@@ -314,7 +334,12 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
let flow = ucs_event_type.map(api::WebhookFlow::from);
- let execution_path = confirm_path_for_flow(candidate_path, flow, &enabled_flows);
+ let execution_path = confirm_path_for_flow(
+ candidate_path,
+ flow,
+ &enabled_flows,
+ connector_integration_type,
+ );
let execution_mode = match execution_path {
common_enums::ExecutionPath::UnifiedConnectorService => {