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: add updated_by to tracker tables (#2604)
Kartikeya Hegde6a74e8cba907
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex a44725bc91..f0386fc2f4 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -809,6 +809,29 @@ pub enum EventType {MandateRevoked,}+// TODO: This decision about using KV mode or not,+// should be taken at a top level rather than pushing it down to individual functions via an enum.+#[derive(+ Clone,+ Copy,+ Debug,+ Default,+ Eq,+ PartialEq,+ serde::Deserialize,+ serde::Serialize,+ strum::Display,+ strum::EnumString,+)]+#[router_derive::diesel_enum(storage_type = "pg_enum")]+#[serde(rename_all = "snake_case")]+#[strum(serialize_all = "snake_case")]+pub enum MerchantStorageScheme {+ #[default]+ PostgresOnly,+ RedisKv,+}+#[derive(Clone,Copy,diff --git a/crates/data_models/src/lib.rs b/crates/data_models/src/lib.rsindex f1e659ee9e..322c70225c 100644--- a/crates/data_models/src/lib.rs+++ b/crates/data_models/src/lib.rs@@ -2,28 +2,6 @@ pub mod errors;pub mod mandates;pub mod payments;-// TODO: This decision about using KV mode or not,-// should be taken at a top level rather than pushing it down to individual functions via an enum.-#[derive(- Clone,- Copy,- Debug,- Default,- Eq,- PartialEq,- serde::Deserialize,- serde::Serialize,- strum::Display,- strum::EnumString,-)]-#[serde(rename_all = "snake_case")]-#[strum(serialize_all = "snake_case")]-pub enum MerchantStorageScheme {- #[default]- PostgresOnly,- RedisKv,-}-#[derive(Clone, Debug, Eq, PartialEq)]pub enum RemoteStorageObject<T: ForeignIDRef> {ForeignID(String),diff --git a/crates/data_models/src/payments.rs b/crates/data_models/src/payments.rsindex 5cdd167a8d..029f710850 100644--- a/crates/data_models/src/payments.rs+++ b/crates/data_models/src/payments.rs@@ -47,4 +47,5 @@ pub struct PaymentIntent {// Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto paymentpub merchant_decision: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,+ pub updated_by: String,}diff --git a/crates/data_models/src/payments/payment_attempt.rs b/crates/data_models/src/payments/payment_attempt.rsindex f711ae6638..cf65c3f5de 100644--- a/crates/data_models/src/payments/payment_attempt.rs+++ b/crates/data_models/src/payments/payment_attempt.rs@@ -4,21 +4,21 @@ use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;use super::PaymentIntent;-use crate::{errors, mandates::MandateDataType, ForeignIDRef, MerchantStorageScheme};+use crate::{errors, mandates::MandateDataType, ForeignIDRef};#[async_trait::async_trait]pub trait PaymentAttemptInterface {async fn insert_payment_attempt(&self,payment_attempt: PaymentAttemptNew,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn update_payment_attempt_with_attempt_id(&self,this: PaymentAttempt,payment_attempt: PaymentAttemptUpdate,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(@@ -26,21 +26,21 @@ pub trait PaymentAttemptInterface {connector_transaction_id: &str,payment_id: &str,merchant_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,payment_id: &str,merchant_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,merchant_id: &str,connector_txn_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(@@ -48,35 +48,35 @@ pub trait PaymentAttemptInterface {payment_id: &str,merchant_id: &str,attempt_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_by_attempt_id_merchant_id(&self,attempt_id: &str,merchant_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,preprocessing_id: &str,merchant_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_attempts_by_merchant_id_payment_id(&self,merchant_id: &str,payment_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<PaymentAttempt>, errors::StorageError>;async fn get_filters_for_payments(&self,pi: &[PaymentIntent],merchant_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentListFilters, errors::StorageError>;#[allow(clippy::too_many_arguments)]@@ -88,7 +88,7 @@ pub trait PaymentAttemptInterface {payment_method: Option<Vec<storage_enums::PaymentMethod>>,payment_method_type: Option<Vec<storage_enums::PaymentMethodType>>,authentication_type: Option<Vec<storage_enums::AuthenticationType>>,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<i64, errors::StorageError>;}@@ -142,6 +142,7 @@ pub struct PaymentAttempt {pub connector_response_reference_id: Option<String>,pub amount_capturable: i64,pub surcharge_metadata: Option<serde_json::Value>,+ pub updated_by: String,}#[derive(Clone, Debug, Eq, PartialEq)]@@ -201,6 +202,7 @@ pub struct PaymentAttemptNew {pub multiple_capture_count: Option<i16>,pub amount_capturable: i64,pub surcharge_metadata: Option<serde_json::Value>,+ pub updated_by: String,}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -218,15 +220,18 @@ pub enum PaymentAttemptUpdate {business_sub_label: Option<String>,amount_to_capture: Option<i64>,capture_method: Option<storage_enums::CaptureMethod>,+ updated_by: String,},UpdateTrackers {payment_token: Option<String>,connector: Option<String>,straight_through_algorithm: Option<serde_json::Value>,amount_capturable: Option<i64>,+ updated_by: String,},AuthenticationTypeUpdate {authentication_type: storage_enums::AuthenticationType,+ updated_by: String,},ConfirmUpdate {amount: i64,@@ -245,15 +250,18 @@ pub enum PaymentAttemptUpdate {error_code: Option<Option<String>>,error_message: Option<Option<String>>,amount_capturable: Option<i64>,+ updated_by: String,},RejectUpdate {status: storage_enums::AttemptStatus,error_code: Option<Option<String>>,error_message: Option<Option<String>>,+ updated_by: String,},VoidUpdate {status: storage_enums::AttemptStatus,cancellation_reason: Option<String>,+ updated_by: String,},ResponseUpdate {status: storage_enums::AttemptStatus,@@ -269,6 +277,7 @@ pub enum PaymentAttemptUpdate {error_reason: Option<Option<String>>,connector_response_reference_id: Option<String>,amount_capturable: Option<i64>,+ updated_by: String,},UnresolvedResponseUpdate {status: storage_enums::AttemptStatus,@@ -279,9 +288,11 @@ pub enum PaymentAttemptUpdate {error_message: Option<Option<String>>,error_reason: Option<Option<String>>,connector_response_reference_id: Option<String>,+ updated_by: String,},StatusUpdate {status: storage_enums::AttemptStatus,+ updated_by: String,},ErrorUpdate {connector: Option<String>,@@ -290,17 +301,21 @@ pub enum PaymentAttemptUpdate {error_message: Option<Option<String>>,error_reason: Option<Option<String>>,amount_capturable: Option<i64>,+ updated_by: String,},MultipleCaptureCountUpdate {multiple_capture_count: i16,+ updated_by: String,},SurchargeAmountUpdate {surcharge_amount: Option<i64>,tax_amount: Option<i64>,+ updated_by: String,},AmountToCaptureUpdate {status: storage_enums::AttemptStatus,amount_capturable: i64,+ updated_by: String,},PreprocessingUpdate {status: storage_enums::AttemptStatus,@@ -309,9 +324,11 @@ pub enum PaymentAttemptUpdate {preprocessing_step_id: Option<String>,connector_transaction_id: Option<String>,connector_response_reference_id: Option<String>,+ updated_by: String,},SurchargeMetadataUpdate {surcharge_metadata: Option<serde_json::Value>,+ updated_by: String,},}diff --git a/crates/data_models/src/payments/payment_intent.rs b/crates/data_models/src/payments/payment_intent.rsindex 57507aa6a3..155e6b5ca6 100644--- a/crates/data_models/src/payments/payment_intent.rs+++ b/crates/data_models/src/payments/payment_intent.rs@@ -7,33 +7,33 @@ use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;use super::{payment_attempt::PaymentAttempt, PaymentIntent};-use crate::{errors, MerchantStorageScheme, RemoteStorageObject};+use crate::{errors, RemoteStorageObject};#[async_trait::async_trait]pub trait PaymentIntentInterface {async fn update_payment_intent(&self,this: PaymentIntent,payment_intent: PaymentIntentUpdate,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, errors::StorageError>;async fn insert_payment_intent(&self,new: PaymentIntentNew,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, errors::StorageError>;async fn find_payment_intent_by_payment_id_merchant_id(&self,payment_id: &str,merchant_id: &str,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, errors::StorageError>;async fn get_active_payment_attempt(&self,payment: &mut PaymentIntent,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;#[cfg(feature = "olap")]@@ -41,7 +41,7 @@ pub trait PaymentIntentInterface {&self,merchant_id: &str,filters: &PaymentIntentFetchConstraints,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<PaymentIntent>, errors::StorageError>;#[cfg(feature = "olap")]@@ -49,7 +49,7 @@ pub trait PaymentIntentInterface {&self,merchant_id: &str,time_range: &api_models::payments::TimeRange,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<PaymentIntent>, errors::StorageError>;#[cfg(feature = "olap")]@@ -57,7 +57,7 @@ pub trait PaymentIntentInterface {&self,merchant_id: &str,constraints: &PaymentIntentFetchConstraints,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, errors::StorageError>;#[cfg(feature = "olap")]@@ -65,7 +65,7 @@ pub trait PaymentIntentInterface {&self,merchant_id: &str,constraints: &PaymentIntentFetchConstraints,- storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<String>, errors::StorageError>;}@@ -104,6 +104,7 @@ pub struct PaymentIntentNew {pub merchant_decision: Option<String>,pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,+ pub updated_by: String,}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -112,9 +113,11 @@ pub enum PaymentIntentUpdate {status: storage_enums::IntentStatus,amount_captured: Option<i64>,return_url: Option<String>,+ updated_by: String,},MetadataUpdate {metadata: pii::SecretSerdeValue,+ updated_by: String,},ReturnUrlUpdate {return_url: Option<String>,@@ -122,14 +125,17 @@ pub enum PaymentIntentUpdate {customer_id: Option<String>,shipping_address_id: Option<String>,billing_address_id: Option<String>,+ updated_by: String,},MerchantStatusUpdate {status: storage_enums::IntentStatus,shipping_address_id: Option<String>,billing_address_id: Option<String>,+ updated_by: String,},PGStatusUpdate {status: storage_enums::IntentStatus,+ updated_by: String,},Update {amount: i64,@@ -148,22 +154,27 @@ pub enum PaymentIntentUpdate {order_details: Option<Vec<pii::SecretSerdeValue>>,metadata: Option<pii::SecretSerdeValue>,payment_confirm_source: Option<storage_enums::PaymentSource>,+ updated_by: String,},PaymentAttemptAndAttemptCountUpdate {active_attempt_id: String,attempt_count: i16,+ updated_by: String,},StatusAndAttemptUpdate {status: storage_enums::IntentStatus,active_attempt_id: String,attempt_count: i16,+ updated_by: String,},ApproveUpdate {merchant_decision: Option<String>,+ updated_by: String,},RejectUpdate {status: storage_enums::IntentStatus,merchant_decision: Option<String>,+ updated_by: String,},}@@ -193,6 +204,7 @@ pub struct PaymentIntentUpdateInternal {// Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto paymentpub merchant_decision: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,+ pub updated_by: String,}impl PaymentIntentUpdate {@@ -218,6 +230,7 @@ impl PaymentIntentUpdate {.or(source.shipping_address_id),modified_at: common_utils::date_time::now(),order_details: internal_update.order_details.or(source.order_details),+ updated_by: internal_update.updated_by,..source}}@@ -243,6 +256,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {order_details,metadata,payment_confirm_source,+ updated_by,} => Self {amount: Some(amount),currency: Some(currency),@@ -261,11 +275,16 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {order_details,metadata,payment_confirm_source,+ updated_by,..Default::default()},- PaymentIntentUpdate::MetadataUpdate { metadata } => Self {+ PaymentIntentUpdate::MetadataUpdate {+ metadata,+ updated_by,+ } => Self {metadata: Some(metadata),modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentIntentUpdate::ReturnUrlUpdate {@@ -274,6 +293,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {customer_id,shipping_address_id,billing_address_id,+ updated_by,} => Self {return_url,status,@@ -281,22 +301,26 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {shipping_address_id,billing_address_id,modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},- PaymentIntentUpdate::PGStatusUpdate { status } => Self {+ PaymentIntentUpdate::PGStatusUpdate { status, updated_by } => Self {status: Some(status),modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentIntentUpdate::MerchantStatusUpdate {status,shipping_address_id,billing_address_id,+ updated_by,} => Self {status: Some(status),shipping_address_id,billing_address_id,modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentIntentUpdate::ResponseUpdate {@@ -306,6 +330,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {amount_captured,// customer_id,return_url,+ updated_by,} => Self {// amount,// currency: Some(currency),@@ -314,36 +339,47 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {// customer_id,return_url,modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {active_attempt_id,attempt_count,+ updated_by,} => Self {active_attempt_id: Some(active_attempt_id),attempt_count: Some(attempt_count),+ updated_by,..Default::default()},PaymentIntentUpdate::StatusAndAttemptUpdate {status,active_attempt_id,attempt_count,+ updated_by,} => Self {status: Some(status),active_attempt_id: Some(active_attempt_id),attempt_count: Some(attempt_count),+ updated_by,..Default::default()},- PaymentIntentUpdate::ApproveUpdate { merchant_decision } => Self {+ PaymentIntentUpdate::ApproveUpdate {+ merchant_decision,+ updated_by,+ } => Self {merchant_decision,+ updated_by,..Default::default()},PaymentIntentUpdate::RejectUpdate {status,merchant_decision,+ updated_by,} => Self {status: Some(status),merchant_decision,+ updated_by,..Default::default()},}diff --git a/crates/diesel_models/src/address.rs b/crates/diesel_models/src/address.rsindex 569df3f551..e67f37c904 100644--- a/crates/diesel_models/src/address.rs+++ b/crates/diesel_models/src/address.rs@@ -24,6 +24,7 @@ pub struct AddressNew {pub payment_id: Option<String>,pub created_at: PrimitiveDateTime,pub modified_at: PrimitiveDateTime,+ pub updated_by: String,}#[derive(Clone, Debug, Queryable, Identifiable, Serialize, Deserialize)]@@ -47,6 +48,7 @@ pub struct Address {pub customer_id: String,pub merchant_id: String,pub payment_id: Option<String>,+ pub updated_by: String,}#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay, Serialize, Deserialize)]@@ -64,6 +66,7 @@ pub struct AddressUpdateInternal {pub phone_number: Option<Encryption>,pub country_code: Option<String>,pub modified_at: PrimitiveDateTime,+ pub updated_by: String,}impl AddressUpdateInternal {@@ -81,7 +84,7 @@ impl AddressUpdateInternal {phone_number: self.phone_number,country_code: self.country_code,modified_at: self.modified_at,-+ updated_by: self.updated_by,..source}}diff --git a/crates/diesel_models/src/connector_response.rs b/crates/diesel_models/src/connector_response.rsindex 401a6eec91..863ce28ee0 100644--- a/crates/diesel_models/src/connector_response.rs+++ b/crates/diesel_models/src/connector_response.rs@@ -19,6 +19,7 @@ pub struct ConnectorResponseNew {pub connector_transaction_id: Option<String>,pub authentication_data: Option<serde_json::Value>,pub encoded_data: Option<String>,+ pub updated_by: String,}#[derive(Clone, Debug, Deserialize, Serialize, Identifiable, Queryable)]@@ -36,6 +37,7 @@ pub struct ConnectorResponse {pub connector_transaction_id: Option<String>,pub authentication_data: Option<serde_json::Value>,pub encoded_data: Option<String>,+ pub updated_by: String,}#[derive(Clone, Default, Debug, Deserialize, AsChangeset, Serialize)]@@ -46,6 +48,7 @@ pub struct ConnectorResponseUpdateInternal {pub modified_at: Option<PrimitiveDateTime>,pub encoded_data: Option<String>,pub connector_name: Option<String>,+ pub updated_by: String,}#[derive(Clone, Debug, Serialize, Deserialize)]@@ -55,9 +58,11 @@ pub enum ConnectorResponseUpdate {authentication_data: Option<serde_json::Value>,encoded_data: Option<String>,connector_name: Option<String>,+ updated_by: String,},ErrorUpdate {connector_name: Option<String>,+ updated_by: String,},}@@ -80,6 +85,7 @@ impl ConnectorResponseUpdate {encoded_data: connector_response_update.encoded_data.or(source.encoded_data),+ updated_by: connector_response_update.updated_by,..source}}@@ -93,16 +99,22 @@ impl From<ConnectorResponseUpdate> for ConnectorResponseUpdateInternal {authentication_data,encoded_data,connector_name,+ updated_by,} => Self {connector_transaction_id,authentication_data,encoded_data,modified_at: Some(common_utils::date_time::now()),connector_name,+ updated_by,},- ConnectorResponseUpdate::ErrorUpdate { connector_name } => Self {+ ConnectorResponseUpdate::ErrorUpdate {+ connector_name,+ updated_by,+ } => Self {connector_name,modified_at: Some(common_utils::date_time::now()),+ updated_by,..Self::default()},}diff --git a/crates/diesel_models/src/enums.rs b/crates/diesel_models/src/enums.rsindex 09b8024efd..b73eeefbb1 100644--- a/crates/diesel_models/src/enums.rs+++ b/crates/diesel_models/src/enums.rs@@ -63,27 +63,6 @@ pub enum EventObjectType {MandateDetails,}-#[derive(- Clone,- Copy,- Debug,- Default,- Eq,- PartialEq,- serde::Deserialize,- serde::Serialize,- strum::Display,- strum::EnumString,-)]-#[router_derive::diesel_enum(storage_type = "pg_enum")]-#[serde(rename_all = "snake_case")]-#[strum(serialize_all = "snake_case")]-pub enum MerchantStorageScheme {- #[default]- PostgresOnly,- RedisKv,-}-#[derive(Clone,Copy,diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rsindex 97f45a8683..ca73540437 100644--- a/crates/diesel_models/src/payment_attempt.rs+++ b/crates/diesel_models/src/payment_attempt.rs@@ -58,6 +58,7 @@ pub struct PaymentAttempt {pub connector_response_reference_id: Option<String>,pub amount_capturable: i64,pub surcharge_metadata: Option<serde_json::Value>,+ pub updated_by: String,}#[derive(Clone, Debug, Eq, PartialEq, Queryable, Serialize, Deserialize)]@@ -117,6 +118,7 @@ pub struct PaymentAttemptNew {pub multiple_capture_count: Option<i16>,pub amount_capturable: i64,pub surcharge_metadata: Option<serde_json::Value>,+ pub updated_by: String,}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -134,15 +136,18 @@ pub enum PaymentAttemptUpdate {business_sub_label: Option<String>,amount_to_capture: Option<i64>,capture_method: Option<storage_enums::CaptureMethod>,+ updated_by: String,},UpdateTrackers {payment_token: Option<String>,connector: Option<String>,straight_through_algorithm: Option<serde_json::Value>,amount_capturable: Option<i64>,+ updated_by: String,},AuthenticationTypeUpdate {authentication_type: storage_enums::AuthenticationType,+ updated_by: String,},ConfirmUpdate {amount: i64,@@ -161,15 +166,18 @@ pub enum PaymentAttemptUpdate {error_code: Option<Option<String>>,error_message: Option<Option<String>>,amount_capturable: Option<i64>,+ updated_by: String,},VoidUpdate {status: storage_enums::AttemptStatus,cancellation_reason: Option<String>,+ updated_by: String,},RejectUpdate {status: storage_enums::AttemptStatus,error_code: Option<Option<String>>,error_message: Option<Option<String>>,+ updated_by: String,},ResponseUpdate {status: storage_enums::AttemptStatus,@@ -185,6 +193,7 @@ pub enum PaymentAttemptUpdate {error_reason: Option<Option<String>>,connector_response_reference_id: Option<String>,amount_capturable: Option<i64>,+ updated_by: String,},UnresolvedResponseUpdate {status: storage_enums::AttemptStatus,@@ -195,9 +204,11 @@ pub enum PaymentAttemptUpdate {error_message: Option<Option<String>>,error_reason: Option<Option<String>>,connector_response_reference_id: Option<String>,+ updated_by: String,},StatusUpdate {status: storage_enums::AttemptStatus,+ updated_by: String,},ErrorUpdate {connector: Option<String>,@@ -206,17 +217,21 @@ pub enum PaymentAttemptUpdate {error_message: Option<Option<String>>,error_reason: Option<Option<String>>,amount_capturable: Option<i64>,+ updated_by: String,},MultipleCaptureCountUpdate {multiple_capture_count: i16,+ updated_by: String,},AmountToCaptureUpdate {status: storage_enums::AttemptStatus,amount_capturable: i64,+ updated_by: String,},SurchargeAmountUpdate {surcharge_amount: Option<i64>,tax_amount: Option<i64>,+ updated_by: String,},PreprocessingUpdate {status: storage_enums::AttemptStatus,@@ -225,9 +240,11 @@ pub enum PaymentAttemptUpdate {preprocessing_step_id: Option<String>,connector_transaction_id: Option<String>,connector_response_reference_id: Option<String>,+ updated_by: String,},SurchargeMetadataUpdate {surcharge_metadata: Option<serde_json::Value>,+ updated_by: String,},}@@ -265,6 +282,7 @@ pub struct PaymentAttemptUpdateInternal {tax_amount: Option<i64>,amount_capturable: Option<i64>,surcharge_metadata: Option<serde_json::Value>,+ updated_by: String,}impl PaymentAttemptUpdate {@@ -292,6 +310,7 @@ impl PaymentAttemptUpdate {.preprocessing_step_id.or(source.preprocessing_step_id),surcharge_metadata: pa_update.surcharge_metadata.or(source.surcharge_metadata),+ updated_by: pa_update.updated_by,..source}}@@ -314,6 +333,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {business_sub_label,amount_to_capture,capture_method,+ updated_by,} => Self {amount: Some(amount),currency: Some(currency),@@ -329,13 +349,16 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {business_sub_label,amount_to_capture,capture_method,+ updated_by,..Default::default()},PaymentAttemptUpdate::AuthenticationTypeUpdate {authentication_type,+ updated_by,} => Self {authentication_type: Some(authentication_type),modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentAttemptUpdate::ConfirmUpdate {@@ -355,6 +378,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {error_code,error_message,amount_capturable,+ updated_by,} => Self {amount: Some(amount),currency: Some(currency),@@ -373,24 +397,29 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {error_code,error_message,amount_capturable,+ updated_by,..Default::default()},PaymentAttemptUpdate::VoidUpdate {status,cancellation_reason,+ updated_by,} => Self {status: Some(status),cancellation_reason,+ updated_by,..Default::default()},PaymentAttemptUpdate::RejectUpdate {status,error_code,error_message,+ updated_by,} => Self {status: Some(status),error_code,error_message,+ updated_by,..Default::default()},PaymentAttemptUpdate::ResponseUpdate {@@ -407,6 +436,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {error_reason,connector_response_reference_id,amount_capturable,+ updated_by,} => Self {status: Some(status),connector,@@ -422,6 +452,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {error_reason,connector_response_reference_id,amount_capturable,+ updated_by,..Default::default()},PaymentAttemptUpdate::ErrorUpdate {@@ -431,6 +462,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {error_message,error_reason,amount_capturable,+ updated_by,} => Self {connector,status: Some(status),@@ -439,10 +471,12 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {modified_at: Some(common_utils::date_time::now()),error_reason,amount_capturable,+ updated_by,..Default::default()},- PaymentAttemptUpdate::StatusUpdate { status } => Self {+ PaymentAttemptUpdate::StatusUpdate { status, updated_by } => Self {status: Some(status),+ updated_by,..Default::default()},PaymentAttemptUpdate::UpdateTrackers {@@ -450,11 +484,13 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {connector,straight_through_algorithm,amount_capturable,+ updated_by,} => Self {payment_token,connector,straight_through_algorithm,amount_capturable,+ updated_by,..Default::default()},PaymentAttemptUpdate::UnresolvedResponseUpdate {@@ -466,6 +502,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {error_message,error_reason,connector_response_reference_id,+ updated_by,} => Self {status: Some(status),connector,@@ -476,6 +513,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {error_message,error_reason,connector_response_reference_id,+ updated_by,..Default::default()},PaymentAttemptUpdate::PreprocessingUpdate {@@ -485,6 +523,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {preprocessing_step_id,connector_transaction_id,connector_response_reference_id,+ updated_by,} => Self {status: Some(status),payment_method_id,@@ -493,32 +532,43 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {preprocessing_step_id,connector_transaction_id,connector_response_reference_id,+ updated_by,..Default::default()},PaymentAttemptUpdate::MultipleCaptureCountUpdate {multiple_capture_count,+ updated_by,} => Self {multiple_capture_count: Some(multiple_capture_count),+ updated_by,..Default::default()},PaymentAttemptUpdate::AmountToCaptureUpdate {status,amount_capturable,+ updated_by,} => Self {status: Some(status),amount_capturable: Some(amount_capturable),+ updated_by,..Default::default()},- PaymentAttemptUpdate::SurchargeMetadataUpdate { surcharge_metadata } => Self {+ PaymentAttemptUpdate::SurchargeMetadataUpdate {surcharge_metadata,+ updated_by,+ } => Self {+ surcharge_metadata,+ updated_by,..Default::default()},PaymentAttemptUpdate::SurchargeAmountUpdate {surcharge_amount,tax_amount,+ updated_by,} => Self {surcharge_amount,tax_amount,+ updated_by,..Default::default()},}diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rsindex 82cfc05eaf..c6b95b5cef 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -48,6 +48,7 @@ pub struct PaymentIntent {pub merchant_decision: Option<String>,pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,+ pub updated_by: String,}#[derive(@@ -100,6 +101,7 @@ pub struct PaymentIntentNew {pub merchant_decision: Option<String>,pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,+ pub updated_by: String,}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -108,9 +110,11 @@ pub enum PaymentIntentUpdate {status: storage_enums::IntentStatus,amount_captured: Option<i64>,return_url: Option<String>,+ updated_by: String,},MetadataUpdate {metadata: pii::SecretSerdeValue,+ updated_by: String,},ReturnUrlUpdate {return_url: Option<String>,@@ -118,14 +122,17 @@ pub enum PaymentIntentUpdate {customer_id: Option<String>,shipping_address_id: Option<String>,billing_address_id: Option<String>,+ updated_by: String,},MerchantStatusUpdate {status: storage_enums::IntentStatus,shipping_address_id: Option<String>,billing_address_id: Option<String>,+ updated_by: String,},PGStatusUpdate {status: storage_enums::IntentStatus,+ updated_by: String,},Update {amount: i64,@@ -144,22 +151,27 @@ pub enum PaymentIntentUpdate {order_details: Option<Vec<pii::SecretSerdeValue>>,metadata: Option<pii::SecretSerdeValue>,payment_confirm_source: Option<storage_enums::PaymentSource>,+ updated_by: String,},PaymentAttemptAndAttemptCountUpdate {active_attempt_id: String,attempt_count: i16,+ updated_by: String,},StatusAndAttemptUpdate {status: storage_enums::IntentStatus,active_attempt_id: String,attempt_count: i16,+ updated_by: String,},ApproveUpdate {merchant_decision: Option<String>,+ updated_by: String,},RejectUpdate {status: storage_enums::IntentStatus,merchant_decision: Option<String>,+ updated_by: String,},}@@ -190,6 +202,7 @@ pub struct PaymentIntentUpdateInternal {pub profile_id: Option<String>,merchant_decision: Option<String>,payment_confirm_source: Option<storage_enums::PaymentSource>,+ pub updated_by: String,}impl PaymentIntentUpdate {@@ -240,6 +253,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {order_details,metadata,payment_confirm_source,+ updated_by,} => Self {amount: Some(amount),currency: Some(currency),@@ -258,11 +272,16 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {order_details,metadata,payment_confirm_source,+ updated_by,..Default::default()},- PaymentIntentUpdate::MetadataUpdate { metadata } => Self {+ PaymentIntentUpdate::MetadataUpdate {+ metadata,+ updated_by,+ } => Self {metadata: Some(metadata),modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentIntentUpdate::ReturnUrlUpdate {@@ -271,6 +290,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {customer_id,shipping_address_id,billing_address_id,+ updated_by,} => Self {return_url,status,@@ -278,22 +298,26 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {shipping_address_id,billing_address_id,modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},- PaymentIntentUpdate::PGStatusUpdate { status } => Self {+ PaymentIntentUpdate::PGStatusUpdate { status, updated_by } => Self {status: Some(status),modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentIntentUpdate::MerchantStatusUpdate {status,shipping_address_id,billing_address_id,+ updated_by,} => Self {status: Some(status),shipping_address_id,billing_address_id,modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentIntentUpdate::ResponseUpdate {@@ -303,6 +327,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {amount_captured,// customer_id,return_url,+ updated_by,} => Self {// amount,// currency: Some(currency),@@ -311,36 +336,47 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {// customer_id,return_url,modified_at: Some(common_utils::date_time::now()),+ updated_by,..Default::default()},PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {active_attempt_id,attempt_count,+ updated_by,} => Self {active_attempt_id: Some(active_attempt_id),attempt_count: Some(attempt_count),+ updated_by,..Default::default()},PaymentIntentUpdate::StatusAndAttemptUpdate {status,active_attempt_id,attempt_count,+ updated_by,} => Self {status: Some(status),active_attempt_id: Some(active_attempt_id),attempt_count: Some(attempt_count),+ updated_by,..Default::default()},- PaymentIntentUpdate::ApproveUpdate { merchant_decision } => Self {+ PaymentIntentUpdate::ApproveUpdate {+ merchant_decision,+ updated_by,+ } => Self {merchant_decision,+ updated_by,..Default::default()},PaymentIntentUpdate::RejectUpdate {status,merchant_decision,+ updated_by,} => Self {status: Some(status),merchant_decision,+ updated_by,..Default::default()},}diff --git a/crates/diesel_models/src/refund.rs b/crates/diesel_models/src/refund.rsindex eba0ff84cc..56adfaf028 100644--- a/crates/diesel_models/src/refund.rs+++ b/crates/diesel_models/src/refund.rs@@ -37,6 +37,7 @@ pub struct Refund {pub refund_reason: Option<String>,pub refund_error_code: Option<String>,pub profile_id: Option<String>,+ pub updated_by: String,}#[derive(@@ -77,6 +78,7 @@ pub struct RefundNew {pub attempt_id: String,pub refund_reason: Option<String>,pub profile_id: Option<String>,+ pub updated_by: String,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]@@ -87,20 +89,24 @@ pub enum RefundUpdate {sent_to_gateway: bool,refund_error_message: Option<String>,refund_arn: String,+ updated_by: String,},MetadataAndReasonUpdate {metadata: Option<pii::SecretSerdeValue>,reason: Option<String>,+ updated_by: String,},StatusUpdate {connector_refund_id: Option<String>,sent_to_gateway: bool,refund_status: storage_enums::RefundStatus,+ updated_by: String,},ErrorUpdate {refund_status: Option<storage_enums::RefundStatus>,refund_error_message: Option<String>,refund_error_code: Option<String>,+ updated_by: String,},}@@ -115,6 +121,7 @@ pub struct RefundUpdateInternal {metadata: Option<pii::SecretSerdeValue>,refund_reason: Option<String>,refund_error_code: Option<String>,+ updated_by: String,}impl RefundUpdateInternal {@@ -128,6 +135,7 @@ impl RefundUpdateInternal {metadata: self.metadata,refund_reason: self.refund_reason,refund_error_code: self.refund_error_code,+ updated_by: self.updated_by,..source}}@@ -142,37 +150,48 @@ impl From<RefundUpdate> for RefundUpdateInternal {sent_to_gateway,refund_error_message,refund_arn,+ updated_by,} => Self {connector_refund_id: Some(connector_refund_id),refund_status: Some(refund_status),sent_to_gateway: Some(sent_to_gateway),refund_error_message,refund_arn: Some(refund_arn),+ updated_by,..Default::default()},- RefundUpdate::MetadataAndReasonUpdate { metadata, reason } => Self {+ RefundUpdate::MetadataAndReasonUpdate {+ metadata,+ reason,+ updated_by,+ } => Self {metadata,refund_reason: reason,+ updated_by,..Default::default()},RefundUpdate::StatusUpdate {connector_refund_id,sent_to_gateway,refund_status,+ updated_by,} => Self {connector_refund_id,sent_to_gateway: Some(sent_to_gateway),refund_status: Some(refund_status),+ updated_by,..Default::default()},RefundUpdate::ErrorUpdate {refund_status,refund_error_message,refund_error_code,+ updated_by,} => Self {refund_status,refund_error_message,refund_error_code,+ updated_by,..Default::default()},}@@ -193,6 +212,7 @@ impl RefundUpdate {refund_arn: pa_update.refund_arn.or(source.refund_arn),metadata: pa_update.metadata.or(source.metadata),refund_reason: pa_update.refund_reason.or(source.refund_reason),+ updated_by: pa_update.updated_by,..source}}diff --git a/crates/diesel_models/src/reverse_lookup.rs b/crates/diesel_models/src/reverse_lookup.rsindex 6483b7c78c..a9463d27b6 100644--- a/crates/diesel_models/src/reverse_lookup.rs+++ b/crates/diesel_models/src/reverse_lookup.rs@@ -19,6 +19,7 @@ pub struct ReverseLookup {pub pk_id: String,/// the source of insertion for referencepub source: String,+ pub updated_by: String,}#[derive(@@ -37,6 +38,7 @@ pub struct ReverseLookupNew {pub pk_id: String,pub sk_id: String,pub source: String,+ pub updated_by: String,}impl From<ReverseLookupNew> for ReverseLookup {@@ -46,6 +48,7 @@ impl From<ReverseLookupNew> for ReverseLookup {sk_id: new.sk_id,pk_id: new.pk_id,source: new.source,+ updated_by: new.updated_by,}}}diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 578d22c6ad..2cbd6027a7 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -29,6 +29,8 @@ diesel::table! {merchant_id -> Varchar,#[max_length = 64]payment_id -> Nullable<Varchar>,+ #[max_length = 32]+ updated_by -> Varchar,}}@@ -175,6 +177,8 @@ diesel::table! {connector_transaction_id -> Nullable<Varchar>,authentication_data -> Nullable<Json>,encoded_data -> Nullable<Text>,+ #[max_length = 32]+ updated_by -> Varchar,}}@@ -556,6 +560,8 @@ diesel::table! {connector_response_reference_id -> Nullable<Varchar>,amount_capturable -> Int8,surcharge_metadata -> Nullable<Jsonb>,+ #[max_length = 32]+ updated_by -> Varchar,}}@@ -614,6 +620,8 @@ diesel::table! {#[max_length = 255]payment_link_id -> Nullable<Varchar>,payment_confirm_source -> Nullable<PaymentSource>,+ #[max_length = 32]+ updated_by -> Varchar,}}@@ -818,6 +826,8 @@ diesel::table! {refund_error_code -> Nullable<Text>,#[max_length = 64]profile_id -> Nullable<Varchar>,+ #[max_length = 32]+ updated_by -> Varchar,}}@@ -834,6 +844,8 @@ diesel::table! {pk_id -> Varchar,#[max_length = 128]source -> Varchar,+ #[max_length = 32]+ updated_by -> Varchar,}}diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex d80175ee9e..1f60f11a97 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -5,7 +5,6 @@ use common_utils::{ext_traits::{AsyncExt, ConfigExt, Encode, ValueExt},pii,};-use data_models::MerchantStorageScheme;use error_stack::{report, FutureExt, ResultExt};use masking::{PeekInterface, Secret};use uuid::Uuid;@@ -26,7 +25,7 @@ use crate::{self,types::{self as domain_types, AsyncLift},},- storage,+ storage::{self, enums::MerchantStorageScheme},transformers::ForeignTryFrom,},utils::{self, OptionExt},diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rsindex f4ef3d8ed8..9442bf2ff3 100644--- a/crates/router/src/core/customers.rs+++ b/crates/router/src/core/customers.rs@@ -63,7 +63,13 @@ pub async fn create_customer(let customer_address: api_models::payments::AddressDetails = addr.clone();let address = customer_data- .get_domain_address(customer_address, merchant_id, customer_id, key)+ .get_domain_address(+ customer_address,+ merchant_id,+ customer_id,+ key,+ merchant_account.storage_scheme,+ ).await.switch().attach_printable("Failed while encrypting address")?;@@ -255,6 +261,7 @@ pub async fn delete_customer(last_name: Some(redacted_encrypted_value.clone()),phone_number: Some(redacted_encrypted_value.clone()),country_code: Some(REDACTED.to_string()),+ updated_by: merchant_account.storage_scheme.to_string(),};match db@@ -336,7 +343,7 @@ pub async fn update_customer(Some(address_id) => {let customer_address: api_models::payments::AddressDetails = addr.clone();let update_address = update_customer- .get_address_update(customer_address, key)+ .get_address_update(customer_address, key, merchant_account.storage_scheme).await.switch().attach_printable("Failed while encrypting Address while Update")?;@@ -359,6 +366,7 @@ pub async fn update_customer(&merchant_account.merchant_id,&customer.customer_id,key,+ merchant_account.storage_scheme,).await.switch()diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex d6031703fd..efc752355d 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -176,6 +176,7 @@ pub async fn create_or_update_address_for_payment_by_request(.phone.as_ref().and_then(|value| value.country_code.clone()),+ updated_by: storage_scheme.to_string(),})}.await@@ -233,6 +234,7 @@ pub async fn create_or_update_address_for_payment_by_request(customer_id,payment_id,key,+ storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -293,6 +295,7 @@ pub async fn create_or_find_address_for_payment_by_request(customer_id,payment_id,key,+ storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -317,6 +320,7 @@ pub async fn get_domain_address_for_payments(customer_id: &str,payment_id: &str,key: &[u8],+ storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<domain::Address, common_utils::errors::CryptoError> {async {Ok(domain::Address {@@ -364,6 +368,7 @@ pub async fn get_domain_address_for_payments(.async_lift(|inner| types::encrypt_optional(inner, key)).await?,payment_id: Some(payment_id.to_owned()),+ updated_by: storage_scheme.to_string(),})}.await@@ -2404,6 +2409,7 @@ mod tests {profile_id: None,merchant_decision: None,payment_confirm_source: None,+ updated_by: storage_enums::MerchantStorageScheme::PostgresOnly.to_string(),};let req_cs = Some("1".to_string());let merchant_fulfillment_time = Some(900);@@ -2452,6 +2458,7 @@ mod tests {profile_id: None,merchant_decision: None,payment_confirm_source: None,+ updated_by: storage_enums::MerchantStorageScheme::PostgresOnly.to_string(),};let req_cs = Some("1".to_string());let merchant_fulfillment_time = Some(10);@@ -2500,6 +2507,7 @@ mod tests {profile_id: None,merchant_decision: None,payment_confirm_source: None,+ updated_by: storage_enums::MerchantStorageScheme::PostgresOnly.to_string(),};let req_cs = Some("1".to_string());let merchant_fulfillment_time = Some(10);@@ -2831,6 +2839,7 @@ impl AttemptType {payment_method_data: &Option<api_models::payments::PaymentMethodData>,old_payment_attempt: PaymentAttempt,new_attempt_count: i16,+ storage_scheme: enums::MerchantStorageScheme,) -> storage::PaymentAttemptNew {let created_at @ modified_at @ last_synced = Some(common_utils::date_time::now());@@ -2892,6 +2901,7 @@ impl AttemptType {connector_response_reference_id: None,amount_capturable: old_payment_attempt.amount,surcharge_metadata: old_payment_attempt.surcharge_metadata,+ updated_by: storage_scheme.to_string(),}}@@ -2914,6 +2924,7 @@ impl AttemptType {&request.payment_method_data,fetched_payment_attempt,new_attempt_count,+ storage_scheme,),storage_scheme,)@@ -2932,6 +2943,7 @@ impl AttemptType {),active_attempt_id: new_payment_attempt.attempt_id.clone(),attempt_count: new_attempt_count,+ updated_by: storage_scheme.to_string(),},storage_scheme,)diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rsindex 5b7b475988..a1d50a9049 100644--- a/crates/router/src/core/payments/operations/payment_approve.rs+++ b/crates/router/src/core/payments/operations/payment_approve.rs@@ -364,6 +364,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>{let intent_status_update = storage::PaymentIntentUpdate::ApproveUpdate {merchant_decision: Some(api_models::enums::MerchantDecision::Approved.to_string()),+ updated_by: storage_scheme.to_string(),};payment_data.payment_intent = db.update_payment_intent(diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rsindex 9159153aee..43fdc440e6 100644--- a/crates/router/src/core/payments/operations/payment_cancel.rs+++ b/crates/router/src/core/payments/operations/payment_cancel.rs@@ -207,6 +207,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>if payment_data.payment_intent.status != enums::IntentStatus::RequiresCapture {let payment_intent_update = storage::PaymentIntentUpdate::PGStatusUpdate {status: enums::IntentStatus::Cancelled,+ updated_by: storage_scheme.to_string(),};(Some(payment_intent_update), enums::AttemptStatus::Voided)} else {@@ -229,6 +230,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>storage::PaymentAttemptUpdate::VoidUpdate {status: attempt_status_update,cancellation_reason,+ updated_by: storage_scheme.to_string(),},storage_scheme,)diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rsindex 63869781ba..eeb94f4558 100644--- a/crates/router/src/core/payments/operations/payment_capture.rs+++ b/crates/router/src/core/payments/operations/payment_capture.rs@@ -125,6 +125,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>capture.merchant_id.clone(),capture.capture_id.clone(),Some(capture.connector.clone()),+ storage_scheme.to_string(),),storage_scheme,)@@ -267,6 +268,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>payment_data.payment_attempt,storage::PaymentAttemptUpdate::MultipleCaptureCountUpdate {multiple_capture_count: multiple_capture_data.get_captures_count()?,+ updated_by: storage_scheme.to_string(),},storage_scheme,)diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 9ee079fbd0..a045cee354 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -564,6 +564,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>error_code,error_message,amount_capturable: Some(authorized_amount),+ updated_by: storage_scheme.to_string(),},storage_scheme,)@@ -589,6 +590,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>order_details,metadata,payment_confirm_source: header_payload.payment_confirm_source,+ updated_by: storage_scheme.to_string(),},storage_scheme,)diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 71127c28f7..2cc15fbfc3 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -440,6 +440,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>true => Some(authorized_amount),false => None,},+ updated_by: storage_scheme.to_string(),},storage_scheme,)@@ -457,6 +458,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>customer_id,shipping_address_id: None,billing_address_id: None,+ updated_by: storage_scheme.to_string(),},storage_scheme,)@@ -718,6 +720,7 @@ impl PaymentCreate {merchant_decision: None,payment_link_id,payment_confirm_source: None,+ updated_by: merchant_account.storage_scheme.to_string(),})}@@ -735,6 +738,7 @@ impl PaymentCreate {connector_transaction_id: None,authentication_data: None,encoded_data: None,+ updated_by: payment_attempt.updated_by.clone(),}}diff --git a/crates/router/src/core/payments/operations/payment_method_validate.rs b/crates/router/src/core/payments/operations/payment_method_validate.rsindex 48bac48aac..6af25221b2 100644--- a/crates/router/src/core/payments/operations/payment_method_validate.rs+++ b/crates/router/src/core/payments/operations/payment_method_validate.rs@@ -104,6 +104,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>request.payment_method,request,state,+ merchant_account.storage_scheme,),storage_scheme,)@@ -122,6 +123,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>merchant_id,request,payment_attempt.attempt_id.clone(),+ merchant_account.storage_scheme,),storage_scheme,)@@ -246,6 +248,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve> UpdateTracker<F, PaymentData<F>, api:customer_id,shipping_address_id: None,billing_address_id: None,+ updated_by: storage_scheme.to_string(),},storage_scheme,)@@ -321,6 +324,7 @@ impl PaymentMethodValidate {payment_method: Option<api_enums::PaymentMethod>,_request: &api::VerifyRequest,state: &AppState,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> storage::PaymentAttemptNew {let created_at @ modified_at @ last_synced = Some(date_time::now());let status = storage_enums::AttemptStatus::Pending;@@ -347,6 +351,7 @@ impl PaymentMethodValidate {created_at,modified_at,last_synced,+ updated_by: storage_scheme.to_string(),..Default::default()}}@@ -356,6 +361,7 @@ impl PaymentMethodValidate {merchant_id: &str,request: &api::VerifyRequest,active_attempt_id: String,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> storage::PaymentIntentNew {let created_at @ modified_at @ last_synced = Some(date_time::now());let status = helpers::payment_intent_status_fsm(&request.payment_method_data, Some(true));@@ -396,6 +402,7 @@ impl PaymentMethodValidate {merchant_decision: Default::default(),payment_confirm_source: Default::default(),payment_link_id: Default::default(),+ updated_by: storage_scheme.to_string(),}}}diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rsindex 08731f5aa3..415ab3eccf 100644--- a/crates/router/src/core/payments/operations/payment_reject.rs+++ b/crates/router/src/core/payments/operations/payment_reject.rs@@ -191,6 +191,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>let intent_status_update = storage::PaymentIntentUpdate::RejectUpdate {status: enums::IntentStatus::Failed,merchant_decision: Some(enums::MerchantDecision::Rejected.to_string()),+ updated_by: storage_scheme.to_string(),};let (error_code, error_message) =payment_data@@ -206,6 +207,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>status: enums::AttemptStatus::Failure,error_code,error_message,+ updated_by: storage_scheme.to_string(),};payment_data.payment_intent = dbdiff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 6863af7ee5..af84152120 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -351,6 +351,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(} else {None},+ updated_by: storage_scheme.to_string(),}),)}@@ -360,6 +361,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(attempt_update,Some(storage::ConnectorResponseUpdate::ErrorUpdate {connector_name: Some(router_data.connector.clone()),+ updated_by: storage_scheme.to_string(),}),)}@@ -389,6 +391,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(preprocessing_step_id,connector_transaction_id,connector_response_reference_id,+ updated_by: storage_scheme.to_string(),};(None, Some(payment_attempt_update), None)@@ -474,6 +477,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(} else {None},+ updated_by: storage_scheme.to_string(),}),),};@@ -483,6 +487,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(authentication_data,encoded_data,connector_name: Some(connector_name),+ updated_by: storage_scheme.to_string(),};(@@ -512,6 +517,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(error_message: Some(reason.clone().map(|cd| cd.message)),error_reason: Some(reason.map(|cd| cd.message)),connector_response_reference_id,+ updated_by: storage_scheme.to_string(),}),None,)@@ -555,6 +561,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(status: multiple_capture_data.get_attempt_status(authorized_amount),amount_capturable: payment_data.payment_attempt.amount- multiple_capture_data.get_total_blocked_amount(),+ updated_by: storage_scheme.to_string(),});Some(multiple_capture_data)}@@ -610,6 +617,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(status: payment_data.payment_attempt.get_intent_status(payment_data.payment_intent.amount_captured),+ updated_by: storage_scheme.to_string(),},Ok(_) => storage::PaymentIntentUpdate::ResponseUpdate {status: payment_data@@ -617,6 +625,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(.get_intent_status(payment_data.payment_intent.amount_captured),return_url: router_data.return_url.clone(),amount_captured,+ updated_by: storage_scheme.to_string(),},};diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex b9f78cb81e..b5ed79b290 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -235,7 +235,10 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>Some(metadata) => db.update_payment_intent(payment_data.payment_intent,- storage::PaymentIntentUpdate::MetadataUpdate { metadata },+ storage::PaymentIntentUpdate::MetadataUpdate {+ metadata,+ updated_by: storage_scheme.to_string(),+ },storage_scheme,).awaitdiff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 257793ce78..a77ede0e6f 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -498,6 +498,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>business_sub_label,amount_to_capture,capture_method,+ updated_by: storage_scheme.to_string(),},storage_scheme,)@@ -560,6 +561,7 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>order_details,metadata,payment_confirm_source: None,+ updated_by: storage_scheme.to_string(),},storage_scheme,)diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rsindex 4f1537d5f4..4085b5b3bd 100644--- a/crates/router/src/core/refunds.rs+++ b/crates/router/src/core/refunds.rs@@ -132,6 +132,7 @@ pub async fn trigger_refund_to_gateway(.into_report().attach_printable("Failed to retrieve connector from payment attempt")?;+ let storage_scheme = merchant_account.storage_scheme;metrics::REFUND_COUNT.add(&metrics::CONTEXT,1,@@ -206,6 +207,7 @@ pub async fn trigger_refund_to_gateway(refund_status: Some(enums::RefundStatus::Failure),refund_error_message: err.reason.or(Some(err.message)),refund_error_code: Some(err.code),+ updated_by: storage_scheme.to_string(),},Ok(response) => {if response.refund_status == diesel_models::enums::RefundStatus::Success {@@ -224,6 +226,7 @@ pub async fn trigger_refund_to_gateway(sent_to_gateway: true,refund_error_message: None,refund_arn: "".to_string(),+ updated_by: storage_scheme.to_string(),}}};@@ -381,6 +384,8 @@ pub async fn sync_refund_with_gateway(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to get the connector")?;+ let storage_scheme = merchant_account.storage_scheme;+let currency = payment_attempt.currency.get_required_value("currency")?;let mut router_data = core_utils::construct_refund_router_data::<api::RSync>(@@ -434,6 +439,7 @@ pub async fn sync_refund_with_gateway(refund_status: None,refund_error_message: error_message.reason.or(Some(error_message.message)),refund_error_code: Some(error_message.code),+ updated_by: storage_scheme.to_string(),},Ok(response) => storage::RefundUpdate::Update {connector_refund_id: response.connector_refund_id,@@ -441,6 +447,7 @@ pub async fn sync_refund_with_gateway(sent_to_gateway: true,refund_error_message: None,refund_arn: "".to_string(),+ updated_by: storage_scheme.to_string(),},};@@ -486,6 +493,7 @@ pub async fn refund_update_core(storage::RefundUpdate::MetadataAndReasonUpdate {metadata: req.metadata,reason: req.reason,+ updated_by: merchant_account.storage_scheme.to_string(),},merchant_account.storage_scheme,)diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rsindex 7540845c34..2e763751f4 100644--- a/crates/router/src/core/webhooks.rs+++ b/crates/router/src/core/webhooks.rs@@ -226,6 +226,7 @@ pub async fn refunds_incoming_webhook_flow<W: types::OutgoingWebhookType>(.into_report().change_context(errors::ApiErrorResponse::WebhookProcessingFailure).attach_printable("failed refund status mapping from event type")?,+ updated_by: merchant_account.storage_scheme.to_string(),};db.update_refund(refund.to_owned(),diff --git a/crates/router/src/db/address.rs b/crates/router/src/db/address.rsindex 4e09471ede..20f7bdb912 100644--- a/crates/router/src/db/address.rs+++ b/crates/router/src/db/address.rs@@ -1,5 +1,4 @@-use data_models::MerchantStorageScheme;-use diesel_models::address::AddressUpdateInternal;+use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme};use error_stack::ResultExt;use router_env::{instrument, tracing};@@ -78,7 +77,6 @@ where#[cfg(not(feature = "kv_store"))]mod storage {use common_utils::ext_traits::AsyncExt;- use data_models::MerchantStorageScheme;use error_stack::{IntoReport, ResultExt};use router_env::{instrument, tracing};@@ -92,7 +90,7 @@ mod storage {self,behaviour::{Conversion, ReverseConversion},},- storage::{self as storage_types},+ storage::{self as storage_types, enums::MerchantStorageScheme},},};#[async_trait::async_trait]@@ -275,8 +273,7 @@ mod storage {#[cfg(feature = "kv_store")]mod storage {use common_utils::ext_traits::AsyncExt;- use data_models::MerchantStorageScheme;- use diesel_models::AddressUpdateInternal;+ use diesel_models::{enums::MerchantStorageScheme, AddressUpdateInternal};use error_stack::{IntoReport, ResultExt};use redis_interface::HsetnxReply;use router_env::{instrument, tracing};@@ -503,6 +500,7 @@ mod storage {customer_id: address_new.customer_id.clone(),merchant_id: address_new.merchant_id.clone(),payment_id: address_new.payment_id.clone(),+ updated_by: storage_scheme.to_string(),};let redis_entry = kv::TypedSql {diff --git a/crates/router/src/db/connector_response.rs b/crates/router/src/db/connector_response.rsindex 3151d72d73..354231d136 100644--- a/crates/router/src/db/connector_response.rs+++ b/crates/router/src/db/connector_response.rs@@ -97,6 +97,7 @@ mod storage {#[cfg(feature = "kv_store")]mod storage {+ use diesel_models::enums as storage_enums;use error_stack::{IntoReport, ResultExt};use redis_interface::HsetnxReply;use router_env::{instrument, tracing};@@ -121,12 +122,12 @@ mod storage {let conn = connection::pg_connection_write(self).await?;match storage_scheme {- data_models::MerchantStorageScheme::PostgresOnly => connector_response+ storage_enums::MerchantStorageScheme::PostgresOnly => connector_response.insert(&conn).await.map_err(Into::into).into_report(),- data_models::MerchantStorageScheme::RedisKv => {+ storage_enums::MerchantStorageScheme::RedisKv => {let merchant_id = &connector_response.merchant_id;let payment_id = &connector_response.payment_id;let attempt_id = &connector_response.attempt_id;@@ -147,6 +148,7 @@ mod storage {.clone(),authentication_data: connector_response.authentication_data.clone(),encoded_data: connector_response.encoded_data.clone(),+ updated_by: storage_scheme.to_string(),};let redis_entry = kv::TypedSql {@@ -199,8 +201,8 @@ mod storage {.into_report()};match storage_scheme {- data_models::MerchantStorageScheme::PostgresOnly => database_call().await,- data_models::MerchantStorageScheme::RedisKv => {+ storage_enums::MerchantStorageScheme::PostgresOnly => database_call().await,+ storage_enums::MerchantStorageScheme::RedisKv => {let key = format!("mid_{merchant_id}_pid_{payment_id}");let field = format!("connector_resp_{merchant_id}_{payment_id}_{attempt_id}");@@ -229,12 +231,12 @@ mod storage {) -> CustomResult<storage_type::ConnectorResponse, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;match storage_scheme {- data_models::MerchantStorageScheme::PostgresOnly => this+ storage_enums::MerchantStorageScheme::PostgresOnly => this.update(&conn, connector_response_update).await.map_err(Into::into).into_report(),- data_models::MerchantStorageScheme::RedisKv => {+ storage_enums::MerchantStorageScheme::RedisKv => {let key = format!("mid_{}_pid_{}", this.merchant_id, this.payment_id);let updated_connector_response = connector_response_update.clone()@@ -286,7 +288,7 @@ impl ConnectorResponseInterface for MockDb {async fn insert_connector_response(&self,new: storage_type::ConnectorResponseNew,- _storage_scheme: enums::MerchantStorageScheme,+ storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_type::ConnectorResponse, errors::StorageError> {let mut connector_response = self.connector_response.lock().await;let response = storage_type::ConnectorResponse {@@ -304,6 +306,7 @@ impl ConnectorResponseInterface for MockDb {connector_transaction_id: new.connector_transaction_id,authentication_data: new.authentication_data,encoded_data: new.encoded_data,+ updated_by: storage_scheme.to_string(),};connector_response.push(response.clone());Ok(response)diff --git a/crates/router/src/db/refund.rs b/crates/router/src/db/refund.rsindex 819938ea67..ae586a48ad 100644--- a/crates/router/src/db/refund.rs+++ b/crates/router/src/db/refund.rs@@ -367,6 +367,7 @@ mod storage {description: new.description.clone(),refund_reason: new.refund_reason.clone(),profile_id: new.profile_id.clone(),+ updated_by: new.updated_by.clone(),};let field = format!(@@ -408,6 +409,7 @@ mod storage {),pk_id: key.clone(),source: "refund".to_string(),+ updated_by: storage_scheme.to_string(),},// [#492]: A discussion is required on whether this is required?storage_types::ReverseLookupNew {@@ -419,6 +421,7 @@ mod storage {),pk_id: key.clone(),source: "refund".to_string(),+ updated_by: storage_scheme.to_string(),},];if let Some(connector_refund_id) =@@ -434,6 +437,7 @@ mod storage {),pk_id: key,source: "refund".to_string(),+ updated_by: storage_scheme.to_string(),})};let rev_look = reverse_lookups@@ -791,6 +795,7 @@ impl RefundInterface for MockDb {description: new.description,refund_reason: new.refund_reason.clone(),profile_id: new.profile_id,+ updated_by: new.updated_by,};refunds.push(refund.clone());Ok(refund)diff --git a/crates/router/src/db/reverse_lookup.rs b/crates/router/src/db/reverse_lookup.rsindex f7ada48a40..4a4056032b 100644--- a/crates/router/src/db/reverse_lookup.rs+++ b/crates/router/src/db/reverse_lookup.rs@@ -85,16 +85,17 @@ mod storage {storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<ReverseLookup, errors::StorageError> {match storage_scheme {- data_models::MerchantStorageScheme::PostgresOnly => {+ enums::MerchantStorageScheme::PostgresOnly => {let conn = connection::pg_connection_write(self).await?;new.insert(&conn).await.map_err(Into::into).into_report()}- data_models::MerchantStorageScheme::RedisKv => {+ enums::MerchantStorageScheme::RedisKv => {let created_rev_lookup = ReverseLookup {lookup_id: new.lookup_id.clone(),sk_id: new.sk_id.clone(),pk_id: new.pk_id.clone(),source: new.source.clone(),+ updated_by: storage_scheme.to_string(),};let redis_entry = kv::TypedSql {op: kv::DBOperation::Insert {@@ -137,8 +138,8 @@ mod storage {};match storage_scheme {- data_models::MerchantStorageScheme::PostgresOnly => database_call().await,- data_models::MerchantStorageScheme::RedisKv => {+ enums::MerchantStorageScheme::PostgresOnly => database_call().await,+ enums::MerchantStorageScheme::RedisKv => {let redis_fut = async {kv_wrapper(self,diff --git a/crates/router/src/types/domain/address.rs b/crates/router/src/types/domain/address.rsindex bd9d034e8c..008cead1eb 100644--- a/crates/router/src/types/domain/address.rs+++ b/crates/router/src/types/domain/address.rs@@ -38,6 +38,7 @@ pub struct Address {pub customer_id: String,pub merchant_id: String,pub payment_id: Option<String>,+ pub updated_by: String,}#[async_trait]@@ -65,6 +66,7 @@ impl behaviour::Conversion for Address {customer_id: self.customer_id,merchant_id: self.merchant_id,payment_id: self.payment_id,+ updated_by: self.updated_by,})}@@ -93,6 +95,7 @@ impl behaviour::Conversion for Address {customer_id: other.customer_id,merchant_id: other.merchant_id,payment_id: other.payment_id,+ updated_by: other.updated_by,})}.await@@ -121,6 +124,7 @@ impl behaviour::Conversion for Address {payment_id: self.payment_id,created_at: now,modified_at: now,+ updated_by: self.updated_by,})}}@@ -139,6 +143,7 @@ pub enum AddressUpdate {last_name: crypto::OptionalEncryptableSecretString,phone_number: crypto::OptionalEncryptableSecretString,country_code: Option<String>,+ updated_by: String,},}@@ -157,6 +162,7 @@ impl From<AddressUpdate> for AddressUpdateInternal {last_name,phone_number,country_code,+ updated_by,} => Self {city,country,@@ -170,6 +176,7 @@ impl From<AddressUpdate> for AddressUpdateInternal {phone_number: phone_number.map(Encryption::from),country_code,modified_at: date_time::convert_to_pdt(OffsetDateTime::now_utc()),+ updated_by,},}}diff --git a/crates/router/src/types/domain/merchant_account.rs b/crates/router/src/types/domain/merchant_account.rsindex 326a2e4290..cbcd70aaef 100644--- a/crates/router/src/types/domain/merchant_account.rs+++ b/crates/router/src/types/domain/merchant_account.rs@@ -4,12 +4,13 @@ use common_utils::{ext_traits::ValueExt,pii,};-use data_models::MerchantStorageScheme;-use diesel_models::{encryption::Encryption, merchant_account::MerchantAccountUpdateInternal};+use diesel_models::{+ encryption::Encryption, enums::MerchantStorageScheme,+ merchant_account::MerchantAccountUpdateInternal,+};use error_stack::ResultExt;use masking::{PeekInterface, Secret};use router_env::logger;-use storage_impl::DataModelExt;use crate::{errors::{CustomResult, ValidationError},@@ -127,7 +128,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {..Default::default()},MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self {- storage_scheme: Some(storage_scheme.to_storage_model()),+ storage_scheme: Some(storage_scheme),modified_at: Some(date_time::now()),..Default::default()},@@ -163,7 +164,7 @@ impl super::behaviour::Conversion for MerchantAccount {sub_merchants_enabled: self.sub_merchants_enabled,parent_merchant_id: self.parent_merchant_id,publishable_key: self.publishable_key,- storage_scheme: self.storage_scheme.to_storage_model(),+ storage_scheme: self.storage_scheme,locker_id: self.locker_id,metadata: self.metadata,routing_algorithm: self.routing_algorithm,@@ -208,7 +209,7 @@ impl super::behaviour::Conversion for MerchantAccount {sub_merchants_enabled: item.sub_merchants_enabled,parent_merchant_id: item.parent_merchant_id,publishable_key: item.publishable_key,- storage_scheme: MerchantStorageScheme::from_storage_model(item.storage_scheme),+ storage_scheme: item.storage_scheme,locker_id: item.locker_id,metadata: item.metadata,routing_algorithm: item.routing_algorithm,diff --git a/crates/router/src/types/storage/connector_response.rs b/crates/router/src/types/storage/connector_response.rsindex 1017d406a9..c93c231e3d 100644--- a/crates/router/src/types/storage/connector_response.rs+++ b/crates/router/src/types/storage/connector_response.rs@@ -1,6 +1,9 @@-pub use diesel_models::connector_response::{- ConnectorResponse, ConnectorResponseNew, ConnectorResponseUpdate,- ConnectorResponseUpdateInternal,+pub use diesel_models::{+ connector_response::{+ ConnectorResponse, ConnectorResponseNew, ConnectorResponseUpdate,+ ConnectorResponseUpdateInternal,+ },+ enums::MerchantStorageScheme,};pub trait ConnectorResponseExt {@@ -9,6 +12,7 @@ pub trait ConnectorResponseExt {merchant_id: String,attempt_id: String,connector: Option<String>,+ storage_scheme: String,) -> ConnectorResponseNew;}@@ -18,6 +22,7 @@ impl ConnectorResponseExt for ConnectorResponse {merchant_id: String,attempt_id: String,connector: Option<String>,+ storage_scheme: String,) -> ConnectorResponseNew {let now = common_utils::date_time::now();ConnectorResponseNew {@@ -30,6 +35,7 @@ impl ConnectorResponseExt for ConnectorResponse {connector_transaction_id: None,authentication_data: None,encoded_data: None,+ updated_by: storage_scheme,}}}diff --git a/crates/router/src/types/storage/enums.rs b/crates/router/src/types/storage/enums.rsindex 472fd94710..9c7d02cdce 100644--- a/crates/router/src/types/storage/enums.rs+++ b/crates/router/src/types/storage/enums.rs@@ -1,2 +1 @@-pub use data_models::MerchantStorageScheme;pub use diesel_models::enums::*;diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rsindex fa92cd1119..0f5fbeb465 100644--- a/crates/router/src/utils.rs+++ b/crates/router/src/utils.rs@@ -454,6 +454,7 @@ pub trait CustomerAddress {&self,address_details: api_models::payments::AddressDetails,key: &[u8],+ storage_scheme: storage::enums::MerchantStorageScheme,) -> CustomResult<storage::AddressUpdate, common_utils::errors::CryptoError>;async fn get_domain_address(@@ -462,6 +463,7 @@ pub trait CustomerAddress {merchant_id: &str,customer_id: &str,key: &[u8],+ storage_scheme: storage::enums::MerchantStorageScheme,) -> CustomResult<domain::Address, common_utils::errors::CryptoError>;}@@ -471,6 +473,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {&self,address_details: api_models::payments::AddressDetails,key: &[u8],+ storage_scheme: storage::enums::MerchantStorageScheme,) -> CustomResult<storage::AddressUpdate, common_utils::errors::CryptoError> {async {Ok(storage::AddressUpdate::Update {@@ -510,6 +513,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {.async_lift(|inner| encrypt_optional(inner, key)).await?,country_code: self.phone_country_code.clone(),+ updated_by: storage_scheme.to_string(),})}.await@@ -521,6 +525,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {merchant_id: &str,customer_id: &str,key: &[u8],+ storage_scheme: storage::enums::MerchantStorageScheme,) -> CustomResult<domain::Address, common_utils::errors::CryptoError> {async {Ok(domain::Address {@@ -567,6 +572,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {payment_id: None,created_at: common_utils::date_time::now(),modified_at: common_utils::date_time::now(),+ updated_by: storage_scheme.to_string(),})}.awaitdiff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rsindex 4ca0c4bccd..1e77089e0a 100644--- a/crates/router/src/workflows/payment_sync.rs+++ b/crates/router/src/workflows/payment_sync.rs@@ -117,7 +117,7 @@ impl ProcessTrackerWorkflow<AppState> for PaymentsSyncWorkflow {.as_ref().is_none(){- let payment_intent_update = data_models::payments::payment_intent::PaymentIntentUpdate::PGStatusUpdate { status: api_models::enums::IntentStatus::Failed };+ let payment_intent_update = data_models::payments::payment_intent::PaymentIntentUpdate::PGStatusUpdate { status: api_models::enums::IntentStatus::Failed,updated_by: merchant_account.storage_scheme.to_string() };let payment_attempt_update =data_models::payments::payment_attempt::PaymentAttemptUpdate::ErrorUpdate {connector: None,@@ -128,6 +128,7 @@ impl ProcessTrackerWorkflow<AppState> for PaymentsSyncWorkflow {consts::REQUEST_TIMEOUT_ERROR_MESSAGE_FROM_PSYNC.to_string(),)),amount_capturable: Some(0),+ updated_by: merchant_account.storage_scheme.to_string(),};payment_data.payment_attempt = dbdiff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rsindex 58f4d4956f..dd8d71fc70 100644--- a/crates/storage_impl/src/lib.rs+++ b/crates/storage_impl/src/lib.rs@@ -225,24 +225,6 @@ pub trait DataModelExt {fn from_storage_model(storage_model: Self::StorageModel) -> Self;}-impl DataModelExt for data_models::MerchantStorageScheme {- type StorageModel = diesel_models::enums::MerchantStorageScheme;-- fn to_storage_model(self) -> Self::StorageModel {- match self {- Self::PostgresOnly => diesel_models::enums::MerchantStorageScheme::PostgresOnly,- Self::RedisKv => diesel_models::enums::MerchantStorageScheme::RedisKv,- }- }-- fn from_storage_model(storage_model: Self::StorageModel) -> Self {- match storage_model {- diesel_models::enums::MerchantStorageScheme::PostgresOnly => Self::PostgresOnly,- diesel_models::enums::MerchantStorageScheme::RedisKv => Self::RedisKv,- }- }-}-pub(crate) fn diesel_error_to_data_error(diesel_error: &diesel_models::errors::DatabaseError,) -> StorageError {diff --git a/crates/storage_impl/src/lookup.rs b/crates/storage_impl/src/lookup.rsindex a01c5d900e..dbfd77a8d6 100644--- a/crates/storage_impl/src/lookup.rs+++ b/crates/storage_impl/src/lookup.rs@@ -1,7 +1,7 @@use common_utils::errors::CustomResult;use data_models::errors;use diesel_models::{- kv,+ enums as storage_enums, kv,reverse_lookup::{ReverseLookup as DieselReverseLookup, ReverseLookupNew as DieselReverseLookupNew,},@@ -21,12 +21,12 @@ pub trait ReverseLookupInterface {async fn insert_reverse_lookup(&self,_new: DieselReverseLookupNew,- storage_scheme: data_models::MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<DieselReverseLookup, errors::StorageError>;async fn get_lookup_by_lookup_id(&self,_id: &str,- storage_scheme: data_models::MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<DieselReverseLookup, errors::StorageError>;}@@ -35,7 +35,7 @@ impl<T: DatabaseStore> ReverseLookupInterface for RouterStore<T> {async fn insert_reverse_lookup(&self,new: DieselReverseLookupNew,- _storage_scheme: data_models::MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<DieselReverseLookup, errors::StorageError> {let conn = self.get_master_pool()@@ -52,7 +52,7 @@ impl<T: DatabaseStore> ReverseLookupInterface for RouterStore<T> {async fn get_lookup_by_lookup_id(&self,id: &str,- _storage_scheme: data_models::MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<DieselReverseLookup, errors::StorageError> {let conn = utils::pg_connection_read(self).await?;DieselReverseLookup::find_by_lookup_id(id, &conn)@@ -69,20 +69,21 @@ impl<T: DatabaseStore> ReverseLookupInterface for KVRouterStore<T> {async fn insert_reverse_lookup(&self,new: DieselReverseLookupNew,- storage_scheme: data_models::MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<DieselReverseLookup, errors::StorageError> {match storage_scheme {- data_models::MerchantStorageScheme::PostgresOnly => {+ storage_enums::MerchantStorageScheme::PostgresOnly => {self.router_store.insert_reverse_lookup(new, storage_scheme).await}- data_models::MerchantStorageScheme::RedisKv => {+ storage_enums::MerchantStorageScheme::RedisKv => {let created_rev_lookup = DieselReverseLookup {lookup_id: new.lookup_id.clone(),sk_id: new.sk_id.clone(),pk_id: new.pk_id.clone(),source: new.source.clone(),+ updated_by: storage_scheme.to_string(),};let redis_entry = kv::TypedSql {op: kv::DBOperation::Insert {@@ -114,7 +115,7 @@ impl<T: DatabaseStore> ReverseLookupInterface for KVRouterStore<T> {async fn get_lookup_by_lookup_id(&self,id: &str,- storage_scheme: data_models::MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<DieselReverseLookup, errors::StorageError> {let database_call = || async {self.router_store@@ -122,8 +123,8 @@ impl<T: DatabaseStore> ReverseLookupInterface for KVRouterStore<T> {.await};match storage_scheme {- data_models::MerchantStorageScheme::PostgresOnly => database_call().await,- data_models::MerchantStorageScheme::RedisKv => {+ storage_enums::MerchantStorageScheme::PostgresOnly => database_call().await,+ storage_enums::MerchantStorageScheme::RedisKv => {let redis_fut = async {kv_wrapper(self,diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rsindex 21343bd31e..8674fd711a 100644--- a/crates/storage_impl/src/mock_db/payment_attempt.rs+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs@@ -5,8 +5,8 @@ use data_models::{payments::payment_attempt::{PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,},- MerchantStorageScheme,};+use diesel_models::enums as storage_enums;use super::MockDb;use crate::DataModelExt;@@ -18,7 +18,7 @@ impl PaymentAttemptInterface for MockDb {_payment_id: &str,_merchant_id: &str,_attempt_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -28,7 +28,7 @@ impl PaymentAttemptInterface for MockDb {&self,_pi: &[data_models::payments::PaymentIntent],_merchant_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<data_models::payments::payment_attempt::PaymentListFilters, StorageError>{Err(StorageError::MockDbError)?@@ -42,7 +42,7 @@ impl PaymentAttemptInterface for MockDb {_payment_method: Option<Vec<PaymentMethod>>,_payment_method_type: Option<Vec<PaymentMethodType>>,_authentication_type: Option<Vec<AuthenticationType>>,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<i64, StorageError> {Err(StorageError::MockDbError)?}@@ -51,7 +51,7 @@ impl PaymentAttemptInterface for MockDb {&self,_attempt_id: &str,_merchant_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -61,7 +61,7 @@ impl PaymentAttemptInterface for MockDb {&self,_preprocessing_id: &str,_merchant_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -71,7 +71,7 @@ impl PaymentAttemptInterface for MockDb {&self,_merchant_id: &str,_connector_txn_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -81,7 +81,7 @@ impl PaymentAttemptInterface for MockDb {&self,_merchant_id: &str,_payment_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Vec<PaymentAttempt>, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -91,7 +91,7 @@ impl PaymentAttemptInterface for MockDb {async fn insert_payment_attempt(&self,payment_attempt: PaymentAttemptNew,- _storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {let mut payment_attempts = self.payment_attempts.lock().await;#[allow(clippy::as_conversions)]@@ -141,6 +141,7 @@ impl PaymentAttemptInterface for MockDb {connector_response_reference_id: None,amount_capturable: payment_attempt.amount_capturable,surcharge_metadata: payment_attempt.surcharge_metadata,+ updated_by: storage_scheme.to_string(),};payment_attempts.push(payment_attempt.clone());Ok(payment_attempt)@@ -152,7 +153,7 @@ impl PaymentAttemptInterface for MockDb {&self,this: PaymentAttempt,payment_attempt: PaymentAttemptUpdate,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {let mut payment_attempts = self.payment_attempts.lock().await;@@ -175,7 +176,7 @@ impl PaymentAttemptInterface for MockDb {_connector_transaction_id: &str,_payment_id: &str,_merchant_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -187,7 +188,7 @@ impl PaymentAttemptInterface for MockDb {&self,payment_id: &str,merchant_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {let payment_attempts = self.payment_attempts.lock().await;diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rsindex 692847e14e..edc17a0cf5 100644--- a/crates/storage_impl/src/mock_db/payment_intent.rs+++ b/crates/storage_impl/src/mock_db/payment_intent.rs@@ -6,8 +6,8 @@ use data_models::{payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},PaymentIntent,},- MerchantStorageScheme,};+use diesel_models::enums as storage_enums;use error_stack::{IntoReport, ResultExt};use super::MockDb;@@ -19,7 +19,7 @@ impl PaymentIntentInterface for MockDb {&self,_merchant_id: &str,_filters: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Vec<PaymentIntent>, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -29,7 +29,7 @@ impl PaymentIntentInterface for MockDb {&self,_merchant_id: &str,_time_range: &api_models::payments::TimeRange,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Vec<PaymentIntent>, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -39,7 +39,7 @@ impl PaymentIntentInterface for MockDb {&self,_merchant_id: &str,_constraints: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<String>, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -49,7 +49,7 @@ impl PaymentIntentInterface for MockDb {&self,_merchant_id: &str,_constraints: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {// [#172]: Implement function for `MockDb`Err(StorageError::MockDbError)?@@ -59,7 +59,7 @@ impl PaymentIntentInterface for MockDb {async fn insert_payment_intent(&self,new: PaymentIntentNew,- _storage_scheme: MerchantStorageScheme,+ storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentIntent, StorageError> {let mut payment_intents = self.payment_intents.lock().await;let time = common_utils::date_time::now();@@ -103,6 +103,7 @@ impl PaymentIntentInterface for MockDb {merchant_decision: new.merchant_decision,payment_link_id: new.payment_link_id,payment_confirm_source: new.payment_confirm_source,+ updated_by: storage_scheme.to_string(),};payment_intents.push(payment_intent.clone());Ok(payment_intent)@@ -114,7 +115,7 @@ impl PaymentIntentInterface for MockDb {&self,this: PaymentIntent,update: PaymentIntentUpdate,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentIntent, StorageError> {let mut payment_intents = self.payment_intents.lock().await;let payment_intent = payment_intents@@ -131,7 +132,7 @@ impl PaymentIntentInterface for MockDb {&self,payment_id: &str,merchant_id: &str,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentIntent, StorageError> {let payment_intents = self.payment_intents.lock().await;@@ -147,7 +148,7 @@ impl PaymentIntentInterface for MockDb {async fn get_active_payment_attempt(&self,payment: &mut PaymentIntent,- _storage_scheme: MerchantStorageScheme,+ _storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, StorageError> {match payment.active_attempt.clone() {data_models::RemoteStorageObject::ForeignID(id) => {diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rsindex 2a483ca527..e1311bda67 100644--- a/crates/storage_impl/src/payments/payment_attempt.rs+++ b/crates/storage_impl/src/payments/payment_attempt.rs@@ -10,10 +10,12 @@ use data_models::{},PaymentIntent,},- MerchantStorageScheme,};use diesel_models::{- enums::{MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType},+ enums::{+ MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType,+ MerchantStorageScheme,+ },kv,payment_attempt::{PaymentAttempt as DieselPaymentAttempt, PaymentAttemptNew as DieselPaymentAttemptNew,@@ -359,6 +361,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {connector_response_reference_id: None,amount_capturable: payment_attempt.amount_capturable,surcharge_metadata: payment_attempt.surcharge_metadata.clone(),+ updated_by: storage_scheme.to_string(),};let field = format!("pa_{}", created_attempt.attempt_id);@@ -399,6 +402,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {pk_id: key,sk_id: field,source: "payment_attempt".to_string(),+ updated_by: storage_scheme.to_string(),};self.insert_reverse_lookup(reverse_lookup, storage_scheme).await?;@@ -953,6 +957,7 @@ impl DataModelExt for PaymentAttempt {connector_response_reference_id: self.connector_response_reference_id,amount_capturable: self.amount_capturable,surcharge_metadata: self.surcharge_metadata,+ updated_by: self.updated_by,}}@@ -1002,6 +1007,7 @@ impl DataModelExt for PaymentAttempt {connector_response_reference_id: storage_model.connector_response_reference_id,amount_capturable: storage_model.amount_capturable,surcharge_metadata: storage_model.surcharge_metadata,+ updated_by: storage_model.updated_by,}}}@@ -1051,6 +1057,7 @@ impl DataModelExt for PaymentAttemptNew {multiple_capture_count: self.multiple_capture_count,amount_capturable: self.amount_capturable,surcharge_metadata: self.surcharge_metadata,+ updated_by: self.updated_by,}}@@ -1098,6 +1105,7 @@ impl DataModelExt for PaymentAttemptNew {multiple_capture_count: storage_model.multiple_capture_count,amount_capturable: storage_model.amount_capturable,surcharge_metadata: storage_model.surcharge_metadata,+ updated_by: storage_model.updated_by,}}}@@ -1120,6 +1128,7 @@ impl DataModelExt for PaymentAttemptUpdate {business_sub_label,amount_to_capture,capture_method,+ updated_by,} => DieselPaymentAttemptUpdate::Update {amount,currency,@@ -1133,22 +1142,27 @@ impl DataModelExt for PaymentAttemptUpdate {business_sub_label,amount_to_capture,capture_method,+ updated_by,},Self::UpdateTrackers {payment_token,connector,straight_through_algorithm,amount_capturable,+ updated_by,} => DieselPaymentAttemptUpdate::UpdateTrackers {payment_token,connector,straight_through_algorithm,amount_capturable,+ updated_by,},Self::AuthenticationTypeUpdate {authentication_type,+ updated_by,} => DieselPaymentAttemptUpdate::AuthenticationTypeUpdate {authentication_type,+ updated_by,},Self::ConfirmUpdate {amount,@@ -1167,6 +1181,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_code,error_message,amount_capturable,+ updated_by,} => DieselPaymentAttemptUpdate::ConfirmUpdate {amount,currency,@@ -1184,13 +1199,16 @@ impl DataModelExt for PaymentAttemptUpdate {error_code,error_message,amount_capturable,+ updated_by,},Self::VoidUpdate {status,cancellation_reason,+ updated_by,} => DieselPaymentAttemptUpdate::VoidUpdate {status,cancellation_reason,+ updated_by,},Self::ResponseUpdate {status,@@ -1206,6 +1224,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_reason,connector_response_reference_id,amount_capturable,+ updated_by,} => DieselPaymentAttemptUpdate::ResponseUpdate {status,connector,@@ -1220,6 +1239,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_reason,connector_response_reference_id,amount_capturable,+ updated_by,},Self::UnresolvedResponseUpdate {status,@@ -1230,6 +1250,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_message,error_reason,connector_response_reference_id,+ updated_by,} => DieselPaymentAttemptUpdate::UnresolvedResponseUpdate {status,connector,@@ -1239,8 +1260,11 @@ impl DataModelExt for PaymentAttemptUpdate {error_message,error_reason,connector_response_reference_id,+ updated_by,},- Self::StatusUpdate { status } => DieselPaymentAttemptUpdate::StatusUpdate { status },+ Self::StatusUpdate { status, updated_by } => {+ DieselPaymentAttemptUpdate::StatusUpdate { status, updated_by }+ }Self::ErrorUpdate {connector,status,@@ -1248,6 +1272,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_message,error_reason,amount_capturable,+ updated_by,} => DieselPaymentAttemptUpdate::ErrorUpdate {connector,status,@@ -1255,11 +1280,14 @@ impl DataModelExt for PaymentAttemptUpdate {error_message,error_reason,amount_capturable,+ updated_by,},Self::MultipleCaptureCountUpdate {multiple_capture_count,+ updated_by,} => DieselPaymentAttemptUpdate::MultipleCaptureCountUpdate {multiple_capture_count,+ updated_by,},Self::PreprocessingUpdate {status,@@ -1268,6 +1296,7 @@ impl DataModelExt for PaymentAttemptUpdate {preprocessing_step_id,connector_transaction_id,connector_response_reference_id,+ updated_by,} => DieselPaymentAttemptUpdate::PreprocessingUpdate {status,payment_method_id,@@ -1275,32 +1304,43 @@ impl DataModelExt for PaymentAttemptUpdate {preprocessing_step_id,connector_transaction_id,connector_response_reference_id,+ updated_by,},Self::RejectUpdate {status,error_code,error_message,+ updated_by,} => DieselPaymentAttemptUpdate::RejectUpdate {status,error_code,error_message,+ updated_by,},Self::AmountToCaptureUpdate {status,amount_capturable,+ updated_by,} => DieselPaymentAttemptUpdate::AmountToCaptureUpdate {status,amount_capturable,+ updated_by,+ },+ Self::SurchargeMetadataUpdate {+ surcharge_metadata,+ updated_by,+ } => DieselPaymentAttemptUpdate::SurchargeMetadataUpdate {+ surcharge_metadata,+ updated_by,},- Self::SurchargeMetadataUpdate { surcharge_metadata } => {- DieselPaymentAttemptUpdate::SurchargeMetadataUpdate { surcharge_metadata }- }Self::SurchargeAmountUpdate {surcharge_amount,tax_amount,+ updated_by,} => DieselPaymentAttemptUpdate::SurchargeAmountUpdate {surcharge_amount,tax_amount,+ updated_by,},}}@@ -1320,6 +1360,7 @@ impl DataModelExt for PaymentAttemptUpdate {business_sub_label,amount_to_capture,capture_method,+ updated_by,} => Self::Update {amount,currency,@@ -1333,22 +1374,27 @@ impl DataModelExt for PaymentAttemptUpdate {business_sub_label,amount_to_capture,capture_method,+ updated_by,},DieselPaymentAttemptUpdate::UpdateTrackers {payment_token,connector,straight_through_algorithm,amount_capturable,+ updated_by,} => Self::UpdateTrackers {payment_token,connector,straight_through_algorithm,amount_capturable,+ updated_by,},DieselPaymentAttemptUpdate::AuthenticationTypeUpdate {authentication_type,+ updated_by,} => Self::AuthenticationTypeUpdate {authentication_type,+ updated_by,},DieselPaymentAttemptUpdate::ConfirmUpdate {amount,@@ -1367,6 +1413,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_code,error_message,amount_capturable,+ updated_by,} => Self::ConfirmUpdate {amount,currency,@@ -1384,13 +1431,16 @@ impl DataModelExt for PaymentAttemptUpdate {error_code,error_message,amount_capturable,+ updated_by,},DieselPaymentAttemptUpdate::VoidUpdate {status,cancellation_reason,+ updated_by,} => Self::VoidUpdate {status,cancellation_reason,+ updated_by,},DieselPaymentAttemptUpdate::ResponseUpdate {status,@@ -1406,6 +1456,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_reason,connector_response_reference_id,amount_capturable,+ updated_by,} => Self::ResponseUpdate {status,connector,@@ -1420,6 +1471,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_reason,connector_response_reference_id,amount_capturable,+ updated_by,},DieselPaymentAttemptUpdate::UnresolvedResponseUpdate {status,@@ -1430,6 +1482,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_message,error_reason,connector_response_reference_id,+ updated_by,} => Self::UnresolvedResponseUpdate {status,connector,@@ -1439,8 +1492,11 @@ impl DataModelExt for PaymentAttemptUpdate {error_message,error_reason,connector_response_reference_id,+ updated_by,},- DieselPaymentAttemptUpdate::StatusUpdate { status } => Self::StatusUpdate { status },+ DieselPaymentAttemptUpdate::StatusUpdate { status, updated_by } => {+ Self::StatusUpdate { status, updated_by }+ }DieselPaymentAttemptUpdate::ErrorUpdate {connector,status,@@ -1448,6 +1504,7 @@ impl DataModelExt for PaymentAttemptUpdate {error_message,error_reason,amount_capturable,+ updated_by,} => Self::ErrorUpdate {connector,status,@@ -1455,11 +1512,14 @@ impl DataModelExt for PaymentAttemptUpdate {error_message,error_reason,amount_capturable,+ updated_by,},DieselPaymentAttemptUpdate::MultipleCaptureCountUpdate {multiple_capture_count,+ updated_by,} => Self::MultipleCaptureCountUpdate {multiple_capture_count,+ updated_by,},DieselPaymentAttemptUpdate::PreprocessingUpdate {status,@@ -1468,6 +1528,7 @@ impl DataModelExt for PaymentAttemptUpdate {preprocessing_step_id,connector_transaction_id,connector_response_reference_id,+ updated_by,} => Self::PreprocessingUpdate {status,payment_method_id,@@ -1475,32 +1536,43 @@ impl DataModelExt for PaymentAttemptUpdate {preprocessing_step_id,connector_transaction_id,connector_response_reference_id,+ updated_by,},DieselPaymentAttemptUpdate::RejectUpdate {status,error_code,error_message,+ updated_by,} => Self::RejectUpdate {status,error_code,error_message,+ updated_by,},DieselPaymentAttemptUpdate::AmountToCaptureUpdate {status,amount_capturable,+ updated_by,} => Self::AmountToCaptureUpdate {status,amount_capturable,+ updated_by,+ },+ DieselPaymentAttemptUpdate::SurchargeMetadataUpdate {+ surcharge_metadata,+ updated_by,+ } => Self::SurchargeMetadataUpdate {+ surcharge_metadata,+ updated_by,},- DieselPaymentAttemptUpdate::SurchargeMetadataUpdate { surcharge_metadata } => {- Self::SurchargeMetadataUpdate { surcharge_metadata }- }DieselPaymentAttemptUpdate::SurchargeAmountUpdate {surcharge_amount,tax_amount,+ updated_by,} => Self::SurchargeAmountUpdate {surcharge_amount,tax_amount,+ updated_by,},}}@@ -1521,6 +1593,7 @@ async fn add_connector_txn_id_to_reverse_lookup<T: DatabaseStore>(pk_id: key.to_owned(),sk_id: field.clone(),source: "payment_attempt".to_string(),+ updated_by: storage_scheme.to_string(),};store.insert_reverse_lookup(reverse_lookup_new, storage_scheme)@@ -1542,6 +1615,7 @@ async fn add_preprocessing_id_to_reverse_lookup<T: DatabaseStore>(pk_id: key.to_owned(),sk_id: field.clone(),source: "payment_attempt".to_string(),+ updated_by: storage_scheme.to_string(),};store.insert_reverse_lookup(reverse_lookup_new, storage_scheme)diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rsindex 76097b3ea4..1d8b637720 100644--- a/crates/storage_impl/src/payments/payment_intent.rs+++ b/crates/storage_impl/src/payments/payment_intent.rs@@ -10,11 +10,12 @@ use data_models::{payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},PaymentIntent,},- MerchantStorageScheme, RemoteStorageObject,+ RemoteStorageObject,};#[cfg(feature = "olap")]use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};use diesel_models::{+ enums::MerchantStorageScheme,kv,payment_attempt::PaymentAttempt as DieselPaymentAttempt,payment_intent::{@@ -92,6 +93,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {merchant_decision: new.merchant_decision.clone(),payment_link_id: new.payment_link_id.clone(),payment_confirm_source: new.payment_confirm_source,+ updated_by: storage_scheme.to_string(),};let redis_entry = kv::TypedSql {op: kv::DBOperation::Insert {@@ -740,6 +742,7 @@ impl DataModelExt for PaymentIntentNew {merchant_decision: self.merchant_decision,payment_link_id: self.payment_link_id,payment_confirm_source: self.payment_confirm_source,+ updated_by: self.updated_by,}}@@ -778,6 +781,7 @@ impl DataModelExt for PaymentIntentNew {merchant_decision: storage_model.merchant_decision,payment_link_id: storage_model.payment_link_id,payment_confirm_source: storage_model.payment_confirm_source,+ updated_by: storage_model.updated_by,}}}@@ -821,6 +825,7 @@ impl DataModelExt for PaymentIntent {merchant_decision: self.merchant_decision,payment_link_id: self.payment_link_id,payment_confirm_source: self.payment_confirm_source,+ updated_by: self.updated_by,}}@@ -860,6 +865,7 @@ impl DataModelExt for PaymentIntent {merchant_decision: storage_model.merchant_decision,payment_link_id: storage_model.payment_link_id,payment_confirm_source: storage_model.payment_confirm_source,+ updated_by: storage_model.updated_by,}}}@@ -873,37 +879,49 @@ impl DataModelExt for PaymentIntentUpdate {status,amount_captured,return_url,+ updated_by,} => DieselPaymentIntentUpdate::ResponseUpdate {status,amount_captured,return_url,+ updated_by,+ },+ Self::MetadataUpdate {+ metadata,+ updated_by,+ } => DieselPaymentIntentUpdate::MetadataUpdate {+ metadata,+ updated_by,},- Self::MetadataUpdate { metadata } => {- DieselPaymentIntentUpdate::MetadataUpdate { metadata }- }Self::ReturnUrlUpdate {return_url,status,customer_id,shipping_address_id,billing_address_id,+ updated_by,} => DieselPaymentIntentUpdate::ReturnUrlUpdate {return_url,status,customer_id,shipping_address_id,billing_address_id,+ updated_by,},Self::MerchantStatusUpdate {status,shipping_address_id,billing_address_id,+ updated_by,} => DieselPaymentIntentUpdate::MerchantStatusUpdate {status,shipping_address_id,billing_address_id,+ updated_by,},- Self::PGStatusUpdate { status } => DieselPaymentIntentUpdate::PGStatusUpdate { status },+ Self::PGStatusUpdate { status, updated_by } => {+ DieselPaymentIntentUpdate::PGStatusUpdate { status, updated_by }+ }Self::Update {amount,currency,@@ -921,6 +939,7 @@ impl DataModelExt for PaymentIntentUpdate {order_details,metadata,payment_confirm_source,+ updated_by,} => DieselPaymentIntentUpdate::Update {amount,currency,@@ -938,32 +957,43 @@ impl DataModelExt for PaymentIntentUpdate {order_details,metadata,payment_confirm_source,+ updated_by,},Self::PaymentAttemptAndAttemptCountUpdate {active_attempt_id,attempt_count,+ updated_by,} => DieselPaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {active_attempt_id,attempt_count,+ updated_by,},Self::StatusAndAttemptUpdate {status,active_attempt_id,attempt_count,+ updated_by,} => DieselPaymentIntentUpdate::StatusAndAttemptUpdate {status,active_attempt_id,attempt_count,+ updated_by,+ },+ Self::ApproveUpdate {+ merchant_decision,+ updated_by,+ } => DieselPaymentIntentUpdate::ApproveUpdate {+ merchant_decision,+ updated_by,},- Self::ApproveUpdate { merchant_decision } => {- DieselPaymentIntentUpdate::ApproveUpdate { merchant_decision }- }Self::RejectUpdate {status,merchant_decision,+ updated_by,} => DieselPaymentIntentUpdate::RejectUpdate {status,merchant_decision,+ updated_by,},}}diff --git a/migrations/2023-10-13-090450_add_updated_by_for_tables/down.sql b/migrations/2023-10-13-090450_add_updated_by_for_tables/down.sqlnew file mode 100644index 0000000000..0c2706390e--- /dev/null+++ b/migrations/2023-10-13-090450_add_updated_by_for_tables/down.sql@@ -0,0 +1,13 @@+ALTER TABLE payment_intent DROP column updated_by;++ALTER TABLE payment_attempt DROP column updated_by;++ALTER TABLE reverse_lookup DROP column updated_by;++ALTER TABLE address DROP column updated_by;++ALTER TABLE connector_response DROP column updated_by;++ALTER TABLE refund DROP column updated_by;++diff --git a/migrations/2023-10-13-090450_add_updated_by_for_tables/up.sql b/migrations/2023-10-13-090450_add_updated_by_for_tables/up.sqlnew file mode 100644index 0000000000..cbacde479f--- /dev/null+++ b/migrations/2023-10-13-090450_add_updated_by_for_tables/up.sql@@ -0,0 +1,12 @@+ALTER TABLE payment_intent ADD column updated_by VARCHAR(32) NOT NULL DEFAULT 'postgres_only';++ALTER TABLE payment_attempt ADD column updated_by VARCHAR(32) NOT NULL DEFAULT 'postgres_only';++ALTER TABLE refund ADD column updated_by VARCHAR(32) NOT NULL DEFAULT 'postgres_only';++ALTER TABLE connector_response ADD column updated_by VARCHAR(32) NOT NULL DEFAULT 'postgres_only';++ALTER TABLE reverse_lookup ADD column updated_by VARCHAR(32) NOT NULL DEFAULT 'postgres_only';++ALTER TABLE address ADD column updated_by VARCHAR(32) NOT NULL DEFAULT 'postgres_only';+