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

fix(router): resolve notify connector comments (#13122)

Akshaya Shankarbf3ee5ef4897
diff --git a/crates/router/src/compatibility/stripe/webhooks.rs b/crates/router/src/compatibility/stripe/webhooks.rs
index 4ab7e0d346..860fcfc279 100644
--- a/crates/router/src/compatibility/stripe/webhooks.rs
+++ b/crates/router/src/compatibility/stripe/webhooks.rs
@@ -289,6 +289,8 @@ fn get_stripe_event_type(event_type: api_models::enums::EventType) -> &'static s
api_models::enums::EventType::DisputeLost => "dispute.lost",
api_models::enums::EventType::MandateActive => "mandate.active",
api_models::enums::EventType::MandateRevoked => "mandate.revoked",
+ api_models::enums::EventType::SurchargePaymentSucceeded => "surcharge_payment.succeeded",
+ api_models::enums::EventType::SurchargeRefundSucceeded => "surcharge_refund.succeeded",
// as per this doc https://stripe.com/docs/api/events/types#event_types-payment_intent.amount_capturable_updated
api_models::enums::EventType::PaymentAuthorized => {
@@ -304,9 +306,6 @@ fn get_stripe_event_type(event_type: api_models::enums::EventType) -> &'static s
api_models::enums::EventType::PayoutExpired => "payout.failed",
api_models::enums::EventType::PayoutReversed => "payout.reconciliation_completed",
api_models::enums::EventType::InvoicePaid => "invoice.paid",
- // surcharge events
- api_models::enums::EventType::SurchargePaymentSucceeded => "surcharge_payment.succeeded",
- api_models::enums::EventType::SurchargeRefundSucceeded => "surcharge_refund.succeeded",
}
}
diff --git a/crates/router/src/core/webhooks/outgoing.rs b/crates/router/src/core/webhooks/outgoing.rs
index 8868629129..81457b3a18 100644
--- a/crates/router/src/core/webhooks/outgoing.rs
+++ b/crates/router/src/core/webhooks/outgoing.rs
@@ -66,7 +66,6 @@ pub(crate) async fn get_webhook_events(
},
}];
- #[cfg(feature = "v1")]
if let Some(surcharge_connector_id) = provider_profile
.surcharge_connector_details
.as_ref()
@@ -101,7 +100,6 @@ pub(crate) async fn get_webhook_events(
}
/// Fetches surcharge connector and builds surcharge webhook event if applicable.
-#[cfg(feature = "v1")]
async fn get_surcharge_webhook_event(
state: &SessionState,
platform: domain::Platform,
@@ -1480,7 +1478,6 @@ async fn handle_successful_delivery(
.await
}
-#[cfg(feature = "v1")]
trait OutgoingWebhookResponseHandlerV1 {
#[allow(clippy::too_many_arguments)]
async fn handle_success_response<R: WebhookDeliveryResponse>(
@@ -1513,7 +1510,6 @@ trait OutgoingWebhookResponseHandlerV1 {
>;
}
-#[cfg(feature = "v1")]
impl OutgoingWebhookResponseHandlerV1 for enums::WebhookDeliveryAttempt {
async fn handle_success_response<R: WebhookDeliveryResponse>(
&self,
@@ -1603,7 +1599,6 @@ impl OutgoingWebhookResponseHandlerV1 for enums::WebhookDeliveryAttempt {
}
}
-#[cfg(feature = "v1")]
#[async_trait::async_trait]
trait WebhookNotificationHandlerV1: Send + Sync {
async fn notified_action(
@@ -1625,7 +1620,6 @@ trait WebhookNotificationHandlerV1: Send + Sync {
) -> Option<Report<errors::WebhooksFlowError>>;
}
-#[cfg(feature = "v1")]
#[async_trait::async_trait]
impl WebhookNotificationHandlerV1 for types::InitialAttempt {
async fn notified_action(
@@ -1671,7 +1665,6 @@ impl WebhookNotificationHandlerV1 for types::InitialAttempt {
}
}
-#[cfg(feature = "v1")]
#[async_trait::async_trait]
impl WebhookNotificationHandlerV1 for types::AutomaticRetry {
async fn notified_action(
@@ -1726,7 +1719,6 @@ impl WebhookNotificationHandlerV1 for types::AutomaticRetry {
}
}
-#[cfg(feature = "v1")]
#[async_trait::async_trait]
impl WebhookNotificationHandlerV1 for types::ManualRetry {
async fn notified_action(
diff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rs
index 27bb2cd5b5..07f9e9513a 100644
--- a/crates/router/src/workflows/outgoing_webhook_retry.rs
+++ b/crates/router/src/workflows/outgoing_webhook_retry.rs
@@ -166,8 +166,7 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {
.await;
}
- // Event inserted by old version of application, fetch current information about
- // resource
+ // Event inserted by an older version of the application, or event created when sending webhooks to a connector
None => {
// Fetch provider merchant account and keystore
let provider_key_store = db
@@ -207,6 +206,7 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {
);
// TODO: Add request state for the PT flows as well
+ // Fetch the current resource information
let (content, event_type) =
if let WebhookRecipientData::Merchant { .. } = recipient_data.clone() {
let (content, event_type) =