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): [AdyenPlatform] update incoming webhooks for payouts (#9002)

Kashif0269edf45b34
diff --git a/crates/hyperswitch_connectors/src/connectors/adyenplatform.rs b/crates/hyperswitch_connectors/src/connectors/adyenplatform.rs
index 78c8c4c806..2158fece4c 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyenplatform.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyenplatform.rs
@@ -402,6 +402,7 @@ impl IncomingWebhook for Adyenplatform {
webhook_body.webhook_type,
webhook_body.data.status,
webhook_body.data.tracking,
+ webhook_body.data.category.as_ref(),
))
}
#[cfg(not(feature = "payouts"))]
diff --git a/crates/hyperswitch_connectors/src/connectors/adyenplatform/transformers/payouts.rs b/crates/hyperswitch_connectors/src/connectors/adyenplatform/transformers/payouts.rs
index 6c964aea20..b04ca410d3 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyenplatform/transformers/payouts.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyenplatform/transformers/payouts.rs
@@ -513,6 +513,7 @@ pub struct AdyenplatformIncomingWebhookData {
pub status: AdyenplatformWebhookStatus,
pub reference: String,
pub tracking: Option<AdyenplatformInstantStatus>,
+ pub category: Option<AdyenPayoutMethod>,
}
#[derive(Debug, Serialize, Deserialize)]
@@ -551,6 +552,7 @@ pub fn get_adyen_webhook_event(
event_type: AdyenplatformWebhookEventType,
status: AdyenplatformWebhookStatus,
instant_status: Option<AdyenplatformInstantStatus>,
+ category: Option<&AdyenPayoutMethod>,
) -> webhooks::IncomingWebhookEvent {
match (event_type, status, instant_status) {
(AdyenplatformWebhookEventType::PayoutCreated, _, _) => {
@@ -565,9 +567,25 @@ pub fn get_adyen_webhook_event(
}
}
(AdyenplatformWebhookEventType::PayoutUpdated, status, _) => match status {
- AdyenplatformWebhookStatus::Authorised
- | AdyenplatformWebhookStatus::Booked
- | AdyenplatformWebhookStatus::Received => webhooks::IncomingWebhookEvent::PayoutCreated,
+ AdyenplatformWebhookStatus::Authorised | AdyenplatformWebhookStatus::Received => {
+ webhooks::IncomingWebhookEvent::PayoutCreated
+ }
+ AdyenplatformWebhookStatus::Booked => {
+ match category {
+ Some(AdyenPayoutMethod::Card) => {
+ // For card payouts, "booked" is the final success state
+ webhooks::IncomingWebhookEvent::PayoutSuccess
+ }
+ Some(AdyenPayoutMethod::Bank) => {
+ // For bank payouts, "booked" is intermediate - wait for final confirmation
+ webhooks::IncomingWebhookEvent::PayoutProcessing
+ }
+ None => {
+ // Default to processing if category is unknown
+ webhooks::IncomingWebhookEvent::PayoutProcessing
+ }
+ }
+ }
AdyenplatformWebhookStatus::Pending => webhooks::IncomingWebhookEvent::PayoutProcessing,
AdyenplatformWebhookStatus::Failed => webhooks::IncomingWebhookEvent::PayoutFailure,
AdyenplatformWebhookStatus::Returned => webhooks::IncomingWebhookEvent::PayoutReversed,