diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs index 30e86e0a829e..7321200a30ad 100644 --- a/crates/router/src/core/payments/operations/payment_reject.rs +++ b/crates/router/src/core/payments/operations/payment_reject.rs @@ -12,6 +12,7 @@ use crate::{ errors::{self, RouterResult, StorageErrorExt}, payments::{helpers, operations, PaymentAddress, PaymentData}, }, + events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ @@ -20,7 +21,6 @@ use crate::{ storage::{self, enums}, }, utils::OptionExt, - events::audit_events::{AuditEvent, AuditEventType}, }; #[derive(Debug, Clone, Copy, router_derive::PaymentOperation)] @@ -265,13 +265,17 @@ impl UpdateTracker, PaymentsCancelRequest> for Payme ) .await .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; - + let error_code = payment_data.payment_attempt.error_code; + let error_message = payment_data.payment_attempt.error_message; req_state .event_context - .event(AuditEvent::new(AuditEventType::PaymentReject)) + .event(AuditEvent::new(AuditEventType::PaymentReject { + error_code, + error_message, + })) .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 8f22e4a435b6..e2308f09a556 100644 --- a/crates/router/src/events/audit_events.rs +++ b/crates/router/src/events/audit_events.rs @@ -27,7 +27,10 @@ pub enum AuditEventType { capture_amount: Option, multiple_capture_count: Option, }, - PaymentReject, + PaymentReject { + error_code: Option, + error_message: Option, + }, } #[derive(Debug, Clone, Serialize)] @@ -66,7 +69,7 @@ impl Event for AuditEvent { AuditEventType::RefundSuccess => "refund_success", AuditEventType::RefundFail => "refund_fail", AuditEventType::PaymentCancelled { .. } => "payment_cancelled", - AuditEventType::PaymentReject => "payment_rejected", + AuditEventType::PaymentReject { .. } => "payment_rejected", }; format!( "{event_type}-{}",