Skip to content

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

feat(router): added superposition api support to fetch sdk configs (#11370)

Sahkal Poddara7542f2cac12
diff --git a/Cargo.lock b/Cargo.lock
index 15b4b4f0ff..dc1bd994b1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -295,7 +295,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [
"cfg-if 1.0.0",
+ "getrandom 0.2.16",
"once_cell",
+ "serde",
"version_check",
"zerocopy 0.7.35",
]
@@ -477,6 +479,7 @@ dependencies = [
"smithy",
"smithy-core",
"strum 0.26.3",
+ "superposition_types",
"tempfile",
"time",
"url",
@@ -1514,15 +1517,30 @@ dependencies = [
"syn 2.0.101",
]
+[[package]]
+name = "bit-set"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
+dependencies = [
+ "bit-vec 0.6.3",
+]
+
[[package]]
name = "bit-set"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
dependencies = [
- "bit-vec",
+ "bit-vec 0.8.0",
]
+[[package]]
+name = "bit-vec"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
+
[[package]]
name = "bit-vec"
version = "0.8.0"
@@ -3344,6 +3362,7 @@ dependencies = [
"serde_json",
"serde_urlencoded",
"superposition_provider",
+ "superposition_types",
"thiserror 1.0.69",
"time",
"tokio 1.48.0",
@@ -3367,6 +3386,16 @@ dependencies = [
"rand 0.8.5",
]
+[[package]]
+name = "fancy-regex"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2"
+dependencies = [
+ "bit-set 0.5.3",
+ "regex",
+]
+
[[package]]
name = "fantoccini"
version = "0.19.3"
@@ -3508,6 +3537,16 @@ dependencies = [
"percent-encoding",
]
+[[package]]
+name = "fraction"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3027ae1df8d41b4bed2241c8fdad4acc1e7af60c8e17743534b545e77182d678"
+dependencies = [
+ "lazy_static",
+ "num",
+]
+
[[package]]
name = "fragile"
version = "2.0.1"
@@ -4850,6 +4889,15 @@ version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
+[[package]]
+name = "iso8601"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1082f0c48f143442a1ac6122f67e360ceee130b967af4d50996e5154a45df46"
+dependencies = [
+ "nom 8.0.0",
+]
+
[[package]]
name = "iso_country"
version = "0.1.4"
@@ -4960,6 +5008,36 @@ dependencies = [
"serde",
]
+[[package]]
+name = "jsonschema"
+version = "0.17.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2a071f4f7efc9a9118dfb627a0a94ef247986e1ab8606a4c806ae2b3aa3b6978"
+dependencies = [
+ "ahash 0.8.11",
+ "anyhow",
+ "base64 0.21.7",
+ "bytecount",
+ "clap 4.5.38",
+ "fancy-regex",
+ "fraction",
+ "getrandom 0.2.16",
+ "iso8601",
+ "itoa",
+ "memchr",
+ "num-cmp",
+ "once_cell",
+ "parking_lot 0.12.3",
+ "percent-encoding",
+ "regex",
+ "reqwest 0.11.27",
+ "serde",
+ "serde_json",
+ "time",
+ "url",
+ "uuid",
+]
+
[[package]]
name = "jsonwebtoken"
version = "9.3.1"
@@ -5632,6 +5710,20 @@ dependencies = [
"winapi 0.3.9",
]
+[[package]]
+name = "num"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
+dependencies = [
+ "num-bigint",
+ "num-complex",
+ "num-integer",
+ "num-iter",
+ "num-rational",
+ "num-traits",
+]
+
[[package]]
name = "num-bigint"
version = "0.4.6"
@@ -5659,6 +5751,21 @@ dependencies = [
"zeroize",
]
+[[package]]
+name = "num-cmp"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa"
+
+[[package]]
+name = "num-complex"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
+dependencies = [
+ "num-traits",
+]
+
[[package]]
name = "num-conv"
version = "0.1.0"
@@ -5685,6 +5792,17 @@ dependencies = [
"num-traits",
]
+[[package]]
+name = "num-rational"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
+dependencies = [
+ "num-bigint",
+ "num-integer",
+ "num-traits",
+]
+
[[package]]
name = "num-traits"
version = "0.2.19"
@@ -6687,8 +6805,8 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50"
dependencies = [
- "bit-set",
- "bit-vec",
+ "bit-set 0.8.0",
+ "bit-vec 0.8.0",
"bitflags 2.9.0",
"lazy_static",
"num-traits",
@@ -6735,7 +6853,7 @@ dependencies = [
"prettyplease",
"prost 0.14.3",
"prost-types 0.14.3",
- "pulldown-cmark 0.13.1",
+ "pulldown-cmark 0.13.3",
"pulldown-cmark-to-cmark",
"regex",
"syn 2.0.101",
@@ -6828,9 +6946,9 @@ dependencies = [
[[package]]
name = "pulldown-cmark"
-version = "0.13.1"
+version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83c41efbf8f90ac44de7f3a868f0867851d261b56291732d0cbf7cceaaeb55a6"
+checksum = "7c3a14896dfa883796f1cb410461aef38810ea05f2b2c33c5aded3649095fdad"
dependencies = [
"bitflags 2.9.0",
"memchr",
@@ -6843,7 +6961,7 @@ version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50793def1b900256624a709439404384204a5dc3a6ec580281bfaac35e882e90"
dependencies = [
- "pulldown-cmark 0.13.1",
+ "pulldown-cmark 0.13.3",
]
[[package]]
@@ -9017,20 +9135,25 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "superposition_core"
-version = "0.97.4"
+version = "0.99.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d175b1f122c71bed5ee46d673913fa9da1bbc3209215c633fcaa02959a67396d"
+checksum = "5ce785d9bcadebf9cccdbf1962513daaf2522df0e83d70f5a2bb746f12904125"
dependencies = [
"actix-web",
"anyhow",
+ "bigdecimal 0.3.1",
+ "blake3",
"cbindgen",
"cfg-if 1.0.0",
"chrono",
"derive_more 0.99.19",
"itertools 0.10.5",
+ "jsonschema",
"log",
"mini-moka",
+ "num-bigint",
"once_cell",
+ "percent-encoding",
"rand 0.9.2",
"reqwest 0.11.27",
"serde",
@@ -9040,14 +9163,15 @@ dependencies = [
"superposition_types",
"thiserror 1.0.69",
"tokio 1.48.0",
+ "toml 0.8.22",
"uniffi",
]
[[package]]
name = "superposition_derives"
-version = "0.97.4"
+version = "0.99.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69975e8279bf31a5d6d7a2e1b5ed58ee3654293fbead0bcbd8c9c1cb579c1f68"
+checksum = "b7babb30f4056937c5be0d93c67694c01a180e5ad4fa60519ffbe06182d96596"
dependencies = [
"proc-macro2",
"quote",
@@ -9056,9 +9180,9 @@ dependencies = [
[[package]]
name = "superposition_provider"
-version = "0.97.4"
+version = "0.99.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd6a040632a384bd5ab0929f89c826fe745038a7df79551f9b7d798f810718d5"
+checksum = "16120fe041ac9457f27caebb78aee364a454ef74802e91415ea91801b3eb4efd"
dependencies = [
"async-trait",
"aws-smithy-types",
@@ -9073,14 +9197,15 @@ dependencies = [
"superposition_types",
"thiserror 1.0.69",
"tokio 1.48.0",
+ "tokio-util",
"uuid",
]
[[package]]
name = "superposition_sdk"
-version = "0.97.4"
+version = "0.99.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a34a90239b55a3466651d2b952da2a2b82dde69ce3ea8cee156cc314d0b0d62d"
+checksum = "dda16fe320a6a04943eb5ecc9f5477ec64d6ff556ec4802a6c18c6b7de9dce5d"
dependencies = [
"aws-smithy-async",
"aws-smithy-http 0.62.1",
@@ -9096,9 +9221,9 @@ dependencies = [
[[package]]
name = "superposition_types"
-version = "0.97.4"
+version = "0.99.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "372c30ac54dded10c9981719d3d7cbd83a7d06744f13c73517512625b890fd69"
+checksum = "4bdc5d336f7ce4a9d78ab431b333bfc5ec49b5bbd9c82719b5c22db2c672c4ab"
dependencies = [
"bigdecimal 0.3.1",
"chrono",
diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml
index 2e2afbd8f9..2c2e15374f 100644
--- a/crates/api_models/Cargo.toml
+++ b/crates/api_models/Cargo.toml
@@ -38,6 +38,7 @@ url = { version = "2.5.4", features = ["serde"] }
utoipa = { version = "4.2.3", features = ["preserve_order", "preserve_path_order"] }
nutype = { version = "0.4.3", features = ["serde"] }
deserialize_form_style_query_parameter = "0.2.2"
+superposition_types = "0.99.1"
# First party crates
cards = { version = "0.1.0", path = "../cards" }
diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs
index 6d9243df1e..ac1c582230 100644
--- a/crates/api_models/src/lib.rs
+++ b/crates/api_models/src/lib.rs
@@ -49,6 +49,7 @@ pub mod relay;
pub mod revenue_recovery_data_backfill;
pub mod routing;
pub mod subscription;
+pub mod superposition_sdk_config;
pub mod surcharge_decision_configs;
pub mod three_ds_decision_rule;
#[cfg(feature = "tokenization_v2")]
diff --git a/crates/api_models/src/superposition_sdk_config.rs b/crates/api_models/src/superposition_sdk_config.rs
new file mode 100644
index 0000000000..deb015c9bd
--- /dev/null
+++ b/crates/api_models/src/superposition_sdk_config.rs
@@ -0,0 +1,12 @@
+use common_utils::events::ApiEventMetric;
+use serde_json::{Map, Value};
+use superposition_types::Config;
+
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+pub struct SuperPositionConfigResponse {
+ pub raw_configs: Option<Config>,
+ pub resolved_configs: Option<Map<String, Value>>,
+ pub context_used: Map<String, Value>,
+}
+
+impl ApiEventMetric for SuperPositionConfigResponse {}
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index 2bcfb6647e..2eeded837b 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -74,7 +74,8 @@ url = { version = "2.5.4", features = ["serde"] }
quick-xml = { version = "0.31.0", features = ["serialize"] }
unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.03.04.0-hotfix2" , package = "rust-grpc-client" }
open-feature = { version = "0.2.5", optional = true }
-superposition_provider = { version = "0.97.0", optional = true }
+superposition_provider = { version = "0.99.1", optional = true}
+superposition_types = "0.99.1"
# First party crates
diff --git a/crates/external_services/src/superposition.rs b/crates/external_services/src/superposition.rs
index b8e187c85a..bdbea567c9 100644
--- a/crates/external_services/src/superposition.rs
+++ b/crates/external_services/src/superposition.rs
@@ -8,6 +8,7 @@ use std::collections::HashMap;
use common_utils::{errors::CustomResult, id_type::TargetingKey};
use error_stack::report;
use hyperswitch_masking::ExposeInterface;
+use serde_json::Map;
pub use self::types::{ConfigContext, SuperpositionClientConfig, SuperpositionError};
use crate::config_metrics;
@@ -98,6 +99,8 @@ impl GetValue<serde_json::Value> for open_feature::Client {
#[allow(missing_debug_implementations)]
pub struct SuperpositionClient {
client: open_feature::Client,
+ /// Provider for Superposition
+ provider: superposition_provider::SuperpositionProvider,
}
impl SuperpositionClient {
@@ -133,14 +136,14 @@ impl SuperpositionClient {
// Initialize OpenFeature API and set provider
let mut api = open_feature::OpenFeature::singleton_mut().await;
- api.set_provider(provider).await;
+ api.set_provider(provider.clone()).await;
// Create client
let client = api.create_client();
router_env::logger::info!("Superposition client initialized successfully");
- Ok(Self { client })
+ Ok(Self { client, provider })
}
/// Build evaluation context for Superposition requests
@@ -197,6 +200,52 @@ impl SuperpositionClient {
)))
})
}
+
+ /// Resolve full configuration from Superposition
+ ///
+ /// # Arguments
+ /// * `context` - Evaluation context
+ ///
+ /// # Returns
+ /// * `CustomResult<Map<String, serde_json::Value>, SuperpositionError>` - The full configuration or error
+ pub async fn resolve_full_config(
+ &self,
+ context: Option<&ConfigContext>,
+ targeting_key: Option<&String>,
+ ) -> CustomResult<Map<String, serde_json::Value>, SuperpositionError> {
+ let evaluation_context = self.build_evaluation_context(context, targeting_key);
+ self.provider
+ .resolve_full_config(&evaluation_context)
+ .await
+ .map_err(|e| {
+ report!(SuperpositionError::ProviderError(format!(
+ "Failed to resolve full config: {e:?}"
+ )))
+ })
+ }
+
+ /// Get cached configuration from Superposition
+ ///
+ /// # Arguments
+ /// * `prefix_filter` - Optional prefix filter for configuration keys
+ /// * `dimension_filter` - Optional dimension filter for configuration values
+ ///
+ /// # Returns
+ /// * `CustomResult<Config, SuperpositionError>` - The cached configuration or error
+ pub async fn get_cached_config(
+ &self,
+ prefix_filter: Option<Vec<String>>,
+ dimension_filter: Option<Map<String, serde_json::Value>>,
+ ) -> CustomResult<superposition_types::Config, SuperpositionError> {
+ self.provider
+ .get_cached_config(dimension_filter, prefix_filter)
+ .await
+ .map_err(|e| {
+ report!(SuperpositionError::ProviderError(format!(
+ "Failed to get cached config: {e:?}"
+ )))
+ })
+ }
}
/// Each config type implements this trait to define how its value should be
diff --git a/crates/external_services/src/superposition/types.rs b/crates/external_services/src/superposition/types.rs
index dda719bfbe..923c04cdad 100644
--- a/crates/external_services/src/superposition/types.rs
+++ b/crates/external_services/src/superposition/types.rs
@@ -81,6 +81,9 @@ pub enum SuperpositionError {
/// Invalid configuration provided
#[error("Invalid configuration: {0}")]
InvalidConfiguration(String),
+ /// Error from the Superposition provider
+ #[error("Superposition provider error: {0}")]
+ ProviderError(String),
}
/// Context for configuration requests
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 721fb011a9..fdab7daed0 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -112,7 +112,7 @@ unicode-segmentation = "1.12.0"
url = { version = "2.5.4", features = ["serde"] }
urlencoding = "2.1.3"
utoipa = { version = "4.2.3", features = ["preserve_order", "preserve_path_order", "time"] }
-uuid = { version = "1.17.0", features = ["v4"] }
+uuid = { version = "1.20.0", features = ["v4"] }
validator = "0.17.0"
x509-parser = "0.16.0"
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index f1e4ea0388..324d6e9c5a 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -354,6 +354,8 @@ pub mod superposition {
pub const REQUIRES_CVV: &str = "requires_cvv";
/// implicit customer update configuration key
pub const IMPLICIT_CUSTOMER_UPDATE: &str = "implicit_customer_update";
+ /// dynamic fields configuration key for sdk config
+ pub const DYNAMIC_FIELDS: &str = "dynamic_fields";
/// payout sync tracker configuration key
pub const PAYOUT_TRACKER_MAPPING: &str = "payout_tracker_mapping";
}
diff --git a/crates/router/src/core.rs b/crates/router/src/core.rs
index a5569d5425..4e22a0403b 100644
--- a/crates/router/src/core.rs
+++ b/crates/router/src/core.rs
@@ -65,6 +65,7 @@ pub mod revenue_recovery;
#[cfg(feature = "v2")]
pub mod revenue_recovery_data_backfill;
pub mod routing;
+pub mod superposition_sdk_config;
pub mod surcharge_decision_config;
pub mod three_ds_decision_rule;
pub mod tokenization;
diff --git a/crates/router/src/core/superposition_sdk_config.rs b/crates/router/src/core/superposition_sdk_config.rs
new file mode 100644
index 0000000000..900c64d04b
--- /dev/null
+++ b/crates/router/src/core/superposition_sdk_config.rs
@@ -0,0 +1,65 @@
+use api_models::superposition_sdk_config::SuperPositionConfigResponse;
+use common_utils::ext_traits::AsyncExt;
+use error_stack::ResultExt;
+use serde_json::Map;
+
+use crate::{
+ consts::superposition::DYNAMIC_FIELDS,
+ core::errors::{self, RouterResponse},
+ types::domain,
+ SessionState,
+};
+
+pub async fn get_superposition_sdk_config(
+ state: SessionState,
+ platform: domain::Platform,
+ profile_id: common_utils::id_type::ProfileId,
+) -> RouterResponse<SuperPositionConfigResponse> {
+ // we want resolve config with filters which is not yet available in any version of superposition yet. so we are commenting it for future usecase
+
+ // let resolved_configs = state
+ // .superposition_service
+ // .as_ref()
+ // .async_map(|sp| async move { sp.as_ref().resolve_full_config(None, None).await })
+ // .await
+ // .transpose()
+ // .change_context(errors::ApiErrorResponse::InternalServerError)
+ // .attach_printable("Failed to resolve superposition sdk config")?;
+ let merchant_account = platform.get_processor().get_account();
+
+ let mut dimension_filter = Map::new();
+ dimension_filter.insert(
+ "profile_id".to_string(),
+ serde_json::Value::String(profile_id.get_string_repr().to_string()),
+ );
+ dimension_filter.insert(
+ "merchant_id".to_string(),
+ serde_json::Value::String(merchant_account.get_id().get_string_repr().to_string()),
+ );
+ dimension_filter.insert(
+ "organization_id".to_string(),
+ serde_json::Value::String(merchant_account.get_org_id().get_string_repr().to_string()),
+ );
+
+ let cached_configs = state
+ .superposition_service
+ .as_ref()
+ .async_map(|sp| {
+ sp.as_ref().get_cached_config(
+ Some(vec![DYNAMIC_FIELDS.to_string()]),
+ Some(dimension_filter.clone()),
+ )
+ })
+ .await
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to get cached superposition sdk config")?;
+
+ Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(
+ SuperPositionConfigResponse {
+ raw_configs: cached_configs,
+ resolved_configs: None,
+ context_used: dimension_filter,
+ },
+ ))
+}
diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs
index 9eeab32c42..cb64b58d60 100644
--- a/crates/router/src/lib.rs
+++ b/crates/router/src/lib.rs
@@ -182,7 +182,8 @@ pub fn mk_app(
server_app = server_app
.service(routes::Refunds::server(state.clone()))
.service(routes::Mandates::server(state.clone()))
- .service(routes::Authentication::server(state.clone()));
+ .service(routes::Authentication::server(state.clone()))
+ .service(routes::SdkConfig::server(state.clone()));
}
}
diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rs
index 356deb80a5..569ccb44c7 100644
--- a/crates/router/src/routes.rs
+++ b/crates/router/src/routes.rs
@@ -58,6 +58,7 @@ pub mod revenue_recovery_redis;
pub mod routing;
#[cfg(feature = "v1")]
pub mod subscription;
+pub mod superposition_sdk_config;
pub mod three_ds_decision_rule;
pub mod tokenization;
#[cfg(feature = "olap")]
@@ -98,7 +99,7 @@ pub use self::app::{
Chat, Configs, ConnectorOnboarding, Customers, Disputes, Embedded, EphemeralKey, FeatureMatrix,
Files, Forex, Gsm, Health, Hypersense, Mandates, MerchantAccount, MerchantConnectorAccount,
Oidc, PaymentLink, PaymentMethods, Payments, Poll, ProcessTracker, ProcessTrackerDeprecated,
- Profile, ProfileAcquirer, ProfileNew, Refunds, Relay, RelayWebhooks, SessionState,
+ Profile, ProfileAcquirer, ProfileNew, Refunds, Relay, RelayWebhooks, SdkConfig, SessionState,
ThreeDsDecisionRule, User, UserDeprecated, Webhooks,
};
#[cfg(feature = "olap")]
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index be8729418d..1208d72489 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -3357,3 +3357,16 @@ impl RecoveryDataBackfill {
))
}
}
+
+pub struct SdkConfig;
+#[cfg(feature = "v1")]
+impl SdkConfig {
+ pub fn server(state: AppState) -> Scope {
+ web::scope("/v1/sdk/configs")
+ .app_data(web::Data::new(state))
+ .service(
+ web::resource("{profile_id}/{platform}/{sdk_config.json}")
+ .route(web::get().to(super::superposition_sdk_config::get_sdk_config)),
+ )
+ }
+}
diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs
index 67d7e1e009..dba998c856 100644
--- a/crates/router/src/routes/lock_utils.rs
+++ b/crates/router/src/routes/lock_utils.rs
@@ -52,6 +52,7 @@ pub enum ApiIdentifier {
ThreeDsDecisionRule,
GenericTokenization,
RecoveryRecovery,
+ Superposition,
CardIssuers,
}
@@ -384,6 +385,7 @@ impl From<Flow> for ApiIdentifier {
| Flow::NetworkTokenEligibilityCheck => Self::GenericTokenization,
Flow::RecoveryDataBackfill | Flow::RevenueRecoveryRedis => Self::RecoveryRecovery,
+ Flow::GetSuperpositionSdkConfig => Self::Superposition,
Flow::MerchantConnectorWebhookRegister | Flow::MerchantConnectorWebhookList => {
Self::MerchantConnectorWebhookManagement
}
diff --git a/crates/router/src/routes/superposition_sdk_config.rs b/crates/router/src/routes/superposition_sdk_config.rs
new file mode 100644
index 0000000000..4e5d461f4e
--- /dev/null
+++ b/crates/router/src/routes/superposition_sdk_config.rs
@@ -0,0 +1,38 @@
+use actix_web::{web, HttpRequest, HttpResponse};
+use router_env::{instrument, tracing, Flow};
+
+use super::app::AppState;
+use crate::{
+ core::{api_locking, superposition_sdk_config},
+ services::{api, authentication as auth},
+};
+
+#[instrument(skip_all, fields(flow = ?Flow::GetSuperpositionSdkConfig))]
+pub async fn get_sdk_config(
+ state: web::Data<AppState>,
+ req: HttpRequest,
+ path: web::Path<(common_utils::id_type::ProfileId, String, String)>,
+) -> HttpResponse {
+ let flow = Flow::GetSuperpositionSdkConfig;
+ let (profile_id, _platform, _sdk_config) = path.into_inner();
+
+ Box::pin(api::server_wrap(
+ flow,
+ state,
+ &req,
+ (),
+ |state: super::SessionState, auth_data, _req, _| {
+ superposition_sdk_config::get_superposition_sdk_config(
+ state,
+ auth_data.platform,
+ profile_id.clone(),
+ )
+ },
+ &auth::HeaderAuth(auth::PublishableKeyAuth {
+ allow_connected_scope_operation: true,
+ allow_platform_self_operation: false,
+ }),
+ api_locking::LockAction::NotApplicable,
+ ))
+ .await
+}
diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs
index dd890e5df0..35c41f4e85 100644
--- a/crates/router_env/src/logger/types.rs
+++ b/crates/router_env/src/logger/types.rs
@@ -735,6 +735,8 @@ pub enum Flow {
GetEmbeddedToken,
// Get embedded token info flow
EmbeddedTokenInfo,
+ /// Superposition SDK Config Get flow
+ GetSuperpositionSdkConfig,
// Get user details internal
GetUserDetailsInternal,
// List users internal