mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 13:30:39 +08:00
chore: refined the code
This commit is contained in:
@ -5236,6 +5236,7 @@ where
|
||||
merchant_connector_account_type_details.clone(),
|
||||
external_vault_merchant_connector_account_type_details.clone(),
|
||||
merchant_context,
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@ -234,6 +234,7 @@ pub trait Feature<F, T> {
|
||||
_merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
_external_vault_merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
_merchant_context: &domain::MerchantContext,
|
||||
_shadow_mode: bool,
|
||||
) -> RouterResult<()>
|
||||
where
|
||||
F: Clone,
|
||||
|
||||
@ -529,7 +529,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
|
||||
#[cfg(feature = "v2")]
|
||||
merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
merchant_context: &domain::MerchantContext,
|
||||
ucs_shadow_mode: bool,
|
||||
shadow_mode: bool,
|
||||
) -> RouterResult<()> {
|
||||
if self.request.mandate_id.is_some() {
|
||||
Box::pin(call_unified_connector_service_repeat_payment(
|
||||
@ -539,7 +539,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
|
||||
lineage_ids,
|
||||
merchant_connector_account,
|
||||
merchant_context,
|
||||
ucs_shadow_mode,
|
||||
shadow_mode,
|
||||
))
|
||||
.await
|
||||
} else {
|
||||
@ -550,7 +550,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
|
||||
lineage_ids,
|
||||
merchant_connector_account,
|
||||
merchant_context,
|
||||
ucs_shadow_mode,
|
||||
shadow_mode,
|
||||
))
|
||||
.await
|
||||
}
|
||||
@ -853,7 +853,7 @@ async fn call_unified_connector_service_authorize(
|
||||
#[cfg(feature = "v1")] merchant_connector_account: helpers::MerchantConnectorAccountType,
|
||||
#[cfg(feature = "v2")] merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
merchant_context: &domain::MerchantContext,
|
||||
ucs_shadow_mode: bool,
|
||||
shadow_mode: bool,
|
||||
) -> RouterResult<()> {
|
||||
let client = state
|
||||
.grpc_client
|
||||
@ -881,7 +881,7 @@ async fn call_unified_connector_service_authorize(
|
||||
.flatten()
|
||||
.map(ucs_types::UcsReferenceId::Payment);
|
||||
let headers_builder = state
|
||||
.get_grpc_headers_ucs(ucs_shadow_mode)
|
||||
.get_grpc_headers_ucs(shadow_mode)
|
||||
.external_vault_proxy_metadata(None)
|
||||
.merchant_reference_id(merchant_order_reference_id)
|
||||
.lineage_ids(lineage_ids);
|
||||
@ -943,7 +943,7 @@ async fn call_unified_connector_service_repeat_payment(
|
||||
#[cfg(feature = "v1")] merchant_connector_account: helpers::MerchantConnectorAccountType,
|
||||
#[cfg(feature = "v2")] merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
merchant_context: &domain::MerchantContext,
|
||||
ucs_shadow_mode: bool,
|
||||
shadow_mode: bool,
|
||||
) -> RouterResult<()> {
|
||||
let client = state
|
||||
.grpc_client
|
||||
@ -971,7 +971,7 @@ async fn call_unified_connector_service_repeat_payment(
|
||||
.flatten()
|
||||
.map(ucs_types::UcsReferenceId::Payment);
|
||||
let headers_builder = state
|
||||
.get_grpc_headers_ucs(ucs_shadow_mode)
|
||||
.get_grpc_headers_ucs(shadow_mode)
|
||||
.external_vault_proxy_metadata(None)
|
||||
.merchant_reference_id(merchant_order_reference_id)
|
||||
.lineage_ids(lineage_ids);
|
||||
|
||||
@ -374,6 +374,7 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
|
||||
merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
external_vault_merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
merchant_context: &domain::MerchantContext,
|
||||
shadow_mode: bool,
|
||||
) -> RouterResult<()> {
|
||||
let client = state
|
||||
.grpc_client
|
||||
@ -411,7 +412,7 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
|
||||
.flatten()
|
||||
.map(ucs_types::UcsReferenceId::Payment);
|
||||
let headers_builder = state
|
||||
.get_grpc_headers_ucs(false)
|
||||
.get_grpc_headers_ucs(shadow_mode)
|
||||
.external_vault_proxy_metadata(Some(external_vault_proxy_metadata))
|
||||
.merchant_reference_id(merchant_order_reference_id)
|
||||
.lineage_ids(lineage_ids);
|
||||
|
||||
@ -2135,27 +2135,6 @@ pub async fn should_execute_based_on_rollout(
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn should_execute_shadow_ucs(
|
||||
state: &SessionState,
|
||||
config_key: &str,
|
||||
) -> RouterResult<bool> {
|
||||
let db = state.store.as_ref();
|
||||
|
||||
match db.find_config_by_key(config_key).await {
|
||||
Ok(config) => match config.config.parse::<bool>() {
|
||||
Ok(is_enabled) => Ok(is_enabled),
|
||||
Err(err) => {
|
||||
logger::error!(error = ?err, "Failed to parse shadow UCS enabled config");
|
||||
Ok(false)
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
logger::error!(error = ?err, "Failed to fetch shadow UCS enabled config from DB");
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn determine_standard_vault_action(
|
||||
is_network_tokenization_enabled: bool,
|
||||
mandate_id: Option<api_models::payments::MandateIds>,
|
||||
|
||||
@ -46,8 +46,7 @@ use crate::{
|
||||
errors::{self, RouterResult},
|
||||
payments::{
|
||||
helpers::{
|
||||
is_ucs_enabled, should_execute_based_on_rollout, should_execute_shadow_ucs,
|
||||
MerchantConnectorAccountType,
|
||||
is_ucs_enabled, should_execute_based_on_rollout, MerchantConnectorAccountType,
|
||||
},
|
||||
OperationSessionGetters, OperationSessionSetters,
|
||||
},
|
||||
@ -142,7 +141,7 @@ where
|
||||
let should_execute = should_execute_based_on_rollout(state, &config_key).await?;
|
||||
|
||||
let should_execute_shadow_ucs =
|
||||
should_execute_shadow_ucs(state, &shadow_ucs_config_key).await?;
|
||||
should_execute_based_on_rollout(state, &shadow_ucs_config_key).await?;
|
||||
|
||||
// Apply stickiness logic if payment_data is available
|
||||
if let Some(payment_data) = payment_data {
|
||||
|
||||
Reference in New Issue
Block a user