refactor: add encryption support to payment attempt domain model (#5882)

This commit is contained in:
Sanchith Hegde
2024-09-17 16:26:08 +05:30
committed by GitHub
parent bc6c460ca9
commit f72abe4b97
30 changed files with 2986 additions and 735 deletions

View File

@ -1,6 +1,10 @@
use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMethodType};
use common_utils::errors::CustomResult;
#[cfg(all(feature = "v2", feature = "payment_v2"))]
use common_utils::types::keymanager::KeyManagerState;
use diesel_models::enums as storage_enums;
#[cfg(all(feature = "v2", feature = "payment_v2"))]
use hyperswitch_domain_models::merchant_key_store::MerchantKeyStore;
use hyperswitch_domain_models::{
errors::StorageError,
payments::payment_attempt::{
@ -13,6 +17,7 @@ use crate::DataModelExt;
#[async_trait::async_trait]
impl PaymentAttemptInterface for MockDb {
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&self,
_payment_id: &common_utils::id_type::PaymentId,
@ -24,6 +29,7 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
async fn get_filters_for_payments(
&self,
_pi: &[hyperswitch_domain_models::payments::PaymentIntent],
@ -36,6 +42,7 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
async fn get_total_count_of_filtered_payment_attempts(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
@ -51,6 +58,7 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
async fn find_payment_attempt_by_attempt_id_merchant_id(
&self,
_attempt_id: &str,
@ -61,6 +69,20 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(feature = "v2", feature = "payment_v2"))]
async fn find_payment_attempt_by_attempt_id_merchant_id(
&self,
_key_manager_state: &KeyManagerState,
_merchant_key_store: &MerchantKeyStore,
_attempt_id: &str,
_merchant_id: &common_utils::id_type::MerchantId,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
async fn find_payment_attempt_by_preprocessing_id_merchant_id(
&self,
_preprocessing_id: &str,
@ -71,6 +93,7 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
async fn find_payment_attempt_by_merchant_id_connector_txn_id(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
@ -81,6 +104,7 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
async fn find_attempts_by_merchant_id_payment_id(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
@ -91,6 +115,7 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[allow(clippy::panic)]
async fn insert_payment_attempt(
&self,
@ -168,6 +193,20 @@ impl PaymentAttemptInterface for MockDb {
Ok(payment_attempt)
}
#[cfg(all(feature = "v2", feature = "payment_v2"))]
#[allow(clippy::panic)]
async fn insert_payment_attempt(
&self,
_key_manager_state: &KeyManagerState,
_merchant_key_store: &MerchantKeyStore,
_payment_attempt: PaymentAttempt,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
// safety: only used for testing
#[allow(clippy::unwrap_used)]
async fn update_payment_attempt_with_attempt_id(
@ -192,6 +231,20 @@ impl PaymentAttemptInterface for MockDb {
Ok(item.clone())
}
#[cfg(all(feature = "v2", feature = "payment_v2"))]
async fn update_payment_attempt_with_attempt_id(
&self,
_key_manager_state: &KeyManagerState,
_merchant_key_store: &MerchantKeyStore,
_this: PaymentAttempt,
_payment_attempt: PaymentAttemptUpdate,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
async fn find_payment_attempt_by_connector_transaction_id_payment_id_merchant_id(
&self,
_connector_transaction_id: &str,
@ -203,6 +256,7 @@ impl PaymentAttemptInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
// safety: only used for testing
#[allow(clippy::unwrap_used)]
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
@ -222,6 +276,8 @@ impl PaymentAttemptInterface for MockDb {
.cloned()
.unwrap())
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
#[allow(clippy::unwrap_used)]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(
&self,