From 3d7e22a4f106e4d7c4224fecf455e2f2aa417cd0 Mon Sep 17 00:00:00 2001 From: Hrithikesh <61539176+hrithikesh026@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:30:51 +0530 Subject: [PATCH] fix(connector): make webhook source verification mandatory for adyen (#2360) --- crates/router/src/connector/adyen.rs | 3 +++ crates/router/src/core/webhooks.rs | 4 ++++ crates/router/src/services/api.rs | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index 82fa35ceb6..bc6930891b 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -104,6 +104,9 @@ impl ConnectorValidation for Adyen { } .into()) } + fn is_webhook_source_verification_mandatory(&self) -> bool { + true + } } impl api::Payment for Adyen {} diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs index ed7ba920b7..c365e3e6bf 100644 --- a/crates/router/src/core/webhooks.rs +++ b/crates/router/src/core/webhooks.rs @@ -895,6 +895,10 @@ pub async fn webhooks_core( merchant_account.merchant_id.clone(), )], ); + } else if connector.is_webhook_source_verification_mandatory() { + // if webhook consumption is mandatory for connector, fail webhook + // so that merchant can retrigger it after updating merchant_secret + return Err(errors::ApiErrorResponse::WebhookAuthenticationFailed.into()); } logger::info!(source_verified=?source_verified); diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index 432844afbe..ec358e357f 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -88,6 +88,10 @@ pub trait ConnectorValidation: ConnectorCommon { .change_context(errors::ConnectorError::MissingConnectorTransactionID) .map(|_| ()) } + + fn is_webhook_source_verification_mandatory(&self) -> bool { + false + } } #[async_trait::async_trait]