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(superposition): Add support for create override macro to superposition (#11454)
chikke srujan239a78331931
diff --git a/.github/workflows/cypress-tests-runner.yml b/.github/workflows/cypress-tests-runner.ymlindex 23de36e017..55568038cd 100644--- a/.github/workflows/cypress-tests-runner.yml+++ b/.github/workflows/cypress-tests-runner.yml@@ -233,6 +233,13 @@ jobs:--health-retries 5ports:- 5432:5432+ superposition:+ image: ghcr.io/juspay/superposition-demo:0.102.0+ env:+ API_HOSTNAME: http://localhost:8081+ REDIS_URL: redis://redis:6379+ ports:+ - 8081:8080steps:- name: Skip tests for PRs from forks@@ -344,6 +351,15 @@ jobs:run: |PGPASSWORD=db_pass psql --host=localhost --port=5432 --username=db_user --dbname=hyperswitch_db --command "\copy gateway_status_map FROM '.github/data/gateway_status_map.csv' DELIMITER ',' CSV HEADER;"+ - name: Seed Superposition+ if: ${{ env.RUN_TESTS == 'true' }}+ env:+ SUPERPOSITION_URL: "http://localhost:8081"+ SEED_FILE: "./config/superposition_seed.toml"+ WORKSPACE_ID: "dev"+ ORG_ID: "localorg"+ run: bash scripts/seed_superposition.sh+- name: Setup Local Serverif: ${{ env.RUN_TESTS == 'true' }}env:@@ -760,6 +776,13 @@ jobs:--health-retries 5ports:- 5432:5432+ superposition:+ image: ghcr.io/juspay/superposition-demo:0.102.0+ env:+ API_HOSTNAME: http://localhost:8081+ REDIS_URL: redis://redis:6379+ ports:+ - 8081:8080steps:- name: Checkout repository@@ -851,6 +874,14 @@ jobs:run: |PGPASSWORD=db_pass psql --host=localhost --port=5432 --username=db_user --dbname=hyperswitch_db --command "\copy gateway_status_map FROM '.github/data/gateway_status_map.csv' DELIMITER ',' CSV HEADER;"+ - name: Seed Superposition+ env:+ SUPERPOSITION_URL: "http://localhost:8081"+ SEED_FILE: "./config/superposition_seed.toml"+ WORKSPACE_ID: "dev"+ ORG_ID: "localorg"+ run: bash scripts/seed_superposition.sh+- name: Setup Local Serverenv:ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC: ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE }}@@ -939,6 +970,13 @@ jobs:--health-retries 5ports:- 5432:5432+ superposition:+ image: ghcr.io/juspay/superposition-demo:0.102.0+ env:+ API_HOSTNAME: http://localhost:8081+ REDIS_URL: redis://redis:6379+ ports:+ - 8081:8080steps:- name: Skip tests for PRs from forks@@ -1032,6 +1070,15 @@ jobs:run: |PGPASSWORD=db_pass psql --host=localhost --port=5432 --username=db_user --dbname=hyperswitch_db --command "\copy gateway_status_map FROM '.github/data/gateway_status_map.csv' DELIMITER ',' CSV HEADER;"+ - name: Seed Superposition+ if: ${{ env.RUN_TESTS == 'true' }}+ env:+ SUPERPOSITION_URL: "http://localhost:8081"+ SEED_FILE: "./config/superposition_seed.toml"+ WORKSPACE_ID: "dev"+ ORG_ID: "localorg"+ run: bash scripts/seed_superposition.sh+- name: Start mock servers for alpha connectorsif: ${{ env.RUN_TESTS == 'true' }}run: |@@ -1150,6 +1197,13 @@ jobs:--health-retries 5ports:- 5432:5432+ superposition:+ image: ghcr.io/juspay/superposition-demo:0.102.0+ env:+ API_HOSTNAME: http://localhost:8081+ REDIS_URL: redis://redis:6379+ ports:+ - 8081:8080steps:- name: Skip tests for PRs from forks@@ -1268,6 +1322,15 @@ jobs:run: |PGPASSWORD=db_pass psql --host=localhost --port=5432 --username=db_user --dbname=hyperswitch_db --command "\copy gateway_status_map FROM '.github/data/gateway_status_map.csv' DELIMITER ',' CSV HEADER;"+ - name: Seed Superposition+ if: ${{ env.RUN_TESTS == 'true' }}+ env:+ SUPERPOSITION_URL: "http://localhost:8081"+ SEED_FILE: "./config/superposition_seed.toml"+ WORKSPACE_ID: "dev"+ ORG_ID: "localorg"+ run: bash scripts/seed_superposition.sh+- name: Build projectif: ${{ env.RUN_TESTS == 'true' }}env:diff --git a/Cargo.lock b/Cargo.lockindex 99edb754e0..f02e035791 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3371,6 +3371,7 @@ dependencies = ["serde_json","serde_urlencoded","superposition_provider",+ "superposition_sdk","superposition_types","thiserror 1.0.69","time 0.3.41",diff --git a/config/config.example.toml b/config/config.example.tomlindex c2a7818845..fc0f580e08 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -1407,7 +1407,6 @@ internal_api_key = "test_internal_api_key" # API key for internal merchant id anpayments_base_url = "http://localhost:8080"[superposition]-enabled = true # Enable or disable Superposition integration (default: false)endpoint = "http://superposition:8080" # Superposition service endpoint URLtoken = "your_superposition_token" # Superposition tokenorg_id = "your_org_id" # Organization ID in Superpositiondiff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.tomlindex 6a1012d639..0bee6e69a7 100644--- a/config/deployments/env_specific.toml+++ b/config/deployments/env_specific.toml@@ -451,7 +451,6 @@ proxy_connector_http_status_code = false # If enabled, the http status code opayments_base_url = "http://localhost:8080"[superposition]-enabled = true # Enable or disable Superposition integration (default: false)endpoint = "http://superposition:8080" # Superposition service endpoint URLtoken = "your_superposition_token" # Superposition tokenorg_id = "your_org_id" # Organization ID in Superpositiondiff --git a/config/development.toml b/config/development.tomlindex 47c35287e0..f4740b1a1b 100644--- a/config/development.toml+++ b/config/development.toml@@ -1530,12 +1530,11 @@ internal_api_key = "test_internal_api_key"payments_base_url = "http://localhost:8080"[superposition]-enabled = true # Enable Superposition integrationendpoint = "http://localhost:8081" # Superposition service endpointtoken = "123456" # Superposition tokenorg_id = "localorg" # Organization ID in Superpositionworkspace_id = "dev" # Workspace ID in Superposition-polling_interval = 15 # Polling interval in seconds for configuration updates+polling_interval = 300 # Polling interval in seconds for configuration updates# request_timeout = # Request timeout in seconds for Superposition API calls (optional, default: none)backup_file_path = "./config/superposition_seed.toml" # Path to a local file for fallback configuration. Used when the Superposition HTTP service is unavailable. If set, the client will fall back to reading configuration from this file instead of failing completely. This ensures graceful degradation during network outages or service disruptions.diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 60124215e0..a7e36b11f0 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -1409,7 +1409,6 @@ internal_api_key = "test_internal_api_key" # API key for internal merchant id anpayments_base_url = "http://localhost:8080"[superposition]-enabled = true # Enable Superposition for dynamic configuration managementendpoint = "http://superposition:8080" # Superposition service endpointtoken = "123456" # Superposition tokenorg_id = "localorg" # Organization ID in Superpositiondiff --git a/config/superposition_seed.toml b/config/superposition_seed.tomlindex 48d1b89943..1d29a9c251 100644--- a/config/superposition_seed.toml+++ b/config/superposition_seed.toml@@ -73,6 +73,12 @@ schema = { type = "boolean" }description = "Whether client session validation is enabled for payments"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"+[default-configs.should_call_gsm]value = falseschema = { type = "boolean" }diff --git a/crates/drainer/src/main.rs b/crates/drainer/src/main.rsindex 91ec191bf9..b403f60a15 100644--- a/crates/drainer/src/main.rs+++ b/crates/drainer/src/main.rs@@ -32,7 +32,13 @@ async fn main() -> DrainerResult<()> {let _guard = router_env::setup(&conf.log,router_env::service_name!(),- [router_env::service_name!()],+ [+ router_env::service_name!(),+ "actix_server",+ "open_feature",+ "superposition_provider",+ "superposition_sdk",+ ],);#[allow(clippy::expect_used)]diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.tomlindex 5bc8112a3f..6f67bcdd2e 100644--- a/crates/external_services/Cargo.toml+++ b/crates/external_services/Cargo.toml@@ -12,7 +12,7 @@ aws_kms = ["dep:aws-config", "dep:aws-sdk-kms"]email = ["dep:aws-config"]aws_s3 = ["dep:aws-config", "dep:aws-sdk-s3"]hashicorp-vault = ["dep:vaultrs"]-superposition = ["dep:open-feature", "dep:superposition_provider"]+superposition = ["dep:open-feature", "dep:superposition_provider", "dep:superposition_sdk"]v1 = ["hyperswitch_interfaces/v1", "common_utils/v1"]v2 = ["hyperswitch_interfaces/v2", "common_utils/v2"]revenue_recovery = [@@ -77,6 +77,7 @@ unified-connector-service-client = { git = "https://github.com/juspay/connector-open-feature = { version = "0.2.5", optional = true }superposition_provider = { version = "0.102.0", optional = true}superposition_types = "0.102.0"+superposition_sdk = { version = "0.102.0", optional = true }# First party cratesdiff --git a/crates/external_services/src/superposition.rs b/crates/external_services/src/superposition.rsindex 5c8bd1db5a..3840488453 100644--- a/crates/external_services/src/superposition.rs+++ b/crates/external_services/src/superposition.rs@@ -5,15 +5,21 @@ pub mod types;use std::collections::HashMap;+use aws_smithy_types::Document;use common_utils::{errors::CustomResult, id_type::TargetingKey};use error_stack::{report, ResultExt};use hyperswitch_masking::ExposeInterface;use serde_json::Map;use superposition_provider::traits::AllFeatureProvider;-pub use self::types::{ConfigContext, SuperpositionClientConfig, SuperpositionError};+pub use self::types::{ConfigContext, SuperpositionClientConfig, SuperpositionError, ToDocument};use crate::config_metrics;+/// Generate a default change reason from the config key+fn generate_change_reason(key: &str) -> String {+ format!("Updating {key} configuration")+}+fn convert_open_feature_value(value: open_feature::Value) -> Result<serde_json::Value, String> {match value {open_feature::Value::String(s) => Ok(serde_json::Value::String(s)),@@ -115,14 +121,26 @@ impl GetValue<serde_json::Value> for open_feature::Client {// Debug trait cannot be derived because open_feature::Client doesn't implement Debug#[allow(missing_debug_implementations)]pub struct SuperpositionClient {+ /// OpenFeature client for reading configsclient: open_feature::Client,/// Provider for Superposition (using LocalResolutionProvider for fallback support)provider: superposition_provider::local_provider::LocalResolutionProvider,+ /// SDK client for writing configs (create/update operations)+ sdk_client: superposition_sdk::Client,+ /// Organization ID for write operations+ org_id: String,+ /// Workspace ID for write operations+ workspace_id: String,+ /// Name of the service performing writes, attached to audit metadata+ service_name: &'static str,}impl SuperpositionClient {- /// Create a new Superposition client- pub async fn new(config: SuperpositionClientConfig) -> CustomResult<Self, SuperpositionError> {+ /// Create a new Superposition client.+ pub async fn new(+ config: SuperpositionClientConfig,+ service_name: &'static str,+ ) -> CustomResult<Self, SuperpositionError> {let token_value = config.token.expose();let refresh_strategy = superposition_provider::RefreshStrategy::Polling(@@ -187,7 +205,25 @@ impl SuperpositionClient {router_env::logger::info!("Superposition client initialized successfully");- Ok(Self { client, provider })+ // Initialize SDK client for write operations+ // Use the same token_value extracted earlier for the provider+ let sdk_config = superposition_sdk::Config::builder()+ .endpoint_url(config.endpoint.clone())+ .bearer_token(superposition_sdk::config::Token::new(token_value, None))+ .build();++ let sdk_client = superposition_sdk::Client::from_conf(sdk_config);++ router_env::logger::info!("Superposition SDK client initialized successfully");++ Ok(Self {+ client,+ sdk_client,+ provider,+ org_id: config.org_id,+ workspace_id: config.workspace_id,+ service_name,+ })}/// Build evaluation context for Superposition requests@@ -300,6 +336,77 @@ impl SuperpositionClient {}}}++ /// Generic method to set a configuration value in Superposition+ ///+ /// # Type Parameters+ /// * `T` - A type implementing `WritableConfig` that defines the config key and input type+ ///+ /// # Arguments+ /// * `value` - The value to write+ /// * `context` - The context (dimensions) for this config+ ///+ /// # Returns+ /// * `CustomResult<(), SuperpositionError>` - Success or error+ pub async fn set_config_value<T: WritableConfig>(+ &self,+ value: &T::Input,+ context: &ConfigContext,+ ) -> CustomResult<(), SuperpositionError> {+ let mut builder = superposition_sdk::types::ContextPut::builder();++ // Add context entries (dimensions)+ for (key, val) in &context.values {+ builder = builder.context(key, Document::String(val.clone()));+ }++ let change_reason = generate_change_reason(T::SUPERPOSITION_KEY);++ builder = builder+ .r#override(T::SUPERPOSITION_KEY, value.to_document())+ .change_reason(change_reason)+ .description(format!(+ "[{}] Config update for {}",+ self.service_name,+ T::SUPERPOSITION_KEY+ ));++ let context_put = builder.build().map_err(|e| {+ report!(SuperpositionError::ClientError(format!(+ "Failed to build ContextPut: {e:?}"+ )))+ })?;++ // Call create_context API+ let response = self+ .sdk_client+ .create_context()+ .workspace_id(self.workspace_id.clone())+ .org_id(self.org_id.clone())+ .request(context_put)+ .send()+ .await;++ response.change_context(SuperpositionError::ClientError(format!(+ "Failed to set {} config",+ T::SUPERPOSITION_KEY+ )))?;++ router_env::logger::info!("Set {} config successfully", T::SUPERPOSITION_KEY);++ Ok(())+ }+}++/// Trait for configs that can be written to Superposition.+/// This is separate from the Config trait - a config type can implement+/// one or both traits depending on whether it supports read and/or write operations.+pub trait WritableConfig {+ /// The type of value to write (input type)+ type Input: ToDocument;++ /// The Superposition key for this config+ const SUPERPOSITION_KEY: &'static str;}/// Each config type implements this trait to define how its value should bediff --git a/crates/external_services/src/superposition/types.rs b/crates/external_services/src/superposition/types.rsindex b0357a66ac..f0605d44e8 100644--- a/crates/external_services/src/superposition/types.rs+++ b/crates/external_services/src/superposition/types.rs@@ -2,12 +2,40 @@use std::{collections::HashMap, sync::Arc};+use aws_smithy_types::Document;use common_utils::{errors::CustomResult, fp_utils::when};use error_stack::ResultExt;use hyperswitch_masking::{ExposeInterface, Secret};use super::SuperpositionClient;+/// Trait for converting Rust types to Superposition Document for write operations+pub trait ToDocument {+ /// Convert the value to a Document for storage in Superposition+ fn to_document(&self) -> Document;+}++impl ToDocument for String {+ fn to_document(&self) -> Document {+ Document::String(self.clone())+ }+}++impl ToDocument for bool {+ fn to_document(&self) -> Document {+ Document::Bool(*self)+ }+}++impl ToDocument for i64 {+ fn to_document(&self) -> Document {+ match *self {+ n if n >= 0 => Document::Number(aws_smithy_types::Number::PosInt(n.unsigned_abs())),+ n => Document::Number(aws_smithy_types::Number::NegInt(n)),+ }+ }+}+/// Wrapper type for JSON values from Superposition#[derive(Debug, Clone)]pub struct JsonValue(serde_json::Value);@@ -42,8 +70,6 @@ impl TryFrom<open_feature::StructValue> for JsonValue {#[derive(Debug, Clone, serde::Deserialize)]#[serde(default)]pub struct SuperpositionClientConfig {- /// Whether Superposition is enabled- pub enabled: bool,/// Superposition API endpointpub endpoint: String,/// Authentication token for Superposition@@ -64,7 +90,6 @@ pub struct SuperpositionClientConfig {impl Default for SuperpositionClientConfig {fn default() -> Self {Self {- enabled: false,endpoint: String::new(),token: Secret::new(String::new()),org_id: String::new(),@@ -101,11 +126,12 @@ pub struct ConfigContext {}impl SuperpositionClientConfig {- /// Create and return a Superposition client+ /// Create and return a Superposition client.pub async fn get_superposition_client(&self,+ service_name: &'static str,) -> CustomResult<Arc<SuperpositionClient>, SuperpositionError> {- let client = SuperpositionClient::new(self.clone())+ let client = SuperpositionClient::new(self.clone(), service_name).await.change_context(SuperpositionError::ClientInitError("Failed to create Superposition client".to_string(),@@ -115,10 +141,6 @@ impl SuperpositionClientConfig {/// Validate the Superposition configurationpub fn validate(&self) -> Result<(), SuperpositionError> {- if !self.enabled {- return Ok(());- }-when(self.endpoint.is_empty(), || {Err(SuperpositionError::InvalidConfiguration("Superposition endpoint cannot be empty".to_string(),@@ -185,13 +207,9 @@ impl hyperswitch_interfaces::secrets_interface::secret_handler::SecretsHandlerhyperswitch_interfaces::secrets_interface::SecretsManagementError,> {let superposition_config = value.get_inner();- let token = if superposition_config.enabled {- secret_management_client- .get_secret(superposition_config.token.clone())- .await?- } else {- superposition_config.token.clone()- };+ let token = secret_management_client+ .get_secret(superposition_config.token.clone())+ .await?;Ok(value.transition_state(|superposition_config| Self {token,diff --git a/crates/router/src/bin/router.rs b/crates/router/src/bin/router.rsindex 0fb415bdd4..62086b4abf 100644--- a/crates/router/src/bin/router.rs+++ b/crates/router/src/bin/router.rs@@ -27,7 +27,13 @@ async fn main() -> ApplicationResult<()> {let _guard = router_env::setup(&conf.log,router_env::service_name!(),- [router_env::service_name!(), "actix_server"],+ [+ router_env::service_name!(),+ "actix_server",+ "open_feature",+ "superposition_provider",+ "superposition_sdk",+ ],).change_context(ApplicationError::ConfigurationError)?;@@ -39,7 +45,7 @@ async fn main() -> ApplicationResult<()> {);#[allow(clippy::expect_used)]- let server = Box::pin(router::start_server(conf))+ let server = Box::pin(router::start_server(conf, router_env::service_name!())).await.expect("Failed to create the server");let _ = server.await;diff --git a/crates/router/src/bin/scheduler.rs b/crates/router/src/bin/scheduler.rsindex 511f5e3bd6..70d4056f03 100644--- a/crates/router/src/bin/scheduler.rs+++ b/crates/router/src/bin/scheduler.rs@@ -44,6 +44,7 @@ async fn main() -> CustomResult<(), ProcessTrackerError> {conf,redis_shutdown_signal_tx,api_client,+ router_env::service_name!(),)).await;// channel to shutdown scheduler gracefully@@ -71,7 +72,13 @@ async fn main() -> CustomResult<(), ProcessTrackerError> {let _guard = router_env::setup(&state.conf.log,&scheduler_flow_str,- [router_env::service_name!()],+ [+ router_env::service_name!(),+ "actix_server",+ "open_feature",+ "superposition_provider",+ "superposition_sdk",+ ],);#[allow(clippy::expect_used)]diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rsindex 8c948a3682..8a78241fbc 100644--- a/crates/router/src/consts.rs+++ b/crates/router/src/consts.rs@@ -285,8 +285,8 @@ pub const IRRELEVANT_PAYMENT_ATTEMPT_ID: &str = "irrelevant_payment_attempt_id";pub static PROFILE_ID_UNAVAILABLE: sync::LazyLock<id_type::ProfileId> = sync::LazyLock::new(|| {#[allow(clippy::expect_used)]- id_type::ProfileId::from_str("PROFILE_ID_UNAVAIABLE")- .expect("Failed to parse PROFILE_ID_UNAVAIABLE")+ id_type::ProfileId::from_str("PROFILE_ID_UNAVAILABLE")+ .expect("Failed to parse PROFILE_ID_UNAVAILABLE")});/// Default payment attempt id@@ -357,6 +357,8 @@ 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+ pub const FINGERPRINT_SECRET: &str = "fingerprint_secret";/// GSM (Global Status Map) call configuration keypub const SHOULD_CALL_GSM: &str = "should_call_gsm";/// Eligibility check configuration keydiff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex 66f5d35d97..5a4efdb26e 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -11,9 +11,9 @@ use common_utils::{fp_utils, id_type, pii, type_name,types::keymanager::{self as km_types, KeyManagerState, ToEncryptable},};+use diesel_models::payment_method;#[cfg(all(any(feature = "v1", feature = "v2"), feature = "olap"))]use diesel_models::{business_profile::CardTestingGuardConfig, organization::OrganizationBridge};-use diesel_models::{configs, payment_method};use error_stack::{report, FutureExt, ResultExt};use external_services::http_client::client;use hyperswitch_domain_models::merchant_connector_account::{@@ -34,6 +34,7 @@ use crate::types::transformers::ForeignFrom;use crate::{consts,core::{+ configs::dimension_state,connector_validation::ConnectorAuthTypeAndMetadataValidation,disputes,encryption::transfer_encryption_key,@@ -73,26 +74,18 @@ pub fn create_merchant_publishable_key() -> String {)}-pub async fn insert_merchant_configs(- db: &dyn StorageInterface,- merchant_id: &id_type::MerchantId,+/// Insert merchant configs using Superposition for fingerprint_secret+pub async fn insert_merchant_configs_with_superposition(+ state: &SessionState,+ dimensions: &dimension_state::DimensionsWithProcessorMerchantId,) -> RouterResult<()> {- db.insert_config(configs::ConfigNew {- key: merchant_id.get_requires_cvv_key(),- config: "true".to_string(),- })- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Error while setting requires_cvv config")?;-- db.insert_config(configs::ConfigNew {- key: merchant_id.get_merchant_fingerprint_secret_key(),- config: utils::generate_id(consts::FINGERPRINT_SECRET_LENGTH, "fs"),- })- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Error while inserting merchant fingerprint secret")?;+ 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(())}@@ -403,9 +396,17 @@ pub async fn create_merchant_account(key_store.clone(),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);- insert_merchant_configs(db, &merchant_id).await?;+ Box::pin(insert_merchant_configs_with_superposition(+ &state,+ &dimensions,+ ))+ .await?;Ok(service_api::ApplicationResponse::Json(api::MerchantAccountResponse::foreign_try_from(merchant_account)diff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rsindex 75eaaca156..0f8e36fac6 100644--- a/crates/router/src/core/blocklist/utils.rs+++ b/crates/router/src/core/blocklist/utils.rs@@ -7,14 +7,13 @@ use hyperswitch_masking::StrongSecret;use super::{errors, transformers::generate_fingerprint, SessionState};use crate::{- consts,core::{+ configs::dimension_state,errors::{RouterResult, StorageErrorExt},payments::PaymentData,},logger,types::{domain, storage, transformers::ForeignInto},- utils,};pub async fn delete_entry_from_blocklist(@@ -218,35 +217,21 @@ pub async fn insert_entry_into_blocklist(pub async fn get_merchant_fingerprint_secret(state: &SessionState,- merchant_id: &common_utils::id_type::MerchantId,+ dimensions: &dimension_state::DimensionsWithProcessorMerchantId,) -> RouterResult<String> {- let key = merchant_id.get_merchant_fingerprint_secret_key();- let config_fetch_result = state.store.find_config_by_key(&key).await;-- match config_fetch_result {- Ok(config) => Ok(config.config),-- Err(e) if e.current_context().is_db_not_found() => {- let new_fingerprint_secret =- utils::generate_id(consts::FINGERPRINT_SECRET_LENGTH, "fs");- let new_config = storage::ConfigNew {- key,- config: new_fingerprint_secret.clone(),- };-- state- .store- .insert_config(new_config)- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("unable to create new fingerprint secret for merchant")?;-- Ok(new_fingerprint_secret)- }+ // 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;- Err(e) => Err(e)- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("error fetching merchant fingerprint secret"),+ match secret.is_empty() {+ false => Ok(secret),+ true => Err(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("fingerprint_secret not found in Superposition for merchant"),}}@@ -309,12 +294,15 @@ 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 merchant_id = processor.get_account().get_id();- let merchant_fingerprint_secret = get_merchant_fingerprint_secret(state, merchant_id).await?;+ let processor_dimensions = dimensions.without_provider_merchant_id();+ let merchant_fingerprint_secret =+ get_merchant_fingerprint_secret(state, &processor_dimensions).await?;// Hashed Fingerprint to check whether or not this payment should be blocked.let card_number_fingerprint =@@ -417,6 +405,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,payment_data: &mut PaymentData<F>,business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse>@@ -427,6 +416,7 @@ wherelet block_reason = should_payment_be_blocked(state,processor,+ dimensions,&payment_data.payment_method_data.clone()@@ -483,7 +473,7 @@ where} else {payment_data.payment_attempt.fingerprint_id = generate_payment_fingerprint(state,- payment_data.payment_attempt.merchant_id.clone(),+ &dimensions.without_provider_merchant_id(),payment_data.payment_method_data.clone(),).await?;@@ -589,10 +579,10 @@ pub async fn should_payment_be_blocked_by_profile_config(pub async fn generate_payment_fingerprint(state: &SessionState,- merchant_id: common_utils::id_type::MerchantId,+ dimensions: &dimension_state::DimensionsWithProcessorMerchantId,payment_method_data: Option<domain::PaymentMethodData>,) -> CustomResult<Option<String>, errors::ApiErrorResponse> {- let merchant_fingerprint_secret = get_merchant_fingerprint_secret(state, &merchant_id).await?;+ let merchant_fingerprint_secret = get_merchant_fingerprint_secret(state, dimensions).await?;Ok(if let Some(domain::PaymentMethodData::Card(card)) = payment_method_data.as_ref() {diff --git a/crates/router/src/core/configs.rs b/crates/router/src/core/configs.rsindex b722ea3234..1b2a1fb8af 100644--- a/crates/router/src/core/configs.rs+++ b/crates/router/src/core/configs.rs@@ -195,7 +195,7 @@ wherelet superposition_result = C::fetch(superposition_client, context, targeting_key).await;- let resolved_value = match superposition_result {+ match superposition_result {Ok(value) => {router_env::logger::info!(config_key = %config_type,@@ -262,8 +262,7 @@ wheredefault_value}},- };- resolved_value+ }}/// Fetch object-type config with JSON-to-Type conversion.diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rsindex b5bcc0d4e9..8fb7a654d9 100644--- a/crates/router/src/core/configs/dimension_config.rs+++ b/crates/router/src/core/configs/dimension_config.rs@@ -1,9 +1,50 @@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, 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:@@ -147,6 +188,23 @@ impl DatabaseBackedConfig for ImplicitCustomerUpdate {}}+config! {+ superposition_key = FINGERPRINT_SECRET,+ output = String,+ default = String::new(),+ requires = dimension_state::DimensionsWithProcessorMerchantId,+ targeting_key = id_type::MerchantId+}++impl DatabaseBackedConfig for FingerprintSecret {+ const KEY: &'static str = "fingerprint_secret";+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {+ dimensions+ .get_processor_merchant_id()+ .map(|id| format!("{}_{}", id.get_string_repr(), Self::KEY))+ }+}+config! {superposition_key = SHOULD_CALL_GSM,output = bool,@@ -240,6 +298,13 @@ 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/configs/dimension_state.rs b/crates/router/src/core/configs/dimension_state.rsindex 0750cc942f..d76ac04699 100644--- a/crates/router/src/core/configs/dimension_state.rs+++ b/crates/router/src/core/configs/dimension_state.rs@@ -486,6 +486,16 @@ pub type DimensionsWithProviderMerchantId = Dimensions<NoPayoutRetryType,>;+// Type alias - only processor merchant ID present+pub type DimensionsWithProcessorMerchantId = Dimensions<+ NoProviderMerchantId,+ HasProcessorMerchantId,+ NoOrgId,+ NoProfileId,+ NoConnector,+ NoPayoutRetryType,+>;+// Type aliases - both provider and processor merchant IDs presentpub type DimensionsWithProcessorAndProviderMerchantId = Dimensions<HasProviderMerchantId,diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 4ee988c433..f27a6d5b95 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -131,7 +131,10 @@ use crate::{},consts,core::{- configs::dimension_state,+ configs::dimension_state::{+ Dimensions, DimensionsWithProcessorAndProviderMerchantId,+ DimensionsWithProcessorAndProviderMerchantIdAndProfileId,+ },errors::{self, CustomResult, RouterResponse, RouterResult},payment_methods::{cards, network_tokenization, transformers as pm_transformers, utils as pm_utils,@@ -215,7 +218,7 @@ wherePaymentResponse: Operation<F, FData, Data = D>,FData: Send + Sync + Clone,{- let dimensions = dimension_state::Dimensions::new()+ 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());@@ -638,7 +641,7 @@ pub async fn payments_operation_core<'a, F, Req, Op, FData, D>(auth_flow: services::AuthFlow,eligible_connectors: Option<Vec<enums::RoutableConnectors>>,header_payload: HeaderPayload,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantId,) -> RouterResult<(D, Req, Option<u16>, Option<u128>)>whereF: Send + Clone + Sync + Debug + 'static,@@ -1491,7 +1494,7 @@ pub async fn proxy_for_payments_operation_core<F, Req, Op, FData, D>(auth_flow: services::AuthFlow,header_payload: HeaderPayload,return_raw_connector_response: Option<bool>,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantId,) -> RouterResult<(D, Req, Option<u16>, Option<u128>)>whereF: Send + Clone + Sync,@@ -1840,7 +1843,7 @@ where// Get the trackers related to track the state of the paymentlet operations::GetTrackerResponse { mut payment_data } = get_tracker_response;- let dimensions = dimension_state::Dimensions::new()+ 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());@@ -1963,7 +1966,7 @@ whereD: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,{let operation: BoxedOperation<'_, F, Req, D> = Box::new(operation);- let dimensions = dimension_state::Dimensions::new()+ 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());@@ -2043,6 +2046,9 @@ whereD: OperationSessionGetters<F> + Send + Sync + Clone,{let operation: BoxedOperation<'_, F, Req, D> = Box::new(operation);+ 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());tracing::Span::current().record("merchant_id",@@ -2053,7 +2059,7 @@ where.get_string_repr(),);- let dimensions = dimension_state::Dimensions::new()+ let dimensions = Dimensions::new().with_provider_merchant_id(platform.get_provider().get_provider_merchant_id()).with_processor_merchant_id(platform.get_processor().get_processor_merchant_id()).with_profile_id(profile.get_id().clone());@@ -2563,7 +2569,7 @@ where.flat_map(|c| c.foreign_try_into()).collect()});- let dimensions = dimension_state::Dimensions::new()+ 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 (payment_data, _req, connector_http_status_code, external_latency) =@@ -2628,7 +2634,7 @@ where// To perform router related operation for PaymentResponsePaymentResponse: Operation<F, FData, Data = D>,{- let dimensions = dimension_state::Dimensions::new()+ 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 (payment_data, _req, connector_http_status_code, external_latency) =@@ -2838,7 +2844,7 @@ pub async fn record_attempt_core(.get_string_repr(),);- let dimensions = dimension_state::Dimensions::new()+ 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());@@ -4813,7 +4819,7 @@ pub async fn complete_connector_service<F, RouterDReq, ApiRequest, D>(header_payload: HeaderPayload,frm_suggestion: Option<storage_enums::FrmSuggestion>,call_connector_service_response: ConnectorServiceIntermediateState<F, RouterDReq>,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantId,) -> RouterResult<(RouterData<F, RouterDReq, router_types::PaymentsResponseData>,helpers::MerchantConnectorAccountType,@@ -4926,6 +4932,10 @@ wheredyn api::Connector:services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,{+ let dimensions = Dimensions::new()+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())+ .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id());+let merchant_connector_account = construct_profile_id_and_get_mca(state,platform.get_processor(),@@ -5024,6 +5034,7 @@ whereblocklist_guard(state,platform.get_processor(),+ &dimensions,operation,payment_data,business_profile,@@ -5306,7 +5317,7 @@ pub async fn complete_connector_service<F, RouterDReq, ApiRequest, D>(header_payload: HeaderPayload,frm_suggestion: Option<storage_enums::FrmSuggestion>,call_connector_service_response: ConnectorServiceIntermediateState<F, RouterDReq>,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantId,) -> RouterResult<(RouterData<F, RouterDReq, router_types::PaymentsResponseData>,domain::MerchantConnectorAccountTypeDetails,@@ -5677,7 +5688,7 @@ where).await?;- let dimensions = dimension_state::Dimensions::new()+ 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());@@ -5738,7 +5749,7 @@ whereNone => true,};- let dimensions = dimension_state::Dimensions::new()+ let dimensions = Dimensions::new().with_provider_merchant_id(platform.get_provider().get_provider_merchant_id()).with_processor_merchant_id(platform.get_processor().get_processor_merchant_id()).with_profile_id(business_profile.get_id().clone());@@ -5900,7 +5911,7 @@ pub async fn call_unified_connector_service_for_external_proxy<F, RouterDReq, Apexternal_vault_merchant_connector_account_type_details: domain::MerchantConnectorAccountTypeDetails,mut router_data: RouterData<F, RouterDReq, router_types::PaymentsResponseData>,_updated_customer: Option<storage::CustomerUpdate>,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantId,) -> RouterResult<RouterData<F, RouterDReq, router_types::PaymentsResponseData>>whereF: Send + Clone + Sync,@@ -5983,6 +5994,10 @@ wheredyn api::Connector:services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,{+ 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 stime_connector = Instant::now();let merchant_connector_account = construct_profile_id_and_get_mca(@@ -6110,9 +6125,6 @@ where}let frm_suggestion = None;- let dimensions = dimension_state::Dimensions::new()- .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())- .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id());(_, *payment_data) = operation.to_update_tracker()?.update_trackers(@@ -6193,7 +6205,7 @@ where).await?,));- let dimensions = dimension_state::Dimensions::new()+ 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());@@ -6322,7 +6334,7 @@ where{let stime_connector = Instant::now();- let dimensions = dimension_state::Dimensions::new()+ 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());@@ -6869,6 +6881,7 @@ pub async fn get_merchant_bank_data_for_open_banking_connectors(async fn blocklist_guard<F, ApiRequest, D>(state: &SessionState,processor: &domain::Processor,+ dimensions: &DimensionsWithProcessorAndProviderMerchantId,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,business_profile: &domain::Profile,@@ -6899,7 +6912,13 @@ whereif blocklist_guard_enabled {Ok(operation.to_domain()?- .guard_payment_against_blocklist(state, processor, payment_data, business_profile)+ .guard_payment_against_blocklist(+ state,+ processor,+ dimensions,+ payment_data,+ business_profile,+ ).await?)} else {Ok(false)@@ -8747,7 +8766,7 @@ impl PaymentEligibilityData {payment_method_type: common_enums::PaymentMethod,profile_id: &id_type::ProfileId,) -> CustomResult<Option<domain::EligibilityPaymentMethodData>, errors::ApiErrorResponse> {- let pm_modular_dimensions = dimension_state::Dimensions::new().with_organization_id(+ let pm_modular_dimensions = Dimensions::new().with_organization_id(platform.get_processor().get_account()@@ -9765,7 +9784,7 @@ pub async fn choose_connector<F, Req, D>(payment_data: &mut D,eligible_connectors: Option<Vec<enums::RoutableConnectors>>,mandate_type: Option<api::MandateTransactionType>,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,) -> RouterResult<Option<ConnectorCallType>>whereF: Send + Clone,@@ -10003,7 +10022,7 @@ wherepub async fn validate_for_proxy_payment<F, D>(state: &SessionState,payment_data: &D,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,payment_id: &id_type::PaymentId,) -> RouterResult<()>where@@ -10047,7 +10066,7 @@ pub async fn perform_routing_for_connector_selection<F, D>(request_straight_through: Option<serde_json::Value>,eligible_connectors: Option<Vec<enums::RoutableConnectors>>,mandate_type: Option<api::MandateTransactionType>,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,fallback_config: Vec<api_models::routing::RoutableConnectorChoice>,backend_input: dsl_inputs::BackendInput,) -> RouterResult<ConnectorCallType>@@ -10296,7 +10315,7 @@ pub async fn decide_connector<F, D>(routing_data: &mut storage::RoutingData,eligible_connectors: Option<Vec<enums::RoutableConnectors>>,mandate_type: Option<api::MandateTransactionType>,- dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,+ dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,fallback_config: Vec<api_models::routing::RoutableConnectorChoice>,backend_input: dsl_inputs::BackendInput,is_payment_method_modular_allowed: bool,@@ -10489,7 +10508,6 @@ whereis_payment_method_modular_allowed,business_profile.is_connector_agnostic_mit_enabled,business_profile.is_network_tokenization_enabled,- dimensions,).await}@@ -10505,7 +10523,6 @@ pub async fn plan_payment_execution_after_routing<F: Clone, D>(is_payment_method_modular_allowed: bool,is_connector_agnostic_mit_enabled: Option<bool>,is_network_tokenization_enabled: bool,- _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,) -> RouterResult<ConnectorCallType>whereD: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,@@ -12086,9 +12103,14 @@ 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,)@@ -12109,7 +12131,7 @@ impl EligibilityCheck for BlockListCheck {}}-// Perform Card Testing Gaurd Check+// Perform Card Testing Guard Check#[cfg(feature = "v1")]struct CardTestingCheck;diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rsindex 1fae8e2a2f..45471510ea 100644--- a/crates/router/src/core/payments/operations.rs+++ b/crates/router/src/core/payments/operations.rs@@ -450,6 +450,7 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut D,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {@@ -722,6 +723,7 @@ where&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut D,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {@@ -812,6 +814,7 @@ where&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut D,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {@@ -903,6 +906,7 @@ where&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut D,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {@@ -988,6 +992,7 @@ where&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut D,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_attempt_list.rs b/crates/router/src/core/payments/operations/payment_attempt_list.rsindex 49c27be3a9..44d1d9e69f 100644--- a/crates/router/src/core/payments/operations/payment_attempt_list.rs+++ b/crates/router/src/core/payments/operations/payment_attempt_list.rs@@ -213,6 +213,7 @@ impl<F: Clone + Send + Sync>&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut payments::PaymentAttemptListData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rsindex 9dd9924634..a730b59c2f 100644--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs@@ -294,6 +294,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsCancelPostCaptureRequest, Pa&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> errors::CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex 4158d7d1f7..670b7f34dc 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -500,6 +500,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex fd649fb660..9994aeea47 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -2190,12 +2190,14 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for&'a self,state: &SessionState,processor: &domain::Processor,+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,payment_data: &mut PaymentData<F>,business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {blocklist_utils::validate_data_for_blocklist(state,processor,+ dimensions,payment_data,business_profile,)diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 830896d411..d162a13f8c 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -1041,6 +1041,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_create_intent.rs b/crates/router/src/core/payments/operations/payment_create_intent.rsindex f69cf125d4..57e0539d49 100644--- a/crates/router/src/core/payments/operations/payment_create_intent.rs+++ b/crates/router/src/core/payments/operations/payment_create_intent.rs@@ -294,6 +294,7 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsCreateIntentRequest, payments::Pa&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut payments::PaymentIntentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_get_intent.rs b/crates/router/src/core/payments/operations/payment_get_intent.rsindex 7117ea9b2e..8a2c50b057 100644--- a/crates/router/src/core/payments/operations/payment_get_intent.rs+++ b/crates/router/src/core/payments/operations/payment_get_intent.rs@@ -215,6 +215,7 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsGetIntentRequest, payments::Payme&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut payments::PaymentIntentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rsindex 4d8b7a07b3..4f4d8a4ea0 100644--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs@@ -254,6 +254,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsPostSessionTokensRequest, Pa&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> errors::CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex 86380e2fdf..128500ca67 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -529,6 +529,7 @@ where&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> errors::CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_session_intent.rs b/crates/router/src/core/payments/operations/payment_session_intent.rsindex 5366375cc2..8b85f46ade 100644--- a/crates/router/src/core/payments/operations/payment_session_intent.rs+++ b/crates/router/src/core/payments/operations/payment_session_intent.rs@@ -371,6 +371,7 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsSessionRequest, payments::Payment&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut payments::PaymentIntentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex d234e35e20..6619246452 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -377,6 +377,7 @@ where&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rsindex 3b7972d18f..ea3c6ffc26 100644--- a/crates/router/src/core/payments/operations/payment_status.rs+++ b/crates/router/src/core/payments/operations/payment_status.rs@@ -153,6 +153,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 0e3cc3e752..79cbbcf29f 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -793,6 +793,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_update_intent.rs b/crates/router/src/core/payments/operations/payment_update_intent.rsindex d957b2dd11..a83bb24b2c 100644--- a/crates/router/src/core/payments/operations/payment_update_intent.rs+++ b/crates/router/src/core/payments/operations/payment_update_intent.rs@@ -487,6 +487,7 @@ impl<F: Clone + Send> Domain<F, PaymentsUpdateIntentRequest, payments::PaymentIn&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut payments::PaymentIntentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rsindex 94a7bfd8ba..cbeaa7068d 100644--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs@@ -260,6 +260,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsUpdateMetadataRequest, Payme&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> errors::CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rsindex a4ec168777..cea8b1a716 100644--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs@@ -276,6 +276,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsExtendAuthorizationRequest,&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> errors::CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rsindex c5bdeb6ac8..f8466f67d4 100644--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs@@ -394,6 +394,7 @@ impl<F: Clone + Send + Sync>&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut payments::PaymentData<F>,_business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rsindex e37f815563..5099f0cf23 100644--- a/crates/router/src/core/payments/operations/tax_calculation.rs+++ b/crates/router/src/core/payments/operations/tax_calculation.rs@@ -372,6 +372,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsDynamicTaxCalculationRequest&'a self,_state: &SessionState,_processor: &domain::Processor,+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,_payment_data: &mut PaymentData<F>,_business_profile: &domain::Profile,) -> errors::CustomResult<bool, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rsindex 7fc1dafe77..5148cbc9d8 100644--- a/crates/router/src/core/user.rs+++ b/crates/router/src/core/user.rs@@ -1829,13 +1829,13 @@ pub async fn create_org_merchant_for_user(default_product_type,)?;- admin::create_merchant_account(+ Box::pin(admin::create_merchant_account(state.clone(),merchant_account_create_request,Some(auth::AuthenticationDataWithOrg {organization_id: org.get_organization_id(),}),- )+ )).await.change_context(UserErrors::InternalServerError).attach_printable("Error while creating a merchant")?;diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex 5a0edbd599..fe87d2fde6 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -1010,6 +1010,7 @@ mod tests {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let app_state_arc = Arc::new(app_state);@@ -1124,6 +1125,7 @@ mod tests {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = &Arc::new(app_state)@@ -1234,6 +1236,7 @@ mod tests {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rsindex 845dd42818..f38d7461bb 100644--- a/crates/router/src/db/merchant_connector_account.rs+++ b/crates/router/src/db/merchant_connector_account.rs@@ -137,6 +137,7 @@ mod merchant_connector_account_cache_tests {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;@@ -320,6 +321,7 @@ mod merchant_connector_account_cache_tests {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = &Arc::new(app_state)diff --git a/crates/router/src/db/merchant_key_store.rs b/crates/router/src/db/merchant_key_store.rsindex 837c619df9..659044e39d 100644--- a/crates/router/src/db/merchant_key_store.rs+++ b/crates/router/src/db/merchant_key_store.rs@@ -31,6 +31,7 @@ mod tests {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = &Arc::new(app_state)diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rsindex 065b7a74f9..d691797b3b 100644--- a/crates/router/src/lib.rs+++ b/crates/router/src/lib.rs@@ -276,14 +276,17 @@ pub fn mk_app(////// Unwrap used because without the value we can't start the server#[allow(clippy::expect_used, clippy::unwrap_used)]-pub async fn start_server(conf: settings::Settings<SecuredSecret>) -> ApplicationResult<Server> {+pub async fn start_server(+ conf: settings::Settings<SecuredSecret>,+ service_name: &'static str,+) -> ApplicationResult<Server> {logger::debug!(startup_config=?conf);let server = conf.server.clone();let (tx, rx) = oneshot::channel();let api_client = Box::new(services::ProxyClient::new(&conf.proxy).map_err(|error| {errors::ApplicationError::ApiClientError(error.current_context().clone())})?);- let state = Box::pin(AppState::new(conf, tx, api_client)).await;+ let state = Box::pin(AppState::new(conf, tx, api_client, service_name)).await;let request_body_limit = server.request_body_limit;let server_builder =diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex 1fbfe08349..0e5af56eb3 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -422,6 +422,7 @@ impl AppState {storage_impl: StorageImpl,shut_down_signal: oneshot::Sender<()>,api_client: Box<dyn crate::services::ApiClient>,+ service_name: &'static str,) -> Self {#[allow(clippy::expect_used)]let secret_management_client = conf@@ -512,7 +513,7 @@ impl AppState {let superposition_service = conf.superposition.get_inner()- .get_superposition_client()+ .get_superposition_client(service_name).await.expect("Failed to initialize superposition client");Self {@@ -616,12 +617,14 @@ impl AppState {conf: settings::Settings<SecuredSecret>,shut_down_signal: oneshot::Sender<()>,api_client: Box<dyn crate::services::ApiClient>,+ service_name: &'static str,) -> Self {Box::pin(Self::with_storage(conf,StorageImpl::Postgresql,shut_down_signal,api_client,+ service_name,)).await}diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rsindex 32e1b2e1dd..788e29edf3 100644--- a/crates/router/src/types/storage/payment_attempt.rs+++ b/crates/router/src/types/storage/payment_attempt.rs@@ -150,6 +150,7 @@ mod tests {StorageImpl::PostgresqlTest,tx,api_client,+ env!("CARGO_PKG_NAME"),)).await}diff --git a/crates/router/tests/cache.rs b/crates/router/tests/cache.rsindex 5aba196aed..85f917adc9 100644--- a/crates/router/tests/cache.rs+++ b/crates/router/tests/cache.rs@@ -14,6 +14,7 @@ async fn invalidate_existing_cache_success() {Settings::default(),tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rsindex 8e250f709e..e51ca8e834 100644--- a/crates/router/tests/connectors/utils.rs+++ b/crates/router/tests/connectors/utils.rs@@ -621,6 +621,7 @@ pub trait ConnectorActions: Connector {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)@@ -666,6 +667,7 @@ pub trait ConnectorActions: Connector {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)@@ -712,6 +714,7 @@ pub trait ConnectorActions: Connector {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)@@ -757,6 +760,7 @@ pub trait ConnectorActions: Connector {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)@@ -853,6 +857,7 @@ pub trait ConnectorActions: Connector {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)@@ -895,6 +900,7 @@ async fn call_connector<StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex d5a5a0c468..e9d7ae523f 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -284,6 +284,7 @@ async fn payments_create_core() {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;@@ -586,6 +587,7 @@ async fn payments_create_core_adyen_no_redirect() {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex 24527efda1..526cfc00d7 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -44,6 +44,7 @@ async fn payments_create_core() {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;@@ -354,6 +355,7 @@ async fn payments_create_core_adyen_no_redirect() {StorageImpl::PostgresqlTest,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)diff --git a/crates/router/tests/services.rs b/crates/router/tests/services.rsindex 7fe4a2788c..b30a143bb9 100644--- a/crates/router/tests/services.rs+++ b/crates/router/tests/services.rs@@ -14,6 +14,7 @@ async fn get_redis_conn_failure() {Settings::default(),tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)@@ -45,6 +46,7 @@ async fn get_redis_conn_success() {Settings::default(),tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;let state = Arc::new(app_state)diff --git a/crates/router/tests/utils.rs b/crates/router/tests/utils.rsindex eb369861fc..b05d5ef50b 100644--- a/crates/router/tests/utils.rs+++ b/crates/router/tests/utils.rs@@ -21,7 +21,7 @@ static SERVER: OnceCell<bool> = OnceCell::const_new();async fn spawn_server() -> bool {let conf = Settings::new().expect("invalid settings");- let server = Box::pin(router::start_server(conf))+ let server = Box::pin(router::start_server(conf, env!("CARGO_PKG_NAME"))).await.expect("failed to create server");@@ -55,6 +55,7 @@ pub async fn mk_service(router::db::StorageImpl::Mock,tx,Box::new(services::MockApiClient),+ env!("CARGO_PKG_NAME"),)).await;actix_web::test::init_service(router::mk_app(app_state, request_body_limit)).awaitdiff --git a/docker-compose-development.yml b/docker-compose-development.ymlindex 0e65f601fa..676d5489f3 100644--- a/docker-compose-development.yml+++ b/docker-compose-development.yml@@ -65,13 +65,17 @@ services:- DATABASE_URL=postgresql://db_user:db_pass@pg:5432/hyperswitch_dbsuperposition:- image: ghcr.io/juspay/superposition-demo:latest+ image: ghcr.io/juspay/superposition-demo:0.102.0ports:- "8081:8080"networks:- router_netenvironment:- API_HOSTNAME=http://localhost:8081+ - REDIS_URL=redis://redis-standalone:6379+ depends_on:+ redis-standalone:+ condition: service_healthysuperposition-init:image: alpine:latestdiff --git a/docker-compose.yml b/docker-compose.ymlindex 26c7dd663b..cd13aa4a70 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -78,13 +78,17 @@ services:- DATABASE_URL=postgresql://db_user:db_pass@pg:5432/hyperswitch_dbsuperposition:- image: ghcr.io/juspay/superposition-demo:latest+ image: ghcr.io/juspay/superposition-demo:0.102.0ports:- "8081:8080"networks:- router_netenvironment:- API_HOSTNAME=http://localhost:8081+ - REDIS_URL=redis://redis-standalone:6379+ depends_on:+ redis-standalone:+ condition: service_healthysuperposition-init:image: alpine:latestdiff --git a/scripts/seed_superposition.sh b/scripts/seed_superposition.shindex 97d1200b60..592fc2a5c3 100755--- a/scripts/seed_superposition.sh+++ b/scripts/seed_superposition.sh@@ -7,6 +7,8 @@ SUPERPOSITION_URL="${SUPERPOSITION_URL:-http://localhost:8081}"SEED_FILE="${SEED_FILE:-./config/superposition_seed.toml}"WORKSPACE_ID="${WORKSPACE_ID:-dev}"ORG_ID="${ORG_ID:-localorg}"+MAX_RETRIES="${MAX_RETRIES:-60}"+RETRY_INTERVAL="${RETRY_INTERVAL:-2}"echo "Seeding Superposition at $SUPERPOSITION_URL"echo "Using seed file: $SEED_FILE"@@ -14,21 +16,60 @@ echo "Workspace: $WORKSPACE_ID, Org: $ORG_ID"# Wait for superposition to be readyecho "Waiting for Superposition to be ready..."-for i in {1..30}; do- if curl -s "$SUPERPOSITION_URL/health" > /dev/null 2>&1; then+READY=0+for ((i=1; i<=MAX_RETRIES; i++)); do+ if curl -sS -o /dev/null "$SUPERPOSITION_URL/health"; thenecho "Superposition is ready!"+ READY=1breakfi- echo "Waiting for Superposition... ($i/30)"- sleep 2+ echo "Waiting for Superposition... ($i/$MAX_RETRIES)"+ sleep "$RETRY_INTERVAL"done+if [ "$READY" -ne 1 ]; then+ echo "Error: Superposition did not become ready at $SUPERPOSITION_URL after $((MAX_RETRIES * RETRY_INTERVAL))s"+ exit 1+fi+# Check if seed file existsif [ ! -f "$SEED_FILE" ]; thenecho "Error: Seed file not found at $SEED_FILE"exit 1fi+# POST a payload and accept 2xx or 409 (already exists); fail loudly on anything else.+post_or_fail() {+ local url="$1"+ local payload="$2"+ local label="$3"++ local tmp+ tmp=$(mktemp)+ local status+ status=$(curl -sS -o "$tmp" -w "%{http_code}" -X POST "$url" \+ -H "Content-Type: application/json" \+ -H "x-org-id: $ORG_ID" \+ -H "x-workspace: $WORKSPACE_ID" \+ -d "$payload")++ case "$status" in+ 2??)+ ;;+ 409)+ echo " $label already exists (HTTP 409), continuing"+ ;;+ *)+ echo "Error: $label failed with HTTP $status"+ echo "Response body:"+ cat "$tmp"+ rm -f "$tmp"+ exit 1+ ;;+ esac+ rm -f "$tmp"+}+# Convert TOML seed file to JSON for processingSEED_JSON=$(yq -p toml -o json '.' "$SEED_FILE")@@ -40,12 +81,7 @@ echo "$SEED_JSON" | jq -c '.dimensions | to_entries[] | {dimension: .key, positidim_name=$(echo "$dimension" | jq -r '.dimension')echo "Creating dimension: $dim_name"-- curl -s -X POST "$SUPERPOSITION_URL/dimension" \- -H "Content-Type: application/json" \- -H "x-org-id: $ORG_ID" \- -H "x-workspace: $WORKSPACE_ID" \- -d "$dimension" || echo "Dimension may already exist, continuing..."+ post_or_fail "$SUPERPOSITION_URL/dimension" "$dimension" "dimension $dim_name"done# Seed default configs@@ -56,12 +92,7 @@ echo "$SEED_JSON" | jq -c '."default-configs" | to_entries[] | {key: .key, valuekey=$(echo "$config" | jq -r '.key')echo "Setting default config: $key"-- curl -s -X POST "$SUPERPOSITION_URL/default-config" \- -H "Content-Type: application/json" \- -H "x-org-id: $ORG_ID" \- -H "x-workspace: $WORKSPACE_ID" \- -d "$config" || echo "Config may already exist, continuing..."+ post_or_fail "$SUPERPOSITION_URL/default-config" "$config" "default-config $key"doneecho "Seeding complete!"