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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connectors): [stripe] fix webhook event type mapping (#11653)
Akshaya Shankar7f7fc20472ce
diff --git a/crates/hyperswitch_connectors/src/connectors/stripe.rs b/crates/hyperswitch_connectors/src/connectors/stripe.rsindex e863200733..c531279745 100644--- a/crates/hyperswitch_connectors/src/connectors/stripe.rs+++ b/crates/hyperswitch_connectors/src/connectors/stripe.rs@@ -2416,6 +2416,8 @@ impl IncomingWebhook for Stripe {.parse_struct("WebhookEventTypeBody").change_context(ConnectorError::WebhookReferenceIdNotFound)?;+ let status = details.event_data.event_object.status;+Ok(match details.event_type {stripe::WebhookEventType::PaymentIntentFailed => {IncomingWebhookEvent::PaymentIntentFailure@@ -2441,37 +2443,36 @@ impl IncomingWebhook for Stripe {IncomingWebhookEvent::EventNotSupported}}- stripe::WebhookEventType::ChargeRefundUpdated => details- .event_data- .event_object- .status- .map(|status| match status {+ stripe::WebhookEventType::ChargeRefundUpdated => status+ .map(|s| match s {stripe::WebhookEventStatus::Succeeded => IncomingWebhookEvent::RefundSuccess,stripe::WebhookEventStatus::Failed => IncomingWebhookEvent::RefundFailure,_ => IncomingWebhookEvent::EventNotSupported,}).unwrap_or(IncomingWebhookEvent::EventNotSupported),stripe::WebhookEventType::SourceChargeable => IncomingWebhookEvent::SourceChargeable,- stripe::WebhookEventType::DisputeCreated => IncomingWebhookEvent::DisputeOpened,- stripe::WebhookEventType::DisputeClosed => IncomingWebhookEvent::DisputeCancelled,- stripe::WebhookEventType::DisputeUpdated => details- .event_data- .event_object- .status+ // Dispute events: prefer object.status, fall back to event type+ stripe::WebhookEventType::DisputeCreated => status+ .map(Into::into)+ .unwrap_or(IncomingWebhookEvent::DisputeOpened),+ stripe::WebhookEventType::DisputeUpdated => status.map(Into::into).unwrap_or(IncomingWebhookEvent::EventNotSupported),+ stripe::WebhookEventType::DisputeClosed => status+ .map(Into::into)+ .unwrap_or(IncomingWebhookEvent::DisputeCancelled),+ stripe::WebhookEventType::ChargeDisputeFundsWithdrawn => status+ .map(Into::into)+ .unwrap_or(IncomingWebhookEvent::DisputeLost),+ stripe::WebhookEventType::ChargeDisputeFundsReinstated => status+ .map(Into::into)+ .unwrap_or(IncomingWebhookEvent::DisputeWon),stripe::WebhookEventType::PaymentIntentPartiallyFunded => {IncomingWebhookEvent::PaymentIntentPartiallyFunded}stripe::WebhookEventType::PaymentIntentRequiresAction => {IncomingWebhookEvent::PaymentActionRequired}- stripe::WebhookEventType::ChargeDisputeFundsWithdrawn => {- IncomingWebhookEvent::DisputeLost- }- stripe::WebhookEventType::ChargeDisputeFundsReinstated => {- IncomingWebhookEvent::DisputeWon- }stripe::WebhookEventType::Unknown| stripe::WebhookEventType::ChargeCaptured| stripe::WebhookEventType::ChargeExpireddiff --git a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rsindex f9492ca360..47dff203c4 100644--- a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs@@ -1047,14 +1047,16 @@ pub enum StripeBankNames {impl From<WebhookEventStatus> for api_models::webhooks::IncomingWebhookEvent {fn from(value: WebhookEventStatus) -> Self {match value {- WebhookEventStatus::WarningNeedsResponse => Self::DisputeOpened,+ WebhookEventStatus::WarningNeedsResponse | WebhookEventStatus::NeedsResponse => {+ Self::DisputeOpened+ }WebhookEventStatus::WarningClosed => Self::DisputeCancelled,- WebhookEventStatus::WarningUnderReview => Self::DisputeChallenged,+ WebhookEventStatus::WarningUnderReview | WebhookEventStatus::UnderReview => {+ Self::DisputeChallenged+ }WebhookEventStatus::Won => Self::DisputeWon,WebhookEventStatus::Lost => Self::DisputeLost,- WebhookEventStatus::NeedsResponse- | WebhookEventStatus::UnderReview- | WebhookEventStatus::ChargeRefunded+ WebhookEventStatus::ChargeRefunded| WebhookEventStatus::Succeeded| WebhookEventStatus::RequiresPaymentMethod| WebhookEventStatus::RequiresConfirmation