mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +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 = |             let routing_decision = | ||||||
|                 routing_helpers::RoutingDecisionData::get_debit_routing_decision_data( |                 routing_helpers::RoutingDecisionData::get_debit_routing_decision_data( | ||||||
|                     card_network, |                     card_network, | ||||||
|                     debit_routing_output, |                     Some(debit_routing_output), | ||||||
|                 ); |                 ); | ||||||
|             return Ok((data, Some(routing_decision))); |             return Ok((data, Some(routing_decision))); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ use crate::{ | |||||||
|             flows::{ConstructFlowSpecificData, Feature}, |             flows::{ConstructFlowSpecificData, Feature}, | ||||||
|             operations, |             operations, | ||||||
|         }, |         }, | ||||||
|  |         routing::helpers as routing_helpers, | ||||||
|     }, |     }, | ||||||
|     db::StorageInterface, |     db::StorageInterface, | ||||||
|     routes::{ |     routes::{ | ||||||
| @ -109,6 +110,7 @@ where | |||||||
|             frm_suggestion, |             frm_suggestion, | ||||||
|             business_profile, |             business_profile, | ||||||
|             false, //should_retry_with_pan is not applicable for step-up |             false, //should_retry_with_pan is not applicable for step-up | ||||||
|  |             None, | ||||||
|         ) |         ) | ||||||
|         .await?; |         .await?; | ||||||
|     } |     } | ||||||
| @ -155,11 +157,20 @@ where | |||||||
|                             .unwrap_or(false) |                             .unwrap_or(false) | ||||||
|                         && business_profile.is_clear_pan_retries_enabled; |                         && 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. |                         // 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 { |                     } 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( |                     router_data = do_retry( | ||||||
| @ -178,6 +189,7 @@ where | |||||||
|                         frm_suggestion, |                         frm_suggestion, | ||||||
|                         business_profile, |                         business_profile, | ||||||
|                         should_retry_with_pan, |                         should_retry_with_pan, | ||||||
|  |                         routing_decision, | ||||||
|                     ) |                     ) | ||||||
|                     .await?; |                     .await?; | ||||||
|  |  | ||||||
| @ -329,6 +341,7 @@ pub async fn do_retry<F, ApiRequest, FData, D>( | |||||||
|     frm_suggestion: Option<storage_enums::FrmSuggestion>, |     frm_suggestion: Option<storage_enums::FrmSuggestion>, | ||||||
|     business_profile: &domain::Profile, |     business_profile: &domain::Profile, | ||||||
|     should_retry_with_pan: bool, |     should_retry_with_pan: bool, | ||||||
|  |     routing_decision: Option<routing_helpers::RoutingDecisionData>, | ||||||
| ) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>> | ) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>> | ||||||
| where | where | ||||||
|     F: Clone + Send + Sync, |     F: Clone + Send + Sync, | ||||||
| @ -372,7 +385,7 @@ where | |||||||
|         business_profile, |         business_profile, | ||||||
|         true, |         true, | ||||||
|         should_retry_with_pan, |         should_retry_with_pan, | ||||||
|         None, |         routing_decision, | ||||||
|         None, |         None, | ||||||
|     ) |     ) | ||||||
|     .await?; |     .await?; | ||||||
|  | |||||||
| @ -330,7 +330,7 @@ pub enum RoutingDecisionData { | |||||||
| #[cfg(feature = "v1")] | #[cfg(feature = "v1")] | ||||||
| pub struct DebitRoutingDecisionData { | pub struct DebitRoutingDecisionData { | ||||||
|     pub card_network: common_enums::enums::CardNetwork, |     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")] | #[cfg(feature = "v1")] | ||||||
| impl RoutingDecisionData { | impl RoutingDecisionData { | ||||||
| @ -350,7 +350,7 @@ impl RoutingDecisionData { | |||||||
|  |  | ||||||
|     pub fn get_debit_routing_decision_data( |     pub fn get_debit_routing_decision_data( | ||||||
|         network: common_enums::enums::CardNetwork, |         network: common_enums::enums::CardNetwork, | ||||||
|         debit_routing_result: open_router::DebitRoutingOutput, |         debit_routing_result: Option<open_router::DebitRoutingOutput>, | ||||||
|     ) -> Self { |     ) -> Self { | ||||||
|         Self::DebitRouting(DebitRoutingDecisionData { |         Self::DebitRouting(DebitRoutingDecisionData { | ||||||
|             card_network: network, |             card_network: network, | ||||||
| @ -370,7 +370,9 @@ impl DebitRoutingDecisionData { | |||||||
|             + Clone, |             + Clone, | ||||||
|     { |     { | ||||||
|         payment_data.set_card_network(self.card_network.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)] | #[derive(Clone, Debug)] | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Shankar Singh C
					Shankar Singh C