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(revenue_recovery): remove time-based monitoring threshold logic (#15051)
CHALLA NISHANTH BABUdec7dca01962
diff --git a/config/config.example.toml b/config/config.example.tomlindex 0425103312..ce7b27cc36 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -1629,7 +1629,6 @@ billing_connectors_which_require_invoice_record_back_call = "chargebee,stripebilbilling_connectors_which_requires_dispute_record_back_call = "chargebee" # List of billing connectors which support the dispute record back api call[revenue_recovery]-monitoring_threshold_in_seconds = 60 # 60 secs , threshold for monitoring the retry systemretry_algorithm_type = "cascading" # type of retry algorithmredis_ttl_in_seconds=3888000 # ttl for redis for storing payment processor token detailsdefault_retry_hour_utc = 12 # fallback hour-of-day (UTC, 0-23) the retry model schedules at when a cluster has no hour-of-day historydiff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.tomlindex 5f5a711188..cbc1dad258 100644--- a/config/deployments/env_specific.toml+++ b/config/deployments/env_specific.toml@@ -556,7 +556,6 @@ ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list[revenue_recovery]# monitoring threshold - 120 days-monitoring_threshold_in_seconds = 10368000retry_algorithm_type = "cascading"redis_ttl_in_seconds=3888000default_retry_hour_utc = 12 # fallback hour-of-day (UTC, 0-23) the retry model schedules at when a cluster has no hour-of-day historydiff --git a/config/development.toml b/config/development.tomlindex 77de10aaa4..b538fed1e0 100644--- a/config/development.toml+++ b/config/development.toml@@ -1700,7 +1700,6 @@ ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fisucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call[revenue_recovery]-monitoring_threshold_in_seconds = 60retry_algorithm_type = "cascading"redis_ttl_in_seconds=3888000default_retry_hour_utc = 12 # fallback hour-of-day (UTC, 0-23) the retry model schedules at when a cluster has no hour-of-day historydiff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 1b1d0aea2a..83eaaf1756 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -1557,7 +1557,6 @@ click_to_pay = {connector_list = "adyen, cybersource, trustpay"}connector_list = "juspaythreedsserver, ctp_mastercard, ctp_visa"[revenue_recovery]-monitoring_threshold_in_seconds = 60 # threshold for monitoring the retry systemretry_algorithm_type = "cascading" # type of retry algorithmredis_ttl_in_seconds=3888000 # ttl for redis for storing payment processor token detailsdefault_retry_hour_utc = 12 # fallback hour-of-day (UTC, 0-23) the retry model schedules at when a cluster has no hour-of-day historydiff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rsindex a94f3e2945..a04c911140 100644--- a/crates/diesel_models/src/business_profile.rs+++ b/crates/diesel_models/src/business_profile.rs@@ -5,7 +5,6 @@ use common_types::primitive_wrappers;use common_utils::{encryption::Encryption, pii};use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use hyperswitch_masking::Secret;-use time::Duration;#[cfg(feature = "v1")]use crate::schema::business_profile;@@ -698,14 +697,6 @@ pub struct RevenueRecoveryAlgorithmData {pub monitoring_configured_timestamp: time::PrimitiveDateTime,}-impl RevenueRecoveryAlgorithmData {- pub fn has_exceeded_monitoring_threshold(&self, monitoring_threshold_in_seconds: i64) -> bool {- let total_threshold_time = self.monitoring_configured_timestamp- + Duration::seconds(monitoring_threshold_in_seconds);- common_utils::date_time::now() >= total_threshold_time- }-}-common_utils::impl_to_sql_from_sql_json!(RevenueRecoveryAlgorithmData);/// Configuration for payment method blocking based on card attributesdiff --git a/crates/router/src/core/webhooks/recovery_incoming.rs b/crates/router/src/core/webhooks/recovery_incoming.rsindex 4a225aa9d3..41cf8970b4 100644--- a/crates/router/src/core/webhooks/recovery_incoming.rs+++ b/crates/router/src/core/webhooks/recovery_incoming.rs@@ -241,38 +241,6 @@ pub async fn recovery_incoming_webhook_flow(.await}-async fn handle_monitoring_threshold(- state: &SessionState,- business_profile: &domain::Profile,- key_store: &domain::MerchantKeyStore,-) -> CustomResult<webhooks::WebhookResponseTracker, errors::RevenueRecoveryError> {- let db = &*state.store;- let key_manager_state = &(state).into();- let monitoring_threshold_config = state.conf.revenue_recovery.monitoring_threshold_in_seconds;- let retry_algorithm_type = state.conf.revenue_recovery.retry_algorithm_type;- let revenue_recovery_retry_algorithm = business_profile- .revenue_recovery_retry_algorithm_data- .clone()- .ok_or(report!(- errors::RevenueRecoveryError::RetryAlgorithmTypeNotFound- ))?;- if revenue_recovery_retry_algorithm- .has_exceeded_monitoring_threshold(monitoring_threshold_config)- {- let profile_wrapper = admin::ProfileWrapper::new(business_profile.clone());- profile_wrapper- .update_revenue_recovery_algorithm_under_profile(- db,- key_manager_state,- key_store,- retry_algorithm_type,- )- .await- .change_context(errors::RevenueRecoveryError::RetryAlgorithmUpdationFailed)?;- }- Ok(webhooks::WebhookResponseTracker::NoEffect)-}-#[allow(clippy::too_many_arguments)]async fn handle_schedule_failed_payment(billing_connector_account: &domain::MerchantConnectorAccount,@@ -1757,12 +1725,10 @@ impl RecoveryAction {))?;match recovery_algorithm_type {api_enums::RevenueRecoveryAlgorithmType::Monitoring => {- handle_monitoring_threshold(- state,- business_profile,- platform.get_processor().get_key_store(),- )- .await+ logger::info!(+ "Profile is in monitoring mode, skipping recovery scheduling"+ );+ Ok(webhooks::WebhookResponseTracker::NoEffect)}revenue_recovery_retry_type => {handle_schedule_failed_payment(diff --git a/crates/router/src/types/storage/revenue_recovery.rs b/crates/router/src/types/storage/revenue_recovery.rsindex 469f74f823..eac2fff3fb 100644--- a/crates/router/src/types/storage/revenue_recovery.rs+++ b/crates/router/src/types/storage/revenue_recovery.rs@@ -98,7 +98,6 @@ impl RevenueRecoveryPaymentData {#[derive(Debug, serde::Deserialize, Clone, Default)]pub struct RevenueRecoverySettings {- pub monitoring_threshold_in_seconds: i64,pub retry_algorithm_type: enums::RevenueRecoveryAlgorithmType,pub recovery_timestamp: RecoveryTimestamp,pub card_config: RetryLimitsConfig,