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(authentication): added should_enable_authentication_service config to superposition (#14101)
Sahkal Poddar4d5777f252f8
diff --git a/config/superposition_seed.toml b/config/superposition_seed.tomlindex 1e42b4663d..581763c4da 100644--- a/config/superposition_seed.toml+++ b/config/superposition_seed.toml@@ -2674,6 +2674,7 @@ pt_mapping_outgoing_connector_webhooks = { value = { default_mapping = { frequen"payments.should_call_gsm" = { value = false, schema = { type = "boolean" }, description = "Whether to call GSM (Global Status Mapping) for auto-retries on payment failure", change_reason = "Initial setup" }"system.should_call_pm_modular_service" = { value = false, schema = { type = "boolean" }, description = "Whether to call the PM modular service for a provider merchant, with organization fallback", change_reason = "Initial setup" }"vaulting.should_disable_vault_tokenization" = { value = false, schema = { type = "boolean" }, description = "Whether to disable vault tokenization for a merchant", change_reason = "Initial setup" }+"system.should_enable_authentication_service" = { value = false, schema = { type = "boolean" }, description = "Whether a merchant/org is eligible for the unified authentication service, with organization taking precedence over merchant", change_reason = "Initial setup" }"payments.should_enable_mit_with_limited_card_data" = { value = false, schema = { type = "boolean" }, description = "Whether to allow merchant-initiated transactions (MIT) with limited card data", change_reason = "Initial setup" }"payments.should_perform_eligibility" = { value = false, schema = { type = "boolean" }, description = "Whether the SDK should perform an eligibility check before confirming payment", change_reason = "Initial setup" }"payments.should_return_raw_payment_method_details" = { value = false, schema = { type = "boolean" }, description = "Whether to return raw payment method details (v2 only)", change_reason = "Initial setup" }diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rsindex e84860b6bd..c12a9c876d 100644--- a/crates/router/src/consts.rs+++ b/crates/router/src/consts.rs@@ -472,6 +472,9 @@ pub mod superposition {/// Disable vault tokenization configuration keypub const SHOULD_DISABLE_VAULT_TOKENIZATION: &str ="vaulting.should_disable_vault_tokenization";+ /// Authentication service eligibility configuration key (org and merchant scoped, org takes precedence)+ pub const SHOULD_ENABLE_AUTHENTICATION_SERVICE: &str =+ "system.should_enable_authentication_service";/// Return raw payment method details configuration keypub const SHOULD_RETURN_RAW_PAYMENT_METHOD_DETAILS: &str ="payments.should_return_raw_payment_method_details";diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rsindex 78d663e64f..b04dc110fd 100644--- a/crates/router/src/core/configs/dimension_config.rs+++ b/crates/router/src/core/configs/dimension_config.rs@@ -362,6 +362,29 @@ impl DatabaseBackedConfig for ShouldDisableVaultTokenization {}}+config! {+ superposition_key = SHOULD_ENABLE_AUTHENTICATION_SERVICE,+ output = bool,+ default = false,+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndOrgId,+ targeting_key = id_type::CustomerId+}++impl DatabaseBackedConfig for ShouldEnableAuthenticationService {+ const KEY: &'static str = "should_enable_authentication_service";++ fn db_keys(dimensions: &impl dimension_state::DimensionsBase) -> Vec<Option<String>> {+ vec![+ dimensions+ .get_organization_id()+ .map(|id| id.get_authentication_service_eligible_key()),+ dimensions+ .get_processor_merchant_id()+ .map(|id| id.get_authentication_service_eligible_key()),+ ]+ }+}+#[cfg(feature = "v2")]config! {superposition_key = SHOULD_RETURN_RAW_PAYMENT_METHOD_DETAILS,diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 31fa183b96..e98b812d8a 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -9650,7 +9650,10 @@ pub fn validate_platform_request_for_marketplace(/// Returns `true` if either the org or merchant config is set to "true"///-/// Priority logic:+/// Resolved from Superposition (`SHOULD_ENABLE_AUTHENTICATION_SERVICE`), falling back to the+/// legacy DB config (`authentication_service_eligible_<id>`) when Superposition has no value.+///+/// Priority logic (DB fallback order, see `ShouldEnableAuthenticationService::db_keys`):/// 1. If org-level config exists (either "true" or "false"), that decision is final/// - Org = "true" → returns true (authentication enabled)/// - Org = "false" → returns false (authentication disabled, merchant config ignored)@@ -9663,35 +9666,19 @@ pub async fn is_merchant_eligible_authentication_service(processor: &domain::Processor,state: &SessionState,) -> RouterResult<bool> {- let db = &*state.store;- let org_key = processor- .get_account()- .get_org_id()- .get_authentication_service_eligible_key();- let org_eligible = db- .find_config_by_key(&org_key)- .await- .inspect_err(|error| {- logger::error!(?error, "Failed to fetch `{org_key}` config from DB");- })- .ok()- .map(|c| c.config.to_lowercase() == "true");+ let dimensions = dimension_state::Dimensions::new()+ .with_processor_merchant_id(processor.get_processor_merchant_id())+ .with_provider_merchant_id(dimension_state::ProviderMerchantId::new(+ processor.get_account().get_id().clone(),+ ))+ .with_organization_id(processor.get_account().get_org_id().clone());- Ok(org_eligible- .async_unwrap_or_else(|| async {- let merchant_key = processor- .get_account()- .get_id()- .get_authentication_service_eligible_key();- db.find_config_by_key(&merchant_key)- .await- .inspect_err(|error| {- logger::error!(?error, "Failed to fetch `{merchant_key}` config from DB");- })- .ok()- .map(|c| c.config.to_lowercase() == "true")- .unwrap_or(false)- })+ Ok(dimensions+ .get_should_enable_authentication_service(+ state.store.as_ref(),+ state.superposition_service.as_ref(),+ None,+ ).await)}