Skip to content

Commit

Permalink
feat(events): add audit event for CompleteAuthorize (#6310)
Browse files Browse the repository at this point in the history
Co-authored-by: Sandeep Kumar <[email protected]>
  • Loading branch information
hex1c and tsdk02 authored Dec 5, 2024
1 parent b370d04 commit dc26317
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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 @@ -462,7 +463,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Comple
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: storage_enums::MerchantStorageScheme,
Expand Down Expand Up @@ -492,6 +493,12 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, 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))
}
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,
PaymentCompleteAuthorize,
PaymentReject {
error_code: Option<String>,
error_message: Option<String>,
Expand Down Expand Up @@ -78,6 +79,7 @@ impl Event for AuditEvent {
AuditEventType::PaymentUpdate { .. } => "payment_update",
AuditEventType::PaymentApprove { .. } => "payment_approve",
AuditEventType::PaymentCreate { .. } => "payment_create",
AuditEventType::PaymentCompleteAuthorize => "payment_complete_authorize",
AuditEventType::PaymentReject { .. } => "payment_rejected",
};
format!(
Expand Down

0 comments on commit dc26317

Please sign in to comment.