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(vsaas): add `created_by` and `last_modified_by` tracking fields to customers and payment_methods tables (#10250)
Sandeep Kumarb54606dd3cc4
diff --git a/crates/common_utils/src/macros.rs b/crates/common_utils/src/macros.rsindex d994815653..27836f236d 100644--- a/crates/common_utils/src/macros.rs+++ b/crates/common_utils/src/macros.rs@@ -587,11 +587,22 @@ macro_rules! impl_enum_str {fn from_str(s: &str) -> Result<Self, Self::Err> {// Check for explicit "Invalid" string firstif s == "Invalid" {+ #[cfg(feature = "logs")]+ router_env::logger::warn!(+ "Failed to parse {} enum from 'Invalid': explicit Invalid variant encountered",+ stringify!($enum_name)+ );return Ok(Self::Invalid);}let Some((tag, associated_data)) = s.split_once($tag_delim) else {// Missing delimiter -> Invalid+ #[cfg(feature = "logs")]+ router_env::logger::warn!(+ "Failed to parse {} enum from '{}': missing delimiter",+ stringify!($enum_name),+ s+ );return Ok(Self::Invalid);};@@ -606,13 +617,29 @@ macro_rules! impl_enum_str {},Err(_) => {// Field parse failure -> Invalid+ #[cfg(feature = "logs")]+ router_env::logger::warn!(+ "Failed to parse {} enum from '{}': field parse failure for variant '{}'",+ stringify!($enum_name),+ s,+ stringify!($variant)+ );Self::Invalid}}}),*// Unknown tag -> Invalid- _ => Self::Invalid,+ _ => {+ #[cfg(feature = "logs")]+ router_env::logger::warn!(+ "Failed to parse {} enum from '{}': unknown variant tag '{}'",+ stringify!($enum_name),+ s,+ tag+ );+ Self::Invalid+ },};Ok(result) // Always Ok because failure modes return Self::Invalid}@@ -688,6 +715,13 @@ macro_rules! impl_enum_str {}}}++ // Implement HasInvalidVariant trait+ impl $crate::types::HasInvalidVariant for $enum_name {+ fn is_invalid(&self) -> bool {+ matches!(self, Self::Invalid)+ }+ }};}diff --git a/crates/common_utils/src/types.rs b/crates/common_utils/src/types.rsindex e5b66cb272..e701eac236 100644--- a/crates/common_utils/src/types.rs+++ b/crates/common_utils/src/types.rs@@ -1442,6 +1442,13 @@ impl_enum_str!(});+/// Trait for enums created with `impl_enum_str!` macro that have an `Invalid` variant.+/// This trait allows generic functions to check if a parsed enum value is invalid.+pub trait HasInvalidVariant {+ /// Returns true if this instance is the `Invalid` variant+ fn is_invalid(&self) -> bool;+}+#[allow(missing_docs)]pub trait TenantConfig: Send + Sync {fn get_tenant_id(&self) -> &id_type::TenantId;diff --git a/crates/diesel_models/src/customers.rs b/crates/diesel_models/src/customers.rsindex d8c95ecd10..2f704b6db7 100644--- a/crates/diesel_models/src/customers.rs+++ b/crates/diesel_models/src/customers.rs@@ -31,6 +31,8 @@ pub struct CustomerNew {pub updated_by: Option<String>,pub version: ApiVersion,pub tax_registration_id: Option<Encryption>,+ pub created_by: Option<String>,+ pub last_modified_by: Option<String>,}#[cfg(feature = "v1")]@@ -60,6 +62,8 @@ impl From<CustomerNew> for Customer {updated_by: customer_new.updated_by,version: customer_new.version,tax_registration_id: customer_new.tax_registration_id,+ created_by: customer_new.created_by,+ last_modified_by: customer_new.last_modified_by,}}}@@ -89,6 +93,8 @@ pub struct CustomerNew {pub default_shipping_address: Option<Encryption>,pub status: DeleteStatus,pub id: common_utils::id_type::GlobalCustomerId,+ pub created_by: Option<String>,+ pub last_modified_by: Option<String>,}#[cfg(feature = "v2")]@@ -121,6 +127,8 @@ impl From<CustomerNew> for Customer {id: customer_new.id,version: customer_new.version,status: customer_new.status,+ created_by: customer_new.created_by,+ last_modified_by: customer_new.last_modified_by,}}}@@ -147,6 +155,8 @@ pub struct Customer {pub updated_by: Option<String>,pub version: ApiVersion,pub tax_registration_id: Option<Encryption>,+ pub created_by: Option<String>,+ pub last_modified_by: Option<String>,}#[cfg(feature = "v2")]@@ -169,6 +179,8 @@ pub struct Customer {pub updated_by: Option<String>,pub version: ApiVersion,pub tax_registration_id: Option<Encryption>,+ pub created_by: Option<String>,+ pub last_modified_by: Option<String>,pub merchant_reference_id: Option<common_utils::id_type::CustomerId>,pub default_billing_address: Option<Encryption>,pub default_shipping_address: Option<Encryption>,@@ -195,6 +207,7 @@ pub struct CustomerUpdateInternal {pub default_payment_method_id: Option<Option<String>>,pub updated_by: Option<String>,pub tax_registration_id: Option<Encryption>,+ pub last_modified_by: Option<String>,}#[cfg(feature = "v1")]@@ -211,6 +224,7 @@ impl CustomerUpdateInternal {address_id,default_payment_method_id,tax_registration_id,+ last_modified_by,..} = self;@@ -228,6 +242,7 @@ impl CustomerUpdateInternal {.flatten().map_or(source.default_payment_method_id, Some),tax_registration_id: tax_registration_id.map_or(source.tax_registration_id, Some),+ last_modified_by: last_modified_by.or(source.last_modified_by),..source}}@@ -253,6 +268,7 @@ pub struct CustomerUpdateInternal {pub default_shipping_address: Option<Encryption>,pub status: Option<DeleteStatus>,pub tax_registration_id: Option<Encryption>,+ pub last_modified_by: Option<String>,}#[cfg(feature = "v2")]@@ -271,6 +287,7 @@ impl CustomerUpdateInternal {default_shipping_address,status,tax_registration_id,+ last_modified_by,..} = self;@@ -292,6 +309,7 @@ impl CustomerUpdateInternal {.map_or(source.default_shipping_address, Some),status: status.unwrap_or(source.status),tax_registration_id: tax_registration_id.map_or(source.tax_registration_id, Some),+ last_modified_by: last_modified_by.or(source.last_modified_by),..source}}diff --git a/crates/diesel_models/src/kv.rs b/crates/diesel_models/src/kv.rsindex ed984649e9..ea3c0e0dcb 100644--- a/crates/diesel_models/src/kv.rs+++ b/crates/diesel_models/src/kv.rs@@ -215,7 +215,7 @@ pub enum Insertable {ReverseLookUp(ReverseLookupNew),Payouts(PayoutsNew),PayoutAttempt(PayoutAttemptNew),- PaymentMethod(PaymentMethodNew),+ PaymentMethod(Box<PaymentMethodNew>),Mandate(MandateNew),}diff --git a/crates/diesel_models/src/payment_method.rs b/crates/diesel_models/src/payment_method.rsindex edadeea799..fb90059ccc 100644--- a/crates/diesel_models/src/payment_method.rs+++ b/crates/diesel_models/src/payment_method.rs@@ -62,6 +62,8 @@ pub struct PaymentMethod {pub network_token_payment_method_data: Option<Encryption>,pub external_vault_source: Option<common_utils::id_type::MerchantConnectorAccountId>,pub vault_type: Option<storage_enums::VaultType>,+ pub created_by: Option<String>,+ pub last_modified_by: Option<String>,}#[cfg(feature = "v2")]@@ -88,6 +90,8 @@ pub struct PaymentMethod {pub network_token_payment_method_data: Option<Encryption>,pub external_vault_source: Option<common_utils::id_type::MerchantConnectorAccountId>,pub vault_type: Option<storage_enums::VaultType>,+ pub created_by: Option<String>,+ pub last_modified_by: Option<String>,pub locker_fingerprint_id: Option<String>,pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,@@ -149,6 +153,8 @@ pub struct PaymentMethodNew {pub network_token_payment_method_data: Option<Encryption>,pub external_vault_source: Option<common_utils::id_type::MerchantConnectorAccountId>,pub vault_type: Option<storage_enums::VaultType>,+ pub created_by: Option<String>,+ pub last_modified_by: Option<String>,}#[cfg(feature = "v2")]@@ -179,6 +185,8 @@ pub struct PaymentMethodNew {pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,pub id: common_utils::id_type::GlobalPaymentMethodId,pub vault_type: Option<storage_enums::VaultType>,+ pub created_by: Option<String>,+ pub last_modified_by: Option<String>,}impl PaymentMethodNew {@@ -209,14 +217,17 @@ pub enum PaymentMethodUpdate {MetadataUpdateAndLastUsed {metadata: Option<serde_json::Value>,last_used_at: PrimitiveDateTime,+ last_modified_by: Option<String>,},UpdatePaymentMethodDataAndLastUsed {payment_method_data: Option<Encryption>,scheme: Option<String>,last_used_at: PrimitiveDateTime,+ last_modified_by: Option<String>,},PaymentMethodDataUpdate {payment_method_data: Option<Encryption>,+ last_modified_by: Option<String>,},LastUsedUpdate {last_used_at: PrimitiveDateTime,@@ -224,9 +235,11 @@ pub enum PaymentMethodUpdate {NetworkTransactionIdAndStatusUpdate {network_transaction_id: Option<String>,status: Option<storage_enums::PaymentMethodStatus>,+ last_modified_by: Option<String>,},StatusUpdate {status: Option<storage_enums::PaymentMethodStatus>,+ last_modified_by: Option<String>,},AdditionalDataUpdate {payment_method_data: Option<Encryption>,@@ -238,24 +251,29 @@ pub enum PaymentMethodUpdate {network_token_requestor_reference_id: Option<String>,network_token_locker_id: Option<String>,network_token_payment_method_data: Option<Encryption>,+ last_modified_by: Option<String>,},ConnectorMandateDetailsUpdate {connector_mandate_details: Option<serde_json::Value>,+ last_modified_by: Option<String>,},NetworkTokenDataUpdate {network_token_requestor_reference_id: Option<String>,network_token_locker_id: Option<String>,network_token_payment_method_data: Option<Encryption>,+ last_modified_by: Option<String>,},ConnectorNetworkTransactionIdAndMandateDetailsUpdate {connector_mandate_details: Option<pii::SecretSerdeValue>,network_transaction_id: Option<Secret<String>>,+ last_modified_by: Option<String>,},PaymentMethodBatchUpdate {connector_mandate_details: Option<pii::SecretSerdeValue>,network_transaction_id: Option<String>,status: Option<storage_enums::PaymentMethodStatus>,payment_method_data: Option<Encryption>,+ last_modified_by: Option<String>,},}@@ -266,9 +284,11 @@ pub enum PaymentMethodUpdate {payment_method_data: Option<Encryption>,scheme: Option<String>,last_used_at: PrimitiveDateTime,+ last_modified_by: Option<String>,},PaymentMethodDataUpdate {payment_method_data: Option<Encryption>,+ last_modified_by: Option<String>,},LastUsedUpdate {last_used_at: PrimitiveDateTime,@@ -276,9 +296,11 @@ pub enum PaymentMethodUpdate {NetworkTransactionIdAndStatusUpdate {network_transaction_id: Option<String>,status: Option<storage_enums::PaymentMethodStatus>,+ last_modified_by: Option<String>,},StatusUpdate {status: Option<storage_enums::PaymentMethodStatus>,+ last_modified_by: Option<String>,},GenericUpdate {payment_method_data: Option<Encryption>,@@ -292,9 +314,11 @@ pub enum PaymentMethodUpdate {locker_fingerprint_id: Option<String>,connector_mandate_details: Option<CommonMandateReference>,external_vault_source: Option<common_utils::id_type::MerchantConnectorAccountId>,+ last_modified_by: Option<String>,},ConnectorMandateDetailsUpdate {connector_mandate_details: Option<CommonMandateReference>,+ last_modified_by: Option<String>,},}@@ -328,6 +352,7 @@ pub struct PaymentMethodUpdateInternal {network_token_payment_method_data: Option<Encryption>,locker_fingerprint_id: Option<String>,external_vault_source: Option<common_utils::id_type::MerchantConnectorAccountId>,+ last_modified_by: Option<String>,}#[cfg(feature = "v2")]@@ -349,6 +374,7 @@ impl PaymentMethodUpdateInternal {network_token_payment_method_data,locker_fingerprint_id,external_vault_source,+ last_modified_by,} = self;PaymentMethod {@@ -380,6 +406,8 @@ impl PaymentMethodUpdateInternal {external_vault_source: external_vault_source.or(source.external_vault_source),external_vault_token_data: source.external_vault_token_data,vault_type: source.vault_type,+ created_by: source.created_by,+ last_modified_by: last_modified_by.or(source.last_modified_by),}}}@@ -404,6 +432,7 @@ pub struct PaymentMethodUpdateInternal {network_token_locker_id: Option<String>,network_token_payment_method_data: Option<Encryption>,scheme: Option<String>,+ last_modified_by: Option<String>,}#[cfg(feature = "v1")]@@ -426,6 +455,7 @@ impl PaymentMethodUpdateInternal {network_token_locker_id,network_token_payment_method_data,scheme,+ last_modified_by,} = self;PaymentMethod {@@ -468,6 +498,8 @@ impl PaymentMethodUpdateInternal {.or(source.network_token_payment_method_data),external_vault_source: source.external_vault_source,vault_type: source.vault_type,+ created_by: source.created_by,+ last_modified_by: last_modified_by.or(source.last_modified_by),}}}@@ -479,6 +511,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {PaymentMethodUpdate::MetadataUpdateAndLastUsed {metadata,last_used_at,+ last_modified_by,} => Self {metadata,payment_method_data: None,@@ -496,9 +529,11 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id: None,network_token_payment_method_data: None,scheme: None,+ last_modified_by,},PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data,+ last_modified_by,} => Self {metadata: None,payment_method_data,@@ -516,6 +551,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id: None,network_token_payment_method_data: None,scheme: None,+ last_modified_by,},PaymentMethodUpdate::LastUsedUpdate { last_used_at } => Self {metadata: None,@@ -534,11 +570,13 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id: None,network_token_payment_method_data: None,scheme: None,+ last_modified_by: None,},PaymentMethodUpdate::UpdatePaymentMethodDataAndLastUsed {payment_method_data,scheme,last_used_at,+ last_modified_by,} => Self {metadata: None,payment_method_data,@@ -556,10 +594,12 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id: None,network_token_payment_method_data: None,scheme,+ last_modified_by,},PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,status,+ last_modified_by,} => Self {metadata: None,payment_method_data: None,@@ -577,8 +617,12 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id: None,network_token_payment_method_data: None,scheme: None,+ last_modified_by,},- PaymentMethodUpdate::StatusUpdate { status } => Self {+ PaymentMethodUpdate::StatusUpdate {+ status,+ last_modified_by,+ } => Self {metadata: None,payment_method_data: None,last_used_at: None,@@ -595,6 +639,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id: None,network_token_payment_method_data: None,scheme: None,+ last_modified_by,},PaymentMethodUpdate::AdditionalDataUpdate {payment_method_data,@@ -606,6 +651,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {payment_method_issuer,network_token_locker_id,network_token_payment_method_data,+ last_modified_by,} => Self {metadata: None,payment_method_data,@@ -623,9 +669,11 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id,network_token_payment_method_data,scheme: None,+ last_modified_by,},PaymentMethodUpdate::ConnectorMandateDetailsUpdate {connector_mandate_details,+ last_modified_by,} => Self {metadata: None,payment_method_data: None,@@ -643,11 +691,13 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id: None,network_token_payment_method_data: None,scheme: None,+ last_modified_by,},PaymentMethodUpdate::NetworkTokenDataUpdate {network_token_requestor_reference_id,network_token_locker_id,network_token_payment_method_data,+ last_modified_by,} => Self {metadata: None,payment_method_data: None,@@ -665,10 +715,12 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id,network_token_payment_method_data,scheme: None,+ last_modified_by,},PaymentMethodUpdate::ConnectorNetworkTransactionIdAndMandateDetailsUpdate {connector_mandate_details,network_transaction_id,+ last_modified_by,} => Self {connector_mandate_details: connector_mandate_details.map(|mandate_details| mandate_details.expose()),@@ -687,12 +739,14 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_locker_id: None,network_token_payment_method_data: None,scheme: None,+ last_modified_by,},PaymentMethodUpdate::PaymentMethodBatchUpdate {connector_mandate_details,network_transaction_id,status,payment_method_data,+ last_modified_by,} => Self {metadata: None,last_used_at: None,@@ -711,6 +765,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data: None,scheme: None,payment_method_data,+ last_modified_by,},}}@@ -722,6 +777,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {match payment_method_update {PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data,+ last_modified_by,} => Self {payment_method_data,last_used_at: None,@@ -738,6 +794,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data: None,locker_fingerprint_id: None,external_vault_source: None,+ last_modified_by,},PaymentMethodUpdate::LastUsedUpdate { last_used_at } => Self {payment_method_data: None,@@ -755,10 +812,12 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data: None,locker_fingerprint_id: None,external_vault_source: None,+ last_modified_by: None,},PaymentMethodUpdate::UpdatePaymentMethodDataAndLastUsed {payment_method_data,last_used_at,+ last_modified_by,..} => Self {payment_method_data,@@ -776,10 +835,12 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data: None,locker_fingerprint_id: None,external_vault_source: None,+ last_modified_by,},PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,status,+ last_modified_by,} => Self {payment_method_data: None,last_used_at: None,@@ -796,8 +857,12 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data: None,locker_fingerprint_id: None,external_vault_source: None,+ last_modified_by,},- PaymentMethodUpdate::StatusUpdate { status } => Self {+ PaymentMethodUpdate::StatusUpdate {+ status,+ last_modified_by,+ } => Self {payment_method_data: None,last_used_at: None,network_transaction_id: None,@@ -813,6 +878,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data: None,locker_fingerprint_id: None,external_vault_source: None,+ last_modified_by,},PaymentMethodUpdate::GenericUpdate {payment_method_data,@@ -826,6 +892,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {locker_fingerprint_id,connector_mandate_details,external_vault_source,+ last_modified_by,} => Self {payment_method_data,last_used_at: None,@@ -842,9 +909,11 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data,locker_fingerprint_id,external_vault_source,+ last_modified_by,},PaymentMethodUpdate::ConnectorMandateDetailsUpdate {connector_mandate_details,+ last_modified_by,} => Self {payment_method_data: None,last_used_at: None,@@ -861,6 +930,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data: None,locker_fingerprint_id: None,external_vault_source: None,+ last_modified_by,},}}@@ -912,6 +982,8 @@ impl From<&PaymentMethodNew> for PaymentMethod {.clone(),external_vault_source: payment_method_new.external_vault_source.clone(),vault_type: payment_method_new.vault_type,+ created_by: payment_method_new.created_by.clone(),+ last_modified_by: payment_method_new.last_modified_by.clone(),}}}@@ -951,6 +1023,8 @@ impl From<&PaymentMethodNew> for PaymentMethod {external_vault_source: None,external_vault_token_data: payment_method_new.external_vault_token_data.clone(),vault_type: payment_method_new.vault_type,+ created_by: payment_method_new.created_by.clone(),+ last_modified_by: payment_method_new.last_modified_by.clone(),}}}diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 79b9e8502f..7fb1e05726 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -383,6 +383,10 @@ diesel::table! {updated_by -> Nullable<Varchar>,version -> ApiVersion,tax_registration_id -> Nullable<Bytea>,+ #[max_length = 255]+ created_by -> Nullable<Varchar>,+ #[max_length = 255]+ last_modified_by -> Nullable<Varchar>,}}@@ -1296,6 +1300,10 @@ diesel::table! {external_vault_source -> Nullable<Varchar>,#[max_length = 64]vault_type -> Nullable<Varchar>,+ #[max_length = 255]+ created_by -> Nullable<Varchar>,+ #[max_length = 255]+ last_modified_by -> Nullable<Varchar>,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex acdcf5ea5c..0459fbc619 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -388,6 +388,10 @@ diesel::table! {updated_by -> Nullable<Varchar>,version -> ApiVersion,tax_registration_id -> Nullable<Bytea>,+ #[max_length = 255]+ created_by -> Nullable<Varchar>,+ #[max_length = 255]+ last_modified_by -> Nullable<Varchar>,#[max_length = 64]merchant_reference_id -> Nullable<Varchar>,default_billing_address -> Nullable<Bytea>,@@ -1231,6 +1235,10 @@ diesel::table! {external_vault_source -> Nullable<Varchar>,#[max_length = 64]vault_type -> Nullable<Varchar>,+ #[max_length = 255]+ created_by -> Nullable<Varchar>,+ #[max_length = 255]+ last_modified_by -> Nullable<Varchar>,#[max_length = 64]locker_fingerprint_id -> Nullable<Varchar>,#[max_length = 64]diff --git a/crates/hyperswitch_domain_models/src/customer.rs b/crates/hyperswitch_domain_models/src/customer.rsindex d440a2d5da..42ad0da4ea 100644--- a/crates/hyperswitch_domain_models/src/customer.rs+++ b/crates/hyperswitch_domain_models/src/customer.rs@@ -10,7 +10,7 @@ use common_utils::{id_type, pii,types::{keymanager::{self, KeyManagerState, ToEncryptable},- Description,+ CreatedBy, Description,},};use diesel_models::{@@ -49,6 +49,8 @@ pub struct Customer {pub version: common_enums::ApiVersion,#[encrypt]pub tax_registration_id: Option<Encryptable<Secret<String>>>,+ pub created_by: Option<CreatedBy>,+ pub last_modified_by: Option<CreatedBy>,}#[cfg(feature = "v2")]@@ -77,6 +79,8 @@ pub struct Customer {pub status: DeleteStatus,#[encrypt]pub tax_registration_id: Option<Encryptable<Secret<String>>>,+ pub created_by: Option<CreatedBy>,+ pub last_modified_by: Option<CreatedBy>,}impl Customer {@@ -164,6 +168,10 @@ impl behaviour::Conversion for Customer {updated_by: self.updated_by,version: self.version,tax_registration_id: self.tax_registration_id.map(Encryption::from),+ created_by: self.created_by.map(|created_by| created_by.to_string()),+ last_modified_by: self+ .last_modified_by+ .map(|last_modified_by| last_modified_by.to_string()),})}@@ -224,6 +232,12 @@ impl behaviour::Conversion for Customer {updated_by: item.updated_by,version: item.version,tax_registration_id: encryptable_customer.tax_registration_id,+ created_by: item+ .created_by+ .and_then(|created_by| created_by.parse::<CreatedBy>().ok()),+ last_modified_by: item+ .last_modified_by+ .and_then(|last_modified_by| last_modified_by.parse::<CreatedBy>().ok()),})}@@ -245,6 +259,11 @@ impl behaviour::Conversion for Customer {updated_by: self.updated_by,version: self.version,tax_registration_id: self.tax_registration_id.map(Encryption::from),+ created_by: self+ .created_by+ .as_ref()+ .map(|created_by| created_by.to_string()),+ last_modified_by: self.created_by.map(|created_by| created_by.to_string()), // Same as created_by on creation})}}@@ -275,6 +294,10 @@ impl behaviour::Conversion for Customer {version: self.version,status: self.status,tax_registration_id: self.tax_registration_id.map(Encryption::from),+ created_by: self.created_by.map(|created_by| created_by.to_string()),+ last_modified_by: self+ .last_modified_by+ .map(|last_modified_by| last_modified_by.to_string()),})}@@ -338,6 +361,12 @@ impl behaviour::Conversion for Customer {version: item.version,status: item.status,tax_registration_id: encryptable_customer.tax_registration_id,+ created_by: item+ .created_by+ .and_then(|created_by| created_by.parse::<CreatedBy>().ok()),+ last_modified_by: item+ .last_modified_by+ .and_then(|last_modified_by| last_modified_by.parse::<CreatedBy>().ok()),})}@@ -363,6 +392,11 @@ impl behaviour::Conversion for Customer {version: common_types::consts::API_VERSION,status: self.status,tax_registration_id: self.tax_registration_id.map(Encryption::from),+ created_by: self+ .created_by+ .as_ref()+ .map(|created_by| created_by.to_string()),+ last_modified_by: self.created_by.map(|created_by| created_by.to_string()), // Same as created_by on creation})}}@@ -382,6 +416,7 @@ pub struct CustomerGeneralUpdate {pub default_payment_method_id: Option<Option<id_type::GlobalPaymentMethodId>>,pub status: Option<DeleteStatus>,pub tax_registration_id: crypto::OptionalEncryptableSecretString,+ pub last_modified_by: Option<String>,}#[cfg(feature = "v2")]@@ -390,9 +425,11 @@ pub enum CustomerUpdate {Update(Box<CustomerGeneralUpdate>),ConnectorCustomer {connector_customer: Option<common_types::customers::ConnectorCustomerMap>,+ last_modified_by: Option<String>,},UpdateDefaultPaymentMethod {default_payment_method_id: Option<Option<id_type::GlobalPaymentMethodId>>,+ last_modified_by: Option<String>,},}@@ -414,6 +451,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {default_payment_method_id,status,tax_registration_id,+ last_modified_by,} = *update;Self {name: name.map(Encryption::from),@@ -430,9 +468,13 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {updated_by: None,status,tax_registration_id: tax_registration_id.map(Encryption::from),+ last_modified_by,}}- CustomerUpdate::ConnectorCustomer { connector_customer } => Self {+ CustomerUpdate::ConnectorCustomer {+ connector_customer,+ last_modified_by,+ } => Self {connector_customer,name: None,email: None,@@ -447,9 +489,11 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {default_shipping_address: None,status: None,tax_registration_id: None,+ last_modified_by,},CustomerUpdate::UpdateDefaultPaymentMethod {default_payment_method_id,+ last_modified_by,} => Self {default_payment_method_id,modified_at: date_time::now(),@@ -465,6 +509,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {default_shipping_address: None,status: None,tax_registration_id: None,+ last_modified_by,},}}@@ -483,12 +528,15 @@ pub enum CustomerUpdate {connector_customer: Box<Option<pii::SecretSerdeValue>>,address_id: Option<String>,tax_registration_id: crypto::OptionalEncryptableSecretString,+ last_modified_by: Option<String>,},ConnectorCustomer {connector_customer: Option<pii::SecretSerdeValue>,+ last_modified_by: Option<String>,},UpdateDefaultPaymentMethod {default_payment_method_id: Option<Option<String>>,+ last_modified_by: Option<String>,},}@@ -506,6 +554,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {connector_customer,address_id,tax_registration_id,+ last_modified_by,} => Self {name: name.map(Encryption::from),email: email.map(Encryption::from),@@ -519,8 +568,12 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {default_payment_method_id: None,updated_by: None,tax_registration_id: tax_registration_id.map(Encryption::from),+ last_modified_by,},- CustomerUpdate::ConnectorCustomer { connector_customer } => Self {+ CustomerUpdate::ConnectorCustomer {+ connector_customer,+ last_modified_by,+ } => Self {connector_customer,modified_at: date_time::now(),name: None,@@ -533,9 +586,11 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {updated_by: None,address_id: None,tax_registration_id: None,+ last_modified_by,},CustomerUpdate::UpdateDefaultPaymentMethod {default_payment_method_id,+ last_modified_by,} => Self {default_payment_method_id,modified_at: date_time::now(),@@ -549,6 +604,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {updated_by: None,address_id: None,tax_registration_id: None,+ last_modified_by,},}}@@ -720,6 +776,7 @@ 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,},)}@@ -741,6 +798,7 @@ 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,}})}diff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rsindex 2a786616fa..bf11615bde 100644--- a/crates/hyperswitch_domain_models/src/payment_methods.rs+++ b/crates/hyperswitch_domain_models/src/payment_methods.rs@@ -13,7 +13,7 @@ use common_utils::{crypto::Encryptable, encryption::Encryption, types::keymanageuse common_utils::{errors::{CustomResult, ParsingError, ValidationError},id_type, pii, type_name,- types::keymanager,+ types::{keymanager, CreatedBy},};pub use diesel_models::{enums as storage_enums, PaymentMethodUpdate};use error_stack::ResultExt;@@ -90,6 +90,8 @@ pub struct PaymentMethod {pub network_token_locker_id: Option<String>,pub network_token_payment_method_data: OptionalEncryptableValue,pub vault_source_details: PaymentMethodVaultSourceDetails,+ pub created_by: Option<CreatedBy>,+ pub last_modified_by: Option<CreatedBy>,}#[cfg(feature = "v2")]@@ -132,6 +134,8 @@ pub struct PaymentMethod {pub external_vault_token_data:Option<Encryptable<api_models::payment_methods::ExternalVaultTokenData>>,pub vault_type: Option<storage_enums::VaultType>,+ pub created_by: Option<CreatedBy>,+ pub last_modified_by: Option<CreatedBy>,}impl PaymentMethod {@@ -305,6 +309,10 @@ impl super::behaviour::Conversion for PaymentMethod {.map(|val| val.into()),external_vault_source,vault_type,+ created_by: self.created_by.map(|created_by| created_by.to_string()),+ last_modified_by: self+ .last_modified_by+ .map(|last_modified_by| last_modified_by.to_string()),})}@@ -421,6 +429,12 @@ impl super::behaviour::Conversion for PaymentMethod {network_token_locker_id: item.network_token_locker_id,network_token_payment_method_data,vault_source_details,+ created_by: item+ .created_by+ .and_then(|created_by| created_by.parse::<CreatedBy>().ok()),+ last_modified_by: item+ .last_modified_by+ .and_then(|last_modified_by| last_modified_by.parse::<CreatedBy>().ok()),})}@@ -467,6 +481,10 @@ impl super::behaviour::Conversion for PaymentMethod {.map(|val| val.into()),external_vault_source,vault_type,+ created_by: self.created_by.map(|created_by| created_by.to_string()),+ last_modified_by: self+ .last_modified_by+ .map(|last_modified_by| last_modified_by.to_string()),})}}@@ -507,6 +525,10 @@ impl super::behaviour::Conversion for PaymentMethod {external_vault_source: self.external_vault_source,external_vault_token_data: self.external_vault_token_data.map(|val| val.into()),vault_type: self.vault_type,+ created_by: self.created_by.map(|created_by| created_by.to_string()),+ last_modified_by: self+ .last_modified_by+ .map(|last_modified_by| last_modified_by.to_string()),})}@@ -613,6 +635,12 @@ impl super::behaviour::Conversion for PaymentMethod {external_vault_source: storage_model.external_vault_source,external_vault_token_data,vault_type: storage_model.vault_type,+ created_by: storage_model+ .created_by+ .and_then(|created_by| created_by.parse::<CreatedBy>().ok()),+ last_modified_by: storage_model+ .last_modified_by+ .and_then(|last_modified_by| last_modified_by.parse::<CreatedBy>().ok()),})}.await@@ -651,6 +679,10 @@ impl super::behaviour::Conversion for PaymentMethod {.map(|val| val.into()),external_vault_token_data: self.external_vault_token_data.map(|val| val.into()),vault_type: self.vault_type,+ created_by: self.created_by.map(|created_by| created_by.to_string()),+ last_modified_by: self+ .last_modified_by+ .map(|last_modified_by| last_modified_by.to_string()),})}}@@ -1289,6 +1321,8 @@ mod tests {network_token_locker_id: None,network_token_payment_method_data: None,vault_source_details: Default::default(),+ created_by: None,+ last_modified_by: None,};payment_method.clone()}diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex c89109d649..3180b1ce62 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -605,7 +605,7 @@ pub struct PaymentIntent {pub force_3ds_challenge_trigger: Option<bool>,/// merchant who owns the credentials of the processor, i.e. processor ownerpub processor_merchant_id: id_type::MerchantId,- /// merchantwho invoked the resource based api (identifier) and through what source (Api, Jwt(Dashboard))+ /// merchant or user who invoked the resource-based API (identifier) and the source (Api, Jwt(Dashboard))pub created_by: Option<CreatedBy>,/// Indicates if the redirection has to open in the iframediff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex ba4c8fe73b..89956c3f8f 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -489,7 +489,7 @@ pub struct PaymentAttempt {pub feature_metadata: Option<PaymentAttemptFeatureMetadata>,/// merchant who owns the credentials of the processor, i.e. processor ownerpub processor_merchant_id: id_type::MerchantId,- /// merchantwho invoked the resource based api (identifier) and through what source (Api, Jwt(Dashboard))+ /// merchant or user who invoked the resource-based API (identifier) and the source (Api, Jwt(Dashboard))pub created_by: Option<CreatedBy>,pub connector_request_reference_id: Option<String>,pub network_transaction_id: Option<String>,@@ -1037,7 +1037,7 @@ pub struct PaymentAttempt {pub issuer_error_message: Option<String>,/// merchant who owns the credentials of the processor, i.e. processor ownerpub processor_merchant_id: id_type::MerchantId,- /// merchantwho invoked the resource based api (identifier) and through what source (Api, Jwt(Dashboard))+ /// merchant or user who invoked the resource-based API (identifier) and the source (Api, Jwt(Dashboard))pub created_by: Option<CreatedBy>,pub setup_future_usage_applied: Option<storage_enums::FutureUsage>,pub routing_approach: Option<storage_enums::RoutingApproach>,@@ -1354,7 +1354,7 @@ pub struct PaymentAttemptNew {pub card_discovery: Option<common_enums::CardDiscovery>,/// merchant who owns the credentials of the processor, i.e. processor ownerpub processor_merchant_id: id_type::MerchantId,- /// merchantwho invoked the resource based api (identifier) and through what source (Api, Jwt(Dashboard))+ /// merchant or user who invoked the resource-based API (identifier) and the source (Api, Jwt(Dashboard))pub created_by: Option<CreatedBy>,pub setup_future_usage_applied: Option<storage_enums::FutureUsage>,pub routing_approach: Option<storage_enums::RoutingApproach>,@@ -2226,7 +2226,7 @@ impl behaviour::Conversion for PaymentAttempt {// Below fields are deprecated. Please add any new fields above this line.connector_transaction_data: None,processor_merchant_id: Some(self.processor_merchant_id),- created_by: self.created_by.map(|cb| cb.to_string()),+ created_by: self.created_by.map(|created_by| created_by.to_string()),routing_approach: self.routing_approach,connector_request_reference_id: self.connector_request_reference_id,network_transaction_id: self.network_transaction_id,@@ -2428,7 +2428,7 @@ impl behaviour::Conversion for PaymentAttempt {capture_before: self.capture_before,card_discovery: self.card_discovery,processor_merchant_id: Some(self.processor_merchant_id),- created_by: self.created_by.map(|cb| cb.to_string()),+ created_by: self.created_by.map(|created_by| created_by.to_string()),setup_future_usage_applied: self.setup_future_usage_applied,routing_approach: self.routing_approach,connector_request_reference_id: self.connector_request_reference_id,@@ -2605,7 +2605,7 @@ impl behaviour::Conversion for PaymentAttempt {.as_ref().and_then(|details| details.network_error_message.clone()),processor_merchant_id: Some(processor_merchant_id),- created_by: created_by.map(|cb| cb.to_string()),+ created_by: created_by.map(|created_by| created_by.to_string()),connector_request_reference_id,network_transaction_id,is_overcapture_enabled: None,@@ -2894,7 +2894,7 @@ impl behaviour::Conversion for PaymentAttempt {.as_ref().and_then(|details| details.network_error_message.clone()),processor_merchant_id: Some(processor_merchant_id),- created_by: created_by.map(|cb| cb.to_string()),+ created_by: created_by.map(|created_by| created_by.to_string()),connector_request_reference_id,network_details: None,tokenization: None,diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex c808560fb7..eb1b09c1e3 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -1970,7 +1970,7 @@ impl behaviour::Conversion for PaymentIntent {force_3ds_challenge,force_3ds_challenge_trigger,processor_merchant_id: Some(processor_merchant_id),- created_by: created_by.map(|cb| cb.to_string()),+ created_by: created_by.map(|created_by| created_by.to_string()),is_iframe_redirection_enabled,is_payment_id_from_merchant,payment_channel: None,@@ -2229,7 +2229,7 @@ impl behaviour::Conversion for PaymentIntent {force_3ds_challenge: self.force_3ds_challenge,force_3ds_challenge_trigger: self.force_3ds_challenge_trigger,processor_merchant_id: Some(self.processor_merchant_id),- created_by: self.created_by.map(|cb| cb.to_string()),+ created_by: self.created_by.map(|created_by| created_by.to_string()),is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,routing_algorithm_id: self.routing_algorithm_id,is_payment_id_from_merchant: self.is_payment_id_from_merchant,@@ -2311,7 +2311,7 @@ impl behaviour::Conversion for PaymentIntent {psd2_sca_exemption_type: self.psd2_sca_exemption_type,platform_merchant_id: None,processor_merchant_id: Some(self.processor_merchant_id),- created_by: self.created_by.map(|cb| cb.to_string()),+ created_by: self.created_by.map(|created_by| created_by.to_string()),force_3ds_challenge: self.force_3ds_challenge,force_3ds_challenge_trigger: self.force_3ds_challenge_trigger,is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,@@ -2507,7 +2507,7 @@ impl behaviour::Conversion for PaymentIntent {psd2_sca_exemption_type: self.psd2_sca_exemption_type,platform_merchant_id: None,processor_merchant_id: Some(self.processor_merchant_id),- created_by: self.created_by.map(|cb| cb.to_string()),+ created_by: self.created_by.map(|created_by| created_by.to_string()),force_3ds_challenge: self.force_3ds_challenge,force_3ds_challenge_trigger: self.force_3ds_challenge_trigger,is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,diff --git a/crates/payment_methods/src/core/migration/payment_methods.rs b/crates/payment_methods/src/core/migration/payment_methods.rsindex 086dccbc2f..92f72445ba 100644--- a/crates/payment_methods/src/core/migration/payment_methods.rs+++ b/crates/payment_methods/src/core/migration/payment_methods.rs@@ -617,6 +617,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,},merchant_context.get_merchant_account().storage_scheme,)diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rsindex 162afd38e6..a4818e1b6b 100644--- a/crates/router/src/core/customers.rs+++ b/crates/router/src/core/customers.rs@@ -218,6 +218,9 @@ impl CustomerCreateBridge for customers::CustomerRequest {updated_by: None,version: common_types::consts::API_VERSION,tax_registration_id: encryptable_customer.tax_registration_id,+ // TODO: Populate created_by from authentication context once it is integrated in auth data+ created_by: None,+ last_modified_by: None,})}@@ -349,6 +352,9 @@ impl CustomerCreateBridge for customers::CustomerRequest {version: common_types::consts::API_VERSION,status: common_enums::DeleteStatus::Active,tax_registration_id: encryptable_customer.tax_registration_id,+ // TODO: Populate created_by from authentication context once it is integrated in auth data+ created_by: None,+ last_modified_by: None,})}@@ -808,6 +814,7 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {default_payment_method_id: None,status: Some(common_enums::DeleteStatus::Redacted),tax_registration_id: Some(redacted_encrypted_value),+ last_modified_by: None,}));db.update_customer_by_global_id(@@ -1059,6 +1066,7 @@ impl CustomerDeleteBridge for id_type::CustomerId {connector_customer: Box::new(None),address_id: None,tax_registration_id: Some(redacted_encrypted_value.clone()),+ last_modified_by: None,};db.update_customer_by_customer_id_merchant_id(@@ -1390,6 +1398,7 @@ 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,},merchant_context.get_merchant_key_store(),merchant_context.get_merchant_account().storage_scheme,@@ -1516,6 +1525,7 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {default_shipping_address: encrypted_customer_shipping_address.map(Into::into),default_payment_method_id: Some(self.default_payment_method_id.clone()),status: None,+ last_modified_by: None,})),merchant_context.get_merchant_key_store(),merchant_context.get_merchant_account().storage_scheme,diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex a7f1e1320a..20911af0ed 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -1076,6 +1076,7 @@ pub async fn create_payment_method_card_core(Err(e) => {let pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(enums::PaymentMethodStatus::Inactive),+ last_modified_by: None,};db.update_payment_method(@@ -1963,6 +1964,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,},storage_scheme,)@@ -2029,6 +2032,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,},storage_scheme,)@@ -2238,6 +2243,7 @@ pub async fn create_pm_additional_data_update(connector_mandate_details: connector_mandate_details_update,locker_fingerprint_id: vault_fingerprint_id,external_vault_source,+ last_modified_by: None,};Ok(pm_update)@@ -2816,6 +2822,7 @@ pub async fn update_payment_method_status_internal(let pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(status),+ last_modified_by: None,};let updated_pm = db@@ -3017,6 +3024,7 @@ pub async fn delete_payment_method_core(// Soft deletelet pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(enums::PaymentMethodStatus::Inactive),+ last_modified_by: None,};db.update_payment_method(diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 66a1811f06..344e091780 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -197,6 +197,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,},self.merchant_context.get_merchant_account().storage_scheme,)@@ -417,6 +419,7 @@ 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,};let db = &*self.state.store;let existing_pm = db@@ -839,6 +842,7 @@ impl PaymentMethodsController for PmCards<'_> {let customer_update = CustomerUpdate::UpdateDefaultPaymentMethod {default_payment_method_id: Some(Some(payment_method_id.to_owned())),+ last_modified_by: None,};// update the db with the default payment method id@@ -1048,6 +1052,7 @@ 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,};db.update_customer_by_customer_id_merchant_id(key_manager_state,@@ -1265,6 +1270,7 @@ impl PaymentMethodsController for PmCards<'_> {let pm_update = storage::PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: pm_data_encrypted.map(Into::into),+ last_modified_by: None,};db.update_payment_method(@@ -1507,6 +1513,7 @@ 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,};db.update_payment_method(@@ -1579,6 +1586,7 @@ 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,};db.update_payment_method(@@ -1614,6 +1622,7 @@ pub async fn add_payment_method_data(Err(e) => {let pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(enums::PaymentMethodStatus::Inactive),+ last_modified_by: None,};db.update_payment_method(@@ -1825,6 +1834,7 @@ 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,};add_card_resp@@ -1904,6 +1914,7 @@ 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,};let pm = db@@ -2251,6 +2262,7 @@ pub async fn update_payment_method_metadata_and_last_used(let pm_update = payment_method::PaymentMethodUpdate::MetadataUpdateAndLastUsed {metadata: pm_metadata,last_used_at: common_utils::date_time::now(),+ last_modified_by: None,};db.update_payment_method(&(state.into()), key_store, pm, pm_update, storage_scheme).await@@ -2271,6 +2283,7 @@ pub async fn update_payment_method_and_last_used(payment_method_data: payment_method_update,scheme: card_scheme,last_used_at: common_utils::date_time::now(),+ last_modified_by: None,};db.update_payment_method(&(state.into()), key_store, pm, pm_update, storage_scheme).await@@ -2289,6 +2302,7 @@ pub async fn update_payment_method_connector_mandate_details() -> 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,};db.update_payment_method(&(state.into()), key_store, pm, pm_update, storage_scheme)@@ -2317,6 +2331,7 @@ 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,};db.update_payment_method(&(state.into()), key_store, pm, pm_update, storage_scheme)diff --git a/crates/router/src/core/payment_methods/migration.rs b/crates/router/src/core/payment_methods/migration.rsindex ccd3568a2b..070d4269cc 100644--- a/crates/router/src/core/payment_methods/migration.rs+++ b/crates/router/src/core/payment_methods/migration.rs@@ -259,17 +259,20 @@ pub async fn update_payment_method_record(network_transaction_id,status,payment_method_data: updated_payment_method_data.clone(),+ last_modified_by: None,}}_ => {if updated_payment_method_data.is_some() {PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: updated_payment_method_data,+ last_modified_by: None,}} else {PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,status,+ last_modified_by: None,}}}@@ -403,6 +406,7 @@ fn build_connector_customer_update(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to serialize connector customer data")?,)),+ last_modified_by: None,},)}diff --git a/crates/router/src/core/payment_methods/tokenize/card_executor.rs b/crates/router/src/core/payment_methods/tokenize/card_executor.rsindex 924a2e2f8b..ddb52ff2dc 100644--- a/crates/router/src/core/payment_methods/tokenize/card_executor.rs+++ b/crates/router/src/core/payment_methods/tokenize/card_executor.rs@@ -431,6 +431,9 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest> {updated_by: None,version: common_types::consts::API_VERSION,tax_registration_id: encryptable_customer.tax_registration_id,+ // 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};db.insert_customer(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 ca9c2d9d14..dd79b0327b 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@@ -399,6 +399,7 @@ 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,};self.state.storediff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 9081e51454..9e3e7b09ab 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -1850,6 +1850,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(metadata: Box::new(None),address_id: None,tax_registration_id: encryptable_customer.tax_registration_id,+ last_modified_by: None,};db.update_customer_by_customer_id_merchant_id(@@ -1892,6 +1893,9 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(updated_by: None,version: common_types::consts::API_VERSION,tax_registration_id: encryptable_customer.tax_registration_id,+ // 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};metrics::CUSTOMER_CREATED.add(1, &[]);db.insert_customer(new_customer, key_manager_state, key_store, storage_scheme)diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 903b4f9519..79d7033293 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -2506,11 +2506,13 @@ 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,}} else {storage::PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,status: None,+ last_modified_by: None,}};diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex 3dedf7ac50..d322d097c3 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -2248,6 +2248,7 @@ pub async fn create_recipient_disburse_account(#[cfg(feature = "v2")]connector_mandate_details: Some(common_connector_mandate),+ last_modified_by: None,};payout_data.payment_method = Some(diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rsindex 9d0188ec76..446f215a9d 100644--- a/crates/router/src/core/payouts/helpers.rs+++ b/crates/router/src/core/payouts/helpers.rs@@ -712,6 +712,7 @@ 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,};payout_data.payment_method = Some(db.update_payment_method(@@ -877,6 +878,9 @@ pub(super) async fn get_or_create_customer_details(updated_by: None,version: common_types::consts::API_VERSION,tax_registration_id: encryptable_customer.tax_registration_id,+ // 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};Ok(Some(diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rsindex f9ef014da1..788bf9b033 100644--- a/crates/router/src/core/pm_auth.rs+++ b/crates/router/src/core/pm_auth.rs@@ -475,6 +475,7 @@ 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,};update_entries.push((pm.clone(), pm_update));@@ -529,6 +530,8 @@ 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,};new_entries.push(pm_new);diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex bebdfc344d..cd36b99db0 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -2929,6 +2929,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,};statediff --git a/crates/router/src/core/webhooks/network_tokenization_incoming.rs b/crates/router/src/core/webhooks/network_tokenization_incoming.rsindex a49ec40cba..92789f37de 100644--- a/crates/router/src/core/webhooks/network_tokenization_incoming.rs+++ b/crates/router/src/core/webhooks/network_tokenization_incoming.rs@@ -335,6 +335,7 @@ 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,}} else {storage::PaymentMethodUpdate::AdditionalDataUpdate {@@ -347,6 +348,7 @@ 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,}};let db = &*state.store;diff --git a/crates/router/src/workflows/payment_method_status_update.rs b/crates/router/src/workflows/payment_method_status_update.rsindex 24f3205324..797b11abde 100644--- a/crates/router/src/workflows/payment_method_status_update.rs+++ b/crates/router/src/workflows/payment_method_status_update.rs@@ -66,6 +66,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentMethodStatusUpdateWorkflowlet pm_update = storage::PaymentMethodUpdate::StatusUpdate {status: Some(curr_pm_status),+ last_modified_by: None,};let res = dbdiff --git a/crates/storage_impl/src/payment_method.rs b/crates/storage_impl/src/payment_method.rsindex 760f09e8eb..ed77ec5ba6 100644--- a/crates/storage_impl/src/payment_method.rs+++ b/crates/storage_impl/src/payment_method.rs@@ -175,7 +175,7 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {payment_method_new.clone().insert(&conn),payment_method,InsertResourceParams {- insertable: kv::Insertable::PaymentMethod(payment_method_new.clone()),+ insertable: kv::Insertable::PaymentMethod(Box::new(payment_method_new.clone())),reverse_lookups,key,identifier,@@ -679,6 +679,7 @@ 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,};self.call_database(state,@@ -957,6 +958,7 @@ impl PaymentMethodInterface for MockDb {) -> CustomResult<DomainPaymentMethod, errors::StorageError> {let payment_method_update = PaymentMethodUpdate::StatusUpdate {status: Some(common_enums::PaymentMethodStatus::Inactive),+ last_modified_by: None,};let payment_method_updated = PaymentMethodUpdateInternal::from(payment_method_update).apply_changeset(diff --git a/migrations/2025-11-11-111301_add_tracking_fields_to_customers/down.sql b/migrations/2025-11-11-111301_add_tracking_fields_to_customers/down.sqlnew file mode 100644index 0000000000..c45bc64b02--- /dev/null+++ b/migrations/2025-11-11-111301_add_tracking_fields_to_customers/down.sql@@ -0,0 +1,6 @@+-- This file should undo anything in `up.sql`+-- Remove created_by column from customers table+ALTER TABLE customers DROP COLUMN IF EXISTS created_by;++-- Remove last_modified_by column from customers table+ALTER TABLE customers DROP COLUMN IF EXISTS last_modified_by;diff --git a/migrations/2025-11-11-111301_add_tracking_fields_to_customers/up.sql b/migrations/2025-11-11-111301_add_tracking_fields_to_customers/up.sqlnew file mode 100644index 0000000000..40a536dba8--- /dev/null+++ b/migrations/2025-11-11-111301_add_tracking_fields_to_customers/up.sql@@ -0,0 +1,6 @@+-- Your SQL goes here+-- Add created_by column to customers table for tracking the creator/origin of the record+ALTER TABLE customers ADD COLUMN IF NOT EXISTS created_by VARCHAR(255);++-- Add last_modified_by column to customers table for tracking who last modified the record+ALTER TABLE customers ADD COLUMN IF NOT EXISTS last_modified_by VARCHAR(255);diff --git a/migrations/2025-11-12-135015_add_tracking_fields_to_payment_methods/down.sql b/migrations/2025-11-12-135015_add_tracking_fields_to_payment_methods/down.sqlnew file mode 100644index 0000000000..bf7b624e55--- /dev/null+++ b/migrations/2025-11-12-135015_add_tracking_fields_to_payment_methods/down.sql@@ -0,0 +1,6 @@+-- This file should undo anything in `up.sql`+-- Remove created_by column from payment_methods table+ALTER TABLE payment_methods DROP COLUMN IF EXISTS created_by;++-- Remove last_modified_by column from payment_methods table+ALTER TABLE payment_methods DROP COLUMN IF EXISTS last_modified_by;diff --git a/migrations/2025-11-12-135015_add_tracking_fields_to_payment_methods/up.sql b/migrations/2025-11-12-135015_add_tracking_fields_to_payment_methods/up.sqlnew file mode 100644index 0000000000..862b3bea33--- /dev/null+++ b/migrations/2025-11-12-135015_add_tracking_fields_to_payment_methods/up.sql@@ -0,0 +1,6 @@+-- Your SQL goes here+-- Add created_by column to payment_methods table for tracking the creator/origin of the record+ALTER TABLE payment_methods ADD COLUMN IF NOT EXISTS created_by VARCHAR(255);++-- Add last_modified_by column to payment_methods table for tracking who last modified the record+ALTER TABLE payment_methods ADD COLUMN IF NOT EXISTS last_modified_by VARCHAR(255);