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(events): Add audit events payment confirm (#4763)
Abhishek Kanojiaeb0101fa7d61
diff --git a/config/development.toml b/config/development.tomlindex 95cadf5661..2c6d67e751 100644--- a/config/development.toml+++ b/config/development.toml@@ -646,4 +646,4 @@ sdk_eligible_payment_methods = "card"enabled = false[multitenancy.tenants]-public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = ""}\ No newline at end of file+public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = ""}diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex ea5f2c0ecb..cff51ed809 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -29,6 +29,7 @@ use crate::{utils as core_utils,},db::StorageInterface,+ events::audit_events::{AuditEvent, AuditEventType},routes::{app::ReqState, SessionState},services,types::{@@ -935,7 +936,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,@@ -1294,6 +1295,19 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymenpayment_data.payment_intent = payment_intent;payment_data.payment_attempt = payment_attempt;+ let client_src = payment_data.payment_attempt.client_source.clone();+ let client_ver = payment_data.payment_attempt.client_version.clone();++ let frm_message = payment_data.frm_message.clone();+ req_state+ .event_context+ .event(AuditEvent::new(AuditEventType::PaymentConfirm {+ client_src,+ client_ver,+ frm_message,+ }))+ .with(payment_data.to_event())+ .emit();Ok((Box::new(self), payment_data))}}diff --git a/crates/router/src/events/audit_events.rs b/crates/router/src/events/audit_events.rsindex 0f186e691b..6fc1901865 100644--- a/crates/router/src/events/audit_events.rs+++ b/crates/router/src/events/audit_events.rs@@ -1,18 +1,27 @@+use diesel_models::fraud_check::FraudCheck;use events::{Event, EventInfo};use serde::Serialize;use time::PrimitiveDateTime;-#[derive(Debug, Clone, Serialize)]#[serde(tag = "event_type")]pub enum AuditEventType {- Error { error_message: String },+ Error {+ error_message: String,+ },PaymentCreated,ConnectorDecided,ConnectorCalled,RefundCreated,RefundSuccess,RefundFail,- PaymentCancelled { cancellation_reason: Option<String> },+ PaymentConfirm {+ client_src: Option<String>,+ client_ver: Option<String>,+ frm_message: Option<FraudCheck>,+ },+ PaymentCancelled {+ cancellation_reason: Option<String>,+ },}#[derive(Debug, Clone, Serialize)]@@ -43,6 +52,7 @@ impl Event for AuditEvent {let event_type = match &self.event_type {AuditEventType::Error { .. } => "error",AuditEventType::PaymentCreated => "payment_created",+ AuditEventType::PaymentConfirm { .. } => "payment_confirm",AuditEventType::ConnectorDecided => "connector_decided",AuditEventType::ConnectorCalled => "connector_called",AuditEventType::RefundCreated => "refund_created",