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

feat(router): add webhook_setup_capabilities to merchant response (#10793)

AkshayaFoiger96277280393b
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 3cb305b1ca..154110e772 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -22287,6 +22287,14 @@
}
],
"nullable": true
+ },
+ "webhook_setup_capabilities": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/WebhookSetupCapabilities"
+ }
+ ],
+ "nullable": true
}
},
"additionalProperties": false
@@ -39020,6 +39028,34 @@
"WeChatPayRedirection": {
"type": "object"
},
+ "WebhookConfigType": {
+ "oneOf": [
+ {
+ "type": "string",
+ "description": "Standard webhook configuration supporting all events hyperswitch provides",
+ "enum": [
+ "Standard"
+ ]
+ },
+ {
+ "type": "object",
+ "required": [
+ "CustomEvents"
+ ],
+ "properties": {
+ "CustomEvents": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/EventType"
+ }
+ ],
+ "nullable": true
+ }
+ }
+ }
+ ],
+ "description": "Enum to represent the type of webhook configuration"
+ },
"WebhookDeliveryAttempt": {
"type": "string",
"enum": [
@@ -39119,6 +39155,32 @@
},
"additionalProperties": false
},
+ "WebhookSetupCapabilities": {
+ "type": "object",
+ "description": "Connector details for webhook configuration via hyperswitch API",
+ "required": [
+ "is_webhook_auto_configuration_supported"
+ ],
+ "properties": {
+ "is_webhook_auto_configuration_supported": {
+ "type": "boolean",
+ "description": "Indicates if the connector supports webhooks configuration via API"
+ },
+ "requires_webhook_secret": {
+ "type": "boolean",
+ "description": "Indicates whether a webhook secret must be collected from the merchant for verification",
+ "nullable": true
+ },
+ "config_type": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/WebhookConfigType"
+ }
+ ],
+ "nullable": true
+ }
+ }
+ },
"XenditChargeResponseData": {
"oneOf": [
{
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index 9c00b9c60c..baa0e69dcf 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -1483,6 +1483,11 @@ pub struct MerchantConnectorResponse {
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
#[schema(value_type = Option<ConnectorWalletDetails>)]
pub connector_wallets_details: Option<ConnectorWalletDetails>,
+
+ /// Details about the connector’s webhook configuration
+ #[schema(value_type = Option<WebhookSetupCapabilities>)]
+ pub webhook_setup_capabilities:
+ Option<common_types::connector_webhook_configuration::WebhookSetupCapabilities>,
}
#[cfg(feature = "v1")]
diff --git a/crates/common_types/src/connector_webhook_configuration.rs b/crates/common_types/src/connector_webhook_configuration.rs
new file mode 100644
index 0000000000..5393411c5f
--- /dev/null
+++ b/crates/common_types/src/connector_webhook_configuration.rs
@@ -0,0 +1,25 @@
+use serde::{Deserialize, Serialize};
+use utoipa::ToSchema;
+
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema)]
+/// Connector details for webhook configuration via hyperswitch API
+pub struct WebhookSetupCapabilities {
+ /// Indicates if the connector supports webhooks configuration via API
+ pub is_webhook_auto_configuration_supported: bool,
+
+ /// Indicates whether a webhook secret must be collected from the merchant for verification
+ pub requires_webhook_secret: Option<bool>,
+
+ /// The type of webhook configuration supported by the connector
+ pub config_type: Option<WebhookConfigType>,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema)]
+/// Enum to represent the type of webhook configuration
+pub enum WebhookConfigType {
+ /// Standard webhook configuration supporting all events hyperswitch provides
+ Standard,
+ /// Custom webhook configuration supporting only specific events
+ #[schema(value_type = Option<EventType>)]
+ CustomEvents(Vec<common_enums::EventType>),
+}
diff --git a/crates/common_types/src/lib.rs b/crates/common_types/src/lib.rs
index 91ee876184..fde491ee14 100644
--- a/crates/common_types/src/lib.rs
+++ b/crates/common_types/src/lib.rs
@@ -15,3 +15,6 @@ pub mod three_ds_decision_rule_engine;
///types for callback mapper
pub mod callback_mapper;
+
+///types for connector webhook configuration
+pub mod connector_webhook_configuration;
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen.rs b/crates/hyperswitch_connectors/src/connectors/adyen.rs
index c3f2bd35d0..24843343c6 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen.rs
@@ -3342,7 +3342,6 @@ impl ConnectorSpecifications for Adyen {
Some(ADYEN_SUPPORTED_WEBHOOK_FLOWS)
}
- #[cfg(feature = "v1")]
fn generate_connector_customer_id(
&self,
customer_id: &Option<common_utils::id_type::CustomerId>,
diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs
index d78fc83014..8e775cfd55 100644
--- a/crates/hyperswitch_interfaces/src/api.rs
+++ b/crates/hyperswitch_interfaces/src/api.rs
@@ -586,6 +586,13 @@ pub trait ConnectorSpecifications {
fn should_call_tokenization_before_setup_mandate(&self) -> bool {
true
}
+
+ /// Get connector's API webhook configuration object
+ fn get_api_webhook_config(
+ &self,
+ ) -> &'static common_types::connector_webhook_configuration::WebhookSetupCapabilities {
+ &consts::DEFAULT_WEBHOOK_SETUP_CAPABILITIES
+ }
}
/// Extended trait for connector common to allow functions with generic type
diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
index 733fd304ff..8398544710 100644
--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
@@ -729,6 +729,14 @@ impl ConnectorSpecifications for ConnectorEnum {
Self::New(connector) => connector.should_call_tokenization_before_setup_mandate(),
}
}
+ fn get_api_webhook_config(
+ &self,
+ ) -> &'static common_types::connector_webhook_configuration::WebhookSetupCapabilities {
+ match self {
+ Self::Old(connector) => connector.get_api_webhook_config(),
+ Self::New(connector) => connector.get_api_webhook_config(),
+ }
+ }
}
impl ConnectorCommon for ConnectorEnum {
diff --git a/crates/hyperswitch_interfaces/src/consts.rs b/crates/hyperswitch_interfaces/src/consts.rs
index f5214b4db7..deacbddd1c 100644
--- a/crates/hyperswitch_interfaces/src/consts.rs
+++ b/crates/hyperswitch_interfaces/src/consts.rs
@@ -38,3 +38,12 @@ pub const X_FLOW_NAME: &str = "x-flow";
/// Header name for request ID
pub const X_REQUEST_ID: &str = "x-request-id";
+
+/// Default webhook setup capabilities for connectors
+pub static DEFAULT_WEBHOOK_SETUP_CAPABILITIES:
+ common_types::connector_webhook_configuration::WebhookSetupCapabilities =
+ common_types::connector_webhook_configuration::WebhookSetupCapabilities {
+ is_webhook_auto_configuration_supported: false,
+ requires_webhook_secret: None,
+ config_type: None,
+ };
diff --git a/crates/kgraph_utils/benches/evaluation.rs b/crates/kgraph_utils/benches/evaluation.rs
index 094c687b60..9acb9c7f3d 100644
--- a/crates/kgraph_utils/benches/evaluation.rs
+++ b/crates/kgraph_utils/benches/evaluation.rs
@@ -98,6 +98,7 @@ fn build_test_data(
status: api_enums::ConnectorStatus::Inactive,
additional_merchant_data: None,
connector_wallets_details: None,
+ webhook_setup_capabilities: None,
};
let config = CountryCurrencyFilter {
connector_configs: HashMap::new(),
diff --git a/crates/kgraph_utils/src/mca.rs b/crates/kgraph_utils/src/mca.rs
index 8b72caa6af..653151c655 100644
--- a/crates/kgraph_utils/src/mca.rs
+++ b/crates/kgraph_utils/src/mca.rs
@@ -1195,6 +1195,7 @@ mod tests {
status: api_enums::ConnectorStatus::Inactive,
additional_merchant_data: None,
connector_wallets_details: None,
+ webhook_setup_capabilities: None,
};
let config_map = kgraph_types::CountryCurrencyFilter {
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 227552aa0d..507ea24f9c 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -266,6 +266,8 @@ Never share your secret api keys. Keep them guarded and secure.
common_utils::payout_method_utils::ApplePayDecryptAdditionalData,
common_utils::payout_method_utils::PassthroughAddtionalData,
common_types::payments::SplitPaymentsRequest,
+ common_types::connector_webhook_configuration::WebhookSetupCapabilities,
+ common_types::connector_webhook_configuration::WebhookConfigType,
common_types::payments::GpayTokenizationData,
common_types::payments::GPayPredecryptData,
common_types::payments::GpayEcryptedTokenizationData,
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 6af9d458a3..451fd16071 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -14,6 +14,7 @@ use common_utils::{
use diesel_models::enums as storage_enums;
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::payments::payment_intent::CustomerData;
+use hyperswitch_interfaces::api::ConnectorSpecifications;
use masking::{ExposeInterface, PeekInterface, Secret};
use super::domain;
@@ -1049,6 +1050,11 @@ impl ForeignTryFrom<domain::MerchantConnectorAccount>
})
.transpose()?,
};
+
+ let webhook_setup_details =
+ api_types::ConnectorData::convert_connector(item.connector_name.as_str())?
+ .get_api_webhook_config();
+
#[cfg(feature = "v1")]
let response = Self {
connector_type: item.connector_type,
@@ -1104,6 +1110,7 @@ impl ForeignTryFrom<domain::MerchantConnectorAccount>
.change_context(errors::ApiErrorResponse::InternalServerError)
})
.transpose()?,
+ webhook_setup_capabilities: Some(webhook_setup_details.clone()),
};
Ok(response)
}