From ae00a103de5bd283695969270a421c7609a699e8 Mon Sep 17 00:00:00 2001 From: Rutam Prita Mishra Date: Mon, 16 Dec 2024 16:49:21 +0530 Subject: [PATCH] feat(payments): Add audit events for PaymentStatus update (#6520) --- .../core/payments/operations/payment_status.rs | 17 +++++++++++++++-- crates/router/src/events/audit_events.rs | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs index 69f2d85d6a91..9aa905345c8c 100644 --- a/crates/router/src/core/payments/operations/payment_status.rs +++ b/crates/router/src/core/payments/operations/payment_status.rs @@ -16,6 +16,7 @@ use crate::{ PaymentData, }, }, + events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ @@ -141,7 +142,7 @@ impl UpdateTracker, api::PaymentsRequest> for async fn update_trackers<'b>( &'b self, _state: &'b SessionState, - _req_state: ReqState, + req_state: ReqState, payment_data: PaymentData, _customer: Option, _storage_scheme: enums::MerchantStorageScheme, @@ -156,6 +157,12 @@ impl UpdateTracker, api::PaymentsRequest> for where F: 'b + Send, { + req_state + .event_context + .event(AuditEvent::new(AuditEventType::PaymentStatus)) + .with(payment_data.to_event()) + .emit(); + Ok((Box::new(self), payment_data)) } } @@ -167,7 +174,7 @@ impl UpdateTracker, api::PaymentsRetrieveRequ async fn update_trackers<'b>( &'b self, _state: &'b SessionState, - _req_state: ReqState, + req_state: ReqState, payment_data: PaymentData, _customer: Option, _storage_scheme: enums::MerchantStorageScheme, @@ -182,6 +189,12 @@ impl UpdateTracker, api::PaymentsRetrieveRequ where F: 'b + Send, { + req_state + .event_context + .event(AuditEvent::new(AuditEventType::PaymentStatus)) + .with(payment_data.to_event()) + .emit(); + Ok((Box::new(self), payment_data)) } } diff --git a/crates/router/src/events/audit_events.rs b/crates/router/src/events/audit_events.rs index c314fa8409fa..a0f651b93c39 100644 --- a/crates/router/src/events/audit_events.rs +++ b/crates/router/src/events/audit_events.rs @@ -33,6 +33,7 @@ pub enum AuditEventType { }, PaymentApprove, PaymentCreate, + PaymentStatus, PaymentCompleteAuthorize, PaymentReject { error_code: Option, @@ -79,6 +80,7 @@ impl Event for AuditEvent { AuditEventType::PaymentUpdate { .. } => "payment_update", AuditEventType::PaymentApprove { .. } => "payment_approve", AuditEventType::PaymentCreate { .. } => "payment_create", + AuditEventType::PaymentStatus { .. } => "payment_status", AuditEventType::PaymentCompleteAuthorize => "payment_complete_authorize", AuditEventType::PaymentReject { .. } => "payment_rejected", };