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(payment-methods): add compatibility_updated_at field to payment methods (#12439)
Gaurav Rawatb04d0276d713
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 61144bdcaa..9a43429837 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -10306,8 +10306,7 @@"description": "The CVC number for the card\nThis is optional in case the card needs to be vaulted","example": "242"}- },- "additionalProperties": false+ }},"CardDetailFromLocker": {"type": "object",diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 90b4809200..5f3d08c982 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -879,7 +879,7 @@ pub enum CardType {// when the customer is on_session again, the cvc can be collected from the customer#[cfg(feature = "v2")]#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]-#[serde(deny_unknown_fields)]+// #[serde(deny_unknown_fields)]pub struct CardDetail {/// Card Number#[schema(value_type = String,example = "4111111145551142")]diff --git a/crates/diesel_models/src/payment_method.rs b/crates/diesel_models/src/payment_method.rsindex 2c9ed1f2b5..5c0f2f61b8 100644--- a/crates/diesel_models/src/payment_method.rs+++ b/crates/diesel_models/src/payment_method.rs@@ -78,6 +78,7 @@ pub struct PaymentMethod {// Do not use this column in v1 business logic.pub payment_method_subtype: Option<String>,pub network_transaction_link_id: Option<String>,+ pub compatibility_updated_at: Option<PrimitiveDateTime>,}#[cfg(feature = "v2")]@@ -118,6 +119,7 @@ pub struct PaymentMethod {pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,pub network_transaction_link_id: Option<Secret<String>>,+ pub compatibility_updated_at: Option<PrimitiveDateTime>,pub external_vault_token_data: Option<Encryption>,pub auxiliary_fingerprint_id: Option<String>,}@@ -183,6 +185,7 @@ pub struct PaymentMethodNew {pub locker_fingerprint_id: Option<String>,pub network_tokenization_data: Option<Encryption>,pub id: Option<String>,+ pub compatibility_updated_at: Option<PrimitiveDateTime>,}#[cfg(feature = "v2")]@@ -221,6 +224,7 @@ pub struct PaymentMethodNew {pub created_by: Option<String>,pub last_modified_by: Option<String>,pub customer_details: Option<Encryption>,+ pub compatibility_updated_at: Option<PrimitiveDateTime>,}impl PaymentMethodNew {@@ -432,6 +436,7 @@ pub struct PaymentMethodUpdateInternal {external_vault_source: Option<common_utils::id_type::MerchantConnectorAccountId>,last_modified_by: Option<String>,customer_details: Option<Encryption>,+ compatibility_updated_at: Option<PrimitiveDateTime>,}#[cfg(feature = "v2")]@@ -458,6 +463,7 @@ impl PaymentMethodUpdateInternal {external_vault_source,last_modified_by,customer_details,+ compatibility_updated_at,} = self;PaymentMethod {@@ -499,6 +505,7 @@ impl PaymentMethodUpdateInternal {customer_details: customer_details.or(source.customer_details),network_tokenization_data: source.network_tokenization_data,auxiliary_fingerprint_id: source.auxiliary_fingerprint_id,+ compatibility_updated_at,}}}@@ -535,6 +542,7 @@ pub struct PaymentMethodUpdateInternal {payment_method_type_v2: Option<storage_enums::PaymentMethod>,payment_method_subtype: Option<storage_enums::PaymentMethodType>,id: Option<String>,+ compatibility_updated_at: Option<PrimitiveDateTime>,}#[cfg(feature = "v1")]@@ -564,6 +572,7 @@ impl PaymentMethodUpdateInternal {payment_method_type_v2,payment_method_subtype,id,+ compatibility_updated_at,} = self;PaymentMethod {@@ -619,6 +628,7 @@ impl PaymentMethodUpdateInternal {.map(|payment_method_subtype| payment_method_subtype.to_string()).or(source.payment_method_subtype),id: id.or(source.id),+ compatibility_updated_at: compatibility_updated_at.or(source.compatibility_updated_at),}}}@@ -655,6 +665,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data,@@ -683,6 +694,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::LastUsedUpdate { last_used_at } => Self {metadata: None,@@ -708,6 +720,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::UpdatePaymentMethodDataAndLastUsed {payment_method_data,@@ -738,6 +751,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,@@ -768,6 +782,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::NetworkTransactionLinkIdUpdate {network_transaction_link_id,@@ -796,6 +811,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::StatusUpdate {status,@@ -824,6 +840,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::AdditionalDataUpdate {payment_method_data,@@ -865,6 +882,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::ConnectorMandateDetailsUpdate {connector_mandate_details,@@ -893,6 +911,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::NetworkTokenDataUpdate {network_token_requestor_reference_id,@@ -924,6 +943,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::ConnectorNetworkTransactionIdAndMandateDetailsUpdate {connector_mandate_details,@@ -954,6 +974,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::PaymentMethodBatchUpdate {connector_mandate_details,@@ -987,37 +1008,43 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {id: None,payment_method_type_v2: None,payment_method_subtype: None,+ compatibility_updated_at: None,},PaymentMethodUpdate::PopulateModularCompatFields {id,payment_method_type_v2,payment_method_subtype,last_modified_by,- } => Self {- metadata: None,- payment_method_data: None,- last_used_at: None,- network_transaction_id: None,- network_transaction_link_id: None,- status: None,- locker_id: None,- network_token_requestor_reference_id: None,- payment_method: None,- connector_mandate_details: None,- updated_by: None,- payment_method_issuer: None,- payment_method_type: None,- last_modified: common_utils::date_time::now(),- network_token_locker_id: None,- network_token_payment_method_data: None,- scheme: None,- last_modified_by,- customer_details: None,- network_tokenization_data: None,- payment_method_type_v2,- payment_method_subtype,- id: Some(id),- },+ } => {+ let now = common_utils::date_time::now();++ Self {+ metadata: None,+ payment_method_data: None,+ last_used_at: None,+ network_transaction_id: None,+ network_transaction_link_id: None,+ status: None,+ locker_id: None,+ network_token_requestor_reference_id: None,+ payment_method: None,+ connector_mandate_details: None,+ updated_by: None,+ payment_method_issuer: None,+ payment_method_type: None,+ last_modified: now,+ network_token_locker_id: None,+ network_token_payment_method_data: None,+ scheme: None,+ last_modified_by,+ customer_details: None,+ network_tokenization_data: None,+ payment_method_type_v2,+ payment_method_subtype,+ id: Some(id),+ compatibility_updated_at: Some(now),+ }+ }PaymentMethodUpdate::PopulateLegacyCompatFields {payment_method,payment_method_type,@@ -1046,6 +1073,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {payment_method_type_v2: None,payment_method_subtype: None,id: None,+ compatibility_updated_at: None,},}}@@ -1054,6 +1082,8 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {#[cfg(feature = "v2")]impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {fn from(payment_method_update: PaymentMethodUpdate) -> Self {+ let now = common_utils::date_time::now();+match payment_method_update {PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data,@@ -1071,7 +1101,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {connector_mandate_details: None,updated_by: None,payment_method_subtype: None,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_locker_id: None,network_token_requestor_reference_id: None,network_token_payment_method_data: None,@@ -1079,6 +1109,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {external_vault_source: None,last_modified_by,customer_details: None,+ compatibility_updated_at: Some(now),},PaymentMethodUpdate::LastUsedUpdate { last_used_at } => Self {payment_method_data: None,@@ -1093,7 +1124,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {connector_mandate_details: None,updated_by: None,payment_method_subtype: None,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_locker_id: None,network_token_requestor_reference_id: None,network_token_payment_method_data: None,@@ -1101,6 +1132,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {external_vault_source: None,last_modified_by: None,customer_details: None,+ compatibility_updated_at: Some(now),},PaymentMethodUpdate::UpdatePaymentMethodDataAndLastUsed {payment_method_data,@@ -1120,7 +1152,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {connector_mandate_details: None,updated_by: None,payment_method_subtype: None,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_locker_id: None,network_token_requestor_reference_id: None,network_token_payment_method_data: None,@@ -1128,6 +1160,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {external_vault_source: None,last_modified_by,customer_details: None,+ compatibility_updated_at: Some(now),},PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {network_transaction_id,@@ -1147,7 +1180,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {connector_mandate_details: None,updated_by: None,payment_method_subtype: None,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_locker_id: None,network_token_requestor_reference_id: None,network_token_payment_method_data: None,@@ -1155,6 +1188,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {external_vault_source: None,last_modified_by,customer_details: None,+ compatibility_updated_at: Some(now),},PaymentMethodUpdate::StatusUpdate {status,@@ -1172,7 +1206,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {connector_mandate_details: None,updated_by: None,payment_method_subtype: None,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_locker_id: None,network_token_requestor_reference_id: None,network_token_payment_method_data: None,@@ -1180,6 +1214,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {external_vault_source: None,last_modified_by,customer_details: None,+ compatibility_updated_at: Some(now),},PaymentMethodUpdate::GenericUpdate {payment_method_data,@@ -1207,7 +1242,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {connector_mandate_details: *connector_mandate_details,updated_by: None,payment_method_subtype,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_requestor_reference_id,network_token_locker_id,network_token_payment_method_data,@@ -1217,6 +1252,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_transaction_link_id,last_modified_by,customer_details: None,+ compatibility_updated_at: Some(now),},PaymentMethodUpdate::ConnectorMandateDetailsUpdate {connector_mandate_details,@@ -1234,7 +1270,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_transaction_link_id: None,updated_by: None,payment_method_subtype: None,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_locker_id: None,network_token_requestor_reference_id: None,network_token_payment_method_data: None,@@ -1242,6 +1278,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {external_vault_source: None,last_modified_by,customer_details: None,+ compatibility_updated_at: Some(now),},PaymentMethodUpdate::StatusAndFingerprintUpdate {status,@@ -1260,7 +1297,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {connector_mandate_details: None,updated_by: None,payment_method_subtype: None,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_locker_id: None,network_token_requestor_reference_id: None,network_token_payment_method_data: None,@@ -1268,6 +1305,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {external_vault_source: None,last_modified_by,customer_details: None,+ compatibility_updated_at: Some(now),},PaymentMethodUpdate::PopulateLegacyCompatFields {payment_method,@@ -1286,7 +1324,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {connector_mandate_details: None,updated_by: None,payment_method_subtype: None,- last_modified: common_utils::date_time::now(),+ last_modified: now,network_token_locker_id: None,network_token_requestor_reference_id: None,network_token_payment_method_data: None,@@ -1294,6 +1332,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {external_vault_source: None,last_modified_by,customer_details: None,+ compatibility_updated_at: Some(now),},}}@@ -1354,6 +1393,7 @@ impl From<&PaymentMethodNew> for PaymentMethod {payment_method_type_v2: None,payment_method_subtype: None,id: payment_method_new.id.clone(),+ compatibility_updated_at: payment_method_new.compatibility_updated_at,}}}@@ -1408,6 +1448,7 @@ impl From<&PaymentMethodNew> for PaymentMethod {last_modified_by: payment_method_new.last_modified_by.clone(),customer_details: payment_method_new.customer_details.clone(),network_tokenization_data: None,+ compatibility_updated_at: payment_method_new.compatibility_updated_at,}}}diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 9b97205d7e..3a1a1eb5e6 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -1440,6 +1440,7 @@ diesel::table! {payment_method_subtype -> Nullable<Varchar>,#[max_length = 255]network_transaction_link_id -> Nullable<Varchar>,+ compatibility_updated_at -> Nullable<Timestamp>,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex 8e72d3ab9a..6eacd260aa 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -1380,6 +1380,7 @@ diesel::table! {payment_method_subtype -> Nullable<Varchar>,#[max_length = 255]network_transaction_link_id -> Nullable<Varchar>,+ compatibility_updated_at -> Nullable<Timestamp>,external_vault_token_data -> Nullable<Bytea>,#[max_length = 64]auxiliary_fingerprint_id -> Nullable<Varchar>,diff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rsindex 69cbe46f41..6ef537f673 100644--- a/crates/hyperswitch_domain_models/src/payment_methods.rs+++ b/crates/hyperswitch_domain_models/src/payment_methods.rs@@ -98,6 +98,7 @@ pub struct PaymentMethod {pub locker_fingerprint_id: Option<String>,pub network_tokenization_data: OptionalEncryptableValue,pub storage_type: Option<common_enums::StorageType>,+ pub compatibility_updated_at: Option<PrimitiveDateTime>,}#[cfg(feature = "v2")]@@ -149,6 +150,7 @@ pub struct PaymentMethod {#[encrypt(ty = Value)]pub network_tokenization_data:Option<Encryptable<PaymentMethodNetworkTokenizationDataDomainType>>,+ pub compatibility_updated_at: Option<PrimitiveDateTime>,}impl PaymentMethod {@@ -503,6 +505,7 @@ impl super::behaviour::Conversion for PaymentMethod {payment_method_type_v2: None,payment_method_subtype: None,id: None,+ compatibility_updated_at: self.compatibility_updated_at,})}@@ -683,6 +686,7 @@ impl super::behaviour::Conversion for PaymentMethod {locker_fingerprint_id: item.locker_fingerprint_id,network_tokenization_data,storage_type: None,+ compatibility_updated_at: item.compatibility_updated_at,})}@@ -739,6 +743,7 @@ impl super::behaviour::Conversion for PaymentMethod {locker_fingerprint_id: self.locker_fingerprint_id,network_tokenization_data: self.network_tokenization_data.map(|val| val.into()),id: None,+ compatibility_updated_at: self.compatibility_updated_at,})}}@@ -791,6 +796,7 @@ impl super::behaviour::Conversion for PaymentMethod {customer_details: self.customer_details.map(|val| val.into()),network_tokenization_data: self.network_tokenization_data.map(|val| val.into()),auxiliary_fingerprint_id: self.auxiliary_fingerprint_id,+ compatibility_updated_at: self.compatibility_updated_at,})}@@ -935,6 +941,7 @@ impl super::behaviour::Conversion for PaymentMethod {customer_details,network_tokenization_data,auxiliary_fingerprint_id: storage_model.auxiliary_fingerprint_id,+ compatibility_updated_at: storage_model.compatibility_updated_at,})}.await@@ -984,6 +991,7 @@ impl super::behaviour::Conversion for PaymentMethod {.map(|last_modified_by| last_modified_by.to_string()),customer_details: self.customer_details.map(|val| val.into()),auxiliary_fingerprint_id: self.auxiliary_fingerprint_id,+ compatibility_updated_at: self.compatibility_updated_at,})}}@@ -1777,6 +1785,7 @@ mod tests {locker_fingerprint_id: None,network_tokenization_data: None,storage_type: None,+ compatibility_updated_at: Some(common_utils::date_time::now()),};payment_method.clone()}diff --git a/crates/payment_methods/src/core/migration/payment_methods.rs b/crates/payment_methods/src/core/migration/payment_methods.rsindex 4f564ad756..c3bb4f62a4 100644--- a/crates/payment_methods/src/core/migration/payment_methods.rs+++ b/crates/payment_methods/src/core/migration/payment_methods.rs@@ -731,6 +731,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(locker_fingerprint_id: None,network_tokenization_data: None,storage_type: None,+ compatibility_updated_at: None,},provider.get_account().storage_scheme,)diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex e6fb4734aa..09b3b9a495 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -3921,6 +3921,7 @@ pub async fn create_payment_method_for_intent(customer_details: None,network_tokenization_data: None,auxiliary_fingerprint_id,+ compatibility_updated_at: None,},storage_scheme,)@@ -4010,6 +4011,7 @@ pub async fn construct_payment_method_object(customer_details: None,network_tokenization_data: None,auxiliary_fingerprint_id: None,+ compatibility_updated_at: None,})}@@ -4077,6 +4079,7 @@ pub async fn create_payment_method_for_confirm(customer_details: None,network_tokenization_data: None,auxiliary_fingerprint_id: None,+ compatibility_updated_at: None,},storage_scheme,)diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex b1c11a5054..1474433336 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -211,6 +211,7 @@ impl PaymentMethodsController for PmCards<'_> {locker_fingerprint_id,network_tokenization_data: None, // setting this to None as write path will be introduced in a later PRstorage_type: None,+ compatibility_updated_at: None,},self.provider.get_account().storage_scheme,)diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rsindex cf3bcd54a0..bebc861b77 100644--- a/crates/router/src/core/payment_methods/transformers.rs+++ b/crates/router/src/core/payment_methods/transformers.rs@@ -1519,6 +1519,7 @@ impl DomainPaymentMethodWrapper {locker_fingerprint_id: None,network_tokenization_data: None,storage_type: response.storage_type,+ compatibility_updated_at: None,}))}@@ -1641,6 +1642,7 @@ impl DomainPaymentMethodWrapper {locker_fingerprint_id: None,network_tokenization_data: None,storage_type: response.storage_type,+ compatibility_updated_at: None,}))}}@@ -1821,6 +1823,7 @@ impl TryFrom<CreatePaymentMethodResponse> for DomainPaymentMethodWrapper {locker_fingerprint_id: None,network_tokenization_data: None,storage_type: response.storage_type,+ compatibility_updated_at: None,}))}}diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 7bddf322d3..8c0ddb4930 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -2550,11 +2550,13 @@ whereD: OperationSessionGetters<F> + Send + Sync,Op: Operation<F, R, Data = D> + Send + Sync,{- if feature_config.is_modular_with_pm_version(- payment_data- .get_payment_method_info()- .map(|payment_method| payment_method.version),- ) {+ if payment_data.get_payment_method_info().is_some_and(|pm| {+ feature_config.should_use_modular_pm_path(+ Some(pm.version),+ pm.compatibility_updated_at,+ Some(pm.last_modified),+ )+ }) {logger::debug!(payment_id = ?payment_data.get_payment_attempt().payment_id,"Modular merchant detected; calling update_modular_pm_and_mandate"@@ -8397,11 +8399,13 @@ whereD: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,{let connector = payment_data.get_payment_attempt().connector.to_owned();- let should_use_modular_pm_path = feature_config.is_modular_with_pm_version(- payment_data- .get_payment_method_info()- .map(|payment_method| payment_method.version),- );+ let should_use_modular_pm_path = payment_data.get_payment_method_info().is_some_and(|pm| {+ feature_config.should_use_modular_pm_path(+ Some(pm.version),+ pm.compatibility_updated_at,+ Some(pm.last_modified),+ )+ });let is_mandate = payment_data.get_mandate_id()@@ -8607,11 +8611,13 @@ wherelet is_external_authentication_requested = payment_data.get_payment_intent().request_external_three_ds_authentication;- let should_use_modular_pm_path = feature_config.is_modular_with_pm_version(- payment_data- .get_payment_method_info()- .map(|payment_method| payment_method.version),- );+ let should_use_modular_pm_path = payment_data.get_payment_method_info().is_some_and(|pm| {+ feature_config.should_use_modular_pm_path(+ Some(pm.version),+ pm.compatibility_updated_at,+ Some(pm.last_modified),+ )+ });let payment_data =if !is_operation_confirm(operation) || is_external_authentication_requested == Some(true) {if !should_use_modular_pm_path {@@ -10208,11 +10214,13 @@ where}),};- let should_use_modular_pm_path = feature_config.is_modular_with_pm_version(- payment_data- .get_payment_method_info()- .map(|payment_method| payment_method.version),- );+ let should_use_modular_pm_path = payment_data.get_payment_method_info().is_some_and(|pm| {+ feature_config.should_use_modular_pm_path(+ Some(pm.version),+ pm.compatibility_updated_at,+ Some(pm.last_modified),+ )+ });let decided_connector = decide_connector(state.clone(),diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 83931e0a05..25a7637ee3 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -666,9 +666,13 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>let payment_method_info = payment_method_info.or(prefetched_payment_method_info);let feature_config = core_utils::get_feature_config(state, platform, dimensions).await;- let payment_method_version = payment_method_info.as_ref().map(|pm| pm.version);- let is_modular_payment_method_flow =- feature_config.is_modular_with_pm_version(payment_method_version);+ let is_modular_payment_method_flow = payment_method_info.as_ref().is_some_and(|pm| {+ feature_config.should_use_modular_pm_path(+ Some(pm.version),+ pm.compatibility_updated_at,+ Some(pm.last_modified),+ )+ });let (token_data, payment_method_info) = if is_modular_payment_method_flow {(None, payment_method_info)} else {@@ -1313,7 +1317,11 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> formatch payment_method_info {Some(payment_method)- if feature_config.is_modular_with_pm_version(Some(payment_method.version)) =>+ if feature_config.should_use_modular_pm_path(+ Some(payment_method.version),+ payment_method.compatibility_updated_at,+ Some(payment_method.last_modified),+ ) =>{logger::debug!("Payment method version is V2, fetching payment method from PM Modular Service"diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 899706bde7..a93beeb18d 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -971,7 +971,11 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for};if let Some(payment_method) = payment_method_info {- if feature_config.is_modular_with_pm_version(Some(payment_method.version)) {+ if feature_config.should_use_modular_pm_path(+ Some(payment_method.version),+ payment_method.compatibility_updated_at,+ Some(payment_method.last_modified),+ ) {logger::debug!("Payment method version is V2, fetching payment method from PM Modular Service");diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 7789485c48..7f1e2a0d6f 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -778,10 +778,14 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthorwhereF: 'b + Clone + Send + Sync,{- if !feature_config.is_modular_with_pm_version(+ if !feature_config.should_use_modular_pm_path(+ payment_data.get_payment_method_info().map(|pm| pm.version),payment_data.get_payment_method_info()- .map(|payment_method| payment_method.version),+ .and_then(|pm| pm.compatibility_updated_at),+ payment_data+ .get_payment_method_info()+ .map(|pm| pm.last_modified),) {let _ = update_pm_connector_mandate_details(state,@@ -1082,10 +1086,14 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> forwhereF: 'b + Clone + Send + Sync,{- if !feature_config.is_modular_with_pm_version(+ if !feature_config.should_use_modular_pm_path(+ payment_data.get_payment_method_info().map(|pm| pm.version),+ payment_data+ .get_payment_method_info()+ .and_then(|pm| pm.compatibility_updated_at),payment_data.get_payment_method_info()- .map(|payment_method| payment_method.version),+ .map(|pm| pm.last_modified),) {let _ = update_pm_connector_mandate_details(state,@@ -1834,10 +1842,14 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDawhereF: 'b + Clone + Send + Sync,{- if !feature_config.is_modular_with_pm_version(+ if !feature_config.should_use_modular_pm_path(+ payment_data.get_payment_method_info().map(|pm| pm.version),payment_data.get_payment_method_info()- .map(|payment_method| payment_method.version),+ .and_then(|pm| pm.compatibility_updated_at),+ payment_data+ .get_payment_method_info()+ .map(|pm| pm.last_modified),) {let _ = update_pm_connector_mandate_details(state,@@ -1973,10 +1985,14 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeDatawhereF: 'b + Clone + Send + Sync,{- if !feature_config.is_modular_with_pm_version(+ if !feature_config.should_use_modular_pm_path(+ payment_data.get_payment_method_info().map(|pm| pm.version),+ payment_data+ .get_payment_method_info()+ .and_then(|pm| pm.compatibility_updated_at),payment_data.get_payment_method_info()- .map(|payment_method| payment_method.version),+ .map(|pm| pm.last_modified),) {let _ = update_pm_connector_mandate_details(state,diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex fe2fd4c3e2..7e7dd71b3e 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -135,7 +135,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReqlet token_data = {let feature_config = utils::get_feature_config(state, platform, dimensions).await;let should_use_modular_payment_method_flow =- feature_config.is_modular_with_pm_version(None);+ feature_config.should_use_modular_pm_path(None, None, None);match (payment_attempt.payment_token.clone(),should_use_modular_payment_method_flow,diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rsindex 84742ee80c..01d4fd2862 100644--- a/crates/router/src/core/pm_auth.rs+++ b/crates/router/src/core/pm_auth.rs@@ -544,6 +544,7 @@ async fn store_bank_details_in_payment_methods(locker_fingerprint_id: None,network_tokenization_data: None,storage_type: None,+ compatibility_updated_at: None,};new_entries.push(pm_new);diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex b007678b55..983bfbf9a6 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -74,11 +74,17 @@ pub struct FeatureConfig {}impl FeatureConfig {- pub fn is_modular_with_pm_version(+ pub fn should_use_modular_pm_path(&self,payment_method_version: Option<common_enums::ApiVersion>,+ last_modified_by_modular: Option<time::PrimitiveDateTime>,+ last_modified_by_legacy: Option<time::PrimitiveDateTime>,) -> bool {- self.is_payment_method_modular_allowed+ (self.is_payment_method_modular_allowed+ && matches!(+ (last_modified_by_modular, last_modified_by_legacy),+ (Some(last_mod_modular), Some(last_mod_legacy)) if last_mod_modular >= last_mod_legacy+ ))|| payment_method_version == Some(common_enums::ApiVersion::V2)}}diff --git a/crates/router/src/types/payment_methods.rs b/crates/router/src/types/payment_methods.rsindex 69ea6116f1..a3d4c0beec 100644--- a/crates/router/src/types/payment_methods.rs+++ b/crates/router/src/types/payment_methods.rs@@ -54,6 +54,14 @@ pub struct AddVaultRequest<D> {pub ttl: i64,}+#[derive(Debug, serde::Deserialize, serde::Serialize)]+pub struct AddCompatVaultRequest<D> {+ pub entity_id: id_type::CustomerId,+ pub vault_id: domain::VaultId,+ pub data: D,+ pub ttl: i64,+}+#[cfg(feature = "v2")]#[derive(Debug, serde::Deserialize, serde::Serialize)]pub struct AddVaultRequest<D> {diff --git a/crates/router/src/workflows/payment_method_modular_forward_compat.rs b/crates/router/src/workflows/payment_method_modular_forward_compat.rsindex c1954fbc17..fd4ca77026 100644--- a/crates/router/src/workflows/payment_method_modular_forward_compat.rs+++ b/crates/router/src/workflows/payment_method_modular_forward_compat.rs@@ -124,13 +124,8 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentMethodModularForwardCompatWhyperswitch_domain_models::vault::PaymentMethodVaultingData::Card(card_detail);// Step 5: Upsert the card into generic locker via direct AddVault call.- let entity_id = hyperswitch_domain_models::vault::V1VaultEntityId::new(- key_store.merchant_id.clone(),- customer_id.clone(),- );-- let payload = pm_types::AddVaultRequest {- entity_id,+ let payload = pm_types::AddCompatVaultRequest {+ entity_id: customer_id.clone(),vault_id: crate::types::domain::VaultId::generate(card_reference),data: &pmd,ttl: state.conf.locker.ttl_for_storage_in_secs,diff --git a/migrations/2026-05-18-000001_add_compatibility_updated_at_to_payment_methods/down.sql b/migrations/2026-05-18-000001_add_compatibility_updated_at_to_payment_methods/down.sqlnew file mode 100644index 0000000000..5f1fd82cd4--- /dev/null+++ b/migrations/2026-05-18-000001_add_compatibility_updated_at_to_payment_methods/down.sql@@ -0,0 +1,2 @@+ALTER TABLE payment_methods+ DROP COLUMN IF EXISTS compatibility_updated_at;diff --git a/migrations/2026-05-18-000001_add_compatibility_updated_at_to_payment_methods/up.sql b/migrations/2026-05-18-000001_add_compatibility_updated_at_to_payment_methods/up.sqlnew file mode 100644index 0000000000..c7aed43540--- /dev/null+++ b/migrations/2026-05-18-000001_add_compatibility_updated_at_to_payment_methods/up.sql@@ -0,0 +1,2 @@+ALTER TABLE payment_methods+ ADD COLUMN IF NOT EXISTS compatibility_updated_at TIMESTAMP;