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(events): add logger for incoming webhook payload (#3171)

Prasunna Soppacf47a65916fd
diff --git a/crates/router/src/routes/webhooks.rs b/crates/router/src/routes/webhooks.rs
index 2162ee5612..10eb4ef75e 100644
--- a/crates/router/src/routes/webhooks.rs
+++ b/crates/router/src/routes/webhooks.rs
@@ -25,8 +25,8 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(
flow.clone(),
state,
&req,
- (),
- |state, auth, _| {
+ WebhookBytes(body),
+ |state, auth, payload| {
webhooks::webhooks_wrapper::<W, Oss>(
&flow,
state.to_owned(),
@@ -34,7 +34,7 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(
auth.merchant_account,
auth.key_store,
&connector_id_or_name,
- body.clone(),
+ payload.0,
)
},
&auth::MerchantIdAuth(merchant_id),
@@ -42,3 +42,19 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(
))
.await
}
+
+#[derive(Debug)]
+struct WebhookBytes(web::Bytes);
+
+impl serde::Serialize for WebhookBytes {
+ fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
+ let payload: serde_json::Value = serde_json::from_slice(&self.0).unwrap_or_default();
+ payload.serialize(serializer)
+ }
+}
+
+impl common_utils::events::ApiEventMetric for WebhookBytes {
+ fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
+ Some(common_utils::events::ApiEventsType::Miscellaneous)
+ }
+}