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

refactor(connector): [Finix] Empty event support for webhook configuration (#12824)

Swangi Kumaribb99802d7852
diff --git a/crates/hyperswitch_connectors/src/connectors/finix.rs b/crates/hyperswitch_connectors/src/connectors/finix.rs
index 9324cb18e0..64caa8b2ce 100644
--- a/crates/hyperswitch_connectors/src/connectors/finix.rs
+++ b/crates/hyperswitch_connectors/src/connectors/finix.rs
@@ -1180,16 +1180,21 @@ impl webhooks::IncomingWebhook for Finix {
request: &webhooks::IncomingWebhookRequestDetails<'_>,
_context: Option<&webhooks::WebhookContext>,
) -> CustomResult<IncomingWebhookEvent, errors::ConnectorError> {
- if is_test_webhook(request) {
- return Ok(IncomingWebhookEvent::SetupWebhook);
- }
- let webhook_body: finix::FinixWebhookBody =
- request
+ let trimmed_body = std::str::from_utf8(request.body)
+ .map(|string| string.trim())
+ .unwrap_or("");
+ if request.body.is_empty() || trimmed_body == "{}" {
+ Ok(IncomingWebhookEvent::EndpointVerification)
+ } else if is_test_webhook(request) {
+ Ok(IncomingWebhookEvent::SetupWebhook)
+ } else {
+ let webhook_body: finix::FinixWebhookBody = request
.body
.parse_struct("FinixWebhookBody")
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
- webhook_body.get_webhook_event_type()
+ webhook_body.get_webhook_event_type()
+ }
}
fn get_dispute_details(
&self,