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(platform): populate created_by and last_modified_by using initiator context (#11318)
Ankit Kumar Gupta6ccc09e47c63
diff --git a/crates/hyperswitch_domain_models/src/customer.rs b/crates/hyperswitch_domain_models/src/customer.rsindex 42c8edd712..4b092c1db6 100644--- a/crates/hyperswitch_domain_models/src/customer.rs+++ b/crates/hyperswitch_domain_models/src/customer.rs@@ -28,6 +28,7 @@ use crate::merchant_connector_account::MerchantConnectorAccountTypeDetails;use crate::{behaviour,merchant_key_store::MerchantKeyStore,+ platform,type_encryption::{self as types, AsyncLift},};@@ -855,6 +856,7 @@ pub async fn update_connector_customer_in_customers(connector_label: &str,connector_customer_map: Option<&pii::SecretSerdeValue>,connector_customer_id: Option<String>,+ initiator: Option<&platform::Initiator>,) -> Option<CustomerUpdate> {let mut connector_customer_map = connector_customer_map.and_then(|connector_customer| connector_customer.clone().expose().as_object().cloned())@@ -871,7 +873,9 @@ pub async fn update_connector_customer_in_customers(.map(|connector_customer_value| CustomerUpdate::ConnectorCustomer {connector_customer: Some(pii::SecretSerdeValue::new(connector_customer_value)),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),},)}@@ -882,6 +886,7 @@ pub async fn update_connector_customer_in_customers(merchant_connector_account: &MerchantConnectorAccountTypeDetails,customer: Option<&Customer>,connector_customer_id: Option<String>,+ initiator: Option<&platform::Initiator>,) -> Option<CustomerUpdate> {match merchant_connector_account {MerchantConnectorAccountTypeDetails::MerchantConnectorAccount(account) => {@@ -893,7 +898,9 @@ pub async fn update_connector_customer_in_customers(connector_customer_map.insert(connector_account_id, new_conn_cust_id);CustomerUpdate::ConnectorCustomer {connector_customer: Some(connector_customer_map),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),}})}diff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rsindex b5cb3ef531..6b66c5fddc 100644--- a/crates/hyperswitch_domain_models/src/payment_methods.rs+++ b/crates/hyperswitch_domain_models/src/payment_methods.rs@@ -31,10 +31,10 @@ use rustc_hash::FxHashMap;use serde_json::Value;use time::PrimitiveDateTime;-#[cfg(feature = "v2")]-use crate::address::Address;#[cfg(feature = "v1")]use crate::type_encryption::AsyncLift;+#[cfg(feature = "v2")]+use crate::{address::Address, platform::Initiator};use crate::{mandates::{self, CommonMandateReference},merchant_key_store::MerchantKeyStore,@@ -1120,6 +1120,7 @@ pub trait PaymentMethodInterface {&self,key_store: &MerchantKeyStore,payment_method: PaymentMethod,+ initiator: Option<&Initiator>,) -> CustomResult<PaymentMethod, Self::Error>;async fn find_payment_method_by_fingerprint_id(diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex d7460df9e5..45a476b44b 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -956,7 +956,9 @@ impl PaymentIntent {force_3ds_challenge: None,force_3ds_challenge_trigger: None,processor_merchant_id: platform.get_processor().get_account().get_id().clone(),- created_by: None,+ created_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),is_iframe_redirection_enabled: None,is_payment_id_from_merchant: None,enable_partial_authorization: requestdiff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex 9d4fd0b3d0..6398e4bb6d 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -53,7 +53,8 @@ use url::Url;use super::PaymentIntent;#[cfg(feature = "v2")]use crate::{- address::Address, consts, payment_method_data::PaymentMethodData, router_response_types,+ address::Address, consts, payment_method_data::PaymentMethodData, platform,+ router_response_types,};use crate::{behaviour, errors,@@ -906,6 +907,7 @@ impl PaymentAttempt {storage_scheme: storage_enums::MerchantStorageScheme,request: &api_models::payments::PaymentsConfirmIntentRequest,encrypted_data: DecryptedPaymentAttempt,+ initiator: Option<&platform::Initiator>,) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> {let id = id_type::GlobalAttemptId::generate(&cell_id);let intent_amount_details = payment_intent.amount_details.clone();@@ -988,7 +990,7 @@ impl PaymentAttempt {card_discovery: None,feature_metadata: None,processor_merchant_id: payment_intent.merchant_id.clone(),- created_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),connector_request_reference_id: None,network_transaction_id: None,authorized_amount: None,@@ -1002,6 +1004,7 @@ impl PaymentAttempt {storage_scheme: storage_enums::MerchantStorageScheme,request: &api_models::payments::ProxyPaymentsRequest,encrypted_data: DecryptedPaymentAttempt,+ initiator: Option<&platform::Initiator>,) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> {let id = id_type::GlobalAttemptId::generate(&cell_id);let intent_amount_details = payment_intent.amount_details.clone();@@ -1080,7 +1083,7 @@ impl PaymentAttempt {id,card_discovery: None,processor_merchant_id: payment_intent.merchant_id.clone(),- created_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),connector_request_reference_id: None,network_transaction_id: None,authorized_amount: None,@@ -1094,6 +1097,7 @@ impl PaymentAttempt {storage_scheme: storage_enums::MerchantStorageScheme,request: &api_models::payments::ExternalVaultProxyPaymentsRequest,encrypted_data: DecryptedPaymentAttempt,+ initiator: Option<&platform::Initiator>,) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> {let id = id_type::GlobalAttemptId::generate(&cell_id);let intent_amount_details = payment_intent.amount_details.clone();@@ -1179,7 +1183,7 @@ impl PaymentAttempt {id,card_discovery: None,processor_merchant_id: payment_intent.merchant_id.clone(),- created_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),connector_request_reference_id: None,network_transaction_id: None,authorized_amount: None,@@ -1194,6 +1198,7 @@ impl PaymentAttempt {storage_scheme: storage_enums::MerchantStorageScheme,request: &api_models::payments::PaymentsAttemptRecordRequest,encrypted_data: DecryptedPaymentAttempt,+ initiator: Option<&platform::Initiator>,) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> {let id = id_type::GlobalAttemptId::generate(&cell_id);@@ -1302,7 +1307,7 @@ impl PaymentAttempt {card_discovery: None,charges: None,processor_merchant_id: payment_intent.merchant_id.clone(),- created_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),connector_request_reference_id,network_transaction_id: None,authorized_amount: None,diff --git a/crates/payment_methods/src/controller.rs b/crates/payment_methods/src/controller.rsindex 6f23b569b4..8b50a6095b 100644--- a/crates/payment_methods/src/controller.rs+++ b/crates/payment_methods/src/controller.rs@@ -59,6 +59,7 @@ pub trait PaymentMethodsController {vault_source_details: Option<PaymentMethodVaultSourceDetails>,payment_method_customer_details_encrypted: crypto::OptionalEncryptableValue,locker_fingerprint_id: Option<String>,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> errors::PmResult<payment_methods::PaymentMethod>;#[cfg(feature = "v1")]@@ -81,6 +82,7 @@ pub trait PaymentMethodsController {network_token_payment_method_data: crypto::OptionalEncryptableValue,vault_source_details: Option<PaymentMethodVaultSourceDetails>,locker_fingerprint_id: Option<String>,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> errors::PmResult<payment_methods::PaymentMethod>;#[cfg(feature = "v2")]@@ -104,6 +106,7 @@ pub trait PaymentMethodsController {async fn add_payment_method(&self,req: &api::PaymentMethodCreate,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> errors::PmResponse<api::PaymentMethodResponse>;#[cfg(feature = "v1")]@@ -116,6 +119,7 @@ pub trait PaymentMethodsController {async fn delete_payment_method(&self,pm_id: api::PaymentMethodId,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> errors::PmResponse<api::PaymentMethodDeleteResponse>;#[cfg(feature = "v1")]@@ -174,6 +178,7 @@ pub trait PaymentMethodsController {resp: &mut payment_methods::PaymentMethodResponse,customer_id: &id_type::CustomerId,key_store: &merchant_key_store::MerchantKeyStore,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> errors::PmResult<payment_methods::PaymentMethod>;#[cfg(feature = "v2")]@@ -234,6 +239,7 @@ pub trait PaymentMethodsController {network_token_data: &api_models::payment_methods::MigrateNetworkTokenData,network_token_requestor_ref_id: String,pm_id: String,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> errors::PmResult<bool>;#[cfg(feature = "v1")]@@ -242,6 +248,7 @@ pub trait PaymentMethodsController {merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,payment_method_id: String,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> errors::PmResponse<api_models::payment_methods::CustomerDefaultPaymentMethodResponse>;#[cfg(feature = "v1")]@@ -251,6 +258,7 @@ pub trait PaymentMethodsController {prev_status: common_enums::PaymentMethodStatus,curr_status: common_enums::PaymentMethodStatus,merchant_id: &id_type::MerchantId,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> Result<(), sch_errors::ProcessTrackerError>;#[cfg(feature = "v1")]diff --git a/crates/payment_methods/src/core/migration/payment_methods.rs b/crates/payment_methods/src/core/migration/payment_methods.rsindex f99ebc84e1..f52d55917f 100644--- a/crates/payment_methods/src/core/migration/payment_methods.rs+++ b/crates/payment_methods/src/core/migration/payment_methods.rs@@ -114,6 +114,7 @@ pub async fn migrate_payment_method(platform.get_provider(),&mut migration_status,controller,+ platform.get_initiator(),).await?}@@ -124,6 +125,7 @@ pub async fn migrate_payment_method(&req,merchant_id.to_owned(),platform.get_provider(),+ platform.get_initiator(),card_bin_details.clone(),should_require_connector_mandate_details,&mut migration_status,@@ -156,6 +158,7 @@ pub async fn migrate_payment_method(network_token_data,network_token_requestor_ref_id,pm_id,+ platform.get_initiator(),).await.map_err(|err| logger::error!(?err, "Failed to save network token"))@@ -228,7 +231,7 @@ async fn migrate_payment_method_data(let network_transaction_id = payment_method_create.network_transaction_id.clone();let res = controller- .add_payment_method(&payment_method_create)+ .add_payment_method(&payment_method_create, platform.get_initiator()).await?;let payment_method_response = match res {@@ -494,6 +497,7 @@ pub async fn get_client_secret_or_add_payment_method_for_migration(provider: &platform::Provider,migration_status: &mut migration::RecordMigrationStatusBuilder,controller: &dyn PaymentMethodsController,+ initiator: Option<&platform::Initiator>,) -> CustomResult<ApplicationResponse<pm_api::PaymentMethodResponse>, errors::ApiErrorResponse> {let merchant_id = provider.get_account().get_id();let customer_id = req.customer_id.clone().get_required_value("customer_id")?;@@ -527,6 +531,7 @@ pub async fn get_client_secret_or_add_payment_method_for_migration(req,migration_status,controller,+ initiator,)).await} else {@@ -553,6 +558,7 @@ pub async fn get_client_secret_or_add_payment_method_for_migration(Default::default(),None,None,+ initiator,).await?;migration_status.connector_mandate_details_migrated(@@ -575,6 +581,7 @@ pub async fn get_client_secret_or_add_payment_method_for_migration(enums::PaymentMethodStatus::AwaitingData,enums::PaymentMethodStatus::Inactive,merchant_id,+ initiator,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -595,6 +602,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(req: &pm_api::PaymentMethodMigrate,merchant_id: id_type::MerchantId,provider: &platform::Provider,+ initiator: Option<&platform::Initiator>,card: pm_api::CardDetailFromLocker,should_require_connector_mandate_details: bool,migration_status: &mut migration::RecordMigrationStatusBuilder,@@ -715,8 +723,8 @@ pub async fn skip_locker_call_and_migrate_payment_method(network_token_locker_id: None,network_token_payment_method_data: None,vault_source_details: Default::default(),- created_by: None,- last_modified_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),customer_details: None,locker_fingerprint_id: None,},@@ -746,7 +754,12 @@ pub async fn skip_locker_call_and_migrate_payment_method(if customer.default_payment_method_id.is_none() && req.payment_method.is_some() {let _ = controller- .set_default_payment_method(&merchant_id, &customer_id, payment_method_id.to_owned())+ .set_default_payment_method(+ &merchant_id,+ &customer_id,+ payment_method_id.to_owned(),+ initiator,+ ).await.map_err(|error| logger::error!(?error, "Failed to set the payment method as default"));}@@ -791,6 +804,7 @@ pub async fn save_migration_payment_method(req: pm_api::PaymentMethodCreate,migration_status: &mut migration::RecordMigrationStatusBuilder,controller: &dyn PaymentMethodsController,+ initiator: Option<&platform::Initiator>,) -> CustomResult<ApplicationResponse<pm_api::PaymentMethodResponse>, errors::ApiErrorResponse> {let connector_mandate_details = req.connector_mandate_details@@ -801,7 +815,7 @@ pub async fn save_migration_payment_method(let network_transaction_id = req.network_transaction_id.clone();- let res = controller.add_payment_method(&req).await?;+ let res = controller.add_payment_method(&req, initiator).await?;migration_status.card_migrated(true);migration_status.network_transaction_id_migrated(diff --git a/crates/router/src/compatibility/stripe/customers.rs b/crates/router/src/compatibility/stripe/customers.rsindex 2d1127ce86..2853292b4f 100644--- a/crates/router/src/compatibility/stripe/customers.rs+++ b/crates/router/src/compatibility/stripe/customers.rs@@ -50,7 +50,13 @@ pub async fn customer_create(&req,create_cust_req,|state, auth: auth::AuthenticationData, req, _| {- customers::create_customer(state, auth.platform.get_provider().clone(), req, None)+ customers::create_customer(+ state,+ auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),+ req,+ None,+ )},&auth::HeaderAuth(auth::ApiKeyAuth {allow_connected_scope_operation: true,@@ -146,6 +152,7 @@ pub async fn customer_update(customers::update_customer(state,auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),request_internal,)},@@ -184,7 +191,12 @@ pub async fn customer_delete(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- customers::delete_customer(state, auth.platform.get_provider().clone(), customer_id)+ customers::delete_customer(+ state,+ auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),+ customer_id,+ )},&auth::HeaderAuth(auth::ApiKeyAuth {allow_connected_scope_operation: true,diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rsindex 6a1196ed6e..61962b8e82 100644--- a/crates/router/src/core/customers.rs+++ b/crates/router/src/core/customers.rs@@ -51,6 +51,7 @@ pub const REDACTED: &str = "Redacted";pub async fn create_customer(state: SessionState,provider: domain::Provider,+ initiator: Option<domain::Initiator>,customer_data: customers::CustomerRequest,connector_customer_details: Option<Vec<payment_methods_domain::ConnectorCustomerDetails>>,) -> errors::CustomerResponse<customers::CustomerResponse> {@@ -93,6 +94,7 @@ pub async fn create_customer(db,&merchant_reference_id,&provider,+ initiator.as_ref(),key_manager_state,&state,)@@ -110,6 +112,7 @@ pub async fn create_customer(customer_data.generate_response(&customer)}+#[allow(clippy::too_many_arguments)]#[async_trait::async_trait]trait CustomerCreateBridge {async fn create_domain_model_from_request<'a>(@@ -120,6 +123,7 @@ trait CustomerCreateBridge {db: &'a dyn StorageInterface,merchant_reference_id: &'a Option<id_type::CustomerId>,provider: &'a domain::Provider,+ initiator: Option<&'a domain::Initiator>,key_manager_state: &'a KeyManagerState,state: &'a SessionState,) -> errors::CustomResult<domain::Customer, errors::CustomersErrorResponse>;@@ -141,6 +145,7 @@ impl CustomerCreateBridge for customers::CustomerRequest {db: &'a dyn StorageInterface,merchant_reference_id: &'a Option<id_type::CustomerId>,provider: &'a domain::Provider,+ initiator: Option<&'a domain::Initiator>,key_manager_state: &'a KeyManagerState,state: &'a SessionState,) -> errors::CustomResult<domain::Customer, errors::CustomersErrorResponse> {@@ -256,9 +261,8 @@ impl CustomerCreateBridge for customers::CustomerRequest {version: common_types::consts::API_VERSION,tax_registration_id: encryptable_customer.tax_registration_id,document_details: document_details_encrypted,- // TODO: Populate created_by from authentication context once it is integrated in auth data- created_by: None,- last_modified_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),})}@@ -286,6 +290,7 @@ impl CustomerCreateBridge for customers::CustomerRequest {_db: &'a dyn StorageInterface,merchant_reference_id: &'a Option<id_type::CustomerId>,provider: &'a domain::Provider,+ initiator: Option<&'a domain::Initiator>,key_state: &'a KeyManagerState,state: &'a SessionState,) -> errors::CustomResult<domain::Customer, errors::CustomersErrorResponse> {@@ -376,9 +381,8 @@ impl CustomerCreateBridge for customers::CustomerRequest {status: common_enums::DeleteStatus::Active,tax_registration_id: encryptable_customer.tax_registration_id,document_details: None,- // TODO: Populate created_by from authentication context once it is integrated in auth data- created_by: None,- last_modified_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),})}@@ -812,7 +816,10 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {status: Some(common_enums::DeleteStatus::Redacted),tax_registration_id: Some(redacted_encrypted_value.clone()),document_details: None,- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),}));db.update_customer_by_global_id(@@ -843,6 +850,7 @@ trait CustomerDeleteBridge {&'a self,db: &'a dyn StorageInterface,provider: &'a domain::Provider,+ initiator: Option<&'a domain::Initiator>,key_manager_state: &'a KeyManagerState,state: &'a SessionState,) -> errors::CustomerResponse<customers::CustomerDeleteResponse>;@@ -865,12 +873,19 @@ trait CustomerDeleteBridge {pub async fn delete_customer(state: SessionState,provider: domain::Provider,+ initiator: Option<domain::Initiator>,customer_id: id_type::CustomerId,) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {let db = &*state.store;let key_manager_state = &(&state).into();customer_id- .redact_customer_details_and_generate_response(db, &provider, key_manager_state, &state)+ .redact_customer_details_and_generate_response(+ db,+ &provider,+ initiator.as_ref(),+ key_manager_state,+ &state,+ ).await}@@ -881,6 +896,7 @@ impl CustomerDeleteBridge for id_type::CustomerId {&'a self,db: &'a dyn StorageInterface,provider: &'a domain::Provider,+ initiator: Option<&'a domain::Initiator>,key_manager_state: &'a KeyManagerState,state: &'a SessionState,) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {@@ -1049,7 +1065,9 @@ impl CustomerDeleteBridge for id_type::CustomerId {address_id: None,tax_registration_id: Some(redacted_encrypted_value.clone()),document_details: Box::new(None),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_customer_by_customer_id_merchant_id(@@ -1078,6 +1096,7 @@ impl CustomerDeleteBridge for id_type::CustomerId {pub async fn update_customer(state: SessionState,provider: domain::Provider,+ initiator: Option<domain::Initiator>,update_customer: customers::CustomerUpdateRequestInternal,) -> errors::CustomerResponse<customers::CustomerResponse> {update_customer@@ -1119,6 +1138,7 @@ pub async fn update_customer(&None,db,&provider,+ initiator.as_ref(),key_manager_state,&state,&customer,@@ -1128,6 +1148,7 @@ pub async fn update_customer(update_customer.request.generate_response(&updated_customer)}+#[allow(clippy::too_many_arguments)]#[async_trait::async_trait]trait CustomerUpdateBridge {async fn create_domain_model_from_request<'a>(@@ -1137,6 +1158,7 @@ trait CustomerUpdateBridge {>,db: &'a dyn StorageInterface,provider: &'a domain::Provider,+ initiator: Option<&'a domain::Initiator>,key_manager_state: &'a KeyManagerState,state: &'a SessionState,domain_customer: &'a domain::Customer,@@ -1294,6 +1316,7 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {>,db: &'a dyn StorageInterface,provider: &'a domain::Provider,+ initiator: Option<&'a domain::Initiator>,key_manager_state: &'a KeyManagerState,state: &'a SessionState,domain_customer: &'a domain::Customer,@@ -1390,7 +1413,11 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {description: self.description.clone(),connector_customer: Box::new(None),address_id: address.clone().map(|addr| addr.address_id),- last_modified_by: None,+ last_modified_by: initiator.and_then(|initiator| {+ initiator+ .to_created_by()+ .map(|last_modified_by| last_modified_by.to_string())+ }),},provider.get_key_store(),provider.get_account().storage_scheme,@@ -1424,6 +1451,7 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {>,db: &'a dyn StorageInterface,provider: &'a domain::Provider,+ initiator: Option<&'a domain::Initiator>,key_manager_state: &'a KeyManagerState,state: &'a SessionState,domain_customer: &'a domain::Customer,@@ -1506,7 +1534,11 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {default_shipping_address: encrypted_customer_shipping_address,default_payment_method_id: Some(self.default_payment_method_id.clone()),status: None,- last_modified_by: None,+ last_modified_by: initiator.and_then(|initiator| {+ initiator+ .to_created_by()+ .map(|last_modified_by| last_modified_by.to_string())+ }),})),provider.get_key_store(),provider.get_account().storage_scheme,@@ -1537,6 +1569,7 @@ pub async fn migrate_customers(match create_customer(state.clone(),platform.get_provider().clone(),+ platform.get_initiator().cloned(),customer_migration.customer,customer_migration.connector_customer_details,)diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 60bff2c8d4..a6239cd955 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -466,6 +466,7 @@ pub async fn add_payment_method_status_update_task(curr_status: enums::PaymentMethodStatus,merchant_id: &id_type::MerchantId,application_source: common_enums::ApplicationSource,+ initiator: Option<&hyperswitch_domain_models::platform::Initiator>,) -> Result<(), ProcessTrackerError> {let created_at = payment_method.created_at;let schedule_time =@@ -476,6 +477,9 @@ pub async fn add_payment_method_status_update_task(prev_status,curr_status,merchant_id: merchant_id.to_owned(),+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};let runner = storage::ProcessTrackerRunner::PaymentMethodStatusUpdateWorkflow;@@ -1542,6 +1546,7 @@ impl PaymentMethodResolver {platform.get_provider().get_key_store(),platform.get_provider().get_account().storage_scheme,billing_address.clone(),+ platform.get_initiator(),).await?;Box::pin(execute_payment_method_create(@@ -1636,6 +1641,7 @@ async fn execute_payment_method_create(payment_method_subtype,external_vault_source,Some(enums::PaymentMethodStatus::New),+ platform.get_initiator(),).await.attach_printable("unable to create payment method data")?;@@ -1687,7 +1693,10 @@ async fn execute_payment_method_create(Err(e) => {let pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(enums::PaymentMethodStatus::Inactive),- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_payment_method(@@ -1769,6 +1778,7 @@ pub async fn create_volatile_payment_method_card_core(locker_id,fingerprint_id,external_vault_source,+ platform.get_initiator(),).await.attach_printable("failed to construct payment method")?@@ -1945,6 +1955,7 @@ pub async fn create_payment_method_proxy_card_core(encrypted_payment_method_data,encrypted_external_vault_token_data,vault_type,+ platform.get_initiator(),).await?;@@ -2313,6 +2324,7 @@ pub async fn payment_method_intent_create(state: &SessionState,req: api::PaymentMethodIntentCreate,provider: domain::Provider,+ initiator: Option<&domain::Initiator>,) -> RouterResponse<api::PaymentMethodResponse> {let db = &*state.store;let merchant_id = provider.get_account().get_id();@@ -2362,6 +2374,7 @@ pub async fn payment_method_intent_create(provider.get_key_store(),provider.get_account().storage_scheme,payment_method_billing_address,+ initiator,).await.attach_printable("Failed to add Payment method to DB")?;@@ -2748,6 +2761,7 @@ pub async fn create_payment_method_for_intent(payment_method_billing_address: Option<Encryptable<hyperswitch_domain_models::address::Address>,>,+ initiator: Option<&domain::Initiator>,) -> CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> {use josekit::jwe::zip::deflate::DeflateJweCompression::Def;@@ -2784,8 +2798,8 @@ pub async fn create_payment_method_for_intent(external_vault_source: None,external_vault_token_data: None,vault_type: None,- created_by: None,- last_modified_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),customer_details: None,},storage_scheme,@@ -2816,6 +2830,7 @@ pub async fn construct_payment_method_object(locker_id: Option<domain::VaultId>,locker_fingerprint_id: Option<String>,external_vault_source: Option<id_type::MerchantConnectorAccountId>,+ initiator: Option<&domain::Initiator>,) -> RouterResult<domain::PaymentMethod> {let current_time = common_utils::date_time::now();@@ -2870,8 +2885,8 @@ pub async fn construct_payment_method_object(external_vault_source,external_vault_token_data: None,vault_type: None,- created_by: None,- last_modified_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),customer_details: None,})}@@ -2897,6 +2912,7 @@ pub async fn create_payment_method_for_confirm(Encryptable<payment_methods::ExternalVaultTokenData>,>,vault_type: Option<common_enums::VaultType>,+ initiator: Option<&domain::Initiator>,) -> CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> {let db = &*state.store;let current_time = common_utils::date_time::now();@@ -2930,8 +2946,8 @@ pub async fn create_payment_method_for_confirm(external_vault_source,external_vault_token_data: encrypted_external_vault_token_data,vault_type,- created_by: None,- last_modified_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),customer_details: None,},storage_scheme,@@ -3107,6 +3123,7 @@ pub async fn create_pm_additional_data_update(payment_method_subtype: Option<common_enums::PaymentMethodType>,external_vault_source: Option<id_type::MerchantConnectorAccountId>,status: Option<storage_enums::PaymentMethodStatus>,+ initiator: Option<&domain::Initiator>,) -> RouterResult<storage::PaymentMethodUpdate> {let encrypted_payment_method_data = pmd.map(|payment_method_vaulting_data| payment_method_vaulting_data.get_payment_methods_data())@@ -3153,7 +3170,9 @@ pub async fn create_pm_additional_data_update(locker_fingerprint_id: vault_fingerprint_id,external_vault_source,network_transaction_id,- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};Ok(pm_update)@@ -4168,6 +4187,7 @@ pub async fn update_payment_method_status_internal(storage_scheme: enums::MerchantStorageScheme,status: enums::PaymentMethodStatus,payment_method_id: &id_type::GlobalPaymentMethodId,+ initiator: Option<&domain::Initiator>,) -> RouterResult<domain::PaymentMethod> {let db = &*state.store;@@ -4178,7 +4198,9 @@ pub async fn update_payment_method_status_internal(let pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(status),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};let updated_pm = db@@ -4361,7 +4383,10 @@ pub async fn delete_payment_method_by_record(// Soft deletelet pm_update = storage::PaymentMethodUpdate::StatusAndFingerprintUpdate {status: Some(enums::PaymentMethodStatus::Inactive),- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),locker_fingerprint_id: Some(PAYMENT_METHOD_REDACTED_FINGERPRINT_ID.to_string()),};@@ -5780,6 +5805,7 @@ impl<'a> pm_types::PaymentMethodUpdateHandler<'a> {None,None,pm_status,+ self.platform.get_initiator(),).await.attach_printable("Unable to create Payment method data")?;diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 37c4144487..ba68db0585 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -142,6 +142,7 @@ impl PaymentMethodsController for PmCards<'_> {vault_source_details: Option<domain::PaymentMethodVaultSourceDetails>,payment_method_customer_details_encrypted: crypto::OptionalEncryptableValue,locker_fingerprint_id: Option<String>,+ initiator: Option<&domain::Initiator>,) -> errors::CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> {let db = &*self.state.store;let customer = db@@ -201,8 +202,8 @@ impl PaymentMethodsController for PmCards<'_> {network_token_payment_method_data,vault_source_details: vault_source_details.unwrap_or(domain::PaymentMethodVaultSourceDetails::InternalVault),- created_by: None,- last_modified_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),customer_details: payment_method_customer_details_encrypted,locker_fingerprint_id,},@@ -214,7 +215,12 @@ impl PaymentMethodsController for PmCards<'_> {if customer.default_payment_method_id.is_none() && req.payment_method.is_some() {let _ = self- .set_default_payment_method(merchant_id, customer_id, payment_method_id.to_owned())+ .set_default_payment_method(+ merchant_id,+ customer_id,+ payment_method_id.to_owned(),+ initiator,+ ).await.map_err(|error| {logger::error!(?error, "Failed to set the payment method as default")@@ -276,6 +282,7 @@ impl PaymentMethodsController for PmCards<'_> {resp: &mut domain::PaymentMethodResponse,customer_id: &id_type::CustomerId,key_store: &domain::MerchantKeyStore,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResult<domain::PaymentMethod> {let mut payment_method_id = resp.payment_method_id.clone();let mut locker_id = None;@@ -335,6 +342,7 @@ impl PaymentMethodsController for PmCards<'_> {None,Default::default(),resp.locker_fingerprint_id.clone(),+ initiator,).await} else {@@ -366,6 +374,7 @@ impl PaymentMethodsController for PmCards<'_> {network_token_data: &api_models::payment_methods::MigrateNetworkTokenData,network_token_requestor_ref_id: String,pm_id: String,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResult<bool> {let payment_method_create_request =api::PaymentMethodCreate::get_payment_method_create_from_payment_method_migrate(@@ -425,7 +434,9 @@ impl PaymentMethodsController for PmCards<'_> {network_token_locker_id: Some(token_pm_resp.payment_method_id),network_token_payment_method_data: pm_network_token_data_encrypted.map(Into::into),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};let db = &*self.state.store;let existing_pm = db@@ -482,6 +493,7 @@ impl PaymentMethodsController for PmCards<'_> {network_token_payment_method_data: crypto::OptionalEncryptableValue,vault_source_details: Option<domain::PaymentMethodVaultSourceDetails>,locker_fingerprint_id: Option<String>,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResult<domain::PaymentMethod> {let pm_card_details = match &resp.card {Some(card) => Some(PaymentMethodsData::Card(CardDetailsPaymentMethod::from((@@ -538,6 +550,7 @@ impl PaymentMethodsController for PmCards<'_> {vault_source_details,None,locker_fingerprint_id,+ initiator,).await}@@ -908,6 +921,7 @@ impl PaymentMethodsController for PmCards<'_> {merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,payment_method_id: String,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResponse<api_models::payment_methods::CustomerDefaultPaymentMethodResponse>{let db = &*self.state.store;@@ -958,7 +972,9 @@ impl PaymentMethodsController for PmCards<'_> {let customer_update = CustomerUpdate::UpdateDefaultPaymentMethod {default_payment_method_id: Some(Some(payment_method_id.to_owned())),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};// update the db with the default payment method id@@ -992,6 +1008,7 @@ impl PaymentMethodsController for PmCards<'_> {prev_status: common_enums::PaymentMethodStatus,curr_status: common_enums::PaymentMethodStatus,merchant_id: &id_type::MerchantId,+ initiator: Option<&domain::Initiator>,) -> Result<(), sch_errors::ProcessTrackerError> {add_payment_method_status_update_task(&*self.state.store,@@ -1000,6 +1017,7 @@ impl PaymentMethodsController for PmCards<'_> {curr_status,merchant_id,self.state.conf.application_source,+ initiator,).await}@@ -1102,6 +1120,7 @@ impl PaymentMethodsController for PmCards<'_> {async fn delete_payment_method(&self,pm_id: api::PaymentMethodId,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResponse<api::PaymentMethodDeleteResponse> {let db = self.state.store.as_ref();let key = db@@ -1172,7 +1191,9 @@ impl PaymentMethodsController for PmCards<'_> {if customer.default_payment_method_id.as_ref() == Some(&pm_id.payment_method_id) {let customer_update = CustomerUpdate::UpdateDefaultPaymentMethod {default_payment_method_id: Some(None),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_customer_by_customer_id_merchant_id(key.customer_id,@@ -1200,6 +1221,7 @@ impl PaymentMethodsController for PmCards<'_> {async fn add_payment_method(&self,req: &api::PaymentMethodCreate,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResponse<api::PaymentMethodResponse> {req.validate()?;let db = &*self.state.store;@@ -1293,6 +1315,7 @@ impl PaymentMethodsController for PmCards<'_> {&mut resp,&customer_id,self.provider.get_key_store(),+ initiator,).await?;@@ -1306,6 +1329,7 @@ impl PaymentMethodsController for PmCards<'_> {&mut resp,&customer_id,self.provider.get_key_store(),+ initiator,).await?;@@ -1402,7 +1426,9 @@ impl PaymentMethodsController for PmCards<'_> {let pm_update = storage::PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: pm_data_encrypted.map(Into::into),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_payment_method(@@ -1449,6 +1475,7 @@ impl PaymentMethodsController for PmCards<'_> {None,Default::default(), //Currently this method is used for adding payment method via PaymentMethodCreate API which doesn't support external vault. hence Default i.e. InternalVault is passed for vault source and typeresp.locker_fingerprint_id.clone(),+ initiator,).await?;@@ -1468,6 +1495,7 @@ pub async fn get_client_secret_or_add_payment_method(state: &routes::SessionState,req: api::PaymentMethodCreate,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResponse<api::PaymentMethodResponse> {let merchant_id = provider.get_account().get_id();let customer_id = req.customer_id.clone().get_required_value("customer_id")?;@@ -1496,7 +1524,7 @@ pub async fn get_client_secret_or_add_payment_method(.change_context(errors::ApiErrorResponse::InternalServerError)?;if condition {- Box::pin(cards.add_payment_method(&req)).await+ Box::pin(cards.add_payment_method(&req, initiator)).await} else {let payment_method_id = generate_id(consts::ID_LENGTH, "pm");@@ -1521,6 +1549,7 @@ pub async fn get_client_secret_or_add_payment_method(Default::default(), //Currently this method is used for adding payment method via PaymentMethodCreate API which doesn't support external vault. hence Default i.e. InternalVault is passed for vault typeNone,None,+ initiator,).await?;@@ -1532,6 +1561,7 @@ pub async fn get_client_secret_or_add_payment_method(enums::PaymentMethodStatus::Inactive,merchant_id,state.conf.application_source,+ initiator,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1580,6 +1610,7 @@ pub async fn add_payment_method_data(state: routes::SessionState,req: api::PaymentMethodCreate,provider: domain::Provider,+ initiator: Option<domain::Initiator>,pm_id: String,) -> errors::RouterResponse<api::PaymentMethodResponse> {let db = &*state.store;@@ -1642,7 +1673,10 @@ pub async fn add_payment_method_data(if duplication_check.is_some() {let pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(enums::PaymentMethodStatus::Inactive),- last_modified_by: None,+ last_modified_by: initiator+ .as_ref()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_payment_method(@@ -1661,6 +1695,7 @@ pub async fn add_payment_method_data(&mut domain_pm_resp,&customer_id,provider.get_key_store(),+ initiator.as_ref(),).await?;@@ -1719,7 +1754,10 @@ pub async fn add_payment_method_data(payment_method_type: req.payment_method_type,network_token_locker_id: None,network_token_payment_method_data: None,- last_modified_by: None,+ last_modified_by: initiator+ .as_ref()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),metadata: None,last_used_at: None,connector_mandate_details: None,@@ -1741,6 +1779,7 @@ pub async fn add_payment_method_data(provider.get_account().get_id(),&customer_id,pm_id,+ initiator.as_ref(),).await.map_err(|error| {@@ -1758,7 +1797,10 @@ pub async fn add_payment_method_data(Err(e) => {let pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(enums::PaymentMethodStatus::Inactive),- last_modified_by: None,+ last_modified_by: initiator+ .as_ref()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_payment_method(@@ -1790,6 +1832,7 @@ pub async fn add_payment_method_data(pub async fn update_customer_payment_method(state: routes::SessionState,provider: domain::Provider,+ initiator: Option<domain::Initiator>,req: api::PaymentMethodUpdate,payment_method_id: &str,pm_data: Option<domain::PaymentMethod>,@@ -1975,7 +2018,9 @@ pub async fn update_customer_payment_method(let pm_update = storage::PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: pm_data_encrypted.map(Into::into),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};add_card_resp@@ -2052,7 +2097,9 @@ pub async fn update_customer_payment_method(let pm_update = storage::PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: Some(pm_data_encrypted.into()),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};let pm = db@@ -2378,6 +2425,7 @@ pub async fn update_payment_method_metadata_and_network_token_data_and_last_usednetwork_token_locker_id: Option<String>,pm_network_token_data_encrypted: Option<Encryptable<Secret<serde_json::Value>>>,storage_scheme: MerchantStorageScheme,+ initiator: Option<&domain::Initiator>,) -> errors::CustomResult<(), errors::VaultError> {let pm_update = payment_method::PaymentMethodUpdate::AdditionalDataUpdate {locker_id: None,@@ -2389,7 +2437,9 @@ pub async fn update_payment_method_metadata_and_network_token_data_and_last_usednetwork_token_requestor_reference_id,network_token_locker_id,network_token_payment_method_data: pm_network_token_data_encrypted.map(Into::into),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),metadata: pm_metadata,last_used_at: Some(common_utils::date_time::now()),connector_mandate_details: None,@@ -2411,12 +2461,15 @@ pub async fn update_payment_method_network_token_data(network_token_locker_id: Option<String>,pm_network_token_data_encrypted: Option<Encryptable<Secret<serde_json::Value>>>,storage_scheme: MerchantStorageScheme,+ initiator: Option<&domain::Initiator>,) -> errors::CustomResult<(), errors::VaultError> {let pm_update = payment_method::PaymentMethodUpdate::NetworkTokenDataUpdate {network_token_requestor_reference_id,network_token_locker_id,network_token_payment_method_data: pm_network_token_data_encrypted.map(Into::into),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_payment_method(key_store, pm, pm_update, storage_scheme)@@ -2432,12 +2485,15 @@ pub async fn update_payment_method_and_last_used(payment_method_update: Option<Encryption>,storage_scheme: MerchantStorageScheme,card_scheme: Option<String>,+ initiator: Option<&domain::Initiator>,) -> errors::CustomResult<(), errors::VaultError> {let pm_update = payment_method::PaymentMethodUpdate::UpdatePaymentMethodDataAndLastUsed {payment_method_data: payment_method_update,scheme: card_scheme,last_used_at: common_utils::date_time::now(),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_payment_method(key_store, pm, pm_update, storage_scheme).await@@ -2453,10 +2509,13 @@ pub async fn update_payment_method_connector_mandate_details(pm: domain::PaymentMethod,connector_mandate_details: Option<CommonMandateReference>,storage_scheme: MerchantStorageScheme,+ initiator: Option<&domain::Initiator>,) -> errors::CustomResult<(), errors::VaultError> {let pm_update = payment_method::PaymentMethodUpdate::ConnectorMandateDetailsUpdate {connector_mandate_details: connector_mandate_details.map(|cmd| cmd.into()),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_payment_method(key_store, pm, pm_update, storage_scheme)@@ -2472,6 +2531,7 @@ pub async fn update_payment_method_connector_mandate_details(pm: domain::PaymentMethod,connector_mandate_details: Option<CommonMandateReference>,storage_scheme: MerchantStorageScheme,+ initiator: Option<&domain::Initiator>,) -> errors::CustomResult<(), errors::VaultError> {let connector_mandate_details_value = connector_mandate_details.map(|common_mandate| {@@ -2484,7 +2544,9 @@ pub async fn update_payment_method_connector_mandate_details(let pm_update = payment_method::PaymentMethodUpdate::ConnectorMandateDetailsUpdate {connector_mandate_details: connector_mandate_details_value,- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_payment_method(key_store, pm, pm_update, storage_scheme)@@ -2504,6 +2566,7 @@ pub async fn update_payment_method_connector_mandate_details_and_network_token_dnetwork_token_locker_id: Option<String>,pm_network_token_data_encrypted: Option<Encryptable<Secret<serde_json::Value>>>,storage_scheme: MerchantStorageScheme,+ initiator: Option<&domain::Initiator>,) -> errors::CustomResult<(), errors::VaultError> {let connector_mandate_details_value = connector_mandate_details.map(|common_mandate| {@@ -2523,7 +2586,9 @@ pub async fn update_payment_method_connector_mandate_details_and_network_token_dnetwork_token_requestor_reference_id,network_token_locker_id,network_token_payment_method_data: pm_network_token_data_encrypted.map(Into::into),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),metadata: None,last_used_at: None,connector_mandate_details: connector_mandate_details_value,@@ -5395,6 +5460,7 @@ pub async fn tokenize_card_flow(state: &routes::SessionState,req: domain::CardNetworkTokenizeRequest,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResult<api::CardNetworkTokenizeResponse> {match req.data {domain::TokenizeDataRequest::Card(ref card_req) => {@@ -5406,7 +5472,7 @@ pub async fn tokenize_card_flow();let builder =tokenize::NetworkTokenizationBuilder::<tokenize::TokenizeWithCard>::default();- execute_card_tokenization(executor, builder, card_req).await+ execute_card_tokenization(executor, builder, card_req, initiator).await}domain::TokenizeDataRequest::ExistingPaymentMethod(ref payment_method) => {let executor = tokenize::CardNetworkTokenizeExecutor::new(@@ -5421,6 +5487,7 @@ pub async fn tokenize_card_flow(executor,builder,payment_method,+ initiator,)).await}@@ -5432,6 +5499,7 @@ pub async fn execute_card_tokenization(executor: tokenize::CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest>,builder: tokenize::NetworkTokenizationBuilder<'_, tokenize::TokenizeWithCard>,req: &domain::TokenizeCardRequest,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResult<api::CardNetworkTokenizeResponse> {// Validate request and get optional customerlet optional_customer = executor@@ -5454,7 +5522,7 @@ pub async fn execute_card_tokenization(// Create customer if not presentlet customer = match optional_customer {Some(customer) => customer,- None => executor.create_customer().await?,+ None => executor.create_customer(initiator).await?,};let builder = builder.set_customer(&customer);@@ -5501,6 +5569,7 @@ pub async fn execute_payment_method_tokenization(executor: tokenize::CardNetworkTokenizeExecutor<'_, domain::TokenizePaymentMethodRequest>,builder: tokenize::NetworkTokenizationBuilder<'_, tokenize::TokenizeWithPmId>,req: &domain::TokenizePaymentMethodRequest,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResult<api::CardNetworkTokenizeResponse> {// Fetch payment methodlet payment_method = executor@@ -5570,6 +5639,7 @@ pub async fn execute_payment_method_tokenization(payment_method,&network_token_details,&domain_card,+ initiator,).await?;let builder = builder.set_payment_method(&updated_payment_method);diff --git a/crates/router/src/core/payment_methods/migration.rs b/crates/router/src/core/payment_methods/migration.rsindex 36905503c3..37708531c8 100644--- a/crates/router/src/core/payment_methods/migration.rs+++ b/crates/router/src/core/payment_methods/migration.rs@@ -252,7 +252,10 @@ pub async fn update_payment_method_record(network_transaction_id,status,payment_method_data: updated_payment_method_data.clone(),- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),}}// Case: Only connector_customer_id provided@@ -338,20 +341,29 @@ pub async fn update_payment_method_record(network_transaction_id,status,payment_method_data: updated_payment_method_data.clone(),- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),}}_ => {if updated_payment_method_data.is_some() {PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: updated_payment_method_data,- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),}} else {PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,status,- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),}}}diff --git a/crates/router/src/core/payment_methods/tokenize.rs b/crates/router/src/core/payment_methods/tokenize.rsindex 43ed23eb89..7487d7221c 100644--- a/crates/router/src/core/payment_methods/tokenize.rs+++ b/crates/router/src/core/payment_methods/tokenize.rs@@ -97,6 +97,7 @@ pub async fn tokenize_cards(state: &SessionState,records: Vec<payment_methods_api::CardNetworkTokenizeRequest>,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,) -> errors::RouterResponse<Vec<payment_methods_api::CardNetworkTokenizeResponse>> {use futures::stream::StreamExt;@@ -109,6 +110,7 @@ pub async fn tokenize_cards(state,domain::CardNetworkTokenizeRequest::foreign_from(record),provider,+ initiator,)).await.unwrap_or_else(|e| {diff --git a/crates/router/src/core/payment_methods/tokenize/card_executor.rs b/crates/router/src/core/payment_methods/tokenize/card_executor.rsindex 8398fabbd5..c7e884944a 100644--- a/crates/router/src/core/payment_methods/tokenize/card_executor.rs+++ b/crates/router/src/core/payment_methods/tokenize/card_executor.rs@@ -372,7 +372,10 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest> {)}- pub async fn create_customer(&self) -> RouterResult<api::CustomerDetails> {+ pub async fn create_customer(+ &self,+ initiator: Option<&domain::Initiator>,+ ) -> RouterResult<api::CustomerDetails> {let db = &*self.state.store;let customer_id = self.customer@@ -437,9 +440,8 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest> {version: common_types::consts::API_VERSION,tax_registration_id: encryptable_customer.tax_registration_id,document_details: None,- // TODO: Populate created_by from authentication context once it is integrated in auth data- created_by: None,- last_modified_by: None, // Same as created_by on creation+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),};db.insert_customer(@@ -609,6 +611,7 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest> {Default::default(), // this method is used only for card bulk tokenization, and currently external vault is not supported for this hence passing Default i.e. InternalVaultNone,None,+ platform.get_initiator(),).await}diff --git a/crates/router/src/core/payment_methods/tokenize/payment_method_executor.rs b/crates/router/src/core/payment_methods/tokenize/payment_method_executor.rsindex 9dba8ce3e6..fab964316f 100644--- a/crates/router/src/core/payment_methods/tokenize/payment_method_executor.rs+++ b/crates/router/src/core/payment_methods/tokenize/payment_method_executor.rs@@ -387,6 +387,7 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizePaymentMethodRequest> {payment_method: domain::PaymentMethod,network_token_details: &NetworkTokenizationResponse,card_details: &domain::CardDetail,+ initiator: Option<&domain::Initiator>,) -> RouterResult<domain::PaymentMethod> {// Form encrypted network token datalet enc_token_data = self@@ -398,7 +399,9 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizePaymentMethodRequest> {network_token_requestor_reference_id: network_token_details.1.clone(),network_token_locker_id: Some(store_token_response.card_reference.clone()),network_token_payment_method_data: Some(enc_token_data.into()),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};self.state.storediff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rsindex 9bc383b460..e0ee249f48 100644--- a/crates/router/src/core/payment_methods/transformers.rs+++ b/crates/router/src/core/payment_methods/transformers.rs@@ -1335,8 +1335,12 @@ impl DomainPaymentMethodWrapper {network_token_locker_id: None,network_token_payment_method_data: None,vault_source_details: domain::PaymentMethodVaultSourceDetails::InternalVault,- created_by: None,- last_modified_by: None,+ created_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),customer_details: None,locker_fingerprint_id: None,}))@@ -1463,8 +1467,12 @@ impl DomainPaymentMethodWrapper {network_token_locker_id: None,network_token_payment_method_data: None,vault_source_details: domain::PaymentMethodVaultSourceDetails::InternalVault,- created_by: None,- last_modified_by: None,+ created_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),customer_details: None,locker_fingerprint_id: None,}))diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 39a52ab41f..ab4db50163 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -336,7 +336,13 @@ wherelet payment_data = payments_response_operation.to_post_update_tracker()?- .update_tracker(state, platform.get_processor(), payment_data, router_data)+ .update_tracker(+ state,+ platform.get_processor(),+ platform.get_initiator(),+ payment_data,+ router_data,+ ).await?;(payment_data, connector_response_data)@@ -433,7 +439,13 @@ wherelet payment_data = payments_response_operation.to_post_update_tracker()?- .update_tracker(state, platform.get_processor(), payment_data, router_data)+ .update_tracker(+ state,+ platform.get_processor(),+ platform.get_initiator(),+ payment_data,+ router_data,+ ).await?;(payment_data, connector_response_data)@@ -583,7 +595,13 @@ wherelet payment_data = payments_response_operation.to_post_update_tracker()?- .update_tracker(state, platform.get_processor(), payment_data, router_data)+ .update_tracker(+ state,+ platform.get_processor(),+ platform.get_initiator(),+ payment_data,+ router_data,+ ).await?;Ok((@@ -704,6 +722,7 @@ where&mut payment_data,customer_details, // TODO: Remove this field after implicit customer update is removedplatform.get_provider(),+ platform.get_initiator(),dimensions,).await@@ -962,6 +981,7 @@ wheredecide_unified_connector_service_call(state,platform.get_processor(),+ platform.get_initiator(),connector.connector_data.clone(),&operation,&mut payment_data,@@ -1053,6 +1073,7 @@ where.update_pm_and_mandate(state,platform.get_provider(),+ platform.get_initiator(),&payment_data,&router_data_for_pm_mandate,&feature_config,@@ -1133,6 +1154,7 @@ wheredecide_unified_connector_service_call(state,platform.get_processor(),+ platform.get_initiator(),connector_data.clone(),&operation,&mut payment_data,@@ -1259,6 +1281,7 @@ where.update_pm_and_mandate(state,platform.get_provider(),+ platform.get_initiator(),&payment_data,&router_data_for_pm_mandate,&feature_config,@@ -1552,6 +1575,7 @@ where&mut payment_data,customer_details,platform.get_provider(),+ platform.get_initiator(),dimensions,).await@@ -1610,6 +1634,7 @@ where.update_pm_and_mandate(state,platform.get_provider(),+ platform.get_initiator(),&payment_data,&router_data_for_pm_mandate,&feature_config,@@ -1717,7 +1742,13 @@ wherepayments_response_operation.to_post_update_tracker()?- .update_tracker(state, platform.get_processor(), payment_data, router_data)+ .update_tracker(+ state,+ platform.get_processor(),+ platform.get_initiator(),+ payment_data,+ router_data,+ ).await?}ConnectorCallType::Retryable(vec) => todo!(),@@ -1850,7 +1881,13 @@ wherepayments_response_operation.to_post_update_tracker()?- .update_tracker(state, platform.get_processor(), payment_data, router_data)+ .update_tracker(+ state,+ platform.get_processor(),+ platform.get_initiator(),+ payment_data,+ router_data,+ ).await?}ConnectorCallType::Retryable(_) => todo!(),@@ -4310,6 +4347,7 @@ pub struct ConnectorServiceIntermediateState<F, RouterDReq> {pub async fn call_connector_service<F, RouterDReq, ApiRequest, D>(state: &SessionState,processor: &domain::Processor,+ initiator: Option<&domain::Initiator>,connector: api::ConnectorData,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,@@ -4403,6 +4441,7 @@ wherestate,connector_customer_map,processor,+ initiator,&merchant_connector_account,payment_data,router_data.access_token.as_ref(),@@ -4763,6 +4802,7 @@ wherepub async fn decide_unified_connector_service_call<'a, F, RouterDReq, ApiRequest, D>(state: &'a SessionState,processor: &'a domain::Processor,+ initiator: Option<&'a domain::Initiator>,connector: api::ConnectorData,operation: &'a BoxedOperation<'a, F, ApiRequest, D>,payment_data: &'a mut D,@@ -4834,6 +4874,7 @@ wherelet (updated_customer, call_connector_service_response) = call_connector_service(&updated_state,processor,+ initiator,connector,operation,payment_data,@@ -5122,6 +5163,7 @@ whereplatform.get_processor(),&merchant_connector_account_type_details,payment_data,+ platform.get_initiator(),).await?;@@ -7041,10 +7083,12 @@ pub fn validate_customer_details_for_click_to_pay(}#[cfg(feature = "v1")]+#[allow(clippy::too_many_arguments)]pub async fn call_create_connector_customer_if_required<F, Req, D>(state: &SessionState,connector_customer_map: Option<&pii::SecretSerdeValue>,processor: &domain::Processor,+ initiator: Option<&domain::Initiator>,merchant_connector_account: &helpers::MerchantConnectorAccountType,payment_data: &mut D,access_token: Option<&AccessToken>,@@ -7136,6 +7180,7 @@ where&label,connector_customer_map,connector_customer_id.clone(),+ initiator,).await;@@ -7160,6 +7205,7 @@ pub async fn call_create_connector_customer_if_required<F, Req, D>(processor: &domain::Processor,merchant_connector_account: &domain::MerchantConnectorAccountTypeDetails,payment_data: &mut D,+ initiator: Option<&domain::Initiator>,) -> RouterResult<Option<storage::CustomerUpdate>>whereF: Send + Clone + Sync,@@ -7223,6 +7269,7 @@ wheremerchant_connector_account,customer.as_ref(),connector_customer_id.clone(),+ initiator,).await;diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 34ed86c942..b740030bb4 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -1891,6 +1891,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(payment_data: &mut PaymentData<F>,req: Option<CustomerDetails>,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,dimensions: DimensionsWithMerchantId,) -> CustomResult<(BoxedOperation<'a, F, R, D>, Option<domain::Customer>), errors::StorageError> {let merchant_id = provider.get_account().get_id();@@ -2023,7 +2024,9 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(address_id: None,tax_registration_id: encryptable_customer.tax_registration_id,document_details: Box::new(document_details),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};db.update_customer_by_customer_id_merchant_id(@@ -2066,9 +2069,8 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(version: common_types::consts::API_VERSION,tax_registration_id: encryptable_customer.tax_registration_id,document_details,- // TODO: Populate created_by from authentication context once it is integrated in auth data- created_by: None,- last_modified_by: None, // Same as created_by on creation+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),+ last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),};metrics::CUSTOMER_CREATED.add(1, &[]);db.insert_customer(new_customer, key_store, storage_scheme)diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rsindex 246deb466b..9085268e06 100644--- a/crates/router/src/core/payments/operations.rs+++ b/crates/router/src/core/payments/operations.rs@@ -273,6 +273,7 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {payment_data: &mut D,request: Option<CustomerDetails>,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> CustomResult<(BoxedOperation<'a, F, R, D>, Option<domain::Customer>), errors::StorageError>;@@ -585,6 +586,7 @@ pub trait PostUpdateTracker<F, D, R: Send>: Send {&'b self,db: &'b SessionState,processor: &domain::Processor,+ initiator: Option<&domain::Initiator>,payment_data: D,response: types::RouterData<F, R, PaymentsResponseData>,) -> RouterResult<D>@@ -614,6 +616,7 @@ pub trait PostUpdateTracker<F, D, R: Send>: Send {&self,_state: &SessionState,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_payment_data: &D,_router_data: &types::RouterData<F, R, PaymentsResponseData>,_feature_set: &core_utils::FeatureConfig,@@ -662,6 +665,7 @@ where_payment_data: &mut D,_request: Option<CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> CustomResult<(@@ -731,6 +735,7 @@ where_payment_data: &mut D,_request: Option<CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> CustomResult<(@@ -818,6 +823,7 @@ where_payment_data: &mut D,_request: Option<CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> CustomResult<(@@ -905,6 +911,7 @@ where_payment_data: &mut D,_request: Option<CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> CustomResult<(diff --git a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rsindex 05a20f4638..1a8a823594 100644--- a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs+++ b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs@@ -234,7 +234,8 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ExternalVaultPcell_id,storage_scheme,request,- encrypted_data+ encrypted_data,+ platform.get_initiator(),).await?;db.insert_payment_attempt(@@ -435,6 +436,7 @@ impl<F: Clone + Send + Sync> Domain<F, ExternalVaultProxyPaymentsRequest, Paymenplatform.get_processor().get_account().storage_scheme,common_enums::PaymentMethodStatus::Active,payment_method.get_id(),+ platform.get_initiator(),).await.map_err(|err| router_env::logger::error!(err=?err));@@ -584,6 +586,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor&'b self,state: &'b SessionState,processor: &domain::Processor,+ _initiator: Option<&domain::Initiator>,mut payment_data: PaymentConfirmData<F>,response: types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>,) -> RouterResult<PaymentConfirmData<F>>diff --git a/crates/router/src/core/payments/operations/payment_attempt_record.rs b/crates/router/src/core/payments/operations/payment_attempt_record.rsindex 72cc660067..da4747ccda 100644--- a/crates/router/src/core/payments/operations/payment_attempt_record.rs+++ b/crates/router/src/core/payments/operations/payment_attempt_record.rs@@ -183,6 +183,7 @@ impl<F: Send + Clone + Sync>storage_scheme,request,encrypted_data,+ platform.get_initiator(),).await?;diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rsindex b185b7ea9c..0f08e1a59e 100644--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs@@ -246,6 +246,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsCancelPostCaptureRequest, Pa_payment_data: &mut PaymentData<F>,_request: Option<payments::CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> errors::CustomResult<(diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex bc0b78de40..ab7311834b 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -409,6 +409,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,_request: Option<CustomerDetails>,provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> CustomResult<(CompleteAuthorizeOperation<'a, F>, Option<domain::Customer>),diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex da5ba76fae..aded2bc88f 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -994,6 +994,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,request: Option<CustomerDetails>,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,dimensions: DimensionsWithMerchantId,) -> CustomResult<(PaymentConfirmOperation<'a, F>, Option<domain::Customer>),@@ -1007,6 +1008,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data,request,provider,+ initiator,dimensions,).awaitdiff --git a/crates/router/src/core/payments/operations/payment_confirm_intent.rs b/crates/router/src/core/payments/operations/payment_confirm_intent.rsindex 18a99d8903..b86e5cb893 100644--- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs+++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs@@ -210,7 +210,8 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, PaymentsConfircell_id,storage_scheme,request,- encrypted_data+ encrypted_data,+ platform.get_initiator(),).await?;@@ -356,6 +357,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, PaymentsConfirpm_split_amount_data.payment_method_details.payment_method_subtype,+ platform.get_initiator(),).await?;diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 092f663551..53175e9831 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -696,6 +696,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,request: Option<CustomerDetails>,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,dimensions: DimensionsWithMerchantId,) -> CustomResult<(PaymentCreateOperation<'a, F>, Option<domain::Customer>), errors::StorageError>{@@ -707,6 +708,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data,request,provider,+ initiator,dimensions,).await@@ -1532,7 +1534,7 @@ impl PaymentCreate {capture_before: None,card_discovery: None,processor_merchant_id: platform.get_processor().get_account().get_id().clone(),- created_by: None,+ created_by: platform.get_initiator().and_then(|initiator| initiator.to_created_by()),setup_future_usage_applied: request.setup_future_usage,routing_approach: Some(common_enums::RoutingApproach::default()),connector_request_reference_id: None,@@ -1766,7 +1768,9 @@ impl PaymentCreate {request_extended_authorization: request.request_extended_authorization,psd2_sca_exemption_type: request.psd2_sca_exemption_type,processor_merchant_id: platform.get_processor().get_account().get_id().to_owned(),- created_by: None,+ created_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),force_3ds_challenge: request.force_3ds_challenge,force_3ds_challenge_trigger: Some(force_3ds_challenge_trigger),is_iframe_redirection_enabled: requestdiff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rsindex 5dfad074cb..ec0a170779 100644--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs@@ -206,6 +206,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsPostSessionTokensRequest, Pa_payment_data: &mut PaymentData<F>,_request: Option<payments::CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> errors::CustomResult<(diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 3e27d988e5..16c34ca715 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -234,6 +234,7 @@ whereasync fn update_pm_connector_mandate_details<F, Req>(state: &SessionState,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,payment_data: &PaymentData<F>,router_data: &types::RouterData<F, Req, types::PaymentsResponseData>,) -> RouterResult<()>@@ -321,6 +322,7 @@ wherepayment_method,connector_mandate_details,provider.get_account().storage_scheme,+ initiator,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -698,6 +700,7 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor&self,state: &SessionState,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,payment_data: &PaymentData<F>,router_data: &types::RouterData<F,@@ -710,7 +713,14 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthorF: 'b + Clone + Send + Sync,{if !feature_set.is_payment_method_modular_allowed {- update_pm_connector_mandate_details(state, provider, payment_data, router_data).await+ update_pm_connector_mandate_details(+ state,+ provider,+ initiator,+ payment_data,+ router_data,+ )+ .await} else {Ok(())}@@ -983,6 +993,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> forresp.status,resp.response.clone(),platform.get_provider().get_account().storage_scheme,+ platform.get_initiator(),).await?;Ok(())@@ -993,6 +1004,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> for&self,state: &SessionState,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,payment_data: &PaymentData<F>,router_data: &types::RouterData<F, types::PaymentsSyncData, types::PaymentsResponseData>,feature_set: &core_utils::FeatureConfig,@@ -1001,7 +1013,14 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> forF: 'b + Clone + Send + Sync,{if !feature_set.is_payment_method_modular_allowed {- update_pm_connector_mandate_details(state, provider, payment_data, router_data).await+ update_pm_connector_mandate_details(+ state,+ provider,+ initiator,+ payment_data,+ router_data,+ )+ .await} else {Ok(())}@@ -1727,6 +1746,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa&self,state: &SessionState,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,payment_data: &PaymentData<F>,router_data: &types::RouterData<F,@@ -1738,7 +1758,8 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDawhereF: 'b + Clone + Send + Sync,{- update_pm_connector_mandate_details(state, provider, payment_data, router_data).await+ update_pm_connector_mandate_details(state, provider, initiator, payment_data, router_data)+ .await}#[cfg(feature = "v1")]async fn update_modular_pm_and_mandate<'b>(@@ -1840,6 +1861,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeDataresp.status,resp.response.clone(),platform.get_provider().get_account().storage_scheme,+ platform.get_initiator(),).await?;Ok(())@@ -1850,6 +1872,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData&self,state: &SessionState,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,payment_data: &PaymentData<F>,router_data: &types::RouterData<F,@@ -1862,7 +1885,14 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeDataF: 'b + Clone + Send + Sync,{if !feature_set.is_payment_method_modular_allowed {- update_pm_connector_mandate_details(state, provider, payment_data, router_data).await+ update_pm_connector_mandate_details(+ state,+ provider,+ initiator,+ payment_data,+ router_data,+ )+ .await} else {Ok(())}@@ -2899,6 +2929,7 @@ async fn update_payment_method_status_and_ntid<F: Clone>(attempt_status: common_enums::AttemptStatus,payment_response: Result<types::PaymentsResponseData, ErrorResponse>,storage_scheme: enums::MerchantStorageScheme,+ _initiator: Option<&domain::Initiator>,) -> RouterResult<()> {todo!()}@@ -2911,6 +2942,7 @@ async fn update_payment_method_status_and_ntid<F: Clone>(attempt_status: common_enums::AttemptStatus,payment_response: Result<types::PaymentsResponseData, ErrorResponse>,storage_scheme: enums::MerchantStorageScheme,+ initiator: Option<&domain::Initiator>,) -> RouterResult<()> {// If the payment_method is deleted then ignore the error related to retrieving payment method// This should be handled when the payment method is soft deleted@@ -2969,13 +3001,17 @@ async fn update_payment_method_status_and_ntid<F: Clone>(storage::PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,status: Some(updated_pm_status),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),}} else {storage::PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,status: None,- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),}};@@ -3038,6 +3074,7 @@ impl<F: Clone>&'b self,state: &'b SessionState,processor: &domain::Processor,+ _initiator: Option<&domain::Initiator>,mut payment_data: hyperswitch_domain_models::payments::PaymentCaptureData<F>,response: types::RouterData<F, types::PaymentsCaptureData, types::PaymentsResponseData>,) -> RouterResult<hyperswitch_domain_models::payments::PaymentCaptureData<F>>@@ -3100,6 +3137,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor&'b self,state: &'b SessionState,processor: &domain::Processor,+ initiator: Option<&domain::Initiator>,mut payment_data: PaymentConfirmData<F>,response: types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>,) -> RouterResult<PaymentConfirmData<F>>@@ -3238,6 +3276,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthorprocessor.get_account().storage_scheme,pm_update_status,payment_method.get_id(),+ initiator,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -3270,6 +3309,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentStatusData<F>, types::PaymentsSyncDat&'b self,state: &'b SessionState,processor: &domain::Processor,+ _initiator: Option<&domain::Initiator>,mut payment_data: PaymentStatusData<F>,response: types::RouterData<F, types::PaymentsSyncData, types::PaymentsResponseData>,) -> RouterResult<PaymentStatusData<F>>@@ -3428,6 +3468,7 @@ impl&'b self,state: &'b SessionState,processor: &domain::Processor,+ _initiator: Option<&domain::Initiator>,mut payment_data: PaymentConfirmData<hyperswitch_domain_models::router_flow_types::ExternalVaultProxy,>,@@ -3500,6 +3541,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::SetupMandateRe&'b self,state: &'b SessionState,processor: &domain::Processor,+ _initiator: Option<&domain::Initiator>,mut payment_data: PaymentConfirmData<F>,response: types::RouterData<F, types::SetupMandateRequestData, types::PaymentsResponseData>,) -> RouterResult<PaymentConfirmData<F>>@@ -3822,6 +3864,7 @@ impl<F: Clone + Send + Sync>&'b self,state: &'b SessionState,processor: &domain::Processor,+ _initiator: Option<&domain::Initiator>,mut payment_data: hyperswitch_domain_models::payments::PaymentCancelData<F>,router_data: types::RouterData<F, types::PaymentsCancelData, types::PaymentsResponseData>,) -> RouterResult<hyperswitch_domain_models::payments::PaymentCancelData<F>>diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex f2188f84a7..fc5c826756 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -328,6 +328,7 @@ wherepayment_data: &mut PaymentData<F>,request: Option<payments::CustomerDetails>,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,dimensions: DimensionsWithMerchantId,) -> errors::CustomResult<(PaymentSessionOperation<'a, F>, Option<domain::Customer>),@@ -341,6 +342,7 @@ wherepayment_data,request,provider,+ initiator,dimensions,).awaitdiff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex ab1738f7a9..ef3b5cb03e 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -291,6 +291,7 @@ where_payment_data: &mut PaymentData<F>,_request: Option<CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> CustomResult<(PaymentSessionOperation<'a, F>, Option<domain::Customer>),diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rsindex cfa448bacc..9fc9238994 100644--- a/crates/router/src/core/payments/operations/payment_status.rs+++ b/crates/router/src/core/payments/operations/payment_status.rs@@ -67,6 +67,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,request: Option<CustomerDetails>,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,dimensions: DimensionsWithMerchantId,) -> CustomResult<(@@ -83,6 +84,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data,request,provider,+ initiator,dimensions,).awaitdiff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 5d902b6fe7..c57a53b62a 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -582,6 +582,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,request: Option<CustomerDetails>,provider: &domain::Provider,+ initiator: Option<&domain::Initiator>,dimensions: DimensionsWithMerchantId,) -> CustomResult<(PaymentUpdateOperation<'a, F>, Option<domain::Customer>), errors::StorageError>{@@ -593,6 +594,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data,request,provider,+ initiator,dimensions,).awaitdiff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rsindex d9fb510dca..f40256a793 100644--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs@@ -212,6 +212,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsUpdateMetadataRequest, Payme_payment_data: &mut PaymentData<F>,_request: Option<payments::CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> errors::CustomResult<(diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rsindex c9dc1f3421..a506c4308e 100644--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs@@ -228,6 +228,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsExtendAuthorizationRequest,_payment_data: &mut PaymentData<F>,_request: Option<payments::CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> errors::CustomResult<(diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rsindex b1fea0cd83..5fbed65ef2 100644--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs@@ -326,6 +326,7 @@ impl<F: Clone + Send + Sync>payment_data: &mut payments::PaymentData<F>,request: Option<CustomerDetails>,provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> CustomResult<(diff --git a/crates/router/src/core/payments/operations/proxy_payments_intent.rs b/crates/router/src/core/payments/operations/proxy_payments_intent.rsindex 28363bb36a..63ba23d443 100644--- a/crates/router/src/core/payments/operations/proxy_payments_intent.rs+++ b/crates/router/src/core/payments/operations/proxy_payments_intent.rs@@ -213,7 +213,8 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ProxyPaymentsRcell_id,storage_scheme,request,- encrypted_data+ encrypted_data,+ platform.get_initiator(),).await?;db.insert_payment_attempt(@@ -467,6 +468,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor&'b self,state: &'b SessionState,processor: &domain::Processor,+ _initiator: Option<&domain::Initiator>,mut payment_data: PaymentConfirmData<F>,response: types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>,) -> RouterResult<PaymentConfirmData<F>>diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rsindex 34ae70ebfa..45c7f2ce7e 100644--- a/crates/router/src/core/payments/operations/tax_calculation.rs+++ b/crates/router/src/core/payments/operations/tax_calculation.rs@@ -222,6 +222,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsDynamicTaxCalculationRequest_payment_data: &mut PaymentData<F>,_request: Option<payments::CustomerDetails>,_provider: &domain::Provider,+ _initiator: Option<&domain::Initiator>,_dimensions: DimensionsWithMerchantId,) -> errors::CustomResult<(diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rsindex e873cc0586..d3d3bdf424 100644--- a/crates/router/src/core/payments/retry.rs+++ b/crates/router/src/core/payments/retry.rs@@ -426,6 +426,7 @@ wherepayments::decide_unified_connector_service_call(state,platform.get_processor(),+ platform.get_initiator(),connector.clone(),operation,payment_data,diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rsindex 1fe13bfd29..017d7f22dc 100644--- a/crates/router/src/core/payments/tokenization.rs+++ b/crates/router/src/core/payments/tokenization.rs@@ -499,6 +499,7 @@ wherenetwork_token_locker_id,pm_network_token_data_encrypted,platform.get_provider().get_account().storage_scheme,+ platform.get_initiator(),).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -548,6 +549,7 @@ whereSome(vault_source_details),payment_method_customer_details_encrypted,resp.locker_fingerprint_id,+ platform.get_initiator(),).await} else {@@ -640,6 +642,7 @@ wherenetwork_token_locker_id,pm_network_token_data_encrypted,platform.get_provider().get_account().storage_scheme,+ platform.get_initiator(),).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -692,6 +695,7 @@ whereSome(vault_source_details),payment_method_customer_details_encrypted,resp.locker_fingerprint_id,+ platform.get_initiator(),).await} else {@@ -817,6 +821,7 @@ wherepm_data_encrypted.map(Into::into),platform.get_provider().get_account().storage_scheme,card_scheme,+ platform.get_initiator(),).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -917,6 +922,7 @@ whereSome(vault_source_details),payment_method_customer_details_encrypted,resp.locker_fingerprint_id,+ platform.get_initiator(),).await?;@@ -2145,6 +2151,7 @@ async fn generate_network_token_and_update_payment_method(network_token_locker_id,pm_network_token_data_encrypted,platform.get_provider().get_account().storage_scheme,+ platform.get_initiator(),).await.change_context(errors::ApiErrorResponse::InternalServerError)diff --git a/crates/router/src/core/payments/vault_session.rs b/crates/router/src/core/payments/vault_session.rsindex 848bcb5307..0be07a6113 100644--- a/crates/router/src/core/payments/vault_session.rs+++ b/crates/router/src/core/payments/vault_session.rs@@ -91,6 +91,7 @@ wherestate,customer,platform.get_processor(),+ platform.get_initiator(),&merchant_connector_account,payment_data,)@@ -132,6 +133,7 @@ pub async fn call_create_connector_customer_if_required<F, Req, D>(state: &SessionState,customer: &Option<domain::Customer>,processor: &domain::Processor,+ initiator: Option<&domain::Initiator>,merchant_connector_account_type: &domain::MerchantConnectorAccountTypeDetails,payment_data: &mut D,) -> RouterResult<Option<storage::CustomerUpdate>>@@ -200,6 +202,7 @@ wheremerchant_connector_account_type,customer.as_ref(),connector_customer_id.clone(),+ initiator,).await;diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex 8b6e600795..e6b41b83bb 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -1243,6 +1243,7 @@ pub async fn create_recipient(&connector_label,customer.connector_customer.as_ref(),recipient_create_data.connector_payout_id.clone(),+ platform.get_initiator(),).await{@@ -2217,7 +2218,10 @@ pub async fn create_recipient_disburse_account(#[cfg(feature = "v2")]connector_mandate_details: Some(common_connector_mandate),- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};payout_data.payment_method = Some(diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rsindex 7596804f5f..66f13e1648 100644--- a/crates/router/src/core/payouts/helpers.rs+++ b/crates/router/src/core/payouts/helpers.rs@@ -654,6 +654,7 @@ pub async fn save_payout_data_to_locker(Default::default(),None,None,+ platform.get_initiator(),).await?,);@@ -708,7 +709,10 @@ pub async fn save_payout_data_to_locker(// Update card's metadata in payment_methods tablelet pm_update = storage::PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: card_details_encrypted.map(Into::into),- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};payout_data.payment_method = Some(db.update_payment_method(@@ -899,9 +903,12 @@ pub(super) async fn get_or_create_customer_details(version: common_types::consts::API_VERSION,tax_registration_id: encryptable_customer.tax_registration_id,document_details,- // TODO: Populate created_by from authentication context once it is integrated in auth data- created_by: None,- last_modified_by: None, // Same as created_by on creation+ created_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()), // Same as created_by on creation};Ok(Some(diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rsindex 0915027da9..0bd4aebfb5 100644--- a/crates/router/src/core/pm_auth.rs+++ b/crates/router/src/core/pm_auth.rs@@ -473,7 +473,10 @@ async fn store_bank_details_in_payment_methods(let pm_update = storage::PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: Some(encrypted_data.into()),- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};update_entries.push((pm.clone(), pm_update));@@ -528,8 +531,12 @@ async fn store_bank_details_in_payment_methods(network_token_locker_id: None,network_token_payment_method_data: None,vault_source_details: Default::default(),- created_by: None,- last_modified_by: None,+ created_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by()),customer_details: None,locker_fingerprint_id: None,};diff --git a/crates/router/src/core/split_payments.rs b/crates/router/src/core/split_payments.rsindex 295e1ade7a..66bb3e7fc5 100644--- a/crates/router/src/core/split_payments.rs+++ b/crates/router/src/core/split_payments.rs@@ -503,6 +503,7 @@ pub async fn create_domain_model_for_split_payment(attempts_group_id: &id_type::GlobalAttemptGroupId,payment_method_type: enums::PaymentMethod,payment_method_subtype: enums::PaymentMethodType,+ initiator: Option<&domain::Initiator>,) -> common_utils::errors::CustomResult<domain::PaymentAttempt, errors::ApiErrorResponse> {let id = id_type::GlobalAttemptId::generate(&cell_id);let intent_amount_details = payment_intent.amount_details.clone();@@ -585,7 +586,7 @@ pub async fn create_domain_model_for_split_payment(card_discovery: None,feature_metadata: None,processor_merchant_id: payment_intent.merchant_id.clone(),- created_by: None,+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),connector_request_reference_id: None,network_transaction_id: None,authorized_amount: None,diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex a9227719ce..9557140c15 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -3174,6 +3174,7 @@ async fn update_additional_payment_method_data(Box::pin(cards::update_customer_payment_method(state.clone(),platform.get_provider().clone(),+ platform.get_initiator().cloned(),payment_method_update,&payment_method_id,Some(pm),@@ -3312,7 +3313,7 @@ async fn update_connector_mandate_details(connector_mandate_details: connector_mandate_details_value.map(masking::Secret::new),network_transaction_id: webhook_connector_network_transaction_id.map(|webhook_network_transaction_id| webhook_network_transaction_id.get_id().clone()),- last_modified_by: None,+ last_modified_by: platform.get_initiator().and_then(|initiator| initiator.to_created_by()).map(|last_modified_by| last_modified_by.to_string()),};statediff --git a/crates/router/src/core/webhooks/network_tokenization_incoming.rs b/crates/router/src/core/webhooks/network_tokenization_incoming.rsindex 292f2df133..484837b7c8 100644--- a/crates/router/src/core/webhooks/network_tokenization_incoming.rs+++ b/crates/router/src/core/webhooks/network_tokenization_incoming.rs@@ -336,7 +336,10 @@ pub async fn handle_metadata_update(network_token_requestor_reference_id: None,network_token_locker_id: None,network_token_payment_method_data: None,- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),metadata: None,last_used_at: None,connector_mandate_details: None,@@ -352,7 +355,10 @@ pub async fn handle_metadata_update(network_token_requestor_reference_id: None,network_token_locker_id: Some(res.payment_method_id),network_token_payment_method_data: pm_data_encrypted.map(Into::into),- last_modified_by: None,+ last_modified_by: platform+ .get_initiator()+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),metadata: None,last_used_at: None,connector_mandate_details: None,diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rsindex 2160b73338..4c7f86b1e2 100644--- a/crates/router/src/db/kafka_store.rs+++ b/crates/router/src/db/kafka_store.rs@@ -21,6 +21,8 @@ use error_stack::ResultExt;use hyperswitch_domain_models::payouts::{payout_attempt::PayoutAttemptInterface, payouts::PayoutsInterface,};+#[cfg(feature = "v2")]+use hyperswitch_domain_models::platform::Initiator;use hyperswitch_domain_models::{cards_info::CardsInfoInterface,disputes,@@ -2310,9 +2312,10 @@ impl PaymentMethodInterface for KafkaStore {&self,key_store: &domain::MerchantKeyStore,payment_method: domain::PaymentMethod,+ initiator: Option<&Initiator>,) -> CustomResult<domain::PaymentMethod, errors::StorageError> {self.diesel_store- .delete_payment_method(key_store, payment_method)+ .delete_payment_method(key_store, payment_method, initiator).await}diff --git a/crates/router/src/routes/customers.rs b/crates/router/src/routes/customers.rsindex 0aeaec95ed..c58ad7d812 100644--- a/crates/router/src/routes/customers.rs+++ b/crates/router/src/routes/customers.rs@@ -22,7 +22,13 @@ pub async fn customers_create(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- create_customer(state, auth.platform.get_provider().clone(), req, None)+ create_customer(+ state,+ auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),+ req,+ None,+ )},auth::auth_type(&auth::V2ApiKeyAuth {@@ -54,7 +60,13 @@ pub async fn customers_create(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- create_customer(state, auth.platform.get_provider().clone(), req, None)+ create_customer(+ state,+ auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),+ req,+ None,+ )},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -336,6 +348,7 @@ pub async fn customers_update(update_customer(state,auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),request_internal,)},@@ -378,6 +391,7 @@ pub async fn customers_update(update_customer(state,auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),request_internal,)},@@ -449,7 +463,12 @@ pub async fn customers_delete(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- delete_customer(state, auth.platform.get_provider().clone(), customer_id)+ delete_customer(+ state,+ auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),+ customer_id,+ )},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rsindex 71e764aa9d..f4a5db63da 100644--- a/crates/router/src/routes/payment_methods.rs+++ b/crates/router/src/routes/payment_methods.rs@@ -56,6 +56,7 @@ pub async fn create_payment_method_api(&state,req,auth.platform.get_provider(),+ auth.platform.get_initiator(),)).await},@@ -162,6 +163,7 @@ pub async fn create_payment_method_intent_api(&state,req,auth.platform.get_provider().clone(),+ auth.platform.get_initiator(),)).await},@@ -637,6 +639,7 @@ pub async fn save_payment_method_api(state,req,auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),pm_id.clone(),))},@@ -1061,6 +1064,7 @@ pub async fn payment_method_update_api(cards::update_customer_payment_method(state,auth.platform.get_provider().clone(),+ auth.platform.get_initiator().cloned(),req,&payment_method_id,None,@@ -1103,7 +1107,7 @@ pub async fn payment_method_delete_api(state: &state,provider: auth.platform.get_provider(),}- .delete_payment_method(req)+ .delete_payment_method(req, auth.platform.get_initiator()).await},&*ephemeral_auth,@@ -1243,6 +1247,7 @@ pub async fn default_payment_method_set_api(auth.platform.get_provider().get_account().get_id(),customer_id,default_payment_method.payment_method_id,+ auth.platform.get_initiator(),).await},@@ -1415,6 +1420,7 @@ pub async fn tokenize_card_api(&state,CardNetworkTokenizeRequest::foreign_from(req),platform.get_provider(),+ platform.get_initiator(),)).await?;Ok(services::ApplicationResponse::Json(res))@@ -1465,6 +1471,7 @@ pub async fn tokenize_card_using_pm_api(&state,CardNetworkTokenizeRequest::foreign_from(req),platform.get_provider(),+ platform.get_initiator(),)).await?;Ok(services::ApplicationResponse::Json(res))@@ -1509,6 +1516,7 @@ pub async fn tokenize_card_batch_api(&state,req,platform.get_provider(),+ platform.get_initiator(),)).await}diff --git a/crates/router/src/types/storage/payment_method.rs b/crates/router/src/types/storage/payment_method.rsindex d6adba9456..61d357e38b 100644--- a/crates/router/src/types/storage/payment_method.rs+++ b/crates/router/src/types/storage/payment_method.rs@@ -178,4 +178,5 @@ pub struct PaymentMethodStatusTrackingData {pub prev_status: enums::PaymentMethodStatus,pub curr_status: enums::PaymentMethodStatus,pub merchant_id: common_utils::id_type::MerchantId,+ pub last_modified_by: Option<String>,}diff --git a/crates/router/src/workflows/payment_method_status_update.rs b/crates/router/src/workflows/payment_method_status_update.rsindex 31cd7af890..ebc3dbf0ea 100644--- a/crates/router/src/workflows/payment_method_status_update.rs+++ b/crates/router/src/workflows/payment_method_status_update.rs@@ -31,6 +31,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentMethodStatusUpdateWorkflowlet prev_pm_status = tracking_data.prev_status;let curr_pm_status = tracking_data.curr_status;let merchant_id = tracking_data.merchant_id;+ let last_modified_by = tracking_data.last_modified_by;let key_store = state.store.get_merchant_key_store_by_merchant_id(@@ -59,7 +60,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentMethodStatusUpdateWorkflowlet pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(curr_pm_status),- last_modified_by: None,+ last_modified_by,};let res = dbdiff --git a/crates/storage_impl/src/payment_method.rs b/crates/storage_impl/src/payment_method.rsindex 10e63761e9..0cadb89165 100644--- a/crates/storage_impl/src/payment_method.rs+++ b/crates/storage_impl/src/payment_method.rs@@ -15,6 +15,8 @@ use diesel_models::payment_method::{PaymentMethodUpdate, PaymentMethodUpdateInteuse error_stack::ResultExt;#[cfg(feature = "v1")]use hyperswitch_domain_models::behaviour::ReverseConversion;+#[cfg(feature = "v2")]+use hyperswitch_domain_models::platform::Initiator;use hyperswitch_domain_models::{behaviour::Conversion,merchant_key_store::MerchantKeyStore,@@ -399,9 +401,10 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {&self,key_store: &MerchantKeyStore,payment_method: DomainPaymentMethod,+ initiator: Option<&Initiator>,) -> CustomResult<DomainPaymentMethod, errors::StorageError> {self.router_store- .delete_payment_method(key_store, payment_method)+ .delete_payment_method(key_store, payment_method, initiator).await}@@ -717,6 +720,7 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {&self,key_store: &MerchantKeyStore,payment_method: DomainPaymentMethod,+ initiator: Option<&Initiator>,) -> CustomResult<DomainPaymentMethod, errors::StorageError> {let payment_method = Conversion::convert(payment_method).await@@ -724,7 +728,9 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {let conn = pg_connection_write(self).await?;let payment_method_update = PaymentMethodUpdate::StatusUpdate {status: Some(common_enums::PaymentMethodStatus::Inactive),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};self.call_database(key_store,@@ -1023,10 +1029,13 @@ impl PaymentMethodInterface for MockDb {&self,key_store: &MerchantKeyStore,payment_method: DomainPaymentMethod,+ initiator: Option<&Initiator>,) -> CustomResult<DomainPaymentMethod, errors::StorageError> {let payment_method_update = PaymentMethodUpdate::StatusUpdate {status: Some(common_enums::PaymentMethodStatus::Inactive),- last_modified_by: None,+ last_modified_by: initiator+ .and_then(|initiator| initiator.to_created_by())+ .map(|last_modified_by| last_modified_by.to_string()),};let payment_method_updated = PaymentMethodUpdateInternal::from(payment_method_update).apply_changeset(diff --git a/crates/subscriptions/src/core/subscription_handler.rs b/crates/subscriptions/src/core/subscription_handler.rsindex b323cb7423..befbb32afb 100644--- a/crates/subscriptions/src/core/subscription_handler.rs+++ b/crates/subscriptions/src/core/subscription_handler.rs@@ -118,6 +118,7 @@ impl<'a> SubscriptionHandler<'a> {merchant_connector_id.get_string_repr(),customer.connector_customer.as_ref(),Some(customer_response.connector_customer_id),+ platform.get_initiator(),).await{