refactor(merchant_id): create domain type for merchant_id (#5408)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
This commit is contained in:
Narayan Bhat
2024-07-24 19:18:25 +05:30
committed by GitHub
parent e18ea7a7ba
commit 7068fbfbe2
406 changed files with 3168 additions and 2633 deletions

View File

@ -16,7 +16,7 @@ impl PaymentAttemptInterface for MockDb {
async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&self,
_payment_id: &str,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_attempt_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
@ -27,7 +27,7 @@ impl PaymentAttemptInterface for MockDb {
async fn get_filters_for_payments(
&self,
_pi: &[hyperswitch_domain_models::payments::PaymentIntent],
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<
hyperswitch_domain_models::payments::payment_attempt::PaymentListFilters,
@ -38,7 +38,7 @@ impl PaymentAttemptInterface for MockDb {
async fn get_total_count_of_filtered_payment_attempts(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_active_attempt_ids: &[String],
_connector: Option<Vec<Connector>>,
_payment_method: Option<Vec<PaymentMethod>>,
@ -53,7 +53,7 @@ impl PaymentAttemptInterface for MockDb {
async fn find_payment_attempt_by_attempt_id_merchant_id(
&self,
_attempt_id: &str,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
// [#172]: Implement function for `MockDb`
@ -63,7 +63,7 @@ impl PaymentAttemptInterface for MockDb {
async fn find_payment_attempt_by_preprocessing_id_merchant_id(
&self,
_preprocessing_id: &str,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
// [#172]: Implement function for `MockDb`
@ -72,7 +72,7 @@ impl PaymentAttemptInterface for MockDb {
async fn find_payment_attempt_by_merchant_id_connector_txn_id(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_connector_txn_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
@ -82,7 +82,7 @@ impl PaymentAttemptInterface for MockDb {
async fn find_attempts_by_merchant_id_payment_id(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_payment_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Vec<PaymentAttempt>, StorageError> {
@ -191,7 +191,7 @@ impl PaymentAttemptInterface for MockDb {
&self,
_connector_transaction_id: &str,
_payment_id: &str,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
// [#172]: Implement function for `MockDb`
@ -203,7 +203,7 @@ impl PaymentAttemptInterface for MockDb {
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
&self,
payment_id: &str,
merchant_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
let payment_attempts = self.payment_attempts.lock().await;
@ -212,7 +212,7 @@ impl PaymentAttemptInterface for MockDb {
.iter()
.find(|payment_attempt| {
payment_attempt.payment_id == payment_id
&& payment_attempt.merchant_id == merchant_id
&& payment_attempt.merchant_id.eq(merchant_id)
})
.cloned()
.unwrap())
@ -221,7 +221,7 @@ impl PaymentAttemptInterface for MockDb {
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(
&self,
payment_id: &str,
merchant_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
let payment_attempts = self.payment_attempts.lock().await;
@ -230,7 +230,7 @@ impl PaymentAttemptInterface for MockDb {
.iter()
.find(|payment_attempt| {
payment_attempt.payment_id == payment_id
&& payment_attempt.merchant_id == merchant_id
&& payment_attempt.merchant_id.eq(merchant_id)
&& (payment_attempt.status == storage_enums::AttemptStatus::PartialCharged
|| payment_attempt.status == storage_enums::AttemptStatus::Charged)
})

View File

@ -20,7 +20,7 @@ impl PaymentIntentInterface for MockDb {
async fn filter_payment_intent_by_constraints(
&self,
_state: &KeyManagerState,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_filters: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_key_store: &MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
@ -32,7 +32,7 @@ impl PaymentIntentInterface for MockDb {
async fn filter_payment_intents_by_time_range_constraints(
&self,
_state: &KeyManagerState,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_time_range: &api_models::payments::TimeRange,
_key_store: &MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
@ -43,7 +43,7 @@ impl PaymentIntentInterface for MockDb {
#[cfg(feature = "olap")]
async fn get_filtered_active_attempt_ids_for_total_count(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<Vec<String>, StorageError> {
@ -54,7 +54,7 @@ impl PaymentIntentInterface for MockDb {
async fn get_filtered_payment_intents_attempt(
&self,
_state: &KeyManagerState,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_key_store: &MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
@ -103,7 +103,7 @@ impl PaymentIntentInterface for MockDb {
state,
diesel_payment_intent_update.apply_changeset(diesel_payment_intent),
key_store.key.get_inner(),
key_store.merchant_id.clone(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?;
@ -117,7 +117,7 @@ impl PaymentIntentInterface for MockDb {
&self,
_state: &KeyManagerState,
payment_id: &str,
merchant_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
_key_store: &MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentIntent, StorageError> {
@ -126,7 +126,8 @@ impl PaymentIntentInterface for MockDb {
Ok(payment_intents
.iter()
.find(|payment_intent| {
payment_intent.payment_id == payment_id && payment_intent.merchant_id == merchant_id
payment_intent.payment_id == payment_id
&& payment_intent.merchant_id.eq(merchant_id)
})
.cloned()
.unwrap())

View File

@ -37,7 +37,7 @@ impl PayoutAttemptInterface for MockDb {
async fn find_payout_attempt_by_merchant_id_payout_attempt_id(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_payout_attempt_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PayoutAttempt, StorageError> {
@ -47,7 +47,7 @@ impl PayoutAttemptInterface for MockDb {
async fn find_payout_attempt_by_merchant_id_connector_payout_id(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_connector_payout_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PayoutAttempt, StorageError> {
@ -58,7 +58,7 @@ impl PayoutAttemptInterface for MockDb {
async fn get_filters_for_payouts(
&self,
_payouts: &[Payouts],
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<
hyperswitch_domain_models::payouts::payout_attempt::PayoutListFilters,

View File

@ -14,7 +14,7 @@ use super::MockDb;
impl PayoutsInterface for MockDb {
async fn find_payout_by_merchant_id_payout_id(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_payout_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Payouts, StorageError> {
@ -44,7 +44,7 @@ impl PayoutsInterface for MockDb {
async fn find_optional_payout_by_merchant_id_payout_id(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_payout_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Option<Payouts>, StorageError> {
@ -55,7 +55,7 @@ impl PayoutsInterface for MockDb {
#[cfg(feature = "olap")]
async fn filter_payouts_by_constraints(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Vec<Payouts>, StorageError> {
@ -66,7 +66,7 @@ impl PayoutsInterface for MockDb {
#[cfg(feature = "olap")]
async fn filter_payouts_and_attempts(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Vec<(Payouts, PayoutAttempt, diesel_models::Customer)>, StorageError> {
@ -77,7 +77,7 @@ impl PayoutsInterface for MockDb {
#[cfg(feature = "olap")]
async fn filter_payouts_by_time_range_constraints(
&self,
_merchant_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_time_range: &api_models::payments::TimeRange,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Vec<Payouts>, StorageError> {