mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix(payout): send latest status in outgoing webhook notifications during IncomingWebhook flow (#9283)
This commit is contained in:
@ -1157,7 +1157,7 @@ async fn payouts_incoming_webhook_flow(
|
|||||||
payout_id: payouts.payout_id.clone(),
|
payout_id: payouts.payout_id.clone(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let payout_data = Box::pin(payouts::make_payout_data(
|
let mut payout_data = Box::pin(payouts::make_payout_data(
|
||||||
&state,
|
&state,
|
||||||
&merchant_context,
|
&merchant_context,
|
||||||
None,
|
None,
|
||||||
@ -1181,8 +1181,9 @@ async fn payouts_incoming_webhook_flow(
|
|||||||
payout_attempt.payout_attempt_id
|
payout_attempt.payout_attempt_id
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
payout_data.payout_attempt = updated_payout_attempt;
|
||||||
|
|
||||||
let event_type: Option<enums::EventType> = updated_payout_attempt.status.into();
|
let event_type: Option<enums::EventType> = payout_data.payout_attempt.status.into();
|
||||||
|
|
||||||
// If event is NOT an UnsupportedEvent, trigger Outgoing Webhook
|
// If event is NOT an UnsupportedEvent, trigger Outgoing Webhook
|
||||||
if let Some(outgoing_event_type) = event_type {
|
if let Some(outgoing_event_type) = event_type {
|
||||||
@ -1195,20 +1196,21 @@ async fn payouts_incoming_webhook_flow(
|
|||||||
business_profile,
|
business_profile,
|
||||||
outgoing_event_type,
|
outgoing_event_type,
|
||||||
enums::EventClass::Payouts,
|
enums::EventClass::Payouts,
|
||||||
updated_payout_attempt
|
payout_data
|
||||||
|
.payout_attempt
|
||||||
.payout_id
|
.payout_id
|
||||||
.get_string_repr()
|
.get_string_repr()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
enums::EventObjectType::PayoutDetails,
|
enums::EventObjectType::PayoutDetails,
|
||||||
api::OutgoingWebhookContent::PayoutDetails(Box::new(payout_create_response)),
|
api::OutgoingWebhookContent::PayoutDetails(Box::new(payout_create_response)),
|
||||||
Some(updated_payout_attempt.created_at),
|
Some(payout_data.payout_attempt.created_at),
|
||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(WebhookResponseTracker::Payout {
|
Ok(WebhookResponseTracker::Payout {
|
||||||
payout_id: updated_payout_attempt.payout_id,
|
payout_id: payout_data.payout_attempt.payout_id,
|
||||||
status: updated_payout_attempt.status,
|
status: payout_data.payout_attempt.status,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
metrics::INCOMING_PAYOUT_WEBHOOK_SIGNATURE_FAILURE_METRIC.add(1, &[]);
|
metrics::INCOMING_PAYOUT_WEBHOOK_SIGNATURE_FAILURE_METRIC.add(1, &[]);
|
||||||
|
|||||||
Reference in New Issue
Block a user