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(payments): add superposition config for blocking implicit customer creation (#13561)
Kashif755cf7f91b58
diff --git a/config/superposition_seed.toml b/config/superposition_seed.tomlindex e19de19316..d32e27a9d0 100644--- a/config/superposition_seed.toml+++ b/config/superposition_seed.toml@@ -2554,6 +2554,7 @@ client_session_validation_enabled = { value = true, schema = { type = "boolean""payments.enable_extended_card_bin" = { value = false, schema = { type = "boolean" }, description = "Whether to use extended card BIN (8-digit) for payment method data", change_reason = "Initial setup" }"payouts.gsm_payout_call" = { value = false, schema = { type = "boolean" }, description = "Whether to call GSM for payout retries", change_reason = "Initial setup" }"payments.implicit_customer_update" = { value = false, schema = { type = "boolean" }, description = "Whether to implicitly update customer details on payment", change_reason = "Initial setup" }+"payments.block_implicit_customer_creation" = { value = false, schema = { type = "boolean" }, description = "Whether payments must reject implicit creation of a missing customer for an organization", change_reason = "Decouple implicit customer creation from PM modular eligibility" }"webhooks.incoming_webhook_disabled_events" = { value = false, schema = { type = "boolean" }, description = "Whether a specific incoming webhook event is disabled for a given connector", change_reason = "Initial setup" }"payouts.max_auto_payout_retries" = { value = 0, schema = { maximum = 4294967295, minimum = 0, type = "integer" }, description = "Maximum auto payout retries, differentiated by payout_retry_type dimension (single_connector or multi_connector)", change_reason = "Initial setup" }"payouts.payout_tracker_mapping" = { value = { frequencies = [diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rsindex 3480440c7e..9fc90247dc 100644--- a/crates/router/src/consts.rs+++ b/crates/router/src/consts.rs@@ -408,6 +408,8 @@ pub mod superposition {pub const REQUIRES_CVV: &str = "payments.requires_cvv";/// implicit customer update configuration keypub const IMPLICIT_CUSTOMER_UPDATE: &str = "payments.implicit_customer_update";+ /// Organization-scoped block implicit customer creation configuration key+ pub const BLOCK_IMPLICIT_CUSTOMER_CREATION: &str = "payments.block_implicit_customer_creation";/// Fingerprint secret configuration key retained for migration fallbackpub const FINGERPRINT_SECRET: &str = "vaulting.fingerprint_secret";/// Poll config for external 3DS authentication keydiff --git a/crates/router/src/core/configs.rs b/crates/router/src/core/configs.rsindex 88f0bdcd45..4a8fde620e 100644--- a/crates/router/src/core/configs.rs+++ b/crates/router/src/core/configs.rs@@ -2,8 +2,8 @@ pub mod dimension_config;pub mod dimension_state;use common_utils::errors::CustomResult;pub use dimension_config::{- EnableExtendedCardBin, ImplicitCustomerUpdate, RequiresCvv, ShouldCallGsm,- ShouldEnableMitWithLimitedCardData, ShouldPerformEligibility,+ BlockImplicitCustomerCreation, EnableExtendedCardBin, ImplicitCustomerUpdate, RequiresCvv,+ ShouldCallGsm, ShouldEnableMitWithLimitedCardData, ShouldPerformEligibility,ShouldStoreEligibilityCheckDataForAuthentication,};use error_stack::ResultExt;diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rsindex aee9016f69..b292588239 100644--- a/crates/router/src/core/configs/dimension_config.rs+++ b/crates/router/src/core/configs/dimension_config.rs@@ -181,6 +181,24 @@ impl DatabaseBackedConfig for ImplicitCustomerUpdate {}}+config! {+ superposition_key = BLOCK_IMPLICIT_CUSTOMER_CREATION,+ output = bool,+ default = false,+ requires = dimension_state::DimensionsWithOrgId,+ targeting_key = id_type::CustomerId+}++impl DatabaseBackedConfig for BlockImplicitCustomerCreation {+ const KEY: &'static str = "block_implicit_customer_creation";++ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {+ dimensions+ .get_organization_id()+ .map(|id| format!("{}_{}", Self::KEY, id.get_string_repr()))+ }+}+// Retained temporarily so merchants without a database value can fall back to// their existing Superposition fingerprint secret during migration.config! {diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex bf31a297c8..9613e74c31 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -2170,19 +2170,21 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(}}None => {- let pm_modular_dimensions = dimensions+ let implicit_customer_creation_dimensions = dimensions.without_profile_id().with_organization_id(provider.get_account().organization_id.clone())- .without_processor_merchant_id();- let should_call_pm_modular_service =- payment_methods::utils::get_should_call_pm_modular_service(- state,- &pm_modular_dimensions,- None,- )- .await;+ .without_processor_merchant_id()+ .without_provider_merchant_id();+ let should_block_implicit_customer_creation =+ implicit_customer_creation_dimensions+ .get_block_implicit_customer_creation(+ state.store.as_ref(),+ state.superposition_service.as_ref(),+ Some(&customer_id),+ )+ .await;- if should_call_pm_modular_service {+ if should_block_implicit_customer_creation {Err(report!(errors::StorageError::ValueNotFound("customer".to_owned())))?