From 135d29794c2c04c881d5bf16073d3f6ec9d94658 Mon Sep 17 00:00:00 2001 From: hex1c Date: Mon, 14 Oct 2024 19:14:51 +0530 Subject: [PATCH] feat(events): add audit event for CompleteAuthorize --- .../payments/operations/payment_complete_authorize.rs | 9 ++++++++- crates/router/src/events/audit_events.rs | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs index 99d8df2dfe98..1fbd35f133bc 100644 --- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs +++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs @@ -16,6 +16,7 @@ use crate::{ PaymentData, }, }, + events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ @@ -461,7 +462,7 @@ impl UpdateTracker, api::PaymentsRequest> for Comple async fn update_trackers<'b>( &'b self, state: &'b SessionState, - _req_state: ReqState, + req_state: ReqState, mut payment_data: PaymentData, _customer: Option, storage_scheme: storage_enums::MerchantStorageScheme, @@ -491,6 +492,12 @@ impl UpdateTracker, api::PaymentsRequest> for Comple .await .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; + req_state + .event_context + .event(AuditEvent::new(AuditEventType::PaymentCompleteAuthorize)) + .with(payment_data.to_event()) + .emit(); + payment_data.payment_intent = updated_payment_intent; 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 367a573a93b3..130b12b4948d 100644 --- a/crates/router/src/events/audit_events.rs +++ b/crates/router/src/events/audit_events.rs @@ -27,6 +27,7 @@ pub enum AuditEventType { capture_amount: Option, multiple_capture_count: Option, }, + PaymentCompleteAuthorize, } #[derive(Debug, Clone, Serialize)] @@ -65,6 +66,7 @@ impl Event for AuditEvent { AuditEventType::RefundSuccess => "refund_success", AuditEventType::RefundFail => "refund_fail", AuditEventType::PaymentCancelled { .. } => "payment_cancelled", + AuditEventType::PaymentCompleteAuthorize => "payment_complete_authorize", }; format!( "{event_type}-{}",