refactor(payment_id): add payment id domain type (#5738)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Narayan Bhat
2024-09-02 09:21:33 +05:30
committed by GitHub
parent 4b0564e0e8
commit 7296cceba3
150 changed files with 880 additions and 803 deletions

View File

@ -79,7 +79,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
&self,
connector_transaction_id: &str,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
@ -101,7 +101,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
&self,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
@ -122,7 +122,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(
&self,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> {
@ -164,7 +164,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&self,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
attempt_id: &str,
_storage_scheme: MerchantStorageScheme,
@ -251,7 +251,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
async fn find_attempts_by_merchant_id_payment_id(
&self,
merchant_id: &common_utils::id_type::MerchantId,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<PaymentAttempt>, errors::StorageError> {
let conn = pg_connection_read(self).await?;
@ -600,7 +600,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
&self,
connector_transaction_id: &str,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
@ -654,7 +654,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
&self,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
@ -708,7 +708,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(
&self,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
@ -829,7 +829,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&self,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
attempt_id: &str,
storage_scheme: MerchantStorageScheme,
@ -1004,7 +1004,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
async fn find_attempts_by_merchant_id_payment_id(
&self,
merchant_id: &common_utils::id_type::MerchantId,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<Vec<PaymentAttempt>, errors::StorageError> {
let storage_scheme =

View File

@ -74,7 +74,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
) -> error_stack::Result<PaymentIntent, StorageError> {
let merchant_id = payment_intent.merchant_id.clone();
let payment_id = payment_intent.payment_id.clone();
let field = format!("pi_{}", payment_intent.payment_id);
let field = payment_intent.payment_id.get_hash_key_for_kv_store();
let key = PartitionKey::MerchantIdPaymentId {
merchant_id: &merchant_id,
payment_id: &payment_id,
@ -153,7 +153,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
merchant_id: &merchant_id,
payment_id: &payment_id,
};
let field = format!("pi_{}", this.payment_id);
let field = format!("pi_{}", this.payment_id.get_string_repr());
let storage_scheme = decide_storage_scheme::<_, DieselPaymentIntent>(
self,
storage_scheme,
@ -229,7 +229,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
state: &KeyManagerState,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
merchant_key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
@ -253,7 +253,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
merchant_id,
payment_id,
};
let field = format!("pi_{payment_id}");
let field = payment_id.get_hash_key_for_kv_store();
Box::pin(utils::try_redis_get_else_try_database_get(
async {
kv_wrapper::<DieselPaymentIntent, _, _>(
@ -463,7 +463,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
state: &KeyManagerState,
payment_id: &str,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
merchant_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,