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(superposition): introduce dimension-aware boolean config resolution with superposition (#11397)

Aniket Burmane0006ca1b7e8
diff --git a/config/superposition_seed.toml b/config/superposition_seed.toml
index 3a51aa988f..5d944b2fcc 100644
--- a/config/superposition_seed.toml
+++ b/config/superposition_seed.toml
@@ -67,3 +67,33 @@ schema = { type = "boolean" }
description = "Whether client session validation is enabled for payments"
change_reason = "Initial setup"
+[default-configs.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"
+
+[default-configs.should_perform_eligibility]
+value = false
+schema = { type = "boolean" }
+description = "Whether the SDK should perform an eligibility check before confirming payment"
+change_reason = "Initial setup"
+
+[default-configs.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"
+
+[default-configs.should_store_eligibility_check_data_for_authentication]
+value = false
+schema = { type = "boolean" }
+description = "Whether to store eligibility check data during authentication"
+change_reason = "Initial setup"
+
+[default-configs.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"
+
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index e6b0d19fb1..6c69cba107 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -363,6 +363,18 @@ pub mod superposition {
pub const PAYOUT_TRACKER_MAPPING: &str = "payout_tracker_mapping";
/// client session validation enabled configuration key
pub const CLIENT_SESSION_VALIDATION_ENABLED: &str = "client_session_validation_enabled";
+ /// GSM (Global Status Map) call configuration key
+ pub const SHOULD_CALL_GSM: &str = "should_call_gsm";
+ /// Eligibility check configuration key
+ pub const SHOULD_PERFORM_ELIGIBILITY: &str = "should_perform_eligibility";
+ /// MIT with limited card data configuration key
+ pub const SHOULD_ENABLE_MIT_WITH_LIMITED_CARD_DATA: &str =
+ "should_enable_mit_with_limited_card_data";
+ /// Store eligibility check data for authentication configuration key
+ pub const SHOULD_STORE_ELIGIBILITY_CHECK_DATA_FOR_AUTHENTICATION: &str =
+ "should_store_eligibility_check_data_for_authentication";
+ /// Extended card BIN configuration key
+ pub const ENABLE_EXTENDED_CARD_BIN: &str = "enable_extended_card_bin";
}
#[cfg(test)]
diff --git a/crates/router/src/core/configs.rs b/crates/router/src/core/configs.rs
index eb1c206caa..c5ace10f91 100644
--- a/crates/router/src/core/configs.rs
+++ b/crates/router/src/core/configs.rs
@@ -1,6 +1,11 @@
pub mod dimension_config;
pub mod dimension_state;
use common_utils::errors::CustomResult;
+pub use dimension_config::{
+ EnableExtendedCardBin, ImplicitCustomerUpdate, RequiresCvv, ShouldCallGsm,
+ ShouldEnableMitWithLimitedCardData, ShouldPerformEligibility,
+ ShouldStoreEligibilityCheckDataForAuthentication,
+};
use error_stack::ResultExt;
use external_services::superposition::{self, ConfigContext};
@@ -178,8 +183,16 @@ where
let superposition_result = C::fetch(superposition_client, context, targeting_key).await;
- match superposition_result {
- Ok(value) => value,
+ let resolved_value = match superposition_result {
+ Ok(value) => {
+ router_env::logger::info!(
+ config_key = %config_type,
+ source = "superposition",
+ value = %value.to_config_string().unwrap_or_default(),
+ "Config resolved from superposition"
+ );
+ value
+ }
Err(_) => match db_key {
Some(db_key) => {
router_env::logger::info!(
@@ -199,6 +212,13 @@ where
.and_then(|config| C::Output::from_config_str(&config.config).ok())
{
Some(value) => {
+ router_env::logger::info!(
+ config_key = %config_type,
+ db_key = %db_key,
+ source = "database",
+ value = %value.to_config_string().unwrap_or_default(),
+ "Config resolved from database"
+ );
metrics::CONFIG_DATABASE_FETCH.add(
1,
router_env::metric_attributes!(("config_type", config_type)),
@@ -230,7 +250,8 @@ where
default_value
}
},
- }
+ };
+ resolved_value
}
/// Fetch object-type config with JSON-to-Type conversion.
diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rs
index 1d76c86bf8..05b55f8d53 100644
--- a/crates/router/src/core/configs/dimension_config.rs
+++ b/crates/router/src/core/configs/dimension_config.rs
@@ -1,18 +1,8 @@
use external_services::superposition;
use scheduler::consumer::types::process_data::RetryMapping;
-use super::{
- dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
- fetch_db_config_for_dimensions, DatabaseBackedConfig,
-};
-use crate::{
- consts::superposition as superposition_consts,
- core::configs::dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndConnector,
- db::StorageInterface, utils::id_type,
-};
+use super::{dimension_state, fetch_db_config_for_dimensions, DatabaseBackedConfig};
+use crate::{consts::superposition as superposition_consts, db::StorageInterface, utils::id_type};
/// Macro to generate config struct and superposition::Config trait implementation.
/// Note: Manually implement `DatabaseBackedConfig` for the config struct:
@@ -81,7 +71,7 @@ macro_rules! config {
impl DatabaseBackedConfig for [<$key:camel>] {
const KEY: &'static str = stringify!([<$key:snake>]);
- fn db_key(_dimensions: &impl super::dimension_state::DimensionsBase) -> Option<String> {
+ fn db_key(_dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
None
}
}
@@ -126,18 +116,16 @@ config! {
superposition_key = REQUIRES_CVV,
output = bool,
default = true,
- requires = DimensionsWithProcessorAndProviderMerchantId,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantId,
targeting_key = id_type::CustomerId
}
impl DatabaseBackedConfig for RequiresCvv {
const KEY: &'static str = "requires_cvv";
- fn db_key(dimensions: &impl super::dimension_state::DimensionsBase) -> Option<String> {
- let merchant_id = dimensions
+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
+ dimensions
.get_processor_merchant_id()
- .map(|id| id.get_string_repr())
- .unwrap_or_default();
- Some(format!("{}_{}", merchant_id, Self::KEY))
+ .map(|id| format!("{}_{}", id.get_string_repr(), Self::KEY))
}
}
@@ -145,18 +133,109 @@ config! {
superposition_key = IMPLICIT_CUSTOMER_UPDATE,
output = bool,
default = false,
- requires = DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
targeting_key = id_type::CustomerId
}
impl DatabaseBackedConfig for ImplicitCustomerUpdate {
const KEY: &'static str = "implicit_customer_update";
- fn db_key(dimensions: &impl super::dimension_state::DimensionsBase) -> Option<String> {
- let merchant_id = dimensions
+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
+ dimensions
.get_provider_merchant_id()
- .map(|id| id.get_string_repr())
- .unwrap_or_default();
- Some(format!("{}_{}", merchant_id, Self::KEY))
+ .map(|id| format!("{}_{}", id.get_string_repr(), Self::KEY))
+ }
+}
+
+config! {
+ superposition_key = SHOULD_CALL_GSM,
+ output = bool,
+ default = false,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ targeting_key = id_type::CustomerId
+}
+
+impl DatabaseBackedConfig for ShouldCallGsm {
+ const KEY: &'static str = "should_call_gsm";
+
+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
+ dimensions
+ .get_processor_merchant_id()
+ .map(|id| format!("{}_{}", Self::KEY, id.get_string_repr()))
+ }
+}
+
+config! {
+ superposition_key = SHOULD_PERFORM_ELIGIBILITY,
+ output = bool,
+ default = false,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ targeting_key = id_type::CustomerId
+}
+
+impl DatabaseBackedConfig for ShouldPerformEligibility {
+ const KEY: &'static str = "should_perform_eligibility";
+
+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
+ // Matches the existing key format: "should_perform_eligibility_{merchant_id}"
+ dimensions
+ .get_processor_merchant_id()
+ .map(|id| format!("{}_{}", Self::KEY, id.get_string_repr()))
+ }
+}
+
+config! {
+ superposition_key = SHOULD_ENABLE_MIT_WITH_LIMITED_CARD_DATA,
+ output = bool,
+ default = false,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ targeting_key = id_type::PaymentId
+}
+
+impl DatabaseBackedConfig for ShouldEnableMitWithLimitedCardData {
+ const KEY: &'static str = "should_enable_mit_with_limited_card_data";
+
+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
+ dimensions
+ .get_processor_merchant_id()
+ .map(|id| format!("{}_{}", Self::KEY, id.get_string_repr()))
+ }
+}
+
+config! {
+ superposition_key = SHOULD_STORE_ELIGIBILITY_CHECK_DATA_FOR_AUTHENTICATION,
+ output = bool,
+ default = false,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ targeting_key = id_type::AuthenticationId
+}
+
+impl DatabaseBackedConfig for ShouldStoreEligibilityCheckDataForAuthentication {
+ const KEY: &'static str = "should_store_eligibility_check_data_for_authentication";
+
+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
+ // Matches the existing key format: "should_store_eligibility_check_data_for_authentication_{merchant_id}"
+ dimensions
+ .get_processor_merchant_id()
+ .map(|id| format!("{}_{}", Self::KEY, id.get_string_repr()))
+ }
+}
+
+config! {
+ superposition_key = ENABLE_EXTENDED_CARD_BIN,
+ output = bool,
+ default = false,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ targeting_key = id_type::CustomerId
+}
+
+impl DatabaseBackedConfig for EnableExtendedCardBin {
+ const KEY: &'static str = "enable_extended_card_bin";
+
+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
+ // Matches the existing key format: "{profile_id}_enable_extended_card_bin"
+ dimensions
+ .get_profile_id()
+ .map(|id| format!("{}_{}", id.get_string_repr(), Self::KEY))
}
}
@@ -165,7 +244,7 @@ config! {
output = RetryMapping,
default = RetryMapping::default(),
object = true,
- requires = DimensionsWithProcessorAndProviderMerchantIdAndConnector,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndConnector,
targeting_key = id_type::PayoutId
}
@@ -173,13 +252,13 @@ config! {
superposition_key = CLIENT_SESSION_VALIDATION_ENABLED,
output = bool,
default = true,
- requires = DimensionsWithProcessorAndProviderMerchantId,
+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantId,
targeting_key = id_type::PaymentId
}
impl DatabaseBackedConfig for ClientSessionValidationEnabled {
const KEY: &'static str = "client_session_validation_enabled";
- fn db_key(_dimensions: &impl super::dimension_state::DimensionsBase) -> Option<String> {
+ fn db_key(_dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {
None
}
}
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 87b01e41e6..b1b47694d6 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -76,8 +76,7 @@ use crate::{
configs::settings,
consts as router_consts,
core::{
- configs,
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, StorageErrorExt},
payment_methods::{
network_tokenization, transformers as payment_methods, utils as payment_method_utils,
@@ -3075,6 +3074,9 @@ pub async fn list_payment_methods(
) -> errors::RouterResponse<api::PaymentMethodListResponse> {
let db = &*state.store;
let pm_config_mapping = &state.conf.pm_filters;
+ let dimensions = dimension_state::Dimensions::new()
+ .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
let payment_intent = if let Some(cs) = &req.client_secret {
if cs.starts_with("pm_") {
validate_payment_method_and_client_secret(cs, db, &platform).await?;
@@ -3986,9 +3988,13 @@ pub async fn list_payment_methods(
.as_ref()
.and_then(|intent| intent.request_external_three_ds_authentication)
.unwrap_or(false);
+
let sdk_next_action = payment_method_utils::get_sdk_next_action_for_payment_method_list(
- db,
- platform.get_processor().get_account().get_id(),
+ &state,
+ &dimensions,
+ payment_intent
+ .as_ref()
+ .and_then(|pi| pi.customer_id.as_ref()),
)
.await;
let is_guest_customer = payment_intent
@@ -4601,7 +4607,7 @@ pub async fn do_list_customer_pm_fetch_customer_if_not_passed(
customer_id: Option<&id_type::CustomerId>,
ephemeral_api_key: Option<&str>,
) -> errors::RouterResponse<api::CustomerPaymentMethodsListResponse> {
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
let limit = req.clone().and_then(|pml_req| pml_req.limit);
@@ -4627,7 +4633,7 @@ pub async fn do_list_customer_pm_fetch_customer_if_not_passed(
None,
customer_id,
limit,
- dimensions,
+ &dimensions,
))
.await
} else {
@@ -4647,7 +4653,7 @@ pub async fn do_list_customer_pm_fetch_customer_if_not_passed(
payment_intent,
&customer_id,
limit,
- dimensions,
+ &dimensions,
))
.await
}
@@ -4669,7 +4675,7 @@ pub async fn list_customer_payment_method(
payment_intent: Option<storage::PaymentIntent>,
customer_id: &id_type::CustomerId,
limit: Option<i64>,
- dimensions: DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> errors::RouterResponse<api::CustomerPaymentMethodsListResponse> {
let db = &*state.store;
let off_session_payment_flag = payment_intent
diff --git a/crates/router/src/core/payment_methods/utils.rs b/crates/router/src/core/payment_methods/utils.rs
index fc6afdd22b..130e4e505a 100644
--- a/crates/router/src/core/payment_methods/utils.rs
+++ b/crates/router/src/core/payment_methods/utils.rs
@@ -18,7 +18,9 @@ use kgraph_utils::{error::KgraphError, transformers::IntoDirValue};
use router_env::logger;
use storage_impl::redis::cache::{CacheKey, PM_FILTERS_CGRAPH_CACHE};
-use crate::{configs::settings, db::StorageInterface, routes::SessionState};
+use crate::{
+ configs::settings, core::configs::dimension_state, db::StorageInterface, routes::SessionState,
+};
#[cfg(feature = "v2")]
use crate::{
db::{
@@ -814,25 +816,6 @@ fn compile_accepted_currency_for_mca(
))
}
-pub async fn get_merchant_config_for_eligibility_check(
- db: &dyn StorageInterface,
- merchant_id: &common_utils::id_type::MerchantId,
-) -> bool {
- let config = db
- .find_config_by_key_unwrap_or(
- &merchant_id.get_should_perform_eligibility_check_key(),
- Some("false".to_string()),
- )
- .await;
- match config {
- Ok(conf) => conf.config == "true",
- Err(error) => {
- logger::error!(?error);
- false
- }
- }
-}
-
pub async fn get_organization_eligibility_config_for_pm_modular_service(
db: &dyn StorageInterface,
organization_id: &common_utils::id_type::OrganizationId,
@@ -853,11 +836,17 @@ pub async fn get_organization_eligibility_config_for_pm_modular_service(
}
pub async fn get_sdk_next_action_for_payment_method_list(
- db: &dyn StorageInterface,
- merchant_id: &common_utils::id_type::MerchantId,
+ state: &SessionState,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ customer_id: Option<&common_utils::id_type::CustomerId>,
) -> api_models::payments::SdkNextAction {
- let should_perform_eligibility_check =
- get_merchant_config_for_eligibility_check(db, merchant_id).await;
+ let should_perform_eligibility_check = dimensions
+ .get_should_perform_eligibility(
+ state.store.as_ref(),
+ state.superposition_service.as_ref(),
+ customer_id,
+ )
+ .await;
let next_action_call = if should_perform_eligibility_check {
api_models::payments::NextActionCall::EligibilityCheck
} else {
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index ba795bb3b5..b843cc93ba 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -133,7 +133,7 @@ use crate::{
},
consts,
core::{
- configs::{self as configs, dimension_state::DimensionsWithProcessorAndProviderMerchantId},
+ configs::dimension_state,
errors::{self, CustomResult, RouterResponse, RouterResult},
payment_methods::{cards, network_tokenization},
payments::helpers::{
@@ -213,7 +213,7 @@ where
PaymentResponse: Operation<F, FData, Data = D>,
FData: Send + Sync + Clone,
{
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -636,7 +636,7 @@ pub async fn payments_operation_core<'a, F, Req, Op, FData, D>(
auth_flow: services::AuthFlow,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
header_payload: HeaderPayload,
- dimensions: DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(D, Req, Option<u16>, Option<u128>)>
where
F: Send + Clone + Sync + Debug + 'static,
@@ -772,6 +772,7 @@ where
&mut payment_data,
eligible_connectors,
mandate_type,
+ &dimensions,
)
.await?;
@@ -1246,10 +1247,12 @@ where
#[cfg(all(feature = "retry", feature = "v1"))]
{
use crate::core::payments::retry::{self, GsmValidation};
+
let config_bool = retry::config_should_call_gsm(
- &*state.store,
- platform.get_processor().get_account().get_id(),
+ state,
+ &dimensions,
&business_profile,
+ customer.as_ref().map(|c| c.get_id()),
)
.await;
@@ -1273,6 +1276,7 @@ where
&business_profile,
#[cfg(feature = "pm_modular")]
&feature_config,
+ &dimensions,
)
.await?;
};
@@ -1510,7 +1514,7 @@ pub async fn proxy_for_payments_operation_core<F, Req, Op, FData, D>(
auth_flow: services::AuthFlow,
header_payload: HeaderPayload,
return_raw_connector_response: Option<bool>,
- dimensions: DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(D, Req, Option<u16>, Option<u128>)>
where
F: Send + Clone + Sync,
@@ -1574,7 +1578,8 @@ where
validate_for_proxy_payment(
state,
&payment_data,
- platform.get_processor().get_account().get_id(),
+ &dimensions,
+ &payment_data.get_payment_intent().payment_id,
)
.await?;
@@ -1860,7 +1865,7 @@ where
// Get the trackers related to track the state of the payment
let operations::GetTrackerResponse { mut payment_data } = get_tracker_response;
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -1983,7 +1988,7 @@ where
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
let operation: BoxedOperation<'_, F, Req, D> = Box::new(operation);
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -2062,7 +2067,7 @@ where
D: OperationSessionGetters<F> + Send + Sync + Clone,
{
let operation: BoxedOperation<'_, F, Req, D> = Box::new(operation);
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -2576,7 +2581,7 @@ where
.flat_map(|c| c.foreign_try_into())
.collect()
});
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
let (payment_data, _req, connector_http_status_code, external_latency) =
@@ -2592,7 +2597,7 @@ where
auth_flow,
eligible_routable_connectors,
header_payload.clone(),
- dimensions,
+ &dimensions,
)
.await?;
@@ -2641,7 +2646,7 @@ where
// To perform router related operation for PaymentResponse
PaymentResponse: Operation<F, FData, Data = D>,
{
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
let (payment_data, _req, connector_http_status_code, external_latency) =
@@ -2656,7 +2661,7 @@ where
auth_flow,
header_payload.clone(),
return_raw_connector_response,
- dimensions,
+ &dimensions,
)
.await?;
@@ -2851,7 +2856,7 @@ pub async fn record_attempt_core(
.get_string_repr(),
);
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -4824,7 +4829,7 @@ pub async fn complete_connector_service<F, RouterDReq, ApiRequest, D>(
header_payload: HeaderPayload,
frm_suggestion: Option<storage_enums::FrmSuggestion>,
call_connector_service_response: ConnectorServiceIntermediateState<F, RouterDReq>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
RouterData<F, RouterDReq, router_types::PaymentsResponseData>,
helpers::MerchantConnectorAccountType,
@@ -5318,7 +5323,7 @@ pub async fn complete_connector_service<F, RouterDReq, ApiRequest, D>(
header_payload: HeaderPayload,
frm_suggestion: Option<storage_enums::FrmSuggestion>,
call_connector_service_response: ConnectorServiceIntermediateState<F, RouterDReq>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
RouterData<F, RouterDReq, router_types::PaymentsResponseData>,
domain::MerchantConnectorAccountTypeDetails,
@@ -5689,7 +5694,7 @@ where
)
.await?;
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -5908,7 +5913,7 @@ pub async fn call_unified_connector_service_for_external_proxy<F, RouterDReq, Ap
external_vault_merchant_connector_account_type_details: domain::MerchantConnectorAccountTypeDetails,
mut router_data: RouterData<F, RouterDReq, router_types::PaymentsResponseData>,
_updated_customer: Option<storage::CustomerUpdate>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<RouterData<F, RouterDReq, router_types::PaymentsResponseData>>
where
F: Send + Clone + Sync,
@@ -5991,7 +5996,7 @@ where
dyn api::Connector:
services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,
{
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -6203,7 +6208,7 @@ where
)
.await?,
));
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -6332,7 +6337,7 @@ where
{
let stime_connector = Instant::now();
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -9647,6 +9652,7 @@ pub async fn choose_connector<F, Req, D>(
payment_data: &mut D,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
) -> RouterResult<Option<ConnectorCallType>>
where
F: Send + Clone,
@@ -9718,6 +9724,7 @@ where
Some(straight_through),
eligible_connectors,
mandate_type,
+ dimensions,
fallback_config,
backend_input,
)
@@ -9735,6 +9742,7 @@ where
None,
eligible_connectors,
mandate_type,
+ dimensions,
fallback_config,
backend_input,
)
@@ -9884,7 +9892,8 @@ where
pub async fn validate_for_proxy_payment<F, D>(
state: &SessionState,
payment_data: &D,
- merchant_id: &id_type::MerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ payment_id: &id_type::PaymentId,
) -> RouterResult<()>
where
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
@@ -9896,20 +9905,13 @@ where
.clone()
.is_card_limited_details_flow();
- let db = &*state.store;
- let config = db
- .find_config_by_key_unwrap_or(
- &merchant_id.get_should_enable_mit_with_limited_card_data(),
- Some("false".to_string()),
+ let is_mit_with_limited_card_data_enabled = dimensions
+ .get_should_enable_mit_with_limited_card_data(
+ state.store.as_ref(),
+ state.superposition_service.as_ref(),
+ Some(payment_id),
)
.await;
- let is_mit_with_limited_card_data_enabled = match config {
- Ok(conf) => conf.config == "true",
- Err(error) => {
- router_env::logger::error!(?error);
- false
- }
- };
utils::when(
is_card_limited_details_flow && !is_mit_with_limited_card_data_enabled,
@@ -9934,6 +9936,7 @@ pub async fn perform_routing_for_connector_selection<F, D>(
request_straight_through: Option<serde_json::Value>,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
fallback_config: Vec<api_models::routing::RoutableConnectorChoice>,
backend_input: dsl_inputs::BackendInput,
) -> RouterResult<ConnectorCallType>
@@ -9980,6 +9983,7 @@ where
&mut routing_data,
eligible_connectors,
mandate_type,
+ dimensions,
fallback_config,
backend_input,
#[cfg(feature = "pm_modular")]
@@ -10178,6 +10182,7 @@ pub async fn decide_connector<F, D>(
routing_data: &mut storage::RoutingData,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
fallback_config: Vec<api_models::routing::RoutableConnectorChoice>,
backend_input: dsl_inputs::BackendInput,
is_payment_method_modular_allowed: bool,
@@ -10211,6 +10216,7 @@ where
business_profile,
payment_data,
routing_data,
+ dimensions,
)
.await
.inspect_err(|err| {
@@ -11531,7 +11537,6 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
.clone()
.get_required_value("authentication_connector_details")
.attach_printable("authentication_connector_details not configured by the merchant")?;
-
let authentication_response =
if helpers::is_merchant_eligible_authentication_service(platform.get_processor(), &state)
.await?
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 918f4d83b3..bd0c01571d 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -89,7 +89,7 @@ use crate::{
consts::{self, BASE64_ENGINE},
core::{
authentication,
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers::MandateGenericData,
payment_methods::{
@@ -1958,7 +1958,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(
_payment_data: &mut PaymentData<F>,
_req: Option<CustomerDetails>,
_provider: &domain::Provider,
- _dimensions: DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
) -> CustomResult<(BoxedOperation<'a, F, R, D>, Option<domain::Customer>), errors::StorageError> {
todo!()
}
@@ -1973,7 +1973,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(
req: Option<CustomerDetails>,
provider: &domain::Provider,
initiator: Option<&domain::Initiator>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
) -> CustomResult<(BoxedOperation<'a, F, R, D>, Option<domain::Customer>), errors::StorageError> {
let merchant_id = provider.get_account().get_id();
let storage_scheme = provider.get_account().storage_scheme;
@@ -5607,27 +5607,27 @@ mod test {
pub async fn get_additional_payment_data(
pm_data: &domain::PaymentMethodData,
db: &dyn StorageInterface,
- profile_id: &id_type::ProfileId,
+ superposition_service: &external_services::superposition::SuperpositionClient,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ customer_id: Option<&id_type::CustomerId>,
payment_method_token: Option<&PaymentMethodToken>,
) -> Result<
Option<api_models::payments::AdditionalPaymentData>,
error_stack::Report<errors::ApiErrorResponse>,
> {
+ let enable_extended_bin = dimensions
+ .get_enable_extended_card_bin(db, superposition_service, customer_id)
+ .await;
+
match pm_data {
domain::PaymentMethodData::Card(card_data) => {
//todo!
let card_isin = Some(card_data.card_number.get_card_isin());
- let enable_extended_bin =db
- .find_config_by_key_unwrap_or(
- format!("{}_enable_extended_card_bin", profile_id.get_string_repr()).as_str(),
- Some("false".to_string()))
- .await.map_err(|err| services::logger::error!(message="Failed to fetch the config", extended_card_bin_error=?err)).ok();
-
- let card_extended_bin = match enable_extended_bin {
- Some(config) if config.config == "true" => {
- Some(card_data.card_number.get_extended_card_bin())
- }
- _ => None,
+
+ let card_extended_bin = if enable_extended_bin {
+ Some(card_data.card_number.get_extended_card_bin())
+ } else {
+ None
};
// Added an additional check for card_data.co_badged_card_data.is_some()
@@ -5761,17 +5761,11 @@ pub async fn get_additional_payment_data(
}
domain::PaymentMethodData::CardWithOptionalCVC(card_data) => {
let card_isin = Some(card_data.card_number.get_card_isin());
- let enable_extended_bin =db
- .find_config_by_key_unwrap_or(
- format!("{}_enable_extended_card_bin", profile_id.get_string_repr()).as_str(),
- Some("false".to_string()))
- .await.map_err(|err| services::logger::error!(message="Failed to fetch the config", extended_card_bin_error=?err)).ok();
-
- let card_extended_bin = match enable_extended_bin {
- Some(config) if config.config == "true" => {
- Some(card_data.card_number.get_extended_card_bin())
- }
- _ => None,
+
+ let card_extended_bin = if enable_extended_bin {
+ Some(card_data.card_number.get_extended_card_bin())
+ } else {
+ None
};
// Added an additional check for card_data.co_badged_card_data.is_some()
@@ -5909,7 +5903,9 @@ pub async fn get_additional_payment_data(
card_with_network_token_details.card_details.clone(),
),
db,
- profile_id,
+ superposition_service,
+ dimensions,
+ customer_id,
payment_method_token,
))
.await
@@ -6148,17 +6144,11 @@ pub async fn get_additional_payment_data(
)),
domain::PaymentMethodData::CardDetailsForNetworkTransactionId(card_data) => {
let card_isin = Some(card_data.card_number.get_card_isin());
- let enable_extended_bin =db
- .find_config_by_key_unwrap_or(
- format!("{}_enable_extended_card_bin", profile_id.get_string_repr()).as_str(),
- Some("false".to_string()))
- .await.map_err(|err| services::logger::error!(message="Failed to fetch the config", extended_card_bin_error=?err)).ok();
-
- let card_extended_bin = match enable_extended_bin {
- Some(config) if config.config == "true" => {
- Some(card_data.card_number.get_extended_card_bin())
- }
- _ => None,
+
+ let card_extended_bin = if enable_extended_bin {
+ Some(card_data.card_number.get_extended_card_bin())
+ } else {
+ None
};
let card_network = match card_data
@@ -6264,19 +6254,15 @@ pub async fn get_additional_payment_data(
}
domain::PaymentMethodData::CardWithLimitedDetails(card_with_limited_details) => {
let card_isin = Some(card_with_limited_details.card_number.get_card_isin());
- let enable_extended_bin =db
- .find_config_by_key_unwrap_or(
- format!("{}_enable_extended_card_bin", profile_id.get_string_repr()).as_str(),
- Some("false".to_string()))
- .await.map_err(|err| services::logger::error!(message="Failed to fetch the config", extended_card_bin_error=?err)).ok();
-
- let card_extended_bin = match enable_extended_bin {
- Some(config) if config.config == "true" => Some(
+
+ let card_extended_bin = if enable_extended_bin {
+ Some(
card_with_limited_details
.card_number
.get_extended_card_bin(),
- ),
- _ => None,
+ )
+ } else {
+ None
};
let last4 = Some(card_with_limited_details.card_number.get_last4());
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index 9177124998..86067b44f3 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -107,10 +107,7 @@ use crate::core::payments;
use crate::core::utils as core_utils;
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult},
},
routes::{app::ReqState, SessionState},
@@ -283,7 +280,7 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {
request: Option<CustomerDetails>,
provider: &domain::Provider,
initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<api::MandateTransactionType>,
) -> CustomResult<(BoxedOperation<'a, F, R, D>, Option<domain::Customer>), errors::StorageError>;
@@ -548,7 +545,7 @@ pub trait UpdateTracker<F, D, Req>: Send {
payment_data: D,
frm_suggestion: Option<FrmSuggestion>,
header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(BoxedOperation<'b, F, Req, D>, D)>
where
F: 'b + Send;
@@ -679,7 +676,7 @@ where
_request: Option<CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<api::MandateTransactionType>,
) -> CustomResult<
(
@@ -751,7 +748,7 @@ where
_request: Option<CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<api::MandateTransactionType>,
) -> CustomResult<
(
@@ -841,7 +838,7 @@ where
_request: Option<CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<api::MandateTransactionType>,
) -> CustomResult<
(
@@ -931,7 +928,7 @@ where
_request: Option<CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<api::MandateTransactionType>,
) -> CustomResult<
(
diff --git a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
index da58ae8852..9637d33ca1 100644
--- a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
+++ b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
@@ -17,7 +17,7 @@ use router_env::{instrument, tracing};
use super::{Domain, GetTracker, Operation, PostUpdateTracker, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payment_methods::{self, PaymentMethodExt},
payments::{
@@ -485,7 +485,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ExternalVaultProxy
mut payment_data: PaymentConfirmData<F>,
_frm_suggestion: Option<api_models::enums::FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentConfirmData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs
index af0ad0aa52..c461e5a739 100644
--- a/crates/router/src/core/payments/operations/payment_approve.rs
+++ b/crates/router/src/core/payments/operations/payment_approve.rs
@@ -9,7 +9,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{helpers, operations, PaymentData},
},
@@ -233,7 +233,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsCaptureReque
mut payment_data: PaymentData<F>,
frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentApproveOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_attempt_list.rs b/crates/router/src/core/payments/operations/payment_attempt_list.rs
index d82785fafb..49c27be3a9 100644
--- a/crates/router/src/core/payments/operations/payment_attempt_list.rs
+++ b/crates/router/src/core/payments/operations/payment_attempt_list.rs
@@ -9,7 +9,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult},
payments::{self, operations},
},
@@ -128,7 +128,7 @@ impl<F: Clone + Sync>
payment_data: payments::PaymentAttemptListData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentAttemptsListOperation<'b, F>,
payments::PaymentAttemptListData<F>,
diff --git a/crates/router/src/core/payments/operations/payment_attempt_record.rs b/crates/router/src/core/payments/operations/payment_attempt_record.rs
index b563164fa3..c11b4aaca5 100644
--- a/crates/router/src/core/payments/operations/payment_attempt_record.rs
+++ b/crates/router/src/core/payments/operations/payment_attempt_record.rs
@@ -15,7 +15,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, StorageErrorExt},
payments::{
self, helpers,
@@ -248,7 +248,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentAttemptRecordData<F>, PaymentsAtte
mut payment_data: PaymentAttemptRecordData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentsAttemptRecordOperation<'b, F>,
PaymentAttemptRecordData<F>,
diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs
index a6681cae54..428349403d 100644
--- a/crates/router/src/core/payments/operations/payment_cancel.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel.rs
@@ -9,7 +9,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{helpers, operations, PaymentData},
},
@@ -245,7 +245,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsCancelReques
mut payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentCancelOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
index 47b1acf7a5..1b30f72b83 100644
--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
@@ -8,10 +8,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, PaymentData},
},
@@ -253,7 +250,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsCancelPostCaptureRequest, Pa
_request: Option<payments::CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> errors::CustomResult<
(
@@ -317,7 +314,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsCancelPostCa
payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentCancelPostCaptureOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_cancel_v2.rs b/crates/router/src/core/payments/operations/payment_cancel_v2.rs
index b53de14050..0354a5df31 100644
--- a/crates/router/src/core/payments/operations/payment_cancel_v2.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel_v2.rs
@@ -12,7 +12,7 @@ use super::{
};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::operations,
},
@@ -205,7 +205,7 @@ impl<F: Clone + Send + Sync>
mut payment_data: hyperswitch_domain_models::payments::PaymentCancelData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
BoxedCancelOperation<'b, F>,
hyperswitch_domain_models::payments::PaymentCancelData<F>,
diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs
index 049cec742f..f0f5bf6e17 100644
--- a/crates/router/src/core/payments/operations/payment_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_capture.rs
@@ -9,7 +9,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, types::MultipleCaptureData},
},
@@ -301,7 +301,7 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentData<F>, api::PaymentsCa
mut payment_data: payments::PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentCaptureOperation<'b, F>, payments::PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_capture_v2.rs b/crates/router/src/core/payments/operations/payment_capture_v2.rs
index e67ab61ef4..8281810b34 100644
--- a/crates/router/src/core/payments/operations/payment_capture_v2.rs
+++ b/crates/router/src/core/payments/operations/payment_capture_v2.rs
@@ -7,7 +7,7 @@ use router_env::{instrument, tracing};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
helpers,
@@ -299,7 +299,7 @@ impl<F: Clone> UpdateTracker<F, PaymentCaptureData<F>, PaymentsCaptureRequest> f
mut payment_data: PaymentCaptureData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentCaptureData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index c04d602234..04399638d7 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -10,10 +10,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payments::{
@@ -416,7 +413,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
_request: Option<CustomerDetails>,
provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> CustomResult<
(CompleteAuthorizeOperation<'a, F>, Option<domain::Customer>),
@@ -522,7 +519,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
mut payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(CompleteAuthorizeOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 813c4df7a2..d2b3fe01fe 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -44,10 +44,7 @@ use crate::{
authentication,
blocklist::utils as blocklist_utils,
card_testing_guard::utils as card_testing_guard_utils,
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
metrics,
@@ -524,12 +521,18 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
.or(payment_method_recurring_details.clone());
let store = state.clone().store;
+ let superposition_service = state.superposition_service.clone();
let profile_id = payment_intent
.profile_id
.clone()
.get_required_value("profile_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("'profile_id' not set in payment intent")?;
+ let customer_id = payment_intent.customer_id.clone();
+ let dimensions = dimension_state::Dimensions::new()
+ .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())
+ .with_profile_id(profile_id.clone());
let additional_pm_data_fut = tokio::spawn(
async move {
@@ -538,7 +541,9 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
helpers::get_additional_payment_data(
&payment_method_data,
store.as_ref(),
- &profile_id,
+ superposition_service.as_ref(),
+ &dimensions,
+ customer_id.as_ref(),
None,
)
.await
@@ -1064,7 +1069,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
request: Option<CustomerDetails>,
provider: &domain::Provider,
initiator: Option<&domain::Initiator>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
mandate_type: Option<MandateTransactionType>,
) -> CustomResult<
(PaymentConfirmOperation<'a, F>, Option<domain::Customer>),
@@ -2297,7 +2302,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
_customer: Option<domain::Customer>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::Dimensions,
) -> RouterResult<(
BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>,
PaymentData<F>,
@@ -2321,7 +2326,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
mut payment_data: PaymentData<F>,
frm_suggestion: Option<FrmSuggestion>,
header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>,
PaymentData<F>,
@@ -2415,7 +2420,10 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
.get_required_value("profile_id")
.change_context(errors::ApiErrorResponse::InternalServerError)?;
+ let customer_id = payment_data.payment_intent.customer_id.as_ref();
+
let payment_experience = payment_data.payment_attempt.payment_experience;
+ let dimensions = dimensions.with_profile_id(profile_id.clone());
let additional_pm_data = payment_data
.payment_method_data
.as_ref()
@@ -2423,7 +2431,9 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
helpers::get_additional_payment_data(
payment_method_data,
&*state.store,
- profile_id,
+ state.superposition_service.as_ref(),
+ &dimensions,
+ customer_id,
payment_data.payment_method_token.as_ref(),
)
.await
diff --git a/crates/router/src/core/payments/operations/payment_confirm_intent.rs b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
index 3f84a3fee7..9e9620dad0 100644
--- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
@@ -11,7 +11,7 @@ use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
admin,
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payment_methods,
payments::{
@@ -757,7 +757,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, PaymentsConfirmInt
mut payment_data: PaymentConfirmData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentConfirmData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index a40aa87025..8ea5d0f002 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -35,10 +35,7 @@ use crate::core::payment_methods::transformers as pm_transformers;
use crate::{
consts,
core::{
- configs::dimension_state::{
- Dimensions, DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payment_link,
@@ -373,6 +370,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
profile_id.clone(),
&customer_acceptance,
payment_method_recurring_details.clone(),
+ customer_details.customer_id.as_ref(),
)
.await?;
@@ -672,7 +670,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
let unified_address = address.unify_with_payment_method_data_billing(add);
// Check if client session validation is enabled
- let dimensions = Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id());
@@ -774,7 +772,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
request: Option<CustomerDetails>,
provider: &domain::Provider,
initiator: Option<&domain::Initiator>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
mandate_type: Option<MandateTransactionType>,
) -> CustomResult<(PaymentCreateOperation<'a, F>, Option<domain::Customer>), errors::StorageError>
{
@@ -1070,7 +1068,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
mut payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentCreateOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
@@ -1377,6 +1375,7 @@ impl PaymentCreate {
profile_id: common_utils::id_type::ProfileId,
customer_acceptance: &Option<common_payments_types::CustomerAcceptance>,
payment_method_recurring_details: Option<domain::PaymentMethodData>,
+ customer_id: Option<&common_utils::id_type::CustomerId>,
) -> RouterResult<(
PaymentAttempt,
Option<api_models::payments::AdditionalPaymentData>,
@@ -1389,6 +1388,10 @@ impl PaymentCreate {
payment_method_data_request.payment_method_data.as_ref()
});
+ let dimensions = dimension_state::Dimensions::new()
+ .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
+
let created_at @ modified_at @ last_synced = common_utils::date_time::now();
let status = helpers::payment_attempt_status_fsm(payment_method_data, request.confirm);
let (amount, currency) = (money.0, Some(money.1));
@@ -1403,10 +1406,13 @@ impl PaymentCreate {
.or(payment_method_recurring_details)
.zip(Some(profile_id.clone())) // since data is consumed by async move, profile_id needs to be send separately
.async_map(|(payment_method_data, profile_id)| async move {
+ let dimensions = dimensions.with_profile_id(profile_id);
helpers::get_additional_payment_data(
&payment_method_data,
&*state.store,
- &profile_id,
+ state.superposition_service.as_ref(),
+ &dimensions,
+ customer_id,
None,
)
.await
diff --git a/crates/router/src/core/payments/operations/payment_create_intent.rs b/crates/router/src/core/payments/operations/payment_create_intent.rs
index b647006869..f69cf125d4 100644
--- a/crates/router/src/core/payments/operations/payment_create_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_create_intent.rs
@@ -14,7 +14,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations},
},
@@ -202,7 +202,7 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsC
payment_data: payments::PaymentIntentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentsCreateIntentOperation<'b, F>,
payments::PaymentIntentData<F>,
diff --git a/crates/router/src/core/payments/operations/payment_get.rs b/crates/router/src/core/payments/operations/payment_get.rs
index 2f4dc79719..f76c08d6ca 100644
--- a/crates/router/src/core/payments/operations/payment_get.rs
+++ b/crates/router/src/core/payments/operations/payment_get.rs
@@ -8,7 +8,7 @@ use router_env::{instrument, tracing};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
helpers,
@@ -373,7 +373,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentStatusData<F>, PaymentsRetrieveReq
payment_data: PaymentStatusData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentStatusData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_get_intent.rs b/crates/router/src/core/payments/operations/payment_get_intent.rs
index b7c046534c..7117ea9b2e 100644
--- a/crates/router/src/core/payments/operations/payment_get_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_get_intent.rs
@@ -8,7 +8,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult},
payments::{self, helpers, operations},
},
@@ -130,7 +130,7 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsG
payment_data: payments::PaymentIntentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentsGetIntentOperation<'b, F>,
payments::PaymentIntentData<F>,
diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
index 66e3774939..f425156e6f 100644
--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
@@ -10,10 +10,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, PaymentData},
},
@@ -213,7 +210,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsPostSessionTokensRequest, Pa
_request: Option<payments::CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> errors::CustomResult<
(
@@ -277,7 +274,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsPostSessionT
payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentPostSessionTokensOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_recurrence.rs b/crates/router/src/core/payments/operations/payment_recurrence.rs
index 3728431721..03dc87b0eb 100644
--- a/crates/router/src/core/payments/operations/payment_recurrence.rs
+++ b/crates/router/src/core/payments/operations/payment_recurrence.rs
@@ -20,10 +20,7 @@ use crate::{
};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payment_methods::transformers as pm_transformers,
@@ -164,12 +161,17 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
.map(domain::PaymentMethodData::from);
let store = state.clone().store;
+ let superposition_service = state.clone().superposition_service;
let profile_id = payment_intent
.profile_id
.clone()
.get_required_value("profile_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("'profile_id' not set in payment intent")?;
+ let dimensions = dimension_state::Dimensions::new()
+ .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())
+ .with_profile_id(profile_id.clone());
let additional_pm_data_fut = tokio::spawn(
async move {
@@ -178,7 +180,9 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
helpers::get_additional_payment_data(
&payment_method_data,
store.as_ref(),
- &profile_id,
+ superposition_service.as_ref(),
+ &dimensions,
+ None,
None,
)
.await
@@ -422,7 +426,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
request: Option<CustomerDetails>,
provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<api::MandateTransactionType>,
) -> CustomResult<
(PaymentRecurrenceOperation<'a, F>, Option<domain::Customer>),
@@ -529,7 +533,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
mut payment_data: PaymentData<F>,
frm_suggestion: Option<FrmSuggestion>,
header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
BoxedOperation<'b, F, api::PaymentsRequest, PaymentData<F>>,
PaymentData<F>,
@@ -624,6 +628,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
.change_context(errors::ApiErrorResponse::InternalServerError)?;
let payment_experience = payment_data.payment_attempt.payment_experience;
+ let dimensions = dimensions.with_profile_id(profile_id.clone());
let additional_pm_data = payment_data
.payment_method_data
.as_ref()
@@ -631,7 +636,9 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
helpers::get_additional_payment_data(
payment_method_data,
&*state.store,
- profile_id,
+ state.superposition_service.as_ref(),
+ &dimensions,
+ payment_data.payment_intent.customer_id.as_ref(),
payment_data.payment_method_token.as_ref(),
)
.await
diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs
index d058f2bf23..99fb2910ac 100644
--- a/crates/router/src/core/payments/operations/payment_reject.rs
+++ b/crates/router/src/core/payments/operations/payment_reject.rs
@@ -8,7 +8,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{helpers, operations, PaymentAddress, PaymentData},
},
@@ -230,7 +230,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, PaymentsCancelRequest> fo
mut payment_data: PaymentData<F>,
_should_decline_transaction: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentRejectOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index 019bf307b9..527ed2674d 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -12,10 +12,7 @@ use router_env::{instrument, logger, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, PaymentData},
},
@@ -262,7 +259,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsSessionReque
mut payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentSessionOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
@@ -338,7 +335,7 @@ where
request: Option<payments::CustomerDetails>,
provider: &domain::Provider,
initiator: Option<&domain::Initiator>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> errors::CustomResult<
(PaymentSessionOperation<'a, F>, Option<domain::Customer>),
diff --git a/crates/router/src/core/payments/operations/payment_session_intent.rs b/crates/router/src/core/payments/operations/payment_session_intent.rs
index 4bddef996b..5366375cc2 100644
--- a/crates/router/src/core/payments/operations/payment_session_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_session_intent.rs
@@ -10,7 +10,7 @@ use router_env::{instrument, logger, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, operations::ValidateStatusForOperation},
},
@@ -171,7 +171,7 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsS
mut payment_data: payments::PaymentIntentData<F>,
_frm_suggestion: Option<common_enums::FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentSessionOperation<'b, F>,
payments::PaymentIntentData<F>,
diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs
index a5be806497..2de495c46d 100644
--- a/crates/router/src/core/payments/operations/payment_start.rs
+++ b/crates/router/src/core/payments/operations/payment_start.rs
@@ -11,10 +11,7 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida
use crate::core::utils;
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{helpers, operations, CustomerDetails, PaymentAddress, PaymentData},
},
@@ -274,7 +271,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsStartRequest
payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentSessionOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
@@ -329,7 +326,7 @@ where
_request: Option<CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> CustomResult<
(PaymentSessionOperation<'a, F>, Option<domain::Customer>),
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index 64f7fce9d0..930d4b8176 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -10,10 +10,7 @@ use router_env::{instrument, logger, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
helpers, operations, types as payment_types, CustomerDetails, PaymentAddress,
@@ -71,7 +68,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
request: Option<CustomerDetails>,
provider: &domain::Provider,
initiator: Option<&domain::Initiator>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> CustomResult<
(
@@ -173,7 +170,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentStatusOperation<'b, F, api::PaymentsRequest>,
PaymentData<F>,
@@ -203,7 +200,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRetrieveRequ
payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentStatusOperation<'b, F, api::PaymentsRetrieveRequest>,
PaymentData<F>,
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index 94143d8721..987086e2ba 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -21,10 +21,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
mandate::helpers as m_helpers,
payments::{
@@ -598,7 +595,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
request: Option<CustomerDetails>,
provider: &domain::Provider,
initiator: Option<&domain::Initiator>,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> CustomResult<(PaymentUpdateOperation<'a, F>, Option<domain::Customer>), errors::StorageError>
{
@@ -817,7 +814,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
_customer: Option<domain::Customer>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentUpdateOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
@@ -835,7 +832,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
mut payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentUpdateOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
@@ -863,6 +860,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
.get_required_value("profile_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("'profile_id' not set in payment intent")?;
+ let customer_id = payment_data.payment_intent.customer_id.as_ref();
let additional_pm_data = payment_data
.payment_method_data
@@ -871,7 +869,9 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
helpers::get_additional_payment_data(
payment_method_data,
&*state.store,
- profile_id,
+ state.superposition_service.as_ref(),
+ &dimensions.with_profile_id(profile_id.clone()),
+ customer_id,
payment_data.payment_method_token.as_ref(),
)
.await
diff --git a/crates/router/src/core/payments/operations/payment_update_intent.rs b/crates/router/src/core/payments/operations/payment_update_intent.rs
index 3d12f91d6a..d957b2dd11 100644
--- a/crates/router/src/core/payments/operations/payment_update_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_update_intent.rs
@@ -22,7 +22,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult},
payments::{
self, helpers,
@@ -334,7 +334,7 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsUpdateIn
mut payment_data: payments::PaymentIntentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentsUpdateIntentOperation<'b, F>,
payments::PaymentIntentData<F>,
diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rs
index 3ba5623437..337f4dcba7 100644
--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs
+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs
@@ -11,10 +11,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, PaymentData},
},
@@ -219,7 +216,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsUpdateMetadataRequest, Payme
_request: Option<payments::CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> errors::CustomResult<
(
@@ -283,7 +280,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsUpdateMetada
mut payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentUpdateMetadataOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rs
index 93fabe4ff5..9aea560916 100644
--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs
@@ -8,10 +8,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, PaymentData},
},
@@ -235,7 +232,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsExtendAuthorizationRequest,
_request: Option<payments::CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> errors::CustomResult<
(
@@ -299,7 +296,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsExtendAuthor
payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentExtendAuthorizationOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
index c98ab48e63..c87b853a5a 100644
--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
@@ -13,10 +13,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{
self, helpers, operations, CustomerDetails, IncrementalAuthorizationDetails,
@@ -219,7 +216,7 @@ impl<F: Clone + Sync>
mut payment_data: payments::PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(
PaymentIncrementalAuthorizationOperation<'b, F>,
payments::PaymentData<F>,
@@ -337,7 +334,7 @@ impl<F: Clone + Send + Sync>
request: Option<CustomerDetails>,
provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> CustomResult<
(
diff --git a/crates/router/src/core/payments/operations/proxy_payments_intent.rs b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
index 5fe51d48f3..c46c9dfb6e 100644
--- a/crates/router/src/core/payments/operations/proxy_payments_intent.rs
+++ b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
@@ -13,7 +13,7 @@ use router_env::{instrument, tracing};
use super::{Domain, GetTracker, Operation, PostUpdateTracker, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
operations::{self, ValidateStatusForOperation},
@@ -369,7 +369,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ProxyPaymentsReque
mut payment_data: PaymentConfirmData<F>,
_frm_suggestion: Option<api_models::enums::FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentConfirmData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs
index d22e48db24..7cea90e989 100644
--- a/crates/router/src/core/payments/operations/tax_calculation.rs
+++ b/crates/router/src/core/payments/operations/tax_calculation.rs
@@ -11,10 +11,7 @@ use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
- configs::dimension_state::{
- DimensionsWithProcessorAndProviderMerchantId,
- DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- },
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{self, helpers, operations, PaymentData, PaymentMethodChecker},
utils::{self as core_utils, create_encrypted_data},
@@ -228,7 +225,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsDynamicTaxCalculationRequest
_request: Option<payments::CustomerDetails>,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
_mandate_type: Option<MandateTransactionType>,
) -> errors::CustomResult<
(
@@ -395,7 +392,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsDynamicTaxCa
mut payment_data: PaymentData<F>,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- _dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<(PaymentSessionUpdateOperation<'b, F>, PaymentData<F>)>
where
F: 'b + Send,
diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs
index 6944bf0c9f..93b923dc7f 100644
--- a/crates/router/src/core/payments/retry.rs
+++ b/crates/router/src/core/payments/retry.rs
@@ -14,7 +14,7 @@ use crate::core::utils as core_utils;
use crate::{
consts,
core::{
- configs,
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payments::{
self, complete_connector_service,
@@ -51,6 +51,7 @@ pub async fn do_gsm_actions<'a, F, ApiRequest, FData, D>(
frm_suggestion: Option<storage_enums::FrmSuggestion>,
business_profile: &domain::Profile,
#[cfg(feature = "pm_modular")] feature_config: &core_utils::FeatureConfig,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
where
F: Clone + Send + Sync + std::fmt::Debug + 'static,
@@ -393,7 +394,7 @@ where
types::RouterData<F, FData, types::PaymentsResponseData>: Feature<F, FData>,
dyn api::Connector: services::api::ConnectorIntegration<F, FData, types::PaymentsResponseData>,
{
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -880,32 +881,20 @@ pub fn make_new_payment_attempt(
todo!()
}
-pub async fn get_merchant_config_for_gsm(
- db: &dyn StorageInterface,
- merchant_id: &common_utils::id_type::MerchantId,
-) -> bool {
- let config = db
- .find_config_by_key_unwrap_or(
- &merchant_id.get_should_call_gsm_key(),
- Some("false".to_string()),
- )
- .await;
- match config {
- Ok(conf) => conf.config == "true",
- Err(error) => {
- logger::error!(?error);
- false
- }
- }
-}
-
#[cfg(feature = "v1")]
pub async fn config_should_call_gsm(
- db: &dyn StorageInterface,
- merchant_id: &common_utils::id_type::MerchantId,
+ state: &app::SessionState,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
profile: &domain::Profile,
+ customer_id: Option<&common_utils::id_type::CustomerId>,
) -> bool {
- let merchant_config_gsm = get_merchant_config_for_gsm(db, merchant_id).await;
+ let merchant_config_gsm = dimensions
+ .get_should_call_gsm(
+ state.store.as_ref(),
+ state.superposition_service.as_ref(),
+ customer_id,
+ )
+ .await;
let profile_config_gsm = profile.is_auto_retries_enabled;
merchant_config_gsm || profile_config_gsm
}
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index 5b3d4e9538..8a59027ca2 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -61,6 +61,7 @@ use crate::core::routing::transformers::OpenRouterDecideGatewayRequestExt;
use crate::routes::app::SessionStateInfo;
use crate::{
core::{
+ configs::dimension_state,
errors, errors as oss_errors,
payments::{
routing::utils::DecisionEngineApiHandler, OperationSessionGetters,
@@ -1229,6 +1230,7 @@ pub async fn try_pre_routing_connectors<F, D>(
business_profile: &domain::Profile,
payment_data: &mut D,
routing_data: &mut RoutingData,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
) -> errors::RouterResult<Option<api::ConnectorCallType>>
where
F: Send + Clone,
@@ -1261,9 +1263,10 @@ where
#[cfg(feature = "retry")]
{
let should_do_retry = crate::core::payments::retry::config_should_call_gsm(
- &*state.store,
- processor.get_account().get_id(),
+ state,
+ dimensions,
business_profile,
+ payment_data.get_payment_intent().customer_id.as_ref(),
)
.await;
diff --git a/crates/router/src/core/payments/session_operation.rs b/crates/router/src/core/payments/session_operation.rs
index a134dccdd8..80b3a42fa3 100644
--- a/crates/router/src/core/payments/session_operation.rs
+++ b/crates/router/src/core/payments/session_operation.rs
@@ -22,7 +22,7 @@ use router_env::{env::Env, instrument, tracing};
use crate::{
core::{
- configs::dimension_state::{Dimensions, DimensionsWithProcessorAndProviderMerchantId},
+ configs::dimension_state,
errors::{self, utils::StorageErrorExt, RouterResult},
payments::{
self as payments_core, call_multiple_connectors_service,
@@ -131,7 +131,7 @@ where
{
let operation: BoxedOperation<'_, F, Req, D> = Box::new(operation);
- let dimensions = Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs
index b2fb4fd351..2b35bf5c41 100644
--- a/crates/router/src/core/payouts.rs
+++ b/crates/router/src/core/payouts.rs
@@ -51,7 +51,7 @@ use crate::types::domain::behaviour::Conversion;
use crate::types::PayoutActionData;
use crate::{
core::{
- configs::{self as configs, dimension_state::DimensionsWithProcessorAndProviderMerchantId},
+ configs::dimension_state,
errors::{
self, ConnectorErrorExt, CustomResult, RouterResponse, RouterResult, StorageErrorExt,
},
@@ -184,7 +184,7 @@ pub async fn make_connector_decision(
header_payload: HeaderPayload,
connector_call_type: api::ConnectorCallType,
payout_data: &mut PayoutData,
- dimensions: DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<()> {
match connector_call_type {
api::ConnectorCallType::PreDetermined(routing_data) => {
@@ -194,7 +194,7 @@ pub async fn make_connector_decision(
header_payload.clone(),
&routing_data.connector_data,
payout_data,
- &dimensions,
+ dimensions,
))
.await?;
@@ -213,7 +213,7 @@ pub async fn make_connector_decision(
routing_data.connector_data,
payout_data,
platform,
- &dimensions,
+ dimensions,
header_payload.clone(),
))
.await?;
@@ -233,7 +233,7 @@ pub async fn make_connector_decision(
header_payload.clone(),
&connector_data,
payout_data,
- &dimensions,
+ dimensions,
))
.await?;
@@ -253,7 +253,7 @@ pub async fn make_connector_decision(
connector_data.clone(),
payout_data,
platform,
- &dimensions,
+ dimensions,
header_payload.clone(),
))
.await?;
@@ -272,7 +272,7 @@ pub async fn make_connector_decision(
connector_data,
payout_data,
platform,
- &dimensions,
+ dimensions,
header_payload,
))
.await?;
@@ -296,7 +296,7 @@ pub async fn payouts_core(
payout_data: &mut PayoutData,
routing_algorithm: Option<serde_json::Value>,
eligible_connectors: Option<Vec<api_enums::PayoutConnectors>>,
- dimensions: DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<()> {
let payout_attempt = &payout_data.payout_attempt;
@@ -332,7 +332,7 @@ pub async fn payouts_core(
payout_data: &mut PayoutData,
routing_algorithm: Option<serde_json::Value>,
eligible_connectors: Option<Vec<api_enums::PayoutConnectors>>,
- dimensions: DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<()> {
todo!()
}
@@ -347,10 +347,10 @@ pub async fn payouts_create_core(
// Validate create request
let (payout_id, payout_method_data, profile_id, customer, payment_method) =
validator::validate_create_request(&state, &platform, &req).await?;
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
- .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
-
+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())
+ .with_profile_id(profile_id.clone());
// Create DB entries
let mut payout_data = payout_create_db_entries(
&state,
@@ -362,6 +362,7 @@ pub async fn payouts_create_core(
&state.locale,
customer.as_ref(),
payment_method.clone(),
+ &dimensions,
)
.await?;
@@ -397,7 +398,7 @@ pub async fn payouts_create_core(
&mut payout_data,
req.routing.clone(),
req.connector.clone(),
- dimensions,
+ &dimensions.without_profile_id(),
)
.await?
};
@@ -412,7 +413,7 @@ pub async fn payouts_confirm_core(
req: payouts::PayoutCreateRequest,
header_payload: HeaderPayload,
) -> RouterResponse<payouts::PayoutCreateResponse> {
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -467,7 +468,7 @@ pub async fn payouts_confirm_core(
&mut payout_data,
req.routing.clone(),
req.connector.clone(),
- dimensions,
+ &dimensions,
)
.await?;
@@ -480,7 +481,7 @@ pub async fn payouts_update_core(
req: payouts::PayoutCreateRequest,
header_payload: HeaderPayload,
) -> RouterResponse<payouts::PayoutCreateResponse> {
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -544,7 +545,7 @@ pub async fn payouts_update_core(
&mut payout_data,
req.routing.clone(),
req.connector.clone(),
- dimensions,
+ &dimensions,
)
.await?;
}
@@ -716,7 +717,7 @@ pub async fn payouts_fulfill_core(
let payout_attempt = payout_data.payout_attempt.to_owned();
let status = payout_attempt.status;
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
@@ -1124,7 +1125,7 @@ pub async fn call_connector_payout(
header_payload: HeaderPayload,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<()> {
let payout_attempt = &payout_data.payout_attempt.to_owned();
let payouts = &payout_data.payouts.to_owned();
@@ -2608,7 +2609,7 @@ pub async fn fulfill_payout(
header_payload: HeaderPayload,
connector_data: &api::ConnectorData,
payout_data: &mut PayoutData,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<()> {
// 1. Form Router data
let mut router_data =
@@ -2912,11 +2913,12 @@ pub async fn payout_create_db_entries(
_platform: &domain::Platform,
_req: &payouts::PayoutCreateRequest,
_payout_id: &str,
- _profile_id: &str,
+ _profile_id: &id_type::ProfileId,
_stored_payout_method_data: Option<&payouts::PayoutMethodData>,
_locale: &str,
_customer: Option<&domain::Customer>,
_payment_method: Option<PaymentMethod>,
+ _dimesnions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
) -> RouterResult<PayoutData> {
todo!()
}
@@ -2934,6 +2936,7 @@ pub async fn payout_create_db_entries(
locale: &str,
customer: Option<&domain::Customer>,
payment_method: Option<PaymentMethod>,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
) -> RouterResult<PayoutData> {
let db = &*state.store;
let merchant_id = platform.get_processor().get_account().get_id();
@@ -3077,13 +3080,19 @@ pub async fn payout_create_db_entries(
// Make payout_attempt entry
let payout_attempt_id = utils::get_payout_attempt_id(payout_id.get_string_repr(), 1);
+ let customer_id_for_pm_data = customer_id.clone();
let additional_pm_data_value = req
.payout_method_data
.clone()
.or(stored_payout_method_data.cloned())
.async_and_then(|payout_method_data| async move {
- helpers::get_additional_payout_data(&payout_method_data, &*state.store, profile_id)
- .await
+ helpers::get_additional_payout_data(
+ &payout_method_data,
+ state,
+ dimensions,
+ customer_id_for_pm_data.as_ref(),
+ )
+ .await
})
.await
// If no payout method data in request but we have a stored payment method, populate from it
@@ -3106,7 +3115,7 @@ pub async fn payout_create_db_entries(
business_label: req.business_label.to_owned(),
payout_token: req.payout_token.to_owned(),
profile_id: profile_id.to_owned(),
- customer_id,
+ customer_id: customer_id.clone(),
address_id,
connector: None,
connector_payout_id: None,
@@ -3181,6 +3190,9 @@ pub async fn make_payout_data(
) -> RouterResult<PayoutData> {
let db = &*state.store;
let merchant_id = platform.get_processor().get_account().get_id();
+ let dimensions = dimension_state::Dimensions::new()
+ .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
let payout_id = match req {
payouts::PayoutRequest::PayoutActionRequest(r) => r.payout_id.clone(),
payouts::PayoutRequest::PayoutCreateRequest(r) => {
@@ -3296,10 +3308,15 @@ pub async fn make_payout_data(
payouts::PayoutRequest::PayoutRetrieveRequest(_) => None,
};
+ let dimensions = dimensions.with_profile_id(profile_id.clone());
if let Some(payout_method_data) = payout_method_data_req.clone() {
- let additional_payout_method_data =
- helpers::get_additional_payout_data(&payout_method_data, &*state.store, &profile_id)
- .await;
+ let additional_payout_method_data = helpers::get_additional_payout_data(
+ &payout_method_data,
+ state,
+ &dimensions,
+ customer_id,
+ )
+ .await;
let update_additional_payout_method_data =
storage::PayoutAttemptUpdate::AdditionalPayoutMethodDataUpdate {
diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rs
index 363370a23f..4ac099adc5 100644
--- a/crates/router/src/core/payouts/helpers.rs
+++ b/crates/router/src/core/payouts/helpers.rs
@@ -24,6 +24,7 @@ use crate::core::payments::route_connector_v1_for_payouts;
use crate::{
consts,
core::{
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payment_methods::{
cards,
@@ -1526,23 +1527,27 @@ pub async fn get_translated_unified_code_and_message(
pub async fn get_additional_payout_data(
pm_data: &api::PayoutMethodData,
- db: &dyn StorageInterface,
- profile_id: &id_type::ProfileId,
+ state: &SessionState,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ customer_id: Option<&id_type::CustomerId>,
) -> Option<payout_additional::AdditionalPayoutMethodData> {
+ let db = &*state.store;
match pm_data {
api::PayoutMethodData::Card(card_data) => {
let card_isin = Some(card_data.card_number.get_card_isin());
- let enable_extended_bin =db
- .find_config_by_key_unwrap_or(
- format!("{}_enable_extended_card_bin", profile_id.get_string_repr()).as_str(),
- Some("false".to_string()))
- .await.map_err(|err| services::logger::error!(message="Failed to fetch the config", extended_card_bin_error=?err)).ok();
-
- let card_extended_bin = match enable_extended_bin {
- Some(config) if config.config == "true" => {
- Some(card_data.card_number.get_extended_card_bin())
- }
- _ => None,
+
+ let enable_extended_bin = dimensions
+ .get_enable_extended_card_bin(
+ state.store.as_ref(),
+ state.superposition_service.as_ref(),
+ customer_id,
+ )
+ .await;
+
+ let card_extended_bin = if enable_extended_bin {
+ Some(card_data.card_number.get_extended_card_bin())
+ } else {
+ None
};
let last4 = Some(card_data.card_number.get_last4());
diff --git a/crates/router/src/core/payouts/retry.rs b/crates/router/src/core/payouts/retry.rs
index a13f3f640f..12083e974e 100644
--- a/crates/router/src/core/payouts/retry.rs
+++ b/crates/router/src/core/payouts/retry.rs
@@ -12,7 +12,7 @@ use super::{call_connector_payout, PayoutData};
use crate::{
consts,
core::{
- configs::dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ configs::dimension_state,
errors::{self, RouterResult, StorageErrorExt},
payouts,
},
@@ -30,7 +30,7 @@ pub async fn do_gsm_multiple_connector_actions(
original_connector_data: api::ConnectorData,
payout_data: &mut PayoutData,
platform: &domain::Platform,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
header_payload: HeaderPayload,
) -> RouterResult<()> {
let mut retries = None;
@@ -91,7 +91,7 @@ pub async fn do_gsm_single_connector_actions(
original_connector_data: api::ConnectorData,
payout_data: &mut PayoutData,
platform: &domain::Platform,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
header_payload: HeaderPayload,
) -> RouterResult<()> {
let mut retries = None;
@@ -215,7 +215,7 @@ pub async fn do_retry(
platform: &domain::Platform,
header_payload: HeaderPayload,
payout_data: &mut PayoutData,
- dimensions: &DimensionsWithProcessorAndProviderMerchantId,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> RouterResult<()> {
metrics::AUTO_RETRY_PAYOUT_COUNT.add(1, &[]);
diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rs
index 0538d0dcd1..1f2a64a36c 100644
--- a/crates/router/src/core/payouts/validator.rs
+++ b/crates/router/src/core/payouts/validator.rs
@@ -61,7 +61,7 @@ pub async fn validate_create_request(
) -> RouterResult<(
String,
Option<payouts::PayoutMethodData>,
- String,
+ id_type::ProfileId,
Option<domain::Customer>,
Option<PaymentMethod>,
)> {
diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rs
index cc9371304b..50880baf4b 100644
--- a/crates/router/src/core/unified_authentication_service.rs
+++ b/crates/router/src/core/unified_authentication_service.rs
@@ -55,6 +55,7 @@ use crate::{
consts,
core::{
authentication::utils as auth_utils,
+ configs::dimension_state,
errors::utils::StorageErrorExt,
metrics, payment_methods,
payments::{helpers, validate_customer_details_for_click_to_pay},
@@ -1433,6 +1434,8 @@ trait EligibilityCheck {
&self,
state: &SessionState,
platform: &domain::Platform,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ authentication_id: &common_utils::id_type::AuthenticationId,
) -> CustomResult<bool, ApiErrorResponse>;
// Run the actual check and return the SDK Next Action if applicable
@@ -1478,33 +1481,17 @@ impl EligibilityCheck for StoreEligibilityCheckData {
async fn should_run(
&self,
state: &SessionState,
- platform: &domain::Platform,
+ _platform: &domain::Platform,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,
+ authentication_id: &common_utils::id_type::AuthenticationId,
) -> CustomResult<bool, ApiErrorResponse> {
- let merchant_id = platform.get_processor().get_account().get_id();
- let should_store_eligibility_check_data_key =
- merchant_id.get_should_store_eligibility_check_data_for_authentication();
- let should_store_eligibility_check_data = state
- .store
- .find_config_by_key_unwrap_or(
- &should_store_eligibility_check_data_key,
- Some("false".to_string()),
+ Ok(dimensions
+ .get_should_store_eligibility_check_data_for_authentication(
+ state.store.as_ref(),
+ state.superposition_service.as_ref(),
+ Some(authentication_id),
)
- .await;
-
- Ok(match should_store_eligibility_check_data {
- Ok(config) => serde_json::from_str(&config.config).unwrap_or(false),
-
- // If it is not present in db we are defaulting it to false
- Err(inner) => {
- if !inner.current_context().is_db_not_found() {
- router_env::logger::error!(
- "Error fetching should store eligibility check data enabled config {:?}",
- inner
- );
- }
- false
- }
- })
+ .await)
}
async fn execute_check(
@@ -1553,6 +1540,7 @@ pub struct EligibilityHandler {
state: SessionState,
platform: domain::Platform,
authentication_eligibility_check_request: AuthenticationEligibilityCheckRequest,
+ dimensions: dimension_state::DimensionsWithProcessorAndProviderMerchantId,
}
#[cfg(feature = "v1")]
@@ -1561,11 +1549,13 @@ impl EligibilityHandler {
state: SessionState,
platform: domain::Platform,
authentication_eligibility_check_request: AuthenticationEligibilityCheckRequest,
+ dimensions: dimension_state::DimensionsWithProcessorAndProviderMerchantId,
) -> Self {
Self {
state,
platform,
authentication_eligibility_check_request,
+ dimensions,
}
}
@@ -1573,7 +1563,16 @@ impl EligibilityHandler {
&self,
check: C,
) -> CustomResult<Option<AuthenticationSdkNextAction>, ApiErrorResponse> {
- let should_run = check.should_run(&self.state, &self.platform).await?;
+ let should_run = check
+ .should_run(
+ &self.state,
+ &self.platform,
+ &self.dimensions,
+ &self
+ .authentication_eligibility_check_request
+ .authentication_id,
+ )
+ .await?;
Ok(match should_run {
true => check
.execute_check(
@@ -1600,6 +1599,10 @@ pub async fn authentication_eligibility_check_core(
let merchant_account = platform.get_processor().get_account();
let merchant_id = merchant_account.get_id();
let key_manager_state = (&state).into();
+ let dimensions = dimension_state::Dimensions::new()
+ .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
+
let authentication = db
.find_authentication_by_merchant_id_authentication_id(
merchant_id,
@@ -1621,7 +1624,7 @@ pub async fn authentication_eligibility_check_core(
)
})
.transpose()?;
- let eligibility_handler = EligibilityHandler::new(state, platform, req);
+ let eligibility_handler = EligibilityHandler::new(state, platform, req, dimensions);
// Run the checks in sequence, short-circuiting on the first that returns a next action
let sdk_next_action = eligibility_handler
.run_check(StoreEligibilityCheckData)
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index e4638b6fd2..c76150e2b9 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -40,6 +40,7 @@ use crate::{
consts,
core::{
api_locking,
+ configs::dimension_state,
errors::{self, ConnectorErrorExt, CustomResult, RouterResponse, StorageErrorExt},
metrics, payment_methods,
payment_methods::cards,
@@ -228,6 +229,10 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
platform.get_processor().get_account().get_id().clone()
)),
);
+ let dimensions = dimension_state::Dimensions::new()
+ .with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())
+ .with_organization_id(platform.get_processor().get_account().get_org_id().clone());
let request_details = IncomingWebhookRequestDetails {
method: req.method().clone(),
uri: req.uri().clone(),
@@ -242,7 +247,8 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(
// If No, then it will return Direct
// Direct Signifies its not a authentication connector
let three_ds_execution_path =
- fetch_three_ds_execution_path(&platform, connector_name_or_mca_id, &state).await?;
+ fetch_three_ds_execution_path(&platform, connector_name_or_mca_id, &state, &dimensions)
+ .await?;
// Decodes webhook body based on execution path, and returns connector Integration, connector_name, webhook_processing_result and merchant_connector_account back to the flow without disturbing the current flow
let (connector, connector_name, webhook_processing_result, merchant_connector_account) =
@@ -504,6 +510,7 @@ async fn fetch_three_ds_execution_path(
platform: &domain::Platform,
connector_name_or_mca_id: &str,
state: &SessionState,
+ _dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndOrgId,
) -> errors::RouterResult<ThreeDsProcessingMode> {
let (merchant_connector_account, connector, connector_name) =
fetch_optional_mca_and_connector(state, platform, connector_name_or_mca_id).await?;
diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs
index 24f9d7e0f8..0ceeb2fd12 100644
--- a/crates/router/src/routes/payments.rs
+++ b/crates/router/src/routes/payments.rs
@@ -21,7 +21,7 @@ use crate::routes::payments::payments::operations::payment_recurrence::PaymentRe
use crate::{
self as app,
core::{
- configs::dimension_state::Dimensions,
+ configs::dimension_state,
errors::{self, http_not_implemented},
payments::{self, transformers::ToResponse, OperationSessionGetters, PaymentRedirectFlow},
},
@@ -2373,7 +2373,7 @@ where
.flat_map(|c| c.foreign_try_into())
.collect()
});
- let dimensions = Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
match req.payment_type.unwrap_or_default() {
@@ -2400,7 +2400,7 @@ where
auth_flow,
eligible_routable_connectors.clone(),
header_payload.clone(),
- dimensions.clone(),
+ &dimensions,
))
.await?;
@@ -2442,7 +2442,7 @@ where
auth_flow,
eligible_routable_connectors,
header_payload.clone(),
- dimensions,
+ &dimensions,
))
.await?;
let total_ext_latency = match (external_latency, ext_latency) {
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 85ca23b446..05b82d4194 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -38,7 +38,7 @@ use crate::configs::Settings;
#[cfg(feature = "olap")]
use crate::consts;
#[cfg(feature = "v1")]
-use crate::core::configs::dimension_state::Dimensions;
+use crate::core::configs::dimension_state;
#[cfg(feature = "olap")]
use crate::core::errors::UserResult;
#[cfg(all(feature = "partial-auth", feature = "v1"))]
@@ -3440,7 +3440,7 @@ where
let processor_merchant_id = platform.get_processor().get_account().get_id();
// Check if client session validation is enabled
- let dimensions = Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id());
diff --git a/crates/router/src/workflows/attach_payout_account_workflow.rs b/crates/router/src/workflows/attach_payout_account_workflow.rs
index 4e50fa44eb..457b027666 100644
--- a/crates/router/src/workflows/attach_payout_account_workflow.rs
+++ b/crates/router/src/workflows/attach_payout_account_workflow.rs
@@ -9,7 +9,7 @@ use scheduler::{
};
use crate::{
- core::{configs, payouts},
+ core::{configs::dimension_state, payouts},
errors as core_errors,
routes::SessionState,
types::{api, domain, storage},
@@ -56,7 +56,7 @@ impl ProcessTrackerWorkflow<SessionState> for AttachPayoutAccountWorkflow {
key_store,
None,
);
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id());
let mut payout_data = Box::pin(payouts::make_payout_data(
@@ -75,7 +75,7 @@ impl ProcessTrackerWorkflow<SessionState> for AttachPayoutAccountWorkflow {
&mut payout_data,
None,
None,
- dimensions,
+ &dimensions,
)
.await?;
diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rs
index d08b0b9d2b..8f73187c11 100644
--- a/crates/router/src/workflows/payment_sync.rs
+++ b/crates/router/src/workflows/payment_sync.rs
@@ -14,7 +14,7 @@ use crate::workflows::revenue_recovery::update_token_expiry_based_on_schedule_ti
use crate::{
consts,
core::{
- configs,
+ configs::dimension_state,
errors::StorageErrorExt,
payments::{self as payment_flows, operations},
},
@@ -80,7 +80,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {
key_store.clone(),
None,
);
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());
// TODO: Add support for ReqState in PT flows
@@ -102,7 +102,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {
services::AuthFlow::Client,
None,
hyperswitch_domain_models::payments::HeaderPayload::default(),
- dimensions,
+ &dimensions,
))
.await?;
diff --git a/crates/router/src/workflows/payout_sync.rs b/crates/router/src/workflows/payout_sync.rs
index 13e728e56c..1aa7b4ed55 100644
--- a/crates/router/src/workflows/payout_sync.rs
+++ b/crates/router/src/workflows/payout_sync.rs
@@ -12,12 +12,7 @@ use scheduler::{
};
use crate::{
- core::{
- configs::{
- self, dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndConnector,
- },
- payouts, webhooks,
- },
+ core::{configs::dimension_state, payouts, webhooks},
errors as core_errors,
routes::SessionState,
types::{api, domain, storage},
@@ -109,7 +104,7 @@ impl ProcessTrackerWorkflow<SessionState> for PayoutSyncWorkFlow {
)
.await?;
- let dimensions = configs::dimension_state::Dimensions::new()
+ let dimensions = dimension_state::Dimensions::new()
.with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())
.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id())
.with_connector(connector_data.connector_name);
@@ -151,7 +146,7 @@ impl PayoutSyncWorkFlow {
state: &SessionState,
payout_data: &payouts::PayoutData,
application_source: common_enums::ApplicationSource,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndConnector,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndConnector,
) -> common_utils::errors::CustomResult<(), core_errors::ApiErrorResponse> {
let db = &*state.store;
let scheduled_time = Self::get_payout_sync_process_schedule_time(
@@ -224,12 +219,12 @@ impl PayoutSyncWorkFlow {
state: &SessionState,
payout_id: common_utils::id_type::PayoutId,
retry_count: i32,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndConnector,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndConnector,
) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> {
let value = dimensions
.get_payout_tracker_mapping(
state.store.as_ref(),
- &state.superposition_service,
+ state.superposition_service.as_ref(),
Some(&payout_id),
)
.await;
@@ -299,7 +294,7 @@ impl PayoutSyncWorkFlow {
state: &SessionState,
payout_id: common_utils::id_type::PayoutId,
pt: storage::ProcessTracker,
- dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndConnector,
+ dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndConnector,
) -> Result<(), errors::ProcessTrackerError> {
let db = &*state.store;
let schedule_time: Option<time::PrimitiveDateTime> =