diff --git a/CHANGELOG.md b/CHANGELOG.md index d29420df89d1..21fc88e5e6fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.11.08.0 + +### Features + +- **payments:** Add audit events for PaymentCreate update ([#6427](https://github.com/juspay/hyperswitch/pull/6427)) ([`063fe90`](https://github.com/juspay/hyperswitch/commit/063fe904c66c9af3d7ce0a82ad712eac69e41786)) + +**Full Changelog:** [`2024.11.07.1...2024.11.08.0`](https://github.com/juspay/hyperswitch/compare/2024.11.07.1...2024.11.08.0) + +- - - + ## 2024.11.07.1 ### Bug Fixes diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs index ba8054696a11..545d05e776fa 100644 --- a/crates/router/src/core/payments/flows/session_flow.rs +++ b/crates/router/src/core/payments/flows/session_flow.rs @@ -189,20 +189,11 @@ async fn create_applepay_session_token( ) } else { // Get the apple pay metadata - let connector_apple_pay_wallet_details = - helpers::get_applepay_metadata(router_data.connector_wallets_details.clone()) - .map_err(|error| { - logger::debug!( - "Apple pay connector wallets details parsing failed in create_applepay_session_token {:?}", - error - ) - }) - .ok(); - - let apple_pay_metadata = match connector_apple_pay_wallet_details { - Some(apple_pay_wallet_details) => apple_pay_wallet_details, - None => helpers::get_applepay_metadata(router_data.connector_meta_data.clone())?, - }; + let apple_pay_metadata = + helpers::get_applepay_metadata(router_data.connector_meta_data.clone()) + .attach_printable( + "Failed to to fetch apple pay certificates during session call", + )?; // Get payment request data , apple pay session request and merchant keys let ( diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index d4057c523bc6..c65e58ea2d48 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -42,6 +42,7 @@ use crate::{ utils as core_utils, }, db::StorageInterface, + events::audit_events::{AuditEvent, AuditEventType}, routes::{app::ReqState, SessionState}, services, types::{ @@ -818,7 +819,7 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen async fn update_trackers<'b>( &'b self, state: &'b SessionState, - _req_state: ReqState, + req_state: ReqState, mut payment_data: PaymentData, customer: Option, storage_scheme: enums::MerchantStorageScheme, @@ -923,6 +924,11 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen ) .await .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; + req_state + .event_context + .event(AuditEvent::new(AuditEventType::PaymentCreate)) + .with(payment_data.to_event()) + .emit(); // payment_data.mandate_id = response.and_then(|router_data| router_data.request.mandate_id); Ok(( diff --git a/crates/router/src/events/audit_events.rs b/crates/router/src/events/audit_events.rs index 9b7a688f7eba..54c1934e36f7 100644 --- a/crates/router/src/events/audit_events.rs +++ b/crates/router/src/events/audit_events.rs @@ -27,6 +27,7 @@ pub enum AuditEventType { capture_amount: Option, multiple_capture_count: Option, }, + PaymentCreate, } #[derive(Debug, Clone, Serialize)] @@ -65,6 +66,7 @@ impl Event for AuditEvent { AuditEventType::RefundSuccess => "refund_success", AuditEventType::RefundFail => "refund_fail", AuditEventType::PaymentCancelled { .. } => "payment_cancelled", + AuditEventType::PaymentCreate { .. } => "payment_create", }; format!( "{event_type}-{}",