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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(webhook): do not fail webhook verification if merchant_secret is not set by merchant (#1732)
Hrithikesh374f2c28cd2b
diff --git a/crates/router/src/types/api/webhooks.rs b/crates/router/src/types/api/webhooks.rsindex 14bd5695bb..5fd5621ef9 100644--- a/crates/router/src/types/api/webhooks.rs+++ b/crates/router/src/types/api/webhooks.rs@@ -4,7 +4,7 @@ pub use api_models::webhooks::{OutgoingWebhook, OutgoingWebhookContent, WebhookFlow,};use common_utils::ext_traits::ValueExt;-use error_stack::{IntoReport, ResultExt};+use error_stack::ResultExt;use masking::ExposeInterface;use super::ConnectorCommon;@@ -101,22 +101,25 @@ pub trait IncomingWebhook: ConnectorCommon + Sync {)})?.connector_webhook_details;- let merchant_secret = merchant_connector_webhook_details- .ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)- .into_report()- .attach_printable_lazy(|| format!("Merchant Secret not configured {}", debug_suffix))?- .expose()- .parse_value::<MerchantConnectorWebhookDetails>("MerchantConnectorWebhookDetails")- .change_context_lazy(|| errors::ConnectorError::WebhookSourceVerificationFailed)- .attach_printable_lazy(|| {- format!(- "Deserializing MerchantConnectorWebhookDetails failed {}",- debug_suffix- )- })?- .merchant_secret- .expose();++ let merchant_secret = match merchant_connector_webhook_details {+ Some(merchant_connector_webhook_details) => merchant_connector_webhook_details+ .parse_value::<MerchantConnectorWebhookDetails>("MerchantConnectorWebhookDetails")+ .change_context_lazy(|| errors::ConnectorError::WebhookSourceVerificationFailed)+ .attach_printable_lazy(|| {+ format!(+ "Deserializing MerchantConnectorWebhookDetails failed {}",+ debug_suffix+ )+ })?+ .merchant_secret+ .expose(),+ None => "default_secret".to_string(),+ };//need to fetch merchant secret from config table with caching in future for enhanced performance++ //If merchant has not set the secret for webhook source verification, "default_secret" is returned.+ //So it will fail during verification step and goes to psync flow.Ok(merchant_secret.into_bytes())}