Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(payments): Add audit events for PaymentUpdate update (#6426)
Rutam Prita Mishra1be2654b4fd6
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 9005e94c96..2f1a0c333f 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -25,6 +25,7 @@ use crate::{payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData},utils as core_utils,},+ events::audit_events::{AuditEvent, AuditEventType},routes::{app::ReqState, SessionState},services,types::{@@ -694,7 +695,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymenasync 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,@@ -714,7 +715,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymenasync 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,@@ -925,6 +926,12 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen).await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;+ let amount = payment_data.amount;+ req_state+ .event_context+ .event(AuditEvent::new(AuditEventType::PaymentUpdate { amount }))+ .with(payment_data.to_event())+ .emit();Ok((payments::is_confirm(self, payment_data.confirm),diff --git a/crates/router/src/events/audit_events.rs b/crates/router/src/events/audit_events.rsindex 9fbd754b43..a6b0884d21 100644--- a/crates/router/src/events/audit_events.rs+++ b/crates/router/src/events/audit_events.rs@@ -1,3 +1,4 @@+use api_models::payments::Amount;use common_utils::types::MinorUnit;use diesel_models::fraud_check::FraudCheck;use events::{Event, EventInfo};@@ -27,6 +28,9 @@ pub enum AuditEventType {capture_amount: Option<MinorUnit>,multiple_capture_count: Option<i16>,},+ PaymentUpdate {+ amount: Amount,+ },PaymentApprove,PaymentCreate,}@@ -67,6 +71,7 @@ impl Event for AuditEvent {AuditEventType::RefundSuccess => "refund_success",AuditEventType::RefundFail => "refund_fail",AuditEventType::PaymentCancelled { .. } => "payment_cancelled",+ AuditEventType::PaymentUpdate { .. } => "payment_update",AuditEventType::PaymentApprove { .. } => "payment_approve",AuditEventType::PaymentCreate { .. } => "payment_create",};