From 8ac1b83985dbae33afc3b53d46b85a374ff3c1e9 Mon Sep 17 00:00:00 2001 From: Hrithikesh <61539176+hrithikesh026@users.noreply.github.com> Date: Tue, 4 Feb 2025 01:43:37 +0530 Subject: [PATCH] fix: invalidate surcharge cache during update (#6907) --- crates/router/src/core/surcharge_decision_config.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/router/src/core/surcharge_decision_config.rs b/crates/router/src/core/surcharge_decision_config.rs index 0ff5f3fb37..2d817fd1af 100644 --- a/crates/router/src/core/surcharge_decision_config.rs +++ b/crates/router/src/core/surcharge_decision_config.rs @@ -56,7 +56,7 @@ pub async fn upsert_surcharge_decision_config( message: "Invalid Request Data".to_string(), }) .attach_printable("The Request has an Invalid Comparison")?; - + let surcharge_cache_key = merchant_account.get_id().get_surcharge_dsk_key(); match read_config_key { Ok(config) => { let previous_record: SurchargeDecisionManagerRecord = config @@ -88,7 +88,7 @@ pub async fn upsert_surcharge_decision_config( .attach_printable("Error serializing the config")?; algo_id.update_surcharge_config_id(key.clone()); - let config_key = cache::CacheKind::Surcharge(key.into()); + let config_key = cache::CacheKind::Surcharge(surcharge_cache_key.into()); update_merchant_active_algorithm_ref(&state, &key_store, config_key, algo_id) .await .change_context(errors::ApiErrorResponse::InternalServerError) @@ -125,7 +125,7 @@ pub async fn upsert_surcharge_decision_config( .attach_printable("Error fetching the config")?; algo_id.update_surcharge_config_id(key.clone()); - let config_key = cache::CacheKind::Surcharge(key.clone().into()); + let config_key = cache::CacheKind::Surcharge(surcharge_cache_key.into()); update_merchant_active_algorithm_ref(&state, &key_store, config_key, algo_id) .await .change_context(errors::ApiErrorResponse::InternalServerError) @@ -173,7 +173,8 @@ pub async fn delete_surcharge_decision_config( .attach_printable("Could not decode the surcharge conditional_config algorithm")? .unwrap_or_default(); algo_id.surcharge_config_algo_id = None; - let config_key = cache::CacheKind::Surcharge(key.clone().into()); + let surcharge_cache_key = merchant_account.get_id().get_surcharge_dsk_key(); + let config_key = cache::CacheKind::Surcharge(surcharge_cache_key.into()); update_merchant_active_algorithm_ref(&state, &key_store, config_key, algo_id) .await .change_context(errors::ApiErrorResponse::InternalServerError)