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(webhook): add a function to retrieve payment_id (#2447)

Narayan Bhat409913fd7507
diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rs
index a1cafee1f8..252e3110d6 100644
--- a/crates/api_models/src/webhooks.rs
+++ b/crates/api_models/src/webhooks.rs
@@ -59,6 +59,17 @@ pub enum WebhookResponseTracker {
NoEffect,
}
+impl WebhookResponseTracker {
+ pub fn get_payment_id(&self) -> Option<String> {
+ match self {
+ Self::Payment { payment_id, .. }
+ | Self::Refund { payment_id, .. }
+ | Self::Dispute { payment_id, .. } => Some(payment_id.to_string()),
+ Self::NoEffect => None,
+ }
+ }
+}
+
impl From<IncomingWebhookEvent> for WebhookFlow {
fn from(evt: IncomingWebhookEvent) -> Self {
match evt {