Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(dynamic_routing): perform db operations for dynamic_routing_stats table only when payments are in terminal state (#6900)
Prajjwal Kumar1ec91e54e242
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 0833ab37e3..13deafb4ac 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 notpub 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.rsindex fbc2d2ee46..9692b1ca8a 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -1971,7 +1971,9 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(#[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();