diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 193998c3fd1c..c3faa5c6f93d 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -1304,6 +1304,20 @@ pub enum IntentStatus { } impl IntentStatus { + /// Indicates whether the payment intent is in terminal state or not + pub fn is_in_terminal_state(self) -> bool { + match self { + Self::Succeeded | Self::Failed | Self::Cancelled | Self::PartiallyCaptured => true, + Self::Processing + | Self::RequiresCustomerAction + | Self::RequiresMerchantAction + | Self::RequiresPaymentMethod + | Self::RequiresConfirmation + | Self::RequiresCapture + | Self::PartiallyCapturedAndCapturable => false, + } + } + /// Indicates whether the syncing with the connector should be allowed or not pub fn should_force_sync_with_connector(self) -> bool { match self { diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index 988429a0eecb..8254eeb892e6 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -1969,7 +1969,9 @@ async fn payment_response_update_tracker( #[cfg(all(feature = "v1", feature = "dynamic_routing"))] { - if business_profile.dynamic_routing_algorithm.is_some() { + if payment_intent.status.is_in_terminal_state() + && business_profile.dynamic_routing_algorithm.is_some() + { let state = state.clone(); let business_profile = business_profile.clone(); let payment_attempt = payment_attempt.clone();