mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
refactor(core): Revert "filter default routing config response based on connector type" (#7556)
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
pub mod helpers;
|
pub mod helpers;
|
||||||
pub mod transformers;
|
pub mod transformers;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::HashSet;
|
||||||
|
|
||||||
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
|
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
|
||||||
use api_models::routing::DynamicRoutingAlgoAccessor;
|
use api_models::routing::DynamicRoutingAlgoAccessor;
|
||||||
@ -11,7 +11,6 @@ use api_models::{
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
|
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
|
||||||
use common_utils::ext_traits::AsyncExt;
|
use common_utils::ext_traits::AsyncExt;
|
||||||
use common_utils::id_type::MerchantConnectorAccountId;
|
|
||||||
use diesel_models::routing_algorithm::RoutingAlgorithm;
|
use diesel_models::routing_algorithm::RoutingAlgorithm;
|
||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
|
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
|
||||||
@ -19,9 +18,7 @@ use external_services::grpc_client::dynamic_routing::{
|
|||||||
contract_routing_client::ContractBasedDynamicRouting,
|
contract_routing_client::ContractBasedDynamicRouting,
|
||||||
success_rate_client::SuccessBasedDynamicRouting,
|
success_rate_client::SuccessBasedDynamicRouting,
|
||||||
};
|
};
|
||||||
use hyperswitch_domain_models::{
|
use hyperswitch_domain_models::{mandates, payment_address};
|
||||||
mandates, merchant_connector_account::MerchantConnectorAccount, payment_address,
|
|
||||||
};
|
|
||||||
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
|
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
|
||||||
use router_env::logger;
|
use router_env::logger;
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
@ -979,66 +976,16 @@ pub async fn retrieve_default_routing_config(
|
|||||||
) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> {
|
) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> {
|
||||||
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG.add(1, &[]);
|
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG.add(1, &[]);
|
||||||
let db = state.store.as_ref();
|
let db = state.store.as_ref();
|
||||||
let key_manager_state = &(&state).into();
|
|
||||||
let key_store = state
|
|
||||||
.store
|
|
||||||
.get_merchant_key_store_by_merchant_id(
|
|
||||||
key_manager_state,
|
|
||||||
merchant_account.get_id(),
|
|
||||||
&state.store.get_master_key().to_vec().into(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
|
|
||||||
|
|
||||||
let id = profile_id
|
let id = profile_id
|
||||||
.map(|profile_id| profile_id.get_string_repr().to_owned())
|
.map(|profile_id| profile_id.get_string_repr().to_owned())
|
||||||
.unwrap_or_else(|| merchant_account.get_id().get_string_repr().to_string());
|
.unwrap_or_else(|| merchant_account.get_id().get_string_repr().to_string());
|
||||||
|
|
||||||
let mut merchant_connector_details: HashMap<
|
helpers::get_merchant_default_config(db, &id, transaction_type)
|
||||||
MerchantConnectorAccountId,
|
|
||||||
MerchantConnectorAccount,
|
|
||||||
> = HashMap::new();
|
|
||||||
state
|
|
||||||
.store
|
|
||||||
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
|
|
||||||
key_manager_state,
|
|
||||||
merchant_account.get_id(),
|
|
||||||
false,
|
|
||||||
&key_store,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError {
|
.map(|conn_choice| {
|
||||||
message: format!(
|
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG_SUCCESS_RESPONSE.add(1, &[]);
|
||||||
"Unable to find merchant_connector_accounts associate with merchant_id: {}",
|
service_api::ApplicationResponse::Json(conn_choice)
|
||||||
merchant_account.get_id().get_string_repr()
|
|
||||||
),
|
|
||||||
})?
|
|
||||||
.iter()
|
|
||||||
.for_each(|mca| {
|
|
||||||
merchant_connector_details.insert(mca.get_id(), mca.clone());
|
|
||||||
});
|
|
||||||
|
|
||||||
let connectors = helpers::get_merchant_default_config(db, &id, transaction_type)
|
|
||||||
.await?
|
|
||||||
.iter()
|
|
||||||
.filter(|connector| {
|
|
||||||
connector
|
|
||||||
.merchant_connector_id
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|mca_id| {
|
|
||||||
merchant_connector_details.get(mca_id).is_some_and(|mca| {
|
|
||||||
(*transaction_type == common_enums::TransactionType::Payment
|
|
||||||
&& mca.connector_type == common_enums::ConnectorType::PaymentProcessor)
|
|
||||||
|| (*transaction_type == common_enums::TransactionType::Payout
|
|
||||||
&& mca.connector_type
|
|
||||||
== common_enums::ConnectorType::PayoutProcessor)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.cloned()
|
|
||||||
.collect::<Vec<routing_types::RoutableConnectorChoice>>();
|
|
||||||
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG_SUCCESS_RESPONSE.add(1, &[]);
|
|
||||||
Ok(service_api::ApplicationResponse::Json(connectors))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "v2")]
|
#[cfg(feature = "v2")]
|
||||||
|
|||||||
Reference in New Issue
Block a user