diff --git a/crates/router/src/db/refund.rs b/crates/router/src/db/refund.rs index 67980730f8fe..93227d718460 100644 --- a/crates/router/src/db/refund.rs +++ b/crates/router/src/db/refund.rs @@ -498,14 +498,9 @@ mod storage { .into_report() } enums::MerchantStorageScheme::RedisKv => { - let key = format!("{}_{}", this.merchant_id, this.refund_id); - + let key = format!("{}_{}", this.merchant_id, this.payment_id); + let field = format!("pa_{}_ref_{}", &this.attempt_id, &this.refund_id); let updated_refund = refund.clone().apply_changeset(this.clone()); - // Check for database presence as well Maybe use a read replica here ? - - let lookup = self.get_lookup_by_lookup_id(&key).await?; - - let field = &lookup.sk_id; let redis_value = utils::Encode::::encode_to_string_of_json( @@ -515,7 +510,7 @@ mod storage { self.get_redis_conn() .map_err(Into::::into)? - .set_hash_fields(&lookup.pk_id, (field, redis_value)) + .set_hash_fields(&key, (field, redis_value)) .await .change_context(errors::StorageError::KVError)?; diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs index 693772e89b4e..954da5d8c048 100644 --- a/crates/storage_impl/src/payments/payment_attempt.rs +++ b/crates/storage_impl/src/payments/payment_attempt.rs @@ -669,16 +669,15 @@ impl PaymentAttemptInterface for KVRouterStore { .await } MerchantStorageScheme::RedisKv => { - let lookup_id = format!("{merchant_id}_{attempt_id}"); - let lookup = self.get_lookup_by_lookup_id(&lookup_id).await?; - let key = &lookup.pk_id; + let key = format!("{merchant_id}_{payment_id}"); + let field = format!("pa_{attempt_id}"); try_redis_get_else_try_database_get( self.get_redis_conn() .map_err(|er| { let error = format!("{}", er); er.change_context(errors::StorageError::RedisError(error)) })? - .get_hash_field_and_deserialize(key, &lookup.sk_id, "PaymentAttempt"), + .get_hash_field_and_deserialize(&key, &field, "PaymentAttempt"), || async { self.router_store .find_payment_attempt_by_payment_id_merchant_id_attempt_id(