Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(router): Remove key manager state from DB interfaces (#10169)

Jaganf3bd3f2f45a6
diff --git a/crates/common_utils/src/id_type/tenant.rs b/crates/common_utils/src/id_type/tenant.rs
index 0584496332..882229371a 100644
--- a/crates/common_utils/src/id_type/tenant.rs
+++ b/crates/common_utils/src/id_type/tenant.rs
@@ -1,5 +1,5 @@
use crate::{
- consts::DEFAULT_GLOBAL_TENANT_ID,
+ consts::{DEFAULT_GLOBAL_TENANT_ID, DEFAULT_TENANT},
errors::{CustomResult, ValidationError},
};
@@ -25,6 +25,13 @@ impl TenantId {
))
}
+ /// Get the default tenant ID
+ pub fn get_default_tenant_id() -> Self {
+ Self(super::LengthId::new_unchecked(
+ super::AlphaNumericId::new_unchecked(DEFAULT_TENANT.to_string()),
+ ))
+ }
+
/// Get tenant id from String
pub fn try_from_string(tenant_id: String) -> CustomResult<Self, ValidationError> {
Self::try_from(std::borrow::Cow::from(tenant_id))
diff --git a/crates/common_utils/src/types/keymanager.rs b/crates/common_utils/src/types/keymanager.rs
index 7271cf988b..d92f1fc39a 100644
--- a/crates/common_utils/src/types/keymanager.rs
+++ b/crates/common_utils/src/types/keymanager.rs
@@ -52,7 +52,29 @@ pub struct KeyManagerState {
pub infra_values: Option<serde_json::Value>,
}
+impl Default for KeyManagerState {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl KeyManagerState {
+ pub fn new() -> Self {
+ Self {
+ tenant_id: id_type::TenantId::get_default_tenant_id(),
+ global_tenant_id: id_type::TenantId::get_default_global_tenant_id(),
+ enabled: Default::default(),
+ url: String::default(),
+ client_idle_timeout: Default::default(),
+ #[cfg(feature = "km_forward_x_request_id")]
+ request_id: Default::default(),
+ #[cfg(feature = "keymanager_mtls")]
+ ca: Default::default(),
+ #[cfg(feature = "keymanager_mtls")]
+ cert: Default::default(),
+ infra_values: Default::default(),
+ }
+ }
pub fn add_confirm_value_in_infra_values(
&self,
is_confirm_operation: bool,
diff --git a/crates/hyperswitch_domain_models/src/business_profile.rs b/crates/hyperswitch_domain_models/src/business_profile.rs
index eec8a8e740..86a39b0d2b 100644
--- a/crates/hyperswitch_domain_models/src/business_profile.rs
+++ b/crates/hyperswitch_domain_models/src/business_profile.rs
@@ -2546,21 +2546,18 @@ where
type Error;
async fn insert_business_profile(
&self,
- key_manager_state: &keymanager::KeyManagerState,
merchant_key_store: &MerchantKeyStore,
business_profile: Profile,
) -> CustomResult<Profile, Self::Error>;
async fn find_business_profile_by_profile_id(
&self,
- key_manager_state: &keymanager::KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
) -> CustomResult<Profile, Self::Error>;
async fn find_business_profile_by_merchant_id_profile_id(
&self,
- key_manager_state: &keymanager::KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
profile_id: &common_utils::id_type::ProfileId,
@@ -2568,7 +2565,6 @@ where
async fn find_business_profile_by_profile_name_merchant_id(
&self,
- key_manager_state: &keymanager::KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_name: &str,
merchant_id: &common_utils::id_type::MerchantId,
@@ -2576,7 +2572,6 @@ where
async fn update_profile_by_profile_id(
&self,
- key_manager_state: &keymanager::KeyManagerState,
merchant_key_store: &MerchantKeyStore,
current_state: Profile,
profile_update: ProfileUpdate,
@@ -2590,7 +2585,6 @@ where
async fn list_profile_by_merchant_id(
&self,
- key_manager_state: &keymanager::KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<Profile>, Self::Error>;
diff --git a/crates/hyperswitch_domain_models/src/customer.rs b/crates/hyperswitch_domain_models/src/customer.rs
index 42ad0da4ea..40ec1db1e7 100644
--- a/crates/hyperswitch_domain_models/src/customer.rs
+++ b/crates/hyperswitch_domain_models/src/customer.rs
@@ -647,7 +647,6 @@ where
#[cfg(feature = "v1")]
async fn find_customer_optional_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -657,7 +656,6 @@ where
#[cfg(feature = "v1")]
async fn find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -667,7 +665,6 @@ where
#[cfg(feature = "v2")]
async fn find_optional_by_merchant_id_merchant_reference_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -678,7 +675,6 @@ where
#[allow(clippy::too_many_arguments)]
async fn update_customer_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: id_type::CustomerId,
merchant_id: id_type::MerchantId,
customer: Customer,
@@ -690,7 +686,6 @@ where
#[cfg(feature = "v1")]
async fn find_customer_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -700,7 +695,6 @@ where
#[cfg(feature = "v2")]
async fn find_customer_by_merchant_reference_id_merchant_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -709,7 +703,6 @@ where
async fn list_customers_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: CustomerListConstraints,
@@ -717,7 +710,6 @@ where
async fn list_customers_by_merchant_id_with_count(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: CustomerListConstraints,
@@ -726,7 +718,6 @@ where
async fn insert_customer(
&self,
customer_data: Customer,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Customer, Self::Error>;
@@ -735,7 +726,6 @@ where
#[allow(clippy::too_many_arguments)]
async fn update_customer_by_global_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
customer: Customer,
customer_update: CustomerUpdate,
@@ -746,7 +736,6 @@ where
#[cfg(feature = "v2")]
async fn find_customer_by_global_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
diff --git a/crates/hyperswitch_domain_models/src/invoice.rs b/crates/hyperswitch_domain_models/src/invoice.rs
index 0ce7ca8a39..f4609443ec 100644
--- a/crates/hyperswitch_domain_models/src/invoice.rs
+++ b/crates/hyperswitch_domain_models/src/invoice.rs
@@ -145,21 +145,18 @@ pub trait InvoiceInterface {
type Error;
async fn insert_invoice_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_new: Invoice,
) -> CustomResult<Invoice, Self::Error>;
async fn find_invoice_by_invoice_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_id: String,
) -> CustomResult<Invoice, Self::Error>;
async fn update_invoice_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_id: String,
data: InvoiceUpdate,
@@ -167,14 +164,12 @@ pub trait InvoiceInterface {
async fn get_latest_invoice_for_subscription(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_id: String,
) -> CustomResult<Invoice, Self::Error>;
async fn find_invoice_by_subscription_id_connector_invoice_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_id: String,
connector_invoice_id: common_utils::id_type::InvoiceId,
diff --git a/crates/hyperswitch_domain_models/src/merchant_account.rs b/crates/hyperswitch_domain_models/src/merchant_account.rs
index 86b0f9f139..a6ccaec206 100644
--- a/crates/hyperswitch_domain_models/src/merchant_account.rs
+++ b/crates/hyperswitch_domain_models/src/merchant_account.rs
@@ -894,14 +894,12 @@ where
type Error;
async fn insert_merchant(
&self,
- state: &keymanager::KeyManagerState,
merchant_account: MerchantAccount,
merchant_key_store: &merchant_key_store::MerchantKeyStore,
) -> CustomResult<MerchantAccount, Self::Error>;
async fn find_merchant_account_by_merchant_id(
&self,
- state: &keymanager::KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_key_store: &merchant_key_store::MerchantKeyStore,
) -> CustomResult<MerchantAccount, Self::Error>;
@@ -913,7 +911,6 @@ where
async fn update_merchant(
&self,
- state: &keymanager::KeyManagerState,
this: MerchantAccount,
merchant_account: MerchantAccountUpdate,
merchant_key_store: &merchant_key_store::MerchantKeyStore,
@@ -921,7 +918,6 @@ where
async fn update_specific_fields_in_merchant(
&self,
- state: &keymanager::KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_account: MerchantAccountUpdate,
merchant_key_store: &merchant_key_store::MerchantKeyStore,
@@ -929,14 +925,12 @@ where
async fn find_merchant_account_by_publishable_key(
&self,
- state: &keymanager::KeyManagerState,
publishable_key: &str,
) -> CustomResult<(MerchantAccount, merchant_key_store::MerchantKeyStore), Self::Error>;
#[cfg(feature = "olap")]
async fn list_merchant_accounts_by_organization_id(
&self,
- state: &keymanager::KeyManagerState,
organization_id: &common_utils::id_type::OrganizationId,
) -> CustomResult<Vec<MerchantAccount>, Self::Error>;
@@ -948,14 +942,12 @@ where
#[cfg(feature = "olap")]
async fn list_multiple_merchant_accounts(
&self,
- state: &keymanager::KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
) -> CustomResult<Vec<MerchantAccount>, Self::Error>;
#[cfg(feature = "olap")]
async fn list_merchant_and_org_ids(
&self,
- state: &keymanager::KeyManagerState,
limit: u32,
offset: Option<u32>,
) -> CustomResult<
diff --git a/crates/hyperswitch_domain_models/src/merchant_connector_account.rs b/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
index 0de70ddeea..402ef28aed 100644
--- a/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
+++ b/crates/hyperswitch_domain_models/src/merchant_connector_account.rs
@@ -1031,7 +1031,6 @@ where
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_merchant_id_connector_label(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
connector_label: &str,
key_store: &MerchantKeyStore,
@@ -1040,7 +1039,6 @@ where
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_profile_id_connector_name(
&self,
- state: &KeyManagerState,
profile_id: &id_type::ProfileId,
connector_name: &str,
key_store: &MerchantKeyStore,
@@ -1049,7 +1047,6 @@ where
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_merchant_id_connector_name(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
connector_name: &str,
key_store: &MerchantKeyStore,
@@ -1057,7 +1054,6 @@ where
async fn insert_merchant_connector_account(
&self,
- state: &KeyManagerState,
t: MerchantConnectorAccount,
key_store: &MerchantKeyStore,
) -> CustomResult<MerchantConnectorAccount, Self::Error>;
@@ -1065,7 +1061,6 @@ where
#[cfg(feature = "v1")]
async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
merchant_connector_id: &id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
@@ -1074,14 +1069,12 @@ where
#[cfg(feature = "v2")]
async fn find_merchant_connector_account_by_id(
&self,
- state: &KeyManagerState,
id: &id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
) -> CustomResult<MerchantConnectorAccount, Self::Error>;
async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
get_disabled: bool,
key_store: &MerchantKeyStore,
@@ -1090,14 +1083,12 @@ where
#[cfg(all(feature = "olap", feature = "v2"))]
async fn list_connector_account_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &id_type::ProfileId,
key_store: &MerchantKeyStore,
) -> CustomResult<Vec<MerchantConnectorAccount>, Self::Error>;
async fn list_enabled_connector_accounts_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &id_type::ProfileId,
key_store: &MerchantKeyStore,
connector_type: common_enums::ConnectorType,
@@ -1105,7 +1096,6 @@ where
async fn update_merchant_connector_account(
&self,
- state: &KeyManagerState,
this: MerchantConnectorAccount,
merchant_connector_account: MerchantConnectorAccountUpdateInternal,
key_store: &MerchantKeyStore,
diff --git a/crates/hyperswitch_domain_models/src/merchant_key_store.rs b/crates/hyperswitch_domain_models/src/merchant_key_store.rs
index ebef0b4706..a5e983cc9a 100644
--- a/crates/hyperswitch_domain_models/src/merchant_key_store.rs
+++ b/crates/hyperswitch_domain_models/src/merchant_key_store.rs
@@ -74,14 +74,12 @@ pub trait MerchantKeyStoreInterface {
type Error;
async fn insert_merchant_key_store(
&self,
- state: &KeyManagerState,
merchant_key_store: MerchantKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<MerchantKeyStore, Self::Error>;
async fn get_merchant_key_store_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
key: &Secret<Vec<u8>>,
) -> CustomResult<MerchantKeyStore, Self::Error>;
@@ -94,14 +92,12 @@ pub trait MerchantKeyStoreInterface {
#[cfg(feature = "olap")]
async fn list_multiple_key_stores(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
key: &Secret<Vec<u8>>,
) -> CustomResult<Vec<MerchantKeyStore>, Self::Error>;
async fn get_all_key_stores(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
from: u32,
to: u32,
diff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rs
index bf11615bde..dbdba4476b 100644
--- a/crates/hyperswitch_domain_models/src/payment_methods.rs
+++ b/crates/hyperswitch_domain_models/src/payment_methods.rs
@@ -807,7 +807,6 @@ pub trait PaymentMethodInterface {
#[cfg(feature = "v1")]
async fn find_payment_method(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
payment_method_id: &str,
storage_scheme: MerchantStorageScheme,
@@ -816,7 +815,6 @@ pub trait PaymentMethodInterface {
#[cfg(feature = "v2")]
async fn find_payment_method(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
payment_method_id: &id_type::GlobalPaymentMethodId,
storage_scheme: MerchantStorageScheme,
@@ -825,7 +823,6 @@ pub trait PaymentMethodInterface {
#[cfg(feature = "v1")]
async fn find_payment_method_by_locker_id(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
locker_id: &str,
storage_scheme: MerchantStorageScheme,
@@ -834,7 +831,6 @@ pub trait PaymentMethodInterface {
#[cfg(feature = "v1")]
async fn find_payment_method_by_customer_id_merchant_id_list(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -845,7 +841,6 @@ pub trait PaymentMethodInterface {
#[cfg(feature = "v2")]
async fn find_payment_method_list_by_global_customer_id(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
id: &id_type::GlobalCustomerId,
limit: Option<i64>,
@@ -855,7 +850,6 @@ pub trait PaymentMethodInterface {
#[allow(clippy::too_many_arguments)]
async fn find_payment_method_by_customer_id_merchant_id_status(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -868,7 +862,6 @@ pub trait PaymentMethodInterface {
#[allow(clippy::too_many_arguments)]
async fn find_payment_method_by_global_customer_id_merchant_id_status(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::GlobalCustomerId,
merchant_id: &id_type::MerchantId,
@@ -893,7 +886,6 @@ pub trait PaymentMethodInterface {
async fn insert_payment_method(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: PaymentMethod,
storage_scheme: MerchantStorageScheme,
@@ -901,7 +893,6 @@ pub trait PaymentMethodInterface {
async fn update_payment_method(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: PaymentMethod,
payment_method_update: PaymentMethodUpdate,
@@ -911,7 +902,6 @@ pub trait PaymentMethodInterface {
#[cfg(feature = "v2")]
async fn delete_payment_method(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: PaymentMethod,
) -> CustomResult<PaymentMethod, Self::Error>;
@@ -919,7 +909,6 @@ pub trait PaymentMethodInterface {
#[cfg(feature = "v2")]
async fn find_payment_method_by_fingerprint_id(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
fingerprint_id: &str,
) -> CustomResult<PaymentMethod, Self::Error>;
@@ -927,7 +916,6 @@ pub trait PaymentMethodInterface {
#[cfg(feature = "v1")]
async fn delete_payment_method_by_merchant_id_payment_method_id(
&self,
- state: &keymanager::KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &id_type::MerchantId,
payment_method_id: &str,
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
index 89956c3f8f..cd277af5fc 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
@@ -78,7 +78,6 @@ pub trait PaymentAttemptInterface {
#[cfg(feature = "v2")]
async fn insert_payment_attempt(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_attempt: PaymentAttempt,
storage_scheme: storage_enums::MerchantStorageScheme,
@@ -95,7 +94,6 @@ pub trait PaymentAttemptInterface {
#[cfg(feature = "v2")]
async fn update_payment_attempt(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
this: PaymentAttempt,
payment_attempt: PaymentAttemptUpdate,
@@ -130,7 +128,6 @@ pub trait PaymentAttemptInterface {
#[cfg(feature = "v2")]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_id: &id_type::GlobalPaymentId,
storage_scheme: storage_enums::MerchantStorageScheme,
@@ -147,7 +144,6 @@ pub trait PaymentAttemptInterface {
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_profile_id_connector_transaction_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &id_type::ProfileId,
connector_transaction_id: &str,
@@ -174,7 +170,6 @@ pub trait PaymentAttemptInterface {
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
attempt_id: &id_type::GlobalAttemptId,
storage_scheme: storage_enums::MerchantStorageScheme,
@@ -183,7 +178,6 @@ pub trait PaymentAttemptInterface {
#[cfg(feature = "v2")]
async fn find_payment_attempts_by_payment_intent_id(
&self,
- state: &KeyManagerState,
payment_id: &id_type::GlobalPaymentId,
merchant_key_store: &MerchantKeyStore,
storage_scheme: common_enums::MerchantStorageScheme,
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
index eb1b09c1e3..4d3a39a71a 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
@@ -48,7 +48,6 @@ pub trait PaymentIntentInterface {
type Error;
async fn update_payment_intent(
&self,
- state: &KeyManagerState,
this: PaymentIntent,
payment_intent: PaymentIntentUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -57,7 +56,6 @@ pub trait PaymentIntentInterface {
async fn insert_payment_intent(
&self,
- state: &KeyManagerState,
new: PaymentIntent,
merchant_key_store: &MerchantKeyStore,
storage_scheme: common_enums::MerchantStorageScheme,
@@ -66,7 +64,6 @@ pub trait PaymentIntentInterface {
#[cfg(feature = "v1")]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
- state: &KeyManagerState,
payment_id: &id_type::PaymentId,
merchant_id: &id_type::MerchantId,
merchant_key_store: &MerchantKeyStore,
@@ -75,7 +72,6 @@ pub trait PaymentIntentInterface {
#[cfg(feature = "v2")]
async fn find_payment_intent_by_merchant_reference_id_profile_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &id_type::PaymentReferenceId,
profile_id: &id_type::ProfileId,
merchant_key_store: &MerchantKeyStore,
@@ -85,7 +81,6 @@ pub trait PaymentIntentInterface {
#[cfg(feature = "v2")]
async fn find_payment_intent_by_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalPaymentId,
merchant_key_store: &MerchantKeyStore,
storage_scheme: common_enums::MerchantStorageScheme,
@@ -94,7 +89,6 @@ pub trait PaymentIntentInterface {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn filter_payment_intent_by_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
filters: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
@@ -104,7 +98,6 @@ pub trait PaymentIntentInterface {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn filter_payment_intents_by_time_range_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
time_range: &common_utils::types::TimeRange,
merchant_key_store: &MerchantKeyStore,
@@ -122,7 +115,6 @@ pub trait PaymentIntentInterface {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn get_filtered_payment_intents_attempt(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
constraints: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
@@ -132,7 +124,6 @@ pub trait PaymentIntentInterface {
#[cfg(all(feature = "v2", feature = "olap"))]
async fn get_filtered_payment_intents_attempt(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
constraints: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
diff --git a/crates/hyperswitch_domain_models/src/subscription.rs b/crates/hyperswitch_domain_models/src/subscription.rs
index e73db80cae..2c3a36aac2 100644
--- a/crates/hyperswitch_domain_models/src/subscription.rs
+++ b/crates/hyperswitch_domain_models/src/subscription.rs
@@ -196,14 +196,12 @@ pub trait SubscriptionInterface {
type Error;
async fn insert_subscription_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_new: Subscription,
) -> CustomResult<Subscription, Self::Error>;
async fn find_by_merchant_id_subscription_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
subscription_id: String,
@@ -211,7 +209,6 @@ pub trait SubscriptionInterface {
async fn update_subscription_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
subscription_id: String,
diff --git a/crates/payment_methods/src/core/migration/payment_methods.rs b/crates/payment_methods/src/core/migration/payment_methods.rs
index 26437887ef..8ab78ceff4 100644
--- a/crates/payment_methods/src/core/migration/payment_methods.rs
+++ b/crates/payment_methods/src/core/migration/payment_methods.rs
@@ -544,7 +544,6 @@ pub async fn skip_locker_call_and_migrate_payment_method(
let customer = db
.find_customer_by_customer_id_merchant_id(
- &state.into(),
&customer_id,
&merchant_id,
platform.get_processor().get_key_store(),
@@ -579,7 +578,6 @@ pub async fn skip_locker_call_and_migrate_payment_method(
let response = db
.insert_payment_method(
- &state.into(),
platform.get_processor().get_key_store(),
domain_pm::PaymentMethod {
customer_id: customer_id.to_owned(),
diff --git a/crates/payment_methods/src/state.rs b/crates/payment_methods/src/state.rs
index 225b04a09a..713eaa5e67 100644
--- a/crates/payment_methods/src/state.rs
+++ b/crates/payment_methods/src/state.rs
@@ -50,11 +50,9 @@ impl PaymentMethodsState {
payment_method_id: String,
) -> CustomResult<pm_domain::PaymentMethod, errors::StorageError> {
let db = &*self.store;
- let key_manager_state = &(self.key_manager_state).clone();
match db
.find_payment_method(
- key_manager_state,
key_store,
&payment_method_id,
merchant_account.storage_scheme,
@@ -63,7 +61,6 @@ impl PaymentMethodsState {
{
Err(err) if err.current_context().is_db_not_found() => {
db.find_payment_method_by_locker_id(
- key_manager_state,
key_store,
&payment_method_id,
merchant_account.storage_scheme,
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index b60854b521..2ed212f022 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -193,7 +193,6 @@ pub async fn create_merchant_account(
use common_utils::{keymanager, types::keymanager::EncryptionTransferRequest};
let db = state.store.as_ref();
-
let key = services::generate_aes256_key()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to generate aes 256 key")?;
@@ -247,17 +246,13 @@ pub async fn create_merchant_account(
org_data_from_auth,
)
.await?;
- let key_manager_state = &(&state).into();
- db.insert_merchant_key_store(
- key_manager_state,
- key_store.clone(),
- &master_key.to_vec().into(),
- )
- .await
- .to_duplicate_response(errors::ApiErrorResponse::DuplicateMerchantAccount)?;
+
+ db.insert_merchant_key_store(key_store.clone(), &master_key.to_vec().into())
+ .await
+ .to_duplicate_response(errors::ApiErrorResponse::DuplicateMerchantAccount)?;
let merchant_account = db
- .insert_merchant(key_manager_state, domain_merchant_account, &key_store)
+ .insert_merchant(domain_merchant_account, &key_store)
.await
.to_duplicate_response(errors::ApiErrorResponse::DuplicateMerchantAccount)?;
@@ -386,10 +381,7 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {
OrganizationType::Platform => {
let accounts = state
.store
- .list_merchant_accounts_by_organization_id(
- &state.into(),
- &organization.get_organization_id(),
- )
+ .list_merchant_accounts_by_organization_id(&organization.get_organization_id())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -783,10 +775,7 @@ pub async fn list_merchant_account(
) -> RouterResponse<Vec<api::MerchantAccountResponse>> {
let merchant_accounts = state
.store
- .list_merchant_accounts_by_organization_id(
- &(&state).into(),
- &organization_id.organization_id,
- )
+ .list_merchant_accounts_by_organization_id(&organization_id.organization_id)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -820,7 +809,7 @@ pub async fn list_merchant_account(
}
let merchant_accounts = state
.store
- .list_merchant_accounts_by_organization_id(&(&state).into(), &req.organization_id)
+ .list_merchant_accounts_by_organization_id(&req.organization_id)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -844,10 +833,8 @@ pub async fn get_merchant_account(
_profile_id: Option<id_type::ProfileId>,
) -> RouterResponse<api::MerchantAccountResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&req.merchant_id,
&db.get_master_key().to_vec().into(),
)
@@ -855,7 +842,7 @@ pub async fn get_merchant_account(
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &req.merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&req.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -876,9 +863,8 @@ pub async fn create_profile_from_business_labels(
merchant_id: &id_type::MerchantId,
new_business_details: Vec<admin_types::PrimaryBusinessDetails>,
) -> RouterResult<()> {
- let key_manager_state = &state.into();
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -920,14 +906,9 @@ pub async fn create_profile_from_business_labels(
// If a profile is created, then unset the default profile
if profile_create_result.is_ok() && merchant_account.default_profile.is_some() {
let unset_default_profile = domain::MerchantAccountUpdate::UnsetDefaultProfile;
- db.update_merchant(
- key_manager_state,
- merchant_account.clone(),
- unset_default_profile,
- key_store,
- )
- .await
- .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
+ db.update_merchant(merchant_account.clone(), unset_default_profile, key_store)
+ .await
+ .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
}
}
@@ -958,7 +939,6 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {
let key = key_store.key.get_inner().peek();
let db = state.store.as_ref();
-
let primary_business_details = self.get_primary_details_as_value().change_context(
errors::ApiErrorResponse::InvalidDataValue {
field_name: "primary_business_details",
@@ -998,7 +978,6 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {
// Validate whether profile_id passed in request is valid and is linked to the merchant
core_utils::validate_and_get_business_profile(
state.store.as_ref(),
- key_manager_state,
key_store,
Some(profile_id),
merchant_id,
@@ -1156,13 +1135,8 @@ pub async fn merchant_account_update(
req: api::MerchantAccountUpdate,
) -> RouterResponse<api::MerchantAccountResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- merchant_id,
- &db.get_master_key().to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(merchant_id, &db.get_master_key().to_vec().into())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -1173,7 +1147,6 @@ pub async fn merchant_account_update(
let response = db
.update_specific_fields_in_merchant(
- key_manager_state,
merchant_id,
merchant_account_storage_object,
&key_store,
@@ -1194,10 +1167,8 @@ pub async fn merchant_account_delete(
) -> RouterResponse<api::MerchantAccountDeleteResponse> {
let mut is_deleted = false;
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let merchant_key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -1205,7 +1176,7 @@ pub async fn merchant_account_delete(
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &merchant_key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &merchant_key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -1294,7 +1265,7 @@ async fn validate_merchant_id(
key_store: &domain::MerchantKeyStore,
) -> RouterResult<domain::MerchantAccount> {
let db = &*state.store;
- db.find_merchant_account_by_merchant_id(&state.into(), merchant_id, key_store)
+ db.find_merchant_account_by_merchant_id(merchant_id, key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
}
@@ -1379,7 +1350,6 @@ struct PMAuthConfigValidation<'a> {
merchant_id: &'a id_type::MerchantId,
profile_id: &'a id_type::ProfileId,
key_store: &'a domain::MerchantKeyStore,
- key_manager_state: &'a KeyManagerState,
}
impl PMAuthConfigValidation<'_> {
@@ -1395,7 +1365,6 @@ impl PMAuthConfigValidation<'_> {
let all_mcas = self
.db
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- self.key_manager_state,
self.merchant_id,
true,
self.key_store,
@@ -1692,7 +1661,6 @@ trait MerchantConnectorAccountUpdateBridge {
merchant_id: &id_type::MerchantId,
merchant_connector_id: &id_type::MerchantConnectorAccountId,
key_store: &domain::MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> RouterResult<domain::MerchantConnectorAccount>;
async fn create_domain_model_from_request(
@@ -1713,15 +1681,10 @@ impl MerchantConnectorAccountUpdateBridge for api_models::admin::MerchantConnect
_merchant_id: &id_type::MerchantId,
merchant_connector_id: &id_type::MerchantConnectorAccountId,
key_store: &domain::MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> RouterResult<domain::MerchantConnectorAccount> {
- db.find_merchant_connector_account_by_id(
- key_manager_state,
- merchant_connector_id,
- key_store,
- )
- .await
- .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
+ db.find_merchant_connector_account_by_id(merchant_connector_id, key_store)
+ .await
+ .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
}
async fn create_domain_model_from_request(
@@ -1771,7 +1734,6 @@ impl MerchantConnectorAccountUpdateBridge for api_models::admin::MerchantConnect
merchant_id: platform.get_processor().get_account().get_id(),
profile_id: &mca.profile_id.clone(),
key_store: platform.get_processor().get_key_store(),
- key_manager_state,
};
pm_auth_config_validation.validate_pm_auth_config().await?;
@@ -1876,10 +1838,8 @@ impl MerchantConnectorAccountUpdateBridge for api_models::admin::MerchantConnect
merchant_id: &id_type::MerchantId,
merchant_connector_id: &id_type::MerchantConnectorAccountId,
key_store: &domain::MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> RouterResult<domain::MerchantConnectorAccount> {
db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
merchant_connector_id,
key_store,
@@ -2058,7 +2018,6 @@ trait MerchantConnectorAccountCreateBridge {
self,
platform: &domain::Platform,
db: &dyn StorageInterface,
- key_manager_state: &KeyManagerState,
) -> RouterResult<domain::Profile>;
}
@@ -2204,14 +2163,12 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {
self,
platform: &domain::Platform,
db: &dyn StorageInterface,
- key_manager_state: &KeyManagerState,
) -> RouterResult<domain::Profile> {
let profile_id = self.profile_id;
// Check whether this profile belongs to the merchant
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -2411,7 +2368,6 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {
self,
platform: &domain::Platform,
db: &dyn StorageInterface,
- key_manager_state: &KeyManagerState,
) -> RouterResult<domain::Profile> {
match self.profile_id.or(platform
.get_processor()
@@ -2424,7 +2380,6 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -2442,7 +2397,6 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {
let profile_name = format!("{business_country}_{business_label}");
let business_profile = db
.find_business_profile_by_profile_name_merchant_id(
- key_manager_state,
platform.get_processor().get_key_store(),
&profile_name,
platform.get_processor().get_account().get_id(),
@@ -2498,7 +2452,7 @@ pub async fn create_connector(
let business_profile = req
.clone()
- .validate_and_get_business_profile(&platform, store, key_manager_state)
+ .validate_and_get_business_profile(&platform, store)
.await?;
#[cfg(feature = "v2")]
@@ -2522,7 +2476,6 @@ pub async fn create_connector(
merchant_id,
profile_id: business_profile.get_id(),
key_store: platform.get_processor().get_key_store(),
- key_manager_state,
};
pm_auth_config_validation.validate_pm_auth_config().await?;
@@ -2537,7 +2490,6 @@ pub async fn create_connector(
state
.store
.update_specific_fields_in_merchant(
- key_manager_state,
merchant_id,
storage::MerchantAccountUpdate::ModifiedAtUpdate,
platform.get_processor().get_key_store(),
@@ -2559,7 +2511,6 @@ pub async fn create_connector(
let mca = state
.store
.insert_merchant_connector_account(
- key_manager_state,
merchant_connector_account.clone(),
platform.get_processor().get_key_store(),
)
@@ -2635,7 +2586,6 @@ async fn validate_pm_auth(
let all_mcas = state
.store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
merchant_id,
true,
platform.get_processor().get_key_store(),
@@ -2678,10 +2628,8 @@ pub async fn retrieve_connector(
merchant_connector_id: id_type::MerchantConnectorAccountId,
) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&store.get_master_key().to_vec().into(),
)
@@ -2689,13 +2637,12 @@ pub async fn retrieve_connector(
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let _merchant_account = store
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let mca = store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&merchant_id,
&merchant_connector_id,
&key_store,
@@ -2718,16 +2665,11 @@ pub async fn retrieve_connector(
id: id_type::MerchantConnectorAccountId,
) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
let merchant_id = platform.get_processor().get_account().get_id();
let mca = store
- .find_merchant_connector_account_by_id(
- key_manager_state,
- &id,
- platform.get_processor().get_key_store(),
- )
+ .find_merchant_connector_account_by_id(&id, platform.get_processor().get_key_store())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
id: id.clone().get_string_repr().to_string(),
@@ -2757,10 +2699,8 @@ pub async fn list_connectors_for_a_profile(
profile_id: id_type::ProfileId,
) -> RouterResponse<Vec<api_models::admin::MerchantConnectorListResponse>> {
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
-
let merchant_connector_accounts = store
- .list_connector_account_by_profile_id(key_manager_state, &profile_id, &key_store)
+ .list_connector_account_by_profile_id(&profile_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?;
let mut response = vec![];
@@ -2778,10 +2718,8 @@ pub async fn list_payment_connectors(
profile_id_list: Option<Vec<id_type::ProfileId>>,
) -> RouterResponse<Vec<api_models::admin::MerchantConnectorListResponse>> {
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&store.get_master_key().to_vec().into(),
)
@@ -2790,13 +2728,12 @@ pub async fn list_payment_connectors(
// Validate merchant account
store
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let merchant_connector_accounts = store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- key_manager_state,
&merchant_id,
true,
&key_store,
@@ -2827,28 +2764,18 @@ pub async fn update_connector(
let db = state.store.as_ref();
let key_manager_state = &(&state).into();
let key_store = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &db.get_master_key().to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let mca = req
.clone()
- .get_merchant_connector_account_from_id(
- db,
- &merchant_id,
- merchant_connector_id,
- &key_store,
- key_manager_state,
- )
+ .get_merchant_connector_account_from_id(db, &merchant_id, merchant_connector_id, &key_store)
.await?;
core_utils::validate_profile_id_from_auth_layer(profile_id, &mca)?;
@@ -2868,26 +2795,20 @@ pub async fn update_connector(
let request_connector_label = req.connector_label;
- let updated_mca = db
- .update_merchant_connector_account(
- key_manager_state,
- mca.clone(),
- payment_connector.into(),
- &key_store,
- )
- .await
- .change_context(
- errors::ApiErrorResponse::DuplicateMerchantConnectorAccount {
- profile_id: profile_id.get_string_repr().to_owned(),
- connector_label: request_connector_label.unwrap_or_default(),
- },
- )
- .attach_printable_lazy(|| {
- format!(
- "Failed while updating MerchantConnectorAccount: id: {merchant_connector_id:?}",
-
+ let updated_mca =
+ db.update_merchant_connector_account(mca.clone(), payment_connector.into(), &key_store)
+ .await
+ .change_context(
+ errors::ApiErrorResponse::DuplicateMerchantConnectorAccount {
+ profile_id: profile_id.get_string_repr().to_owned(),
+ connector_label: request_connector_label.unwrap_or_default(),
+ },
)
- })?;
+ .attach_printable_lazy(|| {
+ format!(
+ "Failed while updating MerchantConnectorAccount: id: {merchant_connector_id:?}",
+ )
+ })?;
// redact cgraph cache on connector updation
redact_cgraph_cache(&state, &merchant_id, &profile_id).await?;
@@ -2932,24 +2853,18 @@ pub async fn delete_connector(
merchant_connector_id: id_type::MerchantConnectorAccountId,
) -> RouterResponse<api::MerchantConnectorDeleteResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &db.get_master_key().to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let _merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&merchant_id,
&merchant_connector_id,
&key_store,
@@ -3011,11 +2926,7 @@ pub async fn delete_connector(
let merchant_id = platform.get_processor().get_account().get_id();
let mca = db
- .find_merchant_connector_account_by_id(
- key_manager_state,
- &id,
- platform.get_processor().get_key_store(),
- )
+ .find_merchant_connector_account_by_id(&id, platform.get_processor().get_key_store())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
id: id.clone().get_string_repr().to_string(),
@@ -3042,7 +2953,6 @@ pub async fn delete_connector(
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
&mca.profile_id,
)
@@ -3084,19 +2994,14 @@ pub async fn kv_for_merchant(
enable: bool,
) -> RouterResponse<api_models::admin::ToggleKVResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &db.get_master_key().to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
// check if the merchant account exists
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -3113,7 +3018,6 @@ pub async fn kv_for_merchant(
}
db.update_merchant(
- key_manager_state,
merchant_account,
storage::MerchantAccountUpdate::StorageSchemeUpdate {
storage_scheme: MerchantStorageScheme::RedisKv,
@@ -3124,7 +3028,6 @@ pub async fn kv_for_merchant(
}
(false, MerchantStorageScheme::RedisKv) => {
db.update_merchant(
- key_manager_state,
merchant_account,
storage::MerchantAccountUpdate::StorageSchemeUpdate {
storage_scheme: MerchantStorageScheme::PostgresOnly,
@@ -3187,19 +3090,14 @@ pub async fn check_merchant_account_kv_status(
merchant_id: id_type::MerchantId,
) -> RouterResponse<api_models::admin::ToggleKVResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &db.get_master_key().to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
// check if the merchant account exists
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -3252,7 +3150,7 @@ pub async fn create_and_insert_business_profile(
state
.store
- .insert_business_profile(&state.into(), key_store, business_profile_new)
+ .insert_business_profile(key_store, business_profile_new)
.await
.to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError {
message: format!(
@@ -3690,8 +3588,6 @@ pub async fn create_profile(
platform: domain::Platform,
) -> RouterResponse<api_models::admin::ProfileResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
-
#[cfg(feature = "v1")]
let business_profile = request
.create_domain_model_from_request(&state, &platform)
@@ -3709,11 +3605,7 @@ pub async fn create_profile(
let profile_id = business_profile.get_id().to_owned();
let business_profile = db
- .insert_business_profile(
- key_manager_state,
- platform.get_processor().get_key_store(),
- business_profile,
- )
+ .insert_business_profile(platform.get_processor().get_key_store(), business_profile)
.await
.to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError {
message: format!(
@@ -3732,7 +3624,6 @@ pub async fn create_profile(
{
let unset_default_profile = domain::MerchantAccountUpdate::UnsetDefaultProfile;
db.update_merchant(
- key_manager_state,
platform.get_processor().get_account().clone(),
unset_default_profile,
platform.get_processor().get_key_store(),
@@ -3756,15 +3647,11 @@ pub async fn list_profile(
) -> RouterResponse<Vec<api_models::admin::ProfileResponse>> {
let db = state.store.as_ref();
let key_store = db
- .get_merchant_key_store_by_merchant_id(
- &(&state).into(),
- &merchant_id,
- &db.get_master_key().to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let profiles = db
- .list_profile_by_merchant_id(&(&state).into(), &key_store, &merchant_id)
+ .list_profile_by_merchant_id(&key_store, &merchant_id)
.await
.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?
.clone();
@@ -3787,14 +3674,8 @@ pub async fn retrieve_profile(
key_store: domain::MerchantKeyStore,
) -> RouterResponse<api_models::admin::ProfileResponse> {
let db = state.store.as_ref();
-
let business_profile = db
- .find_business_profile_by_merchant_id_profile_id(
- &(&state).into(),
- &key_store,
- &merchant_id,
- &profile_id,
- )
+ .find_business_profile_by_merchant_id_profile_id(&key_store, &merchant_id, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -4212,15 +4093,8 @@ pub async fn update_profile(
request: api::ProfileUpdate,
) -> RouterResponse<api::ProfileResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
-
let business_profile = db
- .find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
- &key_store,
- &merchant_id,
- profile_id,
- )
+ .find_business_profile_by_merchant_id_profile_id(&key_store, &merchant_id, profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -4231,12 +4105,7 @@ pub async fn update_profile(
.await?;
let updated_business_profile = db
- .update_profile_by_profile_id(
- key_manager_state,
- &key_store,
- business_profile,
- profile_update,
- )
+ .update_profile_by_profile_id(&key_store, business_profile, profile_update)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -4300,15 +4169,10 @@ impl ProfileWrapper {
let profile = self.profile;
- db.update_profile_by_profile_id(
- key_manager_state,
- merchant_key_store,
- profile,
- profile_update,
- )
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to update routing algorithm ref in business profile")?;
+ db.update_profile_by_profile_id(merchant_key_store, profile, profile_update)
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to update routing algorithm ref in business profile")?;
storage_impl::redis::cache::redact_from_redis_and_publish(
db.get_cache_store().as_ref(),
@@ -4376,15 +4240,10 @@ impl ProfileWrapper {
default_fallback_routing: Some(default_fallback_routing),
};
- db.update_profile_by_profile_id(
- key_manager_state,
- merchant_key_store,
- self.profile,
- profile_update,
- )
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to update routing algorithm ref in business profile")?;
+ db.update_profile_by_profile_id(merchant_key_store, self.profile, profile_update)
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to update routing algorithm ref in business profile")?;
Ok(())
}
pub async fn update_revenue_recovery_algorithm_under_profile(
@@ -4403,17 +4262,12 @@ impl ProfileWrapper {
revenue_recovery_retry_algorithm_data: Some(recovery_algorithm_data),
};
- db.update_profile_by_profile_id(
- key_manager_state,
- merchant_key_store,
- self.profile,
- profile_update,
- )
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable(
- "Failed to update revenue recovery retry algorithm in business profile",
- )?;
+ db.update_profile_by_profile_id(merchant_key_store, self.profile, profile_update)
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable(
+ "Failed to update revenue recovery retry algorithm in business profile",
+ )?;
Ok(())
}
}
@@ -4425,11 +4279,8 @@ pub async fn extended_card_info_toggle(
ext_card_info_choice: admin_types::ExtendedCardInfoChoice,
) -> RouterResponse<admin_types::ExtendedCardInfoChoice> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
-
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -4438,7 +4289,7 @@ pub async fn extended_card_info_toggle(
.attach_printable("Error while fetching the key store by merchant_id")?;
let business_profile = db
- .find_business_profile_by_profile_id(key_manager_state, &key_store, profile_id)
+ .find_business_profile_by_profile_id(&key_store, profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -4453,16 +4304,11 @@ pub async fn extended_card_info_toggle(
is_extended_card_info_enabled: ext_card_info_choice.enabled,
};
- db.update_profile_by_profile_id(
- key_manager_state,
- &key_store,
- business_profile,
- profile_update,
- )
- .await
- .to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
- id: profile_id.get_string_repr().to_owned(),
- })?;
+ db.update_profile_by_profile_id(&key_store, business_profile, profile_update)
+ .await
+ .to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
+ id: profile_id.get_string_repr().to_owned(),
+ })?;
}
Ok(service_api::ApplicationResponse::Json(ext_card_info_choice))
@@ -4475,11 +4321,8 @@ pub async fn connector_agnostic_mit_toggle(
connector_agnostic_mit_choice: admin_types::ConnectorAgnosticMitChoice,
) -> RouterResponse<admin_types::ConnectorAgnosticMitChoice> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
-
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -4488,7 +4331,7 @@ pub async fn connector_agnostic_mit_toggle(
.attach_printable("Error while fetching the key store by merchant_id")?;
let business_profile = db
- .find_business_profile_by_profile_id(key_manager_state, &key_store, profile_id)
+ .find_business_profile_by_profile_id(&key_store, profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -4507,16 +4350,11 @@ pub async fn connector_agnostic_mit_toggle(
is_connector_agnostic_mit_enabled: connector_agnostic_mit_choice.enabled,
};
- db.update_profile_by_profile_id(
- key_manager_state,
- &key_store,
- business_profile,
- profile_update,
- )
- .await
- .to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
- id: profile_id.get_string_repr().to_owned(),
- })?;
+ db.update_profile_by_profile_id(&key_store, business_profile, profile_update)
+ .await
+ .to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
+ id: profile_id.get_string_repr().to_owned(),
+ })?;
}
Ok(service_api::ApplicationResponse::Json(
@@ -4790,23 +4628,17 @@ pub async fn enable_platform_account(
merchant_id: id_type::MerchantId,
) -> RouterResponse<()> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &db.get_master_key().to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
db.update_merchant(
- key_manager_state,
merchant_account,
storage::MerchantAccountUpdate::ToPlatformAccount,
&key_store,
diff --git a/crates/router/src/core/apple_pay_certificates_migration.rs b/crates/router/src/core/apple_pay_certificates_migration.rs
index 21f38e5956..106e738ca3 100644
--- a/crates/router/src/core/apple_pay_certificates_migration.rs
+++ b/crates/router/src/core/apple_pay_certificates_migration.rs
@@ -29,12 +29,10 @@ pub async fn apple_pay_certificates_migration(
let mut migration_successful_merchant_ids = vec![];
let mut migration_failed_merchant_ids = vec![];
- let key_manager_state = &(&state).into();
for merchant_id in merchant_id_list {
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -43,7 +41,6 @@ pub async fn apple_pay_certificates_migration(
let merchant_connector_accounts = db
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- key_manager_state,
merchant_id,
true,
&key_store,
diff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rs
index fe2bb00d86..7c7d301467 100644
--- a/crates/router/src/core/blocklist/utils.rs
+++ b/crates/router/src/core/blocklist/utils.rs
@@ -396,7 +396,6 @@ where
if should_payment_be_blocked {
// Update db for attempt and intent status.
db.update_payment_intent(
- &state.into(),
payment_data.payment_intent.clone(),
storage::PaymentIntentUpdate::RejectUpdate {
status: common_enums::IntentStatus::Failed,
diff --git a/crates/router/src/core/conditional_config.rs b/crates/router/src/core/conditional_config.rs
index ca60896727..3d39b565d3 100644
--- a/crates/router/src/core/conditional_config.rs
+++ b/crates/router/src/core/conditional_config.rs
@@ -45,12 +45,7 @@ pub async fn upsert_conditional_config(
three_ds_decision_manager_config: decision_manager_record,
};
let updated_profile = db
- .update_profile_by_profile_id(
- key_manager_state,
- &key_store,
- profile,
- business_profile_update,
- )
+ .update_profile_by_profile_id(&key_store, profile, business_profile_update)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update decision manager record in business profile")?;
diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rs
index d3c911df11..0dad3b1bcf 100644
--- a/crates/router/src/core/customers.rs
+++ b/crates/router/src/core/customers.rs
@@ -57,7 +57,6 @@ pub async fn create_customer(
merchant_id,
merchant_account: platform.get_processor().get_account(),
key_store: platform.get_processor().get_key_store(),
- key_manager_state,
};
// We first need to validate whether the customer with the given customer id already exists
@@ -84,7 +83,6 @@ pub async fn create_customer(
let customer = db
.insert_customer(
domain_customer,
- key_manager_state,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
)
@@ -145,7 +143,6 @@ impl CustomerCreateBridge for customers::CustomerRequest {
customer_id: merchant_reference_id.as_ref(),
storage_scheme: platform.get_processor().get_account().storage_scheme,
key_store: platform.get_processor().get_key_store(),
- key_manager_state,
state,
};
@@ -368,7 +365,6 @@ struct AddressStructForDbEntry<'a> {
customer_id: Option<&'a id_type::CustomerId>,
storage_scheme: common_enums::MerchantStorageScheme,
key_store: &'a domain::MerchantKeyStore,
- key_manager_state: &'a KeyManagerState,
state: &'a SessionState,
}
@@ -400,7 +396,7 @@ impl AddressStructForDbEntry<'_> {
encrypted_customer_address
.async_map(|encrypt_add| async {
- db.insert_address_for_customers(self.key_manager_state, encrypt_add, self.key_store)
+ db.insert_address_for_customers(encrypt_add, self.key_store)
.await
.switch()
.attach_printable("Failed while inserting new address")
@@ -415,7 +411,6 @@ struct MerchantReferenceIdForCustomer<'a> {
merchant_id: &'a id_type::MerchantId,
merchant_account: &'a domain::MerchantAccount,
key_store: &'a domain::MerchantKeyStore,
- key_manager_state: &'a KeyManagerState,
}
#[cfg(feature = "v1")]
@@ -440,7 +435,6 @@ impl<'a> MerchantReferenceIdForCustomer<'a> {
) -> Result<(), error_stack::Report<errors::CustomersErrorResponse>> {
match db
.find_customer_by_customer_id_merchant_id(
- self.key_manager_state,
cus,
self.merchant_id,
self.key_store,
@@ -487,7 +481,6 @@ impl<'a> MerchantReferenceIdForCustomer<'a> {
) -> Result<(), error_stack::Report<errors::CustomersErrorResponse>> {
match db
.find_customer_by_merchant_reference_id_merchant_id(
- self.key_manager_state,
merchant_ref,
self.merchant_id,
self.key_store,
@@ -518,11 +511,9 @@ pub async fn retrieve_customer(
customer_id: id_type::CustomerId,
) -> errors::CustomerResponse<customers::CustomerResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let response = db
.find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
- key_manager_state,
&customer_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -534,13 +525,9 @@ pub async fn retrieve_customer(
let address = match &response.address_id {
Some(address_id) => Some(api_models::payments::AddressDetails::from(
- db.find_address_by_address_id(
- key_manager_state,
- address_id,
- platform.get_processor().get_key_store(),
- )
- .await
- .switch()?,
+ db.find_address_by_address_id(address_id, platform.get_processor().get_key_store())
+ .await
+ .switch()?,
)),
None => None,
};
@@ -557,11 +544,9 @@ pub async fn retrieve_customer(
id: id_type::GlobalCustomerId,
) -> errors::CustomerResponse<customers::CustomerResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let response = db
.find_customer_by_global_id(
- key_manager_state,
&id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -594,12 +579,7 @@ pub async fn list_customers(
};
let domain_customers = db
- .list_customers_by_merchant_id(
- &(&state).into(),
- &merchant_id,
- &key_store,
- customer_list_constraints,
- )
+ .list_customers_by_merchant_id(&merchant_id, &key_store, customer_list_constraints)
.await
.switch()?;
@@ -638,7 +618,6 @@ pub async fn list_customers_with_count(
let domain_customers = db
.list_customers_by_merchant_id_with_count(
- &(&state).into(),
&merchant_id,
&key_store,
customer_list_constraints,
@@ -693,7 +672,6 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {
) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {
let customer_orig = db
.find_customer_by_global_id(
- key_manager_state,
self,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -713,7 +691,6 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {
match db
.find_payment_method_list_by_global_customer_id(
- key_manager_state,
platform.get_processor().get_key_store(),
self,
None,
@@ -802,7 +779,6 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {
}));
db.update_customer_by_global_id(
- key_manager_state,
self,
customer_orig,
updated_customer,
@@ -861,7 +837,6 @@ impl CustomerDeleteBridge for id_type::CustomerId {
) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {
let customer_orig = db
.find_customer_by_customer_id_merchant_id(
- key_manager_state,
self,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -886,7 +861,6 @@ impl CustomerDeleteBridge for id_type::CustomerId {
match db
.find_payment_method_by_customer_id_merchant_id_list(
- key_manager_state,
platform.get_processor().get_key_store(),
self,
platform.get_processor().get_account().get_id(),
@@ -924,7 +898,6 @@ impl CustomerDeleteBridge for id_type::CustomerId {
}
db.delete_payment_method_by_merchant_id_payment_method_id(
- key_manager_state,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().get_id(),
&pm.payment_method_id,
@@ -999,7 +972,6 @@ impl CustomerDeleteBridge for id_type::CustomerId {
match db
.update_address_by_merchant_id_customer_id(
- key_manager_state,
self,
platform.get_processor().get_account().get_id(),
update_address,
@@ -1044,7 +1016,6 @@ impl CustomerDeleteBridge for id_type::CustomerId {
};
db.update_customer_by_customer_id_merchant_id(
- key_manager_state,
self.clone(),
platform.get_processor().get_account().get_id().to_owned(),
customer_orig,
@@ -1081,7 +1052,6 @@ pub async fn update_customer(
merchant_reference_id: &update_customer.customer_id,
merchant_account: platform.get_processor().get_account(),
key_store: platform.get_processor().get_key_store(),
- key_manager_state,
};
#[cfg(feature = "v2")]
@@ -1136,7 +1106,6 @@ struct AddressStructForDbUpdate<'a> {
update_customer: &'a customers::CustomerUpdateRequest,
merchant_account: &'a domain::MerchantAccount,
key_store: &'a domain::MerchantKeyStore,
- key_manager_state: &'a KeyManagerState,
state: &'a SessionState,
domain_customer: &'a domain::Customer,
}
@@ -1164,15 +1133,10 @@ impl AddressStructForDbUpdate<'_> {
.switch()
.attach_printable("Failed while encrypting Address while Update")?;
Some(
- db.update_address(
- self.key_manager_state,
- address_id,
- update_address,
- self.key_store,
- )
- .await
- .switch()
- .attach_printable(format!(
+ db.update_address(address_id, update_address, self.key_store)
+ .await
+ .switch()
+ .attach_printable(format!(
"Failed while updating address: merchant_id: {:?}, customer_id: {:?}",
self.merchant_account.get_id(),
self.domain_customer.customer_id
@@ -1196,27 +1160,19 @@ impl AddressStructForDbUpdate<'_> {
.switch()
.attach_printable("Failed while encrypting address")?;
Some(
- db.insert_address_for_customers(
- self.key_manager_state,
- address,
- self.key_store,
- )
- .await
- .switch()
- .attach_printable("Failed while inserting new address")?,
+ db.insert_address_for_customers(address, self.key_store)
+ .await
+ .switch()
+ .attach_printable("Failed while inserting new address")?,
)
}
}
} else {
match &self.domain_customer.address_id {
Some(address_id) => Some(
- db.find_address_by_address_id(
- self.key_manager_state,
- address_id,
- self.key_store,
- )
- .await
- .switch()?,
+ db.find_address_by_address_id(address_id, self.key_store)
+ .await
+ .switch()?,
),
None => None,
}
@@ -1231,7 +1187,6 @@ struct VerifyIdForUpdateCustomer<'a> {
merchant_reference_id: &'a id_type::CustomerId,
merchant_account: &'a domain::MerchantAccount,
key_store: &'a domain::MerchantKeyStore,
- key_manager_state: &'a KeyManagerState,
}
#[cfg(feature = "v2")]
@@ -1251,7 +1206,6 @@ impl VerifyIdForUpdateCustomer<'_> {
) -> Result<domain::Customer, error_stack::Report<errors::CustomersErrorResponse>> {
let customer = db
.find_customer_by_customer_id_merchant_id(
- self.key_manager_state,
self.merchant_reference_id,
self.merchant_account.get_id(),
self.key_store,
@@ -1272,7 +1226,6 @@ impl VerifyIdForUpdateCustomer<'_> {
) -> Result<domain::Customer, error_stack::Report<errors::CustomersErrorResponse>> {
let customer = db
.find_customer_by_global_id(
- self.key_manager_state,
self.id,
self.key_store,
self.merchant_account.storage_scheme,
@@ -1302,7 +1255,6 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {
update_customer: self,
merchant_account: platform.get_processor().get_account(),
key_store: platform.get_processor().get_key_store(),
- key_manager_state,
state,
domain_customer,
};
@@ -1347,7 +1299,6 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {
let response = db
.update_customer_by_customer_id_merchant_id(
- key_manager_state,
domain_customer.customer_id.to_owned(),
platform.get_processor().get_account().get_id().to_owned(),
domain_customer.to_owned(),
@@ -1468,7 +1419,6 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {
let response = db
.update_customer_by_global_id(
- key_manager_state,
&domain_customer.id,
domain_customer.to_owned(),
storage::CustomerUpdate::Update(Box::new(storage::CustomerGeneralUpdate {
diff --git a/crates/router/src/core/debit_routing.rs b/crates/router/src/core/debit_routing.rs
index a09fc2ab1f..03616c3f13 100644
--- a/crates/router/src/core/debit_routing.rs
+++ b/crates/router/src/core/debit_routing.rs
@@ -2,9 +2,7 @@ use std::{collections::HashSet, fmt::Debug};
use api_models::{enums as api_enums, open_router};
use common_enums::enums;
-use common_utils::{
- errors::CustomResult, ext_traits::ValueExt, id_type, types::keymanager::KeyManagerState,
-};
+use common_utils::{errors::CustomResult, ext_traits::ValueExt, id_type};
use error_stack::ResultExt;
use masking::{PeekInterface, Secret};
@@ -288,7 +286,6 @@ where
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
let db = state.store.as_ref();
- let key_manager_state = &(state).into();
let merchant_id = payment_data.get_payment_attempt().merchant_id.clone();
let profile_id = payment_data.get_payment_attempt().profile_id.clone();
@@ -305,7 +302,6 @@ where
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&db.get_master_key().to_vec().into(),
)
@@ -554,7 +550,6 @@ where
F: Send + Clone,
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
- let key_manager_state = &(state).into();
let db = state.store.as_ref();
let profile_id = payment_data.get_payment_attempt().profile_id.clone();
let merchant_id = payment_data.get_payment_attempt().merchant_id.clone();
@@ -569,7 +564,6 @@ where
get_debit_routing_output::<F, D>(state, payment_data, acquirer_country).await?;
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&db.get_master_key().to_vec().into(),
)
@@ -622,11 +616,9 @@ async fn build_connector_routing_data(
eligible_connector_data_list: Vec<api::ConnectorRoutingData>,
fee_sorted_debit_networks: Vec<common_enums::CardNetwork>,
) -> CustomResult<Vec<api::ConnectorRoutingData>, errors::ApiErrorResponse> {
- let key_manager_state = &state.into();
let debit_routing_config = &state.conf.debit_routing_config;
- let mcas_for_profile =
- fetch_merchant_connector_accounts(state, key_manager_state, profile_id, key_store).await?;
+ let mcas_for_profile = fetch_merchant_connector_accounts(state, profile_id, key_store).await?;
let mut connector_routing_data = Vec::new();
let mut has_us_local_network = false;
@@ -650,14 +642,12 @@ async fn build_connector_routing_data(
/// Fetches merchant connector accounts for the given profile
async fn fetch_merchant_connector_accounts(
state: &SessionState,
- key_manager_state: &KeyManagerState,
profile_id: &id_type::ProfileId,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::ApiErrorResponse> {
state
.store
.list_enabled_connector_accounts_by_profile_id(
- key_manager_state,
profile_id,
key_store,
common_enums::ConnectorType::PaymentProcessor,
diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rs
index 71755fb358..013dd16e8a 100644
--- a/crates/router/src/core/disputes.rs
+++ b/crates/router/src/core/disputes.rs
@@ -72,7 +72,6 @@ pub async fn retrieve_dispute(
core_utils::validate_profile_id_from_auth_layer(profile_id.clone(), &dispute)?;
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(&state).into(),
&dispute.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -135,7 +134,6 @@ pub async fn retrieve_dispute(
let business_profile = state
.store
.find_business_profile_by_profile_id(
- &(&state).into(),
platform.get_processor().get_key_store(),
&payment_attempt.profile_id,
)
@@ -293,7 +291,6 @@ pub async fn accept_dispute(
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(&state).into(),
&dispute.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -417,7 +414,6 @@ pub async fn submit_evidence(
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(&state).into(),
&dispute.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -768,11 +764,9 @@ pub async fn fetch_disputes_from_connector(
req: FetchDisputesRequestData,
) -> RouterResponse<FetchDisputesResponse> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
let merchant_id = platform.get_processor().get_account().get_id();
let merchant_connector_account = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
&merchant_connector_id,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/encryption.rs b/crates/router/src/core/encryption.rs
index fb690b56cb..926a418d49 100644
--- a/crates/router/src/core/encryption.rs
+++ b/crates/router/src/core/encryption.rs
@@ -16,12 +16,7 @@ pub async fn transfer_encryption_key(
) -> errors::CustomResult<usize, errors::ApiErrorResponse> {
let db = &*state.store;
let key_stores = db
- .get_all_key_stores(
- &state.into(),
- &db.get_master_key().to_vec().into(),
- req.from,
- req.limit,
- )
+ .get_all_key_stores(&db.get_master_key().to_vec().into(), req.from, req.limit)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)?;
send_request_to_key_service_for_merchant(state, key_stores).await
diff --git a/crates/router/src/core/files/helpers.rs b/crates/router/src/core/files/helpers.rs
index 0ed35b309e..c5cb6b5617 100644
--- a/crates/router/src/core/files/helpers.rs
+++ b/crates/router/src/core/files/helpers.rs
@@ -320,7 +320,6 @@ pub async fn upload_and_get_provider_provider_file_id_profile_id(
let payment_intent = state
.store
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&dispute.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rs
index d2fb0ed57e..5c62f12178 100644
--- a/crates/router/src/core/fraud_check.rs
+++ b/crates/router/src/core/fraud_check.rs
@@ -212,7 +212,6 @@ where
#[cfg(feature = "v1")]
let merchant_connector_account_from_db_option = db
.find_merchant_connector_account_by_profile_id_connector_name(
- &state.into(),
&profile_id,
&frm_routing_algorithm_struct.data,
platform.get_processor().get_key_store(),
@@ -778,7 +777,6 @@ pub async fn frm_fulfillment_core(
let db = &*state.clone().store;
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(&state).into(),
&req.payment_id.clone(),
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
index 8cb5945ed8..bc2451a050 100644
--- a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
+++ b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
@@ -409,7 +409,6 @@ where
frm_router_data: FrmRouterData,
) -> RouterResult<FrmData> {
let db = &*state.store;
- let key_manager_state = &state.into();
let frm_check_update = match frm_router_data.response {
FrmResponse::Sale(response) => match response {
Err(err) => Some(FraudCheckUpdate::ErrorUpdate {
@@ -607,7 +606,6 @@ where
let payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.get_payment_intent().clone(),
PaymentIntentUpdate::RejectUpdate {
status: payment_intent_status,
diff --git a/crates/router/src/core/locker_migration.rs b/crates/router/src/core/locker_migration.rs
index 9022340a26..0fd70b4495 100644
--- a/crates/router/src/core/locker_migration.rs
+++ b/crates/router/src/core/locker_migration.rs
@@ -33,11 +33,9 @@ pub async fn rust_locker_migration(
use crate::db::customers::CustomerListConstraints;
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -45,7 +43,7 @@ pub async fn rust_locker_migration(
.change_context(errors::ApiErrorResponse::InternalServerError)?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
.change_context(errors::ApiErrorResponse::InternalServerError)?;
@@ -59,7 +57,7 @@ pub async fn rust_locker_migration(
};
let domain_customers = db
- .list_customers_by_merchant_id(key_manager_state, merchant_id, &key_store, constraints)
+ .list_customers_by_merchant_id(merchant_id, &key_store, constraints)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)?;
@@ -75,7 +73,6 @@ pub async fn rust_locker_migration(
for customer in domain_customers {
let result = db
.find_payment_method_by_customer_id_merchant_id_list(
- key_manager_state,
&key_store,
&customer.customer_id,
merchant_id,
diff --git a/crates/router/src/core/mandate/helpers.rs b/crates/router/src/core/mandate/helpers.rs
index ef3c9a83b7..ace6443443 100644
--- a/crates/router/src/core/mandate/helpers.rs
+++ b/crates/router/src/core/mandate/helpers.rs
@@ -22,7 +22,6 @@ pub async fn get_profile_id_for_mandate(
let pi = state
.store
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs
index 0ce0d9db11..7d989244fc 100644
--- a/crates/router/src/core/payment_link.rs
+++ b/crates/router/src/core/payment_link.rs
@@ -83,11 +83,9 @@ pub async fn form_payment_link_data(
payment_id: common_utils::id_type::PaymentId,
) -> RouterResult<(PaymentLink, PaymentLinkData, PaymentLinkConfig)> {
let db = &*state.store;
- let key_manager_state = &state.into();
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(state).into(),
&payment_id,
&merchant_id,
platform.get_processor().get_key_store(),
@@ -157,11 +155,7 @@ pub async fn form_payment_link_data(
.attach_printable("Profile id missing in payment link and payment intent")?;
let business_profile = db
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- &profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -886,11 +880,9 @@ pub async fn get_payment_link_status(
payment_id: common_utils::id_type::PaymentId,
) -> RouterResponse<services::PaymentLinkFormData> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
&merchant_id,
platform.get_processor().get_key_store(),
@@ -988,11 +980,7 @@ pub async fn get_payment_link_status(
.attach_printable("Profile id missing in payment link and payment intent")?;
let business_profile = db
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- &profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
diff --git a/crates/router/src/core/payment_method_balance.rs b/crates/router/src/core/payment_method_balance.rs
index 27b642ec7d..40c48c01d5 100644
--- a/crates/router/src/core/payment_method_balance.rs
+++ b/crates/router/src/core/payment_method_balance.rs
@@ -45,12 +45,9 @@ pub async fn payments_check_gift_card_balance_core(
) -> errors::RouterResult<(MinorUnit, common_enums::Currency)> {
let db = state.store.as_ref();
- let key_manager_state = &state.into();
-
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -206,11 +203,9 @@ pub async fn payments_check_and_apply_pm_data_core(
payment_id: id_type::GlobalPaymentId,
) -> RouterResponse<CheckAndApplyPaymentMethodDataResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
&payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index fc8874c348..95e9d0e222 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -338,7 +338,6 @@ pub async fn render_pm_collect_link(
let customer = db
.find_customer_by_customer_id_merchant_id(
- &(&state).into(),
&customer_id,
&req.merchant_id,
platform.get_processor().get_key_store(),
@@ -912,7 +911,6 @@ pub async fn create_payment_method_core(
let key_manager_state = &(state).into();
db.find_customer_by_global_id(
- key_manager_state,
&customer_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -1058,7 +1056,6 @@ pub async fn create_payment_method_card_core(
let payment_method = db
.update_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
payment_method,
pm_update,
@@ -1079,7 +1076,6 @@ pub async fn create_payment_method_card_core(
};
db.update_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
payment_method,
pm_update,
@@ -1529,7 +1525,6 @@ pub async fn payment_method_intent_create(
let key_manager_state = &(state).into();
db.find_customer_by_global_id(
- key_manager_state,
&customer_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -1606,13 +1601,10 @@ pub async fn list_payment_methods_for_session(
profile: domain::Profile,
payment_method_session_id: id_type::GlobalPaymentMethodSessionId,
) -> RouterResponse<api::PaymentMethodListResponseForSession> {
- let key_manager_state = &(&state).into();
-
let db = &*state.store;
let payment_method_session = db
.get_payment_methods_session(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_session_id,
)
@@ -1622,7 +1614,6 @@ pub async fn list_payment_methods_for_session(
let payment_connector_accounts = db
.list_enabled_connector_accounts_by_profile_id(
- key_manager_state,
profile.get_id(),
platform.get_processor().get_key_store(),
common_enums::ConnectorType::PaymentProcessor,
@@ -1671,13 +1662,10 @@ pub async fn get_token_data_for_payment_method(
request: payment_methods::GetTokenDataRequest,
payment_method_id: id_type::GlobalPaymentMethodId,
) -> RouterResponse<api::TokenDataResponse> {
- let key_manager_state = &(&state).into();
-
let db = &*state.store;
let payment_method = db
.find_payment_method(
- key_manager_state,
&key_store,
&payment_method_id,
merchant_account.storage_scheme,
@@ -1931,7 +1919,6 @@ pub async fn create_payment_method_for_intent(
let response = db
.insert_payment_method(
- &state.into(),
key_store,
domain::PaymentMethod {
customer_id: customer_id.to_owned(),
@@ -1994,12 +1981,10 @@ pub async fn create_payment_method_for_confirm(
vault_type: Option<common_enums::VaultType>,
) -> CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> {
let db = &*state.store;
- let key_manager_state = &state.into();
let current_time = common_utils::date_time::now();
let response = db
.insert_payment_method(
- key_manager_state,
key_store,
domain::PaymentMethod {
customer_id: customer_id.to_owned(),
@@ -2076,7 +2061,7 @@ pub async fn get_external_vault_token(
};
let payment_method = db
- .find_payment_method(&state.into(), key_store, &payment_method_id, storage_scheme)
+ .find_payment_method(key_store, &payment_method_id, storage_scheme)
.await
.change_context(errors::ApiErrorResponse::PaymentMethodNotFound)
.attach_printable("Payment method not found")?;
@@ -2265,7 +2250,6 @@ pub async fn vault_payment_method_internal(
// throw back error if payment method is duplicated
when(
db.find_payment_method_by_fingerprint_id(
- &(state.into()),
platform.get_processor().get_key_store(),
&fingerprint_id_from_vault,
)
@@ -2633,11 +2617,9 @@ pub async fn list_payment_methods_core(
customer_id: &id_type::GlobalCustomerId,
) -> RouterResult<payment_methods::CustomerPaymentMethodsListResponse> {
let db = &*state.store;
- let key_manager_state = &(state).into();
let saved_payment_methods = db
.find_payment_method_by_global_customer_id_merchant_id_status(
- key_manager_state,
platform.get_processor().get_key_store(),
customer_id,
platform.get_processor().get_account().get_id(),
@@ -2668,11 +2650,9 @@ pub async fn list_customer_payment_methods_core(
customer_id: &id_type::GlobalCustomerId,
) -> RouterResult<Vec<payment_methods::CustomerPaymentMethodResponseItem>> {
let db = &*state.store;
- let key_manager_state = &(state).into();
let saved_payment_methods = db
.find_payment_method_by_global_customer_id_merchant_id_status(
- key_manager_state,
platform.get_processor().get_key_store(),
customer_id,
platform.get_processor().get_account().get_id(),
@@ -2764,7 +2744,6 @@ pub async fn retrieve_payment_method(
let payment_method = db
.find_payment_method(
- &((&state).into()),
platform.get_processor().get_key_store(),
&pm_id,
platform.get_processor().get_account().storage_scheme,
@@ -2794,15 +2773,9 @@ pub async fn update_payment_method_status_internal(
payment_method_id: &id_type::GlobalPaymentMethodId,
) -> RouterResult<domain::PaymentMethod> {
let db = &*state.store;
- let key_manager_state = &state.into();
let payment_method = db
- .find_payment_method(
- &((state).into()),
- key_store,
- payment_method_id,
- storage_scheme,
- )
+ .find_payment_method(key_store, payment_method_id, storage_scheme)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;
@@ -2812,13 +2785,7 @@ pub async fn update_payment_method_status_internal(
};
let updated_pm = db
- .update_payment_method(
- key_manager_state,
- key_store,
- payment_method.clone(),
- pm_update,
- storage_scheme,
- )
+ .update_payment_method(key_store, payment_method.clone(), pm_update, storage_scheme)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update payment method in db")?;
@@ -2854,7 +2821,6 @@ pub async fn update_payment_method_core(
let payment_method = db
.find_payment_method(
- &((state).into()),
platform.get_processor().get_key_store(),
payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -2932,7 +2898,6 @@ pub async fn update_payment_method_core(
let payment_method = db
.update_payment_method(
- &((state).into()),
platform.get_processor().get_key_store(),
payment_method,
pm_update,
@@ -2974,11 +2939,9 @@ pub async fn delete_payment_method_core(
profile: &domain::Profile,
) -> RouterResult<api::PaymentMethodDeleteResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(state).into();
let payment_method = db
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
&pm_id,
platform.get_processor().get_account().storage_scheme,
@@ -2993,7 +2956,6 @@ pub async fn delete_payment_method_core(
let _customer = db
.find_customer_by_global_id(
- key_manager_state,
&payment_method.customer_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -3009,7 +2971,6 @@ pub async fn delete_payment_method_core(
};
db.update_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
payment_method.clone(),
pm_update,
@@ -3150,7 +3111,6 @@ pub async fn payment_methods_session_create(
let key_manager_state = &(&state).into();
db.find_customer_by_global_id(
- key_manager_state,
&request.customer_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -3215,7 +3175,6 @@ pub async fn payment_methods_session_create(
};
db.insert_payment_methods_session(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_method_session_domain_model.clone(),
expires_in,
@@ -3246,7 +3205,6 @@ pub async fn payment_methods_session_update(
let existing_payment_method_session_state = db
.get_payment_methods_session(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_session_id,
)
@@ -3283,7 +3241,6 @@ pub async fn payment_methods_session_update(
let update_state_change = db
.update_payment_method_session(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_session_id,
payment_method_session_domain_model,
@@ -3309,11 +3266,9 @@ pub async fn payment_methods_session_retrieve(
payment_method_session_id: id_type::GlobalPaymentMethodSessionId,
) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let payment_method_session_domain_model = db
.get_payment_methods_session(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_session_id,
)
@@ -3342,11 +3297,9 @@ pub async fn payment_methods_session_update_payment_method(
request: payment_methods::PaymentMethodSessionUpdateSavedPaymentMethod,
) -> RouterResponse<payment_methods::PaymentMethodResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
// Validate if the session still exists
db.get_payment_methods_session(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_session_id,
)
@@ -3380,11 +3333,9 @@ pub async fn payment_methods_session_delete_payment_method(
payment_method_session_id: id_type::GlobalPaymentMethodSessionId,
) -> RouterResponse<api::PaymentMethodDeleteResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
// Validate if the session still exists
db.get_payment_methods_session(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_session_id,
)
@@ -3489,12 +3440,10 @@ pub async fn payment_methods_session_confirm(
request: payment_methods::PaymentMethodSessionConfirmRequest,
) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> {
let db: &dyn StorageInterface = state.store.as_ref();
- let key_manager_state = &(&state).into();
// Validate if the session still exists
let payment_method_session = db
.get_payment_methods_session(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_session_id,
)
@@ -3577,7 +3526,6 @@ pub async fn payment_methods_session_confirm(
let payment_method_session = db
.update_payment_method_session(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_session_id,
update_payment_method_session,
@@ -3743,7 +3691,6 @@ async fn create_single_use_tokenization_flow(
let merchant_connector_account_details = db
.find_merchant_connector_account_by_id(
- &(&state).into(),
&connector_id,
platform.get_processor().get_key_store(),
)
@@ -3933,12 +3880,10 @@ async fn fetch_payment_method(
payment_method_id: &id_type::GlobalPaymentMethodId,
) -> RouterResult<domain::PaymentMethod> {
let db = &state.store;
- let key_manager_state = &state.into();
let merchant_account = platform.get_processor().get_account();
let key_store = platform.get_processor().get_key_store();
db.find_payment_method(
- key_manager_state,
key_store,
payment_method_id,
merchant_account.storage_scheme,
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index cdd998c998..25001f364d 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -140,7 +140,6 @@ impl PaymentMethodsController for PmCards<'_> {
let db = &*self.state.store;
let customer = db
.find_customer_by_customer_id_merchant_id(
- &self.state.into(),
customer_id,
merchant_id,
self.platform.get_processor().get_key_store(),
@@ -158,7 +157,6 @@ impl PaymentMethodsController for PmCards<'_> {
let response = db
.insert_payment_method(
- &self.state.into(),
self.platform.get_processor().get_key_store(),
domain::PaymentMethod {
customer_id: customer_id.to_owned(),
@@ -273,11 +271,9 @@ impl PaymentMethodsController for PmCards<'_> {
let mut payment_method_id = resp.payment_method_id.clone();
let mut locker_id = None;
let db = &*self.state.store;
- let key_manager_state = &(self.state.into());
let payment_method = {
let existing_pm_by_pmid = db
.find_payment_method(
- key_manager_state,
key_store,
&payment_method_id,
self.platform.get_processor().get_account().storage_scheme,
@@ -289,7 +285,6 @@ impl PaymentMethodsController for PmCards<'_> {
locker_id = Some(payment_method_id.clone());
let existing_pm_by_locker_id = db
.find_payment_method_by_locker_id(
- key_manager_state,
key_store,
&payment_method_id,
self.platform.get_processor().get_account().storage_scheme,
@@ -424,7 +419,6 @@ impl PaymentMethodsController for PmCards<'_> {
let db = &*self.state.store;
let existing_pm = db
.find_payment_method(
- &self.state.into(),
key_store,
&pm_id,
self.platform.get_processor().get_account().storage_scheme,
@@ -436,7 +430,6 @@ impl PaymentMethodsController for PmCards<'_> {
))?;
db.update_payment_method(
- &self.state.into(),
key_store,
existing_pm,
pm_update,
@@ -794,12 +787,10 @@ impl PaymentMethodsController for PmCards<'_> {
) -> errors::RouterResponse<api_models::payment_methods::CustomerDefaultPaymentMethodResponse>
{
let db = &*self.state.store;
- let key_manager_state = &self.state.into();
// check for the customer
// TODO: customer need not be checked again here, this function can take an optional customer and check for existence of customer based on the optional value
let customer = db
.find_customer_by_customer_id_merchant_id(
- key_manager_state,
customer_id,
merchant_id,
self.platform.get_processor().get_key_store(),
@@ -810,7 +801,6 @@ impl PaymentMethodsController for PmCards<'_> {
// check for the presence of payment_method
let payment_method = db
.find_payment_method(
- &(self.state.into()),
self.platform.get_processor().get_key_store(),
&payment_method_id,
self.platform.get_processor().get_account().storage_scheme,
@@ -850,7 +840,6 @@ impl PaymentMethodsController for PmCards<'_> {
let updated_customer_details = db
.update_customer_by_customer_id_merchant_id(
- key_manager_state,
customer_id.to_owned(),
merchant_id.to_owned(),
customer,
@@ -925,7 +914,6 @@ impl PaymentMethodsController for PmCards<'_> {
let db = self.state.store.as_ref();
let pm = db
.find_payment_method(
- &self.state.into(),
self.platform.get_processor().get_key_store(),
&pm.payment_method_id,
self.platform.get_processor().get_account().storage_scheme,
@@ -982,10 +970,8 @@ impl PaymentMethodsController for PmCards<'_> {
pm_id: api::PaymentMethodId,
) -> errors::RouterResponse<api::PaymentMethodDeleteResponse> {
let db = self.state.store.as_ref();
- let key_manager_state = &(self.state.into());
let key = db
.find_payment_method(
- key_manager_state,
self.platform.get_processor().get_key_store(),
pm_id.payment_method_id.as_str(),
self.platform.get_processor().get_account().storage_scheme,
@@ -995,7 +981,6 @@ impl PaymentMethodsController for PmCards<'_> {
let customer = db
.find_customer_by_customer_id_merchant_id(
- key_manager_state,
&key.customer_id,
self.platform.get_processor().get_account().get_id(),
self.platform.get_processor().get_key_store(),
@@ -1043,7 +1028,6 @@ impl PaymentMethodsController for PmCards<'_> {
}
db.delete_payment_method_by_merchant_id_payment_method_id(
- &(self.state.into()),
self.platform.get_processor().get_key_store(),
self.platform.get_processor().get_account().get_id(),
pm_id.payment_method_id.as_str(),
@@ -1057,7 +1041,6 @@ impl PaymentMethodsController for PmCards<'_> {
last_modified_by: None,
};
db.update_customer_by_customer_id_merchant_id(
- key_manager_state,
key.customer_id,
key.merchant_id,
customer,
@@ -1210,7 +1193,6 @@ impl PaymentMethodsController for PmCards<'_> {
if let Err(err) = add_card_resp {
logger::error!(vault_err=?err);
db.delete_payment_method_by_merchant_id_payment_method_id(
- &(self.state.into()),
self.platform.get_processor().get_key_store(),
merchant_id,
&resp.payment_method_id,
@@ -1276,7 +1258,6 @@ impl PaymentMethodsController for PmCards<'_> {
};
db.update_payment_method(
- &(self.state.into()),
self.platform.get_processor().get_key_store(),
existing_pm,
pm_update,
@@ -1467,7 +1448,6 @@ pub async fn add_payment_method_data(
.get_required_value("client_secret")?;
let payment_method = db
.find_payment_method(
- &((&state).into()),
platform.get_processor().get_key_store(),
pm_id.as_str(),
platform.get_processor().get_account().storage_scheme,
@@ -1484,7 +1464,6 @@ pub async fn add_payment_method_data(
let customer = db
.find_customer_by_customer_id_merchant_id(
- &(&state).into(),
&customer_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -1516,7 +1495,6 @@ pub async fn add_payment_method_data(
};
db.update_payment_method(
- &((&state).into()),
platform.get_processor().get_key_store(),
payment_method,
pm_update,
@@ -1589,7 +1567,6 @@ pub async fn add_payment_method_data(
};
db.update_payment_method(
- &((&state).into()),
platform.get_processor().get_key_store(),
payment_method,
pm_update,
@@ -1625,7 +1602,6 @@ pub async fn add_payment_method_data(
};
db.update_payment_method(
- &((&state).into()),
platform.get_processor().get_key_store(),
payment_method,
pm_update,
@@ -1658,7 +1634,6 @@ pub async fn update_customer_payment_method(
pm
} else {
db.find_payment_method(
- &((&state).into()),
platform.get_processor().get_key_store(),
payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -1841,7 +1816,6 @@ pub async fn update_customer_payment_method(
.clone_from(&pm.payment_method_id);
db.update_payment_method(
- &((&state).into()),
platform.get_processor().get_key_store(),
pm,
pm_update,
@@ -1918,7 +1892,6 @@ pub async fn update_customer_payment_method(
let pm = db
.update_payment_method(
- &((&state).into()),
platform.get_processor().get_key_store(),
pm,
pm_update,
@@ -2251,7 +2224,6 @@ where
#[cfg(feature = "v1")]
pub async fn update_payment_method_metadata_and_last_used(
- state: &routes::SessionState,
key_store: &domain::MerchantKeyStore,
db: &dyn db::StorageInterface,
pm: domain::PaymentMethod,
@@ -2263,14 +2235,13 @@ pub async fn update_payment_method_metadata_and_last_used(
last_used_at: common_utils::date_time::now(),
last_modified_by: None,
};
- db.update_payment_method(&(state.into()), key_store, pm, pm_update, storage_scheme)
+ db.update_payment_method(key_store, pm, pm_update, storage_scheme)
.await
.change_context(errors::VaultError::UpdateInPaymentMethodDataTableFailed)?;
Ok(())
}
pub async fn update_payment_method_and_last_used(
- state: &routes::SessionState,
key_store: &domain::MerchantKeyStore,
db: &dyn db::StorageInterface,
pm: domain::PaymentMethod,
@@ -2284,7 +2255,7 @@ pub async fn update_payment_method_and_last_used(
last_used_at: common_utils::date_time::now(),
last_modified_by: None,
};
- db.update_payment_method(&(state.into()), key_store, pm, pm_update, storage_scheme)
+ db.update_payment_method(key_store, pm, pm_update, storage_scheme)
.await
.change_context(errors::VaultError::UpdateInPaymentMethodDataTableFailed)?;
Ok(())
@@ -2304,7 +2275,7 @@ pub async fn update_payment_method_connector_mandate_details(
last_modified_by: None,
};
- db.update_payment_method(&(state.into()), key_store, pm, pm_update, storage_scheme)
+ db.update_payment_method(key_store, pm, pm_update, storage_scheme)
.await
.change_context(errors::VaultError::UpdateInPaymentMethodDataTableFailed)?;
Ok(())
@@ -2312,7 +2283,6 @@ pub async fn update_payment_method_connector_mandate_details(
#[cfg(feature = "v1")]
pub async fn update_payment_method_connector_mandate_details(
- state: &routes::SessionState,
key_store: &domain::MerchantKeyStore,
db: &dyn db::StorageInterface,
pm: domain::PaymentMethod,
@@ -2333,7 +2303,7 @@ pub async fn update_payment_method_connector_mandate_details(
last_modified_by: None,
};
- db.update_payment_method(&(state.into()), key_store, pm, pm_update, storage_scheme)
+ db.update_payment_method(key_store, pm, pm_update, storage_scheme)
.await
.change_context(errors::VaultError::UpdateInPaymentMethodDataTableFailed)?;
Ok(())
@@ -2688,10 +2658,9 @@ pub async fn list_payment_methods(
) -> errors::RouterResponse<api::PaymentMethodListResponse> {
let db = &*state.store;
let pm_config_mapping = &state.conf.pm_filters;
- let key_manager_state = &(&state).into();
let payment_intent = if let Some(cs) = &req.client_secret {
if cs.starts_with("pm_") {
- validate_payment_method_and_client_secret(&state, cs, db, &platform).await?;
+ validate_payment_method_and_client_secret(cs, db, &platform).await?;
None
} else {
helpers::verify_payment_intent_time_and_client_secret(
@@ -2746,7 +2715,6 @@ pub async fn list_payment_methods(
.as_ref()
.async_and_then(|cust| async {
db.find_customer_by_customer_id_merchant_id(
- key_manager_state,
cust,
&pi.merchant_id,
platform.get_processor().get_key_store(),
@@ -2797,7 +2765,6 @@ pub async fn list_payment_methods(
let all_mcas = db
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- key_manager_state,
platform.get_processor().get_account().get_id(),
false,
platform.get_processor().get_key_store(),
@@ -2813,11 +2780,7 @@ pub async fn list_payment_methods(
message: "Profile id not found".to_string(),
})?;
let business_profile = db
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -3703,7 +3666,6 @@ fn should_collect_shipping_or_billing_details_from_wallet_connector(
#[cfg(feature = "v1")]
async fn validate_payment_method_and_client_secret(
- state: &routes::SessionState,
cs: &String,
db: &dyn db::StorageInterface,
platform: &domain::Platform,
@@ -3717,7 +3679,6 @@ async fn validate_payment_method_and_client_secret(
let payment_method = db
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
pm_id,
platform.get_processor().get_account().storage_scheme,
@@ -3782,7 +3743,6 @@ pub async fn call_surcharge_decision_management(
let _ = state
.store
.update_payment_intent(
- &(&state).into(),
payment_intent,
storage::PaymentIntentUpdate::SurchargeApplicableUpdate {
surcharge_applicable: true,
@@ -3843,7 +3803,6 @@ pub async fn call_surcharge_decision_management_for_saved_card(
let _ = state
.store
.update_payment_intent(
- &state.into(),
payment_intent,
storage::PaymentIntentUpdate::SurchargeApplicableUpdate {
surcharge_applicable: true,
@@ -4228,7 +4187,6 @@ pub async fn list_customer_payment_method(
limit: Option<i64>,
) -> errors::RouterResponse<api::CustomerPaymentMethodsListResponse> {
let db = &*state.store;
- let key_manager_state = &state.into();
let off_session_payment_flag = payment_intent
.as_ref()
.map(|pi| {
@@ -4241,7 +4199,6 @@ pub async fn list_customer_payment_method(
let customer = db
.find_customer_by_customer_id_merchant_id(
- &state.into(),
customer_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -4276,7 +4233,6 @@ pub async fn list_customer_payment_method(
let resp = db
.find_payment_method_by_customer_id_merchant_id_status(
- &(state.into()),
platform.get_processor().get_key_store(),
customer_id,
platform.get_processor().get_account().get_id(),
@@ -4302,7 +4258,6 @@ pub async fn list_customer_payment_method(
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id.as_ref(),
platform.get_processor().get_account().get_id(),
@@ -4643,7 +4598,6 @@ pub async fn get_mca_status(
let mcas = state
.store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
merchant_id,
true,
key_store,
@@ -4865,7 +4819,6 @@ pub async fn update_last_used_at(
state
.store
.update_payment_method(
- &(state.into()),
key_store,
payment_method.clone(),
update_last_used,
diff --git a/crates/router/src/core/payment_methods/migration.rs b/crates/router/src/core/payment_methods/migration.rs
index 3e4203abe9..b32b0d6403 100644
--- a/crates/router/src/core/payment_methods/migration.rs
+++ b/crates/router/src/core/payment_methods/migration.rs
@@ -69,7 +69,6 @@ pub async fn update_payment_method_record(
let payment_method = db
.find_payment_method(
- &state.into(),
platform.get_processor().get_key_store(),
&payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -130,7 +129,6 @@ pub async fn update_payment_method_record(
for merchant_connector_id in parsed_mca_ids {
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- &state.into(),
platform.get_processor().get_account().get_id(),
&merchant_connector_id,
platform.get_processor().get_key_store(),
@@ -153,7 +151,6 @@ pub async fn update_payment_method_record(
(Some(connector_customer_id), Some(cache)) => {
let customer = db
.find_customer_by_customer_id_merchant_id(
- &state.into(),
&payment_method.customer_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -279,7 +276,6 @@ pub async fn update_payment_method_record(
let response = db
.update_payment_method(
- &state.into(),
platform.get_processor().get_key_store(),
payment_method,
pm_update,
@@ -295,7 +291,6 @@ pub async fn update_payment_method_record(
if let (Some(customer_data), Some(customer_update)) = (customer, updated_customer) {
let updated_customer = db
.update_customer_by_customer_id_merchant_id(
- &state.into(),
response.customer_id.clone(),
merchant_id.clone(),
customer_data,
diff --git a/crates/router/src/core/payment_methods/tokenize/card_executor.rs b/crates/router/src/core/payment_methods/tokenize/card_executor.rs
index fcc3b187a1..bf6b947f87 100644
--- a/crates/router/src/core/payment_methods/tokenize/card_executor.rs
+++ b/crates/router/src/core/payment_methods/tokenize/card_executor.rs
@@ -327,9 +327,7 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest> {
// Fetch customer details if present
let db = &*self.state.store;
- let key_manager_state: &KeyManagerState = &self.state.into();
db.find_customer_optional_by_customer_id_merchant_id(
- key_manager_state,
customer_id,
self.merchant_account.get_id(),
self.key_store,
@@ -438,7 +436,6 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest> {
db.insert_customer(
domain_customer,
- key_manager_state,
self.key_store,
self.merchant_account.storage_scheme,
)
diff --git a/crates/router/src/core/payment_methods/tokenize/payment_method_executor.rs b/crates/router/src/core/payment_methods/tokenize/payment_method_executor.rs
index dd79b0327b..fe3e0e76cd 100644
--- a/crates/router/src/core/payment_methods/tokenize/payment_method_executor.rs
+++ b/crates/router/src/core/payment_methods/tokenize/payment_method_executor.rs
@@ -1,7 +1,5 @@
use api_models::enums as api_enums;
-use common_utils::{
- ext_traits::OptionExt, fp_utils::when, pii::Email, types::keymanager::KeyManagerState,
-};
+use common_utils::{ext_traits::OptionExt, fp_utils::when, pii::Email};
use error_stack::{report, ResultExt};
use masking::Secret;
use router_env::logger;
@@ -276,7 +274,6 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizePaymentMethodRequest> {
self.state
.store
.find_payment_method(
- &self.state.into(),
self.key_store,
payment_method_id,
self.merchant_account.storage_scheme,
@@ -355,10 +352,8 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizePaymentMethodRequest> {
// Fetch customer
let db = &*self.state.store;
- let key_manager_state: &KeyManagerState = &self.state.into();
let customer = db
.find_customer_by_customer_id_merchant_id(
- key_manager_state,
&payment_method.customer_id,
self.merchant_account.get_id(),
self.key_store,
@@ -404,7 +399,6 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizePaymentMethodRequest> {
self.state
.store
.update_payment_method(
- &self.state.into(),
self.key_store,
payment_method,
payment_method_update,
diff --git a/crates/router/src/core/payment_methods/validator.rs b/crates/router/src/core/payment_methods/validator.rs
index 302ae8bd52..0a88194c31 100644
--- a/crates/router/src/core/payment_methods/validator.rs
+++ b/crates/router/src/core/payment_methods/validator.rs
@@ -37,7 +37,6 @@ pub async fn validate_request_and_initiate_payment_method_collect_link(
#[cfg(feature = "v1")]
match db
.find_customer_by_customer_id_merchant_id(
- &state.into(),
&customer_id,
&merchant_id,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 7428e393f2..df46e26fb7 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -1740,13 +1740,11 @@ pub async fn retrieve_payment_method_from_vault_using_payment_token(
}
};
let db = &*state.store;
- let key_manager_state = &state.into();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_method = db
.find_payment_method(
- key_manager_state,
platform.get_processor().get_key_store(),
&payment_method_id,
storage_scheme,
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 61a5c94598..be74892b66 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -2649,10 +2649,8 @@ pub async fn payments_get_intent_using_merchant_reference(
) -> RouterResponse<api::PaymentsIntentResponse> {
let db = state.store.as_ref();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
- let key_manager_state = &(&state).into();
let payment_intent = db
.find_payment_intent_by_merchant_reference_id_profile_id(
- key_manager_state,
merchant_reference_id,
profile.get_id(),
platform.get_processor().get_key_store(),
@@ -3170,7 +3168,6 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
_connector: String,
_payment_id: id_type::PaymentId,
) -> RouterResult<Self::PaymentFlowResponse> {
- let key_manager_state = &state.into();
let payment_confirm_req = api::PaymentsRequest {
payment_id: Some(req.resource_id.clone()),
merchant_id: req.merchant_id.clone(),
@@ -3224,7 +3221,6 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
let business_profile = state
.store
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -3339,8 +3335,6 @@ impl PaymentRedirectFlow for PaymentRedirectSync {
_connector: String,
_payment_id: id_type::PaymentId,
) -> RouterResult<Self::PaymentFlowResponse> {
- let key_manager_state = &state.into();
-
let payment_sync_req = api::PaymentsRetrieveRequest {
resource_id: req.resource_id,
merchant_id: req.merchant_id,
@@ -3387,7 +3381,6 @@ impl PaymentRedirectFlow for PaymentRedirectSync {
let business_profile = state
.store
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -3622,12 +3615,10 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {
payment_id: id_type::PaymentId,
) -> RouterResult<Self::PaymentFlowResponse> {
let merchant_id = platform.get_processor().get_account().get_id().clone();
- let key_manager_state = &state.into();
let payment_intent = state
.store
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
&merchant_id,
platform.get_processor().get_key_store(),
@@ -3805,7 +3796,6 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {
let business_profile = state
.store
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -6532,11 +6522,9 @@ pub async fn get_session_token_for_click_to_pay(
.change_context(errors::ApiErrorResponse::MissingRequiredField {
field_name: "authentication_product_ids",
})?;
- let key_manager_state = &(state).into();
let merchant_connector_account = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
&click_to_pay_mca_id,
platform.get_processor().get_key_store(),
@@ -6613,11 +6601,9 @@ async fn get_card_brands_based_on_active_merchant_connector_account(
profile_id: &id_type::ProfileId,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<HashSet<enums::CardNetwork>> {
- let key_manager_state = &(state).into();
let merchant_configured_payment_connectors = state
.store
.list_enabled_connector_accounts_by_profile_id(
- key_manager_state,
profile_id,
key_store,
common_enums::ConnectorType::PaymentProcessor,
@@ -7111,14 +7097,12 @@ where
.attach_printable(
"Failed to get authentication connector id from authentication table",
)?;
- let key_manager_state = &(state).into();
let key_store = platform.get_processor().get_key_store();
let merchant_id = platform.get_processor().get_account().get_id();
let connector_mca = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
&authentication_connector_id,
key_store,
@@ -7914,7 +7898,6 @@ impl PaymentEligibilityData {
platform: &domain::Platform,
payments_eligibility_request: &api_models::payments::PaymentsEligibilityRequest,
) -> CustomResult<Self, errors::ApiErrorResponse> {
- let key_manager_state = &(state).into();
let payment_method_data = payments_eligibility_request
.payment_method_data
.payment_method_data
@@ -7933,7 +7916,6 @@ impl PaymentEligibilityData {
let payment_intent = state
.store
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payments_eligibility_request.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -8241,7 +8223,6 @@ pub async fn list_payments(
let fetch_constraints = constraints.clone().into();
let list: Vec<(storage::PaymentIntent, Option<storage::PaymentAttempt>)> = db
.get_filtered_payment_intents_attempt(
- &(&state).into(),
platform.get_processor().get_account().get_id(),
&fetch_constraints,
platform.get_processor().get_key_store(),
@@ -8320,7 +8301,6 @@ pub async fn apply_filters_on_payments(
let pi_fetch_constraints = (constraints.clone(), profile_id_list.clone()).try_into()?;
let list: Vec<(storage::PaymentIntent, storage::PaymentAttempt)> = db
.get_filtered_payment_intents_attempt(
- &(&state).into(),
platform.get_processor().get_account().get_id(),
&pi_fetch_constraints,
platform.get_processor().get_key_store(),
@@ -8387,7 +8367,6 @@ pub async fn get_filters_for_payments(
let db = state.store.as_ref();
let pi = db
.filter_payment_intents_by_time_range_constraints(
- &(&state).into(),
platform.get_processor().get_account().get_id(),
&time_range,
platform.get_processor().get_key_store(),
@@ -10457,14 +10436,12 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
};
let db = &*state.store;
- let key_manager_state = &(&state).into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_id = req.payment_id;
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -10499,7 +10476,6 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
state
.store
.find_customer_by_customer_id_merchant_id(
- key_manager_state,
customer_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -10577,11 +10553,7 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
let business_profile = state
.store
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), profile_id)
.await
.change_context(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -10739,13 +10711,11 @@ pub async fn payment_start_redirection(
req: api_models::payments::PaymentStartRedirectionRequest,
) -> RouterResponse<serde_json::Value> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
&req.id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -10768,7 +10738,6 @@ pub async fn payment_start_redirection(
let payment_attempt = db
.find_payment_attempt_by_id(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_intent
.active_attempt_id
@@ -10835,11 +10804,9 @@ pub async fn payments_manual_update(
connector_transaction_id,
amount_capturable,
} = req;
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -10848,7 +10815,7 @@ pub async fn payments_manual_update(
.attach_printable("Error while fetching the key store by merchant_id")?;
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
.attach_printable("Error while fetching the merchant_account by merchant_id")?;
@@ -10880,7 +10847,6 @@ pub async fn payments_manual_update(
let payment_intent = state
.store
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_account.get_id(),
&key_store,
@@ -10939,7 +10905,6 @@ pub async fn payments_manual_update(
state
.store
.update_payment_intent(
- key_manager_state,
payment_intent,
payment_intent_update,
&key_store,
@@ -11186,7 +11151,6 @@ pub async fn payments_submit_eligibility(
req: api_models::payments::PaymentsEligibilityRequest,
payment_id: id_type::PaymentId,
) -> RouterResponse<api_models::payments::PaymentsEligibilityResponse> {
- let key_manager_state = &(&state).into();
let payment_eligibility_data =
PaymentEligibilityData::from_request(&state, &platform, &req).await?;
let profile_id = payment_eligibility_data
@@ -11197,11 +11161,7 @@ pub async fn payments_submit_eligibility(
.attach_printable("'profile_id' not set in payment intent")?;
let business_profile = state
.store
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- &profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index b0499f2ddf..a744f3bac0 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -24,7 +24,7 @@ use common_utils::{
new_type::{MaskedIban, MaskedSortCode},
pii, type_name,
types::{
- keymanager::{Identifier, KeyManagerState, ToEncryptable},
+ keymanager::{Identifier, ToEncryptable},
MinorUnit,
},
};
@@ -143,7 +143,6 @@ pub async fn create_or_update_address_for_payment_by_request(
) -> CustomResult<Option<domain::Address>, errors::ApiErrorResponse> {
let key = merchant_key_store.key.get_inner().peek();
let db = &session_state.store;
- let key_manager_state = &session_state.into();
Ok(match address_id {
Some(id) => match req_address {
Some(address) => {
@@ -223,7 +222,6 @@ pub async fn create_or_update_address_for_payment_by_request(
};
let address = db
.find_address_by_merchant_id_payment_id_address_id(
- key_manager_state,
merchant_id,
payment_id,
id,
@@ -235,7 +233,6 @@ pub async fn create_or_update_address_for_payment_by_request(
.attach_printable("Error while fetching address")?;
Some(
db.update_address_for_payments(
- key_manager_state,
address,
address_update,
payment_id.to_owned(),
@@ -249,7 +246,6 @@ pub async fn create_or_update_address_for_payment_by_request(
}
None => Some(
db.find_address_by_merchant_id_payment_id_address_id(
- key_manager_state,
merchant_id,
payment_id,
id,
@@ -278,7 +274,6 @@ pub async fn create_or_update_address_for_payment_by_request(
Some(
db.insert_address_for_payments(
- key_manager_state,
payment_id,
payment_address,
merchant_key_store,
@@ -310,11 +305,9 @@ pub async fn create_or_find_address_for_payment_by_request(
) -> CustomResult<Option<domain::Address>, errors::ApiErrorResponse> {
let key = merchant_key_store.key.get_inner().peek();
let db = &state.store;
- let key_manager_state = &state.into();
Ok(match address_id {
Some(id) => Some(
db.find_address_by_merchant_id_payment_id_address_id(
- key_manager_state,
merchant_id,
payment_id,
id,
@@ -342,7 +335,6 @@ pub async fn create_or_find_address_for_payment_by_request(
Some(
db.insert_address_for_payments(
- key_manager_state,
payment_id,
payment_address,
merchant_key_store,
@@ -446,7 +438,6 @@ pub async fn get_address_by_id(
let db = &*state.store;
Ok(db
.find_address_by_merchant_id_payment_id_address_id(
- &state.into(),
merchant_id,
payment_id,
&address_id,
@@ -498,12 +489,10 @@ pub async fn get_token_pm_type_mandate_details(
RecurringDetails::ProcessorPaymentToken(processor_payment_token) => {
if let Some(mca_id) = &processor_payment_token.merchant_connector_id {
let db = &*state.store;
- let key_manager_state = &state.into();
#[cfg(feature = "v1")]
let connector_name = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
platform.get_processor().get_account().get_id(),
mca_id,
platform.get_processor().get_key_store(),
@@ -515,7 +504,7 @@ pub async fn get_token_pm_type_mandate_details(
#[cfg(feature = "v2")]
let connector_name = db
- .find_merchant_connector_account_by_id(key_manager_state, mca_id, merchant_key_store)
+ .find_merchant_connector_account_by_id( mca_id, merchant_key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
id: mca_id.clone().get_string_repr().to_string(),
@@ -561,7 +550,6 @@ pub async fn get_token_pm_type_mandate_details(
let payment_method_info = state
.store
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -625,7 +613,6 @@ pub async fn get_token_pm_type_mandate_details(
let customer_saved_pm_option = match state
.store
.find_payment_method_by_customer_id_merchant_id_list(
- &(state.into()),
platform.get_processor().get_key_store(),
customer_id,
platform.get_processor().get_account().get_id(),
@@ -681,7 +668,6 @@ pub async fn get_token_pm_type_mandate_details(
state
.store
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
&payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -712,7 +698,6 @@ pub async fn get_token_pm_type_mandate_details(
state
.store
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
&payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -761,13 +746,11 @@ pub async fn get_token_for_recurring_mandate(
)
.await
.to_not_found_response(errors::ApiErrorResponse::MandateNotFound)?;
- let key_manager_state: KeyManagerState = state.into();
let original_payment_intent = mandate
.original_payment_id
.as_ref()
.async_map(|payment_id| async {
db.find_payment_intent_by_payment_id_merchant_id(
- &key_manager_state,
payment_id,
&mandate.merchant_id,
platform.get_processor().get_key_store(),
@@ -826,7 +809,6 @@ pub async fn get_token_for_recurring_mandate(
let payment_method = db
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
payment_method_id.as_str(),
platform.get_processor().get_account().storage_scheme,
@@ -1785,7 +1767,6 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(
Some(customer_id) => {
let customer_data = db
.find_customer_optional_by_customer_id_merchant_id(
- key_manager_state,
&customer_id,
merchant_id,
key_store,
@@ -1851,7 +1832,6 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(
};
db.update_customer_by_customer_id_merchant_id(
- key_manager_state,
customer_id,
merchant_id.to_owned(),
c,
@@ -1895,7 +1875,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(
last_modified_by: None, // Same as created_by on creation
};
metrics::CUSTOMER_CREATED.add(1, &[]);
- db.insert_customer(new_customer, key_manager_state, key_store, storage_scheme)
+ db.insert_customer(new_customer, key_store, storage_scheme)
.await
}
})
@@ -1904,7 +1884,6 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(
None => None,
Some(customer_id) => db
.find_customer_optional_by_customer_id_merchant_id(
- key_manager_state,
customer_id,
merchant_id,
key_store,
@@ -2626,12 +2605,9 @@ pub async fn fetch_card_details_from_external_vault(
merchant_key_store: &domain::MerchantKeyStore,
external_vault_mca_id: &id_type::MerchantConnectorAccountId,
) -> RouterResult<domain::Card> {
- let key_manager_state = &state.into();
-
let merchant_connector_account_details = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
external_vault_mca_id,
merchant_key_store,
@@ -2794,12 +2770,7 @@ pub async fn retrieve_payment_method_from_db_with_token_data(
if let Some(ref payment_method_id) = data.payment_method_id {
state
.store
- .find_payment_method(
- &(state.into()),
- merchant_key_store,
- payment_method_id,
- storage_scheme,
- )
+ .find_payment_method(merchant_key_store, payment_method_id, storage_scheme)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)
.attach_printable("error retrieving payment method from DB")
@@ -2811,12 +2782,7 @@ pub async fn retrieve_payment_method_from_db_with_token_data(
storage::PaymentTokenData::WalletToken(data) => state
.store
- .find_payment_method(
- &(state.into()),
- merchant_key_store,
- &data.payment_method_id,
- storage_scheme,
- )
+ .find_payment_method(merchant_key_store, &data.payment_method_id, storage_scheme)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)
.attach_printable("error retrieveing payment method from DB")
@@ -3353,13 +3319,7 @@ pub(super) async fn filter_by_constraints(
) -> CustomResult<Vec<PaymentIntent>, errors::StorageError> {
let db = &*state.store;
let result = db
- .filter_payment_intent_by_constraints(
- &(state).into(),
- merchant_id,
- constraints,
- key_store,
- storage_scheme,
- )
+ .filter_payment_intent_by_constraints(merchant_id, constraints, key_store, storage_scheme)
.await?;
Ok(result)
}
@@ -3612,12 +3572,10 @@ pub async fn make_client_secret(
headers: &actix_web::http::header::HeaderMap,
) -> errors::RouterResponse<ClientSecretResponse> {
let db = &state.store;
- let key_manager_state = &((&state).into());
match &resource_id {
api_models::ephemeral_key::ResourceId::Customer(global_customer_id) => {
db.find_customer_by_global_id(
- key_manager_state,
global_customer_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -4018,7 +3976,6 @@ pub async fn verify_payment_intent_time_and_client_secret(
#[cfg(feature = "v1")]
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -4403,7 +4360,6 @@ pub async fn get_merchant_connector_account(
merchant_connector_id: Option<&id_type::MerchantConnectorAccountId>,
) -> RouterResult<MerchantConnectorAccountType> {
let db = &*state.store;
- let key_manager_state: &KeyManagerState = &state.into();
match creds_identifier {
Some(creds_identifier) => {
let key = merchant_id.get_creds_identifier_key(creds_identifier);
@@ -4482,7 +4438,6 @@ pub async fn get_merchant_connector_account(
#[cfg(feature = "v1")]
{
db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
merchant_connector_id,
key_store,
@@ -4496,23 +4451,18 @@ pub async fn get_merchant_connector_account(
}
#[cfg(feature = "v2")]
{
- db.find_merchant_connector_account_by_id(
- &state.into(),
- merchant_connector_id,
- key_store,
- )
- .await
- .to_not_found_response(
- errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
- id: merchant_connector_id.get_string_repr().to_string(),
- },
- )
+ db.find_merchant_connector_account_by_id(merchant_connector_id, key_store)
+ .await
+ .to_not_found_response(
+ errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
+ id: merchant_connector_id.get_string_repr().to_string(),
+ },
+ )
}
} else {
#[cfg(feature = "v1")]
{
db.find_merchant_connector_account_by_profile_id_connector_name(
- key_manager_state,
profile_id,
connector_name,
key_store,
@@ -4899,7 +4849,6 @@ impl AttemptType {
Self::SameOld => Ok((fetched_payment_intent, fetched_payment_attempt)),
Self::New => {
let db = &*state.store;
- let key_manager_state = &state.into();
let new_attempt_count = fetched_payment_intent.attempt_count + 1;
let new_payment_attempt_to_insert = Self::make_new_payment_attempt(
request
@@ -4924,7 +4873,6 @@ impl AttemptType {
#[cfg(feature = "v2")]
let new_payment_attempt = db
.insert_payment_attempt(
- key_manager_state,
key_store,
new_payment_attempt_to_insert,
storage_scheme,
@@ -4935,7 +4883,6 @@ impl AttemptType {
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
fetched_payment_intent,
storage::PaymentIntentUpdate::StatusAndAttemptUpdate {
status: payment_intent_status_fsm(
@@ -5839,7 +5786,6 @@ where
let merchant_connector_account_list = state
.store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
platform.get_processor().get_account().get_id(),
false,
platform.get_processor().get_key_store(),
@@ -7583,7 +7529,6 @@ pub async fn validate_merchant_connector_ids_in_connector_mandate_details(
let db = &*state.store;
let merchant_connector_account_list = db
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
merchant_id,
true,
key_store,
@@ -7875,7 +7820,6 @@ pub async fn validate_allowed_payment_method_types_request(
let db = &*state.store;
let all_connector_accounts = db
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
platform.get_processor().get_account().get_id(),
false,
platform.get_processor().get_key_store(),
@@ -7999,7 +7943,7 @@ pub async fn get_merchant_connector_account_v2(
let db = &*state.store;
match merchant_connector_id {
Some(merchant_connector_id) => db
- .find_merchant_connector_account_by_id(&state.into(), merchant_connector_id, key_store)
+ .find_merchant_connector_account_by_id(merchant_connector_id, key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
id: merchant_connector_id.get_string_repr().to_string(),
@@ -8257,7 +8201,6 @@ async fn save_new_connector_customer_id_from_ucs(
let db = &*state.store;
let _ = db
.update_customer_by_customer_id_merchant_id(
- &state.into(),
customer_data.customer_id.clone(),
customer_data.merchant_id.clone(),
customer_data.clone(),
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index e171029e86..da9d06ef33 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -610,7 +610,6 @@ where
// This function is to retrieve customer details. If the customer is deleted, it returns
// customer details that contains the fields as Redacted
db.find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
- &state.into(),
customer_id,
&merchant_key_store.merchant_id,
merchant_key_store,
@@ -696,7 +695,6 @@ where
None => None,
Some(customer_id) => {
db.find_customer_optional_by_customer_id_merchant_id(
- &state.into(),
customer_id,
&merchant_key_store.merchant_id,
merchant_key_store,
@@ -800,7 +798,6 @@ where
None => None,
Some(customer_id) => {
db.find_customer_optional_by_customer_id_merchant_id(
- &state.into(),
customer_id,
&merchant_key_store.merchant_id,
merchant_key_store,
diff --git a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
index a4a23eb8c4..ce4937b5f3 100644
--- a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
+++ b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
@@ -180,7 +180,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ExternalVaultP
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -218,7 +217,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ExternalVaultP
let payment_attempt = match payment_intent.active_attempt_id.clone() {
Some(ref active_attempt_id) => db
.find_payment_attempt_by_id(
- key_manager_state,
platform.get_processor().get_key_store(),
active_attempt_id,
storage_scheme,
@@ -239,7 +237,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ExternalVaultP
)
.await?;
db.insert_payment_attempt(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_attempt_domain_model,
storage_scheme,
@@ -324,12 +321,7 @@ impl<F: Clone + Send + Sync> Domain<F, ExternalVaultProxyPaymentsRequest, Paymen
Some(id) => {
let customer = state
.store
- .find_customer_by_global_id(
- &state.into(),
- &id,
- merchant_key_store,
- storage_scheme,
- )
+ .find_customer_by_global_id(&id, merchant_key_store, storage_scheme)
.await?;
Ok((Box::new(self), Some(customer)))
@@ -497,7 +489,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ExternalVaultProxy
F: 'b + Send,
{
let db = &*state.store;
- let key_manager_state = &state.into();
let intent_status = common_enums::IntentStatus::Processing;
let attempt_status = common_enums::AttemptStatus::Pending;
@@ -554,7 +545,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ExternalVaultProxy
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent.clone(),
payment_intent_update,
key_store,
@@ -568,7 +558,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ExternalVaultProxy
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt.clone(),
payment_attempt_update,
@@ -609,7 +598,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
use hyperswitch_domain_models::router_data::TrackerPostUpdateObjects;
let db = &*state.store;
- let key_manager_state = &state.into();
let response_router_data = response;
@@ -620,7 +608,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent,
payment_intent_update,
key_store,
@@ -632,7 +619,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt,
payment_attempt_update,
diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs
index 1645e74be1..ed76a91089 100644
--- a/crates/router/src/core/payments/operations/payment_approve.rs
+++ b/crates/router/src/core/payments/operations/payment_approve.rs
@@ -48,7 +48,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR
operations::GetTrackerResponse<'a, F, api::PaymentsCaptureRequest, PaymentData<F>>,
> {
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let (mut payment_intent, payment_attempt, currency, amount);
@@ -59,7 +58,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR
payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -84,7 +82,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR
let business_profile = state
.store
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -253,7 +250,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsCaptureReque
payment_data.payment_intent = state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent,
intent_status_update,
key_store,
diff --git a/crates/router/src/core/payments/operations/payment_attempt_list.rs b/crates/router/src/core/payments/operations/payment_attempt_list.rs
index 4b6188c72f..4d5ff73ecb 100644
--- a/crates/router/src/core/payments/operations/payment_attempt_list.rs
+++ b/crates/router/src/core/payments/operations/payment_attempt_list.rs
@@ -92,11 +92,9 @@ impl<F: Send + Clone + Sync>
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<operations::GetTrackerResponse<payments::PaymentAttemptListData<F>>> {
let db = &*state.store;
- let key_manager_state = &state.into();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_attempt_list = db
.find_payment_attempts_by_payment_intent_id(
- key_manager_state,
&request.payment_intent_id,
platform.get_processor().get_key_store(),
storage_scheme,
diff --git a/crates/router/src/core/payments/operations/payment_attempt_record.rs b/crates/router/src/core/payments/operations/payment_attempt_record.rs
index be08134469..033b81ded6 100644
--- a/crates/router/src/core/payments/operations/payment_attempt_record.rs
+++ b/crates/router/src/core/payments/operations/payment_attempt_record.rs
@@ -129,7 +129,6 @@ impl<F: Send + Clone + Sync>
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -187,7 +186,6 @@ impl<F: Send + Clone + Sync>
let payment_attempt = db
.insert_payment_attempt(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_attempt_domain_model,
storage_scheme,
@@ -276,7 +274,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentAttemptRecordData<F>, PaymentsAtte
payment_data.payment_intent = state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent,
payment_intent_update,
key_store,
diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs
index 6d7432e8eb..5c591f8190 100644
--- a/crates/router/src/core/payments/operations/payment_cancel.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel.rs
@@ -48,7 +48,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
operations::GetTrackerResponse<'a, F, api::PaymentsCancelRequest, PaymentData<F>>,
> {
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -58,7 +57,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -153,7 +151,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -273,7 +270,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsCancelReques
payment_data.payment_intent = state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent,
payment_intent_update,
key_store,
diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
index fb3d5ba14c..e359cdecb5 100644
--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
@@ -51,7 +51,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPo
>,
> {
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -61,7 +60,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPo
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -136,7 +134,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPo
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
diff --git a/crates/router/src/core/payments/operations/payment_cancel_v2.rs b/crates/router/src/core/payments/operations/payment_cancel_v2.rs
index b28a51013e..e1287d6b30 100644
--- a/crates/router/src/core/payments/operations/payment_cancel_v2.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel_v2.rs
@@ -140,13 +140,11 @@ impl<F: Send + Clone + Sync>
operations::GetTrackerResponse<hyperswitch_domain_models::payments::PaymentCancelData<F>>,
> {
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -166,7 +164,6 @@ impl<F: Send + Clone + Sync>
let payment_attempt = db
.find_payment_attempt_by_id(
- key_manager_state,
platform.get_processor().get_key_store(),
active_attempt_id,
storage_scheme,
@@ -218,7 +215,6 @@ impl<F: Clone + Send + Sync>
F: 'b + Send,
{
let db = &*state.store;
- let key_manager_state = &state.into();
let payment_attempt_update = hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::VoidUpdate {
status: enums::AttemptStatus::VoidInitiated,
@@ -228,7 +224,6 @@ impl<F: Clone + Send + Sync>
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
merchant_key_store,
payment_data.payment_attempt.clone(),
payment_attempt_update,
diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs
index 9b78264b44..4ec9151b1e 100644
--- a/crates/router/src/core/payments/operations/payment_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_capture.rs
@@ -53,7 +53,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen
>,
> {
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -65,7 +64,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen
payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -209,7 +207,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
diff --git a/crates/router/src/core/payments/operations/payment_capture_v2.rs b/crates/router/src/core/payments/operations/payment_capture_v2.rs
index 3d5306a2d7..c1b97e38dd 100644
--- a/crates/router/src/core/payments/operations/payment_capture_v2.rs
+++ b/crates/router/src/core/payments/operations/payment_capture_v2.rs
@@ -150,13 +150,11 @@ impl<F: Send + Clone> GetTracker<F, PaymentCaptureData<F>, PaymentsCaptureReques
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<operations::GetTrackerResponse<PaymentCaptureData<F>>> {
let db = &*state.store;
- let key_manager_state = &state.into();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -175,7 +173,6 @@ impl<F: Send + Clone> GetTracker<F, PaymentCaptureData<F>, PaymentsCaptureReques
let mut payment_attempt = db
.find_payment_attempt_by_id(
- key_manager_state,
platform.get_processor().get_key_store(),
active_attempt_id,
storage_scheme,
@@ -226,12 +223,7 @@ impl<F: Clone + Send> Domain<F, PaymentsCaptureRequest, PaymentCaptureData<F>> f
Some(id) => {
let customer = state
.store
- .find_customer_by_global_id(
- &state.into(),
- &id,
- merchant_key_store,
- storage_scheme,
- )
+ .find_customer_by_global_id(&id, merchant_key_store, storage_scheme)
.await?;
Ok((Box::new(self), Some(customer)))
@@ -318,7 +310,6 @@ impl<F: Clone> UpdateTracker<F, PaymentCaptureData<F>, PaymentsCaptureRequest> f
let payment_attempt = state
.store
.update_payment_attempt(
- &state.into(),
key_store,
payment_data.payment_attempt.clone(),
payment_attempt_update,
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index d32208a7c9..5e6714880b 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -47,7 +47,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>
{
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -59,7 +58,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -291,7 +289,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -505,7 +502,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
let updated_payment_intent = db
.update_payment_intent(
- &state.into(),
payment_intent,
payment_intent_update,
key_store,
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index eaf3a011e3..1a42b4b21e 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -79,8 +79,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>
{
- let key_manager_state = &state.into();
-
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let (currency, amount);
@@ -96,7 +94,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
// Parallel calls - level 0
let mut payment_intent = store
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
&m_merchant_id,
platform.get_processor().get_key_store(),
@@ -163,17 +160,12 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
.attach_printable("'profile_id' not set in payment intent")?;
let store = state.store.clone();
- let key_manager_state_clone = key_manager_state.clone();
let key_store_clone = platform.get_processor().get_key_store().clone();
let business_profile_fut = tokio::spawn(
async move {
store
- .find_business_profile_by_profile_id(
- &key_manager_state_clone,
- &key_store_clone,
- &profile_id,
- )
+ .find_business_profile_by_profile_id(&key_store_clone, &profile_id)
.map(|business_profile_result| {
business_profile_result.to_not_found_response(
errors::ApiErrorResponse::ProfileNotFound {
@@ -1268,12 +1260,10 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
.change_context(errors::ApiErrorResponse::MissingRequiredField {
field_name: "authentication_product_ids",
})?;
- let key_manager_state = &(state).into();
let merchant_id = &business_profile.merchant_id;
let connector_mca = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
&click_to_pay_mca_id,
key_store,
@@ -2060,13 +2050,11 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
let m_storage_scheme = storage_scheme.to_string();
let session_expiry = m_payment_data_payment_intent.session_expiry;
let m_key_store = key_store.clone();
- let key_manager_state = state.into();
let is_payment_processor_token_flow =
payment_data.payment_intent.is_payment_processor_token_flow;
let payment_intent_fut = tokio::spawn(
async move {
m_db.update_payment_intent(
- &key_manager_state,
m_payment_data_payment_intent,
storage::PaymentIntentUpdate::Update(Box::new(PaymentIntentUpdateFields {
amount: payment_data.payment_intent.amount,
@@ -2133,12 +2121,10 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
let m_updated_customer = updated_customer.clone();
let session_state = state.clone();
let m_db = session_state.store.clone();
- let key_manager_state = state.into();
tokio::spawn(
async move {
let m_customer_customer_id = customer.customer_id.to_owned();
m_db.update_customer_by_customer_id_merchant_id(
- &key_manager_state,
m_customer_customer_id,
m_customer_merchant_id,
customer,
diff --git a/crates/router/src/core/payments/operations/payment_confirm_intent.rs b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
index 3ace5c46b0..f1807ebe78 100644
--- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
@@ -167,7 +167,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, PaymentsConfir
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -216,7 +215,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, PaymentsConfir
let payment_attempt: hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt =
db.insert_payment_attempt(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_attempt_domain_model,
storage_scheme,
@@ -309,7 +307,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, PaymentsConfir
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -360,7 +357,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, PaymentsConfir
let payment_attempt: hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt =
db.insert_payment_attempt(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_attempt_domain_model,
storage_scheme,
@@ -430,12 +426,7 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsConfirmIntentRequest, PaymentConf
Some(id) => {
let customer = state
.store
- .find_customer_by_global_id(
- &state.into(),
- &id,
- merchant_key_store,
- storage_scheme,
- )
+ .find_customer_by_global_id(&id, merchant_key_store, storage_scheme)
.await?;
Ok((Box::new(self), Some(customer)))
@@ -738,7 +729,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, PaymentsConfirmInt
F: 'b + Send,
{
let db = &*state.store;
- let key_manager_state = &state.into();
let intent_status = common_enums::IntentStatus::Processing;
let attempt_status = common_enums::AttemptStatus::Pending;
@@ -816,7 +806,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, PaymentsConfirmInt
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent.clone(),
payment_intent_update,
key_store,
@@ -830,7 +819,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, PaymentsConfirmInt
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt.clone(),
payment_attempt_update,
@@ -848,7 +836,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, PaymentsConfirmInt
let _updated_customer = db
.update_customer_by_global_id(
- key_manager_state,
&customer_id,
customer,
updated_customer,
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 69982eef12..38f76fd0db 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -81,7 +81,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>
{
let db = &*state.store;
- let key_manager_state = &state.into();
let ephemeral_key = Self::get_ephemeral_key(request, state, platform).await;
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -102,7 +101,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
// If profile id is not passed, get it from the business_country and business_label
#[cfg(feature = "v1")]
let profile_id = core_utils::get_profile_id_from_business_details(
- key_manager_state,
request.business_country,
request.business_label.as_ref(),
platform,
@@ -125,7 +123,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
let business_profile = if let Some(business_profile) =
core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
merchant_id,
@@ -135,7 +132,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
business_profile
} else {
db.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
&profile_id,
)
@@ -339,7 +335,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
let payment_intent = db
.insert_payment_intent(
- key_manager_state,
payment_intent_new,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -367,12 +362,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
#[cfg(feature = "v2")]
let payment_attempt = db
- .insert_payment_attempt(
- key_manager_state,
- merchant_key_store,
- payment_attempt_new,
- storage_scheme,
- )
+ .insert_payment_attempt(merchant_key_store, payment_attempt_new, storage_scheme)
.await
.to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {
payment_id: payment_id.clone(),
@@ -690,8 +680,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
if is_tax_connector_enabled && !skip_external_tax_calculation {
let db = state.store.as_ref();
- let key_manager_state: &KeyManagerState = &state.into();
-
let merchant_connector_id = business_profile
.tax_connector_id
.as_ref()
@@ -700,7 +688,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
#[cfg(feature = "v1")]
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&business_profile.merchant_id,
merchant_connector_id,
platform.get_processor().get_key_store(),
@@ -714,11 +701,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
#[cfg(feature = "v2")]
let mca = db
- .find_merchant_connector_account_by_id(
- key_manager_state,
- merchant_connector_id,
- key_store,
- )
+ .find_merchant_connector_account_by_id(merchant_connector_id, key_store)
.await
.to_not_found_response(
errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
@@ -941,7 +924,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
payment_data.payment_intent = state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent,
storage::PaymentIntentUpdate::PaymentCreateUpdate {
return_url: None,
diff --git a/crates/router/src/core/payments/operations/payment_create_intent.rs b/crates/router/src/core/payments/operations/payment_create_intent.rs
index ab0bcb5853..32dbecc10c 100644
--- a/crates/router/src/core/payments/operations/payment_create_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_create_intent.rs
@@ -148,7 +148,6 @@ impl<F: Send + Clone + Sync>
let payment_intent = db
.insert_payment_intent(
- key_manager_state,
payment_intent_domain,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -253,7 +252,7 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsCreateIntentRequest, payments::Pa
if let Some(id) = payment_data.payment_intent.customer_id.clone() {
state
.store
- .find_customer_by_global_id(&state.into(), &id, merchant_key_store, storage_scheme)
+ .find_customer_by_global_id(&id, merchant_key_store, storage_scheme)
.await?;
}
Ok((Box::new(self), None))
diff --git a/crates/router/src/core/payments/operations/payment_get.rs b/crates/router/src/core/payments/operations/payment_get.rs
index a26e68c50b..077a9cb88e 100644
--- a/crates/router/src/core/payments/operations/payment_get.rs
+++ b/crates/router/src/core/payments/operations/payment_get.rs
@@ -160,13 +160,11 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentStatusData<F>, PaymentsRetriev
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<operations::GetTrackerResponse<PaymentStatusData<F>>> {
let db = &*state.store;
- let key_manager_state = &state.into();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -184,7 +182,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentStatusData<F>, PaymentsRetriev
let mut payment_attempt = db
.find_payment_attempt_by_id(
- key_manager_state,
platform.get_processor().get_key_store(),
active_attempt_id,
storage_scheme,
@@ -224,7 +221,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentStatusData<F>, PaymentsRetriev
.as_ref()
.async_map(|active_attempt| async {
db.find_payment_attempts_by_payment_intent_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -272,12 +268,7 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsRetrieveRequest, PaymentStatusDat
Some(id) => {
let customer = state
.store
- .find_customer_by_global_id(
- &state.into(),
- &id,
- merchant_key_store,
- storage_scheme,
- )
+ .find_customer_by_global_id(&id, merchant_key_store, storage_scheme)
.await?;
Ok((Box::new(self), Some(customer)))
diff --git a/crates/router/src/core/payments/operations/payment_get_intent.rs b/crates/router/src/core/payments/operations/payment_get_intent.rs
index f8f4576158..fba938a58f 100644
--- a/crates/router/src/core/payments/operations/payment_get_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_get_intent.rs
@@ -90,11 +90,9 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentIntentData<F>, Payme
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<operations::GetTrackerResponse<payments::PaymentIntentData<F>>> {
let db = &*state.store;
- let key_manager_state = &state.into();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
&request.id,
platform.get_processor().get_key_store(),
storage_scheme,
diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
index 890424efc1..641c8e6a36 100644
--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
@@ -2,7 +2,6 @@ use std::marker::PhantomData;
use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
-use common_utils::types::keymanager::KeyManagerState;
use error_stack::ResultExt;
use masking::PeekInterface;
use router_derive::PaymentOperation;
@@ -57,12 +56,10 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSess
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
let db = &*state.store;
- let key_manager_state: &KeyManagerState = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -94,7 +91,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSess
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs
index 6dc7788ba6..218a196909 100644
--- a/crates/router/src/core/payments/operations/payment_reject.rs
+++ b/crates/router/src/core/payments/operations/payment_reject.rs
@@ -44,7 +44,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequest
) -> RouterResult<operations::GetTrackerResponse<'a, F, PaymentsCancelRequest, PaymentData<F>>>
{
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -54,7 +53,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequest
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -140,7 +138,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequest
let business_profile = state
.store
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -261,7 +258,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, PaymentsCancelRequest> fo
payment_data.payment_intent = state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent,
intent_status_update,
key_store,
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index 76e4c52377..f008c13bef 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -9,7 +9,7 @@ use common_enums::AuthorizationStatus;
use common_utils::ext_traits::ValueExt;
use common_utils::{
ext_traits::{AsyncExt, Encode},
- types::{keymanager::KeyManagerState, ConnectorTransactionId, MinorUnit},
+ types::{ConnectorTransactionId, MinorUnit},
};
use error_stack::{report, ResultExt};
use futures::FutureExt;
@@ -255,7 +255,6 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor
match state
.store
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
payment_method_id,
storage_scheme,
@@ -481,7 +480,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsIncrementalAu
payment_data.payment_intent = state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent.clone(),
payment_intent_update,
key_store,
@@ -749,11 +747,9 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SdkPaymentsSessionUpd
let m_db = db.clone().store;
let payment_intent = payment_data.payment_intent.clone();
- let key_manager_state: KeyManagerState = db.into();
let updated_payment_intent = m_db
.update_payment_intent(
- &key_manager_state,
payment_intent,
payment_intent_update,
key_store,
@@ -894,7 +890,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsUpdateMetadat
if status.is_success() {
let m_db = db.clone().store;
let payment_intent = payment_data.payment_intent.clone();
- let key_manager_state: KeyManagerState = db.into();
let payment_intent_update =
hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdate::MetadataUpdate {
@@ -909,7 +904,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsUpdateMetadat
let updated_payment_intent = m_db
.update_payment_intent(
- &key_manager_state,
payment_intent,
payment_intent_update,
key_store,
@@ -1297,7 +1291,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
match state
.store
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -1847,7 +1840,6 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
)?;
// Update the payment method table with the active mandate record
payment_methods::cards::update_payment_method_connector_mandate_details(
- state,
key_store,
&*state.store,
payment_method,
@@ -2206,11 +2198,9 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
let m_key_store = key_store.clone();
let m_payment_data_payment_intent = payment_data.payment_intent.clone();
let m_payment_intent_update = payment_intent_update.clone();
- let key_manager_state: KeyManagerState = state.into();
let payment_intent_fut = tokio::spawn(
async move {
m_db.update_payment_intent(
- &key_manager_state,
m_payment_data_payment_intent,
m_payment_intent_update,
&m_key_store,
@@ -2454,7 +2444,7 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
if let Some(id) = &payment_data.payment_attempt.payment_method_id {
let payment_method = match state
.store
- .find_payment_method(&(state.into()), key_store, id, storage_scheme)
+ .find_payment_method(key_store, id, storage_scheme)
.await
{
Ok(payment_method) => payment_method,
@@ -2518,13 +2508,7 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
state
.store
- .update_payment_method(
- &(state.into()),
- key_store,
- payment_method,
- pm_update,
- storage_scheme,
- )
+ .update_payment_method(key_store, payment_method, pm_update, storage_scheme)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update payment method in db")?;
@@ -2597,7 +2581,6 @@ impl<F: Clone>
use hyperswitch_domain_models::router_data::TrackerPostUpdateObjects;
let db = &*state.store;
- let key_manager_state = &state.into();
let response_router_data = response;
@@ -2609,7 +2592,6 @@ impl<F: Clone>
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent,
payment_intent_update,
key_store,
@@ -2621,7 +2603,6 @@ impl<F: Clone>
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt,
payment_attempt_update,
@@ -2663,7 +2644,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
use hyperswitch_domain_models::router_data::TrackerPostUpdateObjects;
let db = &*state.store;
- let key_manager_state = &state.into();
let response_router_data = response;
@@ -2674,7 +2654,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent,
payment_intent_update,
key_store,
@@ -2686,7 +2665,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt,
payment_attempt_update,
@@ -2837,7 +2815,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentStatusData<F>, types::PaymentsSyncDat
use hyperswitch_domain_models::router_data::TrackerPostUpdateObjects;
let db = &*state.store;
- let key_manager_state = &state.into();
let response_router_data = response;
@@ -2850,7 +2827,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentStatusData<F>, types::PaymentsSyncDat
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent,
payment_intent_update,
key_store,
@@ -2862,7 +2838,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentStatusData<F>, types::PaymentsSyncDat
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_attempt,
payment_attempt_update,
@@ -2988,7 +2963,6 @@ impl
use hyperswitch_domain_models::router_data::TrackerPostUpdateObjects;
let db = &*state.store;
- let key_manager_state = &state.into();
let response_router_data = response;
@@ -2999,7 +2973,6 @@ impl
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent,
payment_intent_update,
key_store,
@@ -3011,7 +2984,6 @@ impl
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt,
payment_attempt_update,
@@ -3055,7 +3027,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::SetupMandateRe
use hyperswitch_domain_models::router_data::TrackerPostUpdateObjects;
let db = &*state.store;
- let key_manager_state = &state.into();
let response_router_data = response;
@@ -3066,7 +3037,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::SetupMandateRe
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent,
payment_intent_update,
key_store,
@@ -3078,7 +3048,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::SetupMandateRe
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt,
payment_attempt_update,
@@ -3370,7 +3339,6 @@ impl<F: Clone + Send + Sync>
>,
{
let db = &*state.store;
- let key_manager_state = &state.into();
use hyperswitch_domain_models::router_data::TrackerPostUpdateObjects;
@@ -3379,7 +3347,6 @@ impl<F: Clone + Send + Sync>
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent.clone(),
payment_intent_update,
key_store,
@@ -3394,7 +3361,6 @@ impl<F: Clone + Send + Sync>
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt.clone(),
payment_attempt_update,
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index 0838f9feb4..d1db658680 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -51,13 +51,11 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionR
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let mut payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -164,7 +162,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionR
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -267,7 +264,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsSessionReque
Some(metadata) => state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent,
storage::PaymentIntentUpdate::MetadataUpdate {
metadata,
@@ -380,7 +376,6 @@ where
let all_connector_accounts = db
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
platform.get_processor().get_account().get_id(),
false,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/payments/operations/payment_session_intent.rs b/crates/router/src/core/payments/operations/payment_session_intent.rs
index 2d794359f7..4c807915f0 100644
--- a/crates/router/src/core/payments/operations/payment_session_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_session_intent.rs
@@ -126,12 +126,10 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentIntentData<F>, Payme
header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<operations::GetTrackerResponse<payments::PaymentIntentData<F>>> {
let db = &*state.store;
- let key_manager_state = &state.into();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -186,7 +184,6 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsS
Some(prerouting_algorithm) => state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent,
storage::PaymentIntentUpdate::SessionIntentUpdate {
prerouting_algorithm,
@@ -243,12 +240,7 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsSessionRequest, payments::Payment
Some(id) => {
let customer = state
.store
- .find_customer_by_global_id(
- &state.into(),
- &id,
- merchant_key_store,
- storage_scheme,
- )
+ .find_customer_by_global_id(&id, merchant_key_store, storage_scheme)
.await?;
Ok((Box::new(self), Some(customer)))
}
@@ -284,7 +276,6 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsSessionRequest, payments::Payment
let db = &state.store;
let all_connector_accounts = db
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
platform.get_processor().get_account().get_id(),
false,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs
index 18e82a4662..b2a7fdb20c 100644
--- a/crates/router/src/core/payments/operations/payment_start.rs
+++ b/crates/router/src/core/payments/operations/payment_start.rs
@@ -47,7 +47,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReq
> {
let (mut payment_intent, payment_attempt, currency, amount);
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -57,7 +56,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReq
payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -151,7 +149,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReq
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index 98a0543b78..a4704e75d2 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -2,7 +2,7 @@ use std::marker::PhantomData;
use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
-use common_utils::{ext_traits::AsyncExt, types::keymanager::KeyManagerState};
+use common_utils::ext_traits::AsyncExt;
use error_stack::ResultExt;
use router_derive::PaymentOperation;
use router_env::{instrument, logger, tracing};
@@ -307,7 +307,6 @@ async fn get_tracker_for_sync<
payment_attempt.encoded_data.clone_from(&request.param);
let db = &*state.store;
- let key_manager_state = &state.into();
let attempts = match request.expand_attempts {
Some(true) => {
Some(db
@@ -421,11 +420,7 @@ async fn get_tracker_for_sync<
.attach_printable("'profile_id' not set in payment intent")?;
let business_profile = db
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -435,7 +430,6 @@ async fn get_tracker_for_sync<
if let Some(ref payment_method_id) = payment_attempt.payment_method_id.clone() {
match db
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
payment_method_id,
storage_scheme,
@@ -609,7 +603,6 @@ pub async fn get_payment_intent_payment_attempt(
key_store: &domain::MerchantKeyStore,
storage_scheme: enums::MerchantStorageScheme,
) -> RouterResult<(storage::PaymentIntent, storage::PaymentAttempt)> {
- let key_manager_state: KeyManagerState = state.into();
let db = &*state.store;
let get_pi_pa = || async {
let (pi, pa);
@@ -617,7 +610,6 @@ pub async fn get_payment_intent_payment_attempt(
api_models::payments::PaymentIdType::PaymentIntentId(ref id) => {
pi = db
.find_payment_intent_by_payment_id_merchant_id(
- &key_manager_state,
id,
merchant_id,
key_store,
@@ -643,7 +635,6 @@ pub async fn get_payment_intent_payment_attempt(
.await?;
pi = db
.find_payment_intent_by_payment_id_merchant_id(
- &key_manager_state,
&pa.payment_id,
merchant_id,
key_store,
@@ -657,7 +648,6 @@ pub async fn get_payment_intent_payment_attempt(
.await?;
pi = db
.find_payment_intent_by_payment_id_merchant_id(
- &key_manager_state,
&pa.payment_id,
merchant_id,
key_store,
@@ -676,7 +666,6 @@ pub async fn get_payment_intent_payment_attempt(
pi = db
.find_payment_intent_by_payment_id_merchant_id(
- &key_manager_state,
&pa.payment_id,
merchant_id,
key_store,
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index 3ecda35a5f..a9bbc8881b 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -7,7 +7,6 @@ use async_trait::async_trait;
use common_utils::{
ext_traits::{AsyncExt, Encode, ValueExt},
pii::Email,
- types::keymanager::KeyManagerState,
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::payments::payment_intent::{
@@ -66,12 +65,10 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let db = &*state.store;
- let key_manager_state = &state.into();
helpers::allow_payment_update_enabled_for_client_auth(merchant_id, state, auth_flow)
.await?;
payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -435,7 +432,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -578,7 +574,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
.unwrap_or(false);
if is_tax_connector_enabled && !skip_external_tax_calculation {
let db = state.store.as_ref();
- let key_manager_state: &KeyManagerState = &state.into();
let merchant_connector_id = business_profile
.tax_connector_id
@@ -588,7 +583,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
#[cfg(feature = "v1")]
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&business_profile.merchant_id,
merchant_connector_id,
platform.get_processor().get_key_store(),
@@ -602,11 +596,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
#[cfg(feature = "v2")]
let mca = db
- .find_merchant_connector_account_by_id(
- key_manager_state,
- merchant_connector_id,
- key_store,
- )
+ .find_merchant_connector_account_by_id(merchant_connector_id, key_store)
.await
.to_not_found_response(
errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
@@ -927,7 +917,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
payment_data.payment_intent = state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent.clone(),
storage::PaymentIntentUpdate::Update(Box::new(PaymentIntentUpdateFields {
amount: payment_data.amount.into(),
diff --git a/crates/router/src/core/payments/operations/payment_update_intent.rs b/crates/router/src/core/payments/operations/payment_update_intent.rs
index 80f45887cf..bda8e1dfb5 100644
--- a/crates/router/src/core/payments/operations/payment_update_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_update_intent.rs
@@ -157,7 +157,6 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentIntentData<F>, PaymentsUpda
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -343,7 +342,6 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsUpdateIn
F: 'b + Send,
{
let db = &*state.store;
- let key_manager_state = &state.into();
let intent = payment_data.payment_intent.clone();
@@ -397,7 +395,6 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsUpdateIn
let new_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent,
payment_intent_update,
key_store,
diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rs
index bad44f7c97..07940cf803 100644
--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs
+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs
@@ -2,7 +2,6 @@ use std::marker::PhantomData;
use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
-use common_utils::types::keymanager::KeyManagerState;
use error_stack::ResultExt;
use masking::ExposeInterface;
use router_derive::PaymentOperation;
@@ -52,12 +51,10 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsUpdateMe
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
let db = &*state.store;
- let key_manager_state: &KeyManagerState = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let mut payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -98,7 +95,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsUpdateMe
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rs
index 139776f11f..adb3ca5de1 100644
--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs
@@ -51,7 +51,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsExtendAu
>,
> {
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -61,7 +60,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsExtendAu
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- key_manager_state,
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -141,7 +139,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsExtendAu
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
index 196ed7fef9..2c06983e5f 100644
--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
@@ -56,7 +56,6 @@ impl<F: Send + Clone + Sync>
>,
> {
let db = &*state.store;
- let key_manager_state = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
@@ -66,7 +65,6 @@ impl<F: Send + Clone + Sync>
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -120,7 +118,6 @@ impl<F: Send + Clone + Sync>
let business_profile = state
.store
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -266,7 +263,6 @@ impl<F: Clone + Sync>
payment_data.payment_intent = state
.store
.update_payment_intent(
- &state.into(),
payment_data.payment_intent.clone(),
storage::PaymentIntentUpdate::AuthorizationCountUpdate {
authorization_count: new_authorization_count,
diff --git a/crates/router/src/core/payments/operations/proxy_payments_intent.rs b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
index de95d63d57..a88efcbc12 100644
--- a/crates/router/src/core/payments/operations/proxy_payments_intent.rs
+++ b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
@@ -158,7 +158,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ProxyPaymentsR
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
storage_scheme,
@@ -196,7 +195,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ProxyPaymentsR
let payment_attempt = match payment_intent.active_attempt_id.clone() {
Some(ref active_attempt_id) => db
.find_payment_attempt_by_id(
- key_manager_state,
platform.get_processor().get_key_store(),
active_attempt_id,
storage_scheme,
@@ -216,7 +214,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ProxyPaymentsR
)
.await?;
db.insert_payment_attempt(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_attempt_domain_model,
storage_scheme,
@@ -376,7 +373,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ProxyPaymentsReque
F: 'b + Send,
{
let db = &*state.store;
- let key_manager_state = &state.into();
let intent_status = common_enums::IntentStatus::Processing;
let attempt_status = common_enums::AttemptStatus::Pending;
@@ -433,7 +429,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ProxyPaymentsReque
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent.clone(),
payment_intent_update,
key_store,
@@ -447,7 +442,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ProxyPaymentsReque
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt.clone(),
payment_attempt_update,
@@ -488,7 +482,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
use hyperswitch_domain_models::router_data::TrackerPostUpdateObjects;
let db = &*state.store;
- let key_manager_state = &state.into();
let response_router_data = response;
@@ -499,7 +492,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent,
payment_intent_update,
key_store,
@@ -511,7 +503,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
let updated_payment_attempt = db
.update_payment_attempt(
- key_manager_state,
key_store,
payment_data.payment_attempt,
payment_attempt_update,
diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs
index 052c70a16c..9ae32dde05 100644
--- a/crates/router/src/core/payments/operations/tax_calculation.rs
+++ b/crates/router/src/core/payments/operations/tax_calculation.rs
@@ -2,7 +2,7 @@ use std::marker::PhantomData;
use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
-use common_utils::{ext_traits::AsyncExt, types::keymanager::KeyManagerState};
+use common_utils::ext_traits::AsyncExt;
use error_stack::ResultExt;
use masking::PeekInterface;
use router_derive::PaymentOperation;
@@ -62,13 +62,11 @@ impl<F: Send + Clone + Sync>
.change_context(errors::ApiErrorResponse::PaymentNotFound)?;
let db = &*state.store;
- let key_manager_state: &KeyManagerState = &state.into();
let merchant_id = platform.get_processor().get_account().get_id();
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -125,7 +123,6 @@ impl<F: Send + Clone + Sync>
let business_profile = db
.find_business_profile_by_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
profile_id,
)
@@ -244,7 +241,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsDynamicTaxCalculationRequest
.unwrap_or(false);
if is_tax_connector_enabled && !skip_external_tax_calculation {
let db = state.store.as_ref();
- let key_manager_state: &KeyManagerState = &state.into();
let merchant_connector_id = business_profile
.tax_connector_id
@@ -254,7 +250,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsDynamicTaxCalculationRequest
#[cfg(feature = "v1")]
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&business_profile.merchant_id,
merchant_connector_id,
platform.get_processor().get_key_store(),
@@ -268,11 +263,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsDynamicTaxCalculationRequest
#[cfg(feature = "v2")]
let mca = db
- .find_merchant_connector_account_by_id(
- key_manager_state,
- merchant_connector_id,
- key_store,
- )
+ .find_merchant_connector_account_by_id(merchant_connector_id, key_store)
.await
.to_not_found_response(
errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
@@ -439,7 +430,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsDynamicTaxCa
let updated_payment_intent = db
.update_payment_intent(
- &state.into(),
payment_intent,
payment_intent_update,
key_store,
diff --git a/crates/router/src/core/payments/payment_methods.rs b/crates/router/src/core/payments/payment_methods.rs
index d883037ac7..7ae4c31111 100644
--- a/crates/router/src/core/payments/payment_methods.rs
+++ b/crates/router/src/core/payments/payment_methods.rs
@@ -32,11 +32,9 @@ pub async fn list_payment_methods(
header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
) -> errors::RouterResponse<api_models::payments::PaymentMethodListResponseForPayments> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
&payment_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -48,7 +46,6 @@ pub async fn list_payment_methods(
let payment_connector_accounts = db
.list_enabled_connector_accounts_by_profile_id(
- key_manager_state,
profile.get_id(),
platform.get_processor().get_key_store(),
common_enums::ConnectorType::PaymentProcessor,
diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs
index 4927f63b43..e1e739476b 100644
--- a/crates/router/src/core/payments/retry.rs
+++ b/crates/router/src/core/payments/retry.rs
@@ -467,7 +467,6 @@ where
);
let db = &*state.store;
- let key_manager_state = &state.into();
let additional_payment_method_data =
payments::helpers::update_additional_payment_data_with_connector_response_pm_data(
payment_data
@@ -636,12 +635,7 @@ where
#[cfg(feature = "v2")]
let payment_attempt = db
- .insert_payment_attempt(
- key_manager_state,
- key_store,
- new_payment_attempt,
- storage_scheme,
- )
+ .insert_payment_attempt(key_store, new_payment_attempt, storage_scheme)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error inserting payment attempt")?;
@@ -651,7 +645,6 @@ where
let payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.get_payment_intent().clone(),
storage::PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
active_attempt_id: payment_data.get_payment_attempt().get_id().to_owned(),
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index f2103092bc..c773dccc8d 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -856,7 +856,6 @@ pub async fn refresh_cgraph_cache(
let mut merchant_connector_accounts = state
.store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
&key_store.merchant_id,
false,
key_store,
@@ -2746,7 +2745,6 @@ pub async fn get_active_mca_ids(
let db_mcas = state
.store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
&key_store.merchant_id,
false,
key_store,
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index f6fc9e67af..255bee276e 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -387,7 +387,6 @@ where
let payment_method = {
let existing_pm_by_pmid = db
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
&payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -399,7 +398,6 @@ where
locker_id = Some(payment_method_id.clone());
let existing_pm_by_locker_id = db
.find_payment_method_by_locker_id(
- &(state.into()),
platform.get_processor().get_key_store(),
&payment_method_id,
platform
@@ -436,7 +434,6 @@ where
connector_token,
)?;
payment_methods::cards::update_payment_method_metadata_and_last_used(
- state,
platform.get_processor().get_key_store(),
db,
pm.clone(),
@@ -491,7 +488,6 @@ where
let payment_method = {
let existing_pm_by_pmid = db
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
&payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -503,7 +499,6 @@ where
locker_id = Some(payment_method_id.clone());
let existing_pm_by_locker_id = db
.find_payment_method_by_locker_id(
- &(state.into()),
platform.get_processor().get_key_store(),
&payment_method_id,
platform
@@ -557,7 +552,6 @@ where
ConnectorMandateStatus::Inactive,
)?;
payment_methods::cards::update_payment_method_connector_mandate_details(
- state,
platform.get_processor().get_key_store(),
db,
pm.clone(),
@@ -638,7 +632,6 @@ where
if let Err(err) = add_card_resp {
logger::error!(vault_err=?err);
db.delete_payment_method_by_merchant_id_payment_method_id(
- &(state.into()),
platform.get_processor().get_key_store(),
merchant_id,
&resp.payment_method_id,
@@ -711,7 +704,6 @@ where
.attach_printable("Unable to encrypt payment method data")?;
payment_methods::cards::update_payment_method_and_last_used(
- state,
platform.get_processor().get_key_store(),
db,
existing_pm,
@@ -736,7 +728,6 @@ where
match state
.store
.find_payment_method_by_customer_id_merchant_id_list(
- &(state.into()),
platform.get_processor().get_key_store(),
&customer_id,
merchant_id,
@@ -1170,12 +1161,9 @@ pub async fn save_in_locker_external(
let external_vault_mca_id = external_vault_connector_details.vault_connector_id.clone();
- let key_manager_state = &state.into();
-
let merchant_connector_account_details = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
platform.get_processor().get_account().get_id(),
&external_vault_mca_id,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/payments/vault_session.rs b/crates/router/src/core/payments/vault_session.rs
index 5a2bbec3bb..482267833d 100644
--- a/crates/router/src/core/payments/vault_session.rs
+++ b/crates/router/src/core/payments/vault_session.rs
@@ -102,7 +102,6 @@ where
let _updated_customer = db
.update_customer_by_global_id(
- &state.into(),
&customer_id,
customer,
updated_customer,
diff --git a/crates/router/src/core/payout_link.rs b/crates/router/src/core/payout_link.rs
index 12053dd113..3cc011c61d 100644
--- a/crates/router/src/core/payout_link.rs
+++ b/crates/router/src/core/payout_link.rs
@@ -138,7 +138,6 @@ pub async fn initiate_payout_link(
// Fetch customer
let customer = db
.find_customer_by_customer_id_merchant_id(
- &(&state).into(),
&customer_id,
&req.merchant_id,
platform.get_processor().get_key_store(),
@@ -157,7 +156,6 @@ pub async fn initiate_payout_link(
.as_ref()
.async_map(|address_id| async {
db.find_address_by_address_id(
- &(&state).into(),
address_id,
platform.get_processor().get_key_store(),
)
@@ -336,11 +334,9 @@ pub async fn filter_payout_methods(
use masking::ExposeInterface;
let db = &*state.store;
- let key_manager_state = &state.into();
//Fetch all merchant connector accounts
let all_mcas = db
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- key_manager_state,
platform.get_processor().get_account().get_id(),
false,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs
index dc0e89cad0..cce987b6ff 100644
--- a/crates/router/src/core/payouts.rs
+++ b/crates/router/src/core/payouts.rs
@@ -758,7 +758,6 @@ pub async fn payouts_list_core(
#[cfg(feature = "v1")]
Some(customer_id) => db
.find_customer_by_customer_id_merchant_id(
- &(&state).into(),
&customer_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -1255,7 +1254,6 @@ pub async fn create_recipient(
let customer_id = customer.customer_id.to_owned();
payout_data.customer_details = Some(
db.update_customer_by_customer_id_merchant_id(
- &state.into(),
customer_id,
platform.get_processor().get_account().get_id().to_owned(),
customer,
@@ -2221,7 +2219,6 @@ pub async fn create_recipient_disburse_account(
payout_data.payment_method = Some(
db.update_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
pm_method,
pm_update,
@@ -3064,7 +3061,6 @@ pub async fn make_payout_data(
let customer_details = customer_id
.async_map(|customer_id| async move {
db.find_customer_optional_by_customer_id_merchant_id(
- &state.into(),
customer_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -3180,7 +3176,6 @@ pub async fn make_payout_data(
.clone()
.async_map(|pm_id| async move {
db.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
&pm_id,
platform.get_processor().get_account().storage_scheme,
@@ -3252,11 +3247,9 @@ async fn validate_and_get_business_profile(
merchant_id: &id_type::MerchantId,
) -> RouterResult<domain::Profile> {
let db = &*state.store;
- let key_manager_state = &state.into();
if let Some(business_profile) = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
merchant_key_store,
Some(profile_id),
merchant_id,
@@ -3265,7 +3258,7 @@ async fn validate_and_get_business_profile(
{
Ok(business_profile)
} else {
- db.find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_id)
+ db.find_business_profile_by_profile_id(merchant_key_store, profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rs
index bbab031a86..61872acc34 100644
--- a/crates/router/src/core/payouts/helpers.rs
+++ b/crates/router/src/core/payouts/helpers.rs
@@ -408,7 +408,6 @@ pub async fn save_payout_data_to_locker(
// Use locker ref as payment_method_id
let existing_pm_by_pmid = db
.find_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
&locker_ref,
platform.get_processor().get_account().storage_scheme,
@@ -434,7 +433,6 @@ pub async fn save_payout_data_to_locker(
if err.current_context().is_db_not_found() {
match db
.find_payment_method_by_locker_id(
- &(state.into()),
platform.get_processor().get_key_store(),
&locker_ref,
platform.get_processor().get_account().storage_scheme,
@@ -691,7 +689,6 @@ pub async fn save_payout_data_to_locker(
if let Err(err) = stored_resp {
logger::error!(vault_err=?err);
db.delete_payment_method_by_merchant_id_payment_method_id(
- &(state.into()),
platform.get_processor().get_key_store(),
platform.get_processor().get_account().get_id(),
&existing_pm.payment_method_id,
@@ -711,7 +708,6 @@ pub async fn save_payout_data_to_locker(
};
payout_data.payment_method = Some(
db.update_payment_method(
- &(state.into()),
platform.get_processor().get_key_store(),
existing_pm,
pm_update,
@@ -793,11 +789,9 @@ pub(super) async fn get_or_create_customer_details(
.key
.get_inner()
.peek();
- let key_manager_state = &state.into();
match db
.find_customer_optional_by_customer_id_merchant_id(
- key_manager_state,
&customer_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -879,7 +873,6 @@ pub(super) async fn get_or_create_customer_details(
Ok(Some(
db.insert_customer(
customer,
- key_manager_state,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
)
@@ -929,7 +922,6 @@ pub async fn decide_payout_connector(
// Validate and get the business_profile from payout_attempt
let business_profile = core_utils::validate_and_get_business_profile(
state.store.as_ref(),
- &(state).into(),
platform.get_processor().get_key_store(),
Some(&payout_attempt.profile_id),
platform.get_processor().get_account().get_id(),
diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rs
index d97ace5fb3..ce73a119d0 100644
--- a/crates/router/src/core/payouts/validator.rs
+++ b/crates/router/src/core/payouts/validator.rs
@@ -147,7 +147,6 @@ pub async fn validate_create_request(
#[cfg(feature = "v1")]
let profile_id = core_utils::get_profile_id_from_business_details(
- &state.into(),
req.business_country,
req.business_label.as_ref(),
platform,
@@ -177,7 +176,6 @@ pub async fn validate_create_request(
Some(customer) => {
let payment_method = db
.find_payment_method(
- &state.into(),
platform.get_processor().get_key_store(),
&payment_method_id,
platform.get_processor().get_account().storage_scheme,
diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rs
index 12beecb5f2..84985af849 100644
--- a/crates/router/src/core/pm_auth.rs
+++ b/crates/router/src/core/pm_auth.rs
@@ -132,7 +132,6 @@ pub async fn create_link_token(
let merchant_connector_account = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- &(&state).into(),
platform.get_processor().get_account().get_id(),
&selected_config.mca_id,
platform.get_processor().get_key_store(),
@@ -255,7 +254,6 @@ pub async fn exchange_token_core(
let merchant_connector_account = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- &(&state).into(),
platform.get_processor().get_account().get_id(),
&config.mca_id,
platform.get_processor().get_key_store(),
@@ -327,7 +325,6 @@ async fn store_bank_details_in_payment_methods(
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(&state).into(),
&payload.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -342,7 +339,6 @@ async fn store_bank_details_in_payment_methods(
let payment_methods = db
.find_payment_method_by_customer_id_merchant_id_list(
- &((&state).into()),
platform.get_processor().get_key_store(),
&customer_id,
platform.get_processor().get_account().get_id(),
@@ -541,7 +537,6 @@ async fn store_bank_details_in_payment_methods(
}
store_in_db(
- &state,
platform.get_processor().get_key_store(),
update_entries,
new_entries,
@@ -566,26 +561,20 @@ async fn store_bank_details_in_payment_methods(
}
async fn store_in_db(
- state: &SessionState,
key_store: &domain::MerchantKeyStore,
update_entries: Vec<(domain::PaymentMethod, storage::PaymentMethodUpdate)>,
new_entries: Vec<domain::PaymentMethod>,
db: &dyn StorageInterface,
storage_scheme: MerchantStorageScheme,
) -> RouterResult<()> {
- let key_manager_state = &(state.into());
let update_entries_futures = update_entries
.into_iter()
- .map(|(pm, pm_update)| {
- db.update_payment_method(key_manager_state, key_store, pm, pm_update, storage_scheme)
- })
+ .map(|(pm, pm_update)| db.update_payment_method(key_store, pm, pm_update, storage_scheme))
.collect::<Vec<_>>();
let new_entries_futures = new_entries
.into_iter()
- .map(|pm_new| {
- db.insert_payment_method(key_manager_state, key_store, pm_new, storage_scheme)
- })
+ .map(|pm_new| db.insert_payment_method(key_store, pm_new, storage_scheme))
.collect::<Vec<_>>();
let update_futures = futures::future::join_all(update_entries_futures);
@@ -785,20 +774,14 @@ pub async fn retrieve_payment_method_from_auth_service(
let connector = PaymentAuthConnectorData::get_connector_by_name(
auth_token.connector_details.connector.as_str(),
)?;
- let key_manager_state = &state.into();
let merchant_account = db
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payment_intent.merchant_id,
- key_store,
- )
+ .find_merchant_account_by_merchant_id(&payment_intent.merchant_id, key_store)
.await
.to_not_found_response(ApiErrorResponse::MerchantAccountNotFound)?;
#[cfg(feature = "v1")]
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&payment_intent.merchant_id,
&auth_token.connector_details.mca_id,
key_store,
diff --git a/crates/router/src/core/profile_acquirer.rs b/crates/router/src/core/profile_acquirer.rs
index fed0e3d4eb..9f47a61bc0 100644
--- a/crates/router/src/core/profile_acquirer.rs
+++ b/crates/router/src/core/profile_acquirer.rs
@@ -1,5 +1,4 @@
use api_models::profile_acquirer;
-use common_utils::types::keymanager::KeyManagerState;
use error_stack::ResultExt;
use crate::{
@@ -17,15 +16,10 @@ pub async fn create_profile_acquirer(
) -> RouterResponse<profile_acquirer::ProfileAcquirerResponse> {
let db = state.store.as_ref();
let profile_acquirer_id = common_utils::generate_profile_acquirer_id_of_default_length();
- let key_manager_state: KeyManagerState = (&state).into();
let merchant_key_store = platform.get_processor().get_key_store();
let mut business_profile = db
- .find_business_profile_by_profile_id(
- &key_manager_state,
- merchant_key_store,
- &request.profile_id,
- )
+ .find_business_profile_by_profile_id(merchant_key_store, &request.profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: request.profile_id.get_string_repr().to_owned(),
@@ -78,12 +72,7 @@ pub async fn create_profile_acquirer(
acquirer_config_map: business_profile.acquirer_config_map.clone(),
};
let updated_business_profile = db
- .update_profile_by_profile_id(
- &key_manager_state,
- merchant_key_store,
- business_profile,
- profile_update,
- )
+ .update_profile_by_profile_id(merchant_key_store, business_profile, profile_update)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update business profile with new acquirer config")?;
@@ -113,11 +102,10 @@ pub async fn update_profile_acquirer_config(
platform: domain::Platform,
) -> RouterResponse<profile_acquirer::ProfileAcquirerResponse> {
let db = state.store.as_ref();
- let key_manager_state = (&state).into();
let merchant_key_store = platform.get_processor().get_key_store();
let mut business_profile = db
- .find_business_profile_by_profile_id(&key_manager_state, merchant_key_store, &profile_id)
+ .find_business_profile_by_profile_id(merchant_key_store, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -191,12 +179,7 @@ pub async fn update_profile_acquirer_config(
};
let updated_business_profile = db
- .update_profile_by_profile_id(
- &key_manager_state,
- merchant_key_store,
- business_profile,
- profile_update,
- )
+ .update_profile_by_profile_id(merchant_key_store, business_profile, profile_update)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update business profile with updated acquirer config")?;
diff --git a/crates/router/src/core/proxy/utils.rs b/crates/router/src/core/proxy/utils.rs
index ce8e1cc941..0669172cf6 100644
--- a/crates/router/src/core/proxy/utils.rs
+++ b/crates/router/src/core/proxy/utils.rs
@@ -50,7 +50,7 @@ impl ProxyRequestWrapper {
let payment_method_record = state
.store
- .find_payment_method(&((state).into()), key_store, &pm_id, storage_scheme)
+ .find_payment_method(key_store, &pm_id, storage_scheme)
.await
.change_context(errors::ApiErrorResponse::PaymentMethodNotFound)?;
Ok(ProxyRecord::PaymentMethodRecord(Box::new(
@@ -64,10 +64,9 @@ impl ProxyRequestWrapper {
"Error while coneverting from string to GlobalTokenId type",
)?;
let db = state.store.as_ref();
- let key_manager_state = &(state).into();
let tokenization_record = db
- .get_entity_id_vault_id_by_token_id(&token_id, key_store, key_manager_state)
+ .get_entity_id_vault_id_by_token_id(&token_id, key_store)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while fetching tokenization record from vault")?;
diff --git a/crates/router/src/core/recon.rs b/crates/router/src/core/recon.rs
index 1e816a9613..967e4ed3d5 100644
--- a/crates/router/src/core/recon.rs
+++ b/crates/router/src/core/recon.rs
@@ -92,11 +92,9 @@ pub async fn send_recon_request(
recon_status: enums::ReconStatus::Requested,
};
let db = &*state.store;
- let key_manager_state = &(&state).into();
let response = db
.update_merchant(
- key_manager_state,
auth_data.merchant_account,
updated_merchant_account,
&auth_data.key_store,
@@ -153,7 +151,6 @@ pub async fn recon_merchant_account_update(
req: recon_api::ReconUpdateMerchantRequest,
) -> RouterResponse<api_types::MerchantAccountResponse> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
let updated_merchant_account = storage::MerchantAccountUpdate::ReconUpdate {
recon_status: req.recon_status,
@@ -162,7 +159,6 @@ pub async fn recon_merchant_account_update(
let updated_merchant_account = db
.update_merchant(
- key_manager_state,
auth.merchant_account.clone(),
updated_merchant_account,
&auth.key_store,
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs
index d37a998b08..0e80cc3c0d 100644
--- a/crates/router/src/core/refunds.rs
+++ b/crates/router/src/core/refunds.rs
@@ -62,7 +62,6 @@ pub async fn refund_create_core(
payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(&state).into(),
&req.payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -658,7 +657,6 @@ pub async fn refund_retrieve_core(
let payment_id = &refund.payment_id;
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(&state).into(),
payment_id,
merchant_id,
platform.get_processor().get_key_store(),
@@ -1470,11 +1468,9 @@ pub async fn refund_manual_update(
state: SessionState,
req: api_models::refunds::RefundManualUpdateRequest,
) -> RouterResponse<serde_json::Value> {
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&req.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -1483,7 +1479,7 @@ pub async fn refund_manual_update(
.attach_printable("Error while fetching the key store by merchant_id")?;
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, &req.merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&req.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
.attach_printable("Error while fetching the merchant_account by merchant_id")?;
@@ -1759,7 +1755,6 @@ pub async fn sync_refund_with_gateway_workflow(
state: &SessionState,
refund_tracker: &storage::ProcessTracker,
) -> Result<(), errors::ProcessTrackerError> {
- let key_manager_state = &state.into();
let refund_core = serde_json::from_value::<diesel_refund::RefundCoreWorkflow>(
refund_tracker.tracking_data.clone(),
)
@@ -1774,7 +1769,6 @@ pub async fn sync_refund_with_gateway_workflow(
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&refund_core.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -1782,11 +1776,7 @@ pub async fn sync_refund_with_gateway_workflow(
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &refund_core.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&refund_core.merchant_id, &key_store)
.await?;
let platform = domain::Platform::new(
merchant_account.clone(),
@@ -1891,22 +1881,16 @@ pub async fn trigger_refund_execute_workflow(
refund_tracker.tracking_data
)
})?;
- let key_manager_state = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&refund_core.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
.await?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &refund_core.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&refund_core.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -1927,11 +1911,7 @@ pub async fn trigger_refund_execute_workflow(
match (&refund.sent_to_gateway, &refund.refund_status) {
(false, enums::RefundStatus::Pending) => {
let merchant_account = db
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &refund.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&refund.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -1947,7 +1927,6 @@ pub async fn trigger_refund_execute_workflow(
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &(state.into()),
&payment_attempt.payment_id,
&refund.merchant_id,
&key_store,
diff --git a/crates/router/src/core/refunds_v2.rs b/crates/router/src/core/refunds_v2.rs
index ed13c523f7..ed0244966a 100644
--- a/crates/router/src/core/refunds_v2.rs
+++ b/crates/router/src/core/refunds_v2.rs
@@ -48,7 +48,6 @@ pub async fn refund_create_core(
payment_intent = db
.find_payment_intent_by_id(
- &(&state).into(),
&req.payment_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -88,7 +87,6 @@ pub async fn refund_create_core(
payment_attempt = db
.find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
- &(&state).into(),
platform.get_processor().get_key_store(),
&req.payment_id,
platform.get_processor().get_account().storage_scheme,
@@ -131,11 +129,7 @@ pub async fn trigger_refund_to_gateway(
let storage_scheme = platform.get_processor().get_account().storage_scheme;
let mca = db
- .find_merchant_connector_account_by_id(
- &state.into(),
- &mca_id,
- platform.get_processor().get_key_store(),
- )
+ .find_merchant_connector_account_by_id(&mca_id, platform.get_processor().get_key_store())
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to fetch merchant connector account")?;
@@ -676,12 +670,10 @@ pub async fn refund_retrieve_core(
) -> errors::RouterResult<(diesel_refund::Refund, Option<masking::Secret<String>>)> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
core_utils::validate_profile_id_from_auth_layer(profile_id, &refund)?;
let payment_id = &refund.payment_id;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
payment_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -697,7 +689,6 @@ pub async fn refund_retrieve_core(
let payment_attempt = db
.find_payment_attempt_by_id(
- key_manager_state,
platform.get_processor().get_key_store(),
&active_attempt_id,
platform.get_processor().get_account().storage_scheme,
@@ -813,11 +804,7 @@ pub async fn sync_refund_with_gateway(
let mca_id = payment_attempt.get_attempt_merchant_connector_account_id()?;
let mca = db
- .find_merchant_connector_account_by_id(
- &state.into(),
- &mca_id,
- platform.get_processor().get_key_store(),
- )
+ .find_merchant_connector_account_by_id(&mca_id, platform.get_processor().get_key_store())
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to fetch merchant connector account")?;
diff --git a/crates/router/src/core/relay.rs b/crates/router/src/core/relay.rs
index 6d7c1e3727..659cba62b6 100644
--- a/crates/router/src/core/relay.rs
+++ b/crates/router/src/core/relay.rs
@@ -219,7 +219,6 @@ pub async fn relay<T: RelayInterface>(
req: RelayRequestInner<T>,
) -> RouterResponse<relay_api_models::RelayResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let merchant_id = platform.get_processor().get_account().get_id();
let connector_id = &req.connector_id;
@@ -227,7 +226,6 @@ pub async fn relay<T: RelayInterface>(
let profile = db
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
merchant_id,
&profile_id_from_auth_layer,
@@ -240,7 +238,6 @@ pub async fn relay<T: RelayInterface>(
#[cfg(feature = "v1")]
let connector_account = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
connector_id,
platform.get_processor().get_key_store(),
@@ -253,7 +250,6 @@ pub async fn relay<T: RelayInterface>(
#[cfg(feature = "v2")]
let connector_account = db
.find_merchant_connector_account_by_id(
- key_manager_state,
connector_id,
platform.get_processor().get_key_store(),
)
@@ -267,11 +263,7 @@ pub async fn relay<T: RelayInterface>(
let relay_domain = T::get_domain_models(req, merchant_id, profile.get_id());
let relay_record = db
- .insert_relay(
- key_manager_state,
- platform.get_processor().get_key_store(),
- relay_domain,
- )
+ .insert_relay(platform.get_processor().get_key_store(), relay_domain)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to insert a relay record in db")?;
@@ -283,7 +275,6 @@ pub async fn relay<T: RelayInterface>(
let relay_update_record = db
.update_relay(
- key_manager_state,
platform.get_processor().get_key_store(),
relay_record,
relay_response,
@@ -306,14 +297,12 @@ pub async fn relay_retrieve(
req: relay_api_models::RelayRetrieveRequest,
) -> RouterResponse<relay_api_models::RelayResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let merchant_id = platform.get_processor().get_account().get_id();
let relay_id = &req.id;
let profile_id_from_auth_layer = profile_id_optional.get_required_value("ProfileId")?;
db.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
platform.get_processor().get_key_store(),
merchant_id,
&profile_id_from_auth_layer,
@@ -324,11 +313,7 @@ pub async fn relay_retrieve(
})?;
let relay_record_result = db
- .find_relay_by_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- relay_id,
- )
+ .find_relay_by_id(platform.get_processor().get_key_store(), relay_id)
.await;
let relay_record = match relay_record_result {
@@ -349,7 +334,6 @@ pub async fn relay_retrieve(
#[cfg(feature = "v1")]
let connector_account = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
&relay_record.connector_id,
platform.get_processor().get_key_store(),
@@ -362,7 +346,6 @@ pub async fn relay_retrieve(
#[cfg(feature = "v2")]
let connector_account = db
.find_merchant_connector_account_by_id(
- key_manager_state,
&relay_record.connector_id,
platform.get_processor().get_key_store(),
)
@@ -383,7 +366,6 @@ pub async fn relay_retrieve(
.await?;
db.update_relay(
- key_manager_state,
platform.get_processor().get_key_store(),
relay_record,
relay_response,
diff --git a/crates/router/src/core/revenue_recovery/api.rs b/crates/router/src/core/revenue_recovery/api.rs
index df666a95a3..c3ee068dc9 100644
--- a/crates/router/src/core/revenue_recovery/api.rs
+++ b/crates/router/src/core/revenue_recovery/api.rs
@@ -259,12 +259,10 @@ pub async fn custom_revenue_recovery_core(
request: api_models::payments::RecoveryPaymentsCreate,
) -> RouterResponse<payments_api::RecoveryPaymentsResponse> {
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
let payment_merchant_connector_account_id = request.payment_merchant_connector_id.to_owned();
// Find the payment & billing merchant connector id at the top level to avoid multiple DB calls.
let payment_merchant_connector_account = store
.find_merchant_connector_account_by_id(
- key_manager_state,
&payment_merchant_connector_account_id,
platform.get_processor().get_key_store(),
)
@@ -277,7 +275,6 @@ pub async fn custom_revenue_recovery_core(
})?;
let billing_connector_account = store
.find_merchant_connector_account_by_id(
- key_manager_state,
&request.billing_merchant_connector_id.clone(),
platform.get_processor().get_key_store(),
)
diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rs
index 0ff93e0033..c0e4d71273 100644
--- a/crates/router/src/core/routing.rs
+++ b/crates/router/src/core/routing.rs
@@ -231,7 +231,6 @@ async fn build_list_routing_result(
profile_ids: Vec<common_utils::id_type::ProfileId>,
) -> RouterResult<Vec<routing_types::RoutingDictionaryRecord>> {
let db = state.store.as_ref();
- let key_manager_state = &state.into();
let mut list_result: Vec<routing_types::RoutingDictionaryRecord> = vec![];
for profile_id in profile_ids.iter() {
let by_profile =
@@ -240,7 +239,6 @@ async fn build_list_routing_result(
let hs_result_for_profile = hs_results.iter().filter(by_profile).cloned().collect();
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(profile_id),
platform.get_processor().get_account().get_id(),
@@ -274,11 +272,9 @@ pub async fn create_routing_algorithm_under_profile(
) -> RouterResponse<routing_types::RoutingDictionaryRecord> {
metrics::ROUTING_CREATE_REQUEST_RECEIVED.add(1, &[]);
let db = &*state.store;
- let key_manager_state = &(&state).into();
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&request.profile_id),
platform.get_processor().get_account().get_id(),
@@ -290,7 +286,6 @@ pub async fn create_routing_algorithm_under_profile(
let all_mcas = state
.store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- key_manager_state,
merchant_id,
true,
platform.get_processor().get_key_store(),
@@ -350,7 +345,6 @@ pub async fn create_routing_algorithm_under_profile(
metrics::ROUTING_CREATE_REQUEST_RECEIVED.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let name = request
.name
@@ -387,7 +381,6 @@ pub async fn create_routing_algorithm_under_profile(
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -542,7 +535,6 @@ pub async fn link_routing_config_under_profile(
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -597,7 +589,6 @@ pub async fn link_routing_config(
) -> RouterResponse<routing_types::RoutingDictionaryRecord> {
metrics::ROUTING_LINK_CONFIG.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let routing_algorithm = db
.find_routing_algorithm_by_algorithm_id_merchant_id(
@@ -609,7 +600,6 @@ pub async fn link_routing_config(
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&routing_algorithm.profile_id),
platform.get_processor().get_account().get_id(),
@@ -824,7 +814,6 @@ pub async fn link_routing_config(
helpers::update_business_profile_active_dynamic_algorithm_ref(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
business_profile.clone(),
dynamic_routing_ref,
@@ -867,7 +856,6 @@ pub async fn link_routing_config(
routing_ref.update_algorithm_id(algorithm_id);
helpers::update_profile_active_algorithm_ref(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
business_profile.clone(),
routing_ref,
@@ -932,7 +920,6 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
) -> RouterResponse<routing_types::MerchantRoutingAlgorithm> {
metrics::ROUTING_RETRIEVE_CONFIG.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let routing_algorithm = RoutingAlgorithmUpdate::fetch_routing_algo(
platform.get_processor().get_account().get_id(),
@@ -942,7 +929,6 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
.await?;
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&routing_algorithm.0.profile_id),
platform.get_processor().get_account().get_id(),
@@ -970,7 +956,6 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
) -> RouterResponse<routing_types::MerchantRoutingAlgorithm> {
metrics::ROUTING_RETRIEVE_CONFIG.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let routing_algorithm = db
.find_routing_algorithm_by_algorithm_id_merchant_id(
@@ -982,7 +967,6 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&routing_algorithm.profile_id),
platform.get_processor().get_account().get_id(),
@@ -1014,7 +998,6 @@ pub async fn unlink_routing_config_under_profile(
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1067,7 +1050,6 @@ pub async fn unlink_routing_config(
metrics::ROUTING_UNLINK_CONFIG.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let profile_id = request
.profile_id
@@ -1079,7 +1061,6 @@ pub async fn unlink_routing_config(
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1128,7 +1109,6 @@ pub async fn unlink_routing_config(
let response = record.foreign_into();
helpers::update_profile_active_algorithm_ref(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
business_profile.clone(),
routing_algorithm,
@@ -1179,7 +1159,6 @@ pub async fn update_default_fallback_routing(
let key_manager_state = &(&state).into();
let profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1311,10 +1290,8 @@ pub async fn retrieve_default_fallback_algorithm_for_profile(
) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> {
metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1367,11 +1344,9 @@ pub async fn retrieve_routing_config_under_profile(
) -> RouterResponse<routing_types::LinkedRoutingConfigRetrieveResponse> {
metrics::ROUTING_RETRIEVE_LINK_CONFIG.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1411,7 +1386,6 @@ pub async fn retrieve_linked_routing_config(
metrics::ROUTING_RETRIEVE_LINK_CONFIG.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let merchant_key_store = platform.get_processor().get_key_store();
let merchant_id = platform.get_processor().get_account().get_id();
@@ -1419,7 +1393,6 @@ pub async fn retrieve_linked_routing_config(
let business_profiles = if let Some(profile_id) = query_params.profile_id {
core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
merchant_key_store,
Some(&profile_id),
merchant_id,
@@ -1432,7 +1405,7 @@ pub async fn retrieve_linked_routing_config(
})?
} else {
let business_profile = db
- .list_profile_by_merchant_id(key_manager_state, merchant_key_store, merchant_id)
+ .list_profile_by_merchant_id(merchant_key_store, merchant_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound)?;
core_utils::filter_objects_based_on_profile_id_list(
@@ -1574,11 +1547,9 @@ pub async fn retrieve_default_routing_config_for_profiles(
) -> RouterResponse<Vec<routing_types::ProfileDefaultRoutingConfig>> {
metrics::ROUTING_RETRIEVE_CONFIG_FOR_PROFILE.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let all_profiles = db
.list_profile_by_merchant_id(
- key_manager_state,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().get_id(),
)
@@ -1627,11 +1598,9 @@ pub async fn update_default_routing_config_for_profile(
metrics::ROUTING_UPDATE_CONFIG_FOR_PROFILE.add(1, &[]);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1719,11 +1688,9 @@ pub async fn toggle_specific_dynamic_routing(
),
);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1794,11 +1761,9 @@ pub async fn create_specific_dynamic_routing(
),
);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1860,7 +1825,6 @@ pub async fn configure_dynamic_routing_volume_split(
router_env::metric_attributes!(("profile_id", profile_id.clone())),
);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
utils::when(
routing_info.split > crate::consts::DYNAMIC_ROUTING_MAX_VOLUME,
@@ -1873,7 +1837,6 @@ pub async fn configure_dynamic_routing_volume_split(
let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -1899,7 +1862,6 @@ pub async fn configure_dynamic_routing_volume_split(
helpers::update_business_profile_active_dynamic_algorithm_ref(
db,
- &((&state).into()),
platform.get_processor().get_key_store(),
business_profile.clone(),
dynamic_routing_algo_ref.clone(),
@@ -1916,11 +1878,9 @@ pub async fn retrieve_dynamic_routing_volume_split(
profile_id: common_utils::id_type::ProfileId,
) -> RouterResponse<routing_types::RoutingVolumeSplitResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -2163,11 +2123,9 @@ pub async fn contract_based_dynamic_routing_setup(
config: Option<routing_types::ContractBasedRoutingConfig>,
) -> RouterResult<service_api::ApplicationResponse<routing_types::RoutingDictionaryRecord>> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
@@ -2304,7 +2262,6 @@ pub async fn contract_based_dynamic_routing_setup(
let label = info.label.clone();
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
platform.get_processor().get_account().get_id(),
&mca_id,
platform.get_processor().get_key_store(),
@@ -2337,7 +2294,6 @@ pub async fn contract_based_dynamic_routing_setup(
helpers::update_business_profile_active_dynamic_algorithm_ref(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
business_profile,
final_algorithm,
@@ -2372,7 +2328,6 @@ pub async fn contract_based_routing_update_configs(
),
);
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let dynamic_routing_algo_to_update = db
.find_routing_algorithm_by_profile_id_algorithm_id(&profile_id, &algorithm_id)
@@ -2391,7 +2346,6 @@ pub async fn contract_based_routing_update_configs(
for info in info_vec {
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
platform.get_processor().get_account().get_id(),
&info.mca_id,
platform.get_processor().get_key_store(),
@@ -2640,13 +2594,11 @@ pub async fn migrate_rules_for_profile(
let profile_id = query_params.profile_id.clone();
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let merchant_key_store = platform.get_processor().get_key_store();
let merchant_id = platform.get_processor().get_account().get_id();
let business_profile = core_utils::validate_and_get_business_profile(
db,
- key_manager_state,
merchant_key_store,
Some(&profile_id),
merchant_id,
diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs
index 989a21bdab..8038fd3f42 100644
--- a/crates/router/src/core/routing/helpers.rs
+++ b/crates/router/src/core/routing/helpers.rs
@@ -13,7 +13,7 @@ use api_models::open_router;
use api_models::routing as routing_types;
#[cfg(all(feature = "dynamic_routing", feature = "v1"))]
use common_utils::ext_traits::ValueExt;
-use common_utils::{ext_traits::Encode, id_type, types::keymanager::KeyManagerState};
+use common_utils::{ext_traits::Encode, id_type};
use diesel_models::configs;
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
use diesel_models::dynamic_routing_stats::{DynamicRoutingStatsNew, DynamicRoutingStatsUpdate};
@@ -214,7 +214,6 @@ pub async fn update_merchant_active_algorithm_ref(
let db = &*state.store;
db.update_specific_fields_in_merchant(
- &state.into(),
&key_store.merchant_id,
merchant_account_update,
key_store,
@@ -234,7 +233,6 @@ pub async fn update_merchant_active_algorithm_ref(
#[cfg(feature = "v1")]
pub async fn update_profile_active_algorithm_ref(
db: &dyn StorageInterface,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_business_profile: domain::Profile,
algorithm_id: routing_types::RoutingAlgorithmRef,
@@ -264,7 +262,6 @@ pub async fn update_profile_active_algorithm_ref(
};
db.update_profile_by_profile_id(
- key_manager_state,
merchant_key_store,
current_business_profile,
business_profile_update,
@@ -295,7 +292,6 @@ pub async fn update_profile_active_algorithm_ref(
#[cfg(feature = "v1")]
pub async fn update_business_profile_active_dynamic_algorithm_ref(
db: &dyn StorageInterface,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_business_profile: domain::Profile,
dynamic_routing_algorithm_ref: routing_types::DynamicRoutingAlgorithmRef,
@@ -308,7 +304,6 @@ pub async fn update_business_profile_active_dynamic_algorithm_ref(
dynamic_routing_algorithm: Some(ref_val),
};
db.update_profile_by_profile_id(
- key_manager_state,
merchant_key_store,
current_business_profile,
business_profile_update,
@@ -478,7 +473,6 @@ pub async fn validate_connectors_in_routing_config(
let all_mcas = state
.store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- &state.into(),
merchant_id,
true,
key_store,
@@ -1796,7 +1790,6 @@ pub async fn disable_dynamic_routing_algorithm(
dynamic_routing_type: routing_types::DynamicRoutingType,
) -> RouterResult<ApplicationResponse<routing_types::RoutingDictionaryRecord>> {
let db = state.store.as_ref();
- let key_manager_state = &state.into();
let profile_id = business_profile.get_id().clone();
let (algorithm_id, mut dynamic_routing_algorithm, cache_entries_to_redact) =
match dynamic_routing_type {
@@ -1956,7 +1949,6 @@ pub async fn disable_dynamic_routing_algorithm(
let response = record.foreign_into();
update_business_profile_active_dynamic_algorithm_ref(
db,
- key_manager_state,
&key_store,
business_profile,
dynamic_routing_algorithm,
@@ -2095,7 +2087,6 @@ where
dynamic_routing_algo_ref.update_enabled_features(dynamic_routing_type, feature_to_enable);
update_business_profile_active_dynamic_algorithm_ref(
db,
- &state.into(),
&key_store,
business_profile,
dynamic_routing_algo_ref.clone(),
@@ -2125,7 +2116,6 @@ pub async fn default_specific_dynamic_routing_setup(
dynamic_routing_type: routing_types::DynamicRoutingType,
) -> RouterResult<ApplicationResponse<routing_types::RoutingDictionaryRecord>> {
let db = state.store.as_ref();
- let key_manager_state = &state.into();
let profile_id = business_profile.get_id().clone();
let merchant_id = business_profile.merchant_id.clone();
let algorithm_id = common_utils::generate_routing_id_of_default_length();
@@ -2213,7 +2203,6 @@ pub async fn default_specific_dynamic_routing_setup(
);
update_business_profile_active_dynamic_algorithm_ref(
db,
- key_manager_state,
&key_store,
business_profile,
dynamic_routing_algo_ref,
@@ -2241,7 +2230,6 @@ pub async fn create_specific_dynamic_routing_setup(
payload: routing_types::DynamicRoutingPayload,
) -> RouterResult<ApplicationResponse<routing_types::RoutingDictionaryRecord>> {
let db = state.store.as_ref();
- let key_manager_state = &state.into();
let profile_id = business_profile.get_id().clone();
let merchant_id = business_profile.merchant_id.clone();
let algorithm_id = common_utils::generate_routing_id_of_default_length();
@@ -2332,7 +2320,6 @@ pub async fn create_specific_dynamic_routing_setup(
dynamic_routing_algo_ref.update_feature(feature_to_enable, dynamic_routing_type);
update_business_profile_active_dynamic_algorithm_ref(
db,
- key_manager_state,
&key_store,
business_profile,
dynamic_routing_algo_ref,
diff --git a/crates/router/src/core/split_payments.rs b/crates/router/src/core/split_payments.rs
index b0b886fb94..e086551983 100644
--- a/crates/router/src/core/split_payments.rs
+++ b/crates/router/src/core/split_payments.rs
@@ -213,11 +213,9 @@ pub(crate) async fn split_payments_execute_core(
payment_id: id_type::GlobalPaymentId,
) -> RouterResponse<payments_api::PaymentsResponse> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
&payment_id,
platform.get_processor().get_key_store(),
platform.get_processor().get_account().storage_scheme,
@@ -250,7 +248,6 @@ pub(crate) async fn split_payments_execute_core(
let payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_intent,
payment_intent_update,
platform.get_processor().get_key_store(),
@@ -333,7 +330,6 @@ pub(crate) async fn split_payments_execute_core(
let updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent.clone(),
payment_intent_update,
platform.get_processor().get_key_store(),
@@ -426,7 +422,6 @@ pub(crate) async fn split_payments_execute_core(
let _updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_data.payment_intent.clone(),
payment_intent_update,
platform.get_processor().get_key_store(),
@@ -461,7 +456,6 @@ pub(crate) async fn split_payments_execute_core(
let _updated_payment_intent = db
.update_payment_intent(
- key_manager_state,
payment_intent,
payment_intent_update,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/tokenization.rs b/crates/router/src/core/tokenization.rs
index 9f63491990..bb4e807366 100644
--- a/crates/router/src/core/tokenization.rs
+++ b/crates/router/src/core/tokenization.rs
@@ -40,7 +40,6 @@ pub async fn create_vault_token_core(
// Generate a unique vault ID
let vault_id = domain::VaultId::generate(uuid::Uuid::now_v7().to_string());
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let customer_id = req.customer_id.clone();
// Create vault request
let payload = pm_types::AddVaultRequest {
@@ -79,11 +78,7 @@ pub async fn create_vault_token_core(
// Insert into database
let tokenization = db
- .insert_tokenization(
- tokenization_new,
- &(merchant_key_store.clone()),
- key_manager_state,
- )
+ .insert_tokenization(tokenization_new, &(merchant_key_store.clone()))
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to insert tokenization record")?;
@@ -107,15 +102,10 @@ pub async fn delete_tokenized_data_core(
payload: api_models::tokenization::DeleteTokenDataRequest,
) -> RouterResponse<api_models::tokenization::DeleteTokenDataResponse> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
// Retrieve the tokenization record
let tokenization_record = db
- .get_entity_id_vault_id_by_token_id(
- token_id,
- platform.get_processor().get_key_store(),
- key_manager_state,
- )
+ .get_entity_id_vault_id_by_token_id(token_id, platform.get_processor().get_key_store())
.await
.to_not_found_response(errors::ApiErrorResponse::TokenizationRecordNotFound {
id: token_id.get_string_repr().to_string(),
@@ -158,7 +148,6 @@ pub async fn delete_tokenized_data_core(
tokenization_record,
tokenization_update,
platform.get_processor().get_key_store(),
- key_manager_state,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
@@ -180,14 +169,9 @@ pub async fn get_token_vault_core(
query: id_type::GlobalTokenId,
) -> CustomResult<serde_json::Value, errors::ApiErrorResponse> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let tokenization_record = db
- .get_entity_id_vault_id_by_token_id(
- &query,
- &(merchant_key_store.clone()),
- key_manager_state,
- )
+ .get_entity_id_vault_id_by_token_id(&query, &(merchant_key_store.clone()))
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to get tokenization record")?;
diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rs
index 32bc08bdbe..c6ee28cff9 100644
--- a/crates/router/src/core/unified_authentication_service.rs
+++ b/crates/router/src/core/unified_authentication_service.rs
@@ -671,7 +671,6 @@ pub async fn authentication_create_core(
let merchant_id = merchant_account.get_id();
let key_manager_state = (&state).into();
let profile_id = core_utils::get_profile_id_from_business_details(
- &key_manager_state,
None,
None,
&platform,
@@ -682,11 +681,7 @@ pub async fn authentication_create_core(
.await?;
let business_profile = db
- .find_business_profile_by_profile_id(
- &key_manager_state,
- platform.get_processor().get_key_store(),
- &profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), &profile_id)
.await
.to_not_found_response(ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -1036,7 +1031,6 @@ pub async fn authentication_eligibility_core(
let key_manager_state = (&state).into();
let profile_id = core_utils::get_profile_id_from_business_details(
- &key_manager_state,
None,
None,
&platform,
@@ -1047,11 +1041,7 @@ pub async fn authentication_eligibility_core(
.await?;
let business_profile = db
- .find_business_profile_by_profile_id(
- &key_manager_state,
- platform.get_processor().get_key_store(),
- &profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), &profile_id)
.await
.to_not_found_response(ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -1307,11 +1297,7 @@ pub async fn authentication_authenticate_core(
let profile_id = authentication.profile_id.clone();
let business_profile = db
- .find_business_profile_by_profile_id(
- &key_manager_state,
- platform.get_processor().get_key_store(),
- &profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), &profile_id)
.await
.to_not_found_response(ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -1779,11 +1765,7 @@ pub async fn authentication_sync_core(
let profile_id = authentication.profile_id.clone();
let business_profile = db
- .find_business_profile_by_profile_id(
- &key_manager_state,
- platform.get_processor().get_key_store(),
- &profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), &profile_id)
.await
.to_not_found_response(ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -2131,10 +2113,8 @@ pub async fn authentication_post_sync_core(
ensure_not_terminal_status(authentication.trans_status.clone())?;
- let key_manager_state = (&state).into();
let business_profile = db
.find_business_profile_by_profile_id(
- &key_manager_state,
platform.get_processor().get_key_store(),
&authentication.profile_id,
)
@@ -2234,7 +2214,6 @@ pub async fn authentication_session_core(
) -> RouterResponse<api_models::authentication::AuthenticationSessionResponse> {
let merchant_account = platform.get_processor().get_account();
let merchant_id = merchant_account.get_id();
- let key_manager_state = (&state).into();
let authentication_id = req.authentication_id;
let authentication = state
@@ -2250,7 +2229,6 @@ pub async fn authentication_session_core(
let business_profile = state
.store
.find_business_profile_by_profile_id(
- &key_manager_state,
platform.get_processor().get_key_store(),
&authentication.profile_id,
)
@@ -2301,7 +2279,6 @@ pub async fn get_session_token_for_click_to_pay(
let merchant_connector_account = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
&click_to_pay_mca_id,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/unified_authentication_service/utils.rs b/crates/router/src/core/unified_authentication_service/utils.rs
index b7ee887f81..45b276c7bc 100644
--- a/crates/router/src/core/unified_authentication_service/utils.rs
+++ b/crates/router/src/core/unified_authentication_service/utils.rs
@@ -379,8 +379,6 @@ pub async fn get_auth_multi_token_from_external_vault<F, Req>(
authentication_details,
}) = router_data.response.clone()
{
- let key_manager_state = state.into();
-
match business_profile.external_vault_details.clone() {
business_profile::ExternalVaultDetails::ExternalVaultEnabled(
external_vault_details,
@@ -390,7 +388,6 @@ pub async fn get_auth_multi_token_from_external_vault<F, Req>(
let merchant_connector_account_details = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- &key_manager_state,
platform.get_processor().get_account().get_id(),
&external_vault_mca_id,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs
index 161dc75d6e..2f4c4cacef 100644
--- a/crates/router/src/core/user.rs
+++ b/crates/router/src/core/user.rs
@@ -131,12 +131,9 @@ pub async fn get_user_details(
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to retrieve role information")?;
- let key_manager_state = &(&state).into();
-
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&user_from_token.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -145,11 +142,7 @@ pub async fn get_user_details(
let version = if let Ok(merchant_key_store) = merchant_key_store {
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &user_from_token.merchant_id,
- &merchant_key_store,
- )
+ .find_merchant_account_by_merchant_id(&user_from_token.merchant_id, &merchant_key_store)
.await;
if let Ok(merchant_account) = merchant_account {
@@ -1537,11 +1530,9 @@ pub async fn create_internal_user(
|| Err(UserErrors::InvalidRoleId),
)?;
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&common_utils::id_type::MerchantId::get_internal_user_merchant_id(
consts::user_role::INTERNAL_USER_MERCHANT_ID,
),
@@ -1573,7 +1564,7 @@ pub async fn create_internal_user(
let internal_merchant = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, &internal_merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&internal_merchant_id, &key_store)
.await
.map_err(|e| {
if e.current_context().is_db_not_found() {
@@ -1619,11 +1610,9 @@ pub async fn create_tenant_user(
state: SessionState,
request: user_api::CreateTenantUserRequest,
) -> UserResponse<()> {
- let key_manager_state = &(&state).into();
-
let (merchant_id, org_id) = state
.store
- .list_merchant_and_org_ids(key_manager_state, 1, None)
+ .list_merchant_and_org_ids(1, None)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to get merchants list for org")?
@@ -1903,7 +1892,7 @@ pub async fn list_user_roles_details(
let merchant_map = state
.store
- .list_multiple_merchant_accounts(&(&state).into(), merchant_ids)
+ .list_multiple_merchant_accounts(merchant_ids)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Error while listing merchant accounts")?
@@ -1916,14 +1905,11 @@ pub async fn list_user_roles_details(
})
.collect::<HashMap<_, _>>();
- let key_manager_state = &(&state).into();
-
let profile_map = futures::future::try_join_all(merchant_profile_ids.iter().map(
|merchant_profile_id| async {
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_profile_id.0,
&state.store.get_master_key().to_vec().into(),
)
@@ -1933,11 +1919,7 @@ pub async fn list_user_roles_details(
state
.store
- .find_business_profile_by_profile_id(
- key_manager_state,
- &merchant_key_store,
- &merchant_profile_id.1,
- )
+ .find_business_profile_by_profile_id(&merchant_key_store, &merchant_profile_id.1)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to retrieve business profile")
@@ -2453,7 +2435,6 @@ pub async fn transfer_user_key_store_keymanager(
let key_stores = db
.get_all_user_key_store(
- &(&state).into(),
&state.store.get_master_key().to_vec().into(),
req.from,
req.limit,
@@ -3101,21 +3082,14 @@ pub async fn list_orgs_for_user(
.into());
}
let orgs = match role_info.get_entity_type() {
- EntityType::Tenant => {
- let key_manager_state = &(&state).into();
- state
- .store
- .list_merchant_and_org_ids(
- key_manager_state,
- consts::user::ORG_LIST_LIMIT_FOR_TENANT,
- None,
- )
- .await
- .change_context(UserErrors::InternalServerError)?
- .into_iter()
- .map(|(_, org_id)| org_id)
- .collect::<HashSet<_>>()
- }
+ EntityType::Tenant => state
+ .store
+ .list_merchant_and_org_ids(consts::user::ORG_LIST_LIMIT_FOR_TENANT, None)
+ .await
+ .change_context(UserErrors::InternalServerError)?
+ .into_iter()
+ .map(|(_, org_id)| org_id)
+ .collect::<HashSet<_>>(),
EntityType::Organization | EntityType::Merchant | EntityType::Profile => state
.global_store
.list_user_roles_by_user_id(ListUserRolesByUserIdPayload {
@@ -3186,7 +3160,7 @@ pub async fn list_merchants_for_user_in_org(
let merchant_accounts = match role_info.get_entity_type() {
EntityType::Tenant | EntityType::Organization => state
.store
- .list_merchant_accounts_by_organization_id(&(&state).into(), &user_from_token.org_id)
+ .list_merchant_accounts_by_organization_id(&user_from_token.org_id)
.await
.change_context(UserErrors::InternalServerError)?,
EntityType::Merchant | EntityType::Profile => {
@@ -3216,7 +3190,7 @@ pub async fn list_merchants_for_user_in_org(
state
.store
- .list_multiple_merchant_accounts(&(&state).into(), merchant_ids)
+ .list_multiple_merchant_accounts(merchant_ids)
.await
.change_context(UserErrors::InternalServerError)?
}
@@ -3255,11 +3229,9 @@ pub async fn list_profiles_for_user_in_org_and_merchant_account(
.await
.change_context(UserErrors::InternalServerError)?;
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&user_from_token.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -3268,11 +3240,7 @@ pub async fn list_profiles_for_user_in_org_and_merchant_account(
let profiles = match role_info.get_entity_type() {
EntityType::Tenant | EntityType::Organization | EntityType::Merchant => state
.store
- .list_profile_by_merchant_id(
- key_manager_state,
- &key_store,
- &user_from_token.merchant_id,
- )
+ .list_profile_by_merchant_id(&key_store, &user_from_token.merchant_id)
.await
.change_context(UserErrors::InternalServerError)?,
EntityType::Profile => {
@@ -3299,11 +3267,9 @@ pub async fn list_profiles_for_user_in_org_and_merchant_account(
.collect::<HashSet<_>>();
futures::future::try_join_all(profile_ids.iter().map(|profile_id| {
- state.store.find_business_profile_by_profile_id(
- key_manager_state,
- &key_store,
- profile_id,
- )
+ state
+ .store
+ .find_business_profile_by_profile_id(&key_store, profile_id)
}))
.await
.change_context(UserErrors::InternalServerError)?
@@ -3363,7 +3329,7 @@ pub async fn switch_org_for_user(
EntityType::Tenant => {
let merchant_id = state
.store
- .list_merchant_accounts_by_organization_id(&(&state).into(), &request.org_id)
+ .list_merchant_accounts_by_organization_id(&request.org_id)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to get merchant list for org")?
@@ -3376,7 +3342,6 @@ pub async fn switch_org_for_user(
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- &(&state).into(),
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -3385,7 +3350,7 @@ pub async fn switch_org_for_user(
let profile_id = state
.store
- .list_profile_by_merchant_id(&(&state).into(), &key_store, &merchant_id)
+ .list_profile_by_merchant_id(&key_store, &merchant_id)
.await
.change_context(UserErrors::InternalServerError)?
.pop()
@@ -3488,7 +3453,6 @@ pub async fn switch_merchant_for_user_in_org(
.into());
}
- let key_manager_state = &(&state).into();
let role_info = roles::RoleInfo::from_role_id_org_id_tenant_id(
&state,
&user_from_token.role_id,
@@ -3507,7 +3471,6 @@ pub async fn switch_merchant_for_user_in_org(
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&request.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -3516,21 +3479,13 @@ pub async fn switch_merchant_for_user_in_org(
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &request.merchant_id,
- &merchant_key_store,
- )
+ .find_merchant_account_by_merchant_id(&request.merchant_id, &merchant_key_store)
.await
.to_not_found_response(UserErrors::MerchantIdNotFound)?;
let profile_id = state
.store
- .list_profile_by_merchant_id(
- key_manager_state,
- &merchant_key_store,
- &request.merchant_id,
- )
+ .list_profile_by_merchant_id(&merchant_key_store, &request.merchant_id)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to list business profiles by merchant_id")?
@@ -3553,7 +3508,6 @@ pub async fn switch_merchant_for_user_in_org(
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&request.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -3562,11 +3516,7 @@ pub async fn switch_merchant_for_user_in_org(
let merchant_id = state
.store
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &request.merchant_id,
- &merchant_key_store,
- )
+ .find_merchant_account_by_merchant_id(&request.merchant_id, &merchant_key_store)
.await
.change_context(UserErrors::MerchantIdNotFound)?
.organization_id
@@ -3580,11 +3530,7 @@ pub async fn switch_merchant_for_user_in_org(
let profile_id = state
.store
- .list_profile_by_merchant_id(
- key_manager_state,
- &merchant_key_store,
- &merchant_id,
- )
+ .list_profile_by_merchant_id(&merchant_key_store, &merchant_id)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to list business profiles by merchant_id")?
@@ -3702,7 +3648,6 @@ pub async fn switch_profile_for_user_in_org_and_merchant(
.into());
}
- let key_manager_state = &(&state).into();
let role_info = roles::RoleInfo::from_role_id_org_id_tenant_id(
&state,
&user_from_token.role_id,
@@ -3721,7 +3666,6 @@ pub async fn switch_profile_for_user_in_org_and_merchant(
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&user_from_token.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -3732,7 +3676,6 @@ pub async fn switch_profile_for_user_in_org_and_merchant(
let profile_id = state
.store
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
&merchant_key_store,
&user_from_token.merchant_id,
&request.profile_id,
@@ -3849,12 +3792,9 @@ pub async fn clone_connector(
},
)?;
- let key_manager_state = &(&state).into();
-
let source_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&request.source.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -3866,7 +3806,6 @@ pub async fn clone_connector(
let source_mca = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&request.source.merchant_id,
&request.source.mca_id,
&source_key_store,
@@ -3901,7 +3840,6 @@ pub async fn clone_connector(
let destination_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&request.destination.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -3913,7 +3851,6 @@ pub async fn clone_connector(
let destination_merchant_account = state
.store
.find_merchant_account_by_merchant_id(
- key_manager_state,
&request.destination.merchant_id,
&destination_key_store,
)
diff --git a/crates/router/src/core/user/dashboard_metadata.rs b/crates/router/src/core/user/dashboard_metadata.rs
index d229b9e27f..256aa8d481 100644
--- a/crates/router/src/core/user/dashboard_metadata.rs
+++ b/crates/router/src/core/user/dashboard_metadata.rs
@@ -701,7 +701,6 @@ pub async fn backfill_metadata(
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- &state.into(),
&user.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -815,7 +814,6 @@ pub async fn get_merchant_connector_account_by_name(
state
.store
.find_merchant_connector_account_by_merchant_id_connector_name(
- &state.into(),
merchant_id,
connector_name,
key_store,
diff --git a/crates/router/src/core/user/sample_data.rs b/crates/router/src/core/user/sample_data.rs
index d098d1f76d..952d5fdd17 100644
--- a/crates/router/src/core/user/sample_data.rs
+++ b/crates/router/src/core/user/sample_data.rs
@@ -31,7 +31,6 @@ pub async fn generate_sample_data_for_user(
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- &(&state).into(),
&user_from_token.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -95,7 +94,6 @@ pub async fn delete_sample_data_for_user(
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id_del,
&state.store.get_master_key().to_vec().into(),
)
diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rs
index d6a55ffdbf..ce67c916b3 100644
--- a/crates/router/src/core/user_role.rs
+++ b/crates/router/src/core/user_role.rs
@@ -1024,11 +1024,9 @@ pub async fn list_invitations_for_user(
.into_iter()
.collect::<HashMap<_, _>>();
- let key_manager_state = &(&state).into();
-
let merchant_name_map = state
.store
- .list_multiple_merchant_accounts(key_manager_state, merchant_ids)
+ .list_multiple_merchant_accounts(merchant_ids)
.await
.change_context(UserErrors::InternalServerError)?
.into_iter()
@@ -1048,17 +1046,13 @@ pub async fn list_invitations_for_user(
|(profile_id, merchant_id)| async {
let merchant_key_store = state
.store
- .get_merchant_key_store_by_merchant_id(key_manager_state, merchant_id, master_key)
+ .get_merchant_key_store_by_merchant_id(merchant_id, master_key)
.await
.change_context(UserErrors::InternalServerError)?;
let business_profile = state
.store
- .find_business_profile_by_profile_id(
- key_manager_state,
- &merchant_key_store,
- profile_id,
- )
+ .find_business_profile_by_profile_id(&merchant_key_store, profile_id)
.await
.change_context(UserErrors::InternalServerError)?;
diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs
index a8815cdf8d..65510877f2 100644
--- a/crates/router/src/core/utils.rs
+++ b/crates/router/src/core/utils.rs
@@ -12,7 +12,7 @@ use common_utils::{crypto::Encryptable, pii::Email};
use common_utils::{
errors::CustomResult,
ext_traits::AsyncExt,
- types::{keymanager::KeyManagerState, ConnectorTransactionIdTrait, MinorUnit},
+ types::{ConnectorTransactionIdTrait, MinorUnit},
};
use diesel_models::refund as diesel_refund;
use error_stack::{report, ResultExt};
@@ -1844,7 +1844,6 @@ pub fn get_connector_request_reference_id(
/// Validate whether the profile_id exists and is associated with the merchant_id
pub async fn validate_and_get_business_profile(
db: &dyn StorageInterface,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_id: Option<&common_utils::id_type::ProfileId>,
merchant_id: &common_utils::id_type::MerchantId,
@@ -1852,7 +1851,6 @@ pub async fn validate_and_get_business_profile(
profile_id
.async_map(|profile_id| async {
db.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
merchant_key_store,
merchant_id,
profile_id,
@@ -1910,7 +1908,6 @@ pub fn get_connector_label(
/// or return a `MissingRequiredField` error
#[allow(clippy::too_many_arguments)]
pub async fn get_profile_id_from_business_details(
- key_manager_state: &KeyManagerState,
business_country: Option<api_models::enums::CountryAlpha2>,
business_label: Option<&String>,
platform: &domain::Platform,
@@ -1929,7 +1926,6 @@ pub async fn get_profile_id_from_business_details(
if should_validate {
let _ = validate_and_get_business_profile(
db,
- key_manager_state,
platform.get_processor().get_key_store(),
Some(profile_id),
platform.get_processor().get_account().get_id(),
@@ -1943,7 +1939,6 @@ pub async fn get_profile_id_from_business_details(
let profile_name = format!("{business_country}_{business_label}");
let business_profile = db
.find_business_profile_by_profile_name_merchant_id(
- key_manager_state,
platform.get_processor().get_key_store(),
&profile_name,
platform.get_processor().get_account().get_id(),
diff --git a/crates/router/src/core/verification.rs b/crates/router/src/core/verification.rs
index f7ed33be64..3bf0eef104 100644
--- a/crates/router/src/core/verification.rs
+++ b/crates/router/src/core/verification.rs
@@ -93,20 +93,14 @@ pub async fn get_verified_apple_domains_with_mid_mca_id(
errors::ApiErrorResponse,
> {
let db = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &db.get_master_key().to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
.await
.change_context(errors::ApiErrorResponse::MerchantAccountNotFound)?;
#[cfg(feature = "v1")]
let verified_domains = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&merchant_id,
&merchant_connector_id,
&key_store,
@@ -118,11 +112,7 @@ pub async fn get_verified_apple_domains_with_mid_mca_id(
#[cfg(feature = "v2")]
let verified_domains = db
- .find_merchant_connector_account_by_id(
- key_manager_state,
- &merchant_connector_id,
- &key_store,
- )
+ .find_merchant_connector_account_by_id(&merchant_connector_id, &key_store)
.await
.change_context(errors::ApiErrorResponse::ResourceIdNotFound)?
.applepay_verified_domains
diff --git a/crates/router/src/core/verification/utils.rs b/crates/router/src/core/verification/utils.rs
index fb38d0a619..be6ed9cebd 100644
--- a/crates/router/src/core/verification/utils.rs
+++ b/crates/router/src/core/verification/utils.rs
@@ -19,11 +19,9 @@ pub async fn check_existence_and_add_domain_to_db(
merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,
domain_from_req: Vec<String>,
) -> CustomResult<Vec<String>, errors::ApiErrorResponse> {
- let key_manager_state = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -34,7 +32,6 @@ pub async fn check_existence_and_add_domain_to_db(
let merchant_connector_account = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
&merchant_id,
&merchant_connector_id,
&key_store,
@@ -45,11 +42,7 @@ pub async fn check_existence_and_add_domain_to_db(
#[cfg(feature = "v2")]
let merchant_connector_account = state
.store
- .find_merchant_connector_account_by_id(
- key_manager_state,
- &merchant_connector_id,
- &key_store,
- )
+ .find_merchant_connector_account_by_id(&merchant_connector_id, &key_store)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)?;
utils::validate_profile_id_from_auth_layer(
@@ -106,7 +99,6 @@ pub async fn check_existence_and_add_domain_to_db(
state
.store
.update_merchant_connector_account(
- key_manager_state,
merchant_connector_account,
updated_mca.into(),
&key_store,
@@ -153,7 +145,6 @@ pub async fn check_if_profile_id_is_present_in_payment_intent(
let db = &*state.store;
let payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&payment_id,
auth_data.merchant_account.get_id(),
&auth_data.key_store,
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index 7bf2e36266..db484100fb 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -922,15 +922,10 @@ async fn process_webhook_business_logic(
}
let profile_id = &merchant_connector_account.profile_id;
- let key_manager_state = &(state).into();
let business_profile = state
.store
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -1656,7 +1651,6 @@ async fn relay_refunds_incoming_webhook_flow(
source_verified: bool,
) -> CustomResult<WebhookResponseTracker, errors::ApiErrorResponse> {
let db = &*state.store;
- let key_manager_state = &(&state).into();
let relay_record = match webhook_details.object_reference_id {
webhooks::ObjectReferenceId::RefundId(refund_id_type) => match refund_id_type {
@@ -1667,18 +1661,13 @@ async fn relay_refunds_incoming_webhook_flow(
})
.change_context(errors::ApiErrorResponse::InternalServerError)?;
- db.find_relay_by_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- &relay_id,
- )
- .await
- .to_not_found_response(errors::ApiErrorResponse::WebhookResourceNotFound)
- .attach_printable("Failed to fetch the relay record")?
+ db.find_relay_by_id(platform.get_processor().get_key_store(), &relay_id)
+ .await
+ .to_not_found_response(errors::ApiErrorResponse::WebhookResourceNotFound)
+ .attach_printable("Failed to fetch the relay record")?
}
webhooks::RefundIdType::ConnectorRefundId(connector_refund_id) => db
.find_relay_by_profile_id_connector_reference_id(
- key_manager_state,
platform.get_processor().get_key_store(),
business_profile.get_id(),
&connector_refund_id,
@@ -1700,7 +1689,6 @@ async fn relay_refunds_incoming_webhook_flow(
.attach_printable("failed relay refund status mapping from event type")?,
};
db.update_relay(
- key_manager_state,
platform.get_processor().get_key_store(),
relay_record,
relay_update,
@@ -2708,7 +2696,6 @@ async fn fetch_optional_mca_and_connector(
#[cfg(feature = "v1")]
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- &state.into(),
platform.get_processor().get_account().get_id(),
&common_utils::id_type::MerchantConnectorAccountId::wrap(
connector_name_or_mca_id.to_owned(),
@@ -2771,7 +2758,6 @@ async fn update_additional_payment_method_data(
let pm = db
.find_payment_method(
- &state.into(),
platform.get_processor().get_key_store(),
payment_method_id.as_str(),
platform.get_processor().get_account().storage_scheme,
@@ -2823,11 +2809,9 @@ async fn update_connector_mandate_details(
let payment_attempt =
get_payment_attempt_from_object_reference_id(state, object_ref_id, platform).await?;
if let Some(ref payment_method_id) = payment_attempt.payment_method_id {
- let key_manager_state = &state.into();
let payment_method_info = state
.store
.find_payment_method(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_method_id,
platform.get_processor().get_account().storage_scheme,
@@ -2934,7 +2918,6 @@ async fn update_connector_mandate_details(
state
.store
.update_payment_method(
- key_manager_state,
platform.get_processor().get_key_store(),
payment_method_info,
pm_update,
diff --git a/crates/router/src/core/webhooks/incoming_v2.rs b/crates/router/src/core/webhooks/incoming_v2.rs
index e2e5a46216..53da2ee3b9 100644
--- a/crates/router/src/core/webhooks/incoming_v2.rs
+++ b/crates/router/src/core/webhooks/incoming_v2.rs
@@ -595,17 +595,11 @@ where
let (payment_intent, payment_attempt) = match payment_id {
api_models::payments::PaymentIdType::PaymentIntentId(ref id) => {
let payment_intent = db
- .find_payment_intent_by_id(
- key_manager_state,
- id,
- merchant_key_store,
- storage_scheme,
- )
+ .find_payment_intent_by_id(id, merchant_key_store, storage_scheme)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
let payment_attempt = db
.find_payment_attempt_by_id(
- key_manager_state,
merchant_key_store,
&payment_intent
.active_attempt_id
@@ -621,7 +615,6 @@ where
api_models::payments::PaymentIdType::ConnectorTransactionId(ref id) => {
let payment_attempt = db
.find_payment_attempt_by_profile_id_connector_transaction_id(
- key_manager_state,
merchant_key_store,
profile_id,
id,
@@ -631,7 +624,6 @@ where
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
&payment_attempt.payment_id,
merchant_key_store,
storage_scheme,
@@ -647,17 +639,11 @@ where
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while getting GlobalAttemptId")?;
let payment_attempt = db
- .find_payment_attempt_by_id(
- key_manager_state,
- merchant_key_store,
- &global_attempt_id,
- storage_scheme,
- )
+ .find_payment_attempt_by_id(merchant_key_store, &global_attempt_id, storage_scheme)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
let payment_intent = db
.find_payment_intent_by_id(
- key_manager_state,
&payment_attempt.payment_id,
merchant_key_store,
storage_scheme,
@@ -817,7 +803,7 @@ async fn fetch_mca_and_connector(
{
let db = &state.store;
let mca = db
- .find_merchant_connector_account_by_id(&state.into(), connector_id, key_store)
+ .find_merchant_connector_account_by_id(connector_id, key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
id: connector_id.get_string_repr().to_owned(),
diff --git a/crates/router/src/core/webhooks/network_tokenization_incoming.rs b/crates/router/src/core/webhooks/network_tokenization_incoming.rs
index abe9bc1137..649601fe78 100644
--- a/crates/router/src/core/webhooks/network_tokenization_incoming.rs
+++ b/crates/router/src/core/webhooks/network_tokenization_incoming.rs
@@ -351,7 +351,6 @@ pub async fn handle_metadata_update(
let db = &*state.store;
db.update_payment_method(
- &key_manager_state,
platform.get_processor().get_key_store(),
payment_method.clone(),
pm_update,
@@ -411,12 +410,10 @@ pub async fn fetch_merchant_account_for_network_token_webhooks(
merchant_id: &id_type::MerchantId,
) -> RouterResult<domain::Platform> {
let db = &*state.store;
- let key_manager_state = &(state).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -425,7 +422,7 @@ pub async fn fetch_merchant_account_for_network_token_webhooks(
.attach_printable("Failed to fetch merchant key store for the merchant id")?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -447,11 +444,9 @@ pub async fn fetch_payment_method_for_network_token_webhooks(
payment_method_id: &str,
) -> RouterResult<domain::PaymentMethod> {
let db = &*state.store;
- let key_manager_state = &(state).into();
let payment_method = db
.find_payment_method(
- key_manager_state,
key_store,
payment_method_id,
merchant_account.storage_scheme,
diff --git a/crates/router/src/core/webhooks/outgoing.rs b/crates/router/src/core/webhooks/outgoing.rs
index a2bf088984..e3156d4292 100644
--- a/crates/router/src/core/webhooks/outgoing.rs
+++ b/crates/router/src/core/webhooks/outgoing.rs
@@ -8,7 +8,7 @@ use common_utils::{
ext_traits::{Encode, StringExt},
request::RequestContent,
type_name,
- types::keymanager::{Identifier, KeyManagerState},
+ types::keymanager::Identifier,
};
use diesel_models::process_tracker::business_status;
use error_stack::{report, ResultExt};
@@ -154,7 +154,6 @@ pub(crate) async fn create_event_and_trigger_outgoing_webhook(
if (state
.store
.find_event_by_merchant_id_idempotent_event_id(
- key_manager_state,
&merchant_id,
&idempotent_event_id,
platform.get_processor().get_key_store(),
@@ -177,11 +176,7 @@ pub(crate) async fn create_event_and_trigger_outgoing_webhook(
let event_insert_result = state
.store
- .insert_event(
- key_manager_state,
- new_event,
- platform.get_processor().get_key_store(),
- )
+ .insert_event(new_event, platform.get_processor().get_key_store())
.await;
let event = match event_insert_result {
@@ -508,7 +503,6 @@ async fn raise_webhooks_analytics_event(
event: domain::Event,
merchant_key_store: &domain::MerchantKeyStore,
) {
- let key_manager_state: &KeyManagerState = &(&state).into();
let event_id = event.event_id;
let error = if let Err(error) = trigger_webhook_result {
@@ -532,12 +526,7 @@ async fn raise_webhooks_analytics_event(
// Fetch updated_event from db
let updated_event = state
.store
- .find_event_by_merchant_id_event_id(
- key_manager_state,
- &merchant_id,
- &event_id,
- merchant_key_store,
- )
+ .find_event_by_merchant_id_event_id(&merchant_id, &event_id, merchant_key_store)
.await
.attach_printable_lazy(|| format!("event not found for id: {}", &event_id))
.map_err(|error| {
@@ -773,7 +762,6 @@ async fn update_event_if_client_error(
state
.store
.update_event_by_merchant_id_event_id(
- key_manager_state,
merchant_id,
event_id,
event_update,
@@ -894,7 +882,6 @@ async fn update_event_in_storage(
state
.store
.update_event_by_merchant_id_event_id(
- key_manager_state,
merchant_id,
event_id,
event_update,
@@ -910,8 +897,6 @@ async fn update_overall_delivery_status_in_storage(
merchant_id: &common_utils::id_type::MerchantId,
updated_event: domain::Event,
) -> CustomResult<(), errors::WebhooksFlowError> {
- let key_manager_state = &(&state).into();
-
let update_overall_delivery_status = domain::EventUpdate::OverallDeliveryStatusUpdate {
is_overall_delivery_successful: true,
};
@@ -928,7 +913,6 @@ async fn update_overall_delivery_status_in_storage(
state
.store
.update_event_by_merchant_id_event_id(
- key_manager_state,
merchant_id,
initial_attempt_id.as_str(),
update_overall_delivery_status,
diff --git a/crates/router/src/core/webhooks/outgoing_v2.rs b/crates/router/src/core/webhooks/outgoing_v2.rs
index d0d2938e6b..d16d90064d 100644
--- a/crates/router/src/core/webhooks/outgoing_v2.rs
+++ b/crates/router/src/core/webhooks/outgoing_v2.rs
@@ -120,7 +120,7 @@ pub(crate) async fn create_event_and_trigger_outgoing_webhook(
let event_insert_result = state
.store
- .insert_event(key_manager_state, new_event, merchant_key_store)
+ .insert_event(new_event, merchant_key_store)
.await;
let event = match event_insert_result {
@@ -488,7 +488,6 @@ async fn update_event_in_storage(
state
.store
.update_event_by_merchant_id_event_id(
- key_manager_state,
merchant_id,
event_id,
event_update,
@@ -504,8 +503,6 @@ async fn update_overall_delivery_status_in_storage(
merchant_id: &common_utils::id_type::MerchantId,
updated_event: &domain::Event,
) -> CustomResult<(), errors::WebhooksFlowError> {
- let key_manager_state = &(&state).into();
-
let update_overall_delivery_status = domain::EventUpdate::OverallDeliveryStatusUpdate {
is_overall_delivery_successful: true,
};
@@ -522,7 +519,6 @@ async fn update_overall_delivery_status_in_storage(
state
.store
.update_event_by_merchant_id_event_id(
- key_manager_state,
merchant_id,
initial_attempt_id.as_str(),
update_overall_delivery_status,
diff --git a/crates/router/src/core/webhooks/recovery_incoming.rs b/crates/router/src/core/webhooks/recovery_incoming.rs
index b5d2f5ce5d..6efc966443 100644
--- a/crates/router/src/core/webhooks/recovery_incoming.rs
+++ b/crates/router/src/core/webhooks/recovery_incoming.rs
@@ -811,11 +811,10 @@ impl RevenueRecoveryAttempt {
self.0.connector_account_reference_id.clone(),
);
let db = &*state.store;
- let key_manager_state = &(state).into();
let payment_merchant_connector_account = payment_merchant_connector_account_id
.as_ref()
.async_map(|mca_id| async move {
- db.find_merchant_connector_account_by_id(key_manager_state, mca_id, key_store)
+ db.find_merchant_connector_account_by_id(mca_id, key_store)
.await
})
.await
diff --git a/crates/router/src/core/webhooks/webhook_events.rs b/crates/router/src/core/webhooks/webhook_events.rs
index 0df2921998..4a509c9247 100644
--- a/crates/router/src/core/webhooks/webhook_events.rs
+++ b/crates/router/src/core/webhooks/webhook_events.rs
@@ -34,7 +34,6 @@ pub async fn list_initial_delivery_attempts(
)?;
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
let (account, key_store) =
get_account_and_key_store(state.clone(), merchant_id.clone(), profile_id.clone()).await?;
@@ -51,7 +50,6 @@ pub async fn list_initial_delivery_attempts(
match account {
MerchantAccountOrProfile::MerchantAccount(merchant_account) => store
.list_initial_events_by_merchant_id_primary_object_or_initial_attempt_id(
- key_manager_state,
merchant_account.get_id(),
&object_id,
&event_id,
@@ -61,7 +59,6 @@ pub async fn list_initial_delivery_attempts(
MerchantAccountOrProfile::Profile(business_profile) => {
store
.list_initial_events_by_profile_id_primary_object_or_initial_attempt_id(
- key_manager_state,
business_profile.get_id(),
&object_id,
&event_id,
@@ -143,7 +140,6 @@ pub async fn list_initial_delivery_attempts(
MerchantAccountOrProfile::MerchantAccount(merchant_account) => {
store
.list_initial_events_by_merchant_id_constraints(
- key_manager_state,
merchant_account.get_id(),
created_after,
created_before,
@@ -158,7 +154,6 @@ pub async fn list_initial_delivery_attempts(
MerchantAccountOrProfile::Profile(business_profile) => {
store
.list_initial_events_by_profile_id_constraints(
- key_manager_state,
business_profile.get_id(),
created_after,
created_before,
@@ -208,11 +203,9 @@ pub async fn list_delivery_attempts(
initial_attempt_id: String,
) -> RouterResponse<Vec<api::webhook_events::EventRetrieveResponse>> {
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&store.get_master_key().to_vec().into(),
)
@@ -221,7 +214,6 @@ pub async fn list_delivery_attempts(
let events = store
.list_events_by_merchant_id_initial_attempt_id(
- key_manager_state,
&merchant_id,
&initial_attempt_id,
&key_store,
@@ -253,11 +245,9 @@ pub async fn retry_delivery_attempt(
event_id: String,
) -> RouterResponse<api::webhook_events::EventRetrieveResponse> {
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
let key_store = store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&store.get_master_key().to_vec().into(),
)
@@ -265,12 +255,7 @@ pub async fn retry_delivery_attempt(
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let event_to_retry = store
- .find_event_by_merchant_id_event_id(
- key_manager_state,
- &key_store.merchant_id,
- &event_id,
- &key_store,
- )
+ .find_event_by_merchant_id_event_id(&key_store.merchant_id, &event_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::EventNotFound)?;
@@ -280,7 +265,7 @@ pub async fn retry_delivery_attempt(
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to read business profile ID from event to retry")?;
let business_profile = store
- .find_business_profile_by_profile_id(key_manager_state, &key_store, &business_profile_id)
+ .find_business_profile_by_profile_id(&key_store, &business_profile_id)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to find business profile")?;
@@ -317,7 +302,7 @@ pub async fn retry_delivery_attempt(
};
let event = store
- .insert_event(key_manager_state, new_event, &key_store)
+ .insert_event(new_event, &key_store)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to insert event")?;
@@ -346,12 +331,7 @@ pub async fn retry_delivery_attempt(
.await;
let updated_event = store
- .find_event_by_merchant_id_event_id(
- key_manager_state,
- &key_store.merchant_id,
- &new_event_id,
- &key_store,
- )
+ .find_event_by_merchant_id_event_id(&key_store.merchant_id, &new_event_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::EventNotFound)?;
@@ -366,10 +346,9 @@ async fn get_account_and_key_store(
profile_id: Option<common_utils::id_type::ProfileId>,
) -> errors::RouterResult<(MerchantAccountOrProfile, domain::MerchantKeyStore)> {
let store = state.store.as_ref();
- let key_manager_state = &(&state).into();
+
let merchant_key_store = store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&store.get_master_key().to_vec().into(),
)
@@ -382,7 +361,6 @@ async fn get_account_and_key_store(
Some(profile_id) => {
let business_profile = store
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
&merchant_key_store,
&merchant_id,
&profile_id,
@@ -407,11 +385,7 @@ async fn get_account_and_key_store(
None => {
let merchant_account = store
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &merchant_key_store,
- )
+ .find_merchant_account_by_merchant_id(&merchant_id, &merchant_key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
diff --git a/crates/router/src/db.rs b/crates/router/src/db.rs
index c349a23fcb..5dad313938 100644
--- a/crates/router/src/db.rs
+++ b/crates/router/src/db.rs
@@ -42,7 +42,7 @@ pub mod user_key_store;
pub mod user_role;
use ::payment_methods::state::PaymentMethodsStorageInterface;
-use common_utils::id_type;
+use common_utils::{id_type, types::keymanager::KeyManagerState};
use diesel_models::{
fraud_check::{FraudCheck, FraudCheckUpdate},
organization::{Organization, OrganizationNew, OrganizationUpdate},
@@ -154,6 +154,7 @@ pub trait StorageInterface:
fn get_subscription_store(&self)
-> Box<dyn subscriptions::state::SubscriptionStorageInterface>;
fn get_cache_store(&self) -> Box<dyn RedisConnInterface + Send + Sync + 'static>;
+ fn set_key_manager_state(&mut self, key_manager_state: KeyManagerState);
}
#[async_trait::async_trait]
@@ -215,6 +216,12 @@ impl StorageInterface for Store {
) -> Box<dyn subscriptions::state::SubscriptionStorageInterface> {
Box::new(self.clone())
}
+
+ fn set_key_manager_state(&mut self, key_manager_state: KeyManagerState) {
+ self.key_manager_state = Some(key_manager_state.clone());
+ #[cfg(feature = "kv_store")]
+ self.router_store.set_key_manager_state(key_manager_state);
+ }
}
#[async_trait::async_trait]
@@ -243,6 +250,9 @@ impl StorageInterface for MockDb {
) -> Box<dyn subscriptions::state::SubscriptionStorageInterface> {
Box::new(self.clone())
}
+ fn set_key_manager_state(&mut self, key_manager_state: KeyManagerState) {
+ self.key_manager_state = Some(key_manager_state);
+ }
}
#[async_trait::async_trait]
diff --git a/crates/router/src/db/address.rs b/crates/router/src/db/address.rs
index 18b7f7f7af..705486e602 100644
--- a/crates/router/src/db/address.rs
+++ b/crates/router/src/db/address.rs
@@ -1,4 +1,4 @@
-use common_utils::{id_type, types::keymanager::KeyManagerState};
+use common_utils::id_type;
use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme};
use error_stack::ResultExt;
@@ -22,7 +22,6 @@ where
{
async fn update_address(
&self,
- state: &KeyManagerState,
address_id: String,
address: storage_types::AddressUpdate,
key_store: &domain::MerchantKeyStore,
@@ -30,7 +29,6 @@ where
async fn update_address_for_payments(
&self,
- state: &KeyManagerState,
this: domain::PaymentAddress,
address: domain::AddressUpdate,
payment_id: id_type::PaymentId,
@@ -40,14 +38,12 @@ where
async fn find_address_by_address_id(
&self,
- state: &KeyManagerState,
address_id: &str,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError>;
async fn insert_address_for_payments(
&self,
- state: &KeyManagerState,
payment_id: &id_type::PaymentId,
address: domain::PaymentAddress,
key_store: &domain::MerchantKeyStore,
@@ -56,14 +52,12 @@ where
async fn insert_address_for_customers(
&self,
- state: &KeyManagerState,
address: domain::CustomerAddress,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError>;
async fn find_address_by_merchant_id_payment_id_address_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
payment_id: &id_type::PaymentId,
address_id: &str,
@@ -73,7 +67,6 @@ where
async fn update_address_by_merchant_id_customer_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
address: storage_types::AddressUpdate,
@@ -105,7 +98,6 @@ mod storage {
#[instrument(skip_all)]
async fn find_address_by_address_id(
&self,
- state: &KeyManagerState,
address_id: &str,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
@@ -116,7 +108,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -129,7 +122,6 @@ mod storage {
#[instrument(skip_all)]
async fn find_address_by_merchant_id_payment_id_address_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
payment_id: &id_type::PaymentId,
address_id: &str,
@@ -157,7 +149,6 @@ mod storage {
#[instrument(skip_all)]
async fn update_address(
&self,
- state: &KeyManagerState,
address_id: String,
address: storage_types::AddressUpdate,
key_store: &domain::MerchantKeyStore,
@@ -169,7 +160,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -182,7 +174,6 @@ mod storage {
#[instrument(skip_all)]
async fn update_address_for_payments(
&self,
- state: &KeyManagerState,
this: domain::PaymentAddress,
address_update: domain::AddressUpdate,
_payment_id: id_type::PaymentId,
@@ -200,7 +191,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -213,7 +205,6 @@ mod storage {
#[instrument(skip_all)]
async fn insert_address_for_payments(
&self,
- state: &KeyManagerState,
_payment_id: &id_type::PaymentId,
address: domain::PaymentAddress,
key_store: &domain::MerchantKeyStore,
@@ -230,7 +221,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -243,7 +235,6 @@ mod storage {
#[instrument(skip_all)]
async fn insert_address_for_customers(
&self,
- state: &KeyManagerState,
address: domain::CustomerAddress,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
@@ -258,7 +249,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -271,7 +263,6 @@ mod storage {
#[instrument(skip_all)]
async fn update_address_by_merchant_id_customer_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
address: storage_types::AddressUpdate,
@@ -305,7 +296,7 @@ mod storage {
#[cfg(feature = "kv_store")]
mod storage {
- use common_utils::{ext_traits::AsyncExt, id_type, types::keymanager::KeyManagerState};
+ use common_utils::{ext_traits::AsyncExt, id_type};
use diesel_models::{enums::MerchantStorageScheme, AddressUpdateInternal};
use error_stack::{report, ResultExt};
use redis_interface::HsetnxReply;
@@ -333,7 +324,6 @@ mod storage {
#[instrument(skip_all)]
async fn find_address_by_address_id(
&self,
- state: &KeyManagerState,
address_id: &str,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
@@ -344,7 +334,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -357,7 +348,6 @@ mod storage {
#[instrument(skip_all)]
async fn find_address_by_merchant_id_payment_id_address_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
payment_id: &id_type::PaymentId,
address_id: &str,
@@ -406,7 +396,8 @@ mod storage {
}?;
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
@@ -419,7 +410,6 @@ mod storage {
#[instrument(skip_all)]
async fn update_address(
&self,
- state: &KeyManagerState,
address_id: String,
address: storage_types::AddressUpdate,
key_store: &domain::MerchantKeyStore,
@@ -431,7 +421,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -444,7 +435,6 @@ mod storage {
#[instrument(skip_all)]
async fn update_address_for_payments(
&self,
- state: &KeyManagerState,
this: domain::PaymentAddress,
address_update: domain::AddressUpdate,
payment_id: id_type::PaymentId,
@@ -476,7 +466,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -517,7 +508,8 @@ mod storage {
updated_address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -530,7 +522,6 @@ mod storage {
#[instrument(skip_all)]
async fn insert_address_for_payments(
&self,
- state: &KeyManagerState,
payment_id: &id_type::PaymentId,
address: domain::PaymentAddress,
key_store: &domain::MerchantKeyStore,
@@ -558,7 +549,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -622,7 +614,8 @@ mod storage {
.into()),
Ok(HsetnxReply::KeySet) => Ok(created_address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -637,7 +630,6 @@ mod storage {
#[instrument(skip_all)]
async fn insert_address_for_customers(
&self,
- state: &KeyManagerState,
address: domain::CustomerAddress,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
@@ -652,7 +644,8 @@ mod storage {
.async_and_then(|address| async {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -665,7 +658,6 @@ mod storage {
#[instrument(skip_all)]
async fn update_address_by_merchant_id_customer_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
address: storage_types::AddressUpdate,
@@ -686,7 +678,8 @@ mod storage {
output.push(
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -705,7 +698,6 @@ mod storage {
impl AddressInterface for MockDb {
async fn find_address_by_address_id(
&self,
- state: &KeyManagerState,
address_id: &str,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
@@ -719,7 +711,8 @@ impl AddressInterface for MockDb {
Some(address) => address
.clone()
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -735,7 +728,6 @@ impl AddressInterface for MockDb {
async fn find_address_by_merchant_id_payment_id_address_id(
&self,
- state: &KeyManagerState,
_merchant_id: &id_type::MerchantId,
_payment_id: &id_type::PaymentId,
address_id: &str,
@@ -752,7 +744,8 @@ impl AddressInterface for MockDb {
Some(address) => address
.clone()
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -768,7 +761,6 @@ impl AddressInterface for MockDb {
async fn update_address(
&self,
- state: &KeyManagerState,
address_id: String,
address_update: storage_types::AddressUpdate,
key_store: &domain::MerchantKeyStore,
@@ -788,7 +780,8 @@ impl AddressInterface for MockDb {
match updated_addr {
Some(address_updated) => address_updated
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -803,7 +796,6 @@ impl AddressInterface for MockDb {
async fn update_address_for_payments(
&self,
- state: &KeyManagerState,
this: domain::PaymentAddress,
address_update: domain::AddressUpdate,
_payment_id: id_type::PaymentId,
@@ -825,7 +817,8 @@ impl AddressInterface for MockDb {
match updated_addr {
Some(address_updated) => address_updated
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -840,7 +833,6 @@ impl AddressInterface for MockDb {
async fn insert_address_for_payments(
&self,
- state: &KeyManagerState,
_payment_id: &id_type::PaymentId,
address_new: domain::PaymentAddress,
key_store: &domain::MerchantKeyStore,
@@ -856,7 +848,8 @@ impl AddressInterface for MockDb {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -866,7 +859,6 @@ impl AddressInterface for MockDb {
async fn insert_address_for_customers(
&self,
- state: &KeyManagerState,
address_new: domain::CustomerAddress,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
@@ -880,7 +872,8 @@ impl AddressInterface for MockDb {
address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -890,7 +883,6 @@ impl AddressInterface for MockDb {
async fn update_address_by_merchant_id_customer_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
address_update: storage_types::AddressUpdate,
@@ -915,7 +907,8 @@ impl AddressInterface for MockDb {
Some(address) => {
let address: domain::Address = address
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
diff --git a/crates/router/src/db/api_keys.rs b/crates/router/src/db/api_keys.rs
index 140d1fb4a3..25b8f95eae 100644
--- a/crates/router/src/db/api_keys.rs
+++ b/crates/router/src/db/api_keys.rs
@@ -376,6 +376,7 @@ impl ApiKeyInterface for MockDb {
mod tests {
use std::borrow::Cow;
+ use common_utils::types::keymanager::KeyManagerState;
use storage_impl::redis::{
cache::{self, CacheKey, CacheKind, ACCOUNTS_CACHE},
kv_store::RedisConnInterface,
@@ -391,9 +392,12 @@ mod tests {
#[tokio::test]
async fn test_mockdb_api_key_interface() {
#[allow(clippy::expect_used)]
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let merchant_id =
common_utils::id_type::MerchantId::try_from(Cow::from("merchant1")).unwrap();
@@ -488,9 +492,12 @@ mod tests {
let merchant_id =
common_utils::id_type::MerchantId::try_from(Cow::from("test_merchant")).unwrap();
- let db = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let db = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let redis_conn = db.get_redis_conn().unwrap();
redis_conn
diff --git a/crates/router/src/db/dispute.rs b/crates/router/src/db/dispute.rs
index 9a890a317e..81dad9b186 100644
--- a/crates/router/src/db/dispute.rs
+++ b/crates/router/src/db/dispute.rs
@@ -456,7 +456,9 @@ mod tests {
use std::borrow::Cow;
use common_enums::enums::Currency;
- use common_utils::types::{AmountConvertor, MinorUnit, StringMinorUnitForConnector};
+ use common_utils::types::{
+ keymanager::KeyManagerState, AmountConvertor, MinorUnit, StringMinorUnitForConnector,
+ };
use diesel_models::{
dispute::DisputeNew,
enums::{DisputeStage, DisputeStatus},
@@ -511,7 +513,7 @@ mod tests {
#[tokio::test]
async fn test_insert_dispute() {
- let mockdb = MockDb::new(&RedisSettings::default())
+ let mockdb = MockDb::new(&RedisSettings::default(), KeyManagerState::new())
.await
.expect("Failed to create a mock DB");
@@ -550,7 +552,7 @@ mod tests {
let merchant_id =
common_utils::id_type::MerchantId::try_from(Cow::from("merchant_1")).unwrap();
- let mockdb = MockDb::new(&RedisSettings::default())
+ let mockdb = MockDb::new(&RedisSettings::default(), KeyManagerState::new())
.await
.expect("Failed to create Mock store");
@@ -605,7 +607,7 @@ mod tests {
let payment_id =
common_utils::id_type::PaymentId::try_from(Cow::Borrowed("payment_1")).unwrap();
- let mockdb = MockDb::new(&RedisSettings::default())
+ let mockdb = MockDb::new(&RedisSettings::default(), KeyManagerState::new())
.await
.expect("Failed to create Mock store");
@@ -647,7 +649,7 @@ mod tests {
let payment_id =
common_utils::id_type::PaymentId::try_from(Cow::Borrowed("payment_1")).unwrap();
- let mockdb = MockDb::new(&RedisSettings::default())
+ let mockdb = MockDb::new(&RedisSettings::default(), KeyManagerState::new())
.await
.expect("Failed to create Mock store");
@@ -694,7 +696,7 @@ mod tests {
.await
.unwrap();
- assert_eq!(1, found_disputes.len());
+ assert_eq!(2, found_disputes.len());
assert_eq!(created_dispute, found_disputes.first().unwrap().clone());
}
@@ -707,7 +709,7 @@ mod tests {
let payment_id =
common_utils::id_type::PaymentId::try_from(Cow::Borrowed("payment_1")).unwrap();
- let mockdb = MockDb::new(&RedisSettings::default())
+ let mockdb = MockDb::new(&RedisSettings::default(), KeyManagerState::new())
.await
.expect("Failed to create Mock store");
@@ -738,7 +740,7 @@ mod tests {
.await
.unwrap();
- assert_eq!(1, found_disputes.len());
+ assert_eq!(2, found_disputes.len());
assert_eq!(created_dispute, found_disputes.first().unwrap().clone());
}
@@ -770,9 +772,12 @@ mod tests {
let payment_id =
common_utils::id_type::PaymentId::try_from(Cow::Borrowed("payment_1")).unwrap();
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ common_utils::types::keymanager::KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let created_dispute = mockdb
.insert_dispute(create_dispute_new(DisputeNewIds {
@@ -854,9 +859,12 @@ mod tests {
let payment_id =
common_utils::id_type::PaymentId::try_from(Cow::Borrowed("payment_1")).unwrap();
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ common_utils::types::keymanager::KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let created_dispute = mockdb
.insert_dispute(create_dispute_new(DisputeNewIds {
@@ -933,9 +941,12 @@ mod tests {
let payment_id =
common_utils::id_type::PaymentId::try_from(Cow::Borrowed("payment_1")).unwrap();
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ common_utils::types::keymanager::KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let created_dispute = mockdb
.insert_dispute(create_dispute_new(DisputeNewIds {
diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rs
index ef01adf8fb..254644cb55 100644
--- a/crates/router/src/db/events.rs
+++ b/crates/router/src/db/events.rs
@@ -1,6 +1,6 @@
use std::collections::HashSet;
-use common_utils::{ext_traits::AsyncExt, types::keymanager::KeyManagerState};
+use common_utils::ext_traits::AsyncExt;
use error_stack::{report, ResultExt};
use router_env::{instrument, tracing};
@@ -25,14 +25,12 @@ where
{
async fn insert_event(
&self,
- state: &KeyManagerState,
event: domain::Event,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError>;
async fn find_event_by_merchant_id_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -40,7 +38,6 @@ where
async fn find_event_by_merchant_id_idempotent_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
idempotent_event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -48,7 +45,6 @@ where
async fn list_initial_events_by_merchant_id_primary_object_or_initial_attempt_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
primary_object_id: &str,
initial_attempt_id: &str,
@@ -58,7 +54,6 @@ where
#[allow(clippy::too_many_arguments)]
async fn list_initial_events_by_merchant_id_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
created_after: time::PrimitiveDateTime,
created_before: time::PrimitiveDateTime,
@@ -71,7 +66,6 @@ where
async fn list_events_by_merchant_id_initial_attempt_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
initial_attempt_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -79,7 +73,6 @@ where
async fn list_initial_events_by_profile_id_primary_object_or_initial_attempt_id(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
primary_object_id: &str,
initial_attempt_id: &str,
@@ -89,7 +82,6 @@ where
#[allow(clippy::too_many_arguments)]
async fn list_initial_events_by_profile_id_constraints(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
created_after: time::PrimitiveDateTime,
created_before: time::PrimitiveDateTime,
@@ -102,7 +94,6 @@ where
async fn update_event_by_merchant_id_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
event_id: &str,
event: domain::EventUpdate,
@@ -125,7 +116,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn insert_event(
&self,
- state: &KeyManagerState,
event: domain::Event,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
@@ -138,7 +128,8 @@ impl EventInterface for Store {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -149,7 +140,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn find_event_by_merchant_id_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -159,7 +149,8 @@ impl EventInterface for Store {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -170,7 +161,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn find_event_by_merchant_id_idempotent_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
idempotent_event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -184,7 +174,8 @@ impl EventInterface for Store {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -195,7 +186,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn list_initial_events_by_merchant_id_primary_object_or_initial_attempt_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
primary_object_id: &str,
initial_attempt_id: &str,
@@ -215,8 +205,7 @@ impl EventInterface for Store {
for event in events.into_iter() {
domain_events.push(
event
- .convert(
- state,
+ .convert(self.get_keymanager_state().attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -232,7 +221,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn list_initial_events_by_merchant_id_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
created_after: time::PrimitiveDateTime,
created_before: time::PrimitiveDateTime,
@@ -261,7 +249,8 @@ impl EventInterface for Store {
domain_events.push(
event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -277,7 +266,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn list_events_by_merchant_id_initial_attempt_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
initial_attempt_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -296,7 +284,8 @@ impl EventInterface for Store {
domain_events.push(
event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -312,7 +301,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn list_initial_events_by_profile_id_primary_object_or_initial_attempt_id(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
primary_object_id: &str,
initial_attempt_id: &str,
@@ -333,7 +321,8 @@ impl EventInterface for Store {
domain_events.push(
event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -349,7 +338,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn list_initial_events_by_profile_id_constraints(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
created_after: time::PrimitiveDateTime,
created_before: time::PrimitiveDateTime,
@@ -378,7 +366,8 @@ impl EventInterface for Store {
domain_events.push(
event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
merchant_key_store.merchant_id.clone(),
@@ -396,7 +385,6 @@ impl EventInterface for Store {
#[instrument(skip_all)]
async fn update_event_by_merchant_id_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
event_id: &str,
event: domain::EventUpdate,
@@ -407,7 +395,8 @@ impl EventInterface for Store {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -443,7 +432,6 @@ impl EventInterface for Store {
impl EventInterface for MockDb {
async fn insert_event(
&self,
- state: &KeyManagerState,
event: domain::Event,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
@@ -457,7 +445,8 @@ impl EventInterface for MockDb {
stored_event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -467,7 +456,6 @@ impl EventInterface for MockDb {
async fn find_event_by_merchant_id_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -481,8 +469,7 @@ impl EventInterface for MockDb {
.cloned()
.async_map(|event| async {
event
- .convert(
- state,
+ .convert(self.get_keymanager_state().attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -501,7 +488,6 @@ impl EventInterface for MockDb {
async fn find_event_by_merchant_id_idempotent_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
idempotent_event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -515,8 +501,7 @@ impl EventInterface for MockDb {
.cloned()
.async_map(|event| async {
event
- .convert(
- state,
+ .convert(self.get_keymanager_state().attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -535,7 +520,6 @@ impl EventInterface for MockDb {
async fn list_initial_events_by_merchant_id_primary_object_or_initial_attempt_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
primary_object_id: &str,
initial_attempt_id: &str,
@@ -558,7 +542,8 @@ impl EventInterface for MockDb {
for event in events {
let domain_event = event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -572,7 +557,6 @@ impl EventInterface for MockDb {
async fn list_initial_events_by_merchant_id_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
created_after: time::PrimitiveDateTime,
created_before: time::PrimitiveDateTime,
@@ -626,7 +610,8 @@ impl EventInterface for MockDb {
for event in events {
let domain_event = event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -640,7 +625,6 @@ impl EventInterface for MockDb {
async fn list_events_by_merchant_id_initial_attempt_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
initial_attempt_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
@@ -659,7 +643,8 @@ impl EventInterface for MockDb {
for event in events {
let domain_event = event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -673,7 +658,6 @@ impl EventInterface for MockDb {
async fn list_initial_events_by_profile_id_primary_object_or_initial_attempt_id(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
primary_object_id: &str,
initial_attempt_id: &str,
@@ -696,7 +680,8 @@ impl EventInterface for MockDb {
for event in events {
let domain_event = event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -710,7 +695,6 @@ impl EventInterface for MockDb {
async fn list_initial_events_by_profile_id_constraints(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
created_after: time::PrimitiveDateTime,
created_before: time::PrimitiveDateTime,
@@ -764,7 +748,8 @@ impl EventInterface for MockDb {
for event in events {
let domain_event = event
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -778,7 +763,6 @@ impl EventInterface for MockDb {
async fn update_event_by_merchant_id_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
event_id: &str,
event: domain::EventUpdate,
@@ -811,7 +795,8 @@ impl EventInterface for MockDb {
event_to_update
.clone()
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -858,7 +843,10 @@ mod tests {
use common_enums::IntentStatus;
use common_utils::{
generate_organization_id_of_default_length, type_name,
- types::{keymanager::Identifier, MinorUnit},
+ types::{
+ keymanager::{Identifier, KeyManagerState},
+ MinorUnit,
+ },
};
use diesel_models::{
business_profile::WebhookDetails,
@@ -888,20 +876,25 @@ mod tests {
#[tokio::test]
#[cfg(feature = "v1")]
- async fn test_mockdb_event_interface() {
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ #[allow(clippy::panic_in_result_fn)]
+ async fn test_mockdb_event_interface() -> Result<(), Box<dyn std::error::Error>> {
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let event_id = "test_event_id";
let (tx, _) = tokio::sync::oneshot::channel();
let app_state = Box::pin(routes::AppState::with_storage(
- Settings::default(),
+ Settings::new()?,
StorageImpl::PostgresqlTest,
tx,
Box::new(services::MockApiClient),
))
.await;
- let state = &Arc::new(app_state)
+ let app_state_arc = Arc::new(app_state);
+ let state = app_state_arc
.get_session_state(
&common_utils::id_type::TenantId::try_from_string("public".to_string()).unwrap(),
None,
@@ -914,11 +907,10 @@ mod tests {
let business_profile_id =
common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from("profile1")).unwrap();
let payment_id = "test_payment_id";
- let key_manager_state = &state.into();
+ let key_manager_state = &(&state).into();
let master_key = mockdb.get_master_key();
mockdb
.insert_merchant_key_store(
- key_manager_state,
domain::MerchantKeyStore {
merchant_id: merchant_id.clone(),
key: domain::types::crypto_operation(
@@ -940,17 +932,12 @@ mod tests {
.await
.unwrap();
let merchant_key_store = mockdb
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &master_key.to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &master_key.to_vec().into())
.await
.unwrap();
let event1 = mockdb
.insert_event(
- key_manager_state,
domain::Event {
event_id: event_id.into(),
event_type: enums::EventType::PaymentSucceeded,
@@ -984,7 +971,6 @@ mod tests {
let updated_event = mockdb
.update_event_by_merchant_id_event_id(
- key_manager_state,
&merchant_id,
event_id,
domain::EventUpdate::UpdateResponse {
@@ -999,18 +985,23 @@ mod tests {
assert!(updated_event.is_webhook_notified);
assert_eq!(updated_event.primary_object_id, payment_id);
assert_eq!(updated_event.event_id, event_id);
+ Ok(())
}
#[tokio::test]
#[cfg(feature = "v2")]
- async fn test_mockdb_event_interface() {
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ #[allow(clippy::panic_in_result_fn)]
+ async fn test_mockdb_event_interface() -> Result<(), Box<dyn std::error::Error>> {
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let event_id = "test_event_id";
let (tx, _) = tokio::sync::oneshot::channel();
let app_state = Box::pin(routes::AppState::with_storage(
- Settings::default(),
+ Settings::new()?,
StorageImpl::PostgresqlTest,
tx,
Box::new(services::MockApiClient),
@@ -1033,7 +1024,6 @@ mod tests {
let master_key = mockdb.get_master_key();
mockdb
.insert_merchant_key_store(
- key_manager_state,
domain::MerchantKeyStore {
merchant_id: merchant_id.clone(),
key: domain::types::crypto_operation(
@@ -1055,17 +1045,12 @@ mod tests {
.await
.unwrap();
let merchant_key_store = mockdb
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &master_key.to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &master_key.to_vec().into())
.await
.unwrap();
let event1 = mockdb
.insert_event(
- key_manager_state,
domain::Event {
event_id: event_id.into(),
event_type: enums::EventType::PaymentSucceeded,
@@ -1099,7 +1084,6 @@ mod tests {
let updated_event = mockdb
.update_event_by_merchant_id_event_id(
- key_manager_state,
&merchant_id,
event_id,
domain::EventUpdate::UpdateResponse {
@@ -1114,6 +1098,7 @@ mod tests {
assert!(updated_event.is_webhook_notified);
assert_eq!(updated_event.primary_object_id, payment_id);
assert_eq!(updated_event.event_id, event_id);
+ Ok(())
}
#[cfg(feature = "v1")]
@@ -1151,7 +1136,6 @@ mod tests {
let merchant_key_store = state
.store
.insert_merchant_key_store(
- key_manager_state,
domain::MerchantKeyStore {
merchant_id: merchant_id.clone(),
key: domain::types::crypto_operation(
@@ -1218,11 +1202,7 @@ mod tests {
});
let merchant_account = state
.store
- .insert_merchant(
- key_manager_state,
- merchant_account_to_insert,
- &merchant_key_store,
- )
+ .insert_merchant(merchant_account_to_insert, &merchant_key_store)
.await?;
let platform = domain::Platform::new(
@@ -1307,11 +1287,7 @@ mod tests {
let business_profile = state
.store
- .insert_business_profile(
- key_manager_state,
- &merchant_key_store.clone(),
- business_profile_to_insert,
- )
+ .insert_business_profile(&merchant_key_store.clone(), business_profile_to_insert)
.await?;
// Same inputs for all threads
@@ -1476,7 +1452,6 @@ mod tests {
let events = state
.store
.list_initial_events_by_merchant_id_primary_object_or_initial_attempt_id(
- key_manager_state,
&business_profile.merchant_id,
&primary_object_id.clone(),
&initial_attempt_id.clone(),
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index 1ea7da228b..0e4acc2770 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -16,6 +16,7 @@ use diesel_models::{
reverse_lookup::{ReverseLookup, ReverseLookupNew},
user_role as user_storage,
};
+use error_stack::ResultExt;
#[cfg(feature = "payouts")]
use hyperswitch_domain_models::payouts::{
payout_attempt::PayoutAttemptInterface, payouts::PayoutsInterface,
@@ -124,30 +125,27 @@ impl KafkaStore {
impl AddressInterface for KafkaStore {
async fn find_address_by_address_id(
&self,
- state: &KeyManagerState,
address_id: &str,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
self.diesel_store
- .find_address_by_address_id(state, address_id, key_store)
+ .find_address_by_address_id(address_id, key_store)
.await
}
async fn update_address(
&self,
- state: &KeyManagerState,
address_id: String,
address: storage::AddressUpdate,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
self.diesel_store
- .update_address(state, address_id, address, key_store)
+ .update_address(address_id, address, key_store)
.await
}
async fn update_address_for_payments(
&self,
- state: &KeyManagerState,
this: domain::PaymentAddress,
address: domain::AddressUpdate,
payment_id: id_type::PaymentId,
@@ -155,33 +153,24 @@ impl AddressInterface for KafkaStore {
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::PaymentAddress, errors::StorageError> {
self.diesel_store
- .update_address_for_payments(
- state,
- this,
- address,
- payment_id,
- key_store,
- storage_scheme,
- )
+ .update_address_for_payments(this, address, payment_id, key_store, storage_scheme)
.await
}
async fn insert_address_for_payments(
&self,
- state: &KeyManagerState,
payment_id: &id_type::PaymentId,
address: domain::PaymentAddress,
key_store: &domain::MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::PaymentAddress, errors::StorageError> {
self.diesel_store
- .insert_address_for_payments(state, payment_id, address, key_store, storage_scheme)
+ .insert_address_for_payments(payment_id, address, key_store, storage_scheme)
.await
}
async fn find_address_by_merchant_id_payment_id_address_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
payment_id: &id_type::PaymentId,
address_id: &str,
@@ -190,7 +179,6 @@ impl AddressInterface for KafkaStore {
) -> CustomResult<domain::PaymentAddress, errors::StorageError> {
self.diesel_store
.find_address_by_merchant_id_payment_id_address_id(
- state,
merchant_id,
payment_id,
address_id,
@@ -202,31 +190,23 @@ impl AddressInterface for KafkaStore {
async fn insert_address_for_customers(
&self,
- state: &KeyManagerState,
address: domain::CustomerAddress,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Address, errors::StorageError> {
self.diesel_store
- .insert_address_for_customers(state, address, key_store)
+ .insert_address_for_customers(address, key_store)
.await
}
async fn update_address_by_merchant_id_customer_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
address: storage::AddressUpdate,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<Vec<domain::Address>, errors::StorageError> {
self.diesel_store
- .update_address_by_merchant_id_customer_id(
- state,
- customer_id,
- merchant_id,
- address,
- key_store,
- )
+ .update_address_by_merchant_id_customer_id(customer_id, merchant_id, address, key_store)
.await
}
}
@@ -395,7 +375,6 @@ impl CustomerInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn find_customer_optional_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
@@ -403,7 +382,6 @@ impl CustomerInterface for KafkaStore {
) -> CustomResult<Option<domain::Customer>, errors::StorageError> {
self.diesel_store
.find_customer_optional_by_customer_id_merchant_id(
- state,
customer_id,
merchant_id,
key_store,
@@ -415,7 +393,6 @@ impl CustomerInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
@@ -423,7 +400,6 @@ impl CustomerInterface for KafkaStore {
) -> CustomResult<Option<domain::Customer>, errors::StorageError> {
self.diesel_store
.find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
- state,
customer_id,
merchant_id,
key_store,
@@ -435,7 +411,6 @@ impl CustomerInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_optional_by_merchant_id_merchant_reference_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
@@ -443,7 +418,6 @@ impl CustomerInterface for KafkaStore {
) -> CustomResult<Option<domain::Customer>, errors::StorageError> {
self.diesel_store
.find_optional_by_merchant_id_merchant_reference_id(
- state,
customer_id,
merchant_id,
key_store,
@@ -455,7 +429,6 @@ impl CustomerInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn update_customer_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: id_type::CustomerId,
merchant_id: id_type::MerchantId,
customer: domain::Customer,
@@ -465,7 +438,6 @@ impl CustomerInterface for KafkaStore {
) -> CustomResult<domain::Customer, errors::StorageError> {
self.diesel_store
.update_customer_by_customer_id_merchant_id(
- state,
customer_id,
merchant_id,
customer,
@@ -479,7 +451,6 @@ impl CustomerInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn update_customer_by_global_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
customer: domain::Customer,
customer_update: storage::CustomerUpdate,
@@ -487,45 +458,35 @@ impl CustomerInterface for KafkaStore {
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, errors::StorageError> {
self.diesel_store
- .update_customer_by_global_id(
- state,
- id,
- customer,
- customer_update,
- key_store,
- storage_scheme,
- )
+ .update_customer_by_global_id(id, customer, customer_update, key_store, storage_scheme)
.await
}
async fn list_customers_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
constraints: super::customers::CustomerListConstraints,
) -> CustomResult<Vec<domain::Customer>, errors::StorageError> {
self.diesel_store
- .list_customers_by_merchant_id(state, merchant_id, key_store, constraints)
+ .list_customers_by_merchant_id(merchant_id, key_store, constraints)
.await
}
async fn list_customers_by_merchant_id_with_count(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
constraints: super::customers::CustomerListConstraints,
) -> CustomResult<(Vec<domain::Customer>, usize), errors::StorageError> {
self.diesel_store
- .list_customers_by_merchant_id_with_count(state, merchant_id, key_store, constraints)
+ .list_customers_by_merchant_id_with_count(merchant_id, key_store, constraints)
.await
}
#[cfg(feature = "v1")]
async fn find_customer_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
@@ -533,7 +494,6 @@ impl CustomerInterface for KafkaStore {
) -> CustomResult<domain::Customer, errors::StorageError> {
self.diesel_store
.find_customer_by_customer_id_merchant_id(
- state,
customer_id,
merchant_id,
key_store,
@@ -545,7 +505,6 @@ impl CustomerInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_customer_by_merchant_reference_id_merchant_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
@@ -553,7 +512,6 @@ impl CustomerInterface for KafkaStore {
) -> CustomResult<domain::Customer, errors::StorageError> {
self.diesel_store
.find_customer_by_merchant_reference_id_merchant_id(
- state,
merchant_reference_id,
merchant_id,
key_store,
@@ -565,25 +523,23 @@ impl CustomerInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_customer_by_global_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
key_store: &domain::MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, errors::StorageError> {
self.diesel_store
- .find_customer_by_global_id(state, id, key_store, storage_scheme)
+ .find_customer_by_global_id(id, key_store, storage_scheme)
.await
}
async fn insert_customer(
&self,
customer_data: domain::Customer,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, errors::StorageError> {
self.diesel_store
- .insert_customer(customer_data, state, key_store, storage_scheme)
+ .insert_customer(customer_data, key_store, storage_scheme)
.await
}
}
@@ -744,37 +700,33 @@ impl ClientSecretInterface for KafkaStore {
impl EventInterface for KafkaStore {
async fn insert_event(
&self,
- state: &KeyManagerState,
event: domain::Event,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
self.diesel_store
- .insert_event(state, event, merchant_key_store)
+ .insert_event(event, merchant_key_store)
.await
}
async fn find_event_by_merchant_id_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
self.diesel_store
- .find_event_by_merchant_id_event_id(state, merchant_id, event_id, merchant_key_store)
+ .find_event_by_merchant_id_event_id(merchant_id, event_id, merchant_key_store)
.await
}
async fn find_event_by_merchant_id_idempotent_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
idempotent_event_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
self.diesel_store
.find_event_by_merchant_id_idempotent_event_id(
- state,
merchant_id,
idempotent_event_id,
merchant_key_store,
@@ -784,7 +736,6 @@ impl EventInterface for KafkaStore {
async fn list_initial_events_by_merchant_id_primary_object_or_initial_attempt_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
primary_object_id: &str,
initial_attempt_id: &str,
@@ -792,7 +743,6 @@ impl EventInterface for KafkaStore {
) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
self.diesel_store
.list_initial_events_by_merchant_id_primary_object_or_initial_attempt_id(
- state,
merchant_id,
primary_object_id,
initial_attempt_id,
@@ -803,7 +753,6 @@ impl EventInterface for KafkaStore {
async fn list_initial_events_by_merchant_id_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
created_after: PrimitiveDateTime,
created_before: PrimitiveDateTime,
@@ -815,7 +764,6 @@ impl EventInterface for KafkaStore {
) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
self.diesel_store
.list_initial_events_by_merchant_id_constraints(
- state,
merchant_id,
created_after,
created_before,
@@ -830,14 +778,12 @@ impl EventInterface for KafkaStore {
async fn list_events_by_merchant_id_initial_attempt_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
initial_attempt_id: &str,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
self.diesel_store
.list_events_by_merchant_id_initial_attempt_id(
- state,
merchant_id,
initial_attempt_id,
merchant_key_store,
@@ -847,7 +793,6 @@ impl EventInterface for KafkaStore {
async fn list_initial_events_by_profile_id_primary_object_or_initial_attempt_id(
&self,
- state: &KeyManagerState,
profile_id: &id_type::ProfileId,
primary_object_id: &str,
initial_attempt_id: &str,
@@ -855,7 +800,6 @@ impl EventInterface for KafkaStore {
) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
self.diesel_store
.list_initial_events_by_profile_id_primary_object_or_initial_attempt_id(
- state,
profile_id,
primary_object_id,
initial_attempt_id,
@@ -866,7 +810,6 @@ impl EventInterface for KafkaStore {
async fn list_initial_events_by_profile_id_constraints(
&self,
- state: &KeyManagerState,
profile_id: &id_type::ProfileId,
created_after: PrimitiveDateTime,
created_before: PrimitiveDateTime,
@@ -878,7 +821,6 @@ impl EventInterface for KafkaStore {
) -> CustomResult<Vec<domain::Event>, errors::StorageError> {
self.diesel_store
.list_initial_events_by_profile_id_constraints(
- state,
profile_id,
created_after,
created_before,
@@ -893,20 +835,13 @@ impl EventInterface for KafkaStore {
async fn update_event_by_merchant_id_event_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
event_id: &str,
event: domain::EventUpdate,
merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::Event, errors::StorageError> {
self.diesel_store
- .update_event_by_merchant_id_event_id(
- state,
- merchant_id,
- event_id,
- event,
- merchant_key_store,
- )
+ .update_event_by_merchant_id_event_id(merchant_id, event_id, event, merchant_key_store)
.await
}
@@ -1080,47 +1015,43 @@ impl MerchantAccountInterface for KafkaStore {
type Error = errors::StorageError;
async fn insert_merchant(
&self,
- state: &KeyManagerState,
merchant_account: domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
self.diesel_store
- .insert_merchant(state, merchant_account, key_store)
+ .insert_merchant(merchant_account, key_store)
.await
}
async fn find_merchant_account_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
self.diesel_store
- .find_merchant_account_by_merchant_id(state, merchant_id, key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, key_store)
.await
}
async fn update_merchant(
&self,
- state: &KeyManagerState,
this: domain::MerchantAccount,
merchant_account: storage::MerchantAccountUpdate,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
self.diesel_store
- .update_merchant(state, this, merchant_account, key_store)
+ .update_merchant(this, merchant_account, key_store)
.await
}
async fn update_specific_fields_in_merchant(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
merchant_account: storage::MerchantAccountUpdate,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
self.diesel_store
- .update_specific_fields_in_merchant(state, merchant_id, merchant_account, key_store)
+ .update_specific_fields_in_merchant(merchant_id, merchant_account, key_store)
.await
}
@@ -1135,23 +1066,21 @@ impl MerchantAccountInterface for KafkaStore {
async fn find_merchant_account_by_publishable_key(
&self,
- state: &KeyManagerState,
publishable_key: &str,
) -> CustomResult<(domain::MerchantAccount, domain::MerchantKeyStore), errors::StorageError>
{
self.diesel_store
- .find_merchant_account_by_publishable_key(state, publishable_key)
+ .find_merchant_account_by_publishable_key(publishable_key)
.await
}
#[cfg(feature = "olap")]
async fn list_merchant_accounts_by_organization_id(
&self,
- state: &KeyManagerState,
organization_id: &id_type::OrganizationId,
) -> CustomResult<Vec<domain::MerchantAccount>, errors::StorageError> {
self.diesel_store
- .list_merchant_accounts_by_organization_id(state, organization_id)
+ .list_merchant_accounts_by_organization_id(organization_id)
.await
}
@@ -1167,24 +1096,22 @@ impl MerchantAccountInterface for KafkaStore {
#[cfg(feature = "olap")]
async fn list_multiple_merchant_accounts(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<id_type::MerchantId>,
) -> CustomResult<Vec<domain::MerchantAccount>, errors::StorageError> {
self.diesel_store
- .list_multiple_merchant_accounts(state, merchant_ids)
+ .list_multiple_merchant_accounts(merchant_ids)
.await
}
#[cfg(feature = "olap")]
async fn list_merchant_and_org_ids(
&self,
- state: &KeyManagerState,
limit: u32,
offset: Option<u32>,
) -> CustomResult<Vec<(id_type::MerchantId, id_type::OrganizationId)>, errors::StorageError>
{
self.diesel_store
- .list_merchant_and_org_ids(state, limit, offset)
+ .list_merchant_and_org_ids(limit, offset)
.await
}
}
@@ -1270,14 +1197,12 @@ impl MerchantConnectorAccountInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_merchant_id_connector_label(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
connector: &str,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
self.diesel_store
.find_merchant_connector_account_by_merchant_id_connector_label(
- state,
merchant_id,
connector,
key_store,
@@ -1288,14 +1213,12 @@ impl MerchantConnectorAccountInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_merchant_id_connector_name(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
connector_name: &str,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {
self.diesel_store
.find_merchant_connector_account_by_merchant_id_connector_name(
- state,
merchant_id,
connector_name,
key_store,
@@ -1306,14 +1229,12 @@ impl MerchantConnectorAccountInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_profile_id_connector_name(
&self,
- state: &KeyManagerState,
profile_id: &id_type::ProfileId,
connector_name: &str,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
self.diesel_store
.find_merchant_connector_account_by_profile_id_connector_name(
- state,
profile_id,
connector_name,
key_store,
@@ -1323,43 +1244,34 @@ impl MerchantConnectorAccountInterface for KafkaStore {
async fn list_enabled_connector_accounts_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &id_type::ProfileId,
key_store: &domain::MerchantKeyStore,
connector_type: common_enums::ConnectorType,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {
self.diesel_store
- .list_enabled_connector_accounts_by_profile_id(
- state,
- profile_id,
- key_store,
- connector_type,
- )
+ .list_enabled_connector_accounts_by_profile_id(profile_id, key_store, connector_type)
.await
}
async fn insert_merchant_connector_account(
&self,
- state: &KeyManagerState,
t: domain::MerchantConnectorAccount,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
self.diesel_store
- .insert_merchant_connector_account(state, t, key_store)
+ .insert_merchant_connector_account(t, key_store)
.await
}
#[cfg(feature = "v1")]
async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
merchant_connector_id: &id_type::MerchantConnectorAccountId,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
self.diesel_store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- state,
merchant_id,
merchant_connector_id,
key_store,
@@ -1370,25 +1282,22 @@ impl MerchantConnectorAccountInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_merchant_connector_account_by_id(
&self,
- state: &KeyManagerState,
id: &id_type::MerchantConnectorAccountId,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
self.diesel_store
- .find_merchant_connector_account_by_id(state, id, key_store)
+ .find_merchant_connector_account_by_id(id, key_store)
.await
}
async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
get_disabled: bool,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccounts, errors::StorageError> {
self.diesel_store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- state,
merchant_id,
get_disabled,
key_store,
@@ -1399,24 +1308,22 @@ impl MerchantConnectorAccountInterface for KafkaStore {
#[cfg(all(feature = "olap", feature = "v2"))]
async fn list_connector_account_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &id_type::ProfileId,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {
self.diesel_store
- .list_connector_account_by_profile_id(state, profile_id, key_store)
+ .list_connector_account_by_profile_id(profile_id, key_store)
.await
}
async fn update_merchant_connector_account(
&self,
- state: &KeyManagerState,
this: domain::MerchantConnectorAccount,
merchant_connector_account: storage::MerchantConnectorAccountUpdateInternal,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
self.diesel_store
- .update_merchant_connector_account(state, this, merchant_connector_account, key_store)
+ .update_merchant_connector_account(this, merchant_connector_account, key_store)
.await
}
@@ -1529,19 +1436,13 @@ impl PaymentAttemptInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn insert_payment_attempt(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
payment_attempt: storage::PaymentAttempt,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::PaymentAttempt, errors::StorageError> {
let attempt = self
.diesel_store
- .insert_payment_attempt(
- key_manager_state,
- merchant_key_store,
- payment_attempt,
- storage_scheme,
- )
+ .insert_payment_attempt(merchant_key_store, payment_attempt, storage_scheme)
.await?;
if let Err(er) = self
@@ -1588,7 +1489,6 @@ impl PaymentAttemptInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn update_payment_attempt(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
this: storage::PaymentAttempt,
payment_attempt: storage::PaymentAttemptUpdate,
@@ -1597,7 +1497,6 @@ impl PaymentAttemptInterface for KafkaStore {
let attempt = self
.diesel_store
.update_payment_attempt(
- key_manager_state,
merchant_key_store,
this.clone(),
payment_attempt,
@@ -1653,7 +1552,6 @@ impl PaymentAttemptInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_profile_id_connector_transaction_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_id: &id_type::ProfileId,
connector_transaction_id: &str,
@@ -1661,7 +1559,6 @@ impl PaymentAttemptInterface for KafkaStore {
) -> CustomResult<storage::PaymentAttempt, errors::StorageError> {
self.diesel_store
.find_payment_attempt_by_profile_id_connector_transaction_id(
- key_manager_state,
merchant_key_store,
profile_id,
connector_transaction_id,
@@ -1703,32 +1600,24 @@ impl PaymentAttemptInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
attempt_id: &id_type::GlobalAttemptId,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<storage::PaymentAttempt, errors::StorageError> {
self.diesel_store
- .find_payment_attempt_by_id(
- key_manager_state,
- merchant_key_store,
- attempt_id,
- storage_scheme,
- )
+ .find_payment_attempt_by_id(merchant_key_store, attempt_id, storage_scheme)
.await
}
#[cfg(feature = "v2")]
async fn find_payment_attempts_by_payment_intent_id(
&self,
- key_manager_state: &KeyManagerState,
payment_id: &id_type::GlobalPaymentId,
merchant_key_store: &domain::MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<Vec<storage::PaymentAttempt>, errors::StorageError> {
self.diesel_store
.find_payment_attempts_by_payment_intent_id(
- key_manager_state,
payment_id,
merchant_key_store,
storage_scheme,
@@ -1771,14 +1660,12 @@ impl PaymentAttemptInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
payment_id: &id_type::GlobalPaymentId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::PaymentAttempt, errors::StorageError> {
self.diesel_store
.find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
- key_manager_state,
merchant_key_store,
payment_id,
storage_scheme,
@@ -1893,7 +1780,6 @@ impl PaymentIntentInterface for KafkaStore {
type Error = errors::StorageError;
async fn update_payment_intent(
&self,
- state: &KeyManagerState,
this: storage::PaymentIntent,
payment_intent: storage::PaymentIntentUpdate,
key_store: &domain::MerchantKeyStore,
@@ -1902,14 +1788,16 @@ impl PaymentIntentInterface for KafkaStore {
let intent = self
.diesel_store
.update_payment_intent(
- state,
this.clone(),
payment_intent.clone(),
key_store,
storage_scheme,
)
.await?;
-
+ let state = self
+ .diesel_store
+ .get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?;
if let Err(er) = self
.kafka_producer
.log_payment_intent(
@@ -1928,15 +1816,18 @@ impl PaymentIntentInterface for KafkaStore {
async fn insert_payment_intent(
&self,
- state: &KeyManagerState,
new: storage::PaymentIntent,
key_store: &domain::MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::PaymentIntent, errors::StorageError> {
logger::debug!("Inserting PaymentIntent Via KafkaStore");
+ let state = self
+ .diesel_store
+ .get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?;
let intent = self
.diesel_store
- .insert_payment_intent(state, new, key_store, storage_scheme)
+ .insert_payment_intent(new, key_store, storage_scheme)
.await?;
if let Err(er) = self
@@ -1958,7 +1849,6 @@ impl PaymentIntentInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
- state: &KeyManagerState,
payment_id: &id_type::PaymentId,
merchant_id: &id_type::MerchantId,
key_store: &domain::MerchantKeyStore,
@@ -1966,7 +1856,6 @@ impl PaymentIntentInterface for KafkaStore {
) -> CustomResult<storage::PaymentIntent, errors::StorageError> {
self.diesel_store
.find_payment_intent_by_payment_id_merchant_id(
- state,
payment_id,
merchant_id,
key_store,
@@ -1978,40 +1867,31 @@ impl PaymentIntentInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_payment_intent_by_id(
&self,
- state: &KeyManagerState,
payment_id: &id_type::GlobalPaymentId,
key_store: &domain::MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::PaymentIntent, errors::StorageError> {
self.diesel_store
- .find_payment_intent_by_id(state, payment_id, key_store, storage_scheme)
+ .find_payment_intent_by_id(payment_id, key_store, storage_scheme)
.await
}
#[cfg(all(feature = "olap", feature = "v1"))]
async fn filter_payment_intent_by_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
filters: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
key_store: &domain::MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::PaymentIntent>, errors::StorageError> {
self.diesel_store
- .filter_payment_intent_by_constraints(
- state,
- merchant_id,
- filters,
- key_store,
- storage_scheme,
- )
+ .filter_payment_intent_by_constraints(merchant_id, filters, key_store, storage_scheme)
.await
}
#[cfg(all(feature = "olap", feature = "v1"))]
async fn filter_payment_intents_by_time_range_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
time_range: &common_utils::types::TimeRange,
key_store: &domain::MerchantKeyStore,
@@ -2019,7 +1899,6 @@ impl PaymentIntentInterface for KafkaStore {
) -> CustomResult<Vec<storage::PaymentIntent>, errors::StorageError> {
self.diesel_store
.filter_payment_intents_by_time_range_constraints(
- state,
merchant_id,
time_range,
key_store,
@@ -2042,7 +1921,6 @@ impl PaymentIntentInterface for KafkaStore {
#[cfg(all(feature = "olap", feature = "v1"))]
async fn get_filtered_payment_intents_attempt(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
key_store: &domain::MerchantKeyStore,
@@ -2056,7 +1934,6 @@ impl PaymentIntentInterface for KafkaStore {
> {
self.diesel_store
.get_filtered_payment_intents_attempt(
- state,
merchant_id,
constraints,
key_store,
@@ -2068,7 +1945,6 @@ impl PaymentIntentInterface for KafkaStore {
#[cfg(all(feature = "olap", feature = "v2"))]
async fn get_filtered_payment_intents_attempt(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
key_store: &domain::MerchantKeyStore,
@@ -2082,7 +1958,6 @@ impl PaymentIntentInterface for KafkaStore {
> {
self.diesel_store
.get_filtered_payment_intents_attempt(
- state,
merchant_id,
constraints,
key_store,
@@ -2110,7 +1985,6 @@ impl PaymentIntentInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_payment_intent_by_merchant_reference_id_profile_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &id_type::PaymentReferenceId,
profile_id: &id_type::ProfileId,
merchant_key_store: &domain::MerchantKeyStore,
@@ -2119,7 +1993,6 @@ impl PaymentIntentInterface for KafkaStore {
{
self.diesel_store
.find_payment_intent_by_merchant_reference_id_profile_id(
- state,
merchant_reference_id,
profile_id,
merchant_key_store,
@@ -2150,33 +2023,30 @@ impl PaymentMethodInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn find_payment_method(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
payment_method_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::PaymentMethod, errors::StorageError> {
self.diesel_store
- .find_payment_method(state, key_store, payment_method_id, storage_scheme)
+ .find_payment_method(key_store, payment_method_id, storage_scheme)
.await
}
#[cfg(feature = "v2")]
async fn find_payment_method(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
payment_method_id: &id_type::GlobalPaymentMethodId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::PaymentMethod, errors::StorageError> {
self.diesel_store
- .find_payment_method(state, key_store, payment_method_id, storage_scheme)
+ .find_payment_method(key_store, payment_method_id, storage_scheme)
.await
}
#[cfg(feature = "v1")]
async fn find_payment_method_by_customer_id_merchant_id_list(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -2184,7 +2054,6 @@ impl PaymentMethodInterface for KafkaStore {
) -> CustomResult<Vec<domain::PaymentMethod>, errors::StorageError> {
self.diesel_store
.find_payment_method_by_customer_id_merchant_id_list(
- state,
key_store,
customer_id,
merchant_id,
@@ -2196,20 +2065,18 @@ impl PaymentMethodInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_payment_method_list_by_global_customer_id(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
id: &id_type::GlobalCustomerId,
limit: Option<i64>,
) -> CustomResult<Vec<domain::PaymentMethod>, errors::StorageError> {
self.diesel_store
- .find_payment_method_list_by_global_customer_id(state, key_store, id, limit)
+ .find_payment_method_list_by_global_customer_id(key_store, id, limit)
.await
}
#[cfg(feature = "v1")]
async fn find_payment_method_by_customer_id_merchant_id_status(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -2219,7 +2086,6 @@ impl PaymentMethodInterface for KafkaStore {
) -> CustomResult<Vec<domain::PaymentMethod>, errors::StorageError> {
self.diesel_store
.find_payment_method_by_customer_id_merchant_id_status(
- state,
key_store,
customer_id,
merchant_id,
@@ -2233,7 +2099,6 @@ impl PaymentMethodInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn find_payment_method_by_global_customer_id_merchant_id_status(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
customer_id: &id_type::GlobalCustomerId,
merchant_id: &id_type::MerchantId,
@@ -2243,7 +2108,6 @@ impl PaymentMethodInterface for KafkaStore {
) -> CustomResult<Vec<domain::PaymentMethod>, errors::StorageError> {
self.diesel_store
.find_payment_method_by_global_customer_id_merchant_id_status(
- state,
key_store,
customer_id,
merchant_id,
@@ -2283,31 +2147,28 @@ impl PaymentMethodInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn find_payment_method_by_locker_id(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
locker_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::PaymentMethod, errors::StorageError> {
self.diesel_store
- .find_payment_method_by_locker_id(state, key_store, locker_id, storage_scheme)
+ .find_payment_method_by_locker_id(key_store, locker_id, storage_scheme)
.await
}
async fn insert_payment_method(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
m: domain::PaymentMethod,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::PaymentMethod, errors::StorageError> {
self.diesel_store
- .insert_payment_method(state, key_store, m, storage_scheme)
+ .insert_payment_method(key_store, m, storage_scheme)
.await
}
async fn update_payment_method(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
payment_method: domain::PaymentMethod,
payment_method_update: storage::PaymentMethodUpdate,
@@ -2315,7 +2176,6 @@ impl PaymentMethodInterface for KafkaStore {
) -> CustomResult<domain::PaymentMethod, errors::StorageError> {
self.diesel_store
.update_payment_method(
- state,
key_store,
payment_method,
payment_method_update,
@@ -2327,14 +2187,12 @@ impl PaymentMethodInterface for KafkaStore {
#[cfg(feature = "v1")]
async fn delete_payment_method_by_merchant_id_payment_method_id(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
payment_method_id: &str,
) -> CustomResult<domain::PaymentMethod, errors::StorageError> {
self.diesel_store
.delete_payment_method_by_merchant_id_payment_method_id(
- state,
key_store,
merchant_id,
payment_method_id,
@@ -2345,24 +2203,22 @@ impl PaymentMethodInterface for KafkaStore {
#[cfg(feature = "v2")]
async fn delete_payment_method(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
payment_method: domain::PaymentMethod,
) -> CustomResult<domain::PaymentMethod, errors::StorageError> {
self.diesel_store
- .delete_payment_method(state, key_store, payment_method)
+ .delete_payment_method(key_store, payment_method)
.await
}
#[cfg(feature = "v2")]
async fn find_payment_method_by_fingerprint_id(
&self,
- state: &KeyManagerState,
key_store: &domain::MerchantKeyStore,
fingerprint_id: &str,
) -> CustomResult<domain::PaymentMethod, errors::StorageError> {
self.diesel_store
- .find_payment_method_by_fingerprint_id(state, key_store, fingerprint_id)
+ .find_payment_method_by_fingerprint_id(key_store, fingerprint_id)
.await
}
}
@@ -2970,23 +2826,21 @@ impl MerchantKeyStoreInterface for KafkaStore {
type Error = errors::StorageError;
async fn insert_merchant_key_store(
&self,
- state: &KeyManagerState,
merchant_key_store: domain::MerchantKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, errors::StorageError> {
self.diesel_store
- .insert_merchant_key_store(state, merchant_key_store, key)
+ .insert_merchant_key_store(merchant_key_store, key)
.await
}
async fn get_merchant_key_store_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, errors::StorageError> {
self.diesel_store
- .get_merchant_key_store_by_merchant_id(state, merchant_id, key)
+ .get_merchant_key_store_by_merchant_id(merchant_id, key)
.await
}
@@ -3002,24 +2856,20 @@ impl MerchantKeyStoreInterface for KafkaStore {
#[cfg(feature = "olap")]
async fn list_multiple_key_stores(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<id_type::MerchantId>,
key: &Secret<Vec<u8>>,
) -> CustomResult<Vec<domain::MerchantKeyStore>, errors::StorageError> {
self.diesel_store
- .list_multiple_key_stores(state, merchant_ids, key)
+ .list_multiple_key_stores(merchant_ids, key)
.await
}
async fn get_all_key_stores(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
from: u32,
to: u32,
) -> CustomResult<Vec<domain::MerchantKeyStore>, errors::StorageError> {
- self.diesel_store
- .get_all_key_stores(state, key, from, to)
- .await
+ self.diesel_store.get_all_key_stores(key, from, to).await
}
}
@@ -3028,36 +2878,32 @@ impl ProfileInterface for KafkaStore {
type Error = errors::StorageError;
async fn insert_business_profile(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
business_profile: domain::Profile,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
- .insert_business_profile(key_manager_state, merchant_key_store, business_profile)
+ .insert_business_profile(merchant_key_store, business_profile)
.await
}
async fn find_business_profile_by_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_id: &id_type::ProfileId,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
- .find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_id)
+ .find_business_profile_by_profile_id(merchant_key_store, profile_id)
.await
}
async fn find_business_profile_by_merchant_id_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
profile_id: &id_type::ProfileId,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
merchant_key_store,
merchant_id,
profile_id,
@@ -3067,14 +2913,12 @@ impl ProfileInterface for KafkaStore {
async fn update_profile_by_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_state: domain::Profile,
business_profile_update: domain::ProfileUpdate,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.update_profile_by_profile_id(
- key_manager_state,
merchant_key_store,
current_state,
business_profile_update,
@@ -3094,25 +2938,22 @@ impl ProfileInterface for KafkaStore {
async fn list_profile_by_merchant_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
) -> CustomResult<Vec<domain::Profile>, errors::StorageError> {
self.diesel_store
- .list_profile_by_merchant_id(key_manager_state, merchant_key_store, merchant_id)
+ .list_profile_by_merchant_id(merchant_key_store, merchant_id)
.await
}
async fn find_business_profile_by_profile_name_merchant_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_name: &str,
merchant_id: &id_type::MerchantId,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.find_business_profile_by_profile_name_merchant_id(
- key_manager_state,
merchant_key_store,
profile_name,
merchant_id,
@@ -3351,6 +3192,9 @@ impl StorageInterface for KafkaStore {
) -> Box<dyn subscriptions::state::SubscriptionStorageInterface> {
Box::new(self.clone())
}
+ fn set_key_manager_state(&mut self, key_manager_state: KeyManagerState) {
+ self.diesel_store.set_key_manager_state(key_manager_state);
+ }
}
impl GlobalStorageInterface for KafkaStore {
@@ -4068,35 +3912,32 @@ impl GenericLinkInterface for KafkaStore {
impl UserKeyStoreInterface for KafkaStore {
async fn insert_user_key_store(
&self,
- state: &KeyManagerState,
user_key_store: domain::UserKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError> {
self.diesel_store
- .insert_user_key_store(state, user_key_store, key)
+ .insert_user_key_store(user_key_store, key)
.await
}
async fn get_user_key_store_by_user_id(
&self,
- state: &KeyManagerState,
user_id: &str,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError> {
self.diesel_store
- .get_user_key_store_by_user_id(state, user_id, key)
+ .get_user_key_store_by_user_id(user_id, key)
.await
}
async fn get_all_user_key_store(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
from: u32,
limit: u32,
) -> CustomResult<Vec<domain::UserKeyStore>, errors::StorageError> {
self.diesel_store
- .get_all_user_key_store(state, key, from, limit)
+ .get_all_user_key_store(key, from, limit)
.await
}
}
@@ -4249,19 +4090,17 @@ impl ThemeInterface for KafkaStore {
impl db::payment_method_session::PaymentMethodsSessionInterface for KafkaStore {
async fn insert_payment_methods_session(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodSession,
validity: i64,
) -> CustomResult<(), errors::StorageError> {
self.diesel_store
- .insert_payment_methods_session(state, key_store, payment_methods_session, validity)
+ .insert_payment_methods_session(key_store, payment_methods_session, validity)
.await
}
async fn get_payment_methods_session(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
id: &id_type::GlobalPaymentMethodSessionId,
) -> CustomResult<
@@ -4269,13 +4108,12 @@ impl db::payment_method_session::PaymentMethodsSessionInterface for KafkaStore {
errors::StorageError,
> {
self.diesel_store
- .get_payment_methods_session(state, key_store, id)
+ .get_payment_methods_session(key_store, id)
.await
}
async fn update_payment_method_session(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
id: &id_type::GlobalPaymentMethodSessionId,
payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodsSessionUpdateEnum,
@@ -4285,13 +4123,7 @@ impl db::payment_method_session::PaymentMethodsSessionInterface for KafkaStore {
errors::StorageError,
> {
self.diesel_store
- .update_payment_method_session(
- state,
- key_store,
- id,
- payment_methods_session,
- current_session,
- )
+ .update_payment_method_session(key_store, id, payment_methods_session, current_session)
.await
}
}
@@ -4328,11 +4160,10 @@ impl TokenizationInterface for KafkaStore {
&self,
tokenization: hyperswitch_domain_models::tokenization::Tokenization,
merchant_key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
self.diesel_store
- .insert_tokenization(tokenization, merchant_key_store, key_manager_state)
+ .insert_tokenization(tokenization, merchant_key_store)
.await
}
@@ -4340,11 +4171,10 @@ impl TokenizationInterface for KafkaStore {
&self,
token: &id_type::GlobalTokenId,
merchant_key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
self.diesel_store
- .get_entity_id_vault_id_by_token_id(token, merchant_key_store, key_manager_state)
+ .get_entity_id_vault_id_by_token_id(token, merchant_key_store)
.await
}
@@ -4353,16 +4183,10 @@ impl TokenizationInterface for KafkaStore {
tokenization: hyperswitch_domain_models::tokenization::Tokenization,
tokenization_update: hyperswitch_domain_models::tokenization::TokenizationUpdate,
merchant_key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
self.diesel_store
- .update_tokenization_record(
- tokenization,
- tokenization_update,
- merchant_key_store,
- key_manager_state,
- )
+ .update_tokenization_record(tokenization, tokenization_update, merchant_key_store)
.await
}
}
@@ -4377,63 +4201,57 @@ impl InvoiceInterface for KafkaStore {
#[instrument(skip_all)]
async fn insert_invoice_entry(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
invoice_new: DomainInvoice,
) -> CustomResult<DomainInvoice, errors::StorageError> {
self.diesel_store
- .insert_invoice_entry(state, key_store, invoice_new)
+ .insert_invoice_entry(key_store, invoice_new)
.await
}
#[instrument(skip_all)]
async fn find_invoice_by_invoice_id(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
invoice_id: String,
) -> CustomResult<DomainInvoice, errors::StorageError> {
self.diesel_store
- .find_invoice_by_invoice_id(state, key_store, invoice_id)
+ .find_invoice_by_invoice_id(key_store, invoice_id)
.await
}
#[instrument(skip_all)]
async fn update_invoice_entry(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
invoice_id: String,
data: DomainInvoiceUpdate,
) -> CustomResult<DomainInvoice, errors::StorageError> {
self.diesel_store
- .update_invoice_entry(state, key_store, invoice_id, data)
+ .update_invoice_entry(key_store, invoice_id, data)
.await
}
#[instrument(skip_all)]
async fn get_latest_invoice_for_subscription(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
subscription_id: String,
) -> CustomResult<DomainInvoice, errors::StorageError> {
self.diesel_store
- .get_latest_invoice_for_subscription(state, key_store, subscription_id)
+ .get_latest_invoice_for_subscription(key_store, subscription_id)
.await
}
#[instrument(skip_all)]
async fn find_invoice_by_subscription_id_connector_invoice_id(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
subscription_id: String,
connector_invoice_id: id_type::InvoiceId,
) -> CustomResult<Option<DomainInvoice>, errors::StorageError> {
self.diesel_store
.find_invoice_by_subscription_id_connector_invoice_id(
- state,
key_store,
subscription_id,
connector_invoice_id,
@@ -4449,39 +4267,36 @@ impl SubscriptionInterface for KafkaStore {
#[instrument(skip_all)]
async fn insert_subscription_entry(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
subscription_new: DomainSubscription,
) -> CustomResult<DomainSubscription, errors::StorageError> {
self.diesel_store
- .insert_subscription_entry(state, key_store, subscription_new)
+ .insert_subscription_entry(key_store, subscription_new)
.await
}
#[instrument(skip_all)]
async fn find_by_merchant_id_subscription_id(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
subscription_id: String,
) -> CustomResult<DomainSubscription, errors::StorageError> {
self.diesel_store
- .find_by_merchant_id_subscription_id(state, key_store, merchant_id, subscription_id)
+ .find_by_merchant_id_subscription_id(key_store, merchant_id, subscription_id)
.await
}
#[instrument(skip_all)]
async fn update_subscription_entry(
&self,
- state: &KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
subscription_id: String,
data: DomainSubscriptionUpdate,
) -> CustomResult<DomainSubscription, errors::StorageError> {
self.diesel_store
- .update_subscription_entry(state, key_store, merchant_id, subscription_id, data)
+ .update_subscription_entry(key_store, merchant_id, subscription_id, data)
.await
}
}
diff --git a/crates/router/src/db/locker_mock_up.rs b/crates/router/src/db/locker_mock_up.rs
index c4a8b353fe..6f8afb74a9 100644
--- a/crates/router/src/db/locker_mock_up.rs
+++ b/crates/router/src/db/locker_mock_up.rs
@@ -128,7 +128,9 @@ impl LockerMockUpInterface for MockDb {
#[cfg(test)]
mod tests {
mod mockdb_locker_mock_up_interface {
- use common_utils::{generate_customer_id_of_default_length, id_type};
+ use common_utils::{
+ generate_customer_id_of_default_length, id_type, types::keymanager::KeyManagerState,
+ };
use crate::{
db::{locker_mock_up::LockerMockUpInterface, MockDb},
@@ -163,9 +165,12 @@ mod tests {
#[tokio::test]
async fn find_locker_by_card_id() {
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let created_locker = mockdb
.insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds {
@@ -193,9 +198,12 @@ mod tests {
#[tokio::test]
async fn insert_locker_mock_up() {
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let created_locker = mockdb
.insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds {
@@ -222,9 +230,12 @@ mod tests {
#[tokio::test]
async fn delete_locker_mock_up() {
- let mockdb = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let mockdb = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let created_locker = mockdb
.insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds {
diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rs
index 16915f4251..887d85eec1 100644
--- a/crates/router/src/db/merchant_connector_account.rs
+++ b/crates/router/src/db/merchant_connector_account.rs
@@ -107,7 +107,10 @@ mod merchant_connector_account_cache_tests {
#[cfg(feature = "v1")]
use api_models::enums::CountryAlpha2;
- use common_utils::{date_time, type_name, types::keymanager::Identifier};
+ use common_utils::{
+ date_time, type_name,
+ types::keymanager::{Identifier, KeyManagerState},
+ };
use diesel_models::enums::ConnectorType;
use error_stack::ResultExt;
use hyperswitch_domain_models::master_key::MasterKeyInterface;
@@ -158,9 +161,12 @@ mod merchant_connector_account_cache_tests {
|| {},
)
.unwrap();
- let db = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let db = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let redis_conn = db.get_redis_conn().unwrap();
let master_key = db.get_master_key();
@@ -180,7 +186,6 @@ mod merchant_connector_account_cache_tests {
.unwrap();
let key_manager_state = &state.into();
db.insert_merchant_key_store(
- key_manager_state,
domain::MerchantKeyStore {
merchant_id: merchant_id.clone(),
key: domain::types::crypto_operation(
@@ -203,11 +208,7 @@ mod merchant_connector_account_cache_tests {
.unwrap();
let merchant_key = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &master_key.to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &master_key.to_vec().into())
.await
.unwrap();
@@ -261,14 +262,13 @@ mod merchant_connector_account_cache_tests {
version: common_types::consts::API_VERSION,
};
- db.insert_merchant_connector_account(key_manager_state, mca.clone(), &merchant_key)
+ db.insert_merchant_connector_account(mca.clone(), &merchant_key)
.await
.unwrap();
let find_call = || async {
Conversion::convert(
db.find_merchant_connector_account_by_profile_id_connector_name(
- key_manager_state,
&profile_id,
&mca.connector_name,
&merchant_key,
@@ -342,9 +342,12 @@ mod merchant_connector_account_cache_tests {
|| {},
)
.unwrap();
- let db = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create Mock store");
+ let db = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create Mock store");
let redis_conn = db.get_redis_conn().unwrap();
let master_key = db.get_master_key();
@@ -363,7 +366,6 @@ mod merchant_connector_account_cache_tests {
.unwrap();
let key_manager_state = &state.into();
db.insert_merchant_key_store(
- key_manager_state,
domain::MerchantKeyStore {
merchant_id: merchant_id.clone(),
key: domain::types::crypto_operation(
@@ -386,11 +388,7 @@ mod merchant_connector_account_cache_tests {
.unwrap();
let merchant_key = db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &master_key.to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &master_key.to_vec().into())
.await
.unwrap();
@@ -438,7 +436,7 @@ mod merchant_connector_account_cache_tests {
feature_metadata: None,
};
- db.insert_merchant_connector_account(key_manager_state, mca.clone(), &merchant_key)
+ db.insert_merchant_connector_account(mca.clone(), &merchant_key)
.await
.unwrap();
@@ -446,7 +444,6 @@ mod merchant_connector_account_cache_tests {
#[cfg(feature = "v1")]
let mca = db
.find_merchant_connector_account_by_profile_id_connector_name(
- key_manager_state,
profile_id,
&mca.connector_name,
&merchant_key,
diff --git a/crates/router/src/db/merchant_key_store.rs b/crates/router/src/db/merchant_key_store.rs
index b5af8d1b1a..2f28313fb2 100644
--- a/crates/router/src/db/merchant_key_store.rs
+++ b/crates/router/src/db/merchant_key_store.rs
@@ -4,7 +4,10 @@ pub use hyperswitch_domain_models::merchant_key_store::{self, MerchantKeyStoreIn
mod tests {
use std::{borrow::Cow, sync::Arc};
- use common_utils::{type_name, types::keymanager::Identifier};
+ use common_utils::{
+ type_name,
+ types::keymanager::{Identifier, KeyManagerState},
+ };
use hyperswitch_domain_models::master_key::MasterKeyInterface;
use time::macros::datetime;
use tokio::sync::oneshot;
@@ -37,9 +40,12 @@ mod tests {
|| {},
)
.unwrap();
- let mock_db = MockDb::new(&redis_interface::RedisSettings::default())
- .await
- .expect("Failed to create mock DB");
+ let mock_db = MockDb::new(
+ &redis_interface::RedisSettings::default(),
+ KeyManagerState::new(),
+ )
+ .await
+ .expect("Failed to create mock DB");
let master_key = mock_db.get_master_key();
let merchant_id =
common_utils::id_type::MerchantId::try_from(Cow::from("merchant1")).unwrap();
@@ -47,7 +53,6 @@ mod tests {
let key_manager_state = &state.into();
let merchant_key1 = mock_db
.insert_merchant_key_store(
- key_manager_state,
domain::MerchantKeyStore {
merchant_id: merchant_id.clone(),
key: domain::types::crypto_operation(
@@ -70,11 +75,7 @@ mod tests {
.unwrap();
let found_merchant_key1 = mock_db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &master_key.to_vec().into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &master_key.to_vec().into())
.await
.unwrap();
@@ -83,7 +84,6 @@ mod tests {
let insert_duplicate_merchant_key1_result = mock_db
.insert_merchant_key_store(
- key_manager_state,
domain::MerchantKeyStore {
merchant_id: merchant_id.clone(),
key: domain::types::crypto_operation(
@@ -110,7 +110,6 @@ mod tests {
let find_non_existent_merchant_key_result = mock_db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&non_existent_merchant_id,
&master_key.to_vec().into(),
)
@@ -118,11 +117,7 @@ mod tests {
assert!(find_non_existent_merchant_key_result.is_err());
let find_merchant_key_with_incorrect_master_key_result = mock_db
- .get_merchant_key_store_by_merchant_id(
- key_manager_state,
- &merchant_id,
- &vec![0; 32].into(),
- )
+ .get_merchant_key_store_by_merchant_id(&merchant_id, &vec![0; 32].into())
.await;
assert!(find_merchant_key_with_incorrect_master_key_result.is_err());
}
diff --git a/crates/router/src/db/payment_method_session.rs b/crates/router/src/db/payment_method_session.rs
index 5dd00e3690..e2a8c21a5d 100644
--- a/crates/router/src/db/payment_method_session.rs
+++ b/crates/router/src/db/payment_method_session.rs
@@ -7,7 +7,6 @@ use crate::db::MockDb;
pub trait PaymentMethodsSessionInterface {
async fn insert_payment_methods_session(
&self,
- state: &common_utils::types::keymanager::KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodSession,
validity: i64,
@@ -15,7 +14,6 @@ pub trait PaymentMethodsSessionInterface {
async fn update_payment_method_session(
&self,
- state: &common_utils::types::keymanager::KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
id: &common_utils::id_type::GlobalPaymentMethodSessionId,
payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodsSessionUpdateEnum,
@@ -27,7 +25,6 @@ pub trait PaymentMethodsSessionInterface {
async fn get_payment_methods_session(
&self,
- state: &common_utils::types::keymanager::KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
id: &common_utils::id_type::GlobalPaymentMethodSessionId,
) -> CustomResult<
@@ -60,7 +57,6 @@ mod storage {
#[instrument(skip_all)]
async fn insert_payment_methods_session(
&self,
- _state: &common_utils::types::keymanager::KeyManagerState,
_key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodSession,
validity_in_seconds: i64,
@@ -86,7 +82,6 @@ mod storage {
#[instrument(skip_all)]
async fn get_payment_methods_session(
&self,
- state: &common_utils::types::keymanager::KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
id: &common_utils::id_type::GlobalPaymentMethodSessionId,
) -> CustomResult<
@@ -109,7 +104,12 @@ mod storage {
);
db_model
- .convert(state, &key_store.key, key_manager_identifier)
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ &key_store.key,
+ key_manager_identifier,
+ )
.await
.change_context(errors::StorageError::DecryptionError)
.attach_printable("Failed to decrypt payment methods session")
@@ -118,7 +118,6 @@ mod storage {
#[instrument(skip_all)]
async fn update_payment_method_session(
&self,
- state: &common_utils::types::keymanager::KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
session_id: &common_utils::id_type::GlobalPaymentMethodSessionId,
update_request: hyperswitch_domain_models::payment_methods::PaymentMethodsSessionUpdateEnum,
@@ -153,7 +152,12 @@ mod storage {
);
db_model
- .convert(state, &key_store.key, key_manager_identifier)
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ &key_store.key,
+ key_manager_identifier,
+ )
.await
.change_context(errors::StorageError::DecryptionError)
.attach_printable("Failed to decrypt payment methods session")
@@ -165,7 +169,6 @@ mod storage {
impl PaymentMethodsSessionInterface for MockDb {
async fn insert_payment_methods_session(
&self,
- state: &common_utils::types::keymanager::KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodSession,
validity_in_seconds: i64,
@@ -175,7 +178,6 @@ impl PaymentMethodsSessionInterface for MockDb {
async fn update_payment_method_session(
&self,
- state: &common_utils::types::keymanager::KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
id: &common_utils::id_type::GlobalPaymentMethodSessionId,
payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodsSessionUpdateEnum,
@@ -190,7 +192,6 @@ impl PaymentMethodsSessionInterface for MockDb {
#[cfg(feature = "v2")]
async fn get_payment_methods_session(
&self,
- state: &common_utils::types::keymanager::KeyManagerState,
key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
id: &common_utils::id_type::GlobalPaymentMethodSessionId,
) -> CustomResult<
diff --git a/crates/router/src/db/relay.rs b/crates/router/src/db/relay.rs
index 731db91ea2..0a3d411088 100644
--- a/crates/router/src/db/relay.rs
+++ b/crates/router/src/db/relay.rs
@@ -1,4 +1,4 @@
-use common_utils::types::keymanager::KeyManagerState;
+use diesel_models;
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use storage_impl::MockDb;
@@ -15,14 +15,12 @@ use crate::{
pub trait RelayInterface {
async fn insert_relay(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
new: hyperswitch_domain_models::relay::Relay,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError>;
async fn update_relay(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_state: hyperswitch_domain_models::relay::Relay,
relay_update: hyperswitch_domain_models::relay::RelayUpdate,
@@ -30,14 +28,12 @@ pub trait RelayInterface {
async fn find_relay_by_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
relay_id: &common_utils::id_type::RelayId,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError>;
async fn find_relay_by_profile_id_connector_reference_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
connector_reference_id: &str,
@@ -48,7 +44,6 @@ pub trait RelayInterface {
impl RelayInterface for Store {
async fn insert_relay(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
new: hyperswitch_domain_models::relay::Relay,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
@@ -60,7 +55,8 @@ impl RelayInterface for Store {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -70,7 +66,6 @@ impl RelayInterface for Store {
async fn update_relay(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_state: hyperswitch_domain_models::relay::Relay,
relay_update: hyperswitch_domain_models::relay::RelayUpdate,
@@ -86,7 +81,8 @@ impl RelayInterface for Store {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -96,7 +92,6 @@ impl RelayInterface for Store {
async fn find_relay_by_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
relay_id: &common_utils::id_type::RelayId,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
@@ -105,7 +100,8 @@ impl RelayInterface for Store {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -115,7 +111,6 @@ impl RelayInterface for Store {
async fn find_relay_by_profile_id_connector_reference_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
connector_reference_id: &str,
@@ -129,7 +124,8 @@ impl RelayInterface for Store {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -142,7 +138,6 @@ impl RelayInterface for Store {
impl RelayInterface for MockDb {
async fn insert_relay(
&self,
- _key_manager_state: &KeyManagerState,
_merchant_key_store: &domain::MerchantKeyStore,
_new: hyperswitch_domain_models::relay::Relay,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
@@ -151,7 +146,6 @@ impl RelayInterface for MockDb {
async fn update_relay(
&self,
- _key_manager_state: &KeyManagerState,
_merchant_key_store: &domain::MerchantKeyStore,
_current_state: hyperswitch_domain_models::relay::Relay,
_relay_update: hyperswitch_domain_models::relay::RelayUpdate,
@@ -161,7 +155,6 @@ impl RelayInterface for MockDb {
async fn find_relay_by_id(
&self,
- _key_manager_state: &KeyManagerState,
_merchant_key_store: &domain::MerchantKeyStore,
_relay_id: &common_utils::id_type::RelayId,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
@@ -170,7 +163,6 @@ impl RelayInterface for MockDb {
async fn find_relay_by_profile_id_connector_reference_id(
&self,
- _key_manager_state: &KeyManagerState,
_merchant_key_store: &domain::MerchantKeyStore,
_profile_id: &common_utils::id_type::ProfileId,
_connector_reference_id: &str,
@@ -183,53 +175,43 @@ impl RelayInterface for MockDb {
impl RelayInterface for KafkaStore {
async fn insert_relay(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
new: hyperswitch_domain_models::relay::Relay,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
self.diesel_store
- .insert_relay(key_manager_state, merchant_key_store, new)
+ .insert_relay(merchant_key_store, new)
.await
}
async fn update_relay(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_state: hyperswitch_domain_models::relay::Relay,
relay_update: hyperswitch_domain_models::relay::RelayUpdate,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
self.diesel_store
- .update_relay(
- key_manager_state,
- merchant_key_store,
- current_state,
- relay_update,
- )
+ .update_relay(merchant_key_store, current_state, relay_update)
.await
}
async fn find_relay_by_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
relay_id: &common_utils::id_type::RelayId,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
self.diesel_store
- .find_relay_by_id(key_manager_state, merchant_key_store, relay_id)
+ .find_relay_by_id(merchant_key_store, relay_id)
.await
}
async fn find_relay_by_profile_id_connector_reference_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
connector_reference_id: &str,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
self.diesel_store
.find_relay_by_profile_id_connector_reference_id(
- key_manager_state,
merchant_key_store,
profile_id,
connector_reference_id,
diff --git a/crates/router/src/db/user_key_store.rs b/crates/router/src/db/user_key_store.rs
index 952b2f3ac2..ce90cfa835 100644
--- a/crates/router/src/db/user_key_store.rs
+++ b/crates/router/src/db/user_key_store.rs
@@ -1,7 +1,4 @@
-use common_utils::{
- errors::CustomResult,
- types::keymanager::{self, KeyManagerState},
-};
+use common_utils::{errors::CustomResult, types::keymanager};
use error_stack::{report, ResultExt};
use masking::Secret;
use router_env::{instrument, tracing};
@@ -21,21 +18,18 @@ use crate::{
pub trait UserKeyStoreInterface {
async fn insert_user_key_store(
&self,
- state: &KeyManagerState,
user_key_store: domain::UserKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError>;
async fn get_user_key_store_by_user_id(
&self,
- state: &KeyManagerState,
user_id: &str,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError>;
async fn get_all_user_key_store(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
from: u32,
limit: u32,
@@ -47,7 +41,6 @@ impl UserKeyStoreInterface for Store {
#[instrument(skip_all)]
async fn insert_user_key_store(
&self,
- state: &KeyManagerState,
user_key_store: domain::UserKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError> {
@@ -60,7 +53,12 @@ impl UserKeyStoreInterface for Store {
.insert(&conn)
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
- .convert(state, key, keymanager::Identifier::User(user_id))
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ keymanager::Identifier::User(user_id),
+ )
.await
.change_context(errors::StorageError::DecryptionError)
}
@@ -68,7 +66,6 @@ impl UserKeyStoreInterface for Store {
#[instrument(skip_all)]
async fn get_user_key_store_by_user_id(
&self,
- state: &KeyManagerState,
user_id: &str,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError> {
@@ -77,14 +74,18 @@ impl UserKeyStoreInterface for Store {
diesel_models::user_key_store::UserKeyStore::find_by_user_id(&conn, user_id)
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
- .convert(state, key, keymanager::Identifier::User(user_id.to_owned()))
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ keymanager::Identifier::User(user_id.to_owned()),
+ )
.await
.change_context(errors::StorageError::DecryptionError)
}
async fn get_all_user_key_store(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
from: u32,
limit: u32,
@@ -99,7 +100,12 @@ impl UserKeyStoreInterface for Store {
futures::future::try_join_all(key_stores.into_iter().map(|key_store| async {
let user_id = key_store.user_id.clone();
key_store
- .convert(state, key, keymanager::Identifier::User(user_id))
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ keymanager::Identifier::User(user_id),
+ )
.await
.change_context(errors::StorageError::DecryptionError)
}))
@@ -112,7 +118,6 @@ impl UserKeyStoreInterface for MockDb {
#[instrument(skip_all)]
async fn insert_user_key_store(
&self,
- state: &KeyManagerState,
user_key_store: domain::UserKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError> {
@@ -134,14 +139,18 @@ impl UserKeyStoreInterface for MockDb {
locked_user_key_store.push(user_key_store.clone());
let user_id = user_key_store.user_id.clone();
user_key_store
- .convert(state, key, keymanager::Identifier::User(user_id))
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ keymanager::Identifier::User(user_id),
+ )
.await
.change_context(errors::StorageError::DecryptionError)
}
async fn get_all_user_key_store(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
_from: u32,
_limit: u32,
@@ -152,7 +161,12 @@ impl UserKeyStoreInterface for MockDb {
let user_id = user_key.user_id.clone();
user_key
.to_owned()
- .convert(state, key, keymanager::Identifier::User(user_id))
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ keymanager::Identifier::User(user_id),
+ )
.await
.change_context(errors::StorageError::DecryptionError)
}))
@@ -162,7 +176,6 @@ impl UserKeyStoreInterface for MockDb {
#[instrument(skip_all)]
async fn get_user_key_store_by_user_id(
&self,
- state: &KeyManagerState,
user_id: &str,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError> {
@@ -175,7 +188,12 @@ impl UserKeyStoreInterface for MockDb {
.ok_or(errors::StorageError::ValueNotFound(format!(
"No user_key_store is found for user_id={user_id}",
)))?
- .convert(state, key, keymanager::Identifier::User(user_id.to_owned()))
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ keymanager::Identifier::User(user_id.to_owned()),
+ )
.await
.change_context(errors::StorageError::DecryptionError)
}
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 9fab86eba2..b3faebe6b4 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -8,7 +8,10 @@ use api_models::routing::RuleMigrationQuery;
use common_enums::{ExecutionMode, TransactionType};
#[cfg(feature = "partial-auth")]
use common_utils::crypto::Blake3;
-use common_utils::{id_type, types::TenantConfig};
+use common_utils::{
+ id_type,
+ types::{keymanager::KeyManagerState, TenantConfig},
+};
#[cfg(feature = "email")]
use external_services::email::{
no_email::NoEmailClient, ses::AwsSes, smtp::SmtpServer, EmailClientConfigs, EmailService,
@@ -103,6 +106,7 @@ pub use crate::{
},
events::EventsHandler,
services::{get_cache_store, get_store},
+ types::transformers::ForeignFrom,
};
use crate::{
configs::{secrets_transformers, Settings},
@@ -148,6 +152,9 @@ impl scheduler::SchedulerSessionState for SessionState {
}
}
impl SessionState {
+ pub fn set_store(&mut self, store: Box<dyn StorageInterface>) {
+ self.store = store;
+ }
pub fn get_req_state(&self) -> ReqState {
ReqState {
event_context: events::EventContext::new(self.event_handler.clone()),
@@ -530,14 +537,35 @@ impl AppState {
cache_store: Arc<RedisStore>,
testable: bool,
) -> Box<dyn CommonStorageInterface> {
+ let km_conf = conf.key_manager.get_inner();
+ let key_manager_state = KeyManagerState {
+ global_tenant_id: conf.multitenancy.global_tenant.tenant_id.clone(),
+ tenant_id: tenant.get_tenant_id().clone(),
+ enabled: km_conf.enabled,
+ url: km_conf.url.clone(),
+ client_idle_timeout: conf.proxy.idle_pool_connection_timeout,
+ #[cfg(feature = "km_forward_x_request_id")]
+ request_id: None,
+ #[cfg(feature = "keymanager_mtls")]
+ cert: km_conf.cert.clone(),
+ #[cfg(feature = "keymanager_mtls")]
+ ca: km_conf.ca.clone(),
+ infra_values: Self::process_env_mappings(conf.infra_values.clone()),
+ };
match storage_impl {
StorageImpl::Postgresql | StorageImpl::PostgresqlTest => match event_handler {
EventsHandler::Kafka(kafka_client) => Box::new(
KafkaStore::new(
#[allow(clippy::expect_used)]
- get_store(&conf.clone(), tenant, Arc::clone(&cache_store), testable)
- .await
- .expect("Failed to create store"),
+ get_store(
+ &conf.clone(),
+ tenant,
+ Arc::clone(&cache_store),
+ testable,
+ key_manager_state,
+ )
+ .await
+ .expect("Failed to create store"),
kafka_client.clone(),
TenantID(tenant.get_tenant_id().get_string_repr().to_owned()),
tenant,
@@ -546,14 +574,20 @@ impl AppState {
),
EventsHandler::Logs(_) => Box::new(
#[allow(clippy::expect_used)]
- get_store(conf, tenant, Arc::clone(&cache_store), testable)
- .await
- .expect("Failed to create store"),
+ get_store(
+ conf,
+ tenant,
+ Arc::clone(&cache_store),
+ testable,
+ key_manager_state,
+ )
+ .await
+ .expect("Failed to create store"),
),
},
#[allow(clippy::expect_used)]
StorageImpl::Mock => Box::new(
- MockDb::new(&conf.redis)
+ MockDb::new(&conf.redis, key_manager_state)
.await
.expect("Failed to create mock store"),
),
@@ -586,7 +620,9 @@ impl AppState {
let tenant_conf = self.conf.multitenancy.get_tenant(tenant).ok_or_else(err)?;
let mut event_handler = self.event_handler.clone();
event_handler.add_tenant(tenant_conf);
- let store = self.stores.get(tenant).ok_or_else(err)?.clone();
+ let mut store = self.stores.get(tenant).ok_or_else(err)?.clone();
+ let key_manager_state = KeyManagerState::foreign_from((self.as_ref(), tenant_conf.clone()));
+ store.set_key_manager_state(key_manager_state);
Ok(SessionState {
store,
global_store: self.global_store.clone(),
diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rs
index 3e45e5cca2..ef7f774081 100644
--- a/crates/router/src/routes/payment_methods.rs
+++ b/crates/router/src/routes/payment_methods.rs
@@ -292,11 +292,9 @@ async fn get_merchant_account(
state: &SessionState,
merchant_id: &id_type::MerchantId,
) -> CustomResult<(MerchantKeyStore, domain::MerchantAccount), errors::ApiErrorResponse> {
- let key_manager_state = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -305,7 +303,7 @@ async fn get_merchant_account(
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
Ok((key_store, merchant_account))
@@ -361,7 +359,6 @@ pub async fn migrate_payment_methods(
let mca = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- &(&state).into(),
&merchant_id,
&connector_customer.merchant_connector_id,
platform.get_processor().get_key_store(),
diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs
index c0033f94b9..5d82e8a1e7 100644
--- a/crates/router/src/routes/routing.rs
+++ b/crates/router/src/routes/routing.rs
@@ -1686,11 +1686,9 @@ async fn get_merchant_account(
merchant_id: &common_utils::id_type::MerchantId,
) -> common_utils::errors::CustomResult<(MerchantKeyStore, domain::MerchantAccount), ApiErrorResponse>
{
- let key_manager_state = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -1699,7 +1697,7 @@ async fn get_merchant_account(
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.to_not_found_response(ApiErrorResponse::MerchantAccountNotFound)?;
Ok((key_store, merchant_account))
diff --git a/crates/router/src/services.rs b/crates/router/src/services.rs
index d94ab9b514..8acdecfe1a 100644
--- a/crates/router/src/services.rs
+++ b/crates/router/src/services.rs
@@ -17,7 +17,7 @@ pub mod openidconnect;
use std::sync::Arc;
-use common_utils::types::TenantConfig;
+use common_utils::types::{keymanager, TenantConfig};
use error_stack::ResultExt;
pub use hyperswitch_interfaces::connector_integration_v2::{
BoxedConnectorIntegrationV2, ConnectorIntegrationAnyV2, ConnectorIntegrationV2,
@@ -50,6 +50,7 @@ pub async fn get_store(
tenant: &dyn TenantConfig,
cache_store: Arc<RedisStore>,
test_transaction: bool,
+ key_manager_state: keymanager::KeyManagerState,
) -> StorageResult<Store> {
let master_config = config.master_database.clone().into_inner();
@@ -69,7 +70,14 @@ pub async fn get_store(
let conf = (master_config.into(), replica_config.into());
let store: RouterStore<StoreType> = if test_transaction {
- RouterStore::test_store(conf, tenant, &config.redis, master_enc_key).await?
+ RouterStore::test_store(
+ conf,
+ tenant,
+ &config.redis,
+ master_enc_key,
+ Some(key_manager_state.clone()),
+ )
+ .await?
} else {
RouterStore::from_config(
conf,
@@ -77,6 +85,7 @@ pub async fn get_store(
master_enc_key,
cache_store,
storage_impl::redis::cache::IMC_INVALIDATION_CHANNEL,
+ Some(key_manager_state.clone()),
)
.await?
};
@@ -88,6 +97,7 @@ pub async fn get_store(
config.drainer.num_partitions,
config.kv_config.ttl,
config.kv_config.soft_kill,
+ Some(key_manager_state),
);
Ok(store)
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 747f2d6b22..7677956799 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -494,12 +494,9 @@ where
.attach_printable("API key has expired");
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&stored_api_key.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -509,11 +506,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &stored_api_key.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&stored_api_key.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -543,7 +536,6 @@ where
state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant.get_id(),
&state.store().get_master_key().to_vec().into(),
)
@@ -556,7 +548,7 @@ where
let profile = state
.store()
- .find_business_profile_by_profile_id(key_manager_state, &key_store, &profile_id)
+ .find_business_profile_by_profile_id(&key_store, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -620,12 +612,9 @@ where
.attach_printable("API key has expired");
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&stored_api_key.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -644,11 +633,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &stored_api_key.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&stored_api_key.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -677,7 +662,6 @@ where
state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant.get_id(),
&state.store().get_master_key().to_vec().into(),
)
@@ -812,12 +796,9 @@ where
.attach_printable("API key has expired");
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&stored_api_key.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -827,11 +808,7 @@ where
let merchant_account = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &stored_api_key.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&stored_api_key.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)
.attach_printable("Merchant account not found")?;
@@ -901,12 +878,9 @@ where
.attach_printable("API key has expired");
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&stored_api_key.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -916,11 +890,7 @@ where
let merchant_account = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &stored_api_key.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&stored_api_key.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)
.attach_printable("Merchant account not found")?;
@@ -969,12 +939,9 @@ impl PlatformOrgAdminAuthWithMerchantIdFromRoute {
merchant_id: &id_type::MerchantId,
state: &A,
) -> RouterResult<(domain::MerchantKeyStore, domain::MerchantAccount)> {
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -983,7 +950,7 @@ impl PlatformOrgAdminAuthWithMerchantIdFromRoute {
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -1234,14 +1201,9 @@ where
let profile_id = HeaderMapStruct::new(request_headers)
.get_id_type_from_header::<id_type::ProfileId>(headers::X_PROFILE_ID)?;
- let key_manager_state = &(&state.session_state()).into();
let profile = state
.store()
- .find_business_profile_by_profile_id(
- key_manager_state,
- &auth_data.key_store,
- &profile_id,
- )
+ .find_business_profile_by_profile_id(&auth_data.key_store, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -1268,7 +1230,6 @@ where
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- &(&state.session_state()).into(),
merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -1278,11 +1239,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- &(&state.session_state()).into(),
- merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -1305,7 +1262,6 @@ where
state
.store()
.get_merchant_key_store_by_merchant_id(
- &(&state.session_state()).into(),
merchant.get_id(),
&state.store().get_master_key().to_vec().into(),
)
@@ -1587,11 +1543,9 @@ where
let merchant_id = self.0.clone();
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -1600,7 +1554,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -1641,11 +1595,9 @@ where
let profile_id =
get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?
.get_required_value(headers::X_PROFILE_ID)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -1653,17 +1605,12 @@ where
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let profile = state
.store()
- .find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
- &key_store,
- &merchant_id,
- &profile_id,
- )
+ .find_business_profile_by_merchant_id_profile_id(&key_store, &merchant_id, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -1703,11 +1650,9 @@ where
let merchant_id = self.0.clone();
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -1716,7 +1661,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -1787,12 +1732,9 @@ where
.attach_printable("API key has expired");
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&stored_api_key.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -1802,11 +1744,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &stored_api_key.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&stored_api_key.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -1848,11 +1786,9 @@ impl AdminApiAuthWithApiKeyFallbackAndMerchantIdFromRoute {
merchant_id: &id_type::MerchantId,
state: &A,
) -> RouterResult<(domain::MerchantKeyStore, domain::MerchantAccount)> {
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -1861,7 +1797,7 @@ impl AdminApiAuthWithApiKeyFallbackAndMerchantIdFromRoute {
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2090,11 +2026,9 @@ where
let merchant_id = HeaderMapStruct::new(request_headers)
.get_id_type_from_header::<id_type::MerchantId>(headers::X_MERCHANT_ID)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -2103,7 +2037,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2145,11 +2079,9 @@ where
get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?
.get_required_value(headers::X_PROFILE_ID)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -2157,17 +2089,12 @@ where
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let profile = state
.store()
- .find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
- &key_store,
- &merchant_id,
- &profile_id,
- )
+ .find_business_profile_by_merchant_id_profile_id(&key_store, &merchant_id, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2207,11 +2134,9 @@ where
let merchant_id = HeaderMapStruct::new(request_headers)
.get_id_type_from_header::<id_type::MerchantId>(headers::X_MERCHANT_ID)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -2220,7 +2145,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2282,11 +2207,9 @@ where
throw_error_if_platform_merchant_authentication_required(request_headers)?;
}
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&self.0,
&state.store().get_master_key().to_vec().into(),
)
@@ -2295,7 +2218,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &self.0, &key_store)
+ .find_merchant_account_by_merchant_id(&self.0, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2333,7 +2256,6 @@ where
throw_error_if_platform_merchant_authentication_required(request_headers)?;
}
- let key_manager_state = &(&state.session_state()).into();
let merchant_id = HeaderMapStruct::new(request_headers)
.get_id_type_from_header::<id_type::MerchantId>(headers::X_MERCHANT_ID)?;
let profile_id =
@@ -2342,7 +2264,6 @@ where
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -2351,17 +2272,12 @@ where
let profile = state
.store()
- .find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
- &key_store,
- &merchant_id,
- &profile_id,
- )
+ .find_business_profile_by_merchant_id_profile_id(&key_store, &merchant_id, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2423,11 +2339,9 @@ where
return Err(errors::ApiErrorResponse::Unauthorized)
.attach_printable("Internal API key authentication failed");
}
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -2436,7 +2350,6 @@ where
let _profile = state
.store()
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
&key_store,
&merchant_id,
&profile_id,
@@ -2445,7 +2358,7 @@ where
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let auth = AuthenticationData {
@@ -2492,11 +2405,9 @@ where
throw_error_if_platform_merchant_authentication_required(request_headers)?;
}
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&self.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -2506,7 +2417,6 @@ where
let profile = state
.store()
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
&key_store,
&self.merchant_id,
&self.profile_id,
@@ -2515,7 +2425,7 @@ where
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &self.merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&self.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2552,13 +2462,9 @@ where
_request_headers: &HeaderMap,
state: &A,
) -> RouterResult<(AuthenticationData, AuthenticationType)> {
- let key_manager_state = &(&state.session_state()).into();
let (merchant_account, key_store) = state
.store()
- .find_merchant_account_by_publishable_key(
- key_manager_state,
- self.publishable_key.as_str(),
- )
+ .find_merchant_account_by_publishable_key(self.publishable_key.as_str())
.await
.map_err(|e| {
if e.current_context().is_db_not_found() {
@@ -2570,7 +2476,7 @@ where
let profile = state
.store()
- .find_business_profile_by_profile_id(key_manager_state, &key_store, &self.profile_id)
+ .find_business_profile_by_profile_id(&key_store, &self.profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: self.profile_id.get_string_repr().to_owned(),
@@ -2652,12 +2558,9 @@ where
.attach_printable("API key has expired");
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&stored_api_key.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -2667,11 +2570,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &stored_api_key.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&stored_api_key.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2701,7 +2600,6 @@ where
state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant.get_id(),
&state.store().get_master_key().to_vec().into(),
)
@@ -2714,7 +2612,7 @@ where
let profile = state
.store()
- .find_business_profile_by_profile_id(key_manager_state, &key_store, &profile_id)
+ .find_business_profile_by_profile_id(&key_store, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -2817,7 +2715,7 @@ where
let (merchant_account, key_store) = state
.store()
- .find_merchant_account_by_publishable_key(key_manager_state, publishable_key)
+ .find_merchant_account_by_publishable_key(publishable_key)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant_id = merchant_account.get_id().clone();
@@ -2827,12 +2725,7 @@ where
}
let profile = state
.store()
- .find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
- &key_store,
- &merchant_id,
- &profile_id,
- )
+ .find_business_profile_by_merchant_id_profile_id(&key_store, &merchant_id, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
Ok((
@@ -2913,10 +2806,9 @@ where
let publishable_key =
get_api_key(request_headers).change_context(errors::ApiErrorResponse::Unauthorized)?;
- let key_manager_state = &(&state.session_state()).into();
state
.store()
- .find_merchant_account_by_publishable_key(key_manager_state, publishable_key)
+ .find_merchant_account_by_publishable_key(publishable_key)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)
.map(|(merchant_account, key_store)| {
@@ -2947,25 +2839,19 @@ where
) -> RouterResult<(AuthenticationData, AuthenticationType)> {
let publishable_key =
get_api_key(request_headers).change_context(errors::ApiErrorResponse::Unauthorized)?;
- let key_manager_state = &(&state.session_state()).into();
let profile_id =
get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?
.get_required_value(headers::X_PROFILE_ID)?;
let (merchant_account, key_store) = state
.store()
- .find_merchant_account_by_publishable_key(key_manager_state, publishable_key)
+ .find_merchant_account_by_publishable_key(publishable_key)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant_id = merchant_account.get_id().clone();
let profile = state
.store()
- .find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
- &key_store,
- &merchant_id,
- &profile_id,
- )
+ .find_business_profile_by_merchant_id_profile_id(&key_store, &merchant_id, &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
Ok((
@@ -3081,11 +2967,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3095,11 +2979,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.change_context(errors::ApiErrorResponse::InvalidJwtToken)?;
@@ -3276,12 +3156,9 @@ where
return Err(report!(errors::ApiErrorResponse::InvalidJwtToken));
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3291,11 +3168,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -3391,12 +3264,9 @@ where
return Err(report!(errors::ApiErrorResponse::InvalidJwtToken));
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3407,7 +3277,6 @@ where
let profile = state
.store()
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
&key_store,
&payload.merchant_id,
&profile_id,
@@ -3416,11 +3285,7 @@ where
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -3469,12 +3334,9 @@ where
return Err(report!(errors::ApiErrorResponse::InvalidJwtToken));
}
- let key_manager_state = &(&state.session_state()).into();
-
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3484,11 +3346,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -3571,11 +3429,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.required_permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3585,11 +3441,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -3636,11 +3488,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.required_permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3650,7 +3500,6 @@ where
let profile = state
.store()
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
&key_store,
&payload.merchant_id,
&profile_id,
@@ -3659,11 +3508,7 @@ where
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -3708,11 +3553,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.required_permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3722,11 +3565,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -3782,11 +3621,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.required_permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3796,11 +3633,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -3850,11 +3683,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.required_permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3864,11 +3695,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -3916,11 +3743,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.required_permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -3931,7 +3756,6 @@ where
let profile = state
.store()
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
&key_store,
&payload.merchant_id,
&profile_id,
@@ -3940,11 +3764,7 @@ where
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -4017,11 +3837,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -4031,11 +3849,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -4082,11 +3896,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -4097,7 +3909,6 @@ where
let profile = state
.store()
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
&key_store,
&payload.merchant_id,
&profile_id,
@@ -4106,11 +3917,7 @@ where
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -4156,11 +3963,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -4170,11 +3975,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.change_context(errors::ApiErrorResponse::InvalidJwtToken)?;
@@ -4275,11 +4076,9 @@ where
&state.session_state().tenant.tenant_id,
)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -4289,11 +4088,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;
@@ -4738,11 +4533,9 @@ where
let role_info = authorization::get_role_info(state, &payload).await?;
authorization::check_permission(self.permission, &role_info)?;
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&payload.merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -4752,11 +4545,7 @@ where
let merchant = state
.store()
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &payload.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&payload.merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
@@ -4795,11 +4584,9 @@ async fn get_connected_merchant_account<A>(
where
A: SessionStateInfo + Sync,
{
- let key_manager_state = &(&state.session_state()).into();
let key_store = state
.store()
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&connected_merchant_id,
&state.store().get_master_key().to_vec().into(),
)
@@ -4809,7 +4596,7 @@ where
let connected_merchant_account = state
.store()
- .find_merchant_account_by_merchant_id(key_manager_state, &connected_merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&connected_merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::InvalidPlatformOperation)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
diff --git a/crates/router/src/types/api/mandates.rs b/crates/router/src/types/api/mandates.rs
index 0850c1cc75..582cdce53b 100644
--- a/crates/router/src/types/api/mandates.rs
+++ b/crates/router/src/types/api/mandates.rs
@@ -45,7 +45,6 @@ impl MandateResponseExt for MandateResponse {
let db = &*state.store;
let payment_method = db
.find_payment_method(
- &(state.into()),
&key_store,
&mandate.payment_method_id,
merchant_account.storage_scheme,
diff --git a/crates/router/src/types/domain/types.rs b/crates/router/src/types/domain/types.rs
index 6488a061bd..7d5611f83e 100644
--- a/crates/router/src/types/domain/types.rs
+++ b/crates/router/src/types/domain/types.rs
@@ -3,9 +3,32 @@ use common_utils::types::keymanager::KeyManagerState;
pub use hyperswitch_domain_models::type_encryption::{
crypto_operation, AsyncLift, CryptoOperation, Lift, OptionalEncryptableJsonType,
};
+use hyperswitch_interfaces::configs;
-use crate::{routes::app, types::api as api_types};
+use crate::{
+ routes::app,
+ types::{api as api_types, ForeignFrom},
+};
+impl ForeignFrom<(&app::AppState, configs::Tenant)> for KeyManagerState {
+ fn foreign_from((app_state, tenant): (&app::AppState, configs::Tenant)) -> Self {
+ let conf = app_state.conf.key_manager.get_inner();
+ Self {
+ global_tenant_id: app_state.conf.multitenancy.global_tenant.tenant_id.clone(),
+ tenant_id: tenant.tenant_id.clone(),
+ enabled: conf.enabled,
+ url: conf.url.clone(),
+ client_idle_timeout: app_state.conf.proxy.idle_pool_connection_timeout,
+ #[cfg(feature = "km_forward_x_request_id")]
+ request_id: app_state.request_id.clone(),
+ #[cfg(feature = "keymanager_mtls")]
+ cert: conf.cert.clone(),
+ #[cfg(feature = "keymanager_mtls")]
+ ca: conf.ca.clone(),
+ infra_values: app::AppState::process_env_mappings(app_state.conf.infra_values.clone()),
+ }
+ }
+}
impl From<&app::SessionState> for KeyManagerState {
fn from(state: &app::SessionState) -> Self {
let conf = state.conf.key_manager.get_inner();
diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rs
index f5bd19cbb6..03a53f92fe 100644
--- a/crates/router/src/types/domain/user.rs
+++ b/crates/router/src/types/domain/user.rs
@@ -449,7 +449,6 @@ impl NewUserMerchant {
if state
.store
.get_merchant_key_store_by_merchant_id(
- &(&state).into(),
&self.get_merchant_id(),
&state.store.get_master_key().to_vec().into(),
)
@@ -542,11 +541,9 @@ impl NewUserMerchant {
return Err(UserErrors::InternalServerError.into());
};
- let key_manager_state = &(&state).into();
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_account_response.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -557,7 +554,6 @@ impl NewUserMerchant {
let merchant_account = state
.store
.find_merchant_account_by_merchant_id(
- key_manager_state,
&merchant_account_response.merchant_id,
&merchant_key_store,
)
@@ -593,11 +589,9 @@ impl NewUserMerchant {
..Default::default()
};
- let key_manager_state = &(&state).into();
let merchant_key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_account_response.id,
&state.store.get_master_key().to_vec().into(),
)
@@ -608,7 +602,6 @@ impl NewUserMerchant {
let merchant_account = state
.store
.find_merchant_account_by_merchant_id(
- key_manager_state,
&merchant_account_response.id,
&merchant_key_store,
)
@@ -1203,11 +1196,7 @@ impl UserFromStorage {
let key_manager_state = &state.into();
let key_store_result = state
.global_store
- .get_user_key_store_by_user_id(
- key_manager_state,
- self.get_user_id(),
- &master_key.to_vec().into(),
- )
+ .get_user_key_store_by_user_id(self.get_user_id(), &master_key.to_vec().into())
.await;
if let Ok(key_store) = key_store_result {
@@ -1252,7 +1241,7 @@ impl UserFromStorage {
state
.global_store
- .insert_user_key_store(key_manager_state, key_store, &master_key.to_vec().into())
+ .insert_user_key_store(key_store, &master_key.to_vec().into())
.await
.change_context(UserErrors::InternalServerError)
} else {
@@ -1282,7 +1271,6 @@ impl UserFromStorage {
let user_key_store = state
.global_store
.get_user_key_store_by_user_id(
- key_manager_state,
self.get_user_id(),
&state.store.get_master_key().to_vec().into(),
)
diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rs
index 3bcbc65eb0..8b85f9f646 100644
--- a/crates/router/src/utils.rs
+++ b/crates/router/src/utils.rs
@@ -19,7 +19,6 @@ use api_models::{
payments::{self},
subscription as subscription_types, webhooks,
};
-use common_utils::types::keymanager::KeyManagerState;
pub use common_utils::{
crypto::{self, Encryptable},
ext_traits::{ByteSliceExt, BytesExt, Encode, StringExt, ValueExt},
@@ -171,12 +170,10 @@ pub async fn find_payment_intent_from_payment_id_type(
payment_id_type: payments::PaymentIdType,
platform: &domain::Platform,
) -> CustomResult<PaymentIntent, errors::ApiErrorResponse> {
- let key_manager_state: KeyManagerState = state.into();
let db = &*state.store;
match payment_id_type {
payments::PaymentIdType::PaymentIntentId(payment_id) => db
.find_payment_intent_by_payment_id_merchant_id(
- &key_manager_state,
&payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -194,7 +191,6 @@ pub async fn find_payment_intent_from_payment_id_type(
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
db.find_payment_intent_by_payment_id_merchant_id(
- &key_manager_state,
&attempt.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -213,7 +209,6 @@ pub async fn find_payment_intent_from_payment_id_type(
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
db.find_payment_intent_by_payment_id_merchant_id(
- &key_manager_state,
&attempt.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -264,7 +259,6 @@ pub async fn find_payment_intent_from_refund_id_type(
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
db.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&attempt.payment_id,
platform.get_processor().get_account().get_id(),
platform.get_processor().get_key_store(),
@@ -300,7 +294,6 @@ pub async fn find_payment_intent_from_mandate_id_type(
.to_not_found_response(errors::ApiErrorResponse::MandateNotFound)?,
};
db.find_payment_intent_by_payment_id_merchant_id(
- &state.into(),
&mandate
.original_payment_id
.ok_or(errors::ApiErrorResponse::InternalServerError)
@@ -345,7 +338,6 @@ pub async fn find_mca_from_authentication_id_type(
.ok_or(errors::ApiErrorResponse::InternalServerError)
.attach_printable("merchant_connector_id not present in authentication record")?;
db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- &state.into(),
platform.get_processor().get_account().get_id(),
&mca_id,
platform.get_processor().get_key_store(),
@@ -374,7 +366,6 @@ pub async fn get_mca_from_payment_intent(
connector_name: &str,
) -> CustomResult<domain::MerchantConnectorAccount, errors::ApiErrorResponse> {
let db = &*state.store;
- let key_manager_state: &KeyManagerState = &state.into();
#[cfg(feature = "v1")]
let payment_attempt = db
@@ -403,7 +394,6 @@ pub async fn get_mca_from_payment_intent(
#[cfg(feature = "v1")]
{
db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
platform.get_processor().get_account().get_id(),
&merchant_connector_id,
platform.get_processor().get_key_store(),
@@ -437,7 +427,6 @@ pub async fn get_mca_from_payment_intent(
#[cfg(feature = "v1")]
{
db.find_merchant_connector_account_by_profile_id_connector_name(
- key_manager_state,
&profile_id,
connector_name,
platform.get_processor().get_key_store(),
@@ -487,13 +476,11 @@ pub async fn get_mca_from_payout_attempt(
.await
.to_not_found_response(errors::ApiErrorResponse::PayoutNotFound)?,
};
- let key_manager_state: &KeyManagerState = &state.into();
match payout.merchant_connector_id {
Some(merchant_connector_id) => {
#[cfg(feature = "v1")]
{
db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
platform.get_processor().get_account().get_id(),
&merchant_connector_id,
platform.get_processor().get_key_store(),
@@ -511,7 +498,6 @@ pub async fn get_mca_from_payout_attempt(
let _id = merchant_connector_id;
let _ = platform.get_processor().get_key_store();
let _ = connector_name;
- let _ = key_manager_state;
todo!()
}
}
@@ -519,7 +505,6 @@ pub async fn get_mca_from_payout_attempt(
#[cfg(feature = "v1")]
{
db.find_merchant_connector_account_by_profile_id_connector_name(
- key_manager_state,
&payout.profile_id,
connector_name,
platform.get_processor().get_key_store(),
@@ -567,7 +552,6 @@ pub async fn get_mca_from_object_reference_id(
#[cfg(feature = "v1")]
{
db.find_merchant_connector_account_by_profile_id_connector_name(
- &state.into(),
profile_id,
connector_name,
platform.get_processor().get_key_store(),
@@ -1253,14 +1237,9 @@ pub async fn trigger_refund_outgoing_webhook(
) -> RouterResult<()> {
let refund_status = refund.refund_status;
- let key_manager_state = &(state).into();
let business_profile = state
.store
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- &profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), &profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
@@ -1327,15 +1306,10 @@ pub async fn trigger_payouts_webhook(
platform: &domain::Platform,
payout_response: &api_models::payouts::PayoutCreateResponse,
) -> RouterResult<()> {
- let key_manager_state = &(state).into();
let profile_id = &payout_response.profile_id;
let business_profile = state
.store
- .find_business_profile_by_profile_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- profile_id,
- )
+ .find_business_profile_by_profile_id(platform.get_processor().get_key_store(), profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
diff --git a/crates/router/src/utils/connector_onboarding.rs b/crates/router/src/utils/connector_onboarding.rs
index 71847ba1e0..5f07571c11 100644
--- a/crates/router/src/utils/connector_onboarding.rs
+++ b/crates/router/src/utils/connector_onboarding.rs
@@ -44,11 +44,9 @@ pub async fn check_if_connector_exists(
connector_id: &common_utils::id_type::MerchantConnectorAccountId,
merchant_id: &common_utils::id_type::MerchantId,
) -> RouterResult<()> {
- let key_manager_state = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -59,7 +57,6 @@ pub async fn check_if_connector_exists(
let _connector = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
merchant_id,
connector_id,
&key_store,
diff --git a/crates/router/src/utils/user.rs b/crates/router/src/utils/user.rs
index 41a1b90bb7..6cd5e2bfdb 100644
--- a/crates/router/src/utils/user.rs
+++ b/crates/router/src/utils/user.rs
@@ -52,11 +52,9 @@ impl UserFromToken {
&self,
state: SessionState,
) -> UserResult<MerchantAccount> {
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&self.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -70,7 +68,7 @@ impl UserFromToken {
})?;
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, &self.merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&self.merchant_id, &key_store)
.await
.map_err(|e| {
if e.current_context().is_db_not_found() {
diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs
index b308f6f37d..e3f89ea30d 100644
--- a/crates/router/src/utils/user/sample_data.rs
+++ b/crates/router/src/utils/user/sample_data.rs
@@ -37,7 +37,6 @@ pub async fn generate_sample_data(
)>,
> {
let sample_data_size: usize = req.record.unwrap_or(100);
- let key_manager_state = &state.into();
if !(10..=100).contains(&sample_data_size) {
return Err(SampleDataError::InvalidRange.into());
}
@@ -45,7 +44,6 @@ pub async fn generate_sample_data(
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -54,7 +52,7 @@ pub async fn generate_sample_data(
let merchant_from_db = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.change_context::<SampleDataError>(SampleDataError::DataDoesNotExist)?;
@@ -76,7 +74,6 @@ pub async fn generate_sample_data(
let business_label_default = merchant_parsed_details.first().map(|x| x.business.clone());
let profile_id = crate::core::utils::get_profile_id_from_business_details(
- key_manager_state,
business_country_default,
business_label_default.as_ref(),
&platform,
@@ -108,11 +105,7 @@ pub async fn generate_sample_data(
state
.store
- .list_profile_by_merchant_id(
- key_manager_state,
- platform.get_processor().get_key_store(),
- merchant_id,
- )
+ .list_profile_by_merchant_id(platform.get_processor().get_key_store(), merchant_id)
.await
.change_context(SampleDataError::InternalServerError)
.attach_printable("Failed to get business profile")?
diff --git a/crates/router/src/utils/user/theme.rs b/crates/router/src/utils/user/theme.rs
index e45f5c70d9..d82fa7d042 100644
--- a/crates/router/src/utils/user/theme.rs
+++ b/crates/router/src/utils/user/theme.rs
@@ -115,7 +115,6 @@ async fn validate_merchant_and_get_key_store(
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- &state.into(),
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -124,7 +123,7 @@ async fn validate_merchant_and_get_key_store(
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(&state.into(), merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.to_not_found_response(UserErrors::InvalidThemeLineage("merchant_id".to_string()))?;
@@ -153,12 +152,7 @@ async fn validate_profile(
) -> UserResult<()> {
state
.store
- .find_business_profile_by_merchant_id_profile_id(
- &state.into(),
- key_store,
- merchant_id,
- profile_id,
- )
+ .find_business_profile_by_merchant_id_profile_id(key_store, merchant_id, profile_id)
.await
.to_not_found_response(UserErrors::InvalidThemeLineage("profile_id".to_string()))
.map(|_| ())
diff --git a/crates/router/src/utils/user_role.rs b/crates/router/src/utils/user_role.rs
index 25b392fb9f..2033611aa0 100644
--- a/crates/router/src/utils/user_role.rs
+++ b/crates/router/src/utils/user_role.rs
@@ -222,7 +222,7 @@ pub async fn get_single_org_id(
match entity_type {
EntityType::Tenant => Ok(state
.store
- .list_merchant_and_org_ids(&state.into(), 1, None)
+ .list_merchant_and_org_ids(1, None)
.await
.change_context(UserErrors::InternalServerError)
.attach_printable("Failed to get merchants list for org")?
@@ -249,7 +249,7 @@ pub async fn get_single_merchant_id(
match entity_type {
EntityType::Tenant | EntityType::Organization => Ok(state
.store
- .list_merchant_accounts_by_organization_id(&state.into(), org_id)
+ .list_merchant_accounts_by_organization_id(org_id)
.await
.to_not_found_response(UserErrors::InvalidRoleOperationWithMessage(
"Invalid Org Id".to_string(),
@@ -280,7 +280,6 @@ pub async fn get_single_profile_id(
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- &state.into(),
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -289,7 +288,7 @@ pub async fn get_single_profile_id(
Ok(state
.store
- .list_profile_by_merchant_id(&state.into(), &key_store, merchant_id)
+ .list_profile_by_merchant_id(&key_store, merchant_id)
.await
.change_context(UserErrors::InternalServerError)?
.pop()
diff --git a/crates/router/src/workflows/api_key_expiry.rs b/crates/router/src/workflows/api_key_expiry.rs
index 51e862681a..e369abf9fa 100644
--- a/crates/router/src/workflows/api_key_expiry.rs
+++ b/crates/router/src/workflows/api_key_expiry.rs
@@ -31,22 +31,16 @@ impl ProcessTrackerWorkflow<SessionState> for ApiKeyExpiryWorkflow {
.tracking_data
.clone()
.parse_value("ApiKeyExpiryTrackingData")?;
- let key_manager_satte = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_satte,
&tracking_data.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
.await?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(
- key_manager_satte,
- &tracking_data.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&tracking_data.merchant_id, &key_store)
.await?;
let email_id = merchant_account
diff --git a/crates/router/src/workflows/attach_payout_account_workflow.rs b/crates/router/src/workflows/attach_payout_account_workflow.rs
index b0469d5dcb..2a07ce20ac 100644
--- a/crates/router/src/workflows/attach_payout_account_workflow.rs
+++ b/crates/router/src/workflows/attach_payout_account_workflow.rs
@@ -34,17 +34,15 @@ impl ProcessTrackerWorkflow<SessionState> for AttachPayoutAccountWorkflow {
.merchant_id
.clone()
.get_required_value("merchant_id")?;
- let key_manager_state = &state.into();
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&db.get_master_key().to_vec().into(),
)
.await?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await?;
let request = api::payouts::PayoutRequest::PayoutRetrieveRequest(tracking_data);
diff --git a/crates/router/src/workflows/dispute_list.rs b/crates/router/src/workflows/dispute_list.rs
index b615df4d04..2c5fc8c4b9 100644
--- a/crates/router/src/workflows/dispute_list.rs
+++ b/crates/router/src/workflows/dispute_list.rs
@@ -44,21 +44,15 @@ impl ProcessTrackerWorkflow<SessionState> for DisputeListWorkflow {
.tracking_data
.clone()
.parse_value("ProcessDisputePTData")?;
- let key_manager_state = &state.into();
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&tracking_data.merchant_id,
&db.get_master_key().to_vec().into(),
)
.await?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &tracking_data.merchant_id.clone(),
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&tracking_data.merchant_id.clone(), &key_store)
.await?;
let platform = domain::Platform::new(
@@ -71,7 +65,6 @@ impl ProcessTrackerWorkflow<SessionState> for DisputeListWorkflow {
let business_profile = state
.store
.find_business_profile_by_profile_id(
- &(state).into(),
platform.get_processor().get_key_store(),
&tracking_data.profile_id,
)
diff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rs
index 2aa633835e..46c026878b 100644
--- a/crates/router/src/workflows/outgoing_webhook_retry.rs
+++ b/crates/router/src/workflows/outgoing_webhook_retry.rs
@@ -53,20 +53,14 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {
.parse_value("OutgoingWebhookTrackingData")?;
let db = &*state.store;
- let key_manager_state = &state.into();
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&tracking_data.merchant_id,
&db.get_master_key().to_vec().into(),
)
.await?;
let business_profile = db
- .find_business_profile_by_profile_id(
- key_manager_state,
- &key_store,
- &tracking_data.business_profile_id,
- )
+ .find_business_profile_by_profile_id(&key_store, &tracking_data.business_profile_id)
.await?;
let event_id = webhooks_core::utils::generate_event_id();
@@ -81,7 +75,6 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {
let initial_event = match &tracking_data.initial_attempt_id {
Some(initial_attempt_id) => {
db.find_event_by_merchant_id_event_id(
- key_manager_state,
&business_profile.merchant_id,
initial_attempt_id,
&key_store,
@@ -96,7 +89,6 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {
tracking_data.primary_object_id, tracking_data.event_type
);
db.find_event_by_merchant_id_event_id(
- key_manager_state,
&business_profile.merchant_id,
&old_event_id,
&key_store,
@@ -127,7 +119,7 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {
};
let event = db
- .insert_event(key_manager_state, new_event, &key_store)
+ .insert_event(new_event, &key_store)
.await
.inspect_err(|error| {
logger::error!(?error, "Failed to insert event in events table");
@@ -157,11 +149,7 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {
// resource
None => {
let merchant_account = db
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &tracking_data.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&tracking_data.merchant_id, &key_store)
.await?;
let platform = domain::Platform::new(
diff --git a/crates/router/src/workflows/payment_method_status_update.rs b/crates/router/src/workflows/payment_method_status_update.rs
index 797b11abde..31cd7af890 100644
--- a/crates/router/src/workflows/payment_method_status_update.rs
+++ b/crates/router/src/workflows/payment_method_status_update.rs
@@ -31,27 +31,20 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentMethodStatusUpdateWorkflow
let prev_pm_status = tracking_data.prev_status;
let curr_pm_status = tracking_data.curr_status;
let merchant_id = tracking_data.merchant_id;
- let key_manager_state = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
.await?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await?;
let payment_method = db
- .find_payment_method(
- &(state.into()),
- &key_store,
- &pm_id,
- merchant_account.storage_scheme,
- )
+ .find_payment_method(&key_store, &pm_id, merchant_account.storage_scheme)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to decode billing address")?;
@@ -71,7 +64,6 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentMethodStatusUpdateWorkflow
let res = db
.update_payment_method(
- &(state.into()),
&key_store,
payment_method,
pm_update,
diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rs
index 4f4b056d15..a604493ad0 100644
--- a/crates/router/src/workflows/payment_sync.rs
+++ b/crates/router/src/workflows/payment_sync.rs
@@ -52,10 +52,8 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {
.tracking_data
.clone()
.parse_value("PaymentsRetrieveRequest")?;
- let key_manager_state = &state.into();
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
tracking_data
.merchant_id
.as_ref()
@@ -66,7 +64,6 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {
let merchant_account = db
.find_merchant_account_by_merchant_id(
- key_manager_state,
tracking_data
.merchant_id
.as_ref()
@@ -179,7 +176,6 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {
payment_data.payment_intent = db
.update_payment_intent(
- &state.into(),
payment_data.payment_intent,
payment_intent_update,
&key_store,
@@ -197,11 +193,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {
.attach_printable("Could not find profile_id in payment intent")?;
let business_profile = db
- .find_business_profile_by_profile_id(
- key_manager_state,
- &key_store,
- profile_id,
- )
+ .find_business_profile_by_profile_id(&key_store, profile_id)
.await
.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_owned(),
diff --git a/crates/router/src/workflows/process_dispute.rs b/crates/router/src/workflows/process_dispute.rs
index 39b575d157..8da1df0fb7 100644
--- a/crates/router/src/workflows/process_dispute.rs
+++ b/crates/router/src/workflows/process_dispute.rs
@@ -42,21 +42,15 @@ impl ProcessTrackerWorkflow<SessionState> for ProcessDisputeWorkflow {
.tracking_data
.clone()
.parse_value("ProcessDisputePTData")?;
- let key_manager_state = &state.into();
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&tracking_data.merchant_id,
&db.get_master_key().to_vec().into(),
)
.await?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &tracking_data.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&tracking_data.merchant_id, &key_store)
.await?;
let platform = domain::Platform::new(
@@ -76,7 +70,6 @@ impl ProcessTrackerWorkflow<SessionState> for ProcessDisputeWorkflow {
let business_profile = state
.store
.find_business_profile_by_profile_id(
- &(state).into(),
platform.get_processor().get_key_store(),
&payment_attempt.profile_id,
)
diff --git a/crates/router/src/workflows/revenue_recovery.rs b/crates/router/src/workflows/revenue_recovery.rs
index d7811634e2..8d499caa0a 100644
--- a/crates/router/src/workflows/revenue_recovery.rs
+++ b/crates/router/src/workflows/revenue_recovery.rs
@@ -198,37 +198,23 @@ pub(crate) async fn extract_data_and_perform_action(
) -> Result<pcr_storage_types::RevenueRecoveryPaymentData, errors::ProcessTrackerError> {
let db = &state.store;
- let key_manager_state = &state.into();
let key_store = db
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&tracking_data.merchant_id,
&db.get_master_key().to_vec().into(),
)
.await?;
let merchant_account = db
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &tracking_data.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&tracking_data.merchant_id, &key_store)
.await?;
let profile = db
- .find_business_profile_by_profile_id(
- key_manager_state,
- &key_store,
- &tracking_data.profile_id,
- )
+ .find_business_profile_by_profile_id(&key_store, &tracking_data.profile_id)
.await?;
let billing_mca = db
- .find_merchant_connector_account_by_id(
- key_manager_state,
- &tracking_data.billing_mca_id,
- &key_store,
- )
+ .find_merchant_connector_account_by_id(&tracking_data.billing_mca_id, &key_store)
.await?;
let pcr_payment_data = pcr_storage_types::RevenueRecoveryPaymentData {
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index 9a23ab8d1c..5495ba32b5 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -296,11 +296,9 @@ async fn payments_create_core() {
|| {},
)
.unwrap();
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -309,7 +307,7 @@ async fn payments_create_core() {
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.unwrap();
@@ -592,11 +590,9 @@ async fn payments_create_core_adyen_no_redirect() {
let customer_id = format!("cust_{}", Uuid::new_v4());
let merchant_id = id_type::MerchantId::try_from(Cow::from("juspay_merchant")).unwrap();
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -605,7 +601,7 @@ async fn payments_create_core_adyen_no_redirect() {
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.unwrap();
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index 18386f5731..147868ad28 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -56,11 +56,9 @@ async fn payments_create_core() {
|| {},
)
.unwrap();
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -69,7 +67,7 @@ async fn payments_create_core() {
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.unwrap();
@@ -360,11 +358,9 @@ async fn payments_create_core_adyen_no_redirect() {
let payment_id =
id_type::PaymentId::try_from(Cow::Borrowed("pay_mbabizu24mvu3mela5njyhpit10")).unwrap();
- let key_manager_state = &(&state).into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -373,7 +369,7 @@ async fn payments_create_core_adyen_no_redirect() {
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)
+ .find_merchant_account_by_merchant_id(&merchant_id, &key_store)
.await
.unwrap();
diff --git a/crates/storage_impl/src/business_profile.rs b/crates/storage_impl/src/business_profile.rs
index add7ece931..cd86fd69c4 100644
--- a/crates/storage_impl/src/business_profile.rs
+++ b/crates/storage_impl/src/business_profile.rs
@@ -12,7 +12,7 @@ use router_env::{instrument, tracing};
use crate::{
kv_router_store,
utils::{pg_accounts_connection_read, pg_accounts_connection_write},
- CustomResult, DatabaseStore, KeyManagerState, MockDb, RouterStore, StorageError,
+ CustomResult, DatabaseStore, MockDb, RouterStore, StorageError,
};
#[async_trait::async_trait]
@@ -21,37 +21,33 @@ impl<T: DatabaseStore> ProfileInterface for kv_router_store::KVRouterStore<T> {
#[instrument(skip_all)]
async fn insert_business_profile(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
business_profile: domain::Profile,
) -> CustomResult<domain::Profile, StorageError> {
self.router_store
- .insert_business_profile(key_manager_state, merchant_key_store, business_profile)
+ .insert_business_profile(merchant_key_store, business_profile)
.await
}
#[instrument(skip_all)]
async fn find_business_profile_by_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
) -> CustomResult<domain::Profile, StorageError> {
self.router_store
- .find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_id)
+ .find_business_profile_by_profile_id(merchant_key_store, profile_id)
.await
}
async fn find_business_profile_by_merchant_id_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
profile_id: &common_utils::id_type::ProfileId,
) -> CustomResult<domain::Profile, StorageError> {
self.router_store
.find_business_profile_by_merchant_id_profile_id(
- key_manager_state,
merchant_key_store,
merchant_id,
profile_id,
@@ -62,14 +58,12 @@ impl<T: DatabaseStore> ProfileInterface for kv_router_store::KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_business_profile_by_profile_name_merchant_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_name: &str,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<domain::Profile, StorageError> {
self.router_store
.find_business_profile_by_profile_name_merchant_id(
- key_manager_state,
merchant_key_store,
profile_name,
merchant_id,
@@ -80,18 +74,12 @@ impl<T: DatabaseStore> ProfileInterface for kv_router_store::KVRouterStore<T> {
#[instrument(skip_all)]
async fn update_profile_by_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
current_state: domain::Profile,
profile_update: domain::ProfileUpdate,
) -> CustomResult<domain::Profile, StorageError> {
self.router_store
- .update_profile_by_profile_id(
- key_manager_state,
- merchant_key_store,
- current_state,
- profile_update,
- )
+ .update_profile_by_profile_id(merchant_key_store, current_state, profile_update)
.await
}
@@ -109,12 +97,11 @@ impl<T: DatabaseStore> ProfileInterface for kv_router_store::KVRouterStore<T> {
#[instrument(skip_all)]
async fn list_profile_by_merchant_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<domain::Profile>, StorageError> {
self.router_store
- .list_profile_by_merchant_id(key_manager_state, merchant_key_store, merchant_id)
+ .list_profile_by_merchant_id(merchant_key_store, merchant_id)
.await
}
}
@@ -125,7 +112,6 @@ impl<T: DatabaseStore> ProfileInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_business_profile(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
business_profile: domain::Profile,
) -> CustomResult<domain::Profile, StorageError> {
@@ -138,7 +124,8 @@ impl<T: DatabaseStore> ProfileInterface for RouterStore<T> {
.await
.map_err(|error| report!(StorageError::from(error)))?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -149,13 +136,11 @@ impl<T: DatabaseStore> ProfileInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_business_profile_by_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
) -> CustomResult<domain::Profile, StorageError> {
let conn = pg_accounts_connection_read(self).await?;
self.call_database(
- key_manager_state,
merchant_key_store,
business_profile::Profile::find_by_profile_id(&conn, profile_id),
)
@@ -164,14 +149,12 @@ impl<T: DatabaseStore> ProfileInterface for RouterStore<T> {
async fn find_business_profile_by_merchant_id_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
profile_id: &common_utils::id_type::ProfileId,
) -> CustomResult<domain::Profile, StorageError> {
let conn = pg_accounts_connection_read(self).await?;
self.call_database(
- key_manager_state,
merchant_key_store,
business_profile::Profile::find_by_merchant_id_profile_id(
&conn,
@@ -185,14 +168,12 @@ impl<T: DatabaseStore> ProfileInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_business_profile_by_profile_name_merchant_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_name: &str,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<domain::Profile, StorageError> {
let conn = pg_accounts_connection_read(self).await?;
self.call_database(
- key_manager_state,
merchant_key_store,
business_profile::Profile::find_by_profile_name_merchant_id(
&conn,
@@ -206,7 +187,6 @@ impl<T: DatabaseStore> ProfileInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_profile_by_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
current_state: domain::Profile,
profile_update: domain::ProfileUpdate,
@@ -219,7 +199,8 @@ impl<T: DatabaseStore> ProfileInterface for RouterStore<T> {
.await
.map_err(|error| report!(StorageError::from(error)))?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -242,13 +223,11 @@ impl<T: DatabaseStore> ProfileInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn list_profile_by_merchant_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<domain::Profile>, StorageError> {
let conn = pg_accounts_connection_read(self).await?;
self.find_resources(
- key_manager_state,
merchant_key_store,
business_profile::Profile::list_profile_by_merchant_id(&conn, merchant_id),
)
@@ -261,7 +240,6 @@ impl ProfileInterface for MockDb {
type Error = StorageError;
async fn insert_business_profile(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
business_profile: domain::Profile,
) -> CustomResult<domain::Profile, StorageError> {
@@ -276,7 +254,8 @@ impl ProfileInterface for MockDb {
stored_business_profile
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -286,7 +265,6 @@ impl ProfileInterface for MockDb {
async fn find_business_profile_by_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
) -> CustomResult<domain::Profile, StorageError> {
@@ -299,7 +277,8 @@ impl ProfileInterface for MockDb {
.async_map(|business_profile| async {
business_profile
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -318,7 +297,6 @@ impl ProfileInterface for MockDb {
async fn find_business_profile_by_merchant_id_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
profile_id: &common_utils::id_type::ProfileId,
@@ -335,7 +313,7 @@ impl ProfileInterface for MockDb {
.async_map(|business_profile| async {
business_profile
.convert(
- key_manager_state,
+ self.get_keymanager_state().attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -354,7 +332,6 @@ impl ProfileInterface for MockDb {
async fn update_profile_by_profile_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
current_state: domain::Profile,
profile_update: domain::ProfileUpdate,
@@ -375,7 +352,8 @@ impl ProfileInterface for MockDb {
profile_updated
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -413,7 +391,6 @@ impl ProfileInterface for MockDb {
async fn list_profile_by_merchant_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<domain::Profile>, StorageError> {
@@ -431,7 +408,8 @@ impl ProfileInterface for MockDb {
for business_profile in business_profiles {
let domain_profile = business_profile
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -445,7 +423,6 @@ impl ProfileInterface for MockDb {
async fn find_business_profile_by_profile_name_merchant_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_name: &str,
merchant_id: &common_utils::id_type::MerchantId,
@@ -462,7 +439,7 @@ impl ProfileInterface for MockDb {
.async_map(|business_profile| async {
business_profile
.convert(
- key_manager_state,
+ self.get_keymanager_state().attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
diff --git a/crates/storage_impl/src/customers.rs b/crates/storage_impl/src/customers.rs
index befbf5d7f6..c5941f8e93 100644
--- a/crates/storage_impl/src/customers.rs
+++ b/crates/storage_impl/src/customers.rs
@@ -17,7 +17,7 @@ use crate::{
redis::kv_store::{decide_storage_scheme, KvStorePartition, Op, PartitionKey},
store::enums::MerchantStorageScheme,
utils::{pg_connection_read, pg_connection_write},
- CustomResult, DatabaseStore, KeyManagerState, MockDb, RouterStore,
+ CustomResult, DatabaseStore, MockDb, RouterStore,
};
impl KvStorePartition for customers::Customer {}
@@ -56,7 +56,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[cfg(feature = "v1")]
async fn find_customer_optional_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -65,7 +64,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
let conn = pg_connection_read(self).await?;
let maybe_result = self
.find_optional_resource_by_id(
- state,
key_store,
storage_scheme,
customers::Customer::find_optional_by_customer_id_merchant_id(
@@ -94,7 +92,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[cfg(feature = "v1")]
async fn find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -102,7 +99,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
) -> CustomResult<Option<domain::Customer>, StorageError> {
let conn = pg_connection_read(self).await?;
self.find_optional_resource_by_id(
- state,
key_store,
storage_scheme,
customers::Customer::find_optional_by_customer_id_merchant_id(
@@ -124,7 +120,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[cfg(feature = "v2")]
async fn find_optional_by_merchant_id_merchant_reference_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -133,7 +128,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
let conn = pg_connection_read(self).await?;
let maybe_result = self
.find_optional_resource_by_id(
- state,
key_store,
storage_scheme,
customers::Customer::find_optional_by_merchant_id_merchant_reference_id(
@@ -161,7 +155,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[instrument(skip_all)]
async fn update_customer_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: id_type::CustomerId,
merchant_id: id_type::MerchantId,
customer: domain::Customer,
@@ -181,7 +174,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
};
let field = format!("cust_{}", customer_id.get_string_repr());
self.update_resource(
- state,
key_store,
storage_scheme,
customers::Customer::update_by_customer_id_merchant_id(
@@ -206,7 +198,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[instrument(skip_all)]
async fn find_customer_by_merchant_reference_id_merchant_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -215,7 +206,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
let conn = pg_connection_read(self).await?;
let result: domain::Customer = self
.find_resource_by_id(
- state,
key_store,
storage_scheme,
customers::Customer::find_by_merchant_reference_id_merchant_id(
@@ -243,7 +233,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[instrument(skip_all)]
async fn find_customer_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -252,7 +241,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
let conn = pg_connection_read(self).await?;
let result: domain::Customer = self
.find_resource_by_id(
- state,
key_store,
storage_scheme,
customers::Customer::find_by_customer_id_merchant_id(
@@ -279,26 +267,24 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[instrument(skip_all)]
async fn list_customers_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: domain::CustomerListConstraints,
) -> CustomResult<Vec<domain::Customer>, StorageError> {
self.router_store
- .list_customers_by_merchant_id(state, merchant_id, key_store, constraints)
+ .list_customers_by_merchant_id(merchant_id, key_store, constraints)
.await
}
#[instrument(skip_all)]
async fn list_customers_by_merchant_id_with_count(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: domain::CustomerListConstraints,
) -> CustomResult<(Vec<domain::Customer>, usize), StorageError> {
self.router_store
- .list_customers_by_merchant_id_with_count(state, merchant_id, key_store, constraints)
+ .list_customers_by_merchant_id_with_count(merchant_id, key_store, constraints)
.await
}
@@ -307,7 +293,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
async fn insert_customer(
&self,
customer_data: domain::Customer,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
@@ -339,7 +324,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
}
self.insert_resource(
- state,
key_store,
decided_storage_scheme,
new_customer.clone().insert(&conn),
@@ -360,7 +344,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
async fn insert_customer(
&self,
customer_data: domain::Customer,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
@@ -383,7 +366,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
new_customer.update_storage_scheme(storage_scheme);
let customer = new_customer.clone().into();
self.insert_resource(
- state,
key_store,
storage_scheme,
new_customer.clone().insert(&conn),
@@ -415,7 +397,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[instrument(skip_all)]
async fn find_customer_by_global_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
@@ -423,7 +404,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
let conn = pg_connection_read(self).await?;
let result: domain::Customer = self
.find_resource_by_id(
- state,
key_store,
storage_scheme,
customers::Customer::find_by_global_id(&conn, id),
@@ -447,7 +427,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
#[instrument(skip_all)]
async fn update_customer_by_global_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
customer: domain::Customer,
customer_update: domain::CustomerUpdate,
@@ -465,7 +444,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
};
let field = format!("cust_{}", id.get_string_repr());
self.update_resource(
- state,
key_store,
storage_scheme,
database_call,
@@ -490,7 +468,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[cfg(feature = "v1")]
async fn find_customer_optional_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -499,7 +476,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
let conn = pg_connection_read(self).await?;
let maybe_customer: Option<domain::Customer> = self
.find_optional_resource(
- state,
key_store,
customers::Customer::find_optional_by_customer_id_merchant_id(
&conn,
@@ -524,7 +500,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[cfg(feature = "v1")]
async fn find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -532,7 +507,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
) -> CustomResult<Option<domain::Customer>, StorageError> {
let conn = pg_connection_read(self).await?;
self.find_optional_resource(
- state,
key_store,
customers::Customer::find_optional_by_customer_id_merchant_id(
&conn,
@@ -547,7 +521,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[cfg(feature = "v2")]
async fn find_optional_by_merchant_id_merchant_reference_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -556,7 +529,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
let conn = pg_connection_read(self).await?;
let maybe_customer: Option<domain::Customer> = self
.find_optional_resource(
- state,
key_store,
customers::Customer::find_optional_by_merchant_id_merchant_reference_id(
&conn,
@@ -581,7 +553,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_customer_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: id_type::CustomerId,
merchant_id: id_type::MerchantId,
_customer: domain::Customer,
@@ -591,7 +562,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
) -> CustomResult<domain::Customer, StorageError> {
let conn = pg_connection_write(self).await?;
self.call_database(
- state,
key_store,
customers::Customer::update_by_customer_id_merchant_id(
&conn,
@@ -607,7 +577,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_customer_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -616,7 +585,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
let conn = pg_connection_read(self).await?;
let customer: domain::Customer = self
.call_database(
- state,
key_store,
customers::Customer::find_by_customer_id_merchant_id(
&conn,
@@ -635,7 +603,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_customer_by_merchant_reference_id_merchant_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
@@ -644,7 +611,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
let conn = pg_connection_read(self).await?;
let customer: domain::Customer = self
.call_database(
- state,
key_store,
customers::Customer::find_by_merchant_reference_id_merchant_id(
&conn,
@@ -662,7 +628,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn list_customers_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: domain::CustomerListConstraints,
@@ -671,7 +636,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
let customer_list_constraints =
diesel_models::query::customers::CustomerListConstraints::from(constraints);
self.find_resources(
- state,
key_store,
customers::Customer::list_customers_by_merchant_id_and_constraints(
&conn,
@@ -685,7 +649,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn list_customers_by_merchant_id_with_count(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: domain::CustomerListConstraints,
@@ -701,7 +664,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
};
let customers = self
.find_resources(
- state,
key_store,
customers::Customer::list_customers_by_merchant_id_and_constraints(
&conn,
@@ -727,7 +689,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
async fn insert_customer(
&self,
customer_data: domain::Customer,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
@@ -736,7 +697,7 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
.construct_new()
.await
.change_context(StorageError::EncryptionError)?;
- self.call_database(state, key_store, customer_new.insert(&conn))
+ self.call_database(key_store, customer_new.insert(&conn))
.await
}
@@ -760,7 +721,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[allow(clippy::too_many_arguments)]
async fn update_customer_by_global_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
_customer: domain::Customer,
customer_update: domain::CustomerUpdate,
@@ -769,7 +729,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
) -> CustomResult<domain::Customer, StorageError> {
let conn = pg_connection_write(self).await?;
self.call_database(
- state,
key_store,
customers::Customer::update_by_id(&conn, id.clone(), customer_update.into()),
)
@@ -780,18 +739,13 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_customer_by_global_id(
&self,
- state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
let conn = pg_connection_read(self).await?;
let customer: domain::Customer = self
- .call_database(
- state,
- key_store,
- customers::Customer::find_by_global_id(&conn, id),
- )
+ .call_database(key_store, customers::Customer::find_by_global_id(&conn, id))
.await?;
match customer.name {
Some(ref name) if name.peek() == pii::REDACTED => Err(StorageError::CustomerRedacted)?,
@@ -806,14 +760,13 @@ impl domain::CustomerInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_customer_optional_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<Option<domain::Customer>, StorageError> {
let customers = self.customers.lock().await;
- self.find_resource(state, key_store, customers, |customer| {
+ self.find_resource(key_store, customers, |customer| {
customer.customer_id == *customer_id && &customer.merchant_id == merchant_id
})
.await
@@ -822,14 +775,13 @@ impl domain::CustomerInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
&self,
- state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<Option<domain::Customer>, StorageError> {
let customers = self.customers.lock().await;
- self.find_resource(state, key_store, customers, |customer| {
+ self.find_resource(key_store, customers, |customer| {
customer.customer_id == *customer_id && &customer.merchant_id == merchant_id
})
.await
@@ -838,7 +790,6 @@ impl domain::CustomerInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_optional_by_merchant_id_merchant_reference_id(
&self,
- _state: &KeyManagerState,
_customer_id: &id_type::CustomerId,
_merchant_id: &id_type::MerchantId,
_key_store: &MerchantKeyStore,
@@ -849,7 +800,6 @@ impl domain::CustomerInterface for MockDb {
async fn list_customers_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: domain::CustomerListConstraints,
@@ -866,7 +816,8 @@ impl domain::CustomerInterface for MockDb {
customer
.to_owned()
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -881,7 +832,6 @@ impl domain::CustomerInterface for MockDb {
async fn list_customers_by_merchant_id_with_count(
&self,
- state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: domain::CustomerListConstraints,
@@ -898,7 +848,8 @@ impl domain::CustomerInterface for MockDb {
customer
.to_owned()
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -918,7 +869,6 @@ impl domain::CustomerInterface for MockDb {
#[instrument(skip_all)]
async fn update_customer_by_customer_id_merchant_id(
&self,
- _state: &KeyManagerState,
_customer_id: id_type::CustomerId,
_merchant_id: id_type::MerchantId,
_customer: domain::Customer,
@@ -933,7 +883,6 @@ impl domain::CustomerInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_customer_by_customer_id_merchant_id(
&self,
- _state: &KeyManagerState,
_customer_id: &id_type::CustomerId,
_merchant_id: &id_type::MerchantId,
_key_store: &MerchantKeyStore,
@@ -946,7 +895,6 @@ impl domain::CustomerInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_customer_by_merchant_reference_id_merchant_id(
&self,
- _state: &KeyManagerState,
_merchant_reference_id: &id_type::CustomerId,
_merchant_id: &id_type::MerchantId,
_key_store: &MerchantKeyStore,
@@ -960,7 +908,6 @@ impl domain::CustomerInterface for MockDb {
async fn insert_customer(
&self,
customer_data: domain::Customer,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
@@ -974,7 +921,8 @@ impl domain::CustomerInterface for MockDb {
customer
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -996,7 +944,6 @@ impl domain::CustomerInterface for MockDb {
#[allow(clippy::too_many_arguments)]
async fn update_customer_by_global_id(
&self,
- _state: &KeyManagerState,
_id: &id_type::GlobalCustomerId,
_customer: domain::Customer,
_customer_update: domain::CustomerUpdate,
@@ -1010,7 +957,6 @@ impl domain::CustomerInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_customer_by_global_id(
&self,
- _state: &KeyManagerState,
_id: &id_type::GlobalCustomerId,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
diff --git a/crates/storage_impl/src/database/store.rs b/crates/storage_impl/src/database/store.rs
index 9caa84be48..ce8ddebddc 100644
--- a/crates/storage_impl/src/database/store.rs
+++ b/crates/storage_impl/src/database/store.rs
@@ -1,6 +1,9 @@
use async_bb8_diesel::{AsyncConnection, ConnectionError};
use bb8::CustomizeConnection;
-use common_utils::{types::TenantConfig, DbConnectionParams};
+use common_utils::{
+ types::{keymanager, TenantConfig},
+ DbConnectionParams,
+};
use diesel::PgConnection;
use error_stack::ResultExt;
@@ -19,6 +22,7 @@ pub trait DatabaseStore: Clone + Send + Sync {
config: Self::Config,
tenant_config: &dyn TenantConfig,
test_transaction: bool,
+ key_manager_state: Option<keymanager::KeyManagerState>,
) -> StorageResult<Self>;
fn get_master_pool(&self) -> &PgPool;
fn get_replica_pool(&self) -> &PgPool;
@@ -39,6 +43,7 @@ impl DatabaseStore for Store {
config: Database,
tenant_config: &dyn TenantConfig,
test_transaction: bool,
+ _key_manager_state: Option<keymanager::KeyManagerState>,
) -> StorageResult<Self> {
Ok(Self {
master_pool: diesel_make_pg_pool(&config, tenant_config.get_schema(), test_transaction)
@@ -84,6 +89,7 @@ impl DatabaseStore for ReplicaStore {
config: (Database, Database),
tenant_config: &dyn TenantConfig,
test_transaction: bool,
+ _key_manager_state: Option<keymanager::KeyManagerState>,
) -> StorageResult<Self> {
let (master_config, replica_config) = config;
let master_pool =
diff --git a/crates/storage_impl/src/invoice.rs b/crates/storage_impl/src/invoice.rs
index 0a3a93d2b9..61f667de13 100644
--- a/crates/storage_impl/src/invoice.rs
+++ b/crates/storage_impl/src/invoice.rs
@@ -1,4 +1,4 @@
-use common_utils::{errors::CustomResult, types::keymanager::KeyManagerState};
+use common_utils::errors::CustomResult;
pub use diesel_models::invoice::Invoice;
use error_stack::{report, ResultExt};
pub use hyperswitch_domain_models::{
@@ -20,7 +20,6 @@ impl<T: DatabaseStore> InvoiceInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_invoice_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_new: DomainInvoice,
) -> CustomResult<DomainInvoice, StorageError> {
@@ -29,20 +28,17 @@ impl<T: DatabaseStore> InvoiceInterface for RouterStore<T> {
.await
.change_context(StorageError::DecryptionError)?;
let conn = connection::pg_connection_write(self).await?;
- self.call_database(state, key_store, inv_new.insert(&conn))
- .await
+ self.call_database(key_store, inv_new.insert(&conn)).await
}
#[instrument(skip_all)]
async fn find_invoice_by_invoice_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_id: String,
) -> CustomResult<DomainInvoice, StorageError> {
let conn = connection::pg_connection_read(self).await?;
self.call_database(
- state,
key_store,
Invoice::find_invoice_by_id_invoice_id(&conn, invoice_id),
)
@@ -52,7 +48,6 @@ impl<T: DatabaseStore> InvoiceInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_invoice_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_id: String,
data: DomainInvoiceUpdate,
@@ -63,7 +58,6 @@ impl<T: DatabaseStore> InvoiceInterface for RouterStore<T> {
.change_context(StorageError::DecryptionError)?;
let conn = connection::pg_connection_write(self).await?;
self.call_database(
- state,
key_store,
Invoice::update_invoice_entry(&conn, invoice_id, inv_new),
)
@@ -73,14 +67,12 @@ impl<T: DatabaseStore> InvoiceInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn get_latest_invoice_for_subscription(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_id: String,
) -> CustomResult<DomainInvoice, StorageError> {
let conn = connection::pg_connection_write(self).await?;
let invoices: Vec<DomainInvoice> = self
.find_resources(
- state,
key_store,
Invoice::list_invoices_by_subscription_id(
&conn,
@@ -104,14 +96,12 @@ impl<T: DatabaseStore> InvoiceInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_invoice_by_subscription_id_connector_invoice_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_id: String,
connector_invoice_id: common_utils::id_type::InvoiceId,
) -> CustomResult<Option<DomainInvoice>, StorageError> {
let conn = connection::pg_connection_read(self).await?;
self.find_optional_resource(
- state,
key_store,
Invoice::get_invoice_by_subscription_id_connector_invoice_id(
&conn,
@@ -130,63 +120,57 @@ impl<T: DatabaseStore> InvoiceInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn insert_invoice_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_new: DomainInvoice,
) -> CustomResult<DomainInvoice, StorageError> {
self.router_store
- .insert_invoice_entry(state, key_store, invoice_new)
+ .insert_invoice_entry(key_store, invoice_new)
.await
}
#[instrument(skip_all)]
async fn find_invoice_by_invoice_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_id: String,
) -> CustomResult<DomainInvoice, StorageError> {
self.router_store
- .find_invoice_by_invoice_id(state, key_store, invoice_id)
+ .find_invoice_by_invoice_id(key_store, invoice_id)
.await
}
#[instrument(skip_all)]
async fn update_invoice_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
invoice_id: String,
data: DomainInvoiceUpdate,
) -> CustomResult<DomainInvoice, StorageError> {
self.router_store
- .update_invoice_entry(state, key_store, invoice_id, data)
+ .update_invoice_entry(key_store, invoice_id, data)
.await
}
#[instrument(skip_all)]
async fn get_latest_invoice_for_subscription(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_id: String,
) -> CustomResult<DomainInvoice, StorageError> {
self.router_store
- .get_latest_invoice_for_subscription(state, key_store, subscription_id)
+ .get_latest_invoice_for_subscription(key_store, subscription_id)
.await
}
#[instrument(skip_all)]
async fn find_invoice_by_subscription_id_connector_invoice_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_id: String,
connector_invoice_id: common_utils::id_type::InvoiceId,
) -> CustomResult<Option<DomainInvoice>, StorageError> {
self.router_store
.find_invoice_by_subscription_id_connector_invoice_id(
- state,
key_store,
subscription_id,
connector_invoice_id,
@@ -202,7 +186,6 @@ impl InvoiceInterface for MockDb {
#[instrument(skip_all)]
async fn insert_invoice_entry(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_invoice_new: DomainInvoice,
) -> CustomResult<DomainInvoice, StorageError> {
@@ -211,7 +194,6 @@ impl InvoiceInterface for MockDb {
async fn find_invoice_by_invoice_id(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_invoice_id: String,
) -> CustomResult<DomainInvoice, StorageError> {
@@ -220,7 +202,6 @@ impl InvoiceInterface for MockDb {
async fn update_invoice_entry(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_invoice_id: String,
_data: DomainInvoiceUpdate,
@@ -230,7 +211,6 @@ impl InvoiceInterface for MockDb {
async fn get_latest_invoice_for_subscription(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_subscription_id: String,
) -> CustomResult<DomainInvoice, StorageError> {
@@ -239,7 +219,6 @@ impl InvoiceInterface for MockDb {
async fn find_invoice_by_subscription_id_connector_invoice_id(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_subscription_id: String,
_connector_invoice_id: common_utils::id_type::InvoiceId,
diff --git a/crates/storage_impl/src/kv_router_store.rs b/crates/storage_impl/src/kv_router_store.rs
index 7ad2763c8f..e9347b6132 100644
--- a/crates/storage_impl/src/kv_router_store.rs
+++ b/crates/storage_impl/src/kv_router_store.rs
@@ -35,6 +35,7 @@ use crate::{
#[derive(Debug, Clone)]
pub struct KVRouterStore<T: DatabaseStore> {
pub router_store: RouterStore<T>,
+ pub key_manager_state: Option<KeyManagerState>,
drainer_stream_name: String,
drainer_num_partitions: u8,
pub ttl_for_kv: u32,
@@ -42,6 +43,14 @@ pub struct KVRouterStore<T: DatabaseStore> {
pub soft_kill_mode: bool,
}
+impl<T: DatabaseStore> KVRouterStore<T> {
+ pub fn get_keymanager_state(&self) -> Result<&KeyManagerState, errors::StorageError> {
+ self.key_manager_state
+ .as_ref()
+ .ok_or_else(|| errors::StorageError::DecryptionError)
+ }
+}
+
pub struct InsertResourceParams<'a> {
pub insertable: kv::Insertable,
pub reverse_lookups: Vec<String>,
@@ -109,6 +118,7 @@ where
config: Self::Config,
tenant_config: &dyn TenantConfig,
_test_transaction: bool,
+ key_manager_state: Option<KeyManagerState>,
) -> StorageResult<Self> {
let (router_store, _, drainer_num_partitions, ttl_for_kv, soft_kill_mode) = config;
let drainer_stream_name = format!("{}_{}", tenant_config.get_schema(), config.1);
@@ -118,6 +128,7 @@ where
drainer_num_partitions,
ttl_for_kv,
soft_kill_mode,
+ key_manager_state,
))
}
fn get_master_pool(&self) -> &PgPool {
@@ -149,6 +160,7 @@ impl<T: DatabaseStore> KVRouterStore<T> {
drainer_num_partitions: u8,
ttl_for_kv: u32,
soft_kill: Option<bool>,
+ key_manager_state: Option<KeyManagerState>,
) -> Self {
let request_id = store.request_id.clone();
@@ -159,6 +171,7 @@ impl<T: DatabaseStore> KVRouterStore<T> {
ttl_for_kv,
request_id,
soft_kill_mode: soft_kill.unwrap_or(false),
+ key_manager_state,
}
}
@@ -204,7 +217,6 @@ impl<T: DatabaseStore> KVRouterStore<T> {
pub async fn find_resource_by_id<D, R, M>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
find_resource_db_fut: R,
@@ -263,7 +275,8 @@ impl<T: DatabaseStore> KVRouterStore<T> {
res()
.await?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -273,7 +286,6 @@ impl<T: DatabaseStore> KVRouterStore<T> {
pub async fn find_optional_resource_by_id<D, R, M>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
find_resource_db_fut: R,
@@ -334,7 +346,8 @@ impl<T: DatabaseStore> KVRouterStore<T> {
Some(resource) => Ok(Some(
resource
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -347,7 +360,6 @@ impl<T: DatabaseStore> KVRouterStore<T> {
pub async fn insert_resource<D, R, M>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
create_resource_fut: R,
@@ -416,7 +428,8 @@ impl<T: DatabaseStore> KVRouterStore<T> {
}
}?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -426,7 +439,6 @@ impl<T: DatabaseStore> KVRouterStore<T> {
pub async fn update_resource<D, R, M>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
update_resource_fut: R,
@@ -482,7 +494,8 @@ impl<T: DatabaseStore> KVRouterStore<T> {
_ => Err(errors::StorageError::KVError.into()),
}?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -491,7 +504,6 @@ impl<T: DatabaseStore> KVRouterStore<T> {
}
pub async fn filter_resources<D, R, M>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
filter_resource_db_fut: R,
@@ -534,7 +546,8 @@ impl<T: DatabaseStore> KVRouterStore<T> {
.into_iter()
.map(|pm| async {
pm.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rs
index 691a010b1c..de48c8c5f8 100644
--- a/crates/storage_impl/src/lib.rs
+++ b/crates/storage_impl/src/lib.rs
@@ -56,6 +56,18 @@ pub struct RouterStore<T: DatabaseStore> {
cache_store: Arc<RedisStore>,
master_encryption_key: StrongSecret<Vec<u8>>,
pub request_id: Option<String>,
+ key_manager_state: Option<KeyManagerState>,
+}
+
+impl<T: DatabaseStore> RouterStore<T> {
+ pub fn set_key_manager_state(&mut self, state: KeyManagerState) {
+ self.key_manager_state = Some(state);
+ }
+ fn get_keymanager_state(&self) -> Result<&KeyManagerState, StorageError> {
+ self.key_manager_state
+ .as_ref()
+ .ok_or_else(|| StorageError::DecryptionError)
+ }
}
#[async_trait::async_trait]
@@ -74,13 +86,20 @@ where
config: Self::Config,
tenant_config: &dyn TenantConfig,
test_transaction: bool,
+ key_manager_state: Option<KeyManagerState>,
) -> error_stack::Result<Self, StorageError> {
let (db_conf, cache_conf, encryption_key, cache_error_signal, inmemory_cache_stream) =
config;
if test_transaction {
- Self::test_store(db_conf, tenant_config, &cache_conf, encryption_key)
- .await
- .attach_printable("failed to create test router store")
+ Self::test_store(
+ db_conf,
+ tenant_config,
+ &cache_conf,
+ encryption_key,
+ key_manager_state,
+ )
+ .await
+ .attach_printable("failed to create test router store")
} else {
Self::from_config(
db_conf,
@@ -88,6 +107,7 @@ where
encryption_key,
Self::cache_store(&cache_conf, cache_error_signal).await?,
inmemory_cache_stream,
+ key_manager_state,
)
.await
.attach_printable("failed to create store")
@@ -122,8 +142,9 @@ impl<T: DatabaseStore> RouterStore<T> {
encryption_key: StrongSecret<Vec<u8>>,
cache_store: Arc<RedisStore>,
inmemory_cache_stream: &str,
+ key_manager_state: Option<KeyManagerState>,
) -> error_stack::Result<Self, StorageError> {
- let db_store = T::new(db_conf, tenant_config, false).await?;
+ let db_store = T::new(db_conf, tenant_config, false, key_manager_state.clone()).await?;
let redis_conn = cache_store.redis_conn.clone();
let cache_store = Arc::new(RedisStore {
redis_conn: Arc::new(RedisConnectionPool::clone(
@@ -143,6 +164,7 @@ impl<T: DatabaseStore> RouterStore<T> {
cache_store,
master_encryption_key: encryption_key,
request_id: None,
+ key_manager_state,
})
}
@@ -164,7 +186,6 @@ impl<T: DatabaseStore> RouterStore<T> {
pub async fn call_database<D, R, M>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query: R,
) -> error_stack::Result<D, StorageError>
@@ -181,7 +202,8 @@ impl<T: DatabaseStore> RouterStore<T> {
error.change_context(new_err)
})?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -191,7 +213,6 @@ impl<T: DatabaseStore> RouterStore<T> {
pub async fn find_optional_resource<D, R, M>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query_fut: R,
) -> error_stack::Result<Option<D>, StorageError>
@@ -209,7 +230,8 @@ impl<T: DatabaseStore> RouterStore<T> {
Some(resource) => Ok(Some(
resource
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -222,7 +244,6 @@ impl<T: DatabaseStore> RouterStore<T> {
pub async fn find_resources<D, R, M>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query: R,
) -> error_stack::Result<Vec<D>, StorageError>
@@ -243,7 +264,8 @@ impl<T: DatabaseStore> RouterStore<T> {
.map(|resource| async {
resource
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -265,9 +287,10 @@ impl<T: DatabaseStore> RouterStore<T> {
tenant_config: &dyn TenantConfig,
cache_conf: &redis_interface::RedisSettings,
encryption_key: StrongSecret<Vec<u8>>,
+ key_manager_state: Option<KeyManagerState>,
) -> error_stack::Result<Self, StorageError> {
// TODO: create an error enum and return proper error here
- let db_store = T::new(db_conf, tenant_config, true).await?;
+ let db_store = T::new(db_conf, tenant_config, true, key_manager_state.clone()).await?;
let cache_store = RedisStore::new(cache_conf)
.await
.change_context(StorageError::InitializationError)
@@ -277,6 +300,7 @@ impl<T: DatabaseStore> RouterStore<T> {
cache_store: Arc::new(cache_store),
master_encryption_key: encryption_key,
request_id: None,
+ key_manager_state,
})
}
}
diff --git a/crates/storage_impl/src/merchant_account.rs b/crates/storage_impl/src/merchant_account.rs
index 8462950cf6..250c44300d 100644
--- a/crates/storage_impl/src/merchant_account.rs
+++ b/crates/storage_impl/src/merchant_account.rs
@@ -24,7 +24,7 @@ use crate::{
kv_router_store,
store::MerchantAccountUpdateInternal,
utils::{pg_accounts_connection_read, pg_accounts_connection_write},
- CustomResult, DatabaseStore, KeyManagerState, MockDb, RouterStore, StorageError,
+ CustomResult, DatabaseStore, MockDb, RouterStore, StorageError,
};
#[async_trait::async_trait]
@@ -33,66 +33,56 @@ impl<T: DatabaseStore> MerchantAccountInterface for kv_router_store::KVRouterSto
#[instrument(skip_all)]
async fn insert_merchant(
&self,
- state: &KeyManagerState,
merchant_account: domain::MerchantAccount,
merchant_key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, StorageError> {
self.router_store
- .insert_merchant(state, merchant_account, merchant_key_store)
+ .insert_merchant(merchant_account, merchant_key_store)
.await
}
#[instrument(skip_all)]
async fn find_merchant_account_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, StorageError> {
self.router_store
- .find_merchant_account_by_merchant_id(state, merchant_id, merchant_key_store)
+ .find_merchant_account_by_merchant_id(merchant_id, merchant_key_store)
.await
}
#[instrument(skip_all)]
async fn update_merchant(
&self,
- state: &KeyManagerState,
this: domain::MerchantAccount,
merchant_account: domain::MerchantAccountUpdate,
merchant_key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, StorageError> {
self.router_store
- .update_merchant(state, this, merchant_account, merchant_key_store)
+ .update_merchant(this, merchant_account, merchant_key_store)
.await
}
#[instrument(skip_all)]
async fn update_specific_fields_in_merchant(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_account: domain::MerchantAccountUpdate,
merchant_key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, StorageError> {
self.router_store
- .update_specific_fields_in_merchant(
- state,
- merchant_id,
- merchant_account,
- merchant_key_store,
- )
+ .update_specific_fields_in_merchant(merchant_id, merchant_account, merchant_key_store)
.await
}
#[instrument(skip_all)]
async fn find_merchant_account_by_publishable_key(
&self,
- state: &KeyManagerState,
publishable_key: &str,
) -> CustomResult<(domain::MerchantAccount, MerchantKeyStore), StorageError> {
self.router_store
- .find_merchant_account_by_publishable_key(state, publishable_key)
+ .find_merchant_account_by_publishable_key(publishable_key)
.await
}
@@ -100,11 +90,10 @@ impl<T: DatabaseStore> MerchantAccountInterface for kv_router_store::KVRouterSto
#[instrument(skip_all)]
async fn list_merchant_accounts_by_organization_id(
&self,
- state: &KeyManagerState,
organization_id: &common_utils::id_type::OrganizationId,
) -> CustomResult<Vec<domain::MerchantAccount>, StorageError> {
self.router_store
- .list_merchant_accounts_by_organization_id(state, organization_id)
+ .list_merchant_accounts_by_organization_id(organization_id)
.await
}
@@ -122,11 +111,10 @@ impl<T: DatabaseStore> MerchantAccountInterface for kv_router_store::KVRouterSto
#[instrument(skip_all)]
async fn list_multiple_merchant_accounts(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
) -> CustomResult<Vec<domain::MerchantAccount>, StorageError> {
self.router_store
- .list_multiple_merchant_accounts(state, merchant_ids)
+ .list_multiple_merchant_accounts(merchant_ids)
.await
}
@@ -134,7 +122,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for kv_router_store::KVRouterSto
#[instrument(skip_all)]
async fn list_merchant_and_org_ids(
&self,
- _state: &KeyManagerState,
limit: u32,
offset: Option<u32>,
) -> CustomResult<
@@ -145,7 +132,7 @@ impl<T: DatabaseStore> MerchantAccountInterface for kv_router_store::KVRouterSto
StorageError,
> {
self.router_store
- .list_merchant_and_org_ids(_state, limit, offset)
+ .list_merchant_and_org_ids(limit, offset)
.await
}
@@ -165,7 +152,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_merchant(
&self,
- state: &KeyManagerState,
merchant_account: domain::MerchantAccount,
merchant_key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, StorageError> {
@@ -178,7 +164,8 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
.await
.map_err(|error| report!(StorageError::from(error)))?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -189,7 +176,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_merchant_account_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, StorageError> {
@@ -199,6 +185,9 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
.await
.map_err(|error| report!(StorageError::from(error)))
};
+ let state = self
+ .get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?;
#[cfg(not(feature = "accounts_cache"))]
{
@@ -235,7 +224,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_merchant(
&self,
- state: &KeyManagerState,
this: domain::MerchantAccount,
merchant_account: domain::MerchantAccountUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -255,7 +243,8 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
}
updated_merchant_account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -266,7 +255,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_specific_fields_in_merchant(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_account: domain::MerchantAccountUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -286,7 +274,8 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
}
updated_merchant_account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -297,7 +286,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_merchant_account_by_publishable_key(
&self,
- state: &KeyManagerState,
publishable_key: &str,
) -> CustomResult<(domain::MerchantAccount, MerchantKeyStore), StorageError> {
let fetch_by_pub_key_func = || async {
@@ -326,14 +314,14 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
}
let key_store = self
.get_merchant_key_store_by_merchant_id(
- state,
merchant_account.get_id(),
&self.master_key().peek().to_vec().into(),
)
.await?;
let domain_merchant_account = merchant_account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -346,7 +334,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn list_merchant_accounts_by_organization_id(
&self,
- state: &KeyManagerState,
organization_id: &common_utils::id_type::OrganizationId,
) -> CustomResult<Vec<domain::MerchantAccount>, StorageError> {
use futures::future::try_join_all;
@@ -358,11 +345,9 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
.map_err(|error| report!(StorageError::from(error)))?;
let db_master_key = self.master_key().peek().to_vec().into();
-
let merchant_key_stores =
try_join_all(encrypted_merchant_accounts.iter().map(|merchant_account| {
self.get_merchant_key_store_by_merchant_id(
- state,
merchant_account.get_id(),
&db_master_key,
)
@@ -376,7 +361,8 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
.map(|(merchant_account, key_store)| async {
merchant_account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -428,7 +414,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn list_multiple_merchant_accounts(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
) -> CustomResult<Vec<domain::MerchantAccount>, StorageError> {
let conn = pg_accounts_connection_read(self).await?;
@@ -442,7 +427,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
let merchant_key_stores = self
.list_multiple_key_stores(
- state,
encrypted_merchant_accounts
.iter()
.map(|merchant_account| merchant_account.get_id())
@@ -468,7 +452,8 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
)?;
merchant_account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -485,7 +470,6 @@ impl<T: DatabaseStore> MerchantAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn list_merchant_and_org_ids(
&self,
- _state: &KeyManagerState,
limit: u32,
offset: Option<u32>,
) -> CustomResult<
@@ -551,7 +535,6 @@ impl MerchantAccountInterface for MockDb {
#[allow(clippy::panic)]
async fn insert_merchant(
&self,
- state: &KeyManagerState,
merchant_account: domain::MerchantAccount,
merchant_key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, StorageError> {
@@ -563,7 +546,8 @@ impl MerchantAccountInterface for MockDb {
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -574,7 +558,6 @@ impl MerchantAccountInterface for MockDb {
#[allow(clippy::panic)]
async fn find_merchant_account_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantAccount, StorageError> {
@@ -587,7 +570,8 @@ impl MerchantAccountInterface for MockDb {
"Merchant ID: {merchant_id:?} not found",
)))?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -597,7 +581,6 @@ impl MerchantAccountInterface for MockDb {
async fn update_merchant(
&self,
- state: &KeyManagerState,
merchant_account: domain::MerchantAccount,
merchant_account_update: domain::MerchantAccountUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -617,7 +600,8 @@ impl MerchantAccountInterface for MockDb {
*account = update.clone();
update
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -634,7 +618,6 @@ impl MerchantAccountInterface for MockDb {
async fn update_specific_fields_in_merchant(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_account_update: domain::MerchantAccountUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -649,7 +632,8 @@ impl MerchantAccountInterface for MockDb {
*account = update.clone();
update
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -666,7 +650,6 @@ impl MerchantAccountInterface for MockDb {
async fn find_merchant_account_by_publishable_key(
&self,
- state: &KeyManagerState,
publishable_key: &str,
) -> CustomResult<(domain::MerchantAccount, MerchantKeyStore), StorageError> {
let accounts = self.merchant_accounts.lock().await;
@@ -683,7 +666,6 @@ impl MerchantAccountInterface for MockDb {
)))?;
let key_store = self
.get_merchant_key_store_by_merchant_id(
- state,
account.get_id(),
&self.get_master_key().to_vec().into(),
)
@@ -691,7 +673,8 @@ impl MerchantAccountInterface for MockDb {
let merchant_account = account
.clone()
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -725,7 +708,6 @@ impl MerchantAccountInterface for MockDb {
#[cfg(feature = "olap")]
async fn list_merchant_accounts_by_organization_id(
&self,
- state: &KeyManagerState,
organization_id: &common_utils::id_type::OrganizationId,
) -> CustomResult<Vec<domain::MerchantAccount>, StorageError> {
let accounts = self.merchant_accounts.lock().await;
@@ -735,7 +717,6 @@ impl MerchantAccountInterface for MockDb {
.map(|account| async {
let key_store = self
.get_merchant_key_store_by_merchant_id(
- state,
account.get_id(),
&self.get_master_key().to_vec().into(),
)
@@ -743,7 +724,12 @@ impl MerchantAccountInterface for MockDb {
match key_store {
Ok(key) => account
.clone()
- .convert(state, key.key.get_inner(), key.merchant_id.clone().into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key.key.get_inner(),
+ key.merchant_id.clone().into(),
+ )
.await
.change_context(StorageError::DecryptionError),
Err(err) => Err(err),
@@ -758,7 +744,6 @@ impl MerchantAccountInterface for MockDb {
#[cfg(feature = "olap")]
async fn list_multiple_merchant_accounts(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
) -> CustomResult<Vec<domain::MerchantAccount>, StorageError> {
let accounts = self.merchant_accounts.lock().await;
@@ -768,7 +753,6 @@ impl MerchantAccountInterface for MockDb {
.map(|account| async {
let key_store = self
.get_merchant_key_store_by_merchant_id(
- state,
account.get_id(),
&self.get_master_key().to_vec().into(),
)
@@ -776,7 +760,12 @@ impl MerchantAccountInterface for MockDb {
match key_store {
Ok(key) => account
.clone()
- .convert(state, key.key.get_inner(), key.merchant_id.clone().into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key.key.get_inner(),
+ key.merchant_id.clone().into(),
+ )
.await
.change_context(StorageError::DecryptionError),
Err(err) => Err(err),
@@ -791,7 +780,6 @@ impl MerchantAccountInterface for MockDb {
#[cfg(feature = "olap")]
async fn list_merchant_and_org_ids(
&self,
- _state: &KeyManagerState,
limit: u32,
offset: Option<u32>,
) -> CustomResult<
diff --git a/crates/storage_impl/src/merchant_connector_account.rs b/crates/storage_impl/src/merchant_connector_account.rs
index 20525b28ed..dd3e464987 100644
--- a/crates/storage_impl/src/merchant_connector_account.rs
+++ b/crates/storage_impl/src/merchant_connector_account.rs
@@ -14,7 +14,7 @@ use crate::redis::cache;
use crate::{
kv_router_store,
utils::{pg_accounts_connection_read, pg_accounts_connection_write},
- CustomResult, DatabaseStore, KeyManagerState, MockDb, RouterStore, StorageError,
+ CustomResult, DatabaseStore, MockDb, RouterStore, StorageError,
};
#[async_trait::async_trait]
@@ -24,14 +24,12 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for kv_router_store::KV
#[instrument(skip_all)]
async fn find_merchant_connector_account_by_merchant_id_connector_label(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
connector_label: &str,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
self.router_store
.find_merchant_connector_account_by_merchant_id_connector_label(
- state,
merchant_id,
connector_label,
key_store,
@@ -43,14 +41,12 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for kv_router_store::KV
#[instrument(skip_all)]
async fn find_merchant_connector_account_by_profile_id_connector_name(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
connector_name: &str,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
self.router_store
.find_merchant_connector_account_by_profile_id_connector_name(
- state,
profile_id,
connector_name,
key_store,
@@ -62,14 +58,12 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for kv_router_store::KV
#[instrument(skip_all)]
async fn find_merchant_connector_account_by_merchant_id_connector_name(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
connector_name: &str,
key_store: &MerchantKeyStore,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, Self::Error> {
self.router_store
.find_merchant_connector_account_by_merchant_id_connector_name(
- state,
merchant_id,
connector_name,
key_store,
@@ -81,14 +75,12 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for kv_router_store::KV
#[cfg(feature = "v1")]
async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_connector_id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
self.router_store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- state,
merchant_id,
merchant_connector_id,
key_store,
@@ -100,55 +92,45 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for kv_router_store::KV
#[cfg(feature = "v2")]
async fn find_merchant_connector_account_by_id(
&self,
- state: &KeyManagerState,
id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
self.router_store
- .find_merchant_connector_account_by_id(state, id, key_store)
+ .find_merchant_connector_account_by_id(id, key_store)
.await
}
#[instrument(skip_all)]
async fn insert_merchant_connector_account(
&self,
- state: &KeyManagerState,
t: domain::MerchantConnectorAccount,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
self.router_store
- .insert_merchant_connector_account(state, t, key_store)
+ .insert_merchant_connector_account(t, key_store)
.await
}
async fn list_enabled_connector_accounts_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
key_store: &MerchantKeyStore,
connector_type: common_enums::ConnectorType,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, Self::Error> {
self.router_store
- .list_enabled_connector_accounts_by_profile_id(
- state,
- profile_id,
- key_store,
- connector_type,
- )
+ .list_enabled_connector_accounts_by_profile_id(profile_id, key_store, connector_type)
.await
}
#[instrument(skip_all)]
async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
get_disabled: bool,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccounts, Self::Error> {
self.router_store
.find_merchant_connector_account_by_merchant_id_and_disabled_list(
- state,
merchant_id,
get_disabled,
key_store,
@@ -160,12 +142,11 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for kv_router_store::KV
#[cfg(all(feature = "olap", feature = "v2"))]
async fn list_connector_account_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
key_store: &MerchantKeyStore,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, Self::Error> {
self.router_store
- .list_connector_account_by_profile_id(state, profile_id, key_store)
+ .list_connector_account_by_profile_id(profile_id, key_store)
.await
}
@@ -186,13 +167,12 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for kv_router_store::KV
#[cfg(feature = "v1")]
async fn update_merchant_connector_account(
&self,
- state: &KeyManagerState,
this: domain::MerchantConnectorAccount,
merchant_connector_account: storage::MerchantConnectorAccountUpdateInternal,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
self.router_store
- .update_merchant_connector_account(state, this, merchant_connector_account, key_store)
+ .update_merchant_connector_account(this, merchant_connector_account, key_store)
.await
}
@@ -200,13 +180,12 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for kv_router_store::KV
#[cfg(feature = "v2")]
async fn update_merchant_connector_account(
&self,
- state: &KeyManagerState,
this: domain::MerchantConnectorAccount,
merchant_connector_account: storage::MerchantConnectorAccountUpdateInternal,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
self.router_store
- .update_merchant_connector_account(state, this, merchant_connector_account, key_store)
+ .update_merchant_connector_account(this, merchant_connector_account, key_store)
.await
}
@@ -244,7 +223,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_merchant_connector_account_by_merchant_id_connector_label(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
connector_label: &str,
key_store: &MerchantKeyStore,
@@ -264,7 +242,12 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
{
find_call()
.await?
- .convert(state, key_store.key.get_inner(), merchant_id.clone().into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key_store.key.get_inner(),
+ merchant_id.clone().into(),
+ )
.await
.change_context(Self::Error::DeserializationFailed)
}
@@ -280,7 +263,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
.await
.async_and_then(|item| async {
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -295,7 +279,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_merchant_connector_account_by_profile_id_connector_name(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
connector_name: &str,
key_store: &MerchantKeyStore,
@@ -316,7 +299,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
find_call()
.await?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -335,7 +319,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
.await
.async_and_then(|item| async {
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -350,7 +335,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_merchant_connector_account_by_merchant_id_connector_name(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
connector_name: &str,
key_store: &MerchantKeyStore,
@@ -368,7 +352,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
for item in items.into_iter() {
output.push(
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -385,7 +370,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[cfg(feature = "v1")]
async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_connector_id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
@@ -406,7 +390,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
find_call()
.await?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -428,7 +413,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
)
.await?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -441,7 +427,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[cfg(feature = "v2")]
async fn find_merchant_connector_account_by_id(
&self,
- state: &KeyManagerState,
id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
@@ -457,7 +442,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
find_call()
.await?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone(),
)
@@ -475,7 +461,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
)
.await?
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
@@ -489,7 +476,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_merchant_connector_account(
&self,
- state: &KeyManagerState,
t: domain::MerchantConnectorAccount,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, Self::Error> {
@@ -502,7 +488,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
.map_err(|error| report!(Self::Error::from(error)))
.async_and_then(|item| async {
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -514,7 +501,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
async fn list_enabled_connector_accounts_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
key_store: &MerchantKeyStore,
connector_type: common_enums::ConnectorType,
@@ -533,7 +519,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
for item in items.into_iter() {
output.push(
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -549,7 +536,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
get_disabled: bool,
key_store: &MerchantKeyStore,
@@ -568,7 +554,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
for item in items.into_iter() {
output.push(
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -588,7 +575,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[cfg(all(feature = "olap", feature = "v2"))]
async fn list_connector_account_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
key_store: &MerchantKeyStore,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, Self::Error> {
@@ -601,7 +587,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
for item in items.into_iter() {
output.push(
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -728,7 +715,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[cfg(feature = "v1")]
async fn update_merchant_connector_account(
&self,
- state: &KeyManagerState,
this: domain::MerchantConnectorAccount,
merchant_connector_account: storage::MerchantConnectorAccountUpdateInternal,
key_store: &MerchantKeyStore,
@@ -749,7 +735,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
.map_err(|error| report!(Self::Error::from(error)))
.async_and_then(|item| async {
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -808,7 +795,6 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
#[cfg(feature = "v2")]
async fn update_merchant_connector_account(
&self,
- state: &KeyManagerState,
this: domain::MerchantConnectorAccount,
merchant_connector_account: storage::MerchantConnectorAccountUpdateInternal,
key_store: &MerchantKeyStore,
@@ -829,7 +815,8 @@ impl<T: DatabaseStore> MerchantConnectorAccountInterface for RouterStore<T> {
.map_err(|error| report!(Self::Error::from(error)))
.async_and_then(|item| async {
item.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
@@ -1040,7 +1027,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_merchant_id_connector_label(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
connector: &str,
key_store: &MerchantKeyStore,
@@ -1058,7 +1044,8 @@ impl MerchantConnectorAccountInterface for MockDb {
.async_map(|account| async {
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -1079,7 +1066,6 @@ impl MerchantConnectorAccountInterface for MockDb {
async fn list_enabled_connector_accounts_by_profile_id(
&self,
- _state: &KeyManagerState,
_profile_id: &common_utils::id_type::ProfileId,
_key_store: &MerchantKeyStore,
_connector_type: common_enums::ConnectorType,
@@ -1090,7 +1076,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_merchant_id_connector_name(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
connector_name: &str,
key_store: &MerchantKeyStore,
@@ -1110,7 +1095,8 @@ impl MerchantConnectorAccountInterface for MockDb {
output.push(
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -1124,7 +1110,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_merchant_connector_account_by_profile_id_connector_name(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
connector_name: &str,
key_store: &MerchantKeyStore,
@@ -1144,7 +1129,8 @@ impl MerchantConnectorAccountInterface for MockDb {
Some(mca) => mca
.to_owned()
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -1160,7 +1146,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_connector_id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
@@ -1178,7 +1163,8 @@ impl MerchantConnectorAccountInterface for MockDb {
.async_map(|account| async {
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -1200,7 +1186,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_merchant_connector_account_by_id(
&self,
- state: &KeyManagerState,
id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, StorageError> {
@@ -1214,7 +1199,8 @@ impl MerchantConnectorAccountInterface for MockDb {
.async_map(|account| async {
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
@@ -1238,7 +1224,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v1")]
async fn insert_merchant_connector_account(
&self,
- state: &KeyManagerState,
t: domain::MerchantConnectorAccount,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, StorageError> {
@@ -1274,7 +1259,8 @@ impl MerchantConnectorAccountInterface for MockDb {
accounts.push(account.clone());
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -1285,7 +1271,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v2")]
async fn insert_merchant_connector_account(
&self,
- state: &KeyManagerState,
t: domain::MerchantConnectorAccount,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, StorageError> {
@@ -1316,7 +1301,8 @@ impl MerchantConnectorAccountInterface for MockDb {
accounts.push(account.clone());
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
@@ -1328,7 +1314,6 @@ impl MerchantConnectorAccountInterface for MockDb {
async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
get_disabled: bool,
key_store: &MerchantKeyStore,
@@ -1353,7 +1338,8 @@ impl MerchantConnectorAccountInterface for MockDb {
output.push(
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -1367,7 +1353,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(all(feature = "olap", feature = "v2"))]
async fn list_connector_account_by_profile_id(
&self,
- state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
key_store: &MerchantKeyStore,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, StorageError> {
@@ -1387,7 +1372,8 @@ impl MerchantConnectorAccountInterface for MockDb {
output.push(
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -1401,7 +1387,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v1")]
async fn update_merchant_connector_account(
&self,
- state: &KeyManagerState,
this: domain::MerchantConnectorAccount,
merchant_connector_account: storage::MerchantConnectorAccountUpdateInternal,
key_store: &MerchantKeyStore,
@@ -1421,7 +1406,8 @@ impl MerchantConnectorAccountInterface for MockDb {
.async_map(|account| async {
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -1444,7 +1430,6 @@ impl MerchantConnectorAccountInterface for MockDb {
#[cfg(feature = "v2")]
async fn update_merchant_connector_account(
&self,
- state: &KeyManagerState,
this: domain::MerchantConnectorAccount,
merchant_connector_account: storage::MerchantConnectorAccountUpdateInternal,
key_store: &MerchantKeyStore,
@@ -1464,7 +1449,8 @@ impl MerchantConnectorAccountInterface for MockDb {
.async_map(|account| async {
account
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
diff --git a/crates/storage_impl/src/merchant_key_store.rs b/crates/storage_impl/src/merchant_key_store.rs
index 36126460af..ebeb95d2f6 100644
--- a/crates/storage_impl/src/merchant_key_store.rs
+++ b/crates/storage_impl/src/merchant_key_store.rs
@@ -15,7 +15,7 @@ use crate::redis::{
use crate::{
kv_router_store,
utils::{pg_accounts_connection_read, pg_accounts_connection_write},
- CustomResult, DatabaseStore, KeyManagerState, MockDb, RouterStore, StorageError,
+ CustomResult, DatabaseStore, MockDb, RouterStore, StorageError,
};
#[async_trait::async_trait]
@@ -24,24 +24,22 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for kv_router_store::KVRouterSt
#[instrument(skip_all)]
async fn insert_merchant_key_store(
&self,
- state: &KeyManagerState,
merchant_key_store: domain::MerchantKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, Self::Error> {
self.router_store
- .insert_merchant_key_store(state, merchant_key_store, key)
+ .insert_merchant_key_store(merchant_key_store, key)
.await
}
#[instrument(skip_all)]
async fn get_merchant_key_store_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, Self::Error> {
self.router_store
- .get_merchant_key_store_by_merchant_id(state, merchant_id, key)
+ .get_merchant_key_store_by_merchant_id(merchant_id, key)
.await
}
@@ -59,25 +57,21 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for kv_router_store::KVRouterSt
#[instrument(skip_all)]
async fn list_multiple_key_stores(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
key: &Secret<Vec<u8>>,
) -> CustomResult<Vec<domain::MerchantKeyStore>, Self::Error> {
self.router_store
- .list_multiple_key_stores(state, merchant_ids, key)
+ .list_multiple_key_stores(merchant_ids, key)
.await
}
async fn get_all_key_stores(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
from: u32,
to: u32,
) -> CustomResult<Vec<domain::MerchantKeyStore>, Self::Error> {
- self.router_store
- .get_all_key_stores(state, key, from, to)
- .await
+ self.router_store.get_all_key_stores(key, from, to).await
}
}
@@ -87,7 +81,6 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_merchant_key_store(
&self,
- state: &KeyManagerState,
merchant_key_store: domain::MerchantKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, Self::Error> {
@@ -100,7 +93,12 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for RouterStore<T> {
.insert(&conn)
.await
.map_err(|error| report!(Self::Error::from(error)))?
- .convert(state, key, merchant_id.into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ merchant_id.into(),
+ )
.await
.change_context(Self::Error::DecryptionError)
}
@@ -108,7 +106,6 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn get_merchant_key_store_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, Self::Error> {
@@ -122,6 +119,9 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for RouterStore<T> {
.await
.map_err(|error| report!(Self::Error::from(error)))
};
+ let state = self
+ .get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?;
#[cfg(not(feature = "accounts_cache"))]
{
@@ -186,7 +186,6 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn list_multiple_key_stores(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
key: &Secret<Vec<u8>>,
) -> CustomResult<Vec<domain::MerchantKeyStore>, Self::Error> {
@@ -204,7 +203,12 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for RouterStore<T> {
futures::future::try_join_all(fetch_func().await?.into_iter().map(|key_store| async {
let merchant_id = key_store.merchant_id.clone();
key_store
- .convert(state, key, merchant_id.into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ merchant_id.into(),
+ )
.await
.change_context(Self::Error::DecryptionError)
}))
@@ -213,7 +217,6 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for RouterStore<T> {
async fn get_all_key_stores(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
from: u32,
to: u32,
@@ -228,7 +231,12 @@ impl<T: DatabaseStore> MerchantKeyStoreInterface for RouterStore<T> {
futures::future::try_join_all(stores.into_iter().map(|key_store| async {
let merchant_id = key_store.merchant_id.clone();
key_store
- .convert(state, key, merchant_id.into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ merchant_id.into(),
+ )
.await
.change_context(Self::Error::DecryptionError)
}))
@@ -241,7 +249,6 @@ impl MerchantKeyStoreInterface for MockDb {
type Error = StorageError;
async fn insert_merchant_key_store(
&self,
- state: &KeyManagerState,
merchant_key_store: domain::MerchantKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, Self::Error> {
@@ -263,14 +270,18 @@ impl MerchantKeyStoreInterface for MockDb {
locked_merchant_key_store.push(merchant_key.clone());
let merchant_id = merchant_key.merchant_id.clone();
merchant_key
- .convert(state, key, merchant_id.into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ merchant_id.into(),
+ )
.await
.change_context(StorageError::DecryptionError)
}
async fn get_merchant_key_store_by_merchant_id(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, StorageError> {
@@ -283,7 +294,12 @@ impl MerchantKeyStoreInterface for MockDb {
.ok_or(StorageError::ValueNotFound(String::from(
"merchant_key_store",
)))?
- .convert(state, key, merchant_id.clone().into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ merchant_id.clone().into(),
+ )
.await
.change_context(StorageError::DecryptionError)
}
@@ -306,7 +322,6 @@ impl MerchantKeyStoreInterface for MockDb {
#[cfg(feature = "olap")]
async fn list_multiple_key_stores(
&self,
- state: &KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
key: &Secret<Vec<u8>>,
) -> CustomResult<Vec<domain::MerchantKeyStore>, StorageError> {
@@ -318,7 +333,12 @@ impl MerchantKeyStoreInterface for MockDb {
.map(|merchant_key| async {
merchant_key
.to_owned()
- .convert(state, key, merchant_key.merchant_id.clone().into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ merchant_key.merchant_id.clone().into(),
+ )
.await
.change_context(StorageError::DecryptionError)
}),
@@ -327,7 +347,6 @@ impl MerchantKeyStoreInterface for MockDb {
}
async fn get_all_key_stores(
&self,
- state: &KeyManagerState,
key: &Secret<Vec<u8>>,
_from: u32,
_to: u32,
@@ -337,7 +356,12 @@ impl MerchantKeyStoreInterface for MockDb {
futures::future::try_join_all(merchant_key_stores.iter().map(|merchant_key| async {
merchant_key
.to_owned()
- .convert(state, key, merchant_key.merchant_id.clone().into())
+ .convert(
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
+ key,
+ merchant_key.merchant_id.clone().into(),
+ )
.await
.change_context(StorageError::DecryptionError)
}))
diff --git a/crates/storage_impl/src/mock_db.rs b/crates/storage_impl/src/mock_db.rs
index d7f78de500..3832211d2c 100644
--- a/crates/storage_impl/src/mock_db.rs
+++ b/crates/storage_impl/src/mock_db.rs
@@ -67,10 +67,19 @@ pub struct MockDb {
pub themes: Arc<Mutex<Vec<store::user::theme::Theme>>>,
pub hyperswitch_ai_interactions:
Arc<Mutex<Vec<store::hyperswitch_ai_interaction::HyperswitchAiInteraction>>>,
+ pub key_manager_state: Option<KeyManagerState>,
}
impl MockDb {
- pub async fn new(redis: &RedisSettings) -> error_stack::Result<Self, StorageError> {
+ pub fn get_keymanager_state(&self) -> Result<&KeyManagerState, StorageError> {
+ self.key_manager_state
+ .as_ref()
+ .ok_or(StorageError::DecryptionError)
+ }
+ pub async fn new(
+ redis: &RedisSettings,
+ key_manager_state: KeyManagerState,
+ ) -> error_stack::Result<Self, StorageError> {
Ok(Self {
addresses: Default::default(),
configs: Default::default(),
@@ -116,13 +125,13 @@ impl MockDb {
user_authentication_methods: Default::default(),
themes: Default::default(),
hyperswitch_ai_interactions: Default::default(),
+ key_manager_state: Some(key_manager_state),
})
}
/// Returns an option of the resource if it exists
pub async fn find_resource<D, R>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
resources: MutexGuard<'_, Vec<D>>,
filter_fn: impl Fn(&&D) -> bool,
@@ -135,7 +144,8 @@ impl MockDb {
match resource {
Some(res) => Ok(Some(
res.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -149,7 +159,6 @@ impl MockDb {
/// Throws errors when the requested resource is not found
pub async fn get_resource<D, R>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
resources: MutexGuard<'_, Vec<D>>,
filter_fn: impl Fn(&&D) -> bool,
@@ -159,10 +168,7 @@ impl MockDb {
D: Sync + ReverseConversion<R> + Clone,
R: Conversion,
{
- match self
- .find_resource(state, key_store, resources, filter_fn)
- .await?
- {
+ match self.find_resource(key_store, resources, filter_fn).await? {
Some(res) => Ok(res),
None => Err(StorageError::ValueNotFound(error_message).into()),
}
@@ -170,7 +176,6 @@ impl MockDb {
pub async fn get_resources<D, R>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
resources: MutexGuard<'_, Vec<D>>,
filter_fn: impl Fn(&&D) -> bool,
@@ -188,7 +193,8 @@ impl MockDb {
.into_iter()
.map(|pm| async {
pm.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -205,7 +211,6 @@ impl MockDb {
pub async fn update_resource<D, R>(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
mut resources: MutexGuard<'_, Vec<D>>,
resource_updated: D,
@@ -220,7 +225,8 @@ impl MockDb {
*pm = resource_updated.clone();
let result = resource_updated
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rs
index 19137a5fa2..a853d5d93b 100644
--- a/crates/storage_impl/src/mock_db/payment_attempt.rs
+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs
@@ -1,6 +1,6 @@
use common_utils::errors::CustomResult;
#[cfg(feature = "v2")]
-use common_utils::{id_type, types::keymanager::KeyManagerState};
+use common_utils::id_type;
use diesel_models::enums as storage_enums;
#[cfg(feature = "v2")]
use hyperswitch_domain_models::merchant_key_store::MerchantKeyStore;
@@ -90,7 +90,6 @@ impl PaymentAttemptInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_id(
&self,
- _key_manager_state: &KeyManagerState,
_merchant_key_store: &MerchantKeyStore,
_attempt_id: &id_type::GlobalAttemptId,
_storage_scheme: storage_enums::MerchantStorageScheme,
@@ -102,7 +101,6 @@ impl PaymentAttemptInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_attempts_by_payment_intent_id(
&self,
- _key_manager_state: &KeyManagerState,
_id: &id_type::GlobalPaymentId,
_merchant_key_store: &MerchantKeyStore,
_storage_scheme: common_enums::MerchantStorageScheme,
@@ -136,7 +134,6 @@ impl PaymentAttemptInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_profile_id_connector_transaction_id(
&self,
- _key_manager_state: &KeyManagerState,
_merchant_key_store: &MerchantKeyStore,
_profile_id: &id_type::ProfileId,
_connector_transaction_id: &str,
@@ -255,7 +252,6 @@ impl PaymentAttemptInterface for MockDb {
#[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,
@@ -292,7 +288,6 @@ impl PaymentAttemptInterface for MockDb {
#[cfg(feature = "v2")]
async fn update_payment_attempt(
&self,
- _key_manager_state: &KeyManagerState,
_merchant_key_store: &MerchantKeyStore,
_this: PaymentAttempt,
_payment_attempt: PaymentAttemptUpdate,
@@ -361,7 +356,6 @@ impl PaymentAttemptInterface for MockDb {
#[allow(clippy::unwrap_used)]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
&self,
- _key_manager_state: &KeyManagerState,
_merchant_key_store: &MerchantKeyStore,
payment_id: &id_type::GlobalPaymentId,
_storage_scheme: storage_enums::MerchantStorageScheme,
diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rs
index 427f69d895..ef7d5d558a 100644
--- a/crates/storage_impl/src/mock_db/payment_intent.rs
+++ b/crates/storage_impl/src/mock_db/payment_intent.rs
@@ -1,4 +1,4 @@
-use common_utils::{errors::CustomResult, types::keymanager::KeyManagerState};
+use common_utils::errors::CustomResult;
use diesel_models::enums as storage_enums;
#[cfg(feature = "v1")]
use error_stack::ResultExt;
@@ -21,7 +21,6 @@ impl PaymentIntentInterface for MockDb {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn filter_payment_intent_by_constraints(
&self,
- _state: &KeyManagerState,
_merchant_id: &common_utils::id_type::MerchantId,
_filters: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_key_store: &MerchantKeyStore,
@@ -34,7 +33,6 @@ impl PaymentIntentInterface for MockDb {
#[cfg(all(feature = "v2", feature = "olap"))]
async fn get_filtered_payment_intents_attempt(
&self,
- _state: &KeyManagerState,
_merchant_id: &common_utils::id_type::MerchantId,
_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_merchant_key_store: &MerchantKeyStore,
@@ -52,7 +50,6 @@ impl PaymentIntentInterface for MockDb {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn filter_payment_intents_by_time_range_constraints(
&self,
- _state: &KeyManagerState,
_merchant_id: &common_utils::id_type::MerchantId,
_time_range: &common_utils::types::TimeRange,
_key_store: &MerchantKeyStore,
@@ -98,7 +95,6 @@ impl PaymentIntentInterface for MockDb {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn get_filtered_payment_intents_attempt(
&self,
- _state: &KeyManagerState,
_merchant_id: &common_utils::id_type::MerchantId,
_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_key_store: &MerchantKeyStore,
@@ -117,7 +113,6 @@ impl PaymentIntentInterface for MockDb {
#[allow(clippy::panic)]
async fn insert_payment_intent(
&self,
- _state: &KeyManagerState,
new: PaymentIntent,
_key_store: &MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
@@ -132,7 +127,6 @@ impl PaymentIntentInterface for MockDb {
#[allow(clippy::unwrap_used)]
async fn update_payment_intent(
&self,
- state: &KeyManagerState,
this: PaymentIntent,
update: PaymentIntentUpdate,
key_store: &MerchantKeyStore,
@@ -152,7 +146,8 @@ impl PaymentIntentInterface for MockDb {
.change_context(StorageError::EncryptionError)?;
*payment_intent = PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent_update.apply_changeset(diesel_payment_intent),
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
@@ -168,7 +163,6 @@ impl PaymentIntentInterface for MockDb {
#[allow(clippy::unwrap_used)]
async fn update_payment_intent(
&self,
- _state: &KeyManagerState,
_this: PaymentIntent,
_update: PaymentIntentUpdate,
_key_store: &MerchantKeyStore,
@@ -182,7 +176,6 @@ impl PaymentIntentInterface for MockDb {
#[allow(clippy::unwrap_used)]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
- _state: &KeyManagerState,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
_key_store: &MerchantKeyStore,
@@ -202,7 +195,6 @@ impl PaymentIntentInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_intent_by_id(
&self,
- _state: &KeyManagerState,
id: &common_utils::id_type::GlobalPaymentId,
_merchant_key_store: &MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
@@ -220,7 +212,6 @@ impl PaymentIntentInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_intent_by_merchant_reference_id_profile_id(
&self,
- _state: &KeyManagerState,
merchant_reference_id: &common_utils::id_type::PaymentReferenceId,
profile_id: &common_utils::id_type::ProfileId,
_merchant_key_store: &MerchantKeyStore,
diff --git a/crates/storage_impl/src/payment_method.rs b/crates/storage_impl/src/payment_method.rs
index ed77ec5ba6..f2d3c43223 100644
--- a/crates/storage_impl/src/payment_method.rs
+++ b/crates/storage_impl/src/payment_method.rs
@@ -5,7 +5,7 @@ use crate::redis::kv_store::KvStorePartition;
impl KvStorePartition for PaymentMethod {}
use common_enums::enums::MerchantStorageScheme;
-use common_utils::{errors::CustomResult, id_type, types::keymanager::KeyManagerState};
+use common_utils::{errors::CustomResult, id_type};
#[cfg(feature = "v1")]
use diesel_models::kv;
use diesel_models::payment_method::{PaymentMethodUpdate, PaymentMethodUpdateInternal};
@@ -39,14 +39,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resource_by_id(
- state,
key_store,
storage_scheme,
PaymentMethod::find_by_payment_method_id(&conn, payment_method_id),
@@ -59,14 +57,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method_id: &id_type::GlobalPaymentMethodId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resource_by_id(
- state,
key_store,
storage_scheme,
PaymentMethod::find_by_id(&conn, payment_method_id),
@@ -82,14 +78,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_by_locker_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
locker_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resource_by_id(
- state,
key_store,
storage_scheme,
PaymentMethod::find_by_locker_id(&conn, locker_id),
@@ -131,13 +125,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn insert_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
self.router_store
- .insert_payment_method(state, key_store, payment_method, storage_scheme)
+ .insert_payment_method(key_store, payment_method, storage_scheme)
.await
}
@@ -145,7 +138,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn insert_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
storage_scheme: MerchantStorageScheme,
@@ -169,7 +161,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
}
let payment_method = (&payment_method_new.clone()).into();
self.insert_resource(
- state,
key_store,
storage_scheme,
payment_method_new.clone().insert(&conn),
@@ -189,7 +180,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
payment_method_update: PaymentMethodUpdate,
@@ -211,7 +201,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
payment_method_update.convert_to_payment_method_update(storage_scheme);
let updated_payment_method = p_update.clone().apply_changeset(payment_method.clone());
self.update_resource(
- state,
key_store,
storage_scheme,
payment_method
@@ -239,7 +228,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
payment_method_update: PaymentMethodUpdate,
@@ -247,7 +235,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
self.router_store
.update_payment_method(
- state,
key_store,
payment_method,
payment_method_update,
@@ -260,7 +247,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_by_customer_id_merchant_id_list(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -268,7 +254,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
self.router_store
.find_payment_method_by_customer_id_merchant_id_list(
- state,
key_store,
customer_id,
merchant_id,
@@ -280,13 +265,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[cfg(feature = "v2")]
async fn find_payment_method_list_by_global_customer_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::GlobalCustomerId,
limit: Option<i64>,
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
self.router_store
- .find_payment_method_list_by_global_customer_id(state, key_store, customer_id, limit)
+ .find_payment_method_list_by_global_customer_id(key_store, customer_id, limit)
.await
}
@@ -294,7 +278,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_by_customer_id_merchant_id_status(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -304,7 +287,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.filter_resources(
- state,
key_store,
storage_scheme,
PaymentMethod::find_by_customer_id_merchant_id_status(
@@ -331,7 +313,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_by_global_customer_id_merchant_id_status(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::GlobalCustomerId,
merchant_id: &id_type::MerchantId,
@@ -341,7 +322,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
self.router_store
.find_payment_method_by_global_customer_id_merchant_id_status(
- state,
key_store,
customer_id,
merchant_id,
@@ -355,14 +335,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[cfg(feature = "v1")]
async fn delete_payment_method_by_merchant_id_payment_method_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &id_type::MerchantId,
payment_method_id: &str,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
self.router_store
.delete_payment_method_by_merchant_id_payment_method_id(
- state,
key_store,
merchant_id,
payment_method_id,
@@ -374,12 +352,11 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[cfg(feature = "v2")]
async fn delete_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
self.router_store
- .delete_payment_method(state, key_store, payment_method)
+ .delete_payment_method(key_store, payment_method)
.await
}
@@ -387,12 +364,11 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
#[cfg(feature = "v2")]
async fn find_payment_method_by_fingerprint_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
fingerprint_id: &str,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
self.router_store
- .find_payment_method_by_fingerprint_id(state, key_store, fingerprint_id)
+ .find_payment_method_by_fingerprint_id(key_store, fingerprint_id)
.await
}
}
@@ -404,14 +380,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[cfg(feature = "v1")]
async fn find_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.call_database(
- state,
key_store,
PaymentMethod::find_by_payment_method_id(&conn, payment_method_id),
)
@@ -421,14 +395,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[cfg(feature = "v2")]
async fn find_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method_id: &id_type::GlobalPaymentMethodId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.call_database(
- state,
key_store,
PaymentMethod::find_by_id(&conn, payment_method_id),
)
@@ -439,14 +411,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_by_locker_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
locker_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.call_database(
- state,
key_store,
PaymentMethod::find_by_locker_id(&conn, locker_id),
)
@@ -493,7 +463,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
_storage_scheme: MerchantStorageScheme,
@@ -504,7 +473,7 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
.change_context(errors::StorageError::DecryptionError)?;
let conn = pg_connection_write(self).await?;
- self.call_database(state, key_store, payment_method_new.insert(&conn))
+ self.call_database(key_store, payment_method_new.insert(&conn))
.await
}
@@ -512,7 +481,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
payment_method_update: PaymentMethodUpdate,
@@ -524,7 +492,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
let conn = pg_connection_write(self).await?;
self.call_database(
- state,
key_store,
payment_method.update_with_payment_method_id(&conn, payment_method_update.into()),
)
@@ -535,7 +502,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
payment_method_update: PaymentMethodUpdate,
@@ -546,7 +512,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
.change_context(errors::StorageError::DecryptionError)?;
let conn = pg_connection_write(self).await?;
self.call_database(
- state,
key_store,
payment_method.update_with_id(&conn, payment_method_update.into()),
)
@@ -557,7 +522,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_by_customer_id_merchant_id_list(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -565,7 +529,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resources(
- state,
key_store,
PaymentMethod::find_by_customer_id_merchant_id(&conn, customer_id, merchant_id, limit),
)
@@ -577,14 +540,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_list_by_global_customer_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
id: &id_type::GlobalCustomerId,
limit: Option<i64>,
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resources(
- state,
key_store,
PaymentMethod::find_by_global_customer_id(&conn, id, limit),
)
@@ -595,7 +556,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_by_customer_id_merchant_id_status(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -605,7 +565,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resources(
- state,
key_store,
PaymentMethod::find_by_customer_id_merchant_id_status(
&conn,
@@ -622,7 +581,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_method_by_global_customer_id_merchant_id_status(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::GlobalCustomerId,
merchant_id: &id_type::MerchantId,
@@ -632,7 +590,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resources(
- state,
key_store,
PaymentMethod::find_by_global_customer_id_merchant_id_status(
&conn,
@@ -648,14 +605,12 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[cfg(feature = "v1")]
async fn delete_payment_method_by_merchant_id_payment_method_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &id_type::MerchantId,
payment_method_id: &str,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_write(self).await?;
self.call_database(
- state,
key_store,
PaymentMethod::delete_by_merchant_id_payment_method_id(
&conn,
@@ -669,7 +624,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[cfg(feature = "v2")]
async fn delete_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
@@ -682,7 +636,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
last_modified_by: None,
};
self.call_database(
- state,
key_store,
payment_method.update_with_id(&conn, payment_method_update.into()),
)
@@ -692,13 +645,11 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
#[cfg(feature = "v2")]
async fn find_payment_method_by_fingerprint_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
fingerprint_id: &str,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.call_database(
- state,
key_store,
PaymentMethod::find_by_fingerprint_id(&conn, fingerprint_id),
)
@@ -712,14 +663,12 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let payment_methods = self.payment_methods.lock().await;
self.get_resource::<PaymentMethod, _>(
- state,
key_store,
payment_methods,
|pm| pm.get_id() == payment_method_id,
@@ -731,14 +680,12 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method_id: &id_type::GlobalPaymentMethodId,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let payment_methods = self.payment_methods.lock().await;
self.get_resource::<PaymentMethod, _>(
- state,
key_store,
payment_methods,
|pm| pm.get_id() == payment_method_id,
@@ -750,14 +697,12 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_payment_method_by_locker_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
locker_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let payment_methods = self.payment_methods.lock().await;
self.get_resource::<PaymentMethod, _>(
- state,
key_store,
payment_methods,
|pm| pm.locker_id == Some(locker_id.to_string()),
@@ -800,7 +745,6 @@ impl PaymentMethodInterface for MockDb {
async fn insert_payment_method(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
_storage_scheme: MerchantStorageScheme,
@@ -818,7 +762,6 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_payment_method_by_customer_id_merchant_id_list(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -826,7 +769,6 @@ impl PaymentMethodInterface for MockDb {
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
let payment_methods = self.payment_methods.lock().await;
self.get_resources(
- state,
key_store,
payment_methods,
|pm| pm.customer_id == *customer_id && pm.merchant_id == *merchant_id,
@@ -839,7 +781,6 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_method_list_by_global_customer_id(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_id: &id_type::GlobalCustomerId,
_limit: Option<i64>,
@@ -850,7 +791,6 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v1")]
async fn find_payment_method_by_customer_id_merchant_id_status(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
@@ -860,7 +800,6 @@ impl PaymentMethodInterface for MockDb {
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {
let payment_methods = self.payment_methods.lock().await;
self.get_resources(
- state,
key_store,
payment_methods,
|pm| {
@@ -876,7 +815,6 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_method_by_global_customer_id_merchant_id_status(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
customer_id: &id_type::GlobalCustomerId,
merchant_id: &id_type::MerchantId,
@@ -889,14 +827,13 @@ impl PaymentMethodInterface for MockDb {
pm.customer_id == *customer_id && pm.merchant_id == *merchant_id && pm.status == status
};
let error_message = "cannot find payment method".to_string();
- self.get_resources(state, key_store, payment_methods, find_pm_by, error_message)
+ self.get_resources(key_store, payment_methods, find_pm_by, error_message)
.await
}
#[cfg(feature = "v1")]
async fn delete_payment_method_by_merchant_id_payment_method_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &id_type::MerchantId,
payment_method_id: &str,
@@ -910,7 +847,8 @@ impl PaymentMethodInterface for MockDb {
let deleted_payment_method = payment_methods.remove(index);
Ok(deleted_payment_method
.convert(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
@@ -926,7 +864,6 @@ impl PaymentMethodInterface for MockDb {
async fn update_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
payment_method_update: PaymentMethodUpdate,
@@ -939,7 +876,6 @@ impl PaymentMethodInterface for MockDb {
.change_context(errors::StorageError::EncryptionError)?,
);
self.update_resource::<PaymentMethod, _>(
- state,
key_store,
self.payment_methods.lock().await,
payment_method_updated,
@@ -952,7 +888,6 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v2")]
async fn delete_payment_method(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
@@ -967,7 +902,6 @@ impl PaymentMethodInterface for MockDb {
.change_context(errors::StorageError::EncryptionError)?,
);
self.update_resource::<PaymentMethod, _>(
- state,
key_store,
self.payment_methods.lock().await,
payment_method_updated,
@@ -980,13 +914,11 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_method_by_fingerprint_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
fingerprint_id: &str,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let payment_methods = self.payment_methods.lock().await;
self.get_resource::<PaymentMethod, _>(
- state,
key_store,
payment_methods,
|pm| pm.locker_fingerprint_id == Some(fingerprint_id.to_string()),
diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs
index 0b10a093b9..fe515d3e02 100644
--- a/crates/storage_impl/src/payments/payment_attempt.rs
+++ b/crates/storage_impl/src/payments/payment_attempt.rs
@@ -1,6 +1,4 @@
use common_utils::errors::CustomResult;
-#[cfg(feature = "v2")]
-use common_utils::types::keymanager::KeyManagerState;
#[cfg(feature = "v1")]
use common_utils::{
fallback_reverse_lookup_not_found,
@@ -76,7 +74,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_payment_attempt(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_attempt: PaymentAttempt,
_storage_scheme: MerchantStorageScheme,
@@ -93,7 +90,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
error.change_context(new_error)
})?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -124,7 +122,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_attempt(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
this: PaymentAttempt,
payment_attempt: PaymentAttemptUpdate,
@@ -145,7 +142,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
error.change_context(new_error)
})?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -225,7 +223,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_id: &common_utils::id_type::GlobalPaymentId,
_storage_scheme: MerchantStorageScheme,
@@ -240,7 +237,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
er.change_context(new_err)
})?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -274,7 +272,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_profile_id_connector_transaction_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
connector_txn_id: &str,
@@ -292,7 +289,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
er.change_context(new_err)
})?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -436,7 +434,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_by_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
attempt_id: &common_utils::id_type::GlobalAttemptId,
_storage_scheme: MerchantStorageScheme,
@@ -450,7 +447,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
er.change_context(new_err)
})?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -462,7 +460,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempts_by_payment_intent_id(
&self,
- key_manager_state: &KeyManagerState,
payment_id: &common_utils::id_type::GlobalPaymentId,
merchant_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
@@ -482,7 +479,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
domain_payment_attempts.push(
attempt
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -756,7 +754,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn insert_payment_attempt(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_attempt: PaymentAttempt,
storage_scheme: MerchantStorageScheme,
@@ -772,7 +769,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.insert_payment_attempt(
- key_manager_state,
merchant_key_store,
payment_attempt,
decided_storage_scheme,
@@ -983,7 +979,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_attempt(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
this: PaymentAttempt,
payment_attempt_update: PaymentAttemptUpdate,
@@ -1012,7 +1007,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
.update_with_attempt_id(&conn, payment_attempt_internal.clone());
Box::pin(self.update_resource(
- key_manager_state,
merchant_key_store,
storage_scheme,
updated_payment_attempt_with_id,
@@ -1216,7 +1210,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
payment_id: &common_utils::id_type::GlobalPaymentId,
storage_scheme: MerchantStorageScheme,
@@ -1224,7 +1217,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
let database_call = || {
self.router_store
.find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id(
- key_manager_state,
merchant_key_store,
payment_id,
storage_scheme,
@@ -1237,6 +1229,9 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
Op::Find,
))
.await;
+ let keymanager_state = self
+ .get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?;
match decided_storage_scheme {
MerchantStorageScheme::PostgresOnly => database_call().await,
@@ -1268,7 +1263,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
})?;
let merchant_id = payment_attempt.merchant_id.clone();
PaymentAttempt::convert_back(
- key_manager_state,
+ keymanager_state,
payment_attempt,
merchant_key_store.key.get_inner(),
merchant_id.into(),
@@ -1289,7 +1284,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[cfg(feature = "v2")]
async fn find_payment_attempt_by_profile_id_connector_transaction_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
connector_transaction_id: &str,
@@ -1297,7 +1291,6 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resource_by_id(
- key_manager_state,
merchant_key_store,
storage_scheme,
DieselPaymentAttempt::find_by_profile_id_connector_transaction_id(
@@ -1510,14 +1503,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempt_by_id(
&self,
- key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
attempt_id: &common_utils::id_type::GlobalAttemptId,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.find_resource_by_id(
- key_manager_state,
merchant_key_store,
storage_scheme,
DieselPaymentAttempt::find_by_id(&conn, attempt_id),
@@ -1530,14 +1521,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_attempts_by_payment_intent_id(
&self,
- key_manager_state: &KeyManagerState,
payment_id: &common_utils::id_type::GlobalPaymentId,
merchant_key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<Vec<PaymentAttempt>, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.filter_resources(
- key_manager_state,
merchant_key_store,
storage_scheme,
DieselPaymentAttempt::find_by_payment_id(&conn, payment_id),
diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs
index 4eb3fad60a..177cd2057b 100644
--- a/crates/storage_impl/src/payments/payment_intent.rs
+++ b/crates/storage_impl/src/payments/payment_intent.rs
@@ -2,12 +2,9 @@
use api_models::payments::{AmountFilter, Order, SortBy, SortOn};
#[cfg(feature = "olap")]
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
+use common_utils::ext_traits::{AsyncExt, Encode};
#[cfg(feature = "v2")]
use common_utils::fallback_reverse_lookup_not_found;
-use common_utils::{
- ext_traits::{AsyncExt, Encode},
- types::keymanager::KeyManagerState,
-};
#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
#[cfg(feature = "v1")]
@@ -68,7 +65,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[cfg(feature = "v1")]
async fn insert_payment_intent(
&self,
- state: &KeyManagerState,
payment_intent: PaymentIntent,
merchant_key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
@@ -89,12 +85,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
- .insert_payment_intent(
- state,
- payment_intent,
- merchant_key_store,
- storage_scheme,
- )
+ .insert_payment_intent(payment_intent, merchant_key_store, storage_scheme)
.await
}
@@ -148,7 +139,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[cfg(feature = "v2")]
async fn insert_payment_intent(
&self,
- state: &KeyManagerState,
payment_intent: PaymentIntent,
merchant_key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
@@ -156,12 +146,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
- .insert_payment_intent(
- state,
- payment_intent,
- merchant_key_store,
- storage_scheme,
- )
+ .insert_payment_intent(payment_intent, merchant_key_store, storage_scheme)
.await
}
@@ -236,7 +221,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn get_filtered_payment_intents_attempt(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
constraints: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
@@ -244,7 +228,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
) -> error_stack::Result<Vec<(PaymentIntent, Option<PaymentAttempt>)>, StorageError> {
self.router_store
.get_filtered_payment_intents_attempt(
- state,
merchant_id,
constraints,
merchant_key_store,
@@ -257,7 +240,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_intent(
&self,
- state: &KeyManagerState,
this: PaymentIntent,
payment_intent_update: PaymentIntentUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -280,7 +262,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.update_payment_intent(
- state,
this,
payment_intent_update,
merchant_key_store,
@@ -328,7 +309,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.change_context(StorageError::KVError)?;
let payment_intent = PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_intent,
merchant_key_store.key.get_inner(),
merchant_id.into(),
@@ -345,7 +327,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_intent(
&self,
- state: &KeyManagerState,
this: PaymentIntent,
payment_intent_update: PaymentIntentUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -355,7 +336,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.update_payment_intent(
- state,
this,
payment_intent_update,
merchant_key_store,
@@ -408,7 +388,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.change_context(StorageError::KVError)?;
let payment_intent = PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_intent,
merchant_key_store.key.get_inner(),
merchant_id.into(),
@@ -425,7 +406,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
- state: &KeyManagerState,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
merchant_key_store: &MerchantKeyStore,
@@ -472,7 +452,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
}?;
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_id.to_owned().into(),
@@ -485,7 +466,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_intent_by_id(
&self,
- state: &KeyManagerState,
id: &common_utils::id_type::GlobalPaymentId,
merchant_key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
@@ -536,7 +516,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
let merchant_id = diesel_payment_intent.merchant_id.clone();
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_id.into(),
@@ -548,7 +529,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn filter_payment_intent_by_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
filters: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
@@ -556,7 +536,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
self.router_store
.filter_payment_intent_by_constraints(
- state,
merchant_id,
filters,
merchant_key_store,
@@ -568,7 +547,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn filter_payment_intents_by_time_range_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
time_range: &common_utils::types::TimeRange,
merchant_key_store: &MerchantKeyStore,
@@ -576,7 +554,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
self.router_store
.filter_payment_intents_by_time_range_constraints(
- state,
merchant_id,
time_range,
merchant_key_store,
@@ -600,7 +577,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[cfg(all(feature = "v1", feature = "olap"))]
async fn get_filtered_payment_intents_attempt(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
filters: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
@@ -608,7 +584,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {
self.router_store
.get_filtered_payment_intents_attempt(
- state,
merchant_id,
filters,
merchant_key_store,
@@ -652,7 +627,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
#[cfg(feature = "v2")]
async fn find_payment_intent_by_merchant_reference_id_profile_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &common_utils::id_type::PaymentReferenceId,
profile_id: &common_utils::id_type::ProfileId,
merchant_key_store: &MerchantKeyStore,
@@ -662,7 +636,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.find_payment_intent_by_merchant_reference_id_profile_id(
- state,
merchant_reference_id,
profile_id,
merchant_key_store,
@@ -682,7 +655,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.await,
self.router_store
.find_payment_intent_by_merchant_reference_id_profile_id(
- state,
merchant_reference_id,
profile_id,
merchant_key_store,
@@ -726,7 +698,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
let merchant_id = diesel_payment_intent.merchant_id.clone();
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_id.into(),
@@ -744,7 +717,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn insert_payment_intent(
&self,
- state: &KeyManagerState,
payment_intent: PaymentIntent,
merchant_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
@@ -762,7 +734,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
})?;
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
@@ -775,7 +748,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_intent(
&self,
- state: &KeyManagerState,
this: PaymentIntent,
payment_intent: PaymentIntentUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -796,7 +768,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
})?;
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
@@ -809,7 +782,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn update_payment_intent(
&self,
- state: &KeyManagerState,
this: PaymentIntent,
payment_intent: PaymentIntentUpdate,
merchant_key_store: &MerchantKeyStore,
@@ -830,7 +802,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
})?;
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
@@ -843,7 +816,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_intent_by_payment_id_merchant_id(
&self,
- state: &KeyManagerState,
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
merchant_key_store: &MerchantKeyStore,
@@ -859,7 +831,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
})
.async_and_then(|diesel_payment_intent| async {
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
@@ -874,7 +847,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_intent_by_id(
&self,
- state: &KeyManagerState,
id: &common_utils::id_type::GlobalPaymentId,
merchant_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
@@ -890,7 +862,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
let merchant_id = diesel_payment_intent.merchant_id.clone();
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_id.to_owned().into(),
@@ -903,7 +876,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn find_payment_intent_by_merchant_reference_id_profile_id(
&self,
- state: &KeyManagerState,
merchant_reference_id: &common_utils::id_type::PaymentReferenceId,
profile_id: &common_utils::id_type::ProfileId,
merchant_key_store: &MerchantKeyStore,
@@ -923,7 +895,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
let merchant_id = diesel_payment_intent.merchant_id.clone();
PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_id.to_owned().into(),
@@ -936,7 +909,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn filter_payment_intent_by_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
filters: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
@@ -976,7 +948,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
// TODO: Fetch partial columns for this query since we only need some columns
let starting_at = self
.find_payment_intent_by_payment_id_merchant_id(
- state,
starting_after_id,
merchant_id,
merchant_key_store,
@@ -995,7 +966,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
// TODO: Fetch partial columns for this query since we only need some columns
let ending_at = self
.find_payment_intent_by_payment_id_merchant_id(
- state,
ending_before_id,
merchant_id,
merchant_key_store,
@@ -1029,9 +999,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
}
}
}
-
+ let keymanager_state = self
+ .get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?;
logger::debug!(query = %diesel::debug_query::<diesel::pg::Pg,_>(&query).to_string());
-
db_metrics::track_database_call::<<DieselPaymentIntent as HasTable>::Table, _, _>(
query.get_results_async::<DieselPaymentIntent>(conn),
db_metrics::DatabaseOperation::Filter,
@@ -1040,7 +1011,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.map(|payment_intents| {
try_join_all(payment_intents.into_iter().map(|diesel_payment_intent| {
PaymentIntent::convert_back(
- state,
+ keymanager_state,
diesel_payment_intent,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
@@ -1061,7 +1032,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn filter_payment_intents_by_time_range_constraints(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
time_range: &common_utils::types::TimeRange,
merchant_key_store: &MerchantKeyStore,
@@ -1070,7 +1040,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
// TODO: Remove this redundant function
let payment_filters = (*time_range).into();
self.filter_payment_intent_by_constraints(
- state,
merchant_id,
&payment_filters,
merchant_key_store,
@@ -1127,7 +1096,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn get_filtered_payment_intents_attempt(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
constraints: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
@@ -1195,7 +1163,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
// TODO: Fetch partial columns for this query since we only need some columns
let starting_at = self
.find_payment_intent_by_payment_id_merchant_id(
- state,
starting_after_id,
merchant_id,
merchant_key_store,
@@ -1214,7 +1181,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
// TODO: Fetch partial columns for this query since we only need some columns
let ending_at = self
.find_payment_intent_by_payment_id_merchant_id(
- state,
ending_before_id,
merchant_id,
merchant_key_store,
@@ -1304,7 +1270,9 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
};
logger::debug!(filter = %diesel::debug_query::<diesel::pg::Pg,_>(&query).to_string());
-
+ let keymanager_state = self
+ .get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?;
query
.get_results_async::<(
DieselPaymentIntent,
@@ -1314,7 +1282,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.map(|results| {
try_join_all(results.into_iter().map(|(pi, pa)| {
PaymentIntent::convert_back(
- state,
+ keymanager_state,
pi,
merchant_key_store.key.get_inner(),
merchant_id.to_owned().into(),
@@ -1340,7 +1308,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn get_filtered_payment_intents_attempt(
&self,
- state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
constraints: &PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
@@ -1405,7 +1372,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
// TODO: Fetch partial columns for this query since we only need some columns
let starting_at = self
.find_payment_intent_by_id(
- state,
starting_after_id,
merchant_key_store,
storage_scheme,
@@ -1423,7 +1389,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
// TODO: Fetch partial columns for this query since we only need some columns
let ending_at = self
.find_payment_intent_by_id(
- state,
ending_before_id,
merchant_key_store,
storage_scheme,
@@ -1507,6 +1472,9 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
};
logger::debug!(filter = %diesel::debug_query::<diesel::pg::Pg,_>(&query).to_string());
+ let keymanager_state = self
+ .get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?;
query
.get_results_async::<(
@@ -1519,7 +1487,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
try_join_all(output.into_iter().map(
|(pi, pa): (_, Option<diesel_models::payment_attempt::PaymentAttempt>)| async {
let payment_intent = PaymentIntent::convert_back(
- state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
pi,
merchant_key_store.key.get_inner(),
merchant_id.to_owned().into(),
@@ -1527,7 +1496,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
let payment_attempt = pa
.async_map(|val| {
PaymentAttempt::convert_back(
- state,
+ keymanager_state,
val,
merchant_key_store.key.get_inner(),
merchant_id.to_owned().into(),
diff --git a/crates/storage_impl/src/subscription.rs b/crates/storage_impl/src/subscription.rs
index 79e844c985..ee081eb803 100644
--- a/crates/storage_impl/src/subscription.rs
+++ b/crates/storage_impl/src/subscription.rs
@@ -1,4 +1,4 @@
-use common_utils::{errors::CustomResult, types::keymanager::KeyManagerState};
+use common_utils::errors::CustomResult;
pub use diesel_models::subscription::Subscription;
use error_stack::ResultExt;
pub use hyperswitch_domain_models::{
@@ -23,7 +23,6 @@ impl<T: DatabaseStore> SubscriptionInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_subscription_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_new: DomainSubscription,
) -> CustomResult<DomainSubscription, StorageError> {
@@ -32,20 +31,17 @@ impl<T: DatabaseStore> SubscriptionInterface for RouterStore<T> {
.await
.change_context(StorageError::DecryptionError)?;
let conn = connection::pg_connection_write(self).await?;
- self.call_database(state, key_store, sub_new.insert(&conn))
- .await
+ self.call_database(key_store, sub_new.insert(&conn)).await
}
#[instrument(skip_all)]
async fn find_by_merchant_id_subscription_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
subscription_id: String,
) -> CustomResult<DomainSubscription, StorageError> {
let conn = connection::pg_connection_write(self).await?;
self.call_database(
- state,
key_store,
Subscription::find_by_merchant_id_subscription_id(&conn, merchant_id, subscription_id),
)
@@ -55,7 +51,6 @@ impl<T: DatabaseStore> SubscriptionInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn update_subscription_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
subscription_id: String,
@@ -67,7 +62,6 @@ impl<T: DatabaseStore> SubscriptionInterface for RouterStore<T> {
.change_context(StorageError::DecryptionError)?;
let conn = connection::pg_connection_write(self).await?;
self.call_database(
- state,
key_store,
Subscription::update_subscription_entry(&conn, merchant_id, subscription_id, sub_new),
)
@@ -82,38 +76,35 @@ impl<T: DatabaseStore> SubscriptionInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn insert_subscription_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
subscription_new: DomainSubscription,
) -> CustomResult<DomainSubscription, StorageError> {
self.router_store
- .insert_subscription_entry(state, key_store, subscription_new)
+ .insert_subscription_entry(key_store, subscription_new)
.await
}
#[instrument(skip_all)]
async fn find_by_merchant_id_subscription_id(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
subscription_id: String,
) -> CustomResult<DomainSubscription, StorageError> {
self.router_store
- .find_by_merchant_id_subscription_id(state, key_store, merchant_id, subscription_id)
+ .find_by_merchant_id_subscription_id(key_store, merchant_id, subscription_id)
.await
}
#[instrument(skip_all)]
async fn update_subscription_entry(
&self,
- state: &KeyManagerState,
key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
subscription_id: String,
data: DomainSubscriptionUpdate,
) -> CustomResult<DomainSubscription, StorageError> {
self.router_store
- .update_subscription_entry(state, key_store, merchant_id, subscription_id, data)
+ .update_subscription_entry(key_store, merchant_id, subscription_id, data)
.await
}
}
@@ -125,7 +116,6 @@ impl SubscriptionInterface for MockDb {
#[instrument(skip_all)]
async fn insert_subscription_entry(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_subscription_new: DomainSubscription,
) -> CustomResult<DomainSubscription, StorageError> {
@@ -134,7 +124,6 @@ impl SubscriptionInterface for MockDb {
async fn find_by_merchant_id_subscription_id(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_merchant_id: &common_utils::id_type::MerchantId,
_subscription_id: String,
@@ -144,7 +133,6 @@ impl SubscriptionInterface for MockDb {
async fn update_subscription_entry(
&self,
- _state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_merchant_id: &common_utils::id_type::MerchantId,
_subscription_id: String,
diff --git a/crates/storage_impl/src/tokenization.rs b/crates/storage_impl/src/tokenization.rs
index 8fd299e79f..774184da28 100644
--- a/crates/storage_impl/src/tokenization.rs
+++ b/crates/storage_impl/src/tokenization.rs
@@ -1,5 +1,5 @@
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
-use common_utils::{errors::CustomResult, types::keymanager::KeyManagerState};
+use common_utils::errors::CustomResult;
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use diesel_models::tokenization as tokenization_diesel;
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
@@ -25,14 +25,12 @@ pub trait TokenizationInterface {
&self,
tokenization: hyperswitch_domain_models::tokenization::Tokenization,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>;
async fn get_entity_id_vault_id_by_token_id(
&self,
token: &common_utils::id_type::GlobalTokenId,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>;
async fn update_tokenization_record(
@@ -40,7 +38,6 @@ pub trait TokenizationInterface {
tokenization: hyperswitch_domain_models::tokenization::Tokenization,
tokenization_update: hyperswitch_domain_models::tokenization::TokenizationUpdate,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>;
}
@@ -51,7 +48,6 @@ impl<T: DatabaseStore> TokenizationInterface for RouterStore<T> {
&self,
tokenization: hyperswitch_domain_models::tokenization::Tokenization,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
let conn = connection::pg_connection_write(self).await?;
@@ -64,7 +60,8 @@ impl<T: DatabaseStore> TokenizationInterface for RouterStore<T> {
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -76,7 +73,6 @@ impl<T: DatabaseStore> TokenizationInterface for RouterStore<T> {
&self,
token: &common_utils::id_type::GlobalTokenId,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
let conn = connection::pg_connection_read(self).await?;
@@ -87,7 +83,8 @@ impl<T: DatabaseStore> TokenizationInterface for RouterStore<T> {
let domain = tokenization
.convert(
- key_manager_state,
+ self.get_keymanager_state()
+ .attach_printable("Missing KeyManagerState")?,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
@@ -102,7 +99,6 @@ impl<T: DatabaseStore> TokenizationInterface for RouterStore<T> {
tokenization_record: hyperswitch_domain_models::tokenization::Tokenization,
tokenization_update: hyperswitch_domain_models::tokenization::TokenizationUpdate,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
let conn = connection::pg_connection_write(self).await?;
@@ -111,7 +107,6 @@ impl<T: DatabaseStore> TokenizationInterface for RouterStore<T> {
.await
.change_context(errors::StorageError::DecryptionError)?;
self.call_database(
- key_manager_state,
merchant_key_store,
tokenization_record.update_with_id(
&conn,
@@ -129,11 +124,10 @@ impl<T: DatabaseStore> TokenizationInterface for KVRouterStore<T> {
&self,
tokenization: hyperswitch_domain_models::tokenization::Tokenization,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
self.router_store
- .insert_tokenization(tokenization, merchant_key_store, key_manager_state)
+ .insert_tokenization(tokenization, merchant_key_store)
.await
}
@@ -141,11 +135,10 @@ impl<T: DatabaseStore> TokenizationInterface for KVRouterStore<T> {
&self,
token: &common_utils::id_type::GlobalTokenId,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
self.router_store
- .get_entity_id_vault_id_by_token_id(token, merchant_key_store, key_manager_state)
+ .get_entity_id_vault_id_by_token_id(token, merchant_key_store)
.await
}
@@ -154,7 +147,6 @@ impl<T: DatabaseStore> TokenizationInterface for KVRouterStore<T> {
tokenization_record: hyperswitch_domain_models::tokenization::Tokenization,
tokenization_update: hyperswitch_domain_models::tokenization::TokenizationUpdate,
merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
self.router_store
@@ -162,7 +154,6 @@ impl<T: DatabaseStore> TokenizationInterface for KVRouterStore<T> {
tokenization_record,
tokenization_update,
merchant_key_store,
- key_manager_state,
)
.await
}
@@ -175,7 +166,6 @@ impl TokenizationInterface for MockDb {
&self,
_tokenization: hyperswitch_domain_models::tokenization::Tokenization,
_merchant_key_store: &MerchantKeyStore,
- _key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
Err(errors::StorageError::MockDbError)?
@@ -184,7 +174,6 @@ impl TokenizationInterface for MockDb {
&self,
_token: &common_utils::id_type::GlobalTokenId,
_merchant_key_store: &MerchantKeyStore,
- _key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
Err(errors::StorageError::MockDbError)?
@@ -192,10 +181,9 @@ impl TokenizationInterface for MockDb {
async fn update_tokenization_record(
&self,
- tokenization_record: hyperswitch_domain_models::tokenization::Tokenization,
- tokenization_update: hyperswitch_domain_models::tokenization::TokenizationUpdate,
- merchant_key_store: &MerchantKeyStore,
- key_manager_state: &KeyManagerState,
+ _tokenization_record: hyperswitch_domain_models::tokenization::Tokenization,
+ _tokenization_update: hyperswitch_domain_models::tokenization::TokenizationUpdate,
+ _merchant_key_store: &MerchantKeyStore,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
Err(errors::StorageError::MockDbError)?
diff --git a/crates/subscriptions/src/core/billing_processor_handler.rs b/crates/subscriptions/src/core/billing_processor_handler.rs
index d83896ce6e..2e4672a45b 100644
--- a/crates/subscriptions/src/core/billing_processor_handler.rs
+++ b/crates/subscriptions/src/core/billing_processor_handler.rs
@@ -48,7 +48,6 @@ impl BillingHandler {
let billing_processor_mca = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- &(state).into(),
merchant_account.get_id(),
&merchant_connector_id,
key_store,
diff --git a/crates/subscriptions/src/core/invoice_handler.rs b/crates/subscriptions/src/core/invoice_handler.rs
index 2acf4c0cdf..ec602caa33 100644
--- a/crates/subscriptions/src/core/invoice_handler.rs
+++ b/crates/subscriptions/src/core/invoice_handler.rs
@@ -66,10 +66,9 @@ impl InvoiceHandler {
connector_invoice_id,
);
- let key_manager_state = &(state).into();
let invoice = state
.store
- .insert_invoice_entry(key_manager_state, &self.merchant_key_store, invoice_new)
+ .insert_invoice_entry(&self.merchant_key_store, invoice_new)
.await
.change_context(errors::ApiErrorResponse::SubscriptionError {
operation: "Create Invoice".to_string(),
@@ -87,11 +86,9 @@ impl InvoiceHandler {
) -> errors::SubscriptionResult<hyperswitch_domain_models::invoice::Invoice> {
let update_invoice: hyperswitch_domain_models::invoice::InvoiceUpdate =
update_request.into();
- let key_manager_state = &(state).into();
state
.store
.update_invoice_entry(
- key_manager_state,
&self.merchant_key_store,
invoice_id.get_string_repr().to_string(),
update_invoice,
@@ -235,11 +232,9 @@ impl InvoiceHandler {
&self,
state: &SessionState,
) -> errors::SubscriptionResult<hyperswitch_domain_models::invoice::Invoice> {
- let key_manager_state = &(state).into();
state
.store
.get_latest_invoice_for_subscription(
- key_manager_state,
&self.merchant_key_store,
self.subscription.id.get_string_repr().to_string(),
)
@@ -255,11 +250,9 @@ impl InvoiceHandler {
state: &SessionState,
invoice_id: common_utils::id_type::InvoiceId,
) -> errors::SubscriptionResult<hyperswitch_domain_models::invoice::Invoice> {
- let key_manager_state = &(state).into();
state
.store
.find_invoice_by_invoice_id(
- key_manager_state,
&self.merchant_key_store,
invoice_id.get_string_repr().to_string(),
)
@@ -276,11 +269,9 @@ impl InvoiceHandler {
subscription_id: common_utils::id_type::SubscriptionId,
connector_invoice_id: common_utils::id_type::InvoiceId,
) -> errors::SubscriptionResult<Option<hyperswitch_domain_models::invoice::Invoice>> {
- let key_manager_state = &(state).into();
state
.store
.find_invoice_by_subscription_id_connector_invoice_id(
- key_manager_state,
&self.merchant_key_store,
subscription_id.get_string_repr().to_string(),
connector_invoice_id,
diff --git a/crates/subscriptions/src/core/subscription_handler.rs b/crates/subscriptions/src/core/subscription_handler.rs
index 5a2a2479a9..35c0892190 100644
--- a/crates/subscriptions/src/core/subscription_handler.rs
+++ b/crates/subscriptions/src/core/subscription_handler.rs
@@ -70,10 +70,9 @@ impl<'a> SubscriptionHandler<'a> {
subscription.generate_and_set_client_secret();
- let key_manager_state = &(self.state).into();
let merchant_key_store = self.platform.get_processor().get_key_store();
let new_subscription = db
- .insert_subscription_entry(key_manager_state, merchant_key_store, subscription)
+ .insert_subscription_entry(merchant_key_store, subscription)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("subscriptions: unable to insert subscription entry to database")?;
@@ -91,14 +90,12 @@ impl<'a> SubscriptionHandler<'a> {
platform: &Platform,
customer_id: &common_utils::id_type::CustomerId,
) -> errors::SubscriptionResult<customer::Customer> {
- let key_manager_state = &(state).into();
let merchant_key_store = platform.get_processor().get_key_store();
let merchant_id = platform.get_processor().get_account().get_id();
state
.store
.find_customer_by_customer_id_merchant_id(
- key_manager_state,
customer_id,
merchant_id,
merchant_key_store,
@@ -144,14 +141,12 @@ impl<'a> SubscriptionHandler<'a> {
customer: customer::Customer,
customer_update: customer::CustomerUpdate,
) -> errors::SubscriptionResult<customer::Customer> {
- let key_manager_state = &(state).into();
let merchant_key_store = platform.get_processor().get_key_store();
let merchant_id = platform.get_processor().get_account().get_id();
let db = state.store.as_ref();
let updated_customer = db
.update_customer_by_customer_id_merchant_id(
- key_manager_state,
customer.customer_id.clone(),
merchant_id.clone(),
customer,
@@ -172,12 +167,11 @@ impl<'a> SubscriptionHandler<'a> {
platform: &Platform,
profile_id: &common_utils::id_type::ProfileId,
) -> errors::SubscriptionResult<hyperswitch_domain_models::business_profile::Profile> {
- let key_manager_state = &(state).into();
let merchant_key_store = platform.get_processor().get_key_store();
state
.store
- .find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_id)
+ .find_business_profile_by_profile_id(merchant_key_store, profile_id)
.await
.change_context(errors::ApiErrorResponse::ProfileNotFound {
id: profile_id.get_string_repr().to_string(),
@@ -189,15 +183,12 @@ impl<'a> SubscriptionHandler<'a> {
client_secret: &hyperswitch_domain_models::subscription::ClientSecret,
) -> errors::SubscriptionResult<()> {
let subscription_id = client_secret.get_subscription_id()?;
-
- let key_manager_state = &(self.state).into();
let key_store = self.platform.get_processor().get_key_store();
let subscription = self
.state
.store
.find_by_merchant_id_subscription_id(
- key_manager_state,
key_store,
self.platform.get_processor().get_account().get_id(),
subscription_id.to_string(),
@@ -251,7 +242,6 @@ impl<'a> SubscriptionHandler<'a> {
.state
.store
.find_by_merchant_id_subscription_id(
- &(self.state).into(),
self.platform.get_processor().get_key_store(),
self.platform.get_processor().get_account().get_id(),
subscription_id.get_string_repr().to_string().clone(),
@@ -333,7 +323,6 @@ impl SubscriptionWithHandler<'_> {
let db = self.handler.state.store.as_ref();
let updated_subscription = db
.update_subscription_entry(
- &(self.handler.state).into(),
self.handler.platform.get_processor().get_key_store(),
self.handler.platform.get_processor().get_account().get_id(),
self.subscription.id.get_string_repr().to_string(),
@@ -372,14 +361,12 @@ impl SubscriptionWithHandler<'_> {
) -> CustomResult<merchant_connector_account::MerchantConnectorAccount, errors::ApiErrorResponse>
{
let db = self.handler.state.store.as_ref();
- let key_manager_state = &(self.handler.state).into();
match &self.subscription.merchant_connector_id {
Some(merchant_connector_id) => {
#[cfg(feature = "v1")]
{
db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
self.handler.platform.get_processor().get_account().get_id(),
merchant_connector_id,
self.handler.platform.get_processor().get_key_store(),
@@ -397,7 +384,6 @@ impl SubscriptionWithHandler<'_> {
#[cfg(feature = "v1")]
{
db.find_merchant_connector_account_by_profile_id_connector_name(
- key_manager_state,
&self.subscription.profile_id,
connector_name,
self.handler.platform.get_processor().get_key_store(),
diff --git a/crates/subscriptions/src/workflows/invoice_sync.rs b/crates/subscriptions/src/workflows/invoice_sync.rs
index 6ed3cb96ca..08141be9f5 100644
--- a/crates/subscriptions/src/workflows/invoice_sync.rs
+++ b/crates/subscriptions/src/workflows/invoice_sync.rs
@@ -44,11 +44,9 @@ impl<'a> InvoiceSyncHandler<'a> {
state: &'a SessionState,
tracking_data: storage::invoice_sync::InvoiceSyncTrackingData,
) -> Result<Self, errors::ProcessTrackerError> {
- let key_manager_state = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
- key_manager_state,
&tracking_data.merchant_id,
&state.store.get_master_key().to_vec().into(),
)
@@ -57,28 +55,19 @@ impl<'a> InvoiceSyncHandler<'a> {
let merchant_account = state
.store
- .find_merchant_account_by_merchant_id(
- key_manager_state,
- &tracking_data.merchant_id,
- &key_store,
- )
+ .find_merchant_account_by_merchant_id(&tracking_data.merchant_id, &key_store)
.await
.attach_printable("Subscriptions: Failed to fetch Merchant Account from DB")?;
let profile = state
.store
- .find_business_profile_by_profile_id(
- &(state).into(),
- &key_store,
- &tracking_data.profile_id,
- )
+ .find_business_profile_by_profile_id(&key_store, &tracking_data.profile_id)
.await
.attach_printable("Subscriptions: Failed to fetch Business Profile from DB")?;
let customer = state
.store
.find_customer_by_customer_id_merchant_id(
- &(state).into(),
&tracking_data.customer_id,
merchant_account.get_id(),
&key_store,
@@ -90,7 +79,6 @@ impl<'a> InvoiceSyncHandler<'a> {
let subscription = state
.store
.find_by_merchant_id_subscription_id(
- &state.into(),
&key_store,
merchant_account.get_id(),
tracking_data.subscription_id.get_string_repr().to_string(),
@@ -101,7 +89,6 @@ impl<'a> InvoiceSyncHandler<'a> {
let invoice = state
.store
.find_invoice_by_invoice_id(
- &state.into(),
&key_store,
tracking_data.invoice_id.get_string_repr().to_string(),
)
@@ -182,11 +169,9 @@ impl<'a> InvoiceSyncHandler<'a> {
profile_id: &common_utils::id_type::ProfileId,
merchant_account: &domain::merchant_account::MerchantAccount,
) -> Result<subscription_types::ConfirmSubscriptionResponse, errors::ProcessTrackerError> {
- let key_manager_state = &(&state).into();
-
let invoice = state
.store
- .find_invoice_by_invoice_id(key_manager_state, key_store, invoice_id.clone())
+ .find_invoice_by_invoice_id(key_store, invoice_id.clone())
.await
.map_err(|err| {
logger::error!(
@@ -201,7 +186,6 @@ impl<'a> InvoiceSyncHandler<'a> {
let subscription = state
.store
.find_by_merchant_id_subscription_id(
- key_manager_state,
key_store,
merchant_account.get_id(),
invoice.subscription_id.get_string_repr().to_string(),