Skip to content

Commit 1be2654

Browse files
authored
feat(payments): Add audit events for PaymentUpdate update (#6426)
1 parent 3d9f443 commit 1be2654

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

crates/router/src/core/payments/operations/payment_update.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::{
2525
payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData},
2626
utils as core_utils,
2727
},
28+
events::audit_events::{AuditEvent, AuditEventType},
2829
routes::{app::ReqState, SessionState},
2930
services,
3031
types::{
@@ -694,7 +695,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
694695
async fn update_trackers<'b>(
695696
&'b self,
696697
_state: &'b SessionState,
697-
_req_state: ReqState,
698+
req_state: ReqState,
698699
mut _payment_data: PaymentData<F>,
699700
_customer: Option<domain::Customer>,
700701
_storage_scheme: storage_enums::MerchantStorageScheme,
@@ -714,7 +715,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
714715
async fn update_trackers<'b>(
715716
&'b self,
716717
state: &'b SessionState,
717-
_req_state: ReqState,
718+
req_state: ReqState,
718719
mut payment_data: PaymentData<F>,
719720
customer: Option<domain::Customer>,
720721
storage_scheme: storage_enums::MerchantStorageScheme,
@@ -925,6 +926,12 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
925926
)
926927
.await
927928
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
929+
let amount = payment_data.amount;
930+
req_state
931+
.event_context
932+
.event(AuditEvent::new(AuditEventType::PaymentUpdate { amount }))
933+
.with(payment_data.to_event())
934+
.emit();
928935

929936
Ok((
930937
payments::is_confirm(self, payment_data.confirm),

crates/router/src/events/audit_events.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use api_models::payments::Amount;
12
use common_utils::types::MinorUnit;
23
use diesel_models::fraud_check::FraudCheck;
34
use events::{Event, EventInfo};
@@ -27,6 +28,9 @@ pub enum AuditEventType {
2728
capture_amount: Option<MinorUnit>,
2829
multiple_capture_count: Option<i16>,
2930
},
31+
PaymentUpdate {
32+
amount: Amount,
33+
},
3034
PaymentApprove,
3135
PaymentCreate,
3236
}
@@ -67,6 +71,7 @@ impl Event for AuditEvent {
6771
AuditEventType::RefundSuccess => "refund_success",
6872
AuditEventType::RefundFail => "refund_fail",
6973
AuditEventType::PaymentCancelled { .. } => "payment_cancelled",
74+
AuditEventType::PaymentUpdate { .. } => "payment_update",
7075
AuditEventType::PaymentApprove { .. } => "payment_approve",
7176
AuditEventType::PaymentCreate { .. } => "payment_create",
7277
};

0 commit comments

Comments
 (0)