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(payments): add outgoing payments webhooks (#3133)

Narayan Bhatf4578463d5e1
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 3f815f16be..44c4673252 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -89,7 +89,7 @@ pub async fn payments_operation_core<F, Req, Op, FData, Ctx>(
)>
where
F: Send + Clone + Sync,
- Req: Authenticate,
+ Req: Authenticate + Clone,
Op: Operation<F, Req, Ctx> + Send + Sync,
// To create connector flow specific interface data
@@ -423,6 +423,23 @@ where
.await?;
}
+ let cloned_payment_data = payment_data.clone();
+ let cloned_customer = customer.clone();
+ let cloned_request = req.clone();
+
+ crate::utils::trigger_payments_webhook(
+ merchant_account,
+ business_profile,
+ cloned_payment_data,
+ Some(cloned_request),
+ cloned_customer,
+ state,
+ operation,
+ )
+ .await
+ .map_err(|error| logger::warn!(payments_outgoing_webhook_error=?error))
+ .ok();
+
Ok((
payment_data,
req,
@@ -624,7 +641,7 @@ where
F: Send + Clone + Sync,
FData: Send + Sync,
Op: Operation<F, Req, Ctx> + Send + Sync + Clone,
- Req: Debug + Authenticate,
+ Req: Debug + Authenticate + Clone,
Res: transformers::ToResponse<Req, PaymentData<F>, Op>,
// To create connector flow specific interface data
PaymentData<F>: ConstructFlowSpecificData<F, FData, router_types::PaymentsResponseData>,