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): [Adyen] [paypal] fix error propogation in webhook flows (#11717)

Swangi Kumaridb0ce91e53c1
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen.rs b/crates/hyperswitch_connectors/src/connectors/adyen.rs
index 4c93de5a80..208fbdb020 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen.rs
@@ -2112,7 +2112,7 @@ impl IncomingWebhook for Adyen {
_context: Option<&WebhookContext>,
) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {
let notif = get_webhook_object_from_body(request.body)
- .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
+ .change_context(errors::ConnectorError::WebhookResponseEncodingFailed)?;
Ok(transformers::get_adyen_webhook_event(
notif.event_code,
@@ -2127,7 +2127,7 @@ impl IncomingWebhook for Adyen {
) -> CustomResult<Box<dyn hyperswitch_masking::ErasedMaskSerialize>, errors::ConnectorError>
{
let notif = get_webhook_object_from_body(request.body)
- .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
+ .change_context(errors::ConnectorError::WebhookResponseEncodingFailed)?;
let response = adyen::AdyenWebhookResponse::from(notif);
diff --git a/crates/hyperswitch_connectors/src/connectors/paypal.rs b/crates/hyperswitch_connectors/src/connectors/paypal.rs
index e3b62ff103..a7edf93f2a 100644
--- a/crates/hyperswitch_connectors/src/connectors/paypal.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paypal.rs
@@ -2300,13 +2300,13 @@ impl IncomingWebhook for Paypal {
let payload: paypal::PaypalWebooksEventType = request
.body
.parse_struct("PaypalWebooksEventType")
- .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
+ .change_context(errors::ConnectorError::WebhookResponseEncodingFailed)?;
let outcome = match payload.event_type {
PaypalWebhookEventType::CustomerDisputeResolved => Some(
request
.body
.parse_struct::<paypal::DisputeOutcome>("PaypalWebooksEventType")
- .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?
+ .change_context(errors::ConnectorError::WebhookResponseEncodingFailed)?
.outcome_code,
),
PaypalWebhookEventType::CustomerDisputeCreated