diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs index 27d2a3a3de..b365c6a378 100644 --- a/crates/storage_impl/src/payments/payment_intent.rs +++ b/crates/storage_impl/src/payments/payment_intent.rs @@ -56,6 +56,7 @@ impl PaymentIntentInterface for KVRouterStore { MerchantStorageScheme::RedisKv => { let key = format!("{}_{}", new.merchant_id, new.payment_id); + let field = format!("pi_{}", new.payment_id); let created_intent = PaymentIntent { id: 0i32, payment_id: new.payment_id.clone(), @@ -95,7 +96,7 @@ impl PaymentIntentInterface for KVRouterStore { match self .get_redis_conn() .change_context(StorageError::DatabaseConnectionError)? - .serialize_and_set_hash_field_if_not_exist(&key, "pi", &created_intent) + .serialize_and_set_hash_field_if_not_exist(&key, &field, &created_intent) .await { Ok(HsetnxReply::KeyNotSet) => Err(StorageError::DuplicateValue { @@ -141,6 +142,7 @@ impl PaymentIntentInterface for KVRouterStore { } MerchantStorageScheme::RedisKv => { let key = format!("{}_{}", this.merchant_id, this.payment_id); + let field = format!("pi_{}", this.payment_id); let updated_intent = payment_intent.clone().apply_changeset(this.clone()); // Check for database presence as well Maybe use a read replica here ? @@ -152,7 +154,7 @@ impl PaymentIntentInterface for KVRouterStore { let updated_intent = self .get_redis_conn() .change_context(StorageError::DatabaseConnectionError)? - .set_hash_fields(&key, ("pi", &redis_value)) + .set_hash_fields(&key, (&field, &redis_value)) .await .map(|_| updated_intent) .change_context(StorageError::KVError)?; @@ -203,10 +205,11 @@ impl PaymentIntentInterface for KVRouterStore { MerchantStorageScheme::RedisKv => { let key = format!("{merchant_id}_{payment_id}"); + let field = format!("pi_{payment_id}"); crate::utils::try_redis_get_else_try_database_get( self.get_redis_conn() .change_context(StorageError::DatabaseConnectionError)? - .get_hash_field_and_deserialize(&key, "pi", "PaymentIntent"), + .get_hash_field_and_deserialize(&key, &field, "PaymentIntent"), database_call, ) .await