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(webhooks): Fix incoming webhooks failure (#9894)

Gaurav Rawat46fc68841143
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index 4ff7c4c06e..bb76c664b5 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -348,11 +348,6 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
&webhook_processing_result.transform_data,
&final_request_details,
is_relay_webhook,
- merchant_connector_account
- .ok_or(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
- id: connector_name_or_mca_id.to_string(),
- })?
- .merchant_connector_id,
)
.await;
@@ -536,7 +531,6 @@ async fn process_webhook_business_logic(
webhook_transform_data: &Option<Box<unified_connector_service::WebhookTransformData>>,
request_details: &IncomingWebhookRequestDetails<'_>,
is_relay_webhook: bool,
- billing_connector_mca_id: common_utils::id_type::MerchantConnectorAccountId,
) -> errors::RouterResult<WebhookResponseTracker> {
let object_ref_id = connector
.get_webhook_object_reference_id(request_details)
@@ -842,7 +836,7 @@ async fn process_webhook_business_logic(
connector,
request_details,
event_type,
- billing_connector_mca_id,
+ merchant_connector_account,
))
.await
.attach_printable("Incoming webhook flow for subscription failed")
diff --git a/crates/subscriptions/src/webhooks.rs b/crates/subscriptions/src/webhooks.rs
index 8dc28720b9..e09dc277c6 100644
--- a/crates/subscriptions/src/webhooks.rs
+++ b/crates/subscriptions/src/webhooks.rs
@@ -5,7 +5,8 @@ use common_enums::{connector_enums::Connector, InvoiceStatus};
use common_utils::{consts, errors::CustomResult, generate_id};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
- business_profile, errors::api_error_response as errors, invoice, merchant_context,
+ business_profile, errors::api_error_response as errors, invoice, merchant_connector_account,
+ merchant_context,
};
use hyperswitch_interfaces::{
api::ConnectorCommon, connector_integration_interface, errors::ConnectorError,
@@ -29,8 +30,9 @@ pub async fn incoming_webhook_flow(
connector_enum: &connector_integration_interface::ConnectorEnum,
request_details: &hyperswitch_interfaces::webhooks::IncomingWebhookRequestDetails<'_>,
event_type: api_models::webhooks::IncomingWebhookEvent,
- billing_connector_mca_id: common_utils::id_type::MerchantConnectorAccountId,
+ merchant_connector_account: merchant_connector_account::MerchantConnectorAccount,
) -> CustomResult<WebhookResponseTracker, errors::ApiErrorResponse> {
+ let billing_connector_mca_id = merchant_connector_account.merchant_connector_id.clone();
// Only process invoice_generated events for MIT payments
if event_type != api_models::webhooks::IncomingWebhookEvent::InvoiceGenerated {
return Ok(WebhookResponseTracker::NoEffect);