revert(routing): Add connectors from current active routing algorithm before adding fallback connectors (#8207)

This commit is contained in:
spritianeja03
2025-06-04 21:33:50 +05:30
committed by GitHub
parent f5c4f6106f
commit e902d6d9ea

View File

@ -6935,7 +6935,7 @@ where
} }
if let Some(routing_algorithm) = request_straight_through { if let Some(routing_algorithm) = request_straight_through {
let (connectors, check_eligibility) = routing::perform_straight_through_routing( let (mut connectors, check_eligibility) = routing::perform_straight_through_routing(
&routing_algorithm, &routing_algorithm,
payment_data.get_creds_identifier(), payment_data.get_creds_identifier(),
) )
@ -6943,34 +6943,58 @@ where
.attach_printable("Failed execution of straight through routing")?; .attach_printable("Failed execution of straight through routing")?;
if check_eligibility { if check_eligibility {
let new_pd = payment_data.clone();
let transaction_data = core_routing::PaymentsDslInput::new( let transaction_data = core_routing::PaymentsDslInput::new(
new_pd.get_setup_mandate(), payment_data.get_setup_mandate(),
new_pd.get_payment_attempt(), payment_data.get_payment_attempt(),
new_pd.get_payment_intent(), payment_data.get_payment_intent(),
new_pd.get_payment_method_data(), payment_data.get_payment_method_data(),
new_pd.get_address(), payment_data.get_address(),
new_pd.get_recurring_details(), payment_data.get_recurring_details(),
new_pd.get_currency(), payment_data.get_currency(),
); );
return route_connector_v1_for_payments( connectors = routing::perform_eligibility_analysis_with_fallback(
&state, &state.clone(),
merchant_context, merchant_context.get_merchant_key_store(),
business_profile, connectors,
payment_data, &TransactionData::Payment(transaction_data),
transaction_data,
routing_data,
eligible_connectors, eligible_connectors,
mandate_type, business_profile,
Some(connectors),
) )
.await; .await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("failed eligibility analysis and fallback")?;
} }
let connector_data = connectors
.into_iter()
.map(|conn| {
api::ConnectorData::get_connector_by_name(
&state.conf.connectors,
&conn.connector.to_string(),
api::GetToken::Connector,
conn.merchant_connector_id.clone(),
)
.map(|connector_data| connector_data.into())
})
.collect::<CustomResult<Vec<_>, _>>()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Invalid connector name received")?;
return decide_multiplex_connector_for_normal_or_recurring_payment(
&state,
payment_data,
routing_data,
connector_data,
mandate_type,
business_profile.is_connector_agnostic_mit_enabled,
business_profile.is_network_tokenization_enabled,
)
.await;
} }
if let Some(ref routing_algorithm) = routing_data.routing_info.algorithm { if let Some(ref routing_algorithm) = routing_data.routing_info.algorithm {
let (connectors, check_eligibility) = routing::perform_straight_through_routing( let (mut connectors, check_eligibility) = routing::perform_straight_through_routing(
routing_algorithm, routing_algorithm,
payment_data.get_creds_identifier(), payment_data.get_creds_identifier(),
) )
@ -6978,30 +7002,54 @@ where
.attach_printable("Failed execution of straight through routing")?; .attach_printable("Failed execution of straight through routing")?;
if check_eligibility { if check_eligibility {
let new_pd = payment_data.clone();
let transaction_data = core_routing::PaymentsDslInput::new( let transaction_data = core_routing::PaymentsDslInput::new(
new_pd.get_setup_mandate(), payment_data.get_setup_mandate(),
new_pd.get_payment_attempt(), payment_data.get_payment_attempt(),
new_pd.get_payment_intent(), payment_data.get_payment_intent(),
new_pd.get_payment_method_data(), payment_data.get_payment_method_data(),
new_pd.get_address(), payment_data.get_address(),
new_pd.get_recurring_details(), payment_data.get_recurring_details(),
new_pd.get_currency(), payment_data.get_currency(),
); );
return route_connector_v1_for_payments( connectors = routing::perform_eligibility_analysis_with_fallback(
&state, &state,
merchant_context, merchant_context.get_merchant_key_store(),
business_profile, connectors,
payment_data, &TransactionData::Payment(transaction_data),
transaction_data,
routing_data,
eligible_connectors, eligible_connectors,
mandate_type, business_profile,
Some(connectors),
) )
.await; .await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("failed eligibility analysis and fallback")?;
} }
let connector_data = connectors
.into_iter()
.map(|conn| {
api::ConnectorData::get_connector_by_name(
&state.conf.connectors,
&conn.connector.to_string(),
api::GetToken::Connector,
conn.merchant_connector_id,
)
.map(|connector_data| connector_data.into())
})
.collect::<CustomResult<Vec<_>, _>>()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Invalid connector name received")?;
return decide_multiplex_connector_for_normal_or_recurring_payment(
&state,
payment_data,
routing_data,
connector_data,
mandate_type,
business_profile.is_connector_agnostic_mit_enabled,
business_profile.is_network_tokenization_enabled,
)
.await;
} }
let new_pd = payment_data.clone(); let new_pd = payment_data.clone();
@ -7024,7 +7072,6 @@ where
routing_data, routing_data,
eligible_connectors, eligible_connectors,
mandate_type, mandate_type,
None,
) )
.await .await
} }
@ -7625,7 +7672,6 @@ pub async fn route_connector_v1_for_payments<F, D>(
routing_data: &mut storage::RoutingData, routing_data: &mut storage::RoutingData,
eligible_connectors: Option<Vec<enums::RoutableConnectors>>, eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>, mandate_type: Option<api::MandateTransactionType>,
connector_list: Option<Vec<api_models::routing::RoutableConnectorChoice>>,
) -> RouterResult<ConnectorCallType> ) -> RouterResult<ConnectorCallType>
where where
F: Send + Clone, F: Send + Clone,
@ -7643,7 +7689,7 @@ where
algorithm_ref.algorithm_id algorithm_ref.algorithm_id
}; };
let mut connectors = routing::perform_static_routing_v1( let connectors = routing::perform_static_routing_v1(
state, state,
merchant_context.get_merchant_account().get_id(), merchant_context.get_merchant_account().get_id(),
routing_algorithm_id.as_ref(), routing_algorithm_id.as_ref(),
@ -7653,20 +7699,10 @@ where
.await .await
.change_context(errors::ApiErrorResponse::InternalServerError)?; .change_context(errors::ApiErrorResponse::InternalServerError)?;
// adds straight through connectors to the list of connectors in the active routing algorithm
// and perform eligibility analysis on the combined set of connectors
connectors = connector_list
.map(|mut straight_through_connectors| {
straight_through_connectors.extend(connectors.clone());
straight_through_connectors
})
.unwrap_or_else(|| connectors);
#[cfg(all(feature = "v1", feature = "dynamic_routing"))] #[cfg(all(feature = "v1", feature = "dynamic_routing"))]
let payment_attempt = transaction_data.payment_attempt.clone(); let payment_attempt = transaction_data.payment_attempt.clone();
connectors = routing::perform_eligibility_analysis_with_fallback( let connectors = routing::perform_eligibility_analysis_with_fallback(
&state.clone(), &state.clone(),
merchant_context.get_merchant_key_store(), merchant_context.get_merchant_key_store(),
connectors, connectors,