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
refactor(core): add webhook_url for v2 tunnel (#9625)
Aishwariyaa Ananddf51a4ff9430
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 434bbd298b..1bbeb5f04c 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -19133,6 +19133,12 @@"type": "boolean","description": "If true, returns stringified connector raw response body","nullable": true+ },+ "webhook_url": {+ "type": "string",+ "description": "The webhook endpoint URL to receive payment status notifications",+ "example": "https://merchant.example.com/webhooks/payment",+ "nullable": true}},"additionalProperties": false@@ -20186,6 +20192,12 @@"description": "Allow partial authorization for this payment","default": false,"nullable": true+ },+ "webhook_url": {+ "type": "string",+ "description": "The webhook endpoint URL to receive payment status notifications",+ "example": "https://merchant.example.com/webhooks/payment",+ "nullable": true}},"additionalProperties": falsediff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex ecc34cbd43..dfc2808814 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -5942,6 +5942,10 @@ pub struct PaymentsConfirmIntentRequest {/// If true, returns stringified connector raw response bodypub return_raw_connector_response: Option<bool>,++ /// The webhook endpoint URL to receive payment status notifications+ #[schema(value_type = Option<String>, example = "https://merchant.example.com/webhooks/payment")]+ pub webhook_url: Option<common_utils::types::Url>,}// Serialize is implemented because, this will be serialized in the api events.@@ -6182,6 +6186,10 @@ pub struct PaymentsRequest {/// Allow partial authorization for this payment#[schema(value_type = Option<bool>, default = false)]pub enable_partial_authorization: Option<primitive_wrappers::EnablePartialAuthorizationBool>,++ /// The webhook endpoint URL to receive payment status notifications+ #[schema(value_type = Option<String>, example = "https://merchant.example.com/webhooks/payment")]+ pub webhook_url: Option<common_utils::types::Url>,}#[cfg(feature = "v2")]@@ -6237,6 +6245,7 @@ impl From<&PaymentsRequest> for PaymentsConfirmIntentRequest {merchant_connector_details: request.merchant_connector_details.clone(),return_raw_connector_response: request.return_raw_connector_response,split_payment_method_data: None,+ webhook_url: request.webhook_url.clone(),}}}diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex b1f7a4745e..a01efdf074 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -944,6 +944,8 @@ wherepub payment_method: Option<payment_methods::PaymentMethod>,pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,pub external_vault_pmd: Option<payment_method_data::ExternalVaultPaymentMethodData>,+ /// The webhook url of the merchant, to which the connector will send the webhook.+ pub webhook_url: Option<String>,}#[cfg(feature = "v2")]diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 72c91ca43d..f1f5c482c3 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -3438,6 +3438,7 @@ fn construct_zero_auth_payments_request(merchant_connector_details: None,return_raw_connector_response: None,enable_partial_authorization: None,+ webhook_url: None,})}diff --git a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rsindex 7d40bb81c2..4e4302b1d5 100644--- a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs+++ b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs@@ -298,6 +298,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ExternalVaultPpayment_method: None,merchant_connector_details: None,external_vault_pmd: payment_method_data,+ webhook_url: None,};let get_trackers_response = operations::GetTrackerResponse { payment_data };diff --git a/crates/router/src/core/payments/operations/payment_confirm_intent.rs b/crates/router/src/core/payments/operations/payment_confirm_intent.rsindex 242ff3a425..f7db988b26 100644--- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs+++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs@@ -276,6 +276,10 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, PaymentsConfirpayment_method: None,merchant_connector_details,external_vault_pmd: None,+ webhook_url: request+ .webhook_url+ .as_ref()+ .map(|url| url.get_string_repr().to_string()),};let get_trackers_response = operations::GetTrackerResponse { payment_data };diff --git a/crates/router/src/core/payments/operations/proxy_payments_intent.rs b/crates/router/src/core/payments/operations/proxy_payments_intent.rsindex c53aff42b5..ceae5d850f 100644--- a/crates/router/src/core/payments/operations/proxy_payments_intent.rs+++ b/crates/router/src/core/payments/operations/proxy_payments_intent.rs@@ -269,6 +269,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ProxyPaymentsRpayment_method: None,merchant_connector_details: None,external_vault_pmd: None,+ webhook_url: None,};let get_trackers_response = operations::GetTrackerResponse { payment_data };diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex e0859f7642..b740ca8f28 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -334,8 +334,9 @@ pub async fn construct_payment_router_data_for_authorize<'a>(&attempt.merchant_id,merchant_connector_account.get_id().get_string_repr(),)),- // TODO: Implement for connectors that require a webhook URL to be included in the request payload.- domain::MerchantConnectorAccountTypeDetails::MerchantConnectorDetails(_) => None,+ domain::MerchantConnectorAccountTypeDetails::MerchantConnectorDetails(_) => {+ payment_data.webhook_url+ }};let router_return_url = payment_data@@ -587,8 +588,9 @@ pub async fn construct_external_vault_proxy_payment_router_data<'a>(&attempt.merchant_id,merchant_connector_account.get_id().get_string_repr(),)),- // TODO: Implement for connectors that require a webhook URL to be included in the request payload.- domain::MerchantConnectorAccountTypeDetails::MerchantConnectorDetails(_) => None,+ domain::MerchantConnectorAccountTypeDetails::MerchantConnectorDetails(_) => {+ payment_data.webhook_url.clone()+ }};let router_return_url = payment_data@@ -1432,9 +1434,8 @@ pub async fn construct_payment_router_data_for_setup_mandate<'a>(&attempt.merchant_id,merchant_connector_account.get_id().get_string_repr(),)),- // TODO: Implement for connectors that require a webhook URL to be included in the request payload.domain::MerchantConnectorAccountTypeDetails::MerchantConnectorDetails(_) => {- todo!("Add webhook URL to request for this connector")+ payment_data.webhook_url}};