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(sdk_config): add merchant level vaulting_action override (#13078)

Shankar Singh C213f87db7f49
diff --git a/config/superposition_seed.toml b/config/superposition_seed.toml
index d36cd1c3bf..ab31bd2fe4 100644
--- a/config/superposition_seed.toml
+++ b/config/superposition_seed.toml
@@ -151,6 +151,12 @@ schema = { type = "boolean" }
description = "Whether to call the PM modular service for an organization"
change_reason = "Initial setup"
+[default-configs.should_perform_sdk_vaulting]
+value = true
+schema = { type = "boolean" }
+description = "Org level override on top of should_call_pm_modular_service; when false the SDK skips vaulting"
+change_reason = "Initial setup"
+
[default-configs.should_schedule_modular_forward_compat]
value = false
schema = { type = "boolean" }
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index 8b505fadb6..f1192894f4 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -420,6 +420,10 @@ pub mod superposition {
"should_trigger_backwards_compatibility_inline";
/// Trigger fingerprint migration configuration key
pub const SHOULD_TRIGGER_FINGERPRINT_MIGRATION: &str = "should_trigger_fingerprint_migration";
+ /// Perform SDK vaulting action configuration key. Acts as a merchant level override on top of
+ /// `should_call_pm_modular_service`: defaults to `true` for all merchants and can be set to
+ /// `false` for specific merchants to force the SDK to skip tokenization.
+ pub const SHOULD_PERFORM_SDK_VAULTING: &str = "should_perform_sdk_vaulting";
/// dynamic fields configuration key for sdk config
pub const DYNAMIC_FIELDS: &str = "dynamic_fields";
/// payout sync tracker configuration key
diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rs
index ff368c4a82..d8476503be 100644
--- a/crates/router/src/core/configs/dimension_config.rs
+++ b/crates/router/src/core/configs/dimension_config.rs
@@ -500,6 +500,24 @@ impl DatabaseBackedConfig for ShouldTriggerFingerprintMigration {
}
}
+config! {
+ superposition_key = SHOULD_PERFORM_SDK_VAULTING,
+ output = bool,
+ default = true,
+ requires = dimension_state::DimensionsWithOrgId,
+ targeting_key = id_type::CustomerId
+}
+
+impl DatabaseBackedConfig for ShouldPerformSdkVaulting {
+ const KEY: &'static str = "should_perform_sdk_vaulting";
+
+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
+ dimensions
+ .get_organization_id()
+ .map(|id| format!("{}_{}", Self::KEY, id.get_string_repr()))
+ }
+}
+
config! {
superposition_key = PAYOUT_TRACKER_MAPPING,
output = RetryMapping,
diff --git a/crates/router/src/core/payment_methods/utils.rs b/crates/router/src/core/payment_methods/utils.rs
index acc442cb0d..7daba9f6f0 100644
--- a/crates/router/src/core/payment_methods/utils.rs
+++ b/crates/router/src/core/payment_methods/utils.rs
@@ -828,6 +828,19 @@ pub async fn get_organization_eligibility_config_for_pm_modular_service(
.await
}
+pub async fn get_should_perform_sdk_vaulting(
+ state: &SessionState,
+ dimensions: &dimension_state::DimensionsWithOrgId,
+) -> bool {
+ dimensions
+ .get_should_perform_sdk_vaulting(
+ state.store.as_ref(),
+ state.superposition_service.as_ref(),
+ None,
+ )
+ .await
+}
+
pub async fn get_should_schedule_modular_forward_compat(
state: &SessionState,
dimensions: &dimension_state::DimensionsWithProviderMerchantId,
diff --git a/crates/router/src/core/superposition_sdk_config.rs b/crates/router/src/core/superposition_sdk_config.rs
index 5061c2fc4f..b82f323556 100644
--- a/crates/router/src/core/superposition_sdk_config.rs
+++ b/crates/router/src/core/superposition_sdk_config.rs
@@ -447,10 +447,26 @@ async fn build_account_config(
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
let feature_config = crate::core::utils::get_feature_config(state, platform, &dimensions).await;
+ // Org level override on top of the modular service flag. Defaults to `true` for all merchants;
+ // when set to `false` for a specific org, the SDK is told to skip vaulting.
+ let should_perform_sdk_vaulting =
+ crate::core::payment_methods::utils::get_should_perform_sdk_vaulting(
+ state,
+ &Dimensions::new().with_organization_id(
+ platform
+ .get_processor()
+ .get_account()
+ .organization_id
+ .clone(),
+ ),
+ )
+ .await;
+
AccountConfig {
profile: build_profile_account_config(
business_profile,
feature_config.is_payment_method_modular_allowed,
+ should_perform_sdk_vaulting,
),
}
}
@@ -459,6 +475,7 @@ async fn build_account_config(
fn build_profile_account_config(
business_profile: &domain::Profile,
is_payment_method_modular_allowed: bool,
+ should_perform_sdk_vaulting: bool,
) -> ProfileAccountConfig {
ProfileAccountConfig {
collect_shipping_details_from_wallet_connector: business_profile
@@ -473,16 +490,24 @@ fn build_profile_account_config(
always_collect_shipping_details_from_wallet_connector: business_profile
.always_collect_shipping_details_from_wallet_connector
.unwrap_or(false),
- vaulting_action: resolve_vaulting_action(is_payment_method_modular_allowed),
+ vaulting_action: resolve_vaulting_action(
+ is_payment_method_modular_allowed,
+ should_perform_sdk_vaulting,
+ ),
}
}
/// Determine whether the SDK should tokenize payment method details.
///
-/// Driven solely by whether the modular vaulting flow should be invoked: `Tokenize` when it
-/// should, `Skip` otherwise.
-fn resolve_vaulting_action(should_call_modular: bool) -> VaultingAction {
- if should_call_modular {
+/// `should_call_modular` decides whether the modular vaulting flow is invoked at all.
+/// `should_perform_sdk_vaulting` is a merchant level override (default `true`) that can force the
+/// SDK to skip vaulting for specific merchants. Vaulting is `Tokenize` only when both are `true`;
+/// otherwise it is `Skip`.
+fn resolve_vaulting_action(
+ should_call_modular: bool,
+ should_perform_sdk_vaulting: bool,
+) -> VaultingAction {
+ if should_call_modular && should_perform_sdk_vaulting {
VaultingAction::Tokenize
} else {
VaultingAction::Skip