Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/decider/gatewaydecider/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ impl SC::ServiceConfigKey for SR_V3_INPUT_CONFIG_DEFAULT {

pub const srV3DefaultInputConfig: SR_V3_INPUT_CONFIG_DEFAULT = SR_V3_INPUT_CONFIG_DEFAULT;


pub const NB_QUICK_CHECKOUT_PAYMENT_FLOW_NAME: &str = "NB_QUICK_CHECKOUT";
pub const DEFAULT_SR_V3_BASED_BUCKET_SIZE: i32 = 125;
pub const defaultSrV3BasedUpperResetFactor: f64 = 3.0;
pub const defaultSrV3BasedLowerResetFactor: f64 = 3.0;
Expand Down Expand Up @@ -729,7 +731,7 @@ impl SC::ServiceConfigKey for GATEWAYDECIDER_SCORINGFLOW {
}
}

pub const paymentFlowsRequiredForGwFiltering: [&str; 12] = [
pub const paymentFlowsRequiredForGwFiltering: [&str; 13] = [
"DOTP",
"CARD_MOTO",
"MANDATE_REGISTER",
Expand All @@ -742,6 +744,7 @@ pub const paymentFlowsRequiredForGwFiltering: [&str; 12] = [
"CROSS_BORDER_PAYMENT",
"SINGLE_BLOCK_MULTIPLE_DEBIT",
"ONE_TIME_MANDATE",
NB_QUICK_CHECKOUT_PAYMENT_FLOW_NAME,
];

pub const getCardBrandCacheExpiry: i32 = 2 * 24 * 60 * 60;
Expand Down
3 changes: 3 additions & 0 deletions src/decider/gatewaydecider/flows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,9 @@ pub async fn getFailureReasonWithFilter(
"filterFunctionalGatewaysForOTMFlow" => {
"No functional gateways after filtering for OTM flow.".to_string()
}
"FilterFunctionalGatewaysForNBQCFlow" => {
"No functional gateways after filtering for NB Quick Checkout flow.".to_string()
}
"filterFunctionalGateways" => {
if Utils::is_card_transaction(txn_card_info) {
if m_internal_meta
Expand Down
57 changes: 57 additions & 0 deletions src/decider/gatewaydecider/gw_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ pub async fn newGwFilters(
let _ = filterFunctionalGatewaysForSplitSettlement(this).await;
let _ = filterFunctionalGatewaysForMerchantRequiredFlow(this).await;
let _ = filterFunctionalGatewaysForOTMFlow(this).await;
let _ = filterFunctionalGatewaysForNBQC(this).await;
let _ = filterGatewaysForMGASelectionIntegrity(this).await;
let funcGateways =
returnGwListWithLog(this, DeciderFilterName::FinalFunctionalGateways, false);
Expand Down Expand Up @@ -1453,6 +1454,62 @@ pub async fn filterFunctionalGatewaysForOTMFlow(this: &mut DeciderFlow<'_>) -> V
)
}

pub async fn filterFunctionalGatewaysForNBQC(
this: &mut DeciderFlow<'_>,
) -> GatewayList {
let st = getGws(this);
let txn_detail = this.get().dpTxnDetail.clone();

let macc = this.get().dpMerchantAccount.clone();
let order_reference = this.get().dpOrder.clone();
let (metadata, pl_ref_id_map) = Utils::get_order_metadata_and_pl_ref_id_map(
this,
macc.enableGatewayReferenceIdBasedRouting,
&order_reference,
);
let possible_ref_ids_of_merchant = Utils::get_all_possible_ref_ids(metadata.clone(), order_reference.clone(), pl_ref_id_map.clone());
let enabled_mgas = SETMA::get_enabled_mgas_by_merchant_id_and_ref_id(this, macc.merchantId, possible_ref_ids_of_merchant,).await;
let relevant_flows: Vec<&str> = [
C::NB_QUICK_CHECKOUT_PAYMENT_FLOW_NAME
].to_vec();

let filtered_mgas_by_enablement: Vec<_> = enabled_mgas
.into_iter()
.filter(|mga| {
relevant_flows.iter().all(|flow| {
Utils::is_payment_flow_enabled_in_mga(mga, flow).unwrap_or(false)
})
})
.collect();
let txn_payment_flows = Utils::get_payment_flow_list_from_txn_detail(&txn_detail);


let eligible_mga_post_filtering: Vec<_> = filtered_mgas_by_enablement
.into_iter()
.filter(|mga| {
st.iter().any(|gw| {
gw == &mga.gateway
})
})
.collect();
let final_gateways = eligible_mga_post_filtering
.into_iter()
.map(|g| g.gateway)
.collect::<Vec<_>>();

let is_nb_quick_checkout_in_txn_pf = txn_payment_flows.contains(&C::NB_QUICK_CHECKOUT_PAYMENT_FLOW_NAME.to_string());


if final_gateways.is_empty() || !is_nb_quick_checkout_in_txn_pf {
setGws(this, st);
}
else {
setGws(this, final_gateways);
}

returnGwListWithLog(this, DeciderFilterName::FilterFunctionalGatewaysForNBQC, true)
}

/// Filters gateways based on transaction validation type (Card Mandate, TPV, E-Mandate)
pub async fn filterGatewaysForValidationType(
this: &mut DeciderFlow<'_>,
Expand Down
55 changes: 55 additions & 0 deletions src/decider/gatewaydecider/gw_filter_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub async fn newGwFilters(this: &mut DeciderFlow<'_>) -> (GatewayList, Vec<ETM::
let _ = filterFunctionalGatewaysForSplitSettlement(this).await;
let _ = filterFunctionalGatewaysForMerchantRequiredFlow(this).await;
let _ = filterFunctionalGatewaysForOTMFlow(this).await;
let _ = filterFunctionalGatewaysForNBQC(this).await;
let _ = filterGatewaysForMGASelectionIntegrity(this).await;
let funcGateways = returnGwListWithLog(this,DeciderFilterName::FinalFunctionalGateways, false);
let allMgas = Utils::get_is_merchant_enabled_for_dynamic_mga_selection(this).await
Expand Down Expand Up @@ -946,8 +947,62 @@ pub async fn filterGatewaysForTxnOfferDetails(this: &mut DeciderFlow<'_>) -> Vec
}
}

pub async fn filterFunctionalGatewaysForNBQC(
this: &mut DeciderFlow<'_>,
) -> GatewayList {
let st = getGws(this);
let txn_detail = this.get().dpTxnDetail.clone();

let macc = this.get().dpMerchantAccount.clone();
let order_reference = this.get().dpOrder.clone();
let (metadata, pl_ref_id_map) = Utils::get_order_metadata_and_pl_ref_id_map(
this,
macc.enableGatewayReferenceIdBasedRouting,
&order_reference,
);
let possible_ref_ids_of_merchant = Utils::get_all_possible_ref_ids(metadata.clone(), order_reference.clone(), pl_ref_id_map.clone());
let enabled_mgas = SETMA::get_enabled_mgas_by_merchant_id_and_ref_id(this, macc.merchantId, possible_ref_ids_of_merchant,).await;
let relevant_flows: Vec<&str> = [
C::NB_QUICK_CHECKOUT_PAYMENT_FLOW_NAME
].to_vec();

let filtered_mgas_by_enablement: Vec<_> = enabled_mgas
.into_iter()
.filter(|mga| {
relevant_flows.iter().all(|flow| {
Utils::is_payment_flow_enabled_in_mga(mga, flow).unwrap_or(false)
})
})
.collect();
let txn_payment_flows = Utils::get_payment_flow_list_from_txn_detail(&txn_detail);


let eligible_mga_post_filtering: Vec<_> = filtered_mgas_by_enablement
.into_iter()
.filter(|mga| {
st.iter().any(|gw| {
gw == &mga.gateway
})
})
.collect();
let final_gateways = eligible_mga_post_filtering
.into_iter()
.map(|g| g.gateway)
.collect::<Vec<_>>();

let is_nb_quick_checkout_in_txn_pf = txn_payment_flows.contains(&C::NB_QUICK_CHECKOUT_PAYMENT_FLOW_NAME.to_string());


if final_gateways.is_empty() || !is_nb_quick_checkout_in_txn_pf {
setGws(this, st);
}
else {
setGws(this, final_gateways);
}

returnGwListWithLog(this, DeciderFilterName::FilterFunctionalGatewaysForNBQC, true)
}

/// Filters gateways based on transaction validation type (Card Mandate, TPV, E-Mandate)
pub async fn filterGatewaysForValidationType(this: &mut DeciderFlow<'_>) -> () {
// Get current gateways and transaction details
Expand Down
4 changes: 4 additions & 0 deletions src/decider/gatewaydecider/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub enum DeciderFilterName {
FilterGatewaysForEMITenureSpecficGatewayCreds,
FilterFunctionalGatewaysForReversePennyDrop,
FilterFunctionalGatewaysForOTM,
FilterFunctionalGatewaysForNBQC
}

impl fmt::Display for DeciderFilterName {
Expand Down Expand Up @@ -159,6 +160,9 @@ impl fmt::Display for DeciderFilterName {
Self::FilterFunctionalGatewaysForOTM => {
write!(f, "FilterFunctionalGatewaysForOTM")
}
Self::FilterFunctionalGatewaysForNBQC => {
write!(f, "FilterFunctionalGatewaysForNBQC")
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/decider/gatewaydecider/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,8 @@ pub fn decider_filter_order(filter_name: &str) -> i32 {
"filterGatewaysForEMITenureSpecficGatewayCreds" => 24,
"filterGatewaysForMGASelectionIntegrity" => 25,
"FilterFunctionalGatewaysForOTM" => 26,
_ => 27,
"FilterFunctionalGatewaysForNBQC" => 27,
_ => 28,
}
}

Expand Down
Loading