mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(router): add retry support for debit routing (#8220)
This commit is contained in:
@ -1541,7 +1541,7 @@ fn get_connector_data_with_routing_decision(
|
||||
let routing_decision =
|
||||
routing_helpers::RoutingDecisionData::get_debit_routing_decision_data(
|
||||
card_network,
|
||||
debit_routing_output,
|
||||
Some(debit_routing_output),
|
||||
);
|
||||
return Ok((data, Some(routing_decision)));
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ use crate::{
|
||||
flows::{ConstructFlowSpecificData, Feature},
|
||||
operations,
|
||||
},
|
||||
routing::helpers as routing_helpers,
|
||||
},
|
||||
db::StorageInterface,
|
||||
routes::{
|
||||
@ -109,6 +110,7 @@ where
|
||||
frm_suggestion,
|
||||
business_profile,
|
||||
false, //should_retry_with_pan is not applicable for step-up
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
@ -155,11 +157,20 @@ where
|
||||
.unwrap_or(false)
|
||||
&& business_profile.is_clear_pan_retries_enabled;
|
||||
|
||||
let connector = if should_retry_with_pan {
|
||||
let (connector, routing_decision) = if should_retry_with_pan {
|
||||
// If should_retry_with_pan is true, it indicates that we are retrying with PAN using the same connector.
|
||||
original_connector_data.clone()
|
||||
(original_connector_data.clone(), None)
|
||||
} else {
|
||||
super::get_connector_data(&mut connector_routing_data)?.connector_data
|
||||
let connector_routing_data =
|
||||
super::get_connector_data(&mut connector_routing_data)?;
|
||||
let routing_decision = connector_routing_data.network.map(|card_network| {
|
||||
routing_helpers::RoutingDecisionData::get_debit_routing_decision_data(
|
||||
card_network,
|
||||
None,
|
||||
)
|
||||
});
|
||||
|
||||
(connector_routing_data.connector_data, routing_decision)
|
||||
};
|
||||
|
||||
router_data = do_retry(
|
||||
@ -178,6 +189,7 @@ where
|
||||
frm_suggestion,
|
||||
business_profile,
|
||||
should_retry_with_pan,
|
||||
routing_decision,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@ -329,6 +341,7 @@ pub async fn do_retry<F, ApiRequest, FData, D>(
|
||||
frm_suggestion: Option<storage_enums::FrmSuggestion>,
|
||||
business_profile: &domain::Profile,
|
||||
should_retry_with_pan: bool,
|
||||
routing_decision: Option<routing_helpers::RoutingDecisionData>,
|
||||
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
|
||||
where
|
||||
F: Clone + Send + Sync,
|
||||
@ -372,7 +385,7 @@ where
|
||||
business_profile,
|
||||
true,
|
||||
should_retry_with_pan,
|
||||
None,
|
||||
routing_decision,
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@ -330,7 +330,7 @@ pub enum RoutingDecisionData {
|
||||
#[cfg(feature = "v1")]
|
||||
pub struct DebitRoutingDecisionData {
|
||||
pub card_network: common_enums::enums::CardNetwork,
|
||||
pub debit_routing_result: open_router::DebitRoutingOutput,
|
||||
pub debit_routing_result: Option<open_router::DebitRoutingOutput>,
|
||||
}
|
||||
#[cfg(feature = "v1")]
|
||||
impl RoutingDecisionData {
|
||||
@ -350,7 +350,7 @@ impl RoutingDecisionData {
|
||||
|
||||
pub fn get_debit_routing_decision_data(
|
||||
network: common_enums::enums::CardNetwork,
|
||||
debit_routing_result: open_router::DebitRoutingOutput,
|
||||
debit_routing_result: Option<open_router::DebitRoutingOutput>,
|
||||
) -> Self {
|
||||
Self::DebitRouting(DebitRoutingDecisionData {
|
||||
card_network: network,
|
||||
@ -370,7 +370,9 @@ impl DebitRoutingDecisionData {
|
||||
+ Clone,
|
||||
{
|
||||
payment_data.set_card_network(self.card_network.clone());
|
||||
payment_data.set_co_badged_card_data(&self.debit_routing_result);
|
||||
self.debit_routing_result
|
||||
.as_ref()
|
||||
.map(|data| payment_data.set_co_badged_card_data(data));
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user