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(webhooks): move webhook acknowledge config to cover early deserialization errors (#9508)

Kashif2a00e7226909
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index 84a1a7bd47..d1203cd1a3 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -226,7 +226,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
// Determine webhook processing path (UCS vs non-UCS) and handle event type extraction
let webhook_processing_result =
- if unified_connector_service::should_call_unified_connector_service_for_webhooks(
+ match if unified_connector_service::should_call_unified_connector_service_for_webhooks(
&state,
&merchant_context,
&connector_name,
@@ -245,7 +245,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
&request_details,
merchant_connector_account.as_ref(),
)
- .await?
+ .await
} else {
// NON-UCS PATH: Need to decode body first
let decoded_body = connector
@@ -268,7 +268,23 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
decoded_body.into(),
&request_details,
)
- .await?
+ .await
+ } {
+ Ok(result) => result,
+ Err(error) => {
+ let error_result = handle_incoming_webhook_error(
+ error,
+ &connector,
+ connector_name.as_str(),
+ &request_details,
+ );
+ match error_result {
+ Ok((response, webhook_tracker, serialized_request)) => {
+ return Ok((response, webhook_tracker, serialized_request));
+ }
+ Err(e) => return Err(e),
+ }
+ }
};
// if it is a setup webhook event, return ok status