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
fix(core): moved merchant fingerprint secret from superposition to merchant account table (#13346)
Sahkal Poddar6418fe192259
diff --git a/config/superposition_seed.toml b/config/superposition_seed.tomlindex cf34416472..d8e57a9b0e 100644--- a/config/superposition_seed.toml+++ b/config/superposition_seed.toml@@ -101,8 +101,8 @@ change_reason = "Initial setup"[default-configs.fingerprint_secret]value = ""schema = { type = "string" }-description = "Fingerprint secret used for payment card fingerprinting per merchant"-change_reason = "Initial setup"+description = "Fingerprint secret used as a migration fallback for merchant accounts"+change_reason = "Retain during merchant account migration"[default-configs.should_call_gsm]value = falsediff --git a/crates/common_utils/src/id_type/merchant.rs b/crates/common_utils/src/id_type/merchant.rsindex ed3f585378..f23db0f84c 100644--- a/crates/common_utils/src/id_type/merchant.rs+++ b/crates/common_utils/src/id_type/merchant.rs@@ -130,11 +130,6 @@ impl MerchantId {format!("pre_routing_disabled_pm_pmt_for_{}", self.get_string_repr())}- /// get_merchant_fingerprint_secret_key- pub fn get_merchant_fingerprint_secret_key(&self) -> String {- format!("fingerprint_secret_{}", self.get_string_repr())- }-/// get_surcharge_dsk_keypub fn get_surcharge_dsk_key(&self) -> String {format!("surcharge_dsl_{}", self.get_string_repr())diff --git a/crates/diesel_models/src/merchant_account.rs b/crates/diesel_models/src/merchant_account.rsindex 5366390e33..fe7394faf2 100644--- a/crates/diesel_models/src/merchant_account.rs+++ b/crates/diesel_models/src/merchant_account.rs@@ -1,5 +1,6 @@use common_utils::{encryption::Encryption, pii};use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};+use hyperswitch_masking::Secret;use crate::enums as storage_enums;#[cfg(feature = "v1")]@@ -56,6 +57,7 @@ pub struct MerchantAccount {pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: Option<common_enums::MerchantAccountType>,pub network_tokenization_credentials: Option<Encryption>,+ pub fingerprint_secret: Option<Secret<String>>,}#[cfg(feature = "v1")]@@ -92,6 +94,7 @@ pub struct MerchantAccountSetter {pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: common_enums::MerchantAccountType,pub network_tokenization_credentials: Option<Encryption>,+ pub fingerprint_secret: Option<Secret<String>>,}#[cfg(feature = "v1")]@@ -131,6 +134,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {product_type: item.product_type,merchant_account_type: Some(item.merchant_account_type),network_tokenization_credentials: item.network_tokenization_credentials,+ fingerprint_secret: item.fingerprint_secret,}}}@@ -166,6 +170,7 @@ pub struct MerchantAccount {pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: Option<common_enums::MerchantAccountType>,pub network_tokenization_credentials: Option<Encryption>,+ pub fingerprint_secret: Option<Secret<String>>,}#[cfg(feature = "v2")]@@ -187,6 +192,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {product_type: item.product_type,merchant_account_type: Some(item.merchant_account_type),network_tokenization_credentials: None, // need to check if we can have this column in v2+ fingerprint_secret: item.fingerprint_secret,}}}@@ -207,6 +213,7 @@ pub struct MerchantAccountSetter {pub is_platform_account: bool,pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: common_enums::MerchantAccountType,+ pub fingerprint_secret: Option<Secret<String>>,}impl MerchantAccount {@@ -259,6 +266,7 @@ pub struct MerchantAccountNew {pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: common_enums::MerchantAccountType,pub network_tokenization_credentials: Option<Encryption>,+ pub fingerprint_secret: Option<Secret<String>>,}#[cfg(feature = "v2")]@@ -279,6 +287,7 @@ pub struct MerchantAccountNew {pub is_platform_account: bool,pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: common_enums::MerchantAccountType,+ pub fingerprint_secret: Option<Secret<String>>,}#[cfg(feature = "v2")]diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 2c844762ba..ba6b6a02a9 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -1032,6 +1032,8 @@ diesel::table! {#[max_length = 64]merchant_account_type -> Nullable<Varchar>,network_tokenization_credentials -> Nullable<Bytea>,+ #[max_length = 128]+ fingerprint_secret -> Nullable<Varchar>,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex b29464cb61..d705f234fa 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -1020,6 +1020,8 @@ diesel::table! {#[max_length = 64]merchant_account_type -> Nullable<Varchar>,network_tokenization_credentials -> Nullable<Bytea>,+ #[max_length = 128]+ fingerprint_secret -> Nullable<Varchar>,}}diff --git a/crates/hyperswitch_domain_models/src/merchant_account.rs b/crates/hyperswitch_domain_models/src/merchant_account.rsindex 895e9d61f6..938ac2f9e4 100644--- a/crates/hyperswitch_domain_models/src/merchant_account.rs+++ b/crates/hyperswitch_domain_models/src/merchant_account.rs@@ -55,6 +55,7 @@ pub struct MerchantAccount {pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: common_enums::MerchantAccountType,pub network_tokenization_credentials: OptionalEncryptableValue,+ pub fingerprint_secret: Option<Secret<String>>,}#[cfg(feature = "v1")]@@ -93,6 +94,7 @@ pub struct MerchantAccountSetter {pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: common_enums::MerchantAccountType,pub network_tokenization_credentials: OptionalEncryptableValue,+ pub fingerprint_secret: Option<Secret<String>>,}#[cfg(feature = "v1")]@@ -131,6 +133,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {product_type: item.product_type,merchant_account_type: item.merchant_account_type,network_tokenization_credentials: item.network_tokenization_credentials,+ fingerprint_secret: item.fingerprint_secret,}}}@@ -153,6 +156,7 @@ pub struct MerchantAccountSetter {pub version: common_enums::ApiVersion,pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: common_enums::MerchantAccountType,+ pub fingerprint_secret: Option<Secret<String>>,}#[cfg(feature = "v2")]@@ -173,6 +177,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {version,product_type,merchant_account_type,+ fingerprint_secret,} = item;Self {id,@@ -189,6 +194,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {version,product_type,merchant_account_type,+ fingerprint_secret,}}}@@ -210,6 +216,7 @@ pub struct MerchantAccount {pub version: common_enums::ApiVersion,pub product_type: Option<common_enums::MerchantProductType>,pub merchant_account_type: common_enums::MerchantAccountType,+ pub fingerprint_secret: Option<Secret<String>>,}impl MerchantAccount {@@ -585,6 +592,7 @@ impl Conversion for MerchantAccount {is_platform_account: self.is_platform_account,product_type: self.product_type,merchant_account_type: self.merchant_account_type,+ fingerprint_secret: self.fingerprint_secret,};Ok(diesel_models::MerchantAccount::from(setter))@@ -648,6 +656,7 @@ impl Conversion for MerchantAccount {version: item.version,product_type: item.product_type,merchant_account_type: item.merchant_account_type.unwrap_or_default(),+ fingerprint_secret: item.fingerprint_secret,})}.await@@ -675,6 +684,7 @@ impl Conversion for MerchantAccount {.product_type.or(Some(common_enums::MerchantProductType::Orchestration)),merchant_account_type: self.merchant_account_type,+ fingerprint_secret: self.fingerprint_secret,})}}@@ -720,6 +730,7 @@ impl Conversion for MerchantAccount {network_tokenization_credentials: self.network_tokenization_credentials.map(|credentials| credentials.into()),+ fingerprint_secret: self.fingerprint_secret,};Ok(diesel_models::MerchantAccount::from(setter))@@ -814,6 +825,7 @@ impl Conversion for MerchantAccount {.and_then(|val| val.try_into_optionaloperation())}).await?,+ fingerprint_secret: item.fingerprint_secret,})}.await@@ -862,6 +874,7 @@ impl Conversion for MerchantAccount {network_tokenization_credentials: self.network_tokenization_credentials.map(|credentials| credentials.into()),+ fingerprint_secret: self.fingerprint_secret,})}}diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rsindex f1192894f4..87419b5b77 100644--- a/crates/router/src/consts.rs+++ b/crates/router/src/consts.rs@@ -369,7 +369,7 @@ pub mod superposition {pub const REQUIRES_CVV: &str = "requires_cvv";/// implicit customer update configuration keypub const IMPLICIT_CUSTOMER_UPDATE: &str = "implicit_customer_update";- /// Fingerprint secret configuration key+ /// Fingerprint secret configuration key retained for migration fallbackpub const FINGERPRINT_SECRET: &str = "fingerprint_secret";/// Poll config for external 3DS authentication keypub const POLL_CONFIG_EXTERNAL_THREE_DS: &str = "poll_config_external_three_ds";diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex e0e478d8c7..28cef9605a 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -34,7 +34,6 @@ use crate::types::transformers::ForeignFrom;use crate::{consts,core::{- configs::dimension_state,connector_validation::ConnectorAuthTypeAndMetadataValidation,disputes,encryption::transfer_encryption_key,@@ -74,21 +73,6 @@ pub fn create_merchant_publishable_key() -> String {)}-/// Insert merchant configs using Superposition for fingerprint_secret-pub async fn insert_merchant_configs_with_superposition(- state: &SessionState,- dimensions: &dimension_state::DimensionsWithProcessorMerchantId,-) -> RouterResult<()> {- let fingerprint_secret = utils::generate_id(consts::FINGERPRINT_SECRET_LENGTH, "fs");-- dimensions- .set_fingerprint_secret(state.superposition_service.as_ref(), &fingerprint_secret)- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed to create fingerprint_secret in Superposition")?;- Ok(())-}-#[cfg(feature = "olap")]fn add_publishable_key_to_decision_service(state: &SessionState, platform: &domain::Platform) {let state = state.clone();@@ -397,17 +381,8 @@ pub async fn create_merchant_account(None,);- let dimensions = dimension_state::Dimensions::new()- .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id());-add_publishable_key_to_decision_service(&state, &platform);- Box::pin(insert_merchant_configs_with_superposition(- &state,- &dimensions,- ))- .await?;-Ok(service_api::ApplicationResponse::Json(api::MerchantAccountResponse::foreign_try_from(merchant_account).change_context(errors::ApiErrorResponse::InternalServerError)@@ -645,6 +620,10 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {product_type: self.product_type,merchant_account_type,network_tokenization_credentials,+ fingerprint_secret: Some(Secret::new(utils::generate_id(+ consts::FINGERPRINT_SECRET_LENGTH,+ "fs",+ ))),},)}@@ -941,6 +920,10 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {version: common_types::consts::API_VERSION,product_type: self.product_type,merchant_account_type,+ fingerprint_secret: Some(Secret::new(utils::generate_id(+ consts::FINGERPRINT_SECRET_LENGTH,+ "fs",+ ))),}),)}diff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rsindex c5a79400b5..07a94f0c8d 100644--- a/crates/router/src/core/blocklist/utils.rs+++ b/crates/router/src/core/blocklist/utils.rs@@ -3,13 +3,14 @@ use common_enums::{BlockReason, MerchantDecision};use common_utils::errors::CustomResult;use diesel_models::{business_profile::CardBlockingConfig, configs};use error_stack::ResultExt;-use hyperswitch_masking::StrongSecret;+use hyperswitch_masking::{PeekInterface, StrongSecret};use super::{errors, transformers::generate_fingerprint, SessionState};use crate::{core::{configs::dimension_state,errors::{RouterResult, StorageErrorExt},+ metrics,payments::PaymentData,},logger,@@ -233,21 +234,29 @@ pub async fn insert_entry_into_blocklist(pub async fn get_merchant_fingerprint_secret(state: &SessionState,- dimensions: &dimension_state::DimensionsWithProcessorMerchantId,+ merchant_account: &domain::MerchantAccount,) -> RouterResult<String> {- // Fetch from Superposition only- let secret = dimensions- .get_fingerprint_secret(- &*state.store,- state.superposition_service.as_ref(),- None, // No targeting key needed for merchant-level config- )- .await;+ match merchant_account.fingerprint_secret.as_ref() {+ Some(secret) => Ok(secret.peek().clone()),+ None => {+ logger::warn!(+ merchant_id = ?merchant_account.get_id(),+ "fingerprint_secret missing from merchant account; falling back to Superposition"+ );+ metrics::FINGERPRINT_SECRET_SUPERPOSITION_FETCH_COUNT.add(1, &[]);+ let dimensions = dimension_state::Dimensions::new()+ .with_processor_merchant_id(merchant_account.get_id().clone().into());+ let secret = dimensions+ .get_fingerprint_secret(&*state.store, state.superposition_service.as_ref(), None)+ .await;- match secret.is_empty() {- false => Ok(secret),- true => Err(errors::ApiErrorResponse::InternalServerError)- .attach_printable("fingerprint_secret not found in Superposition for merchant"),+ match secret.is_empty() {+ false => Ok(secret),+ true => Err(errors::ApiErrorResponse::InternalServerError).attach_printable(+ "fingerprint_secret not found in merchant account or Superposition",+ ),+ }+ }}}@@ -317,15 +326,13 @@ async fn delete_card_bin_blocklist_entry(pub async fn should_payment_be_blocked(state: &SessionState,processor: &domain::Processor,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,payment_method_data: &Option<domain::EligibilityPaymentMethodData>,business_profile: &domain::Profile,) -> CustomResult<Option<BlockReason>, errors::ApiErrorResponse> {let db = &state.store;let processor_merchant_id = processor.get_account().get_id();- let processor_dimensions = dimensions.without_provider_merchant_id();let merchant_fingerprint_secret =- get_merchant_fingerprint_secret(state, &processor_dimensions).await?;+ get_merchant_fingerprint_secret(state, processor.get_account()).await?;// Hashed Fingerprint to check whether or not this payment should be blocked.let card_number_fingerprint =@@ -432,7 +439,7 @@ pub async fn should_payment_be_blocked(pub async fn validate_data_for_blocklist<F>(state: &SessionState,processor: &domain::Processor,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,payment_data: &mut PaymentData<F>,business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse>@@ -443,7 +450,6 @@ wherelet block_reason = should_payment_be_blocked(state,processor,- dimensions,&payment_data.payment_method_data.clone()@@ -500,7 +506,7 @@ where} else {payment_data.payment_attempt.fingerprint_id = generate_payment_fingerprint(state,- &dimensions.without_provider_merchant_id(),+ processor.get_account(),payment_data.payment_method_data.clone(),).await?;@@ -606,10 +612,11 @@ pub async fn should_payment_be_blocked_by_profile_config(pub async fn generate_payment_fingerprint(state: &SessionState,- dimensions: &dimension_state::DimensionsWithProcessorMerchantId,+ merchant_account: &domain::MerchantAccount,payment_method_data: Option<domain::PaymentMethodData>,) -> CustomResult<Option<String>, errors::ApiErrorResponse> {- let merchant_fingerprint_secret = get_merchant_fingerprint_secret(state, dimensions).await?;+ let merchant_fingerprint_secret =+ get_merchant_fingerprint_secret(state, merchant_account).await?;Ok(if let Some(domain::PaymentMethodData::Card(card)) = payment_method_data.as_ref() {diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rsindex c430c9db0d..a7bcfb7b92 100644--- a/crates/router/src/core/configs/dimension_config.rs+++ b/crates/router/src/core/configs/dimension_config.rs@@ -2,52 +2,11 @@ use std::collections::HashSet;use api_models::webhooks::IncomingWebhookEvent;use common_enums;-use common_utils::errors::CustomResult;use external_services::superposition;use scheduler::consumer::types::process_data::RetryMapping;use super::{dimension_state, fetch_db_config_for_dimensions, ConfigContext, DatabaseBackedConfig};use crate::{consts::superposition as superposition_consts, db::StorageInterface, utils::id_type};-/// This adds `WritableConfig` trait implementation and `set_<key>()` method.-///-/// # Usage-/// - Use this after `config!` macro for configs that need both read and write-/// - Use this alone for write-only configs (struct must be defined separately)-///-/// # Generated Methods-/// - `set_<key>()` - Write the value to Superposition-macro_rules! writable_config {- (- superposition_key = $key:ident,- input = $input:ty,- requires = $requirement:ty- ) => {- paste::paste! {- impl superposition::WritableConfig for [<$key:camel>] {- type Input = $input;- const SUPERPOSITION_KEY: &'static str = superposition_consts::$key;- }-- impl $requirement {- pub async fn [<set_ $key:lower>](- &self,- superposition_client: &superposition::SuperpositionClient,- value: &$input,- ) -> CustomResult<(), superposition::SuperpositionError> {-- let context = self.to_superposition_context()- .ok_or_else(|| error_stack::report!(superposition::SuperpositionError::ClientError(- "Missing required context dimensions".to_string()- )))?;-- superposition_client- .set_config_value::<[<$key:camel>]>(value, &context)- .await- }- }- }- };-}/// Macro to generate config struct and superposition::Config trait implementation./// Note: Manually implement `DatabaseBackedConfig` for the config struct:@@ -222,6 +181,8 @@ impl DatabaseBackedConfig for ImplicitCustomerUpdate {}}+// Retained temporarily so merchants without a database value can fall back to+// their existing Superposition fingerprint secret during migration.config! {superposition_key = FINGERPRINT_SECRET,output = String,@@ -329,13 +290,6 @@ impl DatabaseBackedConfig for EnableExtendedCardBin {}}-// Write support for FingerprintSecret-writable_config! {- superposition_key = FINGERPRINT_SECRET,- input = String,- requires = dimension_state::DimensionsWithProcessorMerchantId-}-config! {superposition_key = GSM_PAYOUT_CALL,output = bool,diff --git a/crates/router/src/core/metrics.rs b/crates/router/src/core/metrics.rsindex 48e1fb7e4c..d1d87a2303 100644--- a/crates/router/src/core/metrics.rs+++ b/crates/router/src/core/metrics.rs@@ -105,3 +105,5 @@ counter_metric!(POST_AUTHENTICATION_TOKEN_PUSHED_TO_VGS, GLOBAL_METER);counter_metric!(SDK_AUTH_LEGACY_FLOW_TOTAL, GLOBAL_METER); // No. of SDK auth requests without session_id (legacy flow) - tracked per merchant_idcounter_metric!(SDK_AUTH_SESSION_VALIDATED_TOTAL, GLOBAL_METER); // No. of SDK auth requests with valid session_id - tracked per merchant_idcounter_metric!(SDK_AUTH_INVALID_SESSION_TOTAL, GLOBAL_METER); // No. of SDK auth requests with invalid session_id - tracked per merchant_id++counter_metric!(FINGERPRINT_SECRET_SUPERPOSITION_FETCH_COUNT, GLOBAL_METER); // No. of fingerprint secret fetches from Superposition during migration fallbackdiff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 641350cc20..e1201188db 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -13508,14 +13508,9 @@ impl EligibilityCheck for BlockListCheck {payment_elgibility_data: &PaymentEligibilityData,business_profile: &domain::Profile,) -> CustomResult<CheckResult, errors::ApiErrorResponse> {- let dimensions = Dimensions::new()- .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())- .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());-let block_reason = blocklist_utils::should_payment_be_blocked(state,platform.get_processor(),- &dimensions,&payment_elgibility_data.payment_method_data,business_profile,)diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex 4fac0f894b..763d943857 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -1996,6 +1996,7 @@ mod tests {product_type: None,version: common_enums::ApiVersion::V1,network_tokenization_credentials: None,+ fingerprint_secret: None,});let merchant_account = state.storediff --git a/migrations/2026-07-16-000001_add_fingerprint_secret_to_merchant_account/down.sql b/migrations/2026-07-16-000001_add_fingerprint_secret_to_merchant_account/down.sqlnew file mode 100644index 0000000000..1ba5856f40--- /dev/null+++ b/migrations/2026-07-16-000001_add_fingerprint_secret_to_merchant_account/down.sql@@ -0,0 +1,2 @@+ALTER TABLE merchant_account+DROP COLUMN IF EXISTS fingerprint_secret;diff --git a/migrations/2026-07-16-000001_add_fingerprint_secret_to_merchant_account/up.sql b/migrations/2026-07-16-000001_add_fingerprint_secret_to_merchant_account/up.sqlnew file mode 100644index 0000000000..a40d224274--- /dev/null+++ b/migrations/2026-07-16-000001_add_fingerprint_secret_to_merchant_account/up.sql@@ -0,0 +1,2 @@+ALTER TABLE merchant_account+ADD COLUMN IF NOT EXISTS fingerprint_secret VARCHAR(128);