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(account_updater): add Superposition gating and credential resolution (#13488)

Kanika Bansalc4913321aecc
diff --git a/config/config.example.toml b/config/config.example.toml
index 78c6d6b654..f7a9f25e7f 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -1517,6 +1517,15 @@ base_url = "https://offer-engine.example.com/" # Base URL of the Offer Engine se
api_key = "" # API key for API-key authenticated Offer Engine calls
merchant_id = "" # Offer Engine merchant id sent in request bodies
+# Credentials forwarded to UCS for the Account Updater flow; omit the section entirely to keep it off
+[account_updater.juspay]
+base_url = "https://account-updater.example.com/" # Account Updater base URL
+api_key = "" # API key for the Account Updater provider
+merchant_id = "" # Merchant id sent in Account Updater request bodies
+euler_encryption_public_key = "" # Provider RSA public key, used to seal outbound card data
+au_decryption_pvt_key = "" # Our RSA private key, used to open the response payload
+card_sync_key_id = "" # Id of our public key as registered with the provider
+
[micro_services]
# Base URLs for modular microservices
# (e.g., payment-methods, customers, routing, etc.)
diff --git a/config/superposition_seed.toml b/config/superposition_seed.toml
index ac6e6f2f7c..ffe375e6ae 100644
--- a/config/superposition_seed.toml
+++ b/config/superposition_seed.toml
@@ -20,6 +20,11 @@ offer_engine_credential_source = { value = "none", schema = { type = "string", e
"none",
"application",
] }, description = "Source of Offer Engine credentials once offer_engine_enabled is true: 'none' skips Offer Engine; 'application' uses the static offer_engine application config. Future org/merchant/profile sources will extend the enum alongside their credential storage.", change_reason = "Offer Engine credential source is a string enum: 'none' disables, 'application' enables; extensible to org/merchant/profile sources" }
+"account_updater.enabled" = { value = false, schema = { type = "boolean" }, description = "Master gate for the Account Updater integration. When false (default) Account Updater is never called, regardless of account_updater.credential_source. Set true (per tenant/env override) to allow Account Updater calls.", change_reason = "Account Updater disabled by default; enable via Superposition override" }
+"account_updater.credential_source" = { value = "none", schema = { type = "string", enum = [
+ "none",
+ "application",
+] }, description = "Source of Account Updater credentials once account_updater.enabled is true: 'none' skips Account Updater; 'application' uses the static account_updater application config. Future org/merchant/profile sources will extend the enum alongside their credential storage.", change_reason = "Account Updater credential source is a string enum: 'none' disables, 'application' enables; extensible to org/merchant/profile sources" }
client_session_validation_enabled = { value = true, schema = { type = "boolean" } }
"dynamic_fields.bank_debit.ach_bank_debit.account_number._confirm_request_write_path" = { value = "payment_method_data.bank_debit.ach_bank_debit.account_number", schema = { type = "string" } }
"dynamic_fields.bank_debit.ach_bank_debit.account_number._default_label_text" = { value = "Account Number", schema = { type = "string" } }
diff --git a/crates/router/src/configs/secrets_transformers.rs b/crates/router/src/configs/secrets_transformers.rs
index 39e79ee8b7..0e44aff462 100644
--- a/crates/router/src/configs/secrets_transformers.rs
+++ b/crates/router/src/configs/secrets_transformers.rs
@@ -412,6 +412,42 @@ impl SecretsHandler for settings::OidcSettings {
}
}
+impl settings::JuspayAccountUpdaterConfig {
+ async fn convert_to_raw_secret(
+ self,
+ secret_management_client: &dyn SecretManagementInterface,
+ ) -> CustomResult<Self, SecretsManagementError> {
+ let (api_key, euler_encryption_public_key, au_decryption_pvt_key) = tokio::try_join!(
+ secret_management_client.get_secret(self.api_key.clone()),
+ secret_management_client.get_secret(self.euler_encryption_public_key.clone()),
+ secret_management_client.get_secret(self.au_decryption_pvt_key.clone()),
+ )?;
+
+ Ok(Self {
+ api_key,
+ euler_encryption_public_key,
+ au_decryption_pvt_key,
+ ..self
+ })
+ }
+}
+
+#[async_trait::async_trait]
+impl SecretsHandler for settings::AccountUpdaterConfig {
+ async fn convert_to_raw_secret(
+ value: SecretStateContainer<Self, SecuredSecret>,
+ secret_management_client: &dyn SecretManagementInterface,
+ ) -> CustomResult<SecretStateContainer<Self, RawSecret>, SecretsManagementError> {
+ let Self::Juspay(juspay) = value.get_inner().clone();
+
+ let juspay = juspay
+ .convert_to_raw_secret(secret_management_client)
+ .await?;
+
+ Ok(value.transition_state(|_| Self::Juspay(juspay)))
+ }
+}
+
/// # Panics
///
/// Will panic even if kms decryption fails for at least one field
@@ -580,6 +616,20 @@ pub(crate) async fn fetch_raw_secrets(
.await
.expect("Failed to decrypt oidc configs");
+ #[allow(clippy::expect_used)]
+ let account_updater = if let Some(account_updater) = conf.account_updater {
+ Some(
+ settings::AccountUpdaterConfig::convert_to_raw_secret(
+ account_updater,
+ secret_management_client,
+ )
+ .await
+ .expect("Failed to decrypt account updater configuration"),
+ )
+ } else {
+ None
+ };
+
Settings {
server: conf.server,
application_source: conf.application_source,
@@ -703,5 +753,6 @@ pub(crate) async fn fetch_raw_secrets(
comparison_service: conf.comparison_service,
authentication_service_enabled_connectors: conf.authentication_service_enabled_connectors,
save_payment_method_on_session: conf.save_payment_method_on_session,
+ account_updater,
}
}
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 4c9c15e918..573f50c1b8 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -203,6 +203,7 @@ pub struct Settings<S: SecretState> {
pub comparison_service: Option<ComparisonServiceConfig>,
pub authentication_service_enabled_connectors: AuthenticationServiceEnabledConnectors,
pub save_payment_method_on_session: OnSessionConfig,
+ pub account_updater: Option<SecretStateContainer<AccountUpdaterConfig, S>>,
}
#[cfg(feature = "deja")]
@@ -386,6 +387,22 @@ pub struct OnSessionConfig {
HashMap<enums::PaymentMethod, HashSet<enums::PaymentMethodType>>,
}
+#[derive(Debug, Deserialize, Clone)]
+#[serde(rename_all = "snake_case")]
+pub enum AccountUpdaterConfig {
+ Juspay(JuspayAccountUpdaterConfig),
+}
+
+#[derive(Debug, Deserialize, Clone)]
+pub struct JuspayAccountUpdaterConfig {
+ pub base_url: url::Url,
+ pub api_key: Secret<String>,
+ pub merchant_id: String,
+ pub euler_encryption_public_key: Secret<String>,
+ pub au_decryption_pvt_key: Secret<String>,
+ pub card_sync_key_id: String,
+}
+
#[derive(Debug, Deserialize, Clone, Default)]
pub struct DebitRoutingConfig {
#[serde(deserialize_with = "deserialize_hashmap")]
@@ -1485,6 +1502,11 @@ impl Settings<SecuredSecret> {
.map(|offer_engine| offer_engine.validate())
.transpose()?;
+ self.account_updater
+ .as_ref()
+ .map(|account_updater| account_updater.get_inner().validate())
+ .transpose()?;
+
self.paze_decrypt_keys
.as_ref()
.map(|x| x.get_inner().validate())
diff --git a/crates/router/src/configs/validations.rs b/crates/router/src/configs/validations.rs
index 5263e7a49b..56770947e2 100644
--- a/crates/router/src/configs/validations.rs
+++ b/crates/router/src/configs/validations.rs
@@ -370,3 +370,47 @@ impl super::settings::SageSettings {
)
}
}
+
+impl super::settings::AccountUpdaterConfig {
+ pub fn validate(&self) -> Result<(), ApplicationError> {
+ match self {
+ Self::Juspay(juspay) => juspay.validate(),
+ }
+ }
+}
+
+impl super::settings::JuspayAccountUpdaterConfig {
+ pub fn validate(&self) -> Result<(), ApplicationError> {
+ use common_utils::fp_utils::when;
+
+ when(!self.base_url.path().ends_with('/'), || {
+ Err(ApplicationError::InvalidConfigurationValueError(
+ "account_updater.juspay.base_url must end with a trailing slash".into(),
+ ))
+ })?;
+
+ let required = [
+ ("api_key", self.api_key.peek().as_str()),
+ ("merchant_id", self.merchant_id.as_str()),
+ (
+ "euler_encryption_public_key",
+ self.euler_encryption_public_key.peek().as_str(),
+ ),
+ (
+ "au_decryption_pvt_key",
+ self.au_decryption_pvt_key.peek().as_str(),
+ ),
+ ("card_sync_key_id", self.card_sync_key_id.as_str()),
+ ];
+
+ for (field, value) in required {
+ when(value.trim().is_empty(), || {
+ Err(ApplicationError::InvalidConfigurationValueError(format!(
+ "account_updater.juspay.{field} must not be empty"
+ )))
+ })?;
+ }
+
+ Ok(())
+ }
+}
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index 9d98f6f51d..f84ba50d54 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -373,6 +373,10 @@ pub mod superposition {
pub const OFFER_ENGINE_ENABLED: &str = "offer_engine_enabled";
/// Offer Engine credential source key: `"none"` skips Offer Engine, `"application"` uses the static app config.
pub const OFFER_ENGINE_CREDENTIAL_SOURCE: &str = "offer_engine_credential_source";
+ /// Account Updater master gate key: `false` (default) disables all Account Updater calls.
+ pub const ACCOUNT_UPDATER_ENABLED: &str = "account_updater.enabled";
+ /// Account Updater credential source key: `"none"` skips Account Updater, `"application"` uses the static application config.
+ pub const ACCOUNT_UPDATER_CREDENTIAL_SOURCE: &str = "account_updater.credential_source";
/// CVV requirement configuration key
pub const REQUIRES_CVV: &str = "payments.requires_cvv";
/// implicit customer update configuration key
diff --git a/crates/router/src/core.rs b/crates/router/src/core.rs
index ce25204622..73a3703074 100644
--- a/crates/router/src/core.rs
+++ b/crates/router/src/core.rs
@@ -1,3 +1,4 @@
+pub mod account_updater;
pub mod admin;
pub mod api_keys;
pub mod api_locking;
diff --git a/crates/router/src/core/account_updater.rs b/crates/router/src/core/account_updater.rs
new file mode 100644
index 0000000000..8a0560dcb6
--- /dev/null
+++ b/crates/router/src/core/account_updater.rs
@@ -0,0 +1,3 @@
+pub mod types;
+
+pub use types::AccountUpdaterCredentialSource;
diff --git a/crates/router/src/core/account_updater/types.rs b/crates/router/src/core/account_updater/types.rs
new file mode 100644
index 0000000000..ea1652d80d
--- /dev/null
+++ b/crates/router/src/core/account_updater/types.rs
@@ -0,0 +1,17 @@
+#[derive(
+ Debug,
+ Clone,
+ Copy,
+ PartialEq,
+ Eq,
+ serde::Serialize,
+ serde::Deserialize,
+ strum::Display,
+ strum::EnumString,
+)]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum AccountUpdaterCredentialSource {
+ None,
+ Application,
+}
diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rs
index 73337d78ba..5836109be1 100644
--- a/crates/router/src/core/configs/dimension_config.rs
+++ b/crates/router/src/core/configs/dimension_config.rs
@@ -798,3 +798,28 @@ config! {
impl DatabaseBackedConfig for OfferEngineCredentialSource {
const KEY: &'static str = "offer_engine_credential_source";
}
+
+config! {
+ superposition_key = ACCOUNT_UPDATER_ENABLED,
+ output = bool,
+ default = false,
+ requires = dimension_state::DimensionsGlobal,
+ targeting_key = id_type::PaymentId
+}
+
+impl DatabaseBackedConfig for AccountUpdaterEnabled {
+ const KEY: &'static str = "account_updater_enabled";
+}
+
+config! {
+ superposition_key = ACCOUNT_UPDATER_CREDENTIAL_SOURCE,
+ output = crate::core::account_updater::types::AccountUpdaterCredentialSource,
+ default = crate::core::account_updater::types::AccountUpdaterCredentialSource::None,
+ string_enum = true,
+ requires = dimension_state::DimensionsGlobal,
+ targeting_key = id_type::PaymentId
+}
+
+impl DatabaseBackedConfig for AccountUpdaterCredentialSource {
+ const KEY: &'static str = "account_updater_credential_source";
+}