Skip to content

Commit

Permalink
feat(events): Add payment reject audit events
Browse files Browse the repository at this point in the history
  • Loading branch information
Anish Kacham committed Nov 6, 2024
1 parent 01c5216 commit 9c2ae81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/router/src/core/payments/operations/payment_reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::{
storage::{self, enums},
},
utils::OptionExt,
events::audit_events::{AuditEvent, AuditEventType},
};

#[derive(Debug, Clone, Copy, router_derive::PaymentOperation)]
Expand Down Expand Up @@ -209,7 +210,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, PaymentsCancelRequest> for Payme
async fn update_trackers<'b>(
&'b self,
state: &'b SessionState,
_req_state: ReqState,
req_state: ReqState,
mut payment_data: PaymentData<F>,
_customer: Option<domain::Customer>,
storage_scheme: enums::MerchantStorageScheme,
Expand Down Expand Up @@ -264,7 +265,13 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, PaymentsCancelRequest> for Payme
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;


req_state
.event_context
.event(AuditEvent::new(AuditEventType::PaymentReject))
.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 @@ -27,6 +27,7 @@ pub enum AuditEventType {
capture_amount: Option<MinorUnit>,
multiple_capture_count: Option<i16>,
},
PaymentReject,
}

#[derive(Debug, Clone, Serialize)]
Expand Down Expand Up @@ -65,6 +66,7 @@ impl Event for AuditEvent {
AuditEventType::RefundSuccess => "refund_success",
AuditEventType::RefundFail => "refund_fail",
AuditEventType::PaymentCancelled { .. } => "payment_cancelled",
AuditEventType::PaymentReject => "payment_rejected",
};
format!(
"{event_type}-{}",
Expand Down

0 comments on commit 9c2ae81

Please sign in to comment.