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
feat(webhooks): use mTLS callback URL for production connector webhook registration (#15237)
Sayak Bhattacharya676c83ebc623
diff --git a/config/config.example.toml b/config/config.example.tomlindex 3744d52039..3484c7c230 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -1537,6 +1537,7 @@ global_tenant = { tenant_id = "global", schema = "public", redis_key_prefix = ""[multitenancy.tenants.public]base_url = "http://localhost:8080" # URL of the tenant+mtls_base_url = "http://localhost:8080"schema = "public" # Postgres db schemaaccounts_schema = "public"redis_key_prefix = "" # Redis key distinguisherdiff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.tomlindex cbc1dad258..b1c6315376 100644--- a/config/deployments/env_specific.toml+++ b/config/deployments/env_specific.toml@@ -472,6 +472,7 @@ global_tenant = { tenant_id = "global", schema = "public", redis_key_prefix = ""[multitenancy.tenants.public]base_url = "http://localhost:8080"+mtls_base_url = "http://localhost:8080"schema = "public"accounts_schema = "public"redis_key_prefix = ""diff --git a/config/development.toml b/config/development.tomlindex fe33247522..15b9476700 100644--- a/config/development.toml+++ b/config/development.toml@@ -1626,6 +1626,7 @@ global_tenant = { tenant_id = "global", schema = "public", redis_key_prefix = "g[multitenancy.tenants.public]base_url = "http://localhost:8080"+mtls_base_url = "http://localhost:8080"schema = "public"accounts_schema = "public"redis_key_prefix = ""diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 9b76c35e34..dd0b92afa7 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -1445,6 +1445,7 @@ global_tenant = { tenant_id = "global", schema = "public", redis_key_prefix = ""[multitenancy.tenants.public]base_url = "http://localhost:8080"+mtls_base_url = "http://localhost:8080"schema = "public"accounts_schema = "public"redis_key_prefix = ""diff --git a/crates/hyperswitch_connectors/src/connectors/santander.rs b/crates/hyperswitch_connectors/src/connectors/santander.rsindex aa3f7d5993..f12d0a681a 100644--- a/crates/hyperswitch_connectors/src/connectors/santander.rs+++ b/crates/hyperswitch_connectors/src/connectors/santander.rs@@ -2127,7 +2127,10 @@ impl webhooks::IncomingWebhook for Santander {_connector_name: &str,) -> CustomResult<bool, errors::ConnectorError> {// The router establishes source verification only after successful mTLS validation.- Ok(false)+ Ok(!matches!(+ router_env::env::which(),+ router_env::env::Env::Production+ ))}fn get_webhook_object_reference_id(@@ -2497,7 +2500,7 @@ static SANTANDER_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];impl ConnectorSpecifications for Santander {fn is_webhook_mtls_required(&self) -> bool {- true+ matches!(router_env::env::which(), router_env::env::Env::Production)}fn is_payment_recurrence_operation_needed(diff --git a/crates/hyperswitch_interfaces/src/configs.rs b/crates/hyperswitch_interfaces/src/configs.rsindex e19b0a8c6b..c09ecbb553 100644--- a/crates/hyperswitch_interfaces/src/configs.rs+++ b/crates/hyperswitch_interfaces/src/configs.rs@@ -13,6 +13,7 @@ use crate::secrets_interface::SecretsManagementError;pub struct Tenant {pub tenant_id: id_type::TenantId,pub base_url: String,+ pub mtls_base_url: Option<String>,pub schema: String,pub accounts_schema: String,pub redis_key_prefix: String,diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rsindex a16890beab..02d83324fd 100644--- a/crates/router/src/configs/settings.rs+++ b/crates/router/src/configs/settings.rs@@ -2044,6 +2044,8 @@ impl<'de> Deserialize<'de> for TenantConfig {#[derive(Deserialize)]struct Inner {base_url: String,+ #[serde(default)]+ mtls_base_url: Option<String>,schema: String,accounts_schema: String,redis_key_prefix: String,@@ -2062,6 +2064,7 @@ impl<'de> Deserialize<'de> for TenantConfig {Tenant {tenant_id: key,base_url: value.base_url,+ mtls_base_url: value.mtls_base_url,schema: value.schema,accounts_schema: value.accounts_schema,redis_key_prefix: value.redis_key_prefix,diff --git a/crates/router/src/core/merchant_connector_webhook_management.rs b/crates/router/src/core/merchant_connector_webhook_management.rsindex acaf4736c2..81f47fa1e2 100644--- a/crates/router/src/core/merchant_connector_webhook_management.rs+++ b/crates/router/src/core/merchant_connector_webhook_management.rs@@ -225,6 +225,9 @@ pub async fn register_connector_webhook(.get_webhook_registration_plan(scope, &state.conf.connectors).to_webhook_configuration_failed_response()?;+ let webhook_base_url = state+ .get_webhook_registration_base_url(connector_data.connector.is_webhook_mtls_required())?;+let scope_type = configure_connector_webhook_flow::determine_scope_type(scope);let requested = configure_connector_webhook_flow::extract_requested_identifiers(scope);@@ -258,7 +261,7 @@ pub async fn register_connector_webhook(let merchant_connector_id = mca.merchant_connector_id.get_string_repr();let webhook_url = helpers::create_webhook_url(- &state.base_url,+ webhook_base_url,&mca.merchant_id,merchant_connector_id,);diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex 09d9d60bf1..c882fd2248 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -120,7 +120,7 @@ use crate::{configs::{secrets_transformers, Settings},core::configs::payment_callback::PaymentCallbackConfig,db::kafka_store::{KafkaStore, TenantID},- errors::RouterResult,+ errors::{self, RouterResult},routes::{hypersense as hypersense_routes, three_ds_decision_rule},};@@ -200,6 +200,23 @@ impl SessionState {operation(self.accounts_store.as_ref()).await})}++ pub(crate) fn get_webhook_registration_base_url(+ &self,+ connector_requires_mtls: bool,+ ) -> RouterResult<&str> {+ if connector_requires_mtls {+ self.tenant.mtls_base_url.as_deref().ok_or_else(|| {+ error_stack::Report::new(errors::ApiErrorResponse::InternalServerError)+ .attach_printable(+ "mtls_base_url must be configured for connectors that require mTLS webhooks",+ )+ })+ } else {+ Ok(&self.base_url)+ }+ }+/// Resolve the runtime callback policy once for this request and its clones.pub async fn payment_callback_config(&self) -> RouterResult<&PaymentCallbackConfig> {self.payment_callback_configdiff --git a/loadtest/config/development.toml b/loadtest/config/development.tomlindex 091ee36de6..cd554fd817 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -962,6 +962,7 @@ global_tenant = { tenant_id = "global", schema = "public", redis_key_prefix = ""[multitenancy.tenants.public]base_url = "http://localhost:8080"+mtls_base_url = "http://localhost:8080"schema = "public"accounts_schema = "public"redis_key_prefix = ""