mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(router): add three_ds_decision_rule support in routing apis (#8132)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7a44626251
commit
9bac41b208
@ -145,7 +145,7 @@ pub async fn retrieve_merchant_routing_dictionary(
|
||||
merchant_context: domain::MerchantContext,
|
||||
profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,
|
||||
query_params: RoutingRetrieveQuery,
|
||||
transaction_type: &enums::TransactionType,
|
||||
transaction_type: enums::TransactionType,
|
||||
) -> RouterResponse<routing_types::RoutingKind> {
|
||||
metrics::ROUTING_MERCHANT_DICTIONARY_RETRIEVE.add(1, &[]);
|
||||
|
||||
@ -153,7 +153,7 @@ pub async fn retrieve_merchant_routing_dictionary(
|
||||
.store
|
||||
.list_routing_algorithm_metadata_by_merchant_id_transaction_type(
|
||||
merchant_context.get_merchant_account().get_id(),
|
||||
transaction_type,
|
||||
&transaction_type,
|
||||
i64::from(query_params.limit.unwrap_or_default()),
|
||||
i64::from(query_params.offset.unwrap_or_default()),
|
||||
)
|
||||
@ -328,14 +328,16 @@ pub async fn create_routing_algorithm_under_profile(
|
||||
|
||||
core_utils::validate_profile_id_from_auth_layer(authentication_profile_id, &business_profile)?;
|
||||
|
||||
helpers::validate_connectors_in_routing_config(
|
||||
&state,
|
||||
merchant_context.get_merchant_key_store(),
|
||||
merchant_context.get_merchant_account().get_id(),
|
||||
&profile_id,
|
||||
&algorithm,
|
||||
)
|
||||
.await?;
|
||||
if algorithm.should_validate_connectors_in_routing_config() {
|
||||
helpers::validate_connectors_in_routing_config(
|
||||
&state,
|
||||
merchant_context.get_merchant_key_store(),
|
||||
merchant_context.get_merchant_account().get_id(),
|
||||
&profile_id,
|
||||
&algorithm,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let mut decision_engine_routing_id: Option<String> = None;
|
||||
|
||||
@ -471,7 +473,7 @@ pub async fn link_routing_config(
|
||||
merchant_context: domain::MerchantContext,
|
||||
authentication_profile_id: Option<common_utils::id_type::ProfileId>,
|
||||
algorithm_id: common_utils::id_type::RoutingId,
|
||||
transaction_type: &enums::TransactionType,
|
||||
transaction_type: enums::TransactionType,
|
||||
) -> RouterResponse<routing_types::RoutingDictionaryRecord> {
|
||||
metrics::ROUTING_LINK_CONFIG.add(1, &[]);
|
||||
let db = state.store.as_ref();
|
||||
@ -641,7 +643,8 @@ pub async fn link_routing_config(
|
||||
diesel_models::enums::RoutingAlgorithmKind::Single
|
||||
| diesel_models::enums::RoutingAlgorithmKind::Priority
|
||||
| diesel_models::enums::RoutingAlgorithmKind::Advanced
|
||||
| diesel_models::enums::RoutingAlgorithmKind::VolumeSplit => {
|
||||
| diesel_models::enums::RoutingAlgorithmKind::VolumeSplit
|
||||
| diesel_models::enums::RoutingAlgorithmKind::ThreeDsDecisionRule => {
|
||||
let mut routing_ref: routing_types::RoutingAlgorithmRef = business_profile
|
||||
.routing_algorithm
|
||||
.clone()
|
||||
@ -653,7 +656,7 @@ pub async fn link_routing_config(
|
||||
)?
|
||||
.unwrap_or_default();
|
||||
|
||||
utils::when(routing_algorithm.algorithm_for != *transaction_type, || {
|
||||
utils::when(routing_algorithm.algorithm_for != transaction_type, || {
|
||||
Err(errors::ApiErrorResponse::PreconditionFailed {
|
||||
message: format!(
|
||||
"Cannot use {}'s routing algorithm for {} operation",
|
||||
@ -677,7 +680,7 @@ pub async fn link_routing_config(
|
||||
merchant_context.get_merchant_key_store(),
|
||||
business_profile.clone(),
|
||||
routing_ref,
|
||||
transaction_type,
|
||||
&transaction_type,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
@ -815,6 +818,8 @@ pub async fn unlink_routing_config_under_profile(
|
||||
enums::TransactionType::Payment => business_profile.routing_algorithm_id.clone(),
|
||||
#[cfg(feature = "payouts")]
|
||||
enums::TransactionType::Payout => business_profile.payout_routing_algorithm_id.clone(),
|
||||
// TODO: Handle ThreeDsAuthentication Transaction Type for Three DS Decision Rule Algorithm configuration
|
||||
enums::TransactionType::ThreeDsAuthentication => todo!(),
|
||||
};
|
||||
|
||||
if let Some(algorithm_id) = routing_algo_id {
|
||||
@ -849,7 +854,7 @@ pub async fn unlink_routing_config(
|
||||
merchant_context: domain::MerchantContext,
|
||||
request: routing_types::RoutingConfigRequest,
|
||||
authentication_profile_id: Option<common_utils::id_type::ProfileId>,
|
||||
transaction_type: &enums::TransactionType,
|
||||
transaction_type: enums::TransactionType,
|
||||
) -> RouterResponse<routing_types::RoutingDictionaryRecord> {
|
||||
metrics::ROUTING_UNLINK_CONFIG.add(1, &[]);
|
||||
|
||||
@ -883,6 +888,9 @@ pub async fn unlink_routing_config(
|
||||
enums::TransactionType::Payment => business_profile.routing_algorithm.clone(),
|
||||
#[cfg(feature = "payouts")]
|
||||
enums::TransactionType::Payout => business_profile.payout_routing_algorithm.clone(),
|
||||
enums::TransactionType::ThreeDsAuthentication => {
|
||||
business_profile.three_ds_decision_rule_algorithm.clone()
|
||||
}
|
||||
}
|
||||
.map(|val| val.parse_value("RoutingAlgorithmRef"))
|
||||
.transpose()
|
||||
@ -916,7 +924,7 @@ pub async fn unlink_routing_config(
|
||||
merchant_context.get_merchant_key_store(),
|
||||
business_profile,
|
||||
routing_algorithm,
|
||||
transaction_type,
|
||||
&transaction_type,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@ -1171,7 +1179,7 @@ pub async fn retrieve_linked_routing_config(
|
||||
merchant_context: domain::MerchantContext,
|
||||
authentication_profile_id: Option<common_utils::id_type::ProfileId>,
|
||||
query_params: routing_types::RoutingRetrieveLinkQuery,
|
||||
transaction_type: &enums::TransactionType,
|
||||
transaction_type: enums::TransactionType,
|
||||
) -> RouterResponse<routing_types::LinkedRoutingConfigRetrieveResponse> {
|
||||
metrics::ROUTING_RETRIEVE_LINK_CONFIG.add(1, &[]);
|
||||
|
||||
@ -1216,6 +1224,9 @@ pub async fn retrieve_linked_routing_config(
|
||||
enums::TransactionType::Payment => &business_profile.routing_algorithm,
|
||||
#[cfg(feature = "payouts")]
|
||||
enums::TransactionType::Payout => &business_profile.payout_routing_algorithm,
|
||||
enums::TransactionType::ThreeDsAuthentication => {
|
||||
&business_profile.three_ds_decision_rule_algorithm
|
||||
}
|
||||
}
|
||||
.clone()
|
||||
.map(|val| val.parse_value("RoutingAlgorithmRef"))
|
||||
|
||||
Reference in New Issue
Block a user