Skip to content

Commit

Permalink
feat(payments): Add audit events for PaymentStatus update (#6520)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rutam21 authored Dec 16, 2024
1 parent 986de77 commit ae00a10
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/router/src/core/payments/operations/payment_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
PaymentData,
},
},
events::audit_events::{AuditEvent, AuditEventType},
routes::{app::ReqState, SessionState},
services,
types::{
Expand Down Expand Up @@ -141,7 +142,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
async fn update_trackers<'b>(
&'b self,
_state: &'b SessionState,
_req_state: ReqState,
req_state: ReqState,
payment_data: PaymentData<F>,
_customer: Option<domain::Customer>,
_storage_scheme: enums::MerchantStorageScheme,
Expand All @@ -156,6 +157,12 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, 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))
}
}
Expand All @@ -167,7 +174,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRetrieveRequ
async fn update_trackers<'b>(
&'b self,
_state: &'b SessionState,
_req_state: ReqState,
req_state: ReqState,
payment_data: PaymentData<F>,
_customer: Option<domain::Customer>,
_storage_scheme: enums::MerchantStorageScheme,
Expand All @@ -182,6 +189,12 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, 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))
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/events/audit_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub enum AuditEventType {
},
PaymentApprove,
PaymentCreate,
PaymentStatus,
PaymentCompleteAuthorize,
PaymentReject {
error_code: Option<String>,
Expand Down Expand Up @@ -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",
};
Expand Down

0 comments on commit ae00a10

Please sign in to comment.