feat(router): Add revenue recovery retry algorithm type and data columns to business_profile table (#7772)

Co-authored-by: Aniket Burman <aniket.burman@Aniket-Burman-JDXHW2PH34.local>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Amisha Prabhat <55580080+Aprabhat19@users.noreply.github.com>
This commit is contained in:
Aniket Burman
2025-04-24 15:02:01 +05:30
committed by GitHub
parent c3ac0d0bd6
commit c633b336fb
8 changed files with 185 additions and 2 deletions

View File

@ -2913,6 +2913,17 @@ pub async fn create_connector(
.validate_and_get_business_profile(&merchant_account, store, key_manager_state, &key_store)
.await?;
#[cfg(feature = "v2")]
if req.connector_type == common_enums::ConnectorType::BillingProcessor {
update_revenue_recovery_algorithm_under_profile(
business_profile.clone(),
store,
key_manager_state,
&key_store,
common_enums::RevenueRecoveryAlgorithmType::Monitoring,
)
.await?;
}
core_utils::validate_profile_id_from_auth_layer(auth_profile_id, &business_profile)?;
let pm_auth_config_validation = PMAuthConfigValidation {
@ -3941,6 +3952,8 @@ impl ProfileCreateBridge for api::ProfileCreate {
is_clear_pan_retries_enabled: self.is_clear_pan_retries_enabled.unwrap_or_default(),
is_debit_routing_enabled: self.is_debit_routing_enabled.unwrap_or_default(),
merchant_business_country: self.merchant_business_country,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
}))
}
}
@ -4546,6 +4559,33 @@ impl ProfileWrapper {
Ok(())
}
}
#[cfg(feature = "v2")]
pub async fn update_revenue_recovery_algorithm_under_profile(
profile: domain::Profile,
db: &dyn StorageInterface,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
revenue_recovery_retry_algorithm_type: common_enums::RevenueRecoveryAlgorithmType,
) -> RouterResult<()> {
let recovery_algorithm_data = diesel_models::business_profile::RevenueRecoveryAlgorithmData {
monitoring_configured_timestamp: date_time::now(),
};
let profile_update = domain::ProfileUpdate::RevenueRecoveryAlgorithmUpdate {
revenue_recovery_retry_algorithm_type,
revenue_recovery_retry_algorithm_data: Some(recovery_algorithm_data),
};
db.update_profile_by_profile_id(
key_manager_state,
merchant_key_store,
profile,
profile_update,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update revenue recovery retry algorithm in business profile")?;
Ok(())
}
pub async fn extended_card_info_toggle(
state: SessionState,