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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(merchant_id): create domain type for `merchant_id` (#5408)
Narayan Bhat7068fbfbe2f5
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.jsonindex a9dda658d4..41d97b1711 100644--- a/api-reference/openapi_spec.json+++ b/api-reference/openapi_spec.json@@ -11675,7 +11675,7 @@"type": "string","description": "The identifier for the Merchant Account","example": "y3oqhf46pyzuxjbcn2giaqnb44",- "maxLength": 255+ "maxLength": 64},"merchant_name": {"type": "string",@@ -18100,7 +18100,6 @@"PayoutCreateRequest": {"type": "object","required": [- "merchant_id","currency","confirm","payout_type",@@ -18125,6 +18124,7 @@"type": "string","description": "This is an identifier for the merchant account. This is inferred from the API key\nprovided during the request","example": "merchant_1668273825",+ "nullable": true,"maxLength": 255},"amount": {diff --git a/crates/analytics/src/active_payments/core.rs b/crates/analytics/src/active_payments/core.rsindex b5ca3e2d0b..c341ebbcb7 100644--- a/crates/analytics/src/active_payments/core.rs+++ b/crates/analytics/src/active_payments/core.rs@@ -20,7 +20,7 @@ use crate::{pub async fn get_metrics(pool: &AnalyticsProvider,publishable_key: &String,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,req: GetActivePaymentsMetricRequest,) -> AnalyticsResult<MetricsResponse<MetricsBucketResponse>> {let mut metrics_accumulator: HashMap<diff --git a/crates/analytics/src/active_payments/metrics.rs b/crates/analytics/src/active_payments/metrics.rsindex 5526f30fd6..a1e1c5c85e 100644--- a/crates/analytics/src/active_payments/metrics.rs+++ b/crates/analytics/src/active_payments/metrics.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,time_range: &TimeRange,pool: &T,@@ -53,7 +53,7 @@ where{async fn load_metrics(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,time_range: &TimeRange,pool: &T,@@ -66,7 +66,7 @@ wherematch self {Self::ActivePayments => {ActivePayments- .load_metrics(publishable_key, merchant_id, time_range, pool)+ .load_metrics(merchant_id, publishable_key, time_range, pool).await}}diff --git a/crates/analytics/src/active_payments/metrics/active_payments.rs b/crates/analytics/src/active_payments/metrics/active_payments.rsindex 30621c98c7..567820f825 100644--- a/crates/analytics/src/active_payments/metrics/active_payments.rs+++ b/crates/analytics/src/active_payments/metrics/active_payments.rs@@ -28,7 +28,7 @@ where{async fn load_metrics(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,time_range: &TimeRange,pool: &T,@@ -51,7 +51,7 @@ wherequery_builder.add_custom_filter_clause("merchant_id",- format!("'{}','{}'", merchant_id, publishable_key),+ format!("'{}','{}'", merchant_id.get_string_repr(), publishable_key),FilterTypes::In,).switch()?;diff --git a/crates/analytics/src/api_event/core.rs b/crates/analytics/src/api_event/core.rsindex c7d6d9ac33..305de7e69c 100644--- a/crates/analytics/src/api_event/core.rs+++ b/crates/analytics/src/api_event/core.rs@@ -31,17 +31,17 @@ use crate::{pub async fn api_events_core(pool: &AnalyticsProvider,req: ApiLogsRequest,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<Vec<ApiLogsResult>> {let data = match pool {AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented("API Events not implemented for SQLX",)).attach_printable("SQL Analytics is not implemented for API Events"),- AnalyticsProvider::Clickhouse(pool) => get_api_event(&merchant_id, req, pool).await,+ AnalyticsProvider::Clickhouse(pool) => get_api_event(merchant_id, req, pool).await,AnalyticsProvider::CombinedSqlx(_sqlx_pool, ckh_pool)| AnalyticsProvider::CombinedCkh(_sqlx_pool, ckh_pool) => {- get_api_event(&merchant_id, req, ckh_pool).await+ get_api_event(merchant_id, req, ckh_pool).await}}.switch()?;@@ -51,7 +51,7 @@ pub async fn api_events_core(pub async fn get_filters(pool: &AnalyticsProvider,req: GetApiEventFiltersRequest,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<ApiEventFiltersResponse> {use api_models::analytics::{api_event::ApiEventDimensions, ApiEventFilterValue};@@ -68,7 +68,7 @@ pub async fn get_filters(AnalyticsProvider::Clickhouse(ckh_pool)| AnalyticsProvider::CombinedSqlx(_, ckh_pool)| AnalyticsProvider::CombinedCkh(_, ckh_pool) => {- get_api_event_filter_for_dimension(dim, &merchant_id, &req.time_range, ckh_pool)+ get_api_event_filter_for_dimension(dim, merchant_id, &req.time_range, ckh_pool).await}}@@ -92,7 +92,7 @@ pub async fn get_filters(#[instrument(skip_all)]pub async fn get_api_event_metrics(pool: &AnalyticsProvider,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,req: GetApiEventMetricRequest,) -> AnalyticsResult<MetricsResponse<ApiMetricsBucketResponse>> {let mut metrics_accumulator: HashMap<ApiEventMetricsBucketIdentifier, ApiEventMetricRow> =diff --git a/crates/analytics/src/api_event/events.rs b/crates/analytics/src/api_event/events.rsindex 4be3a3420d..039172d1e0 100644--- a/crates/analytics/src/api_event/events.rs+++ b/crates/analytics/src/api_event/events.rs@@ -14,7 +14,7 @@ use crate::{pub trait ApiLogsFilterAnalytics: LoadRow<ApiLogsResult> {}pub async fn get_api_event<T>(- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,query_param: ApiLogsRequest,pool: &T,) -> FiltersResult<Vec<ApiLogsResult>>@@ -102,7 +102,7 @@ where}#[derive(Debug, serde::Serialize, serde::Deserialize)]pub struct ApiLogsResult {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: Option<String>,pub refund_id: Option<String>,pub payment_method_id: Option<String>,diff --git a/crates/analytics/src/api_event/filters.rs b/crates/analytics/src/api_event/filters.rsindex 87414ebad4..62fd878901 100644--- a/crates/analytics/src/api_event/filters.rs+++ b/crates/analytics/src/api_event/filters.rs@@ -12,7 +12,7 @@ pub trait ApiEventFilterAnalytics: LoadRow<ApiEventFilter> {}pub async fn get_api_event_filter_for_dimension<T>(dimension: ApiEventDimensions,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &TimeRange,pool: &T,) -> FiltersResult<Vec<ApiEventFilter>>diff --git a/crates/analytics/src/api_event/metrics.rs b/crates/analytics/src/api_event/metrics.rsindex 1a08b56a59..ac29ec1516 100644--- a/crates/analytics/src/api_event/metrics.rs+++ b/crates/analytics/src/api_event/metrics.rs@@ -43,7 +43,7 @@ whereasync fn load_metrics(&self,dimensions: &[ApiEventDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &ApiEventFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -64,7 +64,7 @@ whereasync fn load_metrics(&self,dimensions: &[ApiEventDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &ApiEventFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/api_event/metrics/api_count.rs b/crates/analytics/src/api_event/metrics/api_count.rsindex cb9d559292..f00c01bbf3 100644--- a/crates/analytics/src/api_event/metrics/api_count.rs+++ b/crates/analytics/src/api_event/metrics/api_count.rs@@ -30,7 +30,7 @@ whereasync fn load_metrics(&self,_dimensions: &[ApiEventDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &ApiEventFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/api_event/metrics/latency.rs b/crates/analytics/src/api_event/metrics/latency.rsindex 20fb648945..5d71da2a0a 100644--- a/crates/analytics/src/api_event/metrics/latency.rs+++ b/crates/analytics/src/api_event/metrics/latency.rs@@ -33,7 +33,7 @@ whereasync fn load_metrics(&self,_dimensions: &[ApiEventDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &ApiEventFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/api_event/metrics/status_code_count.rs b/crates/analytics/src/api_event/metrics/status_code_count.rsindex a513016921..b4fff367b6 100644--- a/crates/analytics/src/api_event/metrics/status_code_count.rs+++ b/crates/analytics/src/api_event/metrics/status_code_count.rs@@ -30,7 +30,7 @@ whereasync fn load_metrics(&self,_dimensions: &[ApiEventDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &ApiEventFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/auth_events/core.rs b/crates/analytics/src/auth_events/core.rsindex e50a6aaf53..250dc07fee 100644--- a/crates/analytics/src/auth_events/core.rs+++ b/crates/analytics/src/auth_events/core.rs@@ -17,7 +17,7 @@ use crate::{#[instrument(skip_all)]pub async fn get_metrics(pool: &AnalyticsProvider,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,publishable_key: &String,req: GetAuthEventMetricRequest,) -> AnalyticsResult<MetricsResponse<MetricsBucketResponse>> {diff --git a/crates/analytics/src/auth_events/metrics.rs b/crates/analytics/src/auth_events/metrics.rsindex 6690850a80..da5bf6309f 100644--- a/crates/analytics/src/auth_events/metrics.rs+++ b/crates/analytics/src/auth_events/metrics.rs@@ -44,7 +44,7 @@ where{async fn load_metrics(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -64,7 +64,7 @@ where{async fn load_metrics(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/auth_events/metrics/authentication_attempt_count.rs b/crates/analytics/src/auth_events/metrics/authentication_attempt_count.rsindex 80c80db92f..4fee15e2af 100644--- a/crates/analytics/src/auth_events/metrics/authentication_attempt_count.rs+++ b/crates/analytics/src/auth_events/metrics/authentication_attempt_count.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/auth_events/metrics/authentication_success_count.rs b/crates/analytics/src/auth_events/metrics/authentication_success_count.rsindex bfcfbaf3a6..06de7a694f 100644--- a/crates/analytics/src/auth_events/metrics/authentication_success_count.rs+++ b/crates/analytics/src/auth_events/metrics/authentication_success_count.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/auth_events/metrics/challenge_attempt_count.rs b/crates/analytics/src/auth_events/metrics/challenge_attempt_count.rsindex b146c053d3..2f744f15e9 100644--- a/crates/analytics/src/auth_events/metrics/challenge_attempt_count.rs+++ b/crates/analytics/src/auth_events/metrics/challenge_attempt_count.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/auth_events/metrics/challenge_flow_count.rs b/crates/analytics/src/auth_events/metrics/challenge_flow_count.rsindex b2921bb3ec..551810d8e5 100644--- a/crates/analytics/src/auth_events/metrics/challenge_flow_count.rs+++ b/crates/analytics/src/auth_events/metrics/challenge_flow_count.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/auth_events/metrics/challenge_success_count.rs b/crates/analytics/src/auth_events/metrics/challenge_success_count.rsindex f6553f84f8..c6c7d1cda0 100644--- a/crates/analytics/src/auth_events/metrics/challenge_success_count.rs+++ b/crates/analytics/src/auth_events/metrics/challenge_success_count.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/auth_events/metrics/frictionless_flow_count.rs b/crates/analytics/src/auth_events/metrics/frictionless_flow_count.rsindex 42261f09b3..69b4eeba4a 100644--- a/crates/analytics/src/auth_events/metrics/frictionless_flow_count.rs+++ b/crates/analytics/src/auth_events/metrics/frictionless_flow_count.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/auth_events/metrics/frictionless_success_count.rs b/crates/analytics/src/auth_events/metrics/frictionless_success_count.rsindex 4d7eed972f..6ea26a9097 100644--- a/crates/analytics/src/auth_events/metrics/frictionless_success_count.rs+++ b/crates/analytics/src/auth_events/metrics/frictionless_success_count.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -52,7 +52,7 @@ where}query_builder- .add_filter_clause("merchant_id", merchant_id)+ .add_filter_clause("merchant_id", merchant_id.get_string_repr()).switch()?;query_builderdiff --git a/crates/analytics/src/auth_events/metrics/three_ds_sdk_count.rs b/crates/analytics/src/auth_events/metrics/three_ds_sdk_count.rsindex 05173bcb9d..ca67400a9b 100644--- a/crates/analytics/src/auth_events/metrics/three_ds_sdk_count.rs+++ b/crates/analytics/src/auth_events/metrics/three_ds_sdk_count.rs@@ -29,7 +29,7 @@ where{async fn load_metrics(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/connector_events/core.rs b/crates/analytics/src/connector_events/core.rsindex a7f5b97842..ae1405ed47 100644--- a/crates/analytics/src/connector_events/core.rs+++ b/crates/analytics/src/connector_events/core.rs@@ -8,7 +8,7 @@ use crate::{errors::AnalyticsResult, types::FiltersError, AnalyticsProvider};pub async fn connector_events_core(pool: &AnalyticsProvider,req: ConnectorEventsRequest,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<Vec<ConnectorEventsResult>> {let data = match pool {AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented(@@ -18,7 +18,7 @@ pub async fn connector_events_core(AnalyticsProvider::Clickhouse(ckh_pool)| AnalyticsProvider::CombinedSqlx(_, ckh_pool)| AnalyticsProvider::CombinedCkh(_, ckh_pool) => {- get_connector_events(&merchant_id, req, ckh_pool).await+ get_connector_events(merchant_id, req, ckh_pool).await}}.switch()?;diff --git a/crates/analytics/src/connector_events/events.rs b/crates/analytics/src/connector_events/events.rsindex 0a13074d72..9bdbba3297 100644--- a/crates/analytics/src/connector_events/events.rs+++ b/crates/analytics/src/connector_events/events.rs@@ -10,7 +10,7 @@ use crate::{pub trait ConnectorEventLogAnalytics: LoadRow<ConnectorEventsResult> {}pub async fn get_connector_events<T>(- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,query_param: ConnectorEventsRequest,pool: &T,) -> FiltersResult<Vec<ConnectorEventsResult>>@@ -56,7 +56,7 @@ where#[derive(Debug, serde::Serialize, serde::Deserialize)]pub struct ConnectorEventsResult {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: String,pub connector_name: Option<String>,pub request_id: Option<String>,diff --git a/crates/analytics/src/disputes/core.rs b/crates/analytics/src/disputes/core.rsindex d227918025..b67716291b 100644--- a/crates/analytics/src/disputes/core.rs+++ b/crates/analytics/src/disputes/core.rs@@ -27,7 +27,7 @@ use crate::{pub async fn get_metrics(pool: &AnalyticsProvider,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,req: GetDisputeMetricRequest,) -> AnalyticsResult<MetricsResponse<DisputeMetricsBucketResponse>> {let mut metrics_accumulator: HashMap<@@ -123,7 +123,7 @@ pub async fn get_metrics(pub async fn get_filters(pool: &AnalyticsProvider,req: GetDisputeFilterRequest,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<DisputeFiltersResponse> {let mut res = DisputeFiltersResponse::default();for dim in req.group_by_names {diff --git a/crates/analytics/src/disputes/filters.rs b/crates/analytics/src/disputes/filters.rsindex 9b03c4de94..e9b6d26bee 100644--- a/crates/analytics/src/disputes/filters.rs+++ b/crates/analytics/src/disputes/filters.rs@@ -11,7 +11,7 @@ pub trait DisputeFilterAnalytics: LoadRow<DisputeFilterRow> {}pub async fn get_dispute_filter_for_dimension<T>(dimension: DisputeDimensions,- merchant: &String,+ merchant: &common_utils::id_type::MerchantId,time_range: &TimeRange,pool: &T,) -> FiltersResult<Vec<DisputeFilterRow>>diff --git a/crates/analytics/src/disputes/metrics.rs b/crates/analytics/src/disputes/metrics.rsindex e397785528..d2ae23d0ac 100644--- a/crates/analytics/src/disputes/metrics.rs+++ b/crates/analytics/src/disputes/metrics.rs@@ -52,7 +52,7 @@ whereasync fn load_metrics(&self,dimensions: &[DisputeDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &DisputeFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -73,7 +73,7 @@ whereasync fn load_metrics(&self,dimensions: &[DisputeDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &DisputeFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/disputes/metrics/dispute_status_metric.rs b/crates/analytics/src/disputes/metrics/dispute_status_metric.rsindex 005be320eb..776f94282c 100644--- a/crates/analytics/src/disputes/metrics/dispute_status_metric.rs+++ b/crates/analytics/src/disputes/metrics/dispute_status_metric.rs@@ -29,7 +29,7 @@ whereasync fn load_metrics(&self,dimensions: &[DisputeDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &DisputeFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/disputes/metrics/total_amount_disputed.rs b/crates/analytics/src/disputes/metrics/total_amount_disputed.rsindex cf299ebfa9..8b45dab395 100644--- a/crates/analytics/src/disputes/metrics/total_amount_disputed.rs+++ b/crates/analytics/src/disputes/metrics/total_amount_disputed.rs@@ -29,7 +29,7 @@ whereasync fn load_metrics(&self,dimensions: &[DisputeDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &DisputeFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rs b/crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rsindex ddf6338f01..f72ca914e6 100644--- a/crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rs+++ b/crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rs@@ -29,7 +29,7 @@ whereasync fn load_metrics(&self,dimensions: &[DisputeDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &DisputeFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/frm/core.rs b/crates/analytics/src/frm/core.rsindex 9c9e73b49a..d2b79ad277 100644--- a/crates/analytics/src/frm/core.rs+++ b/crates/analytics/src/frm/core.rs@@ -25,7 +25,7 @@ use crate::{pub async fn get_metrics(pool: &AnalyticsProvider,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,req: GetFrmMetricRequest,) -> AnalyticsResult<MetricsResponse<FrmMetricsBucketResponse>> {let mut metrics_accumulator: HashMap<FrmMetricsBucketIdentifier, FrmMetricsAccumulator> =@@ -114,7 +114,7 @@ pub async fn get_metrics(pub async fn get_filters(pool: &AnalyticsProvider,req: GetFrmFilterRequest,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<FrmFiltersResponse> {let mut res = FrmFiltersResponse::default();for dim in req.group_by_names {diff --git a/crates/analytics/src/frm/filters.rs b/crates/analytics/src/frm/filters.rsindex c019f61d42..91cde898bb 100644--- a/crates/analytics/src/frm/filters.rs+++ b/crates/analytics/src/frm/filters.rs@@ -18,7 +18,7 @@ pub trait FrmFilterAnalytics: LoadRow<FrmFilterRow> {}pub async fn get_frm_filter_for_dimension<T>(dimension: FrmDimensions,- merchant: &String,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &TimeRange,pool: &T,) -> FiltersResult<Vec<FrmFilterRow>>@@ -39,7 +39,7 @@ where.switch()?;query_builder- .add_filter_clause("merchant_id", merchant)+ .add_filter_clause("merchant_id", merchant_id).switch()?;query_builder.set_distinct();diff --git a/crates/analytics/src/frm/metrics.rs b/crates/analytics/src/frm/metrics.rsindex 8f90409098..7f5b4ea32b 100644--- a/crates/analytics/src/frm/metrics.rs+++ b/crates/analytics/src/frm/metrics.rs@@ -42,7 +42,7 @@ whereasync fn load_metrics(&self,dimensions: &[FrmDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &FrmFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -63,7 +63,7 @@ whereasync fn load_metrics(&self,dimensions: &[FrmDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &FrmFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/frm/metrics/frm_blocked_rate.rs b/crates/analytics/src/frm/metrics/frm_blocked_rate.rsindex 5f331feab6..7154478c02 100644--- a/crates/analytics/src/frm/metrics/frm_blocked_rate.rs+++ b/crates/analytics/src/frm/metrics/frm_blocked_rate.rs@@ -27,7 +27,7 @@ whereasync fn load_metrics(&self,dimensions: &[FrmDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &FrmFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/frm/metrics/frm_triggered_attempts.rs b/crates/analytics/src/frm/metrics/frm_triggered_attempts.rsindex b72345c4e3..168a256ffa 100644--- a/crates/analytics/src/frm/metrics/frm_triggered_attempts.rs+++ b/crates/analytics/src/frm/metrics/frm_triggered_attempts.rs@@ -28,7 +28,7 @@ whereasync fn load_metrics(&self,dimensions: &[FrmDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &FrmFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/lib.rs b/crates/analytics/src/lib.rsindex 34dcc35d9e..7755740e1d 100644--- a/crates/analytics/src/lib.rs+++ b/crates/analytics/src/lib.rs@@ -112,7 +112,7 @@ impl AnalyticsProvider {&self,metric: &PaymentMetrics,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -216,7 +216,7 @@ impl AnalyticsProvider {&self,distribution: &Distribution,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -326,7 +326,7 @@ impl AnalyticsProvider {&self,metric: &PaymentIntentMetrics,dimensions: &[PaymentIntentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -431,7 +431,7 @@ impl AnalyticsProvider {&self,metric: &RefundMetrics,dimensions: &[RefundDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &RefundFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -531,7 +531,7 @@ impl AnalyticsProvider {&self,metric: &FrmMetrics,dimensions: &[FrmDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &FrmFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -631,7 +631,7 @@ impl AnalyticsProvider {&self,metric: &DisputeMetrics,dimensions: &[DisputeDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &DisputeFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -769,7 +769,7 @@ impl AnalyticsProvider {pub async fn get_active_payments_metrics(&self,metric: &ActivePaymentsMetrics,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,time_range: &TimeRange,) -> types::MetricsResult<@@ -796,7 +796,7 @@ impl AnalyticsProvider {pub async fn get_auth_event_metrics(&self,metric: &AuthEventMetrics,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,publishable_key: &str,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -827,7 +827,7 @@ impl AnalyticsProvider {&self,metric: &ApiEventMetrics,dimensions: &[ApiEventDimensions],- pub_key: &str,+ pub_key: &common_utils::id_type::MerchantId,filters: &ApiEventFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/outgoing_webhook_event/core.rs b/crates/analytics/src/outgoing_webhook_event/core.rsindex a78def2751..bf94e2a158 100644--- a/crates/analytics/src/outgoing_webhook_event/core.rs+++ b/crates/analytics/src/outgoing_webhook_event/core.rs@@ -8,7 +8,7 @@ use crate::{errors::AnalyticsResult, types::FiltersError, AnalyticsProvider};pub async fn outgoing_webhook_events_core(pool: &AnalyticsProvider,req: OutgoingWebhookLogsRequest,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<Vec<OutgoingWebhookLogsResult>> {let data = match pool {AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented(@@ -18,7 +18,7 @@ pub async fn outgoing_webhook_events_core(AnalyticsProvider::Clickhouse(ckh_pool)| AnalyticsProvider::CombinedSqlx(_, ckh_pool)| AnalyticsProvider::CombinedCkh(_, ckh_pool) => {- get_outgoing_webhook_event(&merchant_id, req, ckh_pool).await+ get_outgoing_webhook_event(merchant_id, req, ckh_pool).await}}.switch()?;diff --git a/crates/analytics/src/outgoing_webhook_event/events.rs b/crates/analytics/src/outgoing_webhook_event/events.rsindex e742387e1e..9aaddec256 100644--- a/crates/analytics/src/outgoing_webhook_event/events.rs+++ b/crates/analytics/src/outgoing_webhook_event/events.rs@@ -10,7 +10,7 @@ use crate::{pub trait OutgoingWebhookLogsFilterAnalytics: LoadRow<OutgoingWebhookLogsResult> {}pub async fn get_outgoing_webhook_event<T>(- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,query_param: OutgoingWebhookLogsRequest,pool: &T,) -> FiltersResult<Vec<OutgoingWebhookLogsResult>>@@ -72,7 +72,7 @@ where}#[derive(Debug, serde::Serialize, serde::Deserialize)]pub struct OutgoingWebhookLogsResult {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub event_id: String,pub event_type: String,pub outgoing_webhook_event_type: String,diff --git a/crates/analytics/src/payment_intents/core.rs b/crates/analytics/src/payment_intents/core.rsindex c7546a4ab0..96e77be19b 100644--- a/crates/analytics/src/payment_intents/core.rs+++ b/crates/analytics/src/payment_intents/core.rs@@ -43,7 +43,7 @@ pub enum TaskType {#[instrument(skip_all)]pub async fn get_metrics(pool: &AnalyticsProvider,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,req: GetPaymentIntentMetricRequest,) -> AnalyticsResult<MetricsResponse<MetricsBucketResponse>> {let mut metrics_accumulator: HashMap<@@ -149,7 +149,7 @@ pub async fn get_metrics(pub async fn get_filters(pool: &AnalyticsProvider,req: GetPaymentIntentFiltersRequest,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<PaymentIntentFiltersResponse> {let mut res = PaymentIntentFiltersResponse::default();diff --git a/crates/analytics/src/payment_intents/filters.rs b/crates/analytics/src/payment_intents/filters.rsindex 1a74cfd510..29eb8f95d7 100644--- a/crates/analytics/src/payment_intents/filters.rs+++ b/crates/analytics/src/payment_intents/filters.rs@@ -16,7 +16,7 @@ pub trait PaymentIntentFilterAnalytics: LoadRow<PaymentIntentFilterRow> {}pub async fn get_payment_intent_filter_for_dimension<T>(dimension: PaymentIntentDimensions,- merchant: &String,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &TimeRange,pool: &T,) -> FiltersResult<Vec<PaymentIntentFilterRow>>@@ -37,7 +37,7 @@ where.switch()?;query_builder- .add_filter_clause("merchant_id", merchant)+ .add_filter_clause("merchant_id", merchant_id).switch()?;query_builder.set_distinct();diff --git a/crates/analytics/src/payment_intents/metrics.rs b/crates/analytics/src/payment_intents/metrics.rsindex a06d76ce8f..b314b86356 100644--- a/crates/analytics/src/payment_intents/metrics.rs+++ b/crates/analytics/src/payment_intents/metrics.rs@@ -47,7 +47,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentIntentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -68,7 +68,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentIntentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payment_intents/metrics/payment_intent_count.rs b/crates/analytics/src/payment_intents/metrics/payment_intent_count.rsindex 5db153c8a3..c3443902f0 100644--- a/crates/analytics/src/payment_intents/metrics/payment_intent_count.rs+++ b/crates/analytics/src/payment_intents/metrics/payment_intent_count.rs@@ -32,7 +32,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentIntentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs b/crates/analytics/src/payment_intents/metrics/smart_retried_amount.rsindex 3b78a35582..d14174338c 100644--- a/crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs+++ b/crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs@@ -38,7 +38,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentIntentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs b/crates/analytics/src/payment_intents/metrics/successful_smart_retries.rsindex ef0bb6672f..27d54256b1 100644--- a/crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs+++ b/crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs@@ -38,7 +38,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentIntentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payment_intents/metrics/total_smart_retries.rs b/crates/analytics/src/payment_intents/metrics/total_smart_retries.rsindex 3ef8c02aca..ee63d15ee4 100644--- a/crates/analytics/src/payment_intents/metrics/total_smart_retries.rs+++ b/crates/analytics/src/payment_intents/metrics/total_smart_retries.rs@@ -35,7 +35,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentIntentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/core.rs b/crates/analytics/src/payments/core.rsindex e943bf0ac6..1a27fa067a 100644--- a/crates/analytics/src/payments/core.rs+++ b/crates/analytics/src/payments/core.rs@@ -45,7 +45,7 @@ pub enum TaskType {#[instrument(skip_all)]pub async fn get_metrics(pool: &AnalyticsProvider,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,req: GetPaymentMetricRequest,) -> AnalyticsResult<MetricsResponse<MetricsBucketResponse>> {let mut metrics_accumulator: HashMap<@@ -222,7 +222,7 @@ pub async fn get_metrics(pub async fn get_filters(pool: &AnalyticsProvider,req: GetPaymentFiltersRequest,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<PaymentFiltersResponse> {let mut res = PaymentFiltersResponse::default();diff --git a/crates/analytics/src/payments/distribution.rs b/crates/analytics/src/payments/distribution.rsindex c238eb79b9..17c29828eb 100644--- a/crates/analytics/src/payments/distribution.rs+++ b/crates/analytics/src/payments/distribution.rs@@ -47,7 +47,7 @@ where&self,distribution: &Distribution,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -69,7 +69,7 @@ where&self,distribution: &Distribution,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/distribution/payment_error_message.rs b/crates/analytics/src/payments/distribution/payment_error_message.rsindex 7dc42994d2..90869356de 100644--- a/crates/analytics/src/payments/distribution/payment_error_message.rs+++ b/crates/analytics/src/payments/distribution/payment_error_message.rs@@ -32,7 +32,7 @@ where&self,distribution: &Distribution,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/filters.rs b/crates/analytics/src/payments/filters.rsindex 232a3e5b0a..b25c3fcba2 100644--- a/crates/analytics/src/payments/filters.rs+++ b/crates/analytics/src/payments/filters.rs@@ -16,7 +16,7 @@ pub trait PaymentFilterAnalytics: LoadRow<FilterRow> {}pub async fn get_payment_filter_for_dimension<T>(dimension: PaymentDimensions,- merchant: &String,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &TimeRange,pool: &T,) -> FiltersResult<Vec<FilterRow>>@@ -37,7 +37,7 @@ where.switch()?;query_builder- .add_filter_clause("merchant_id", merchant)+ .add_filter_clause("merchant_id", merchant_id).switch()?;query_builder.set_distinct();diff --git a/crates/analytics/src/payments/metrics.rs b/crates/analytics/src/payments/metrics.rsindex 1dd1481688..b5e0a48792 100644--- a/crates/analytics/src/payments/metrics.rs+++ b/crates/analytics/src/payments/metrics.rs@@ -57,7 +57,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -78,7 +78,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/metrics/avg_ticket_size.rs b/crates/analytics/src/payments/metrics/avg_ticket_size.rsindex 1a1fbe5298..b09e2b2365 100644--- a/crates/analytics/src/payments/metrics/avg_ticket_size.rs+++ b/crates/analytics/src/payments/metrics/avg_ticket_size.rs@@ -31,7 +31,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/metrics/connector_success_rate.rs b/crates/analytics/src/payments/metrics/connector_success_rate.rsindex c5da4b51a0..eb2ff1e3aa 100644--- a/crates/analytics/src/payments/metrics/connector_success_rate.rs+++ b/crates/analytics/src/payments/metrics/connector_success_rate.rs@@ -33,7 +33,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/metrics/payment_count.rs b/crates/analytics/src/payments/metrics/payment_count.rsindex 6fd12edea7..9a8b3157d7 100644--- a/crates/analytics/src/payments/metrics/payment_count.rs+++ b/crates/analytics/src/payments/metrics/payment_count.rs@@ -30,7 +30,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/metrics/payment_processed_amount.rs b/crates/analytics/src/payments/metrics/payment_processed_amount.rsindex 772156a070..a3be7a9662 100644--- a/crates/analytics/src/payments/metrics/payment_processed_amount.rs+++ b/crates/analytics/src/payments/metrics/payment_processed_amount.rs@@ -31,7 +31,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/metrics/payment_success_count.rs b/crates/analytics/src/payments/metrics/payment_success_count.rsindex ce63424d1c..e2c3834a44 100644--- a/crates/analytics/src/payments/metrics/payment_success_count.rs+++ b/crates/analytics/src/payments/metrics/payment_success_count.rs@@ -31,7 +31,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/metrics/retries_count.rs b/crates/analytics/src/payments/metrics/retries_count.rsindex 33aa7d3b0b..f0e4084c65 100644--- a/crates/analytics/src/payments/metrics/retries_count.rs+++ b/crates/analytics/src/payments/metrics/retries_count.rs@@ -36,7 +36,7 @@ whereasync fn load_metrics(&self,_dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/payments/metrics/success_rate.rs b/crates/analytics/src/payments/metrics/success_rate.rsindex 1f48deaad1..70fb1814a8 100644--- a/crates/analytics/src/payments/metrics/success_rate.rs+++ b/crates/analytics/src/payments/metrics/success_rate.rs@@ -30,7 +30,7 @@ whereasync fn load_metrics(&self,dimensions: &[PaymentDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/query.rs b/crates/analytics/src/query.rsindex 381deb60b8..cda40e2294 100644--- a/crates/analytics/src/query.rs+++ b/crates/analytics/src/query.rs@@ -354,6 +354,12 @@ pub trait ToSql<T: AnalyticsDataSource> {fn to_sql(&self, table_engine: &TableEngine) -> error_stack::Result<String, ParsingError>;}+impl<T: AnalyticsDataSource> ToSql<T> for &common_utils::id_type::MerchantId {+ fn to_sql(&self, _table_engine: &TableEngine) -> error_stack::Result<String, ParsingError> {+ Ok(self.get_string_repr().to_owned())+ }+}+/// Implement `ToSql` on arrays of types that impl `ToString`.macro_rules! impl_to_sql_for_to_string {($($type:ty),+) => {diff --git a/crates/analytics/src/refunds/core.rs b/crates/analytics/src/refunds/core.rsindex 57480c7cec..c1fc83da76 100644--- a/crates/analytics/src/refunds/core.rs+++ b/crates/analytics/src/refunds/core.rs@@ -28,7 +28,7 @@ use crate::{pub async fn get_metrics(pool: &AnalyticsProvider,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,req: GetRefundMetricRequest,) -> AnalyticsResult<MetricsResponse<RefundMetricsBucketResponse>> {let mut metrics_accumulator: HashMap<RefundMetricsBucketIdentifier, RefundMetricsAccumulator> =@@ -125,7 +125,7 @@ pub async fn get_metrics(pub async fn get_filters(pool: &AnalyticsProvider,req: GetRefundFilterRequest,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,) -> AnalyticsResult<RefundFiltersResponse> {let mut res = RefundFiltersResponse::default();for dim in req.group_by_names {diff --git a/crates/analytics/src/refunds/filters.rs b/crates/analytics/src/refunds/filters.rsindex 29375483eb..138c4b86ea 100644--- a/crates/analytics/src/refunds/filters.rs+++ b/crates/analytics/src/refunds/filters.rs@@ -18,7 +18,7 @@ pub trait RefundFilterAnalytics: LoadRow<RefundFilterRow> {}pub async fn get_refund_filter_for_dimension<T>(dimension: RefundDimensions,- merchant: &String,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &TimeRange,pool: &T,) -> FiltersResult<Vec<RefundFilterRow>>@@ -39,7 +39,7 @@ where.switch()?;query_builder- .add_filter_clause("merchant_id", merchant)+ .add_filter_clause("merchant_id", merchant_id).switch()?;query_builder.set_distinct();diff --git a/crates/analytics/src/refunds/metrics.rs b/crates/analytics/src/refunds/metrics.rsindex d8a59e5488..e8e6d14903 100644--- a/crates/analytics/src/refunds/metrics.rs+++ b/crates/analytics/src/refunds/metrics.rs@@ -51,7 +51,7 @@ whereasync fn load_metrics(&self,dimensions: &[RefundDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &RefundFilters,granularity: &Option<Granularity>,time_range: &TimeRange,@@ -72,7 +72,7 @@ whereasync fn load_metrics(&self,dimensions: &[RefundDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &RefundFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/refunds/metrics/refund_count.rs b/crates/analytics/src/refunds/metrics/refund_count.rsindex 14240ff8e1..1ce6ed4642 100644--- a/crates/analytics/src/refunds/metrics/refund_count.rs+++ b/crates/analytics/src/refunds/metrics/refund_count.rs@@ -30,7 +30,7 @@ whereasync fn load_metrics(&self,dimensions: &[RefundDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &RefundFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/refunds/metrics/refund_processed_amount.rs b/crates/analytics/src/refunds/metrics/refund_processed_amount.rsindex 829b11b082..c03e85caad 100644--- a/crates/analytics/src/refunds/metrics/refund_processed_amount.rs+++ b/crates/analytics/src/refunds/metrics/refund_processed_amount.rs@@ -30,7 +30,7 @@ whereasync fn load_metrics(&self,dimensions: &[RefundDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &RefundFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/refunds/metrics/refund_success_count.rs b/crates/analytics/src/refunds/metrics/refund_success_count.rsindex 0219340b40..ae7b39f1e9 100644--- a/crates/analytics/src/refunds/metrics/refund_success_count.rs+++ b/crates/analytics/src/refunds/metrics/refund_success_count.rs@@ -31,7 +31,7 @@ whereasync fn load_metrics(&self,dimensions: &[RefundDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &RefundFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/refunds/metrics/refund_success_rate.rs b/crates/analytics/src/refunds/metrics/refund_success_rate.rsindex 36d82385b3..b42641df4d 100644--- a/crates/analytics/src/refunds/metrics/refund_success_rate.rs+++ b/crates/analytics/src/refunds/metrics/refund_success_rate.rs@@ -29,7 +29,7 @@ whereasync fn load_metrics(&self,dimensions: &[RefundDimensions],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &RefundFilters,granularity: &Option<Granularity>,time_range: &TimeRange,diff --git a/crates/analytics/src/sdk_events/core.rs b/crates/analytics/src/sdk_events/core.rsindex 51709f37e4..3eca479818 100644--- a/crates/analytics/src/sdk_events/core.rs+++ b/crates/analytics/src/sdk_events/core.rs@@ -26,7 +26,7 @@ use crate::{pub async fn sdk_events_core(pool: &AnalyticsProvider,req: SdkEventsRequest,- publishable_key: &str,+ publishable_key: &String,) -> AnalyticsResult<Vec<SdkEventsResult>> {match pool {AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented(diff --git a/crates/analytics/src/sdk_events/events.rs b/crates/analytics/src/sdk_events/events.rsindex a4d044267e..3120c75138 100644--- a/crates/analytics/src/sdk_events/events.rs+++ b/crates/analytics/src/sdk_events/events.rs@@ -14,7 +14,7 @@ use crate::{pub trait SdkEventsFilterAnalytics: LoadRow<SdkEventsResult> {}pub async fn get_sdk_event<T>(- merchant_id: &str,+ publishable_key: &String,request: SdkEventsRequest,pool: &T,) -> FiltersResult<Vec<SdkEventsResult>>@@ -34,7 +34,7 @@ wherequery_builder.add_select_column("*").switch()?;query_builder- .add_filter_clause("merchant_id", merchant_id)+ .add_filter_clause("merchant_id", publishable_key).switch()?;query_builder.add_filter_clause("payment_id", request.payment_id)@@ -57,7 +57,7 @@ where}#[derive(Debug, serde::Serialize, serde::Deserialize)]pub struct SdkEventsResult {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: String,pub event_name: Option<String>,pub log_type: Option<String>,diff --git a/crates/analytics/src/search.rs b/crates/analytics/src/search.rsindex a5bd117bd6..4143a6df41 100644--- a/crates/analytics/src/search.rs+++ b/crates/analytics/src/search.rs@@ -13,7 +13,7 @@ use crate::opensearch::{pub async fn msearch_results(client: &OpenSearchClient,req: GetGlobalSearchRequest,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,indexes: Vec<SearchIndex>,) -> CustomResult<Vec<GetSearchResponse>, OpenSearchError> {let mut query_builder =@@ -22,7 +22,7 @@ pub async fn msearch_results(query_builder.add_filter_clause("merchant_id.keyword".to_string(),- vec![merchant_id.to_string()],+ vec![merchant_id.get_string_repr().to_owned()],).switch()?;@@ -137,7 +137,7 @@ pub async fn msearch_results(pub async fn search_results(client: &OpenSearchClient,req: GetSearchRequestWithIndex,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<GetSearchResponse, OpenSearchError> {let search_req = req.search_req;@@ -147,7 +147,7 @@ pub async fn search_results(query_builder.add_filter_clause("merchant_id.keyword".to_string(),- vec![merchant_id.to_string()],+ vec![merchant_id.get_string_repr().to_owned()],).switch()?;diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex fe60a2d445..5ba200bdc9 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -72,8 +72,8 @@ pub struct MerchantAccountCreate {pub sub_merchants_enabled: Option<bool>,/// Refers to the Parent Merchant ID if the merchant being created is a sub-merchant- #[schema(max_length = 255, example = "xkkdf909012sdjki2dkh5sdf")]- pub parent_merchant_id: Option<String>,+ #[schema(max_length = 255, example = "xkkdf909012sdjki2dkh5sdf", value_type = Option<String>)]+ pub parent_merchant_id: Option<id_type::MerchantId>,/// A boolean value to indicate if payment response hash needs to be enabled#[schema(default = false, example = true)]@@ -264,8 +264,8 @@ pub struct MerchantAccountMetadata {#[serde(deny_unknown_fields)]pub struct MerchantAccountUpdate {/// The identifier for the Merchant Account- #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: id_type::MerchantId,/// Name of the Merchant Account#[schema(example = "NewAge Retailer")]@@ -296,8 +296,8 @@ pub struct MerchantAccountUpdate {pub sub_merchants_enabled: Option<bool>,/// Refers to the Parent Merchant ID if the merchant being created is a sub-merchant- #[schema(max_length = 255, example = "xkkdf909012sdjki2dkh5sdf")]- pub parent_merchant_id: Option<String>,+ #[schema(max_length = 255, example = "xkkdf909012sdjki2dkh5sdf", value_type = Option<String>)]+ pub parent_merchant_id: Option<id_type::MerchantId>,/// A boolean value to indicate if payment response hash needs to be enabled#[schema(default = false, example = true)]@@ -346,8 +346,8 @@ pub struct MerchantAccountUpdate {#[derive(Clone, Debug, ToSchema, Serialize)]pub struct MerchantAccountResponse {/// The identifier for the Merchant Account- #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: id_type::MerchantId,/// Name of the Merchant Account#[schema(value_type = Option<String>,example = "NewAge Retailer")]@@ -392,8 +392,8 @@ pub struct MerchantAccountResponse {pub sub_merchants_enabled: Option<bool>,/// Refers to the Parent Merchant ID if the merchant being created is a sub-merchant- #[schema(max_length = 255, example = "xkkdf909012sdjki2dkh5sdf")]- pub parent_merchant_id: Option<String>,+ #[schema(max_length = 255, example = "xkkdf909012sdjki2dkh5sdf", value_type = Option<String>)]+ pub parent_merchant_id: Option<id_type::MerchantId>,/// API key that will be used for server side API access#[schema(example = "AH3423bkjbkjdsfbkj")]@@ -555,8 +555,8 @@ pub struct WebhookDetails {#[derive(Debug, Serialize, ToSchema)]pub struct MerchantAccountDeleteResponse {/// The identifier for the Merchant Account- #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: id_type::MerchantId,/// If the connector is deleted or not#[schema(example = false)]pub deleted: bool,@@ -564,12 +564,13 @@ pub struct MerchantAccountDeleteResponse {#[derive(Default, Debug, Deserialize, Serialize)]pub struct MerchantId {- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,}#[derive(Default, Debug, Deserialize, ToSchema, Serialize)]pub struct MerchantConnectorId {- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: id_type::MerchantId,pub merchant_connector_id: String,}@@ -1037,8 +1038,8 @@ pub enum AcceptedCountries {#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]pub struct MerchantConnectorDeleteResponse {/// The identifier for the Merchant Account- #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: id_type::MerchantId,/// Unique ID of the connector#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]pub merchant_connector_id: String,@@ -1050,8 +1051,8 @@ pub struct MerchantConnectorDeleteResponse {#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]pub struct ToggleKVResponse {/// The identifier for the Merchant Account- #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: id_type::MerchantId,/// Status of KV for the specific merchant#[schema(example = true)]pub kv_enabled: bool,@@ -1076,7 +1077,8 @@ pub struct TransferKeyResponse {#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]pub struct ToggleKVRequest {#[serde(skip_deserializing)]- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: id_type::MerchantId,/// Status of KV for the specific merchant#[schema(example = true)]pub kv_enabled: bool,@@ -1208,7 +1210,7 @@ pub struct BusinessProfileCreate {#[schema(value_type = Option<BusinessPayoutLinkConfig>)]pub payout_link_config: Option<BusinessPayoutLinkConfig>,- /// These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.+ /// These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,}@@ -1216,8 +1218,8 @@ pub struct BusinessProfileCreate {#[derive(Clone, Debug, ToSchema, Serialize)]pub struct BusinessProfileResponse {/// The identifier for Merchant Account- #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: id_type::MerchantId,/// The default business profile that must be used for creating merchant accounts and payments#[schema(max_length = 64, example = "pro_abcdefghijklmnopqrstuvwxyz")]diff --git a/crates/api_models/src/analytics.rs b/crates/api_models/src/analytics.rsindex ca10d7ce59..9f95eda6a7 100644--- a/crates/api_models/src/analytics.rs+++ b/crates/api_models/src/analytics.rs@@ -114,7 +114,7 @@ pub struct ReportRequest {#[serde(rename_all = "camelCase")]pub struct GenerateReportRequest {pub request: ReportRequest,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub email: Secret<String, EmailStrategy>,}diff --git a/crates/api_models/src/api_keys.rs b/crates/api_models/src/api_keys.rsindex 801bbc63f5..1fc7ce97be 100644--- a/crates/api_models/src/api_keys.rs+++ b/crates/api_models/src/api_keys.rs@@ -33,8 +33,8 @@ pub struct CreateApiKeyResponse {pub key_id: String,/// The identifier for the Merchant Account.- #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: common_utils::id_type::MerchantId,/// The unique name for the API Key to help you identify it.#[schema(max_length = 64, example = "Sandbox integration key")]@@ -76,8 +76,8 @@ pub struct RetrieveApiKeyResponse {pub key_id: String,/// The identifier for the Merchant Account.- #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: common_utils::id_type::MerchantId,/// The unique name for the API Key to help you identify it.#[schema(max_length = 64, example = "Sandbox integration key")]@@ -134,15 +134,16 @@ pub struct UpdateApiKeyRequest {pub key_id: String,#[serde(skip_deserializing)]- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: common_utils::id_type::MerchantId,}/// The response body for revoking an API Key.#[derive(Debug, Serialize, ToSchema)]pub struct RevokeApiKeyResponse {/// The identifier for the Merchant Account.- #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: common_utils::id_type::MerchantId,/// The identifier for the API Key.#[schema(max_length = 64, example = "5hEEqkgJUyuxgSKGArHA4mWSnX")]diff --git a/crates/api_models/src/apple_pay_certificates_migration.rs b/crates/api_models/src/apple_pay_certificates_migration.rsindex 796734f53e..512bbc6f0e 100644--- a/crates/api_models/src/apple_pay_certificates_migration.rs+++ b/crates/api_models/src/apple_pay_certificates_migration.rs@@ -1,12 +1,12 @@#[derive(Debug, Clone, serde::Serialize)]pub struct ApplePayCertificatesMigrationResponse {- pub migration_successful: Vec<String>,- pub migration_failed: Vec<String>,+ pub migration_successful: Vec<common_utils::id_type::MerchantId>,+ pub migration_failed: Vec<common_utils::id_type::MerchantId>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]pub struct ApplePayCertificatesMigrationRequest {- pub merchant_ids: Vec<String>,+ pub merchant_ids: Vec<common_utils::id_type::MerchantId>,}impl common_utils::events::ApiEventMetric for ApplePayCertificatesMigrationRequest {}diff --git a/crates/api_models/src/connector_onboarding.rs b/crates/api_models/src/connector_onboarding.rsindex 7e8288d974..1ed18392dc 100644--- a/crates/api_models/src/connector_onboarding.rs+++ b/crates/api_models/src/connector_onboarding.rs@@ -45,7 +45,7 @@ pub enum PayPalOnboardingStatus {#[derive(serde::Serialize, Debug, Clone)]pub struct PayPalOnboardingDone {- pub payer_id: String,+ pub payer_id: common_utils::id_type::MerchantId,}#[derive(serde::Serialize, Debug, Clone)]diff --git a/crates/api_models/src/customers.rs b/crates/api_models/src/customers.rsindex ace4b54916..e774085da2 100644--- a/crates/api_models/src/customers.rs+++ b/crates/api_models/src/customers.rs@@ -21,8 +21,8 @@ pub struct CustomerRequest {pub customer_id: Option<id_type::CustomerId>,/// The identifier for the Merchant Account#[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- #[serde(default = "unknown_merchant", skip)]- pub merchant_id: String,+ #[serde(skip)]+ pub merchant_id: id_type::MerchantId,/// The customer's name#[schema(max_length = 255, value_type = Option<String>, example = "Jon Test")]pub name: Option<Secret<String>>,@@ -342,8 +342,3 @@ pub struct CustomerDeleteResponse {#[schema(example = false)]pub payment_methods_deleted: bool,}--#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]-fn unknown_merchant() -> String {- String::from("merchant_unknown")-}diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex fa7b3dc2dd..3f1df4b8e9 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -100,7 +100,7 @@ pub struct PaymentMethodCreate {/// This struct is only used by and internal api to migrate payment methodpub struct PaymentMethodMigrate {/// Merchant id- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,/// The type of payment method use for the payment.pub payment_method: Option<api_enums::PaymentMethod>,@@ -352,8 +352,8 @@ impl CardDetailUpdate {#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema)]pub struct PaymentMethodResponse {/// Unique identifier for a merchant- #[schema(example = "merchant_1671528864")]- pub merchant_id: String,+ #[schema(example = "merchant_1671528864", value_type = String)]+ pub merchant_id: id_type::MerchantId,/// The unique identifier of the customer.#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]@@ -1176,8 +1176,8 @@ pub struct PaymentMethodCollectLinkResponse {#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct PaymentMethodCollectLinkRenderRequest {/// Unique identifier for a merchant.- #[schema(example = "merchant_1671528864")]- pub merchant_id: String,+ #[schema(example = "merchant_1671528864", value_type = String)]+ pub merchant_id: id_type::MerchantId,/// The unique identifier for the collect link.#[schema(value_type = String, example = "pm_collect_link_2bdacf398vwzq5n422S1")]@@ -1346,7 +1346,7 @@ pub struct PaymentMethodRecord {pub email: Option<pii::Email>,pub phone: Option<masking::Secret<String>>,pub phone_country_code: Option<String>,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub payment_method: Option<api_enums::PaymentMethod>,pub payment_method_type: Option<api_enums::PaymentMethodType>,pub nick_name: masking::Secret<String>,diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 04cf4cd5da..2f50571113 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -272,9 +272,9 @@ pub struct PaymentsRequest {/// This is an identifier for the merchant account. This is inferred from the API key/// provided during the request- #[schema(max_length = 255, example = "merchant_1668273825")]+ #[schema(max_length = 255, example = "merchant_1668273825", value_type = Option<String>)]#[remove_in(PaymentsUpdateRequest, PaymentsCreateRequest, PaymentsConfirmRequest)]- pub merchant_id: Option<String>,+ pub merchant_id: Option<id_type::MerchantId>,/// Details of the routing configuration for that payment#[schema(value_type = Option<StraightThroughAlgorithm>, example = json!({@@ -934,7 +934,7 @@ impl From<MinorUnit> for Amount {#[serde(deny_unknown_fields)]pub struct PaymentsRedirectRequest {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub connector: String,pub param: String,}@@ -2877,7 +2877,8 @@ pub struct CardResponse {#[serde(rename_all = "snake_case")]pub struct RewardData {/// The merchant ID with which we have to call the connector- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: id_type::MerchantId,}#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]@@ -3282,7 +3283,8 @@ pub struct PaymentsCaptureRequest {#[serde(skip_deserializing)]pub payment_id: String,/// The unique identifier for the merchant- pub merchant_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub merchant_id: Option<id_type::MerchantId>,/// The Amount to be captured/ debited from the user's payment method.#[schema(value_type = i64, example = 6540)]pub amount_to_capture: Option<MinorUnit>,@@ -3570,8 +3572,8 @@ pub struct PaymentsResponse {/// This is an identifier for the merchant account. This is inferred from the API key/// provided during the request- #[schema(max_length = 255, example = "merchant_1668273825")]- pub merchant_id: Option<String>,+ #[schema(max_length = 255, example = "merchant_1668273825", value_type = Option<String>)]+ pub merchant_id: Option<id_type::MerchantId>,#[schema(value_type = IntentStatus, example = "failed", default = "requires_confirmation")]pub status: api_enums::IntentStatus,@@ -4110,7 +4112,7 @@ pub struct TimeRange {#[derive(Setter, Clone, Default, Debug, PartialEq, serde::Serialize)]pub struct VerifyResponse {pub verify_id: Option<String>,- pub merchant_id: Option<String>,+ pub merchant_id: Option<id_type::MerchantId>,// pub status: enums::VerifyStatus,pub client_secret: Option<Secret<String>>,pub customer_id: Option<id_type::CustomerId>,@@ -4276,7 +4278,7 @@ pub struct RedirectionResponse {pub struct PaymentsResponseForm {pub transaction_id: String,// pub transaction_reference_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub order_id: String,}@@ -4285,7 +4287,8 @@ pub struct PaymentsRetrieveRequest {/// The type of ID (ex: payment intent id, payment attempt id or connector txn id)pub resource_id: PaymentIdType,/// The identifier for the Merchant Account.- pub merchant_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub merchant_id: Option<id_type::MerchantId>,/// Decider to enable or disable the connector call for retrieve requestpub force_sync: bool,/// The parameters passed to a retrieve request@@ -4883,7 +4886,8 @@ pub struct PaymentsSessionResponse {#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]pub struct PaymentRetrieveBody {/// The identifier for the Merchant Account.- pub merchant_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub merchant_id: Option<id_type::MerchantId>,/// Decider to enable or disable the connector call for retrieve requestpub force_sync: Option<bool>,/// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK@@ -4899,7 +4903,8 @@ pub struct PaymentRetrieveBodyWithCredentials {/// The identifier for payment.pub payment_id: String,/// The identifier for the Merchant Account.- pub merchant_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub merchant_id: Option<id_type::MerchantId>,/// Decider to enable or disable the connector call for retrieve requestpub force_sync: Option<bool>,/// Merchant connector details used to make payments.@@ -4967,7 +4972,8 @@ pub struct PaymentsManualUpdateRequest {/// The identifier for the payment attemptpub attempt_id: String,/// Merchant ID- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: id_type::MerchantId,/// The status of the attemptpub attempt_status: Option<enums::AttemptStatus>,/// Error code of the connector@@ -5059,7 +5065,8 @@ pub struct PaymentsStartRequest {/// that have been done by a single merchant. This field is auto generated and is returned in the API response.pub payment_id: String,/// The identifier for the Merchant Account.- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: id_type::MerchantId,/// The identifier for the payment transactionpub attempt_id: String,}@@ -5275,7 +5282,8 @@ pub struct RetrievePaymentLinkResponse {/// Identifier for Payment Linkpub payment_link_id: String,/// Identifier for Merchant- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: id_type::MerchantId,/// Payment Linkpub link_to_pay: String,/// The payment amount. Amount for the payment in the lowest denomination of the currency@@ -5297,7 +5305,8 @@ pub struct RetrievePaymentLinkResponse {#[derive(Clone, Debug, serde::Deserialize, ToSchema, serde::Serialize)]pub struct PaymentLinkInitiateRequest {- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: id_type::MerchantId,pub payment_id: String,}diff --git a/crates/api_models/src/payouts.rs b/crates/api_models/src/payouts.rsindex 49a053dd60..9509df8c59 100644--- a/crates/api_models/src/payouts.rs+++ b/crates/api_models/src/payouts.rs@@ -33,8 +33,8 @@ pub struct PayoutCreateRequest {/// This is an identifier for the merchant account. This is inferred from the API key/// provided during the request- #[schema(max_length = 255, value_type = String, example = "merchant_1668273825")]- pub merchant_id: Option<String>,+ #[schema(max_length = 255, value_type = Option<String>, example = "merchant_1668273825")]+ pub merchant_id: Option<id_type::MerchantId>,/// The payout amount. Amount for the payout in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,#[schema(value_type = i64, example = 1000)]@@ -362,7 +362,7 @@ pub struct PayoutCreateResponse {/// This is an identifier for the merchant account. This is inferred from the API key/// provided during the request#[schema(max_length = 255, value_type = String, example = "merchant_1668273825")]- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,/// The payout amount. Amount for the payout in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,#[schema(value_type = i64, example = 1000)]@@ -531,7 +531,8 @@ pub struct PayoutAttemptResponse {#[derive(Default, Debug, Clone, Deserialize, ToSchema)]pub struct PayoutRetrieveBody {pub force_sync: Option<bool>,- pub merchant_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub merchant_id: Option<id_type::MerchantId>,}#[derive(Default, Debug, Serialize, ToSchema, Clone, Deserialize)]@@ -552,7 +553,8 @@ pub struct PayoutRetrieveRequest {pub force_sync: Option<bool>,/// The identifier for the Merchant Account.- pub merchant_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub merchant_id: Option<id_type::MerchantId>,}#[derive(Default, Debug, Serialize, ToSchema, Clone, Deserialize)]@@ -707,7 +709,8 @@ pub struct PayoutLinkResponse {#[derive(Clone, Debug, serde::Deserialize, ToSchema, serde::Serialize)]pub struct PayoutLinkInitiateRequest {- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: id_type::MerchantId,pub payout_id: String,}diff --git a/crates/api_models/src/recon.rs b/crates/api_models/src/recon.rsindex efbe28f96b..3aafcc413d 100644--- a/crates/api_models/src/recon.rs+++ b/crates/api_models/src/recon.rs@@ -5,7 +5,7 @@ use crate::enums;#[derive(serde::Deserialize, Debug, serde::Serialize)]pub struct ReconUpdateMerchantRequest {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub recon_status: enums::ReconStatus,pub user_email: pii::Email,}diff --git a/crates/api_models/src/refunds.rs b/crates/api_models/src/refunds.rsindex b7fd212057..dd6f1a2250 100644--- a/crates/api_models/src/refunds.rs+++ b/crates/api_models/src/refunds.rs@@ -32,8 +32,8 @@ pub struct RefundRequest {pub refund_id: Option<String>,/// The identifier for the Merchant Account- #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: Option<String>,+ #[schema(max_length = 255, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = Option<String>)]+ pub merchant_id: Option<common_utils::id_type::MerchantId>,/// Total amount for which the refund is to be initiated. Amount for the payment in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc., If not provided, this will default to the full payment amount#[schema(value_type = Option<i64> , minimum = 100, example = 6540)]@@ -103,7 +103,8 @@ pub struct RefundManualUpdateRequest {#[serde(skip)]pub refund_id: String,/// Merchant ID- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: common_utils::id_type::MerchantId,/// The status for refundpub status: Option<RefundStatus>,/// The code for the errordiff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rsindex 4e62a5f67d..7d1bb5bdf3 100644--- a/crates/api_models/src/routing.rs+++ b/crates/api_models/src/routing.rs@@ -445,7 +445,8 @@ pub struct RoutingDictionaryRecord {#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct RoutingDictionary {- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: common_utils::id_type::MerchantId,pub active_id: Option<String>,pub records: Vec<RoutingDictionaryRecord>,}diff --git a/crates/api_models/src/user.rs b/crates/api_models/src/user.rsindex 5bf855c490..03e59db1e8 100644--- a/crates/api_models/src/user.rs+++ b/crates/api_models/src/user.rs@@ -28,7 +28,7 @@ pub type SignUpResponse = DashboardEntryResponse;#[derive(serde::Serialize, Debug, Clone)]pub struct DashboardEntryResponse {pub token: Secret<String>,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub name: Secret<String>,pub email: pii::Email,pub verification_days_left: Option<i64>,@@ -71,7 +71,7 @@ pub struct AuthorizeResponse {pub user_id: String,//this field is added for audit/debug reasons#[serde(skip_serializing)]- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,}#[derive(serde::Deserialize, Debug, serde::Serialize)]@@ -125,7 +125,7 @@ pub struct AcceptInviteFromEmailRequest {#[derive(Debug, serde::Deserialize, serde::Serialize)]pub struct SwitchMerchantIdRequest {- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,}#[derive(serde::Deserialize, Debug, serde::Serialize)]@@ -156,7 +156,7 @@ pub struct UserDetails {#[derive(serde::Serialize, Debug, Clone)]pub struct GetUserDetailsResponse {- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub name: Secret<String>,pub email: pii::Email,pub verification_days_left: Option<i64>,@@ -201,7 +201,7 @@ pub struct SendVerifyEmailRequest {#[derive(Debug, serde::Serialize)]pub struct UserMerchantAccount {- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub merchant_name: OptionalEncryptableName,pub is_active: bool,pub role_id: String,@@ -212,14 +212,14 @@ pub struct UserMerchantAccount {#[cfg(feature = "recon")]#[derive(serde::Serialize, Debug)]pub struct VerifyTokenResponse {- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub user_email: pii::Email,}#[derive(Debug, serde::Deserialize, serde::Serialize)]pub struct UpdateUserAccountDetailsRequest {pub name: Option<Secret<String>>,- pub preferred_merchant_id: Option<String>,+ pub preferred_merchant_id: Option<id_type::MerchantId>,}#[derive(Debug, serde::Deserialize, serde::Serialize)]diff --git a/crates/api_models/src/user_role.rs b/crates/api_models/src/user_role.rsindex 089e22a62a..02e40e2fe1 100644--- a/crates/api_models/src/user_role.rs+++ b/crates/api_models/src/user_role.rs@@ -99,13 +99,13 @@ pub enum UserStatus {#[derive(Debug, serde::Deserialize, serde::Serialize)]pub struct MerchantSelectRequest {- pub merchant_ids: Vec<String>,+ pub merchant_ids: Vec<common_utils::id_type::MerchantId>,// TODO: Remove this once the token only api is being usedpub need_dashboard_entry_response: Option<bool>,}#[derive(Debug, serde::Deserialize, serde::Serialize)]pub struct AcceptInvitationRequest {- pub merchant_ids: Vec<String>,+ pub merchant_ids: Vec<common_utils::id_type::MerchantId>,}#[derive(Debug, serde::Deserialize, serde::Serialize)]diff --git a/crates/api_models/src/verifications.rs b/crates/api_models/src/verifications.rsindex 01193886e1..5fa1b8cd4c 100644--- a/crates/api_models/src/verifications.rs+++ b/crates/api_models/src/verifications.rs@@ -27,7 +27,7 @@ pub struct ApplepayMerchantResponse {#[derive(Debug, serde::Deserialize)]#[serde(rename_all = "snake_case")]pub struct ApplepayGetVerifiedDomainsParam {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub merchant_connector_account_id: String,}/// Response to be sent for derivation of the already verified domainsdiff --git a/crates/api_models/src/webhook_events.rs b/crates/api_models/src/webhook_events.rsindex 40a694a665..2dcc6d6432 100644--- a/crates/api_models/src/webhook_events.rs+++ b/crates/api_models/src/webhook_events.rs@@ -47,8 +47,8 @@ pub struct EventListItemResponse {pub event_id: String,/// The identifier for the Merchant Account.- #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44")]- pub merchant_id: String,+ #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]+ pub merchant_id: common_utils::id_type::MerchantId,/// The identifier for the Business Profile.#[schema(max_length = 64, example = "SqB0zwDGR5wHppWf0bx7GKr1f2")]@@ -97,7 +97,11 @@ pub struct EventRetrieveResponse {impl common_utils::events::ApiEventMetric for EventRetrieveResponse {fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {Some(common_utils::events::ApiEventsType::Events {- merchant_id_or_profile_id: self.event_information.merchant_id.clone(),+ merchant_id_or_profile_id: self+ .event_information+ .merchant_id+ .get_string_repr()+ .to_owned(),})}}diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rsindex 2c10e3a81e..b245e67e85 100644--- a/crates/api_models/src/webhooks.rs+++ b/crates/api_models/src/webhooks.rs@@ -207,7 +207,8 @@ pub struct IncomingWebhookDetails {#[derive(Debug, Clone, Serialize, ToSchema)]pub struct OutgoingWebhook {/// The merchant id of the merchant- pub merchant_id: String,+ #[schema(value_type = String)]+ pub merchant_id: common_utils::id_type::MerchantId,/// The unique event id for each webhookpub event_id: String,diff --git a/crates/cards/Cargo.toml b/crates/cards/Cargo.tomlindex ed2be96655..9091b1e697 100644--- a/crates/cards/Cargo.toml+++ b/crates/cards/Cargo.toml@@ -20,7 +20,7 @@ common_utils = { version = "0.1.0", path = "../common_utils" }masking = { version = "0.1.0", path = "../masking" }[target.'cfg(not(target_arch = "wasm32"))'.dependencies]-router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }+router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"], default-features = false }[dev-dependencies]serde_json = "1.0.115"diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex a9eec76cc1..3454a6ba02 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -3003,3 +3003,10 @@ pub enum Owner {Tenant,Internal,}++#[derive(Clone, Debug, serde::Serialize)]+#[serde(rename_all = "snake_case")]+pub enum PayoutRetryType {+ SingleConnector,+ MultiConnector,+}diff --git a/crates/common_utils/Cargo.toml b/crates/common_utils/Cargo.tomlindex 61d96a2173..4939c0f160 100644--- a/crates/common_utils/Cargo.toml+++ b/crates/common_utils/Cargo.toml@@ -15,6 +15,7 @@ signals = ["dep:signal-hook-tokio", "dep:signal-hook", "dep:tokio", "dep:router_async_ext = ["dep:async-trait", "dep:futures"]logs = ["dep:router_env"]metrics = ["dep:router_env", "dep:futures"]+payouts = ["common_enums/payouts"][dependencies]async-trait = { version = "0.1.79", optional = true }@@ -54,7 +55,7 @@ uuid = { version = "1.8.0", features = ["v7"] }# First party cratescommon_enums = { version = "0.1.0", path = "../common_enums" }masking = { version = "0.1.0", path = "../masking" }-router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"], optional = true }+router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"], optional = true, default-features = false }[target.'cfg(not(target_os = "windows"))'.dependencies]signal-hook-tokio = { version = "0.3.1", features = ["futures-v0_3"], optional = true }diff --git a/crates/common_utils/src/access_token.rs b/crates/common_utils/src/access_token.rsindex 56c2a4f784..3407d2840d 100644--- a/crates/common_utils/src/access_token.rs+++ b/crates/common_utils/src/access_token.rs@@ -2,10 +2,12 @@use std::fmt::Display;+use crate::id_type;+/// Create a key for fetching the access token from redispub fn create_access_token_key(- merchant_id: impl Display,+ merchant_id: &id_type::MerchantId,merchant_connector_id_or_connector_name: impl Display,) -> String {- format!("access_token_{merchant_id}_{merchant_connector_id_or_connector_name}")+ merchant_id.get_access_token_key(merchant_connector_id_or_connector_name)}diff --git a/crates/common_utils/src/events.rs b/crates/common_utils/src/events.rsindex b2420709a7..c2294f865a 100644--- a/crates/common_utils/src/events.rs+++ b/crates/common_utils/src/events.rs@@ -105,8 +105,13 @@ impl_api_event_type!(Miscellaneous,(String,+ id_type::MerchantId,+ (id_type::MerchantId, String),+ (&id_type::MerchantId, String),+ (&id_type::MerchantId, &String),(&String, &String),(Option<i64>, Option<i64>, String),+ (Option<i64>, Option<i64>, id_type::MerchantId),bool));diff --git a/crates/common_utils/src/id_type/merchant.rs b/crates/common_utils/src/id_type/merchant.rsindex 3accdc3a36..838cc52c1d 100644--- a/crates/common_utils/src/id_type/merchant.rs+++ b/crates/common_utils/src/id_type/merchant.rs@@ -3,7 +3,10 @@//! Ids for merchant account are derived from the merchant name//! If there are any special characters, they are removed-use std::{borrow::Cow, fmt::Debug};+use std::{+ borrow::Cow,+ fmt::{Debug, Display},+};use diesel::{backend::Backend,@@ -14,17 +17,20 @@ use diesel::{};use error_stack::{Result, ResultExt};use serde::{Deserialize, Serialize};+use utoipa::ToSchema;use crate::{consts::{MAX_ALLOWED_MERCHANT_REFERENCE_ID_LENGTH, MIN_REQUIRED_MERCHANT_REFERENCE_ID_LENGTH},- errors, generate_id_with_default_len, generate_ref_id_with_default_length,+ date_time, errors, generate_id_with_default_len, generate_ref_id_with_default_length,id_type::{AlphaNumericId, LengthId},new_type::MerchantName,+ types::keymanager,};/// A type for merchant_id that can be used for merchant ids-#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, AsExpression)]+#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, AsExpression, Hash, ToSchema)]#[diesel(sql_type = sql_types::Text)]+#[schema(value_type = String)]pub struct MerchantId(LengthId<MAX_ALLOWED_MERCHANT_REFERENCE_ID_LENGTH, MIN_REQUIRED_MERCHANT_REFERENCE_ID_LENGTH>,);@@ -36,6 +42,22 @@ impl Debug for MerchantId {}}+/// This should be temporary, we should not have direct impl of Display for merchant id+impl Display for MerchantId {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ write!(f, "{}", self.get_string_repr())+ }+}++#[cfg(feature = "metrics")]+/// This is implemented so that we can use merchant id directly as attribute in metrics+impl From<MerchantId> for router_env::opentelemetry::Value {+ fn from(val: MerchantId) -> Self {+ let string_value = val.0 .0 .0;+ Self::String(router_env::opentelemetry::StringValue::from(string_value))+ }+}+impl<DB> Queryable<sql_types::Text, DB> for MerchantIdwhereDB: Backend,@@ -83,6 +105,43 @@ impl MerchantId {Self(length_id)}++ /// Get a merchant id with the const value of `MERCHANT_ID_NOT_FOUND`+ pub fn get_merchant_id_not_found() -> Self {+ let alphanumeric_id = AlphaNumericId::new_unchecked("MERCHANT_ID_NOT_FOUND".to_string());+ let length_id = LengthId::new_unchecked(alphanumeric_id);+ Self(length_id)+ }++ /// Get a merchant id for internal use only+ pub fn get_internal_user_merchant_id(merchant_id: &str) -> Self {+ let alphanumeric_id = AlphaNumericId::new_unchecked(merchant_id.to_string());+ let length_id = LengthId::new_unchecked(alphanumeric_id);+ Self(length_id)+ }++ /// Create a new merchant_id from unix timestamp, of the format `merchant_{timestamp}`+ pub fn new_from_unix_timestamp() -> Self {+ let merchant_id = format!("merchant_{}", date_time::now_unix_timestamp());++ let alphanumeric_id = AlphaNumericId::new_unchecked(merchant_id);+ let length_id = LengthId::new_unchecked(alphanumeric_id);++ Self(length_id)+ }++ /// Get a merchant id with a value of `irrelevant_merchant_id`+ pub fn get_irrelevant_merchant_id() -> Self {+ let alphanumeric_id = AlphaNumericId::new_unchecked("irrelevant_merchant_id".to_string());+ let length_id = LengthId::new_unchecked(alphanumeric_id);+ Self(length_id)+ }+}++impl From<MerchantId> for keymanager::Identifier {+ fn from(value: MerchantId) -> Self {+ Self::Merchant(value)+ }}impl masking::SerializableSecret for MerchantId {}@@ -112,3 +171,129 @@ where.map(Self)}}++/// All the keys that can be formed from merchant id+impl MerchantId {+ /// get step up enabled key+ pub fn get_step_up_enabled_key(&self) -> String {+ format!("step_up_enabled_{}", self.get_string_repr())+ }++ /// get_max_auto_retries_enabled key+ pub fn get_max_auto_retries_enabled(&self) -> String {+ format!("max_auto_retries_enabled_{}", self.get_string_repr())+ }++ /// get_requires_cvv_key+ pub fn get_requires_cvv_key(&self) -> String {+ format!("{}_requires_cvv", self.get_string_repr())+ }++ /// get_pm_filters_cgraph_key+ pub fn get_pm_filters_cgraph_key(&self) -> String {+ format!("pm_filters_cgraph_{}", self.get_string_repr())+ }++ /// get_blocklist_enabled_key+ pub fn get_blocklist_guard_key(&self) -> String {+ format!("guard_blocklist_for_{}", self.get_string_repr())+ }++ /// get_merchant_fingerprint_secret_key+ pub fn get_merchant_fingerprint_secret_key(&self) -> String {+ format!("fingerprint_secret_{}", self.get_string_repr())+ }++ /// get_surcharge_dsk_key+ pub fn get_surcharge_dsk_key(&self) -> String {+ format!("surcharge_dsl_{}", self.get_string_repr())+ }++ /// get_dsk_key+ pub fn get_dsl_config(&self) -> String {+ format!("dsl_{}", self.get_string_repr())+ }++ /// get_creds_identifier_key+ pub fn get_creds_identifier_key(&self, creds_identifier: &str) -> String {+ format!("mcd_{}_{creds_identifier}", self.get_string_repr())+ }++ /// get_poll_id+ pub fn get_poll_id(&self, unique_id: &str) -> String {+ format!("poll_{}_{unique_id}", self.get_string_repr())+ }++ /// get_access_token_key+ pub fn get_access_token_key(+ &self,+ merchant_connector_id_or_connector_name: impl Display,+ ) -> String {+ format!(+ "access_token_{}_{merchant_connector_id_or_connector_name}",+ self.get_string_repr()+ )+ }++ /// get_skip_saving_wallet_at_connector_key+ pub fn get_skip_saving_wallet_at_connector_key(&self) -> String {+ format!("skip_saving_wallet_at_connector_{}", self.get_string_repr())+ }++ /// get_payment_config_routing_id+ pub fn get_payment_config_routing_id(&self) -> String {+ format!("payment_config_id_{}", self.get_string_repr())+ }++ /// get_payment_method_surcharge_routing_id+ pub fn get_payment_method_surcharge_routing_id(&self) -> String {+ format!("payment_method_surcharge_id_{}", self.get_string_repr())+ }++ /// get_webhook_config_disabled_events_key+ pub fn get_webhook_config_disabled_events_key(&self, connector_id: &str) -> String {+ format!(+ "whconf_disabled_events_{}_{connector_id}",+ self.get_string_repr()+ )+ }++ /// get_should_call_gsm_payout_key+ pub fn get_should_call_gsm_payout_key(+ &self,+ payout_retry_type: common_enums::PayoutRetryType,+ ) -> String {+ match payout_retry_type {+ common_enums::PayoutRetryType::SingleConnector => format!(+ "should_call_gsm_single_connector_payout_{}",+ self.get_string_repr()+ ),+ common_enums::PayoutRetryType::MultiConnector => format!(+ "should_call_gsm_multiple_connector_payout_{}",+ self.get_string_repr()+ ),+ }+ }++ /// Get should call gsm key for payment+ pub fn get_should_call_gsm_key(&self) -> String {+ format!("should_call_gsm_{}", self.get_string_repr())+ }++ /// get_max_auto_single_connector_payout_retries_enabled_+ pub fn get_max_auto_single_connector_payout_retries_enabled(+ &self,+ payout_retry_type: common_enums::PayoutRetryType,+ ) -> String {+ match payout_retry_type {+ common_enums::PayoutRetryType::SingleConnector => format!(+ "max_auto_single_connector_payout_retries_enabled_{}",+ self.get_string_repr()+ ),+ common_enums::PayoutRetryType::MultiConnector => format!(+ "max_auto_multiple_connector_payout_retries_enabled_{}",+ self.get_string_repr()+ ),+ }+ }+}diff --git a/crates/common_utils/src/types/keymanager.rs b/crates/common_utils/src/types/keymanager.rsindex 5a7b87d0ce..f4b671abcd 100644--- a/crates/common_utils/src/types/keymanager.rs+++ b/crates/common_utils/src/types/keymanager.rs@@ -17,6 +17,7 @@ use crate::{crypto::Encryptable,encryption::Encryption,errors::{self, CustomResult},+ id_type,transformers::{ForeignFrom, ForeignTryFrom},};@@ -33,7 +34,7 @@ pub struct KeyManagerState {#[serde(tag = "data_identifier", content = "key_identifier")]pub enum Identifier {User(String),- Merchant(String),+ Merchant(id_type::MerchantId),UserAuth(String),}diff --git a/crates/diesel_models/src/address.rs b/crates/diesel_models/src/address.rsindex 57c4e36c78..8de7d8aa19 100644--- a/crates/diesel_models/src/address.rs+++ b/crates/diesel_models/src/address.rs@@ -1,7 +1,6 @@use common_utils::{crypto::{self, Encryptable},encryption::Encryption,- id_type,pii::EmailStrategy,types::keymanager::ToEncryptable,};@@ -28,8 +27,8 @@ pub struct AddressNew {pub last_name: Option<Encryption>,pub phone_number: Option<Encryption>,pub country_code: Option<String>,- pub customer_id: Option<id_type::CustomerId>,- pub merchant_id: String,+ pub customer_id: Option<common_utils::id_type::CustomerId>,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: Option<String>,pub created_at: PrimitiveDateTime,pub modified_at: PrimitiveDateTime,@@ -55,8 +54,8 @@ pub struct Address {pub country_code: Option<String>,pub created_at: PrimitiveDateTime,pub modified_at: PrimitiveDateTime,- pub customer_id: Option<id_type::CustomerId>,- pub merchant_id: String,+ pub customer_id: Option<common_utils::id_type::CustomerId>,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: Option<String>,pub updated_by: String,pub email: Option<Encryption>,diff --git a/crates/diesel_models/src/api_keys.rs b/crates/diesel_models/src/api_keys.rsindex 3b6de46e08..1781e65cde 100644--- a/crates/diesel_models/src/api_keys.rs+++ b/crates/diesel_models/src/api_keys.rs@@ -10,7 +10,7 @@ use crate::schema::api_keys;#[diesel(table_name = api_keys, primary_key(key_id), check_for_backend(diesel::pg::Pg))]pub struct ApiKey {pub key_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub name: String,pub description: Option<String>,pub hashed_api_key: HashedApiKey,@@ -24,7 +24,7 @@ pub struct ApiKey {#[diesel(table_name = api_keys)]pub struct ApiKeyNew {pub key_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub name: String,pub description: Option<String>,pub hashed_api_key: HashedApiKey,@@ -142,7 +142,7 @@ mod diesel_impl {#[derive(Default, Debug, Deserialize, Serialize, Clone)]pub struct ApiKeyExpiryTrackingData {pub key_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub api_key_name: String,pub prefix: String,pub api_key_expiry: Option<PrimitiveDateTime>,diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rsindex 050bc291c0..cb518805eb 100644--- a/crates/diesel_models/src/authentication.rs+++ b/crates/diesel_models/src/authentication.rs@@ -10,7 +10,7 @@ use crate::schema::authentication;#[diesel(table_name = authentication, primary_key(authentication_id), check_for_backend(diesel::pg::Pg))]pub struct Authentication {pub authentication_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub authentication_connector: String,pub connector_authentication_id: Option<String>,pub authentication_data: Option<serde_json::Value>,@@ -61,7 +61,7 @@ impl Authentication {#[diesel(table_name = authentication)]pub struct AuthenticationNew {pub authentication_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub authentication_connector: String,pub connector_authentication_id: Option<String>,// pub authentication_data: Option<serde_json::Value>,diff --git a/crates/diesel_models/src/authorization.rs b/crates/diesel_models/src/authorization.rsindex 694577bba3..2792bfdd55 100644--- a/crates/diesel_models/src/authorization.rs+++ b/crates/diesel_models/src/authorization.rs@@ -11,7 +11,7 @@ use crate::{enums as storage_enums, schema::incremental_authorization};#[diesel(table_name = incremental_authorization, primary_key(authorization_id, merchant_id), check_for_backend(diesel::pg::Pg))]pub struct Authorization {pub authorization_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: String,pub amount: MinorUnit,#[serde(with = "common_utils::custom_serde::iso8601")]@@ -29,7 +29,7 @@ pub struct Authorization {#[diesel(table_name = incremental_authorization)]pub struct AuthorizationNew {pub authorization_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: String,pub amount: MinorUnit,pub status: storage_enums::AuthorizationStatus,diff --git a/crates/diesel_models/src/blocklist.rs b/crates/diesel_models/src/blocklist.rsindex 14dbaf2fe4..0ef7daf009 100644--- a/crates/diesel_models/src/blocklist.rs+++ b/crates/diesel_models/src/blocklist.rs@@ -6,7 +6,7 @@ use crate::schema::blocklist;#[derive(Clone, Debug, Eq, Insertable, PartialEq, Serialize, Deserialize)]#[diesel(table_name = blocklist)]pub struct BlocklistNew {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub fingerprint_id: String,pub data_kind: common_enums::BlocklistDataKind,pub metadata: Option<serde_json::Value>,@@ -20,7 +20,7 @@ pub struct BlocklistNew {pub struct Blocklist {#[serde(skip)]pub id: i32,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub fingerprint_id: String,pub data_kind: common_enums::BlocklistDataKind,pub metadata: Option<serde_json::Value>,diff --git a/crates/diesel_models/src/blocklist_fingerprint.rs b/crates/diesel_models/src/blocklist_fingerprint.rsindex ceea5134bb..93b39e69a5 100644--- a/crates/diesel_models/src/blocklist_fingerprint.rs+++ b/crates/diesel_models/src/blocklist_fingerprint.rs@@ -6,7 +6,7 @@ use crate::schema::blocklist_fingerprint;#[derive(Clone, Debug, Eq, Insertable, PartialEq, Serialize, Deserialize)]#[diesel(table_name = blocklist_fingerprint)]pub struct BlocklistFingerprintNew {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub fingerprint_id: String,pub data_kind: common_enums::BlocklistDataKind,pub encrypted_fingerprint: String,@@ -20,7 +20,7 @@ pub struct BlocklistFingerprintNew {pub struct BlocklistFingerprint {#[serde(skip_serializing)]pub id: i32,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub fingerprint_id: String,pub data_kind: common_enums::BlocklistDataKind,pub encrypted_fingerprint: String,diff --git a/crates/diesel_models/src/blocklist_lookup.rs b/crates/diesel_models/src/blocklist_lookup.rsindex bebad02e78..dd7cd0252d 100644--- a/crates/diesel_models/src/blocklist_lookup.rs+++ b/crates/diesel_models/src/blocklist_lookup.rs@@ -6,7 +6,7 @@ use crate::schema::blocklist_lookup;#[derive(Default, Clone, Debug, Eq, Insertable, PartialEq, Serialize, Deserialize)]#[diesel(table_name = blocklist_lookup)]pub struct BlocklistLookupNew {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub fingerprint: String,}@@ -26,6 +26,6 @@ pub struct BlocklistLookupNew {pub struct BlocklistLookup {#[serde(skip)]pub id: i32,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub fingerprint: String,}diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rsindex b964b290a9..30f6780e36 100644--- a/crates/diesel_models/src/business_profile.rs+++ b/crates/diesel_models/src/business_profile.rs@@ -16,7 +16,7 @@ use crate::schema::business_profile;#[diesel(table_name = business_profile, primary_key(profile_id), check_for_backend(diesel::pg::Pg))]pub struct BusinessProfile {pub profile_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub profile_name: String,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,@@ -50,7 +50,7 @@ pub struct BusinessProfile {#[diesel(table_name = business_profile, primary_key(profile_id))]pub struct BusinessProfileNew {pub profile_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub profile_name: String,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,diff --git a/crates/diesel_models/src/capture.rs b/crates/diesel_models/src/capture.rsindex cff09638a4..714a6a3735 100644--- a/crates/diesel_models/src/capture.rs+++ b/crates/diesel_models/src/capture.rs@@ -12,7 +12,7 @@ use crate::{enums as storage_enums, schema::captures};pub struct Capture {pub capture_id: String,pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub status: storage_enums::CaptureStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,@@ -37,7 +37,7 @@ pub struct Capture {pub struct CaptureNew {pub capture_id: String,pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub status: storage_enums::CaptureStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,diff --git a/crates/diesel_models/src/customers.rs b/crates/diesel_models/src/customers.rsindex 302772b7f9..ea552e0d39 100644--- a/crates/diesel_models/src/customers.rs+++ b/crates/diesel_models/src/customers.rs@@ -1,4 +1,4 @@-use common_utils::{encryption::Encryption, id_type, pii};+use common_utils::{encryption::Encryption, pii};use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use time::PrimitiveDateTime;@@ -9,8 +9,8 @@ use crate::schema::customers;)]#[diesel(table_name = customers)]pub struct CustomerNew {- pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub customer_id: common_utils::id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,pub name: Option<Encryption>,pub email: Option<Encryption>,pub phone: Option<Encryption>,@@ -58,8 +58,8 @@ impl From<CustomerNew> for Customer {#[diesel(table_name = customers, check_for_backend(diesel::pg::Pg))]pub struct Customer {pub id: i32,- pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub customer_id: common_utils::id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,pub name: Option<Encryption>,pub email: Option<Encryption>,pub phone: Option<Encryption>,diff --git a/crates/diesel_models/src/dispute.rs b/crates/diesel_models/src/dispute.rsindex 184dce1564..c2ef94e671 100644--- a/crates/diesel_models/src/dispute.rs+++ b/crates/diesel_models/src/dispute.rs@@ -17,7 +17,7 @@ pub struct DisputeNew {pub dispute_status: storage_enums::DisputeStatus,pub payment_id: String,pub attempt_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub connector_status: String,pub connector_dispute_id: String,pub connector_reason: Option<String>,@@ -44,7 +44,7 @@ pub struct Dispute {pub dispute_status: storage_enums::DisputeStatus,pub payment_id: String,pub attempt_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub connector_status: String,pub connector_dispute_id: String,pub connector_reason: Option<String>,diff --git a/crates/diesel_models/src/ephemeral_key.rs b/crates/diesel_models/src/ephemeral_key.rsindex 1cf15e9bfd..d398ecdf78 100644--- a/crates/diesel_models/src/ephemeral_key.rs+++ b/crates/diesel_models/src/ephemeral_key.rs@@ -1,17 +1,15 @@-use common_utils::id_type;-pub struct EphemeralKeyNew {pub id: String,- pub merchant_id: String,- pub customer_id: id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,+ pub customer_id: common_utils::id_type::CustomerId,pub secret: String,}#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]pub struct EphemeralKey {pub id: String,- pub merchant_id: String,- pub customer_id: id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,+ pub customer_id: common_utils::id_type::CustomerId,pub created_at: i64,pub expires: i64,pub secret: String,diff --git a/crates/diesel_models/src/events.rs b/crates/diesel_models/src/events.rsindex 99879dafaf..20c811654a 100644--- a/crates/diesel_models/src/events.rs+++ b/crates/diesel_models/src/events.rs@@ -21,7 +21,7 @@ pub struct EventNew {pub primary_object_id: String,pub primary_object_type: storage_enums::EventObjectType,pub created_at: PrimitiveDateTime,- pub merchant_id: Option<String>,+ pub merchant_id: Option<common_utils::id_type::MerchantId>,pub business_profile_id: Option<String>,pub primary_object_created_at: Option<PrimitiveDateTime>,pub idempotent_event_id: Option<String>,@@ -50,7 +50,7 @@ pub struct Event {pub primary_object_type: storage_enums::EventObjectType,#[serde(with = "custom_serde::iso8601")]pub created_at: PrimitiveDateTime,- pub merchant_id: Option<String>,+ pub merchant_id: Option<common_utils::id_type::MerchantId>,pub business_profile_id: Option<String>,// This column can be used to partition the database table, so that all events related to a// single object would reside in the same partitiondiff --git a/crates/diesel_models/src/file.rs b/crates/diesel_models/src/file.rsindex af584323b9..e5ad3568d7 100644--- a/crates/diesel_models/src/file.rs+++ b/crates/diesel_models/src/file.rs@@ -9,7 +9,7 @@ use crate::schema::file_metadata;#[serde(deny_unknown_fields)]pub struct FileMetadataNew {pub file_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub file_name: Option<String>,pub file_size: i32,pub file_type: String,@@ -26,7 +26,7 @@ pub struct FileMetadataNew {pub struct FileMetadata {#[serde(skip_serializing)]pub file_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub file_name: Option<String>,pub file_size: i32,pub file_type: String,diff --git a/crates/diesel_models/src/fraud_check.rs b/crates/diesel_models/src/fraud_check.rsindex 2cda6bbd7f..36fe01ea71 100644--- a/crates/diesel_models/src/fraud_check.rs+++ b/crates/diesel_models/src/fraud_check.rs@@ -12,7 +12,7 @@ use crate::{pub struct FraudCheck {pub frm_id: String,pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub attempt_id: String,pub created_at: PrimitiveDateTime,pub frm_name: String,@@ -34,7 +34,7 @@ pub struct FraudCheck {pub struct FraudCheckNew {pub frm_id: String,pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub attempt_id: String,pub created_at: PrimitiveDateTime,pub frm_name: String,diff --git a/crates/diesel_models/src/generic_link.rs b/crates/diesel_models/src/generic_link.rsindex 1017d2d47d..2840269248 100644--- a/crates/diesel_models/src/generic_link.rs+++ b/crates/diesel_models/src/generic_link.rs@@ -1,5 +1,5 @@use common_utils::{- consts, id_type,+ consts,link_utils::{EnabledPaymentMethod, GenericLinkStatus, GenericLinkUiConfig, PaymentMethodCollectStatus,PayoutLinkData, PayoutLinkStatus,@@ -19,7 +19,7 @@ use crate::{enums as storage_enums, schema::generic_link};pub struct GenericLink {pub link_id: String,pub primary_reference: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,#[serde(with = "common_utils::custom_serde::iso8601")]pub created_at: PrimitiveDateTime,#[serde(with = "common_utils::custom_serde::iso8601")]@@ -37,7 +37,7 @@ pub struct GenericLink {pub struct GenericLinkState {pub link_id: String,pub primary_reference: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,#[serde(with = "common_utils::custom_serde::iso8601")]pub created_at: PrimitiveDateTime,#[serde(with = "common_utils::custom_serde::iso8601")]@@ -65,7 +65,7 @@ pub struct GenericLinkState {pub struct GenericLinkNew {pub link_id: String,pub primary_reference: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,#[serde(with = "common_utils::custom_serde::iso8601::option")]pub created_at: Option<PrimitiveDateTime>,#[serde(with = "common_utils::custom_serde::iso8601::option")]@@ -86,7 +86,7 @@ impl Default for GenericLinkNew {Self {link_id: String::default(),primary_reference: String::default(),- merchant_id: String::default(),+ merchant_id: common_utils::id_type::MerchantId::default(),created_at: Some(now),last_modified_at: Some(now),expiry: now + Duration::seconds(consts::DEFAULT_SESSION_EXPIRY),@@ -125,7 +125,7 @@ impl GenericLinkData {pub struct PaymentMethodCollectLink {pub link_id: String,pub primary_reference: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,#[serde(with = "common_utils::custom_serde::iso8601")]pub created_at: PrimitiveDateTime,#[serde(with = "common_utils::custom_serde::iso8601")]@@ -142,7 +142,7 @@ pub struct PaymentMethodCollectLink {#[derive(Debug, Clone, Serialize, Deserialize)]pub struct PaymentMethodCollectLinkData {pub pm_collect_link_id: String,- pub customer_id: id_type::CustomerId,+ pub customer_id: common_utils::id_type::CustomerId,pub link: Secret<String>,pub client_secret: Secret<String>,pub session_expiry: u32,@@ -157,7 +157,7 @@ pub struct PaymentMethodCollectLinkData {pub struct PayoutLink {pub link_id: String,pub primary_reference: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,#[serde(with = "common_utils::custom_serde::iso8601")]pub created_at: PrimitiveDateTime,#[serde(with = "common_utils::custom_serde::iso8601")]diff --git a/crates/diesel_models/src/locker_mock_up.rs b/crates/diesel_models/src/locker_mock_up.rsindex e88ad95e23..04f3607a6c 100644--- a/crates/diesel_models/src/locker_mock_up.rs+++ b/crates/diesel_models/src/locker_mock_up.rs@@ -1,4 +1,3 @@-use common_utils::id_type;use diesel::{Identifiable, Insertable, Queryable, Selectable};use crate::schema::locker_mock_up;@@ -11,13 +10,13 @@ pub struct LockerMockUp {pub external_id: String,pub card_fingerprint: String,pub card_global_fingerprint: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub card_number: String,pub card_exp_year: String,pub card_exp_month: String,pub name_on_card: Option<String>,pub nickname: Option<String>,- pub customer_id: Option<id_type::CustomerId>,+ pub customer_id: Option<common_utils::id_type::CustomerId>,pub duplicate: Option<bool>,pub card_cvc: Option<String>,pub payment_method_id: Option<String>,@@ -31,14 +30,14 @@ pub struct LockerMockUpNew {pub external_id: String,pub card_fingerprint: String,pub card_global_fingerprint: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub card_number: String,pub card_exp_year: String,pub card_exp_month: String,pub name_on_card: Option<String>,pub card_cvc: Option<String>,pub payment_method_id: Option<String>,- pub customer_id: Option<id_type::CustomerId>,+ pub customer_id: Option<common_utils::id_type::CustomerId>,pub nickname: Option<String>,pub enc_card_data: Option<String>,}diff --git a/crates/diesel_models/src/mandate.rs b/crates/diesel_models/src/mandate.rsindex 793174dea7..ec4b572e8e 100644--- a/crates/diesel_models/src/mandate.rs+++ b/crates/diesel_models/src/mandate.rs@@ -1,5 +1,5 @@use common_enums::MerchantStorageScheme;-use common_utils::{id_type, pii};+use common_utils::pii;use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use masking::Secret;use time::PrimitiveDateTime;@@ -13,8 +13,8 @@ use crate::{enums as storage_enums, schema::mandate};pub struct Mandate {pub id: i32,pub mandate_id: String,- pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub customer_id: common_utils::id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_method_id: String,pub mandate_status: storage_enums::MandateStatus,pub mandate_type: storage_enums::MandateType,@@ -51,8 +51,8 @@ pub struct Mandate {#[diesel(table_name = mandate)]pub struct MandateNew {pub mandate_id: String,- pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub customer_id: common_utils::id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_method_id: String,pub mandate_status: storage_enums::MandateStatus,pub mandate_type: storage_enums::MandateType,diff --git a/crates/diesel_models/src/merchant_account.rs b/crates/diesel_models/src/merchant_account.rsindex 800e5636a9..4e99900af2 100644--- a/crates/diesel_models/src/merchant_account.rs+++ b/crates/diesel_models/src/merchant_account.rs@@ -27,7 +27,7 @@ use crate::schema_v2::merchant_account;#[diesel(table_name = merchant_account, primary_key(merchant_id), check_for_backend(diesel::pg::Pg))]pub struct MerchantAccount {pub id: i32,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub return_url: Option<String>,pub enable_payment_response_hash: bool,pub payment_response_hash_key: Option<String>,@@ -36,7 +36,7 @@ pub struct MerchantAccount {pub merchant_details: Option<Encryption>,pub webhook_details: Option<serde_json::Value>,pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<String>,+ pub parent_merchant_id: Option<id_type::MerchantId>,pub publishable_key: Option<String>,pub storage_scheme: storage_enums::MerchantStorageScheme,pub locker_id: Option<String>,@@ -69,7 +69,7 @@ pub struct MerchantAccount {)]#[diesel(table_name = merchant_account, primary_key(merchant_id), check_for_backend(diesel::pg::Pg))]pub struct MerchantAccount {- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub return_url: Option<String>,pub enable_payment_response_hash: bool,pub payment_response_hash_key: Option<String>,@@ -78,7 +78,7 @@ pub struct MerchantAccount {pub merchant_details: Option<Encryption>,pub webhook_details: Option<serde_json::Value>,pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<String>,+ pub parent_merchant_id: Option<common_utils::id_type::MerchantId>,pub publishable_key: Option<String>,pub storage_scheme: storage_enums::MerchantStorageScheme,pub locker_id: Option<String>,@@ -98,16 +98,22 @@ pub struct MerchantAccount {pub pm_collect_link_config: Option<serde_json::Value>,}+impl MerchantAccount {+ pub fn get_id(&self) -> &id_type::MerchantId {+ &self.merchant_id+ }+}+#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]#[diesel(table_name = merchant_account)]pub struct MerchantAccountNew {- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub merchant_name: Option<Encryption>,pub merchant_details: Option<Encryption>,pub return_url: Option<String>,pub webhook_details: Option<serde_json::Value>,pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<String>,+ pub parent_merchant_id: Option<id_type::MerchantId>,pub enable_payment_response_hash: Option<bool>,pub payment_response_hash_key: Option<String>,pub redirect_to_merchant_with_http_post: Option<bool>,@@ -137,7 +143,7 @@ pub struct MerchantAccountUpdateInternal {pub return_url: Option<String>,pub webhook_details: Option<serde_json::Value>,pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<String>,+ pub parent_merchant_id: Option<id_type::MerchantId>,pub enable_payment_response_hash: Option<bool>,pub payment_response_hash_key: Option<String>,pub redirect_to_merchant_with_http_post: Option<bool>,diff --git a/crates/diesel_models/src/merchant_connector_account.rs b/crates/diesel_models/src/merchant_connector_account.rsindex 5a549892dc..4b6ab77d8a 100644--- a/crates/diesel_models/src/merchant_connector_account.rs+++ b/crates/diesel_models/src/merchant_connector_account.rs@@ -1,6 +1,6 @@use std::fmt::Debug;-use common_utils::{encryption::Encryption, pii};+use common_utils::{encryption::Encryption, id_type, pii};use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use masking::Secret;@@ -19,7 +19,7 @@ use crate::{enums as storage_enums, schema::merchant_connector_account};#[diesel(table_name = merchant_connector_account, check_for_backend(diesel::pg::Pg))]pub struct MerchantConnectorAccount {pub id: i32,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub connector_name: String,pub connector_account_details: Encryption,pub test_mode: Option<bool>,@@ -51,7 +51,7 @@ pub struct MerchantConnectorAccount {#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]#[diesel(table_name = merchant_connector_account)]pub struct MerchantConnectorAccountNew {- pub merchant_id: Option<String>,+ pub merchant_id: Option<id_type::MerchantId>,pub connector_type: Option<storage_enums::ConnectorType>,pub connector_name: Option<String>,pub connector_account_details: Option<Encryption>,@@ -82,7 +82,6 @@ pub struct MerchantConnectorAccountNew {#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]#[diesel(table_name = merchant_connector_account)]pub struct MerchantConnectorAccountUpdateInternal {- pub merchant_id: Option<String>,pub connector_type: Option<storage_enums::ConnectorType>,pub connector_name: Option<String>,pub connector_account_details: Option<Encryption>,@@ -110,7 +109,7 @@ impl MerchantConnectorAccountUpdateInternal {source: MerchantConnectorAccount,) -> MerchantConnectorAccount {MerchantConnectorAccount {- merchant_id: self.merchant_id.unwrap_or(source.merchant_id),+ merchant_id: source.merchant_id,connector_type: self.connector_type.unwrap_or(source.connector_type),connector_account_details: self.connector_account_detailsdiff --git a/crates/diesel_models/src/merchant_key_store.rs b/crates/diesel_models/src/merchant_key_store.rsindex b11d997053..5b80067034 100644--- a/crates/diesel_models/src/merchant_key_store.rs+++ b/crates/diesel_models/src/merchant_key_store.rs@@ -16,7 +16,7 @@ use crate::schema::merchant_key_store;)]#[diesel(table_name = merchant_key_store, primary_key(merchant_id), check_for_backend(diesel::pg::Pg))]pub struct MerchantKeyStore {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub key: Encryption,#[serde(with = "custom_serde::iso8601")]pub created_at: PrimitiveDateTime,@@ -27,7 +27,7 @@ pub struct MerchantKeyStore {)]#[diesel(table_name = merchant_key_store)]pub struct MerchantKeyStoreNew {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub key: Encryption,pub created_at: PrimitiveDateTime,}@@ -37,6 +37,6 @@ pub struct MerchantKeyStoreNew {)]#[diesel(table_name = merchant_key_store)]pub struct MerchantKeyStoreUpdateInternal {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub key: Encryption,}diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rsindex 880bf99b3c..791d4fb26e 100644--- a/crates/diesel_models/src/payment_attempt.rs+++ b/crates/diesel_models/src/payment_attempt.rs@@ -16,7 +16,7 @@ use crate::schema_v2::payment_attempt;#[diesel(table_name = payment_attempt, primary_key(attempt_id, merchant_id), check_for_backend(diesel::pg::Pg))]pub struct PaymentAttempt {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub attempt_id: String,pub status: storage_enums::AttemptStatus,pub amount: i64,@@ -88,7 +88,7 @@ pub struct PaymentAttempt {pub struct PaymentAttempt {pub id: Option<i32>,pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub attempt_id: String,pub status: storage_enums::AttemptStatus,pub amount: i64,@@ -172,7 +172,7 @@ pub struct PaymentListFilters {#[diesel(table_name = payment_attempt)]pub struct PaymentAttemptNew {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub attempt_id: String,pub status: storage_enums::AttemptStatus,pub amount: i64,diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rsindex f7ec26e120..012376ae3d 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -1,5 +1,5 @@use common_enums::RequestIncrementalAuthorization;-use common_utils::{encryption::Encryption, id_type, pii, types::MinorUnit};+use common_utils::{encryption::Encryption, pii, types::MinorUnit};use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;@@ -15,12 +15,12 @@ use crate::schema_v2::payment_intent;#[diesel(table_name = payment_intent, primary_key(payment_id, merchant_id), check_for_backend(diesel::pg::Pg))]pub struct PaymentIntent {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub status: storage_enums::IntentStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,pub amount_captured: Option<MinorUnit>,- pub customer_id: Option<id_type::CustomerId>,+ pub customer_id: Option<common_utils::id_type::CustomerId>,pub description: Option<String>,pub return_url: Option<String>,pub metadata: Option<serde_json::Value>,@@ -76,12 +76,12 @@ pub struct PaymentIntent {pub struct PaymentIntent {pub id: Option<i32>,pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub status: storage_enums::IntentStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,pub amount_captured: Option<MinorUnit>,- pub customer_id: Option<id_type::CustomerId>,+ pub customer_id: Option<common_utils::id_type::CustomerId>,pub description: Option<String>,pub return_url: Option<String>,pub metadata: Option<serde_json::Value>,@@ -137,12 +137,12 @@ pub struct PaymentIntent {#[diesel(table_name = payment_intent)]pub struct PaymentIntentNew {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub status: storage_enums::IntentStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,pub amount_captured: Option<MinorUnit>,- pub customer_id: Option<id_type::CustomerId>,+ pub customer_id: Option<common_utils::id_type::CustomerId>,pub description: Option<String>,pub return_url: Option<String>,pub metadata: Option<serde_json::Value>,@@ -208,7 +208,7 @@ pub enum PaymentIntentUpdate {PaymentCreateUpdate {return_url: Option<String>,status: Option<storage_enums::IntentStatus>,- customer_id: Option<id_type::CustomerId>,+ customer_id: Option<common_utils::id_type::CustomerId>,shipping_address_id: Option<String>,billing_address_id: Option<String>,customer_details: Option<Encryption>,@@ -271,7 +271,7 @@ pub struct PaymentIntentUpdateFields {pub currency: storage_enums::Currency,pub setup_future_usage: Option<storage_enums::FutureUsage>,pub status: storage_enums::IntentStatus,- pub customer_id: Option<id_type::CustomerId>,+ pub customer_id: Option<common_utils::id_type::CustomerId>,pub shipping_address_id: Option<String>,pub billing_address_id: Option<String>,pub return_url: Option<String>,@@ -301,7 +301,7 @@ pub struct PaymentIntentUpdateInternal {pub currency: Option<storage_enums::Currency>,pub status: Option<storage_enums::IntentStatus>,pub amount_captured: Option<MinorUnit>,- pub customer_id: Option<id_type::CustomerId>,+ pub customer_id: Option<common_utils::id_type::CustomerId>,pub return_url: Option<String>,pub setup_future_usage: Option<storage_enums::FutureUsage>,pub off_session: Option<bool>,diff --git a/crates/diesel_models/src/payment_link.rs b/crates/diesel_models/src/payment_link.rsindex 7937d2fbe3..d588714301 100644--- a/crates/diesel_models/src/payment_link.rs+++ b/crates/diesel_models/src/payment_link.rs@@ -11,7 +11,7 @@ pub struct PaymentLink {pub payment_link_id: String,pub payment_id: String,pub link_to_pay: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,#[serde(with = "common_utils::custom_serde::iso8601")]@@ -41,7 +41,7 @@ pub struct PaymentLinkNew {pub payment_link_id: String,pub payment_id: String,pub link_to_pay: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,#[serde(with = "common_utils::custom_serde::iso8601::option")]diff --git a/crates/diesel_models/src/payment_method.rs b/crates/diesel_models/src/payment_method.rsindex 6bb40e4b16..0121ec5112 100644--- a/crates/diesel_models/src/payment_method.rs+++ b/crates/diesel_models/src/payment_method.rs@@ -1,5 +1,5 @@use common_enums::MerchantStorageScheme;-use common_utils::{encryption::Encryption, id_type, pii};+use common_utils::{encryption::Encryption, pii};use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use masking::Secret;use serde::{Deserialize, Serialize};@@ -13,8 +13,8 @@ use crate::{enums as storage_enums, schema::payment_methods};#[diesel(table_name = payment_methods, check_for_backend(diesel::pg::Pg))]pub struct PaymentMethod {pub id: i32,- pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub customer_id: common_utils::id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_method_id: String,#[diesel(deserialize_as = super::OptionalDieselArray<storage_enums::Currency>)]pub accepted_currency: Option<Vec<storage_enums::Currency>>,@@ -52,8 +52,8 @@ pub struct PaymentMethod {)]#[diesel(table_name = payment_methods)]pub struct PaymentMethodNew {- pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub customer_id: common_utils::id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_method_id: String,pub payment_method: Option<storage_enums::PaymentMethod>,pub payment_method_type: Option<storage_enums::PaymentMethodType>,diff --git a/crates/diesel_models/src/payout_attempt.rs b/crates/diesel_models/src/payout_attempt.rsindex 9eb2a5a59d..d8e5af55cc 100644--- a/crates/diesel_models/src/payout_attempt.rs+++ b/crates/diesel_models/src/payout_attempt.rs@@ -1,4 +1,3 @@-use common_utils::id_type;use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use serde::{self, Deserialize, Serialize};use time::PrimitiveDateTime;@@ -12,8 +11,8 @@ use crate::{enums as storage_enums, schema::payout_attempt};pub struct PayoutAttempt {pub payout_attempt_id: String,pub payout_id: String,- pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub customer_id: common_utils::id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,pub address_id: String,pub connector: Option<String>,pub connector_payout_id: Option<String>,@@ -48,8 +47,8 @@ pub struct PayoutAttempt {pub struct PayoutAttemptNew {pub payout_attempt_id: String,pub payout_id: String,- pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub customer_id: common_utils::id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,pub address_id: String,pub connector: Option<String>,pub connector_payout_id: Option<String>,diff --git a/crates/diesel_models/src/payouts.rs b/crates/diesel_models/src/payouts.rsindex acef00b15d..9573d05664 100644--- a/crates/diesel_models/src/payouts.rs+++ b/crates/diesel_models/src/payouts.rs@@ -1,4 +1,4 @@-use common_utils::{id_type, pii, types::MinorUnit};+use common_utils::{pii, types::MinorUnit};use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use serde::{self, Deserialize, Serialize};use time::PrimitiveDateTime;@@ -12,8 +12,8 @@ use crate::{enums as storage_enums, schema::payouts};#[diesel(table_name = payouts, primary_key(payout_id), check_for_backend(diesel::pg::Pg))]pub struct Payouts {pub payout_id: String,- pub merchant_id: String,- pub customer_id: id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,+ pub customer_id: common_utils::id_type::CustomerId,pub address_id: String,pub payout_type: Option<storage_enums::PayoutType>,pub payout_method_id: Option<String>,@@ -53,8 +53,8 @@ pub struct Payouts {#[diesel(table_name = payouts)]pub struct PayoutsNew {pub payout_id: String,- pub merchant_id: String,- pub customer_id: id_type::CustomerId,+ pub merchant_id: common_utils::id_type::MerchantId,+ pub customer_id: common_utils::id_type::CustomerId,pub address_id: String,pub payout_type: Option<storage_enums::PayoutType>,pub payout_method_id: Option<String>,diff --git a/crates/diesel_models/src/query/address.rs b/crates/diesel_models/src/query/address.rsindex cf3cd41c40..572a5c7fe0 100644--- a/crates/diesel_models/src/query/address.rs+++ b/crates/diesel_models/src/query/address.rs@@ -1,4 +1,3 @@-use common_utils::id_type;use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};use super::generics;@@ -91,8 +90,8 @@ impl Address {pub async fn update_by_merchant_id_customer_id(conn: &PgPooledConn,- customer_id: &id_type::CustomerId,- merchant_id: &str,+ customer_id: &common_utils::id_type::CustomerId,+ merchant_id: &common_utils::id_type::MerchantId,address: AddressUpdateInternal,) -> StorageResult<Vec<Self>> {generics::generic_update_with_results::<<Self as HasTable>::Table, _, _, _>(@@ -107,7 +106,7 @@ impl Address {pub async fn find_by_merchant_id_payment_id_address_id<'a>(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,address_id: &str,) -> StorageResult<Self> {diff --git a/crates/diesel_models/src/query/api_keys.rs b/crates/diesel_models/src/query/api_keys.rsindex ad7ec7c068..5dd1450102 100644--- a/crates/diesel_models/src/query/api_keys.rs+++ b/crates/diesel_models/src/query/api_keys.rs@@ -17,7 +17,7 @@ impl ApiKeyNew {impl ApiKey {pub async fn update_by_merchant_id_key_id(conn: &PgPooledConn,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,key_id: String,api_key_update: ApiKeyUpdate,) -> StorageResult<Self> {@@ -56,7 +56,7 @@ impl ApiKey {pub async fn revoke_by_merchant_id_key_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(@@ -70,7 +70,7 @@ impl ApiKey {pub async fn find_optional_by_merchant_id_key_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> StorageResult<Option<Self>> {generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(@@ -95,7 +95,7 @@ impl ApiKey {pub async fn find_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,limit: Option<i64>,offset: Option<i64>,) -> StorageResult<Vec<Self>> {diff --git a/crates/diesel_models/src/query/authentication.rs b/crates/diesel_models/src/query/authentication.rsindex 86ee4a35c1..41339fc1aa 100644--- a/crates/diesel_models/src/query/authentication.rs+++ b/crates/diesel_models/src/query/authentication.rs@@ -19,7 +19,7 @@ impl AuthenticationNew {impl Authentication {pub async fn update_by_merchant_id_authentication_id(conn: &PgPooledConn,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,authentication_id: String,authorization_update: AuthenticationUpdate,) -> StorageResult<Self> {@@ -58,7 +58,7 @@ impl Authentication {pub async fn find_by_merchant_id_authentication_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,authentication_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -72,7 +72,7 @@ impl Authentication {pub async fn find_authentication_by_merchant_id_connector_authentication_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_authentication_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(diff --git a/crates/diesel_models/src/query/authorization.rs b/crates/diesel_models/src/query/authorization.rsindex 59282c78f8..61b0fb06a0 100644--- a/crates/diesel_models/src/query/authorization.rs+++ b/crates/diesel_models/src/query/authorization.rs@@ -19,7 +19,7 @@ impl AuthorizationNew {impl Authorization {pub async fn update_by_merchant_id_authorization_id(conn: &PgPooledConn,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,authorization_id: String,authorization_update: AuthorizationUpdate,) -> StorageResult<Self> {@@ -58,7 +58,7 @@ impl Authorization {pub async fn find_by_merchant_id_payment_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(diff --git a/crates/diesel_models/src/query/blocklist.rs b/crates/diesel_models/src/query/blocklist.rsindex 2003a99700..b295765981 100644--- a/crates/diesel_models/src/query/blocklist.rs+++ b/crates/diesel_models/src/query/blocklist.rs@@ -16,7 +16,7 @@ impl BlocklistNew {impl Blocklist {pub async fn find_by_merchant_id_fingerprint_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -30,7 +30,7 @@ impl Blocklist {pub async fn list_by_merchant_id_data_kind(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,data_kind: common_enums::BlocklistDataKind,limit: i64,offset: i64,@@ -49,7 +49,7 @@ impl Blocklist {pub async fn list_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(conn,@@ -63,7 +63,7 @@ impl Blocklist {pub async fn delete_by_merchant_id_fingerprint_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> StorageResult<Self> {generics::generic_delete_one_with_result::<<Self as HasTable>::Table, _, _>(diff --git a/crates/diesel_models/src/query/blocklist_fingerprint.rs b/crates/diesel_models/src/query/blocklist_fingerprint.rsindex 370a06801c..ce9bba3c60 100644--- a/crates/diesel_models/src/query/blocklist_fingerprint.rs+++ b/crates/diesel_models/src/query/blocklist_fingerprint.rs@@ -16,7 +16,7 @@ impl BlocklistFingerprintNew {impl BlocklistFingerprint {pub async fn find_by_merchant_id_fingerprint_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(diff --git a/crates/diesel_models/src/query/blocklist_lookup.rs b/crates/diesel_models/src/query/blocklist_lookup.rsindex f5bc6eda5d..0cd2b5a2c4 100644--- a/crates/diesel_models/src/query/blocklist_lookup.rs+++ b/crates/diesel_models/src/query/blocklist_lookup.rs@@ -16,7 +16,7 @@ impl BlocklistLookupNew {impl BlocklistLookup {pub async fn find_by_merchant_id_fingerprint(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -30,7 +30,7 @@ impl BlocklistLookup {pub async fn delete_by_merchant_id_fingerprint(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> StorageResult<Self> {generics::generic_delete_one_with_result::<<Self as HasTable>::Table, _, _>(diff --git a/crates/diesel_models/src/query/business_profile.rs b/crates/diesel_models/src/query/business_profile.rsindex 609a5c55f2..e716e45c65 100644--- a/crates/diesel_models/src/query/business_profile.rs+++ b/crates/diesel_models/src/query/business_profile.rs@@ -48,7 +48,7 @@ impl BusinessProfile {pub async fn find_by_profile_name_merchant_id(conn: &PgPooledConn,profile_name: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -61,7 +61,7 @@ impl BusinessProfile {pub async fn list_business_profile_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table,@@ -70,7 +70,7 @@ impl BusinessProfile {_,>(conn,- dsl::merchant_id.eq(merchant_id.to_string()),+ dsl::merchant_id.eq(merchant_id.to_owned()),None,None,None,@@ -81,13 +81,13 @@ impl BusinessProfile {pub async fn delete_by_profile_id_merchant_id(conn: &PgPooledConn,profile_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(conn,dsl::profile_id.eq(profile_id.to_owned())- .and(dsl::merchant_id.eq(merchant_id.to_string())),+ .and(dsl::merchant_id.eq(merchant_id.to_owned())),).await}diff --git a/crates/diesel_models/src/query/capture.rs b/crates/diesel_models/src/query/capture.rsindex c39c4ec7f5..fb2859be7a 100644--- a/crates/diesel_models/src/query/capture.rs+++ b/crates/diesel_models/src/query/capture.rs@@ -49,7 +49,7 @@ impl Capture {}pub async fn find_all_by_merchant_id_payment_id_authorized_attempt_id(- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,authorized_attempt_id: &str,conn: &PgPooledConn,diff --git a/crates/diesel_models/src/query/connector_response.rs b/crates/diesel_models/src/query/connector_response.rsindex bdc24139ab..db3ccd68cb 100644--- a/crates/diesel_models/src/query/connector_response.rs+++ b/crates/diesel_models/src/query/connector_response.rs@@ -139,7 +139,7 @@ impl ConnectorResponse {pub async fn find_by_payment_id_merchant_id_attempt_id(conn: &PgPooledConn,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,attempt_id: &str,) -> StorageResult<Self> {let connector_response: Self =diff --git a/crates/diesel_models/src/query/customers.rs b/crates/diesel_models/src/query/customers.rsindex f1cc7a7348..dd9353e72d 100644--- a/crates/diesel_models/src/query/customers.rs+++ b/crates/diesel_models/src/query/customers.rs@@ -1,4 +1,3 @@-use common_utils::id_type;use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};use super::generics;@@ -18,8 +17,8 @@ impl CustomerNew {impl Customer {pub async fn update_by_customer_id_merchant_id(conn: &PgPooledConn,- customer_id: id_type::CustomerId,- merchant_id: String,+ customer_id: common_utils::id_type::CustomerId,+ merchant_id: common_utils::id_type::MerchantId,customer: CustomerUpdateInternal,) -> StorageResult<Self> {match generics::generic_update_by_id::<<Self as HasTable>::Table, _, _, _>(@@ -45,8 +44,8 @@ impl Customer {pub async fn delete_by_customer_id_merchant_id(conn: &PgPooledConn,- customer_id: &id_type::CustomerId,- merchant_id: &str,+ customer_id: &common_utils::id_type::CustomerId,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(conn,@@ -59,8 +58,8 @@ impl Customer {pub async fn find_by_customer_id_merchant_id(conn: &PgPooledConn,- customer_id: &id_type::CustomerId,- merchant_id: &str,+ customer_id: &common_utils::id_type::CustomerId,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_by_id::<<Self as HasTable>::Table, _, _>(conn,@@ -71,7 +70,7 @@ impl Customer {pub async fn list_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(conn,@@ -85,8 +84,8 @@ impl Customer {pub async fn find_optional_by_customer_id_merchant_id(conn: &PgPooledConn,- customer_id: &id_type::CustomerId,- merchant_id: &str,+ customer_id: &common_utils::id_type::CustomerId,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Option<Self>> {generics::generic_find_by_id_optional::<<Self as HasTable>::Table, _, _>(conn,diff --git a/crates/diesel_models/src/query/dashboard_metadata.rs b/crates/diesel_models/src/query/dashboard_metadata.rsindex e180def2c0..15b74a940a 100644--- a/crates/diesel_models/src/query/dashboard_metadata.rs+++ b/crates/diesel_models/src/query/dashboard_metadata.rs@@ -22,7 +22,7 @@ impl DashboardMetadata {pub async fn update(conn: &PgPooledConn,user_id: Option<String>,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,data_key: enums::DashboardMetadata,dashboard_metadata_update: DashboardMetadataUpdate,@@ -62,7 +62,7 @@ impl DashboardMetadata {pub async fn find_user_scoped_dashboard_metadata(conn: &PgPooledConn,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,data_types: Vec<enums::DashboardMetadata>,) -> StorageResult<Vec<Self>> {@@ -84,7 +84,7 @@ impl DashboardMetadata {pub async fn find_merchant_scoped_dashboard_metadata(conn: &PgPooledConn,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,data_types: Vec<enums::DashboardMetadata>,) -> StorageResult<Vec<Self>> {@@ -106,7 +106,7 @@ impl DashboardMetadata {pub async fn delete_all_user_scoped_dashboard_metadata_by_merchant_id(conn: &PgPooledConn,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(conn,@@ -120,7 +120,7 @@ impl DashboardMetadata {pub async fn delete_user_scoped_dashboard_metadata_by_merchant_id_data_key(conn: &PgPooledConn,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,data_key: enums::DashboardMetadata,) -> StorageResult<Self> {generics::generic_delete_one_with_result::<<Self as HasTable>::Table, _, _>(diff --git a/crates/diesel_models/src/query/dispute.rs b/crates/diesel_models/src/query/dispute.rsindex 974ed84e23..585bdc8257 100644--- a/crates/diesel_models/src/query/dispute.rs+++ b/crates/diesel_models/src/query/dispute.rs@@ -17,7 +17,7 @@ impl DisputeNew {impl Dispute {pub async fn find_by_merchant_id_payment_id_connector_dispute_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,connector_dispute_id: &str,) -> StorageResult<Option<Self>> {@@ -33,7 +33,7 @@ impl Dispute {pub async fn find_by_merchant_id_dispute_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -47,7 +47,7 @@ impl Dispute {pub async fn find_by_merchant_id_payment_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> StorageResult<Vec<Self>> {generics::generic_filter::<diff --git a/crates/diesel_models/src/query/events.rs b/crates/diesel_models/src/query/events.rsindex 1d92baaac4..8b2a1a001f 100644--- a/crates/diesel_models/src/query/events.rs+++ b/crates/diesel_models/src/query/events.rs@@ -18,7 +18,7 @@ impl EventNew {impl Event {pub async fn find_by_merchant_id_event_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -32,7 +32,7 @@ impl Event {pub async fn list_initial_attempts_by_merchant_id_primary_object_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,primary_object_id: &str,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(@@ -51,7 +51,7 @@ impl Event {pub async fn list_initial_attempts_by_merchant_id_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,created_after: Option<time::PrimitiveDateTime>,created_before: Option<time::PrimitiveDateTime>,limit: Option<i64>,@@ -101,7 +101,7 @@ impl Event {pub async fn list_by_merchant_id_initial_attempt_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,initial_attempt_id: &str,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(@@ -204,7 +204,7 @@ impl Event {pub async fn update_by_merchant_id_event_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,event: EventUpdateInternal,) -> StorageResult<Self> {diff --git a/crates/diesel_models/src/query/file.rs b/crates/diesel_models/src/query/file.rsindex be81d1bf26..5c12ed231f 100644--- a/crates/diesel_models/src/query/file.rs+++ b/crates/diesel_models/src/query/file.rs@@ -17,7 +17,7 @@ impl FileMetadataNew {impl FileMetadata {pub async fn find_by_merchant_id_file_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,file_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -31,7 +31,7 @@ impl FileMetadata {pub async fn delete_by_merchant_id_file_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,file_id: &str,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(diff --git a/crates/diesel_models/src/query/fraud_check.rs b/crates/diesel_models/src/query/fraud_check.rsindex 18eee0c728..223c2802f5 100644--- a/crates/diesel_models/src/query/fraud_check.rs+++ b/crates/diesel_models/src/query/fraud_check.rs@@ -41,7 +41,7 @@ impl FraudCheck {pub async fn get_with_payment_id(conn: &PgPooledConn,payment_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -55,7 +55,7 @@ impl FraudCheck {pub async fn get_with_payment_id_if_present(conn: &PgPooledConn,payment_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> StorageResult<Option<Self>> {generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(conn,diff --git a/crates/diesel_models/src/query/mandate.rs b/crates/diesel_models/src/query/mandate.rsindex 584721ed8f..26ba676501 100644--- a/crates/diesel_models/src/query/mandate.rs+++ b/crates/diesel_models/src/query/mandate.rs@@ -1,4 +1,3 @@-use common_utils::id_type;use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, Table};use error_stack::report;@@ -14,7 +13,7 @@ impl MandateNew {impl Mandate {pub async fn find_by_merchant_id_mandate_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,mandate_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -28,7 +27,7 @@ impl Mandate {pub async fn find_by_merchant_id_connector_mandate_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_mandate_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -42,8 +41,8 @@ impl Mandate {pub async fn find_by_merchant_id_customer_id(conn: &PgPooledConn,- merchant_id: &str,- customer_id: &id_type::CustomerId,+ merchant_id: &common_utils::id_type::MerchantId,+ customer_id: &common_utils::id_type::CustomerId,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table,@@ -64,7 +63,7 @@ impl Mandate {pub async fn update_by_merchant_id_mandate_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,mandate_id: &str,mandate: MandateUpdateInternal,) -> StorageResult<Self> {diff --git a/crates/diesel_models/src/query/merchant_account.rs b/crates/diesel_models/src/query/merchant_account.rsindex 5c0857fc07..578a100219 100644--- a/crates/diesel_models/src/query/merchant_account.rs+++ b/crates/diesel_models/src/query/merchant_account.rs@@ -43,7 +43,7 @@ impl MerchantAccount {pub async fn update_with_specific_fields(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_account: MerchantAccountUpdateInternal,) -> StorageResult<Self> {generics::generic_update_with_unique_predicate_get_result::<@@ -61,7 +61,7 @@ impl MerchantAccount {pub async fn delete_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(conn,@@ -72,7 +72,7 @@ impl MerchantAccount {pub async fn find_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -113,7 +113,7 @@ impl MerchantAccount {pub async fn list_multiple_merchant_accounts(conn: &PgPooledConn,- merchant_ids: Vec<String>,+ merchant_ids: Vec<common_utils::id_type::MerchantId>,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table,diff --git a/crates/diesel_models/src/query/merchant_connector_account.rs b/crates/diesel_models/src/query/merchant_connector_account.rsindex d275211ebd..ee4cc84346 100644--- a/crates/diesel_models/src/query/merchant_connector_account.rs+++ b/crates/diesel_models/src/query/merchant_connector_account.rs@@ -40,7 +40,7 @@ impl MerchantConnectorAccount {pub async fn delete_by_merchant_id_merchant_connector_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id: &str,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(@@ -54,7 +54,7 @@ impl MerchantConnectorAccount {pub async fn find_by_merchant_id_connector(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_label: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -82,7 +82,7 @@ impl MerchantConnectorAccount {pub async fn find_by_merchant_id_connector_name(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: &str,) -> StorageResult<Vec<Self>> {generics::generic_filter::<@@ -104,7 +104,7 @@ impl MerchantConnectorAccount {pub async fn find_by_merchant_id_merchant_connector_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -118,7 +118,7 @@ impl MerchantConnectorAccount {pub async fn find_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,get_disabled: bool,) -> StorageResult<Vec<Self>> {if get_disabled {diff --git a/crates/diesel_models/src/query/merchant_key_store.rs b/crates/diesel_models/src/query/merchant_key_store.rsindex 4e8e463767..4b35a43efd 100644--- a/crates/diesel_models/src/query/merchant_key_store.rs+++ b/crates/diesel_models/src/query/merchant_key_store.rs@@ -16,7 +16,7 @@ impl MerchantKeyStoreNew {impl MerchantKeyStore {pub async fn find_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -27,7 +27,7 @@ impl MerchantKeyStore {pub async fn delete_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(conn,@@ -38,7 +38,7 @@ impl MerchantKeyStore {pub async fn list_multiple_key_stores(conn: &PgPooledConn,- merchant_ids: Vec<String>,+ merchant_ids: Vec<common_utils::id_type::MerchantId>,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table,diff --git a/crates/diesel_models/src/query/payment_attempt.rs b/crates/diesel_models/src/query/payment_attempt.rsindex 8145b5b11f..68f16b3445 100644--- a/crates/diesel_models/src/query/payment_attempt.rs+++ b/crates/diesel_models/src/query/payment_attempt.rs@@ -59,7 +59,7 @@ impl PaymentAttempt {pub async fn find_optional_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Option<Self>> {generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(conn,@@ -74,7 +74,7 @@ impl PaymentAttempt {conn: &PgPooledConn,connector_transaction_id: &str,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -89,7 +89,7 @@ impl PaymentAttempt {pub async fn find_last_successful_attempt_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {// perform ordering on the application level instead of database levelgenerics::generic_filter::<<Self as HasTable>::Table, _, _, Self>(@@ -111,7 +111,7 @@ impl PaymentAttempt {pub async fn find_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {// perform ordering on the application level instead of database levelgenerics::generic_filter::<<Self as HasTable>::Table, _, _, Self>(@@ -136,7 +136,7 @@ impl PaymentAttempt {pub async fn find_by_merchant_id_connector_txn_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_txn_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -150,7 +150,7 @@ impl PaymentAttempt {pub async fn find_by_merchant_id_attempt_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,attempt_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -164,7 +164,7 @@ impl PaymentAttempt {pub async fn find_by_merchant_id_preprocessing_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,preprocessing_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -179,7 +179,7 @@ impl PaymentAttempt {pub async fn find_by_payment_id_merchant_id_attempt_id(conn: &PgPooledConn,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,attempt_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -195,7 +195,7 @@ impl PaymentAttempt {pub async fn find_by_merchant_id_payment_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> StorageResult<Vec<Self>> {generics::generic_filter::<@@ -218,7 +218,7 @@ impl PaymentAttempt {pub async fn get_filters_for_payments(conn: &PgPooledConn,pi: &[PaymentIntent],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<(Vec<String>,Vec<enums::Currency>,@@ -316,7 +316,7 @@ impl PaymentAttempt {#[allow(clippy::too_many_arguments)]pub async fn get_total_count_of_attempts(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,active_attempt_ids: &[String],connector: Option<Vec<String>>,payment_method: Option<Vec<enums::PaymentMethod>>,diff --git a/crates/diesel_models/src/query/payment_intent.rs b/crates/diesel_models/src/query/payment_intent.rsindex b658f8d9c9..452e5cbc3f 100644--- a/crates/diesel_models/src/query/payment_intent.rs+++ b/crates/diesel_models/src/query/payment_intent.rs@@ -47,7 +47,7 @@ impl PaymentIntent {pub async fn find_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -61,7 +61,7 @@ impl PaymentIntent {pub async fn find_optional_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Option<Self>> {generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(conn,diff --git a/crates/diesel_models/src/query/payment_method.rs b/crates/diesel_models/src/query/payment_method.rsindex 8008fec020..90bf455294 100644--- a/crates/diesel_models/src/query/payment_method.rs+++ b/crates/diesel_models/src/query/payment_method.rs@@ -1,5 +1,4 @@use async_bb8_diesel::AsyncRunQueryDsl;-use common_utils::id_type;use diesel::{associations::HasTable, debug_query, pg::Pg, BoolExpressionMethods, ExpressionMethods,QueryDsl, Table,@@ -34,7 +33,7 @@ impl PaymentMethod {pub async fn delete_by_merchant_id_payment_method_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_method_id: &str,) -> StorageResult<Self> {generics::generic_delete_one_with_result::<<Self as HasTable>::Table, _, Self>(@@ -67,7 +66,7 @@ impl PaymentMethod {pub async fn find_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table,@@ -86,8 +85,8 @@ impl PaymentMethod {pub async fn find_by_customer_id_merchant_id(conn: &PgPooledConn,- customer_id: &id_type::CustomerId,- merchant_id: &str,+ customer_id: &common_utils::id_type::CustomerId,+ merchant_id: &common_utils::id_type::MerchantId,limit: Option<i64>,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(@@ -104,8 +103,8 @@ impl PaymentMethod {pub async fn get_count_by_customer_id_merchant_id_status(conn: &PgPooledConn,- customer_id: &id_type::CustomerId,- merchant_id: &str,+ customer_id: &common_utils::id_type::CustomerId,+ merchant_id: &common_utils::id_type::MerchantId,status: common_enums::PaymentMethodStatus,) -> StorageResult<i64> {let filter = <Self as HasTable>::table()@@ -131,8 +130,8 @@ impl PaymentMethod {pub async fn find_by_customer_id_merchant_id_status(conn: &PgPooledConn,- customer_id: &id_type::CustomerId,- merchant_id: &str,+ customer_id: &common_utils::id_type::CustomerId,+ merchant_id: &common_utils::id_type::MerchantId,status: storage_enums::PaymentMethodStatus,limit: Option<i64>,) -> StorageResult<Vec<Self>> {diff --git a/crates/diesel_models/src/query/payout_attempt.rs b/crates/diesel_models/src/query/payout_attempt.rsindex 0f1785bed5..e415dc6735 100644--- a/crates/diesel_models/src/query/payout_attempt.rs+++ b/crates/diesel_models/src/query/payout_attempt.rs@@ -55,7 +55,7 @@ impl PayoutAttempt {pub async fn find_by_merchant_id_payout_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -69,7 +69,7 @@ impl PayoutAttempt {pub async fn find_by_merchant_id_payout_attempt_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_attempt_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -83,7 +83,7 @@ impl PayoutAttempt {pub async fn find_by_merchant_id_connector_payout_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_payout_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -97,7 +97,7 @@ impl PayoutAttempt {pub async fn update_by_merchant_id_payout_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,payout: PayoutAttemptUpdate,) -> StorageResult<Self> {@@ -118,7 +118,7 @@ impl PayoutAttempt {pub async fn update_by_merchant_id_payout_attempt_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_attempt_id: &str,payout: PayoutAttemptUpdate,) -> StorageResult<Self> {@@ -140,7 +140,7 @@ impl PayoutAttempt {pub async fn get_filters_for_payouts(conn: &PgPooledConn,payouts: &[Payouts],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<(Vec<String>,Vec<enums::Currency>,diff --git a/crates/diesel_models/src/query/payouts.rs b/crates/diesel_models/src/query/payouts.rsindex 13756d19e8..e65062b392 100644--- a/crates/diesel_models/src/query/payouts.rs+++ b/crates/diesel_models/src/query/payouts.rs@@ -41,7 +41,7 @@ impl Payouts {pub async fn find_by_merchant_id_payout_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -55,7 +55,7 @@ impl Payouts {pub async fn update_by_merchant_id_payout_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,payout: PayoutsUpdate,) -> StorageResult<Self> {@@ -76,7 +76,7 @@ impl Payouts {pub async fn find_optional_by_merchant_id_payout_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,) -> StorageResult<Option<Self>> {generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(diff --git a/crates/diesel_models/src/query/refund.rs b/crates/diesel_models/src/query/refund.rsindex 0d5d1baf93..53d57356d4 100644--- a/crates/diesel_models/src/query/refund.rs+++ b/crates/diesel_models/src/query/refund.rs@@ -41,7 +41,7 @@ impl Refund {// This is required to be changed for KV.pub async fn find_by_merchant_id_refund_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_id: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -55,7 +55,7 @@ impl Refund {pub async fn find_by_merchant_id_connector_refund_id_connector(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_refund_id: &str,connector: &str,) -> StorageResult<Self> {@@ -72,7 +72,7 @@ impl Refund {pub async fn find_by_internal_reference_id_merchant_id(conn: &PgPooledConn,internal_reference_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -85,7 +85,7 @@ impl Refund {pub async fn find_by_merchant_id_connector_transaction_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_transaction_id: &str,) -> StorageResult<Vec<Self>> {generics::generic_filter::<@@ -108,7 +108,7 @@ impl Refund {pub async fn find_by_payment_id_merchant_id(conn: &PgPooledConn,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table,diff --git a/crates/diesel_models/src/query/role.rs b/crates/diesel_models/src/query/role.rsindex 3b07afb7b8..7a0b1f8eb6 100644--- a/crates/diesel_models/src/query/role.rs+++ b/crates/diesel_models/src/query/role.rs@@ -23,7 +23,7 @@ impl Role {pub async fn find_by_role_id_in_merchant_scope(conn: &PgPooledConn,role_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(@@ -65,7 +65,7 @@ impl Role {pub async fn list_roles(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> StorageResult<Vec<Self>> {let predicate = dsl::merchant_id.eq(merchant_id.to_owned()).or(dsl::org_iddiff --git a/crates/diesel_models/src/query/routing_algorithm.rs b/crates/diesel_models/src/query/routing_algorithm.rsindex 75a1f37f17..6598733f0e 100644--- a/crates/diesel_models/src/query/routing_algorithm.rs+++ b/crates/diesel_models/src/query/routing_algorithm.rs@@ -20,7 +20,7 @@ impl RoutingAlgorithm {pub async fn find_by_algorithm_id_merchant_id(conn: &PgPooledConn,algorithm_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -164,7 +164,7 @@ impl RoutingAlgorithm {pub async fn list_metadata_by_merchant_id(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,limit: i64,offset: i64,) -> StorageResult<Vec<RoutingProfileMetadata>> {@@ -224,7 +224,7 @@ impl RoutingAlgorithm {pub async fn list_metadata_by_merchant_id_transaction_type(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,transaction_type: &enums::TransactionType,limit: i64,offset: i64,diff --git a/crates/diesel_models/src/query/user/sample_data.rs b/crates/diesel_models/src/query/user/sample_data.rsindex 00fcdbe7ee..ed88ccf46d 100644--- a/crates/diesel_models/src/query/user/sample_data.rs+++ b/crates/diesel_models/src/query/user/sample_data.rs@@ -63,7 +63,7 @@ pub async fn insert_refunds(pub async fn delete_payment_intents(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Vec<PaymentIntent>> {let query = diesel::delete(<PaymentIntent>::table()).filter(payment_intent_dsl::merchant_id.eq(merchant_id.to_owned()))@@ -88,7 +88,7 @@ pub async fn delete_payment_intents(}pub async fn delete_payment_attempts(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<Vec<PaymentAttempt>> {let query = diesel::delete(<PaymentAttempt>::table()).filter(payment_attempt_dsl::merchant_id.eq(merchant_id.to_owned()))@@ -112,7 +112,10 @@ pub async fn delete_payment_attempts(})}-pub async fn delete_refunds(conn: &PgPooledConn, merchant_id: &str) -> StorageResult<Vec<Refund>> {+pub async fn delete_refunds(+ conn: &PgPooledConn,+ merchant_id: &common_utils::id_type::MerchantId,+) -> StorageResult<Vec<Refund>> {let query = diesel::delete(<Refund>::table()).filter(refund_dsl::merchant_id.eq(merchant_id.to_owned())).filter(refund_dsl::payment_id.like("test_%"));diff --git a/crates/diesel_models/src/query/user_role.rs b/crates/diesel_models/src/query/user_role.rsindex 5dc5309fbe..b3fa399479 100644--- a/crates/diesel_models/src/query/user_role.rs+++ b/crates/diesel_models/src/query/user_role.rs@@ -21,7 +21,7 @@ impl UserRole {pub async fn find_by_user_id_merchant_id(conn: &PgPooledConn,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -35,7 +35,7 @@ impl UserRole {pub async fn update_by_user_id_merchant_id(conn: &PgPooledConn,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,update: UserRoleUpdate,) -> StorageResult<Self> {generics::generic_update_with_unique_predicate_get_result::<@@ -70,7 +70,7 @@ impl UserRole {pub async fn delete_by_user_id_merchant_id(conn: &PgPooledConn,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> StorageResult<Self> {generics::generic_delete_one_with_result::<<Self as HasTable>::Table, _, _>(conn,@@ -94,7 +94,7 @@ impl UserRole {pub async fn list_by_merchant_id(conn: &PgPooledConn,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(conn,diff --git a/crates/diesel_models/src/refund.rs b/crates/diesel_models/src/refund.rsindex a3e767fdb3..b95ade2df1 100644--- a/crates/diesel_models/src/refund.rs+++ b/crates/diesel_models/src/refund.rs@@ -25,7 +25,7 @@ pub struct Refund {pub internal_reference_id: String,pub refund_id: String, //merchant_reference idpub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub connector_transaction_id: String,pub connector: String,pub connector_refund_id: Option<String>,@@ -68,7 +68,7 @@ pub struct Refund {pub struct RefundNew {pub refund_id: String,pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub internal_reference_id: String,pub external_reference_id: Option<String>,pub connector_transaction_id: String,@@ -324,7 +324,7 @@ impl RefundUpdate {pub struct RefundCoreWorkflow {pub refund_internal_reference_id: String,pub connector_transaction_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: String,}diff --git a/crates/diesel_models/src/role.rs b/crates/diesel_models/src/role.rsindex cf23e36d83..cf38f49aad 100644--- a/crates/diesel_models/src/role.rs+++ b/crates/diesel_models/src/role.rs@@ -10,7 +10,7 @@ pub struct Role {pub id: i32,pub role_name: String,pub role_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub org_id: id_type::OrganizationId,#[diesel(deserialize_as = super::DieselArray<enums::PermissionGroup>)]pub groups: Vec<enums::PermissionGroup>,@@ -26,7 +26,7 @@ pub struct Role {pub struct RoleNew {pub role_name: String,pub role_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub org_id: id_type::OrganizationId,#[diesel(deserialize_as = super::DieselArray<enums::PermissionGroup>)]pub groups: Vec<enums::PermissionGroup>,diff --git a/crates/diesel_models/src/routing_algorithm.rs b/crates/diesel_models/src/routing_algorithm.rsindex 4634dd1af4..e2566783e9 100644--- a/crates/diesel_models/src/routing_algorithm.rs+++ b/crates/diesel_models/src/routing_algorithm.rs@@ -8,7 +8,7 @@ use crate::{enums, schema::routing_algorithm};pub struct RoutingAlgorithm {pub algorithm_id: String,pub profile_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub name: String,pub description: Option<String>,pub kind: enums::RoutingAlgorithmKind,diff --git a/crates/diesel_models/src/user.rs b/crates/diesel_models/src/user.rsindex 9d6514916d..8469e4c2ca 100644--- a/crates/diesel_models/src/user.rs+++ b/crates/diesel_models/src/user.rs@@ -19,7 +19,7 @@ pub struct User {pub is_verified: bool,pub created_at: PrimitiveDateTime,pub last_modified_at: PrimitiveDateTime,- pub preferred_merchant_id: Option<String>,+ pub preferred_merchant_id: Option<common_utils::id_type::MerchantId>,pub totp_status: TotpStatus,pub totp_secret: Option<Encryption>,#[diesel(deserialize_as = OptionalDieselArray<Secret<String>>)]@@ -39,7 +39,7 @@ pub struct UserNew {pub is_verified: bool,pub created_at: Option<PrimitiveDateTime>,pub last_modified_at: Option<PrimitiveDateTime>,- pub preferred_merchant_id: Option<String>,+ pub preferred_merchant_id: Option<common_utils::id_type::MerchantId>,pub totp_status: TotpStatus,pub totp_secret: Option<Encryption>,pub totp_recovery_codes: Option<Vec<Secret<String>>>,@@ -53,7 +53,7 @@ pub struct UserUpdateInternal {password: Option<Secret<String>>,is_verified: Option<bool>,last_modified_at: PrimitiveDateTime,- preferred_merchant_id: Option<String>,+ preferred_merchant_id: Option<common_utils::id_type::MerchantId>,totp_status: Option<TotpStatus>,totp_secret: Option<Encryption>,totp_recovery_codes: Option<Vec<Secret<String>>>,@@ -66,7 +66,7 @@ pub enum UserUpdate {AccountUpdate {name: Option<String>,is_verified: Option<bool>,- preferred_merchant_id: Option<String>,+ preferred_merchant_id: Option<common_utils::id_type::MerchantId>,},TotpUpdate {totp_status: Option<TotpStatus>,diff --git a/crates/diesel_models/src/user/dashboard_metadata.rs b/crates/diesel_models/src/user/dashboard_metadata.rsindex 78caa20a93..291b4d2a3e 100644--- a/crates/diesel_models/src/user/dashboard_metadata.rs+++ b/crates/diesel_models/src/user/dashboard_metadata.rs@@ -9,7 +9,7 @@ use crate::{enums, schema::dashboard_metadata};pub struct DashboardMetadata {pub id: i32,pub user_id: Option<String>,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub org_id: id_type::OrganizationId,pub data_key: enums::DashboardMetadata,pub data_value: serde_json::Value,@@ -25,7 +25,7 @@ pub struct DashboardMetadata {#[diesel(table_name = dashboard_metadata)]pub struct DashboardMetadataNew {pub user_id: Option<String>,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub org_id: id_type::OrganizationId,pub data_key: enums::DashboardMetadata,pub data_value: serde_json::Value,diff --git a/crates/diesel_models/src/user/sample_data.rs b/crates/diesel_models/src/user/sample_data.rsindex c1ccdfa450..035d99e554 100644--- a/crates/diesel_models/src/user/sample_data.rs+++ b/crates/diesel_models/src/user/sample_data.rs@@ -20,7 +20,7 @@ use crate::{#[diesel(table_name = payment_attempt)]pub struct PaymentAttemptBatchNew {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub attempt_id: String,pub status: AttemptStatus,pub amount: i64,diff --git a/crates/diesel_models/src/user_role.rs b/crates/diesel_models/src/user_role.rsindex 28cbac2f73..7f7c8484e8 100644--- a/crates/diesel_models/src/user_role.rs+++ b/crates/diesel_models/src/user_role.rs@@ -9,7 +9,7 @@ use crate::{enums, schema::user_roles};pub struct UserRole {pub id: i32,pub user_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub role_id: String,pub org_id: id_type::OrganizationId,pub status: enums::UserStatus,@@ -23,7 +23,7 @@ pub struct UserRole {#[diesel(table_name = user_roles)]pub struct UserRoleNew {pub user_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub role_id: String,pub org_id: id_type::OrganizationId,pub status: enums::UserStatus,diff --git a/crates/hyperswitch_domain_models/src/behaviour.rs b/crates/hyperswitch_domain_models/src/behaviour.rsindex 07911e8ea6..29f9d6bab7 100644--- a/crates/hyperswitch_domain_models/src/behaviour.rs+++ b/crates/hyperswitch_domain_models/src/behaviour.rs@@ -1,6 +1,6 @@use common_utils::{errors::{CustomResult, ValidationError},- types::keymanager::KeyManagerState,+ types::keymanager::{Identifier, KeyManagerState},};use masking::Secret;@@ -15,7 +15,7 @@ pub trait Conversion {state: &KeyManagerState,item: Self::DstType,key: &Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized;@@ -29,7 +29,7 @@ pub trait ReverseConversion<SrcType: Conversion> {self,state: &KeyManagerState,key: &Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: Identifier,) -> CustomResult<SrcType, ValidationError>;}@@ -39,8 +39,8 @@ impl<T: Send, U: Conversion<DstType = T>> ReverseConversion<U> for T {self,state: &KeyManagerState,key: &Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: Identifier,) -> CustomResult<U, ValidationError> {- U::convert_back(state, self, key, key_store_ref_id).await+ U::convert_back(state, self, key, key_manager_identifier).await}}diff --git a/crates/hyperswitch_domain_models/src/customer.rs b/crates/hyperswitch_domain_models/src/customer.rsindex ef7c816b0d..558a8b4469 100644--- a/crates/hyperswitch_domain_models/src/customer.rs+++ b/crates/hyperswitch_domain_models/src/customer.rs@@ -4,7 +4,7 @@ use common_utils::{encryption::Encryption,errors::{CustomResult, ValidationError},id_type, pii,- types::keymanager::{Identifier, KeyManagerState, ToEncryptable},+ types::keymanager::{self, KeyManagerState, ToEncryptable},};use diesel_models::customers::CustomerUpdateInternal;use error_stack::ResultExt;@@ -24,7 +24,7 @@ pub enum SoftDeleteStatus {pub struct Customer {pub id: Option<i32>,pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub name: crypto::OptionalEncryptableName,pub email: crypto::OptionalEncryptableEmail,pub phone: crypto::OptionalEncryptablePhone,@@ -73,7 +73,7 @@ impl super::behaviour::Conversion for Customer {state: &KeyManagerState,item: Self::DstType,key: &Secret<Vec<u8>>,- _key_store_ref_id: String,+ _key_manager_identifier: keymanager::Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized,@@ -85,7 +85,7 @@ impl super::behaviour::Conversion for Customer {phone: item.phone.clone(),email: item.email.clone(),}),- Identifier::Merchant(item.merchant_id.clone()),+ keymanager::Identifier::Merchant(item.merchant_id.clone()),key.peek(),).awaitdiff --git a/crates/hyperswitch_domain_models/src/merchant_account.rs b/crates/hyperswitch_domain_models/src/merchant_account.rsindex 5ff3fec14c..eb5905c507 100644--- a/crates/hyperswitch_domain_models/src/merchant_account.rs+++ b/crates/hyperswitch_domain_models/src/merchant_account.rs@@ -1,10 +1,3 @@-#[cfg(all(- any(feature = "v1", feature = "v2"),- not(feature = "merchant_account_v2")-))]-use common_utils::id_type;-#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]-use common_utils::id_type;use common_utils::{crypto::{OptionalEncryptableName, OptionalEncryptableValue},date_time,@@ -12,7 +5,7 @@ use common_utils::{errors::{CustomResult, ValidationError},ext_traits::ValueExt,pii,- types::keymanager,+ types::keymanager::{self},};use diesel_models::{enums::MerchantStorageScheme, merchant_account::MerchantAccountUpdateInternal,@@ -30,7 +23,7 @@ use crate::type_encryption::{decrypt_optional, AsyncLift};#[derive(Clone, Debug, serde::Serialize)]pub struct MerchantAccount {pub id: Option<i32>,- pub merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,pub return_url: Option<String>,pub enable_payment_response_hash: bool,pub payment_response_hash_key: Option<String>,@@ -39,7 +32,7 @@ pub struct MerchantAccount {pub merchant_details: OptionalEncryptableValue,pub webhook_details: Option<serde_json::Value>,pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<String>,+ pub parent_merchant_id: Option<common_utils::id_type::MerchantId>,pub publishable_key: String,pub storage_scheme: MerchantStorageScheme,pub locker_id: Option<String>,@@ -51,7 +44,7 @@ pub struct MerchantAccount {pub modified_at: time::PrimitiveDateTime,pub intent_fulfillment_time: Option<i64>,pub payout_routing_algorithm: Option<serde_json::Value>,- pub organization_id: id_type::OrganizationId,+ pub organization_id: common_utils::id_type::OrganizationId,pub is_recon_enabled: bool,pub default_profile: Option<String>,pub recon_status: diesel_models::enums::ReconStatus,@@ -59,10 +52,85 @@ pub struct MerchantAccount {pub pm_collect_link_config: Option<serde_json::Value>,}+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]+#[derive(Clone)]+/// Set the private fields of merchant account+pub struct MerchantAccountSetter {+ pub merchant_id: common_utils::id_type::MerchantId,+ pub return_url: Option<String>,+ pub enable_payment_response_hash: bool,+ pub payment_response_hash_key: Option<String>,+ pub redirect_to_merchant_with_http_post: bool,+ pub merchant_name: OptionalEncryptableName,+ pub merchant_details: OptionalEncryptableValue,+ pub webhook_details: Option<serde_json::Value>,+ pub sub_merchants_enabled: Option<bool>,+ pub parent_merchant_id: Option<common_utils::id_type::MerchantId>,+ pub publishable_key: String,+ pub storage_scheme: MerchantStorageScheme,+ pub locker_id: Option<String>,+ pub metadata: Option<pii::SecretSerdeValue>,+ pub routing_algorithm: Option<serde_json::Value>,+ pub primary_business_details: serde_json::Value,+ pub frm_routing_algorithm: Option<serde_json::Value>,+ pub created_at: time::PrimitiveDateTime,+ pub modified_at: time::PrimitiveDateTime,+ pub intent_fulfillment_time: Option<i64>,+ pub payout_routing_algorithm: Option<serde_json::Value>,+ pub organization_id: common_utils::id_type::OrganizationId,+ pub is_recon_enabled: bool,+ pub default_profile: Option<String>,+ pub recon_status: diesel_models::enums::ReconStatus,+ pub payment_link_config: Option<serde_json::Value>,+ pub pm_collect_link_config: Option<serde_json::Value>,+}++#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]+impl From<MerchantAccountSetter> for MerchantAccount {+ fn from(item: MerchantAccountSetter) -> Self {+ Self {+ id: None,+ merchant_id: item.merchant_id,+ return_url: item.return_url,+ enable_payment_response_hash: item.enable_payment_response_hash,+ payment_response_hash_key: item.payment_response_hash_key,+ redirect_to_merchant_with_http_post: item.redirect_to_merchant_with_http_post,+ merchant_name: item.merchant_name,+ merchant_details: item.merchant_details,+ webhook_details: item.webhook_details,+ sub_merchants_enabled: item.sub_merchants_enabled,+ parent_merchant_id: item.parent_merchant_id,+ publishable_key: item.publishable_key,+ storage_scheme: item.storage_scheme,+ locker_id: item.locker_id,+ metadata: item.metadata,+ routing_algorithm: item.routing_algorithm,+ primary_business_details: item.primary_business_details,+ frm_routing_algorithm: item.frm_routing_algorithm,+ created_at: item.created_at,+ modified_at: item.modified_at,+ intent_fulfillment_time: item.intent_fulfillment_time,+ payout_routing_algorithm: item.payout_routing_algorithm,+ organization_id: item.organization_id,+ is_recon_enabled: item.is_recon_enabled,+ default_profile: item.default_profile,+ recon_status: item.recon_status,+ payment_link_config: item.payment_link_config,+ pm_collect_link_config: item.pm_collect_link_config,+ }+ }+}+#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]#[derive(Clone, Debug, serde::Serialize)]pub struct MerchantAccount {- pub merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,pub return_url: Option<String>,pub enable_payment_response_hash: bool,pub payment_response_hash_key: Option<String>,@@ -83,7 +151,7 @@ pub struct MerchantAccount {pub modified_at: time::PrimitiveDateTime,pub intent_fulfillment_time: Option<i64>,pub payout_routing_algorithm: Option<serde_json::Value>,- pub organization_id: id_type::OrganizationId,+ pub organization_id: common_utils::id_type::OrganizationId,pub is_recon_enabled: bool,pub default_profile: Option<String>,pub recon_status: diesel_models::enums::ReconStatus,@@ -91,6 +159,13 @@ pub struct MerchantAccount {pub pm_collect_link_config: Option<serde_json::Value>,}+impl MerchantAccount {+ /// Get the unique identifier of MerchantAccount+ pub fn get_id(&self) -> &common_utils::id_type::MerchantId {+ &self.merchant_id+ }+}+#[allow(clippy::large_enum_variant)]#[derive(Debug)]pub enum MerchantAccountUpdate {@@ -100,7 +175,7 @@ pub enum MerchantAccountUpdate {return_url: Option<String>,webhook_details: Option<serde_json::Value>,sub_merchants_enabled: Option<bool>,- parent_merchant_id: Option<String>,+ parent_merchant_id: Option<common_utils::id_type::MerchantId>,enable_payment_response_hash: Option<bool>,payment_response_hash_key: Option<String>,redirect_to_merchant_with_http_post: Option<bool>,@@ -240,7 +315,7 @@ impl super::behaviour::Conversion for MerchantAccount {state: &keymanager::KeyManagerState,item: Self::DstType,key: &Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: keymanager::Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized,@@ -251,8 +326,6 @@ impl super::behaviour::Conversion for MerchantAccount {field_name: "publishable_key".to_string(),})?;- let identifier = keymanager::Identifier::Merchant(key_store_ref_id.clone());-async {Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self {merchant_id: item.merchant_id,@@ -263,13 +336,13 @@ impl super::behaviour::Conversion for MerchantAccount {merchant_name: item.merchant_name.async_lift(|inner| {- decrypt_optional(state, inner, identifier.clone(), key.peek())+ decrypt_optional(state, inner, key_manager_identifier.clone(), key.peek())}).await?,merchant_details: item.merchant_details.async_lift(|inner| {- decrypt_optional(state, inner, identifier.clone(), key.peek())+ decrypt_optional(state, inner, key_manager_identifier.clone(), key.peek())}).await?,webhook_details: item.webhook_details,@@ -380,7 +453,7 @@ impl super::behaviour::Conversion for MerchantAccount {state: &keymanager::KeyManagerState,item: Self::DstType,key: &Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: keymanager::Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized,@@ -390,7 +463,6 @@ impl super::behaviour::Conversion for MerchantAccount {.ok_or(ValidationError::MissingRequiredField {field_name: "publishable_key".to_string(),})?;- let identifier = keymanager::Identifier::Merchant(key_store_ref_id.clone());async {Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self {id: Some(item.id),@@ -402,13 +474,13 @@ impl super::behaviour::Conversion for MerchantAccount {merchant_name: item.merchant_name.async_lift(|inner| {- decrypt_optional(state, inner, identifier.clone(), key.peek())+ decrypt_optional(state, inner, key_manager_identifier.clone(), key.peek())}).await?,merchant_details: item.merchant_details.async_lift(|inner| {- decrypt_optional(state, inner, identifier.clone(), key.peek())+ decrypt_optional(state, inner, key_manager_identifier.clone(), key.peek())}).await?,webhook_details: item.webhook_details,diff --git a/crates/hyperswitch_domain_models/src/merchant_key_store.rs b/crates/hyperswitch_domain_models/src/merchant_key_store.rsindex d48403b62f..bfd75a08fa 100644--- a/crates/hyperswitch_domain_models/src/merchant_key_store.rs+++ b/crates/hyperswitch_domain_models/src/merchant_key_store.rs@@ -2,7 +2,7 @@ use common_utils::{crypto::Encryptable,custom_serde, date_time,errors::{CustomResult, ValidationError},- types::keymanager::{Identifier, KeyManagerState},+ types::keymanager::{self, KeyManagerState},};use error_stack::ResultExt;use masking::{PeekInterface, Secret};@@ -12,7 +12,7 @@ use crate::type_encryption::decrypt;#[derive(Clone, Debug, serde::Serialize)]pub struct MerchantKeyStore {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub key: Encryptable<Secret<Vec<u8>>>,#[serde(with = "custom_serde::iso8601")]pub created_at: PrimitiveDateTime,@@ -34,12 +34,12 @@ impl super::behaviour::Conversion for MerchantKeyStore {state: &KeyManagerState,item: Self::DstType,key: &Secret<Vec<u8>>,- _key_store_ref_id: String,+ _key_manager_identifier: keymanager::Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized,{- let identifier = Identifier::Merchant(item.merchant_id.clone());+ let identifier = keymanager::Identifier::Merchant(item.merchant_id.clone());Ok(Self {key: decrypt(state, item.key, identifier, key.peek()).awaitdiff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex 0e12eac2f9..ac79bc1a94 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -13,7 +13,7 @@ use crate::RemoteStorageObject;#[derive(Clone, Debug, PartialEq, serde::Serialize)]pub struct PaymentIntent {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub status: storage_enums::IntentStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex 2bf8f56260..7e4c552472 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -1,14 +1,13 @@use api_models::enums::Connector;use common_enums as storage_enums;-#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]-use common_utils::types::keymanager::KeyManagerState;-#[cfg(all(feature = "v2", feature = "payment_v2"))]-use common_utils::types::keymanager::KeyManagerState;use common_utils::{encryption::Encryption,errors::{CustomResult, ValidationError},- pii,- types::MinorUnit,+ id_type, pii,+ types::{+ keymanager::{self, KeyManagerState},+ MinorUnit,+ },};use error_stack::ResultExt;use masking::PeekInterface;@@ -42,27 +41,27 @@ pub trait PaymentAttemptInterface {&self,connector_transaction_id: &str,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_txn_id: &str,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;@@ -70,7 +69,7 @@ pub trait PaymentAttemptInterface {async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,attempt_id: &str,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;@@ -78,20 +77,20 @@ pub trait PaymentAttemptInterface {async fn find_payment_attempt_by_attempt_id_merchant_id(&self,attempt_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,preprocessing_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError>;async fn find_attempts_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<PaymentAttempt>, errors::StorageError>;@@ -99,14 +98,14 @@ pub trait PaymentAttemptInterface {async fn get_filters_for_payments(&self,pi: &[PaymentIntent],- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentListFilters, errors::StorageError>;#[allow(clippy::too_many_arguments)]async fn get_total_count_of_filtered_payment_attempts(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,active_attempt_ids: &[String],connector: Option<Vec<Connector>>,payment_method: Option<Vec<storage_enums::PaymentMethod>>,@@ -120,7 +119,7 @@ pub trait PaymentAttemptInterface {#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]pub struct PaymentAttempt {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub attempt_id: String,pub status: storage_enums::AttemptStatus,pub amount: MinorUnit,@@ -210,7 +209,7 @@ pub struct PaymentListFilters {#[derive(Clone, Debug, Default, Serialize, Deserialize)]pub struct PaymentAttemptNew {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub attempt_id: String,pub status: storage_enums::AttemptStatus,pub amount: MinorUnit,@@ -548,20 +547,14 @@ impl behaviour::Conversion for PaymentIntent {state: &KeyManagerState,storage_model: Self::DstType,key: &masking::Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: keymanager::Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized,{async {- let inner_decrypt = |inner| {- decrypt_optional(- state,- inner,- common_utils::types::keymanager::Identifier::Merchant(key_store_ref_id.clone()),- key.peek(),- )- };+ let inner_decrypt =+ |inner| decrypt_optional(state, inner, key_manager_identifier, key.peek());Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self {payment_id: storage_model.payment_id,merchant_id: storage_model.merchant_id,@@ -744,20 +737,14 @@ impl behaviour::Conversion for PaymentIntent {state: &KeyManagerState,storage_model: Self::DstType,key: &masking::Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: keymanager::Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized,{async {- let inner_decrypt = |inner| {- decrypt_optional(- state,- inner,- common_utils::types::keymanager::Identifier::Merchant(key_store_ref_id.clone()),- key.peek(),- )- };+ let inner_decrypt =+ |inner| decrypt_optional(state, inner, key_manager_identifier.clone(), key.peek());Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self {payment_id: storage_model.payment_id,merchant_id: storage_model.merchant_id,diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex f4f6be9705..3d30565679 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -36,7 +36,7 @@ pub trait PaymentIntentInterface {&self,state: &KeyManagerState,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_key_store: &MerchantKeyStore,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, errors::StorageError>;@@ -51,7 +51,7 @@ pub trait PaymentIntentInterface {async fn filter_payment_intent_by_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,filters: &PaymentIntentFetchConstraints,merchant_key_store: &MerchantKeyStore,storage_scheme: storage_enums::MerchantStorageScheme,@@ -61,7 +61,7 @@ pub trait PaymentIntentInterface {async fn filter_payment_intents_by_time_range_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,time_range: &api_models::payments::TimeRange,merchant_key_store: &MerchantKeyStore,storage_scheme: storage_enums::MerchantStorageScheme,@@ -71,7 +71,7 @@ pub trait PaymentIntentInterface {async fn get_filtered_payment_intents_attempt(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,constraints: &PaymentIntentFetchConstraints,merchant_key_store: &MerchantKeyStore,storage_scheme: storage_enums::MerchantStorageScheme,@@ -80,7 +80,7 @@ pub trait PaymentIntentInterface {#[cfg(feature = "olap")]async fn get_filtered_active_attempt_ids_for_total_count(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,constraints: &PaymentIntentFetchConstraints,storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<String>, errors::StorageError>;@@ -97,7 +97,7 @@ pub struct CustomerData {#[derive(Clone, Debug, PartialEq)]pub struct PaymentIntentNew {pub payment_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub status: storage_enums::IntentStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,diff --git a/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rsindex a0786f4de7..fe1cf4c9bd 100644--- a/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs@@ -27,14 +27,14 @@ pub trait PayoutAttemptInterface {async fn find_payout_attempt_by_merchant_id_payout_attempt_id(&self,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,_payout_attempt_id: &str,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PayoutAttempt, errors::StorageError>;async fn find_payout_attempt_by_merchant_id_connector_payout_id(&self,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,_connector_payout_id: &str,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PayoutAttempt, errors::StorageError>;@@ -42,7 +42,7 @@ pub trait PayoutAttemptInterface {async fn get_filters_for_payouts(&self,payout: &[Payouts],- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PayoutListFilters, errors::StorageError>;}@@ -60,7 +60,7 @@ pub struct PayoutAttempt {pub payout_attempt_id: String,pub payout_id: String,pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub address_id: String,pub connector: Option<String>,pub connector_payout_id: Option<String>,@@ -85,7 +85,7 @@ pub struct PayoutAttemptNew {pub payout_attempt_id: String,pub payout_id: String,pub customer_id: id_type::CustomerId,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub address_id: String,pub connector: Option<String>,pub connector_payout_id: Option<String>,@@ -111,7 +111,7 @@ impl Default for PayoutAttemptNew {payout_attempt_id: String::default(),payout_id: String::default(),customer_id: generate_customer_id_of_default_length(),- merchant_id: String::default(),+ merchant_id: id_type::MerchantId::default(),address_id: String::default(),connector: None,connector_payout_id: Some(String::default()),diff --git a/crates/hyperswitch_domain_models/src/payouts/payouts.rs b/crates/hyperswitch_domain_models/src/payouts/payouts.rsindex 78cb572a8b..16b4bf7f91 100644--- a/crates/hyperswitch_domain_models/src/payouts/payouts.rs+++ b/crates/hyperswitch_domain_models/src/payouts/payouts.rs@@ -19,7 +19,7 @@ pub trait PayoutsInterface {async fn find_payout_by_merchant_id_payout_id(&self,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,_payout_id: &str,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Payouts, errors::StorageError>;@@ -34,7 +34,7 @@ pub trait PayoutsInterface {async fn find_optional_payout_by_merchant_id_payout_id(&self,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,_payout_id: &str,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Option<Payouts>, errors::StorageError>;@@ -42,7 +42,7 @@ pub trait PayoutsInterface {#[cfg(feature = "olap")]async fn filter_payouts_by_constraints(&self,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,_filters: &PayoutFetchConstraints,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<Payouts>, errors::StorageError>;@@ -50,7 +50,7 @@ pub trait PayoutsInterface {#[cfg(feature = "olap")]async fn filter_payouts_and_attempts(&self,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,_filters: &PayoutFetchConstraints,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<@@ -61,7 +61,7 @@ pub trait PayoutsInterface {#[cfg(feature = "olap")]async fn filter_payouts_by_time_range_constraints(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,time_range: &api_models::payments::TimeRange,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<Payouts>, errors::StorageError>;@@ -70,7 +70,7 @@ pub trait PayoutsInterface {#[derive(Clone, Debug, Eq, PartialEq)]pub struct Payouts {pub payout_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub customer_id: id_type::CustomerId,pub address_id: String,pub payout_type: Option<storage_enums::PayoutType>,@@ -98,7 +98,7 @@ pub struct Payouts {#[derive(Clone, Debug, Eq, PartialEq)]pub struct PayoutsNew {pub payout_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub customer_id: id_type::CustomerId,pub address_id: String,pub payout_type: Option<storage_enums::PayoutType>,@@ -129,7 +129,7 @@ impl Default for PayoutsNew {Self {payout_id: String::default(),- merchant_id: String::default(),+ merchant_id: id_type::MerchantId::default(),customer_id: common_utils::generate_customer_id_of_default_length(),address_id: String::default(),payout_type: Some(storage_enums::PayoutType::default()),diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rsindex 248c1f3529..c2df268644 100644--- a/crates/hyperswitch_domain_models/src/router_data.rs+++ b/crates/hyperswitch_domain_models/src/router_data.rs@@ -8,7 +8,7 @@ use crate::{payment_address::PaymentAddress, payment_method_data};#[derive(Debug, Clone)]pub struct RouterData<Flow, Request, Response> {pub flow: PhantomData<Flow>,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub customer_id: Option<id_type::CustomerId>,pub connector_customer: Option<String>,pub connector: String,diff --git a/crates/hyperswitch_domain_models/src/router_data_v2/flow_common_types.rs b/crates/hyperswitch_domain_models/src/router_data_v2/flow_common_types.rsindex afba9e14d7..b2dea40082 100644--- a/crates/hyperswitch_domain_models/src/router_data_v2/flow_common_types.rs+++ b/crates/hyperswitch_domain_models/src/router_data_v2/flow_common_types.rs@@ -11,7 +11,7 @@ use crate::{#[derive(Debug, Clone)]pub struct PaymentFlowData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub customer_id: Option<common_utils::id_type::CustomerId>,pub connector_customer: Option<String>,pub payment_id: String,@@ -53,7 +53,7 @@ pub struct PaymentFlowData {#[derive(Debug, Clone)]pub struct RefundFlowData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub customer_id: Option<common_utils::id_type::CustomerId>,pub payment_id: String,pub attempt_id: String,@@ -72,7 +72,7 @@ pub struct RefundFlowData {#[cfg(feature = "payouts")]#[derive(Debug, Clone)]pub struct PayoutFlowData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub customer_id: Option<common_utils::id_type::CustomerId>,pub connector_customer: Option<String>,pub return_url: Option<String>,@@ -88,7 +88,7 @@ pub struct PayoutFlowData {#[cfg(feature = "frm")]#[derive(Debug, Clone)]pub struct FrmFlowData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: String,pub attempt_id: String,pub payment_method: common_enums::enums::PaymentMethod,@@ -104,14 +104,14 @@ pub struct FrmFlowData {#[derive(Debug, Clone)]pub struct ExternalAuthenticationFlowData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub connector_meta_data: Option<pii::SecretSerdeValue>,pub address: PaymentAddress,}#[derive(Debug, Clone)]pub struct DisputesFlowData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: String,pub attempt_id: String,pub payment_method: common_enums::enums::PaymentMethod,@@ -127,14 +127,14 @@ pub struct DisputesFlowData {#[derive(Debug, Clone)]pub struct MandateRevokeFlowData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub customer_id: common_utils::id_type::CustomerId,pub payment_id: Option<String>,}#[derive(Debug, Clone)]pub struct WebhookSourceVerifyData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,}#[derive(Debug, Clone)]@@ -142,7 +142,7 @@ pub struct AccessTokenFlowData {}#[derive(Debug, Clone)]pub struct FilesFlowData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: String,pub attempt_id: String,pub return_url: Option<String>,diff --git a/crates/hyperswitch_interfaces/src/events/connector_api_logs.rs b/crates/hyperswitch_interfaces/src/events/connector_api_logs.rsindex 79b172e9ea..5edd8d68c3 100644--- a/crates/hyperswitch_interfaces/src/events/connector_api_logs.rs+++ b/crates/hyperswitch_interfaces/src/events/connector_api_logs.rs@@ -17,7 +17,7 @@ pub struct ConnectorEvent {url: String,method: String,payment_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,created_at: i128,/// Connector Event Request IDpub request_id: String,@@ -37,7 +37,7 @@ impl ConnectorEvent {url: String,method: Method,payment_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,request_id: Option<&RequestId>,latency: u128,refund_id: Option<String>,diff --git a/crates/hyperswitch_interfaces/src/webhooks.rs b/crates/hyperswitch_interfaces/src/webhooks.rsindex b9148d6701..e863af40a3 100644--- a/crates/hyperswitch_interfaces/src/webhooks.rs+++ b/crates/hyperswitch_interfaces/src/webhooks.rs@@ -45,7 +45,7 @@ pub trait IncomingWebhook: ConnectorCommon + Sync {async fn decode_webhook_body(&self,request: &IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,connector_name: &str,) -> CustomResult<Vec<u8>, errors::ConnectorError> {@@ -79,12 +79,12 @@ pub trait IncomingWebhook: ConnectorCommon + Sync {/// fn get_webhook_source_verification_merchant_secretasync fn get_webhook_source_verification_merchant_secret(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: &str,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,) -> CustomResult<api_models::webhooks::ConnectorWebhookSecrets, errors::ConnectorError> {let debug_suffix = format!(- "For merchant_id: {}, and connector_name: {}",+ "For merchant_id: {:?}, and connector_name: {}",merchant_id, connector_name);let default_secret = "default_secret".to_string();@@ -136,7 +136,7 @@ pub trait IncomingWebhook: ConnectorCommon + Sync {fn get_webhook_source_verification_message(&self,_request: &IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {Ok(Vec::new())@@ -146,7 +146,7 @@ pub trait IncomingWebhook: ConnectorCommon + Sync {async fn verify_webhook_source(&self,request: &IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,connector_name: &str,diff --git a/crates/pm_auth/src/types.rs b/crates/pm_auth/src/types.rsindex e5fb8fb644..4c20e879d8 100644--- a/crates/pm_auth/src/types.rs+++ b/crates/pm_auth/src/types.rs@@ -10,7 +10,7 @@ use masking::Secret;#[derive(Debug, Clone)]pub struct PaymentAuthRouterData<F, Request, Response> {pub flow: PhantomData<F>,- pub merchant_id: Option<String>,+ pub merchant_id: Option<id_type::MerchantId>,pub connector: Option<String>,pub request: Request,pub response: Result<Response, ErrorResponse>,diff --git a/crates/router/src/analytics.rs b/crates/router/src/analytics.rsindex 3cde172d23..b7e89929a8 100644--- a/crates/router/src/analytics.rs+++ b/crates/router/src/analytics.rs@@ -191,13 +191,9 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- analytics::payments::get_metrics(- &state.pool,- &auth.merchant_account.merchant_id,- req,- )- .await- .map(ApplicationResponse::Json)+ analytics::payments::get_metrics(&state.pool, auth.merchant_account.get_id(), req)+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth(Permission::Analytics),api_locking::LockAction::NotApplicable,@@ -229,7 +225,7 @@ pub mod routes {|state, auth: AuthenticationData, req, _| async move {analytics::payment_intents::get_metrics(&state.pool,- &auth.merchant_account.merchant_id,+ auth.merchant_account.get_id(),req,).await@@ -263,13 +259,9 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- analytics::refunds::get_metrics(- &state.pool,- &auth.merchant_account.merchant_id,- req,- )- .await- .map(ApplicationResponse::Json)+ analytics::refunds::get_metrics(&state.pool, auth.merchant_account.get_id(), req)+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth(Permission::Analytics),api_locking::LockAction::NotApplicable,@@ -299,7 +291,7 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- analytics::frm::get_metrics(&state.pool, &auth.merchant_account.merchant_id, req)+ analytics::frm::get_metrics(&state.pool, auth.merchant_account.get_id(), req).await.map(ApplicationResponse::Json)},@@ -370,7 +362,7 @@ pub mod routes {analytics::active_payments::get_metrics(&state.pool,&auth.merchant_account.publishable_key,- &auth.merchant_account.merchant_id,+ auth.merchant_account.get_id(),req,).await@@ -406,7 +398,7 @@ pub mod routes {|state, auth: AuthenticationData, req, _| async move {analytics::auth_events::get_metrics(&state.pool,- &auth.merchant_account.merchant_id,+ auth.merchant_account.get_id(),&auth.merchant_account.publishable_key,req,)@@ -431,13 +423,9 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- analytics::payments::get_filters(- &state.pool,- req,- &auth.merchant_account.merchant_id,- )- .await- .map(ApplicationResponse::Json)+ analytics::payments::get_filters(&state.pool, req, auth.merchant_account.get_id())+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth(Permission::Analytics),api_locking::LockAction::NotApplicable,@@ -460,7 +448,7 @@ pub mod routes {analytics::payment_intents::get_filters(&state.pool,req,- &auth.merchant_account.merchant_id,+ auth.merchant_account.get_id(),).await.map(ApplicationResponse::Json)@@ -483,13 +471,9 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req: GetRefundFilterRequest, _| async move {- analytics::refunds::get_filters(- &state.pool,- req,- &auth.merchant_account.merchant_id,- )- .await- .map(ApplicationResponse::Json)+ analytics::refunds::get_filters(&state.pool, req, auth.merchant_account.get_id())+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth(Permission::Analytics),api_locking::LockAction::NotApplicable,@@ -509,7 +493,7 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req: GetFrmFilterRequest, _| async move {- analytics::frm::get_filters(&state.pool, req, &auth.merchant_account.merchant_id)+ analytics::frm::get_filters(&state.pool, req, auth.merchant_account.get_id()).await.map(ApplicationResponse::Json)},@@ -557,7 +541,7 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- api_events_core(&state.pool, req, auth.merchant_account.merchant_id)+ api_events_core(&state.pool, req, auth.merchant_account.get_id()).await.map(ApplicationResponse::Json)},@@ -581,7 +565,7 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- outgoing_webhook_events_core(&state.pool, req, auth.merchant_account.merchant_id)+ outgoing_webhook_events_core(&state.pool, req, auth.merchant_account.get_id()).await.map(ApplicationResponse::Json)},@@ -635,7 +619,7 @@ pub mod routes {let lambda_req = GenerateReportRequest {request: payload,- merchant_id: auth.merchant_account.merchant_id.to_string(),+ merchant_id: auth.merchant_account.get_id().to_owned(),email: user_email,};@@ -677,7 +661,7 @@ pub mod routes {let lambda_req = GenerateReportRequest {request: payload,- merchant_id: auth.merchant_account.merchant_id.to_string(),+ merchant_id: auth.merchant_account.get_id().to_owned(),email: user_email,};@@ -719,7 +703,7 @@ pub mod routes {let lambda_req = GenerateReportRequest {request: payload,- merchant_id: auth.merchant_account.merchant_id.to_string(),+ merchant_id: auth.merchant_account.get_id().to_owned(),email: user_email,};@@ -763,7 +747,7 @@ pub mod routes {|state, auth: AuthenticationData, req, _| async move {analytics::api_event::get_api_event_metrics(&state.pool,- &auth.merchant_account.merchant_id,+ auth.merchant_account.get_id(),req,).await@@ -787,13 +771,9 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- analytics::api_event::get_filters(- &state.pool,- req,- auth.merchant_account.merchant_id,- )- .await- .map(ApplicationResponse::Json)+ analytics::api_event::get_filters(&state.pool, req, auth.merchant_account.get_id())+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth(Permission::Analytics),api_locking::LockAction::NotApplicable,@@ -813,7 +793,7 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- connector_events_core(&state.pool, req, auth.merchant_account.merchant_id)+ connector_events_core(&state.pool, req, auth.merchant_account.get_id()).await.map(ApplicationResponse::Json)},@@ -915,13 +895,9 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- analytics::disputes::get_filters(- &state.pool,- req,- &auth.merchant_account.merchant_id,- )- .await- .map(ApplicationResponse::Json)+ analytics::disputes::get_filters(&state.pool, req, auth.merchant_account.get_id())+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth(Permission::Analytics),api_locking::LockAction::NotApplicable,@@ -950,13 +926,9 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- analytics::disputes::get_metrics(- &state.pool,- &auth.merchant_account.merchant_id,- req,- )- .await- .map(ApplicationResponse::Json)+ analytics::disputes::get_metrics(&state.pool, auth.merchant_account.get_id(), req)+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth(Permission::Analytics),api_locking::LockAction::NotApplicable,diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rsindex adab685ea0..64969b7d51 100644--- a/crates/router/src/configs/settings.rs+++ b/crates/router/src/configs/settings.rs@@ -702,7 +702,8 @@ pub struct LockerBasedRecipientConnectorList {#[derive(Debug, Deserialize, Clone, Default)]pub struct ConnectorRequestReferenceIdConfig {- pub merchant_ids_send_payment_id_as_connector_request_id: HashSet<String>,+ pub merchant_ids_send_payment_id_as_connector_request_id:+ HashSet<common_utils::id_type::MerchantId>,}#[derive(Debug, Deserialize, Clone, Default)]diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rsindex 96d17edc0e..9d747c2b57 100644--- a/crates/router/src/connector/adyen.rs+++ b/crates/router/src/connector/adyen.rs@@ -1749,7 +1749,7 @@ impl api::IncomingWebhook for Adyen {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let notif = get_webhook_object_from_body(request.body)@@ -1773,7 +1773,7 @@ impl api::IncomingWebhook for Adyen {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,connector_label: &str,diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rsindex 681b994191..27189aab99 100644--- a/crates/router/src/connector/adyen/transformers.rs+++ b/crates/router/src/connector/adyen/transformers.rs@@ -1631,8 +1631,11 @@ fn get_recurring_processing_model(match (item.request.setup_future_usage, item.request.off_session) {(Some(storage_enums::FutureUsage::OffSession), _) => {let customer_id = item.get_customer_id()?;- let shopper_reference =- format!("{}_{}", item.merchant_id, customer_id.get_string_repr());+ let shopper_reference = format!(+ "{}_{}",+ item.merchant_id.get_string_repr(),+ customer_id.get_string_repr()+ );let store_payment_method = item.request.is_mandate_payment();Ok((Some(AdyenRecurringModel::UnscheduledCardOnFile),@@ -1645,7 +1648,7 @@ fn get_recurring_processing_model(None,Some(format!("{}_{}",- item.merchant_id,+ item.merchant_id.get_string_repr(),item.get_customer_id()?.get_string_repr())),)),@@ -1814,11 +1817,15 @@ fn get_social_security_number(voucher_data: &domain::VoucherData) -> Option<Secrfn build_shopper_reference(customer_id: &Option<id_type::CustomerId>,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> Option<String> {- customer_id- .clone()- .map(|c_id| format!("{}_{}", merchant_id, c_id.get_string_repr()))+ customer_id.clone().map(|c_id| {+ format!(+ "{}_{}",+ merchant_id.get_string_repr(),+ c_id.get_string_repr()+ )+ })}impl<'a> TryFrom<(&domain::BankDebitData, &types::PaymentsAuthorizeRouterData)>@@ -4603,7 +4610,7 @@ impl<F> TryFrom<&AdyenRouterData<&types::PayoutsRouterData<F>>> for AdyenPayoutEmerchant_account: auth_type.merchant_account,payment_method: payout_method_data,reference: item.router_data.connector_request_reference_id.clone(),- shopper_reference: item.router_data.merchant_id.clone(),+ shopper_reference: item.router_data.merchant_id.get_string_repr().to_owned(),})}}@@ -4690,7 +4697,7 @@ impl<F> TryFrom<&AdyenRouterData<&types::PayoutsRouterData<F>>> for AdyenPayoutCmerchant_account,payment_data: PayoutPaymentMethodData::PayoutBankData(bank_data),reference: item.router_data.connector_request_reference_id.to_owned(),- shopper_reference: item.router_data.merchant_id.to_owned(),+ shopper_reference: item.router_data.merchant_id.get_string_repr().to_owned(),shopper_email: customer_email,shopper_name: ShopperName {first_name: Some(address.get_first_name()?.to_owned()), // it is a required field for payouts@@ -4736,7 +4743,7 @@ impl<F> TryFrom<&AdyenRouterData<&types::PayoutsRouterData<F>>> for AdyenPayoutCmerchant_account,payment_data: PayoutPaymentMethodData::PayoutWalletData(payout_wallet),reference: item.router_data.request.payout_id.to_owned(),- shopper_reference: item.router_data.merchant_id.to_owned(),+ shopper_reference: item.router_data.merchant_id.get_string_repr().to_owned(),shopper_email: customer_email,shopper_name: ShopperName {first_name: Some(address.get_first_name()?.to_owned()), // it is a required field for payoutsdiff --git a/crates/router/src/connector/airwallex.rs b/crates/router/src/connector/airwallex.rsindex fbc2590948..e6b0113e98 100644--- a/crates/router/src/connector/airwallex.rs+++ b/crates/router/src/connector/airwallex.rs@@ -988,7 +988,7 @@ impl api::IncomingWebhook for Airwallex {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let timestamp = requestdiff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rsindex 8d0c1db37a..b48643e76e 100644--- a/crates/router/src/connector/authorizedotnet.rs+++ b/crates/router/src/connector/authorizedotnet.rs@@ -918,7 +918,7 @@ impl api::IncomingWebhook for Authorizedotnet {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {Ok(request.body.to_vec())diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rsindex 7fb4869dc8..ed54b1e052 100644--- a/crates/router/src/connector/bluesnap.rs+++ b/crates/router/src/connector/bluesnap.rs@@ -1075,7 +1075,7 @@ impl api::IncomingWebhook for Bluesnap {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let timestamp =@@ -1343,12 +1343,15 @@ impl ConnectorErrorTypeMapping for Bluesnap {fn get_url_with_merchant_transaction_id(base_url: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,merchant_transaction_id: String,) -> CustomResult<String, errors::ConnectorError> {Ok(format!("{}{}{},{}",- base_url, "services/2/transactions/", merchant_transaction_id, merchant_id+ base_url,+ "services/2/transactions/",+ merchant_transaction_id,+ merchant_id.get_string_repr()))}diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rsindex f354bf1c2d..2f4670ccdc 100644--- a/crates/router/src/connector/bluesnap/transformers.rs+++ b/crates/router/src/connector/bluesnap/transformers.rs@@ -198,7 +198,7 @@ pub struct ApplepayHeader {#[derive(Debug, Serialize, Deserialize, Clone)]pub struct BluesnapConnectorMetaData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,}#[derive(Debug, Serialize)]diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rsindex 5115280b93..fe15422a12 100644--- a/crates/router/src/connector/braintree.rs+++ b/crates/router/src/connector/braintree.rs@@ -1362,7 +1362,7 @@ impl api::IncomingWebhook for Braintree {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let notify = get_webhook_object_from_body(request.body)@@ -1376,7 +1376,7 @@ impl api::IncomingWebhook for Braintree {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,connector_label: &str,diff --git a/crates/router/src/connector/cashtocode.rs b/crates/router/src/connector/cashtocode.rsindex 2b06e0de69..2155b80dd8 100644--- a/crates/router/src/connector/cashtocode.rs+++ b/crates/router/src/connector/cashtocode.rs@@ -383,7 +383,7 @@ impl api::IncomingWebhook for Cashtocode {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: common_utils::crypto::Encryptable<Secret<serde_json::Value>>,connector_label: &str,diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rsindex d4170d3c3b..3fca0b86ae 100644--- a/crates/router/src/connector/checkout.rs+++ b/crates/router/src/connector/checkout.rs@@ -1236,7 +1236,7 @@ impl api::IncomingWebhook for Checkout {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {Ok(format!("{}", String::from_utf8_lossy(request.body)).into_bytes())diff --git a/crates/router/src/connector/coinbase.rs b/crates/router/src/connector/coinbase.rsindex 497cf81918..0c3c0be41d 100644--- a/crates/router/src/connector/coinbase.rs+++ b/crates/router/src/connector/coinbase.rs@@ -399,7 +399,7 @@ impl api::IncomingWebhook for Coinbase {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let message = std::str::from_utf8(request.body)diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rsindex 40f8584375..2bef8d46d7 100644--- a/crates/router/src/connector/cryptopay.rs+++ b/crates/router/src/connector/cryptopay.rs@@ -462,7 +462,7 @@ impl api::IncomingWebhook for Cryptopay {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let message = std::str::from_utf8(request.body)diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rsindex 5c1a8246f0..7d5553bb25 100644--- a/crates/router/src/connector/globalpay.rs+++ b/crates/router/src/connector/globalpay.rs@@ -967,7 +967,7 @@ impl api::IncomingWebhook for Globalpay {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let payload: Value = request.body.parse_struct("GlobalpayWebhookBody").switch()?;diff --git a/crates/router/src/connector/gocardless.rs b/crates/router/src/connector/gocardless.rsindex fc3a4f1d0b..281a1ea5c9 100644--- a/crates/router/src/connector/gocardless.rs+++ b/crates/router/src/connector/gocardless.rs@@ -760,7 +760,7 @@ impl api::IncomingWebhook for Gocardless {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {Ok(format!("{}", String::from_utf8_lossy(request.body))diff --git a/crates/router/src/connector/gpayments/gpayments_types.rs b/crates/router/src/connector/gpayments/gpayments_types.rsindex cb436fe883..787740523a 100644--- a/crates/router/src/connector/gpayments/gpayments_types.rs+++ b/crates/router/src/connector/gpayments/gpayments_types.rs@@ -12,7 +12,7 @@ pub struct GpaymentsConnectorMetaData {#[serde(rename_all = "camelCase")]pub struct GpaymentsPreAuthVersionCallRequest {pub acct_number: CardNumber,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,}#[derive(Serialize, Deserialize, Debug, Clone)]@@ -68,7 +68,7 @@ pub struct GpaymentsPreAuthenticationRequest {////// Example: "1234567890123456789012345678901234"/// Length: Maximum 35 characters- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,/// Optional boolean. If set to true, ActiveServer will not collect the browser information automatically./// The requestor must have a backend implementation to collect browser information.@@ -135,7 +135,7 @@ pub struct GpaymentsAuthenticationRequest {pub card_expiry_date: String,#[serde(rename = "notificationURL")]pub notification_url: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,#[serde(rename = "threeDSCompInd")]pub three_ds_comp_ind: ThreeDsCompletionIndicator,pub message_category: String,diff --git a/crates/router/src/connector/gpayments/transformers.rs b/crates/router/src/connector/gpayments/transformers.rsindex c6bce775e8..50c8c0f28c 100644--- a/crates/router/src/connector/gpayments/transformers.rs+++ b/crates/router/src/connector/gpayments/transformers.rs@@ -79,7 +79,7 @@ impl TryFrom<&GpaymentsRouterData<&types::authentication::PreAuthNVersionCallRou#[derive(Deserialize, PartialEq)]pub struct GpaymentsMetaData {pub endpoint_prefix: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,}impl TryFrom<&Option<common_utils::pii::SecretSerdeValue>> for GpaymentsMetaData {diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rsindex c3e8344198..8dc7479889 100644--- a/crates/router/src/connector/iatapay.rs+++ b/crates/router/src/connector/iatapay.rs@@ -675,7 +675,7 @@ impl api::IncomingWebhook for Iatapay {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let message = std::str::from_utf8(request.body)diff --git a/crates/router/src/connector/mifinity.rs b/crates/router/src/connector/mifinity.rsindex 9c20c26875..b4a22e38a0 100644--- a/crates/router/src/connector/mifinity.rs+++ b/crates/router/src/connector/mifinity.rs@@ -316,7 +316,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsReOk(format!("{}api/gateway/payment-status/payment_validation_key_{}_{}",self.base_url(connectors),- merchant_id,+ merchant_id.get_string_repr(),payment_id))}diff --git a/crates/router/src/connector/mifinity/transformers.rs b/crates/router/src/connector/mifinity/transformers.rsindex 0e52f7d3b5..20885d0895 100644--- a/crates/router/src/connector/mifinity/transformers.rs+++ b/crates/router/src/connector/mifinity/transformers.rs@@ -127,7 +127,7 @@ impl TryFrom<&MifinityRouterData<&types::PaymentsAuthorizeRouterData>> for Mifin};let validation_key = format!("payment_validation_key_{}_{}",- item.router_data.merchant_id,+ item.router_data.merchant_id.get_string_repr(),item.router_data.connector_request_reference_id.clone());let client_reference = item.router_data.customer_id.clone().ok_or(diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rsindex 2c0712c540..e43bc0808e 100644--- a/crates/router/src/connector/nmi.rs+++ b/crates/router/src/connector/nmi.rs@@ -888,7 +888,7 @@ impl api::IncomingWebhook for Nmi {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let sig_header =diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rsindex d9e476ac1f..4cc049a558 100644--- a/crates/router/src/connector/noon.rs+++ b/crates/router/src/connector/noon.rs@@ -869,7 +869,7 @@ impl api::IncomingWebhook for Noon {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let webhook_body: noon::NoonWebhookBody = requestdiff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rsindex 316a5e7ab4..8108413b4e 100644--- a/crates/router/src/connector/nuvei.rs+++ b/crates/router/src/connector/nuvei.rs@@ -875,7 +875,7 @@ impl api::IncomingWebhook for Nuvei {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let body = serde_urlencoded::from_str::<nuvei::NuveiWebhookDetails>(&request.query_params)diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rsindex 5346fc086d..0a1de1fdde 100644--- a/crates/router/src/connector/opennode.rs+++ b/crates/router/src/connector/opennode.rs@@ -398,7 +398,7 @@ impl api::IncomingWebhook for Opennode {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let message = std::str::from_utf8(request.body)diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rsindex 588ba7e712..6bf26b4f60 100644--- a/crates/router/src/connector/payme.rs+++ b/crates/router/src/connector/payme.rs@@ -1141,7 +1141,7 @@ impl api::IncomingWebhook for Payme {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let resource =@@ -1160,7 +1160,7 @@ impl api::IncomingWebhook for Payme {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,connector_label: &str,diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rsindex 714f8d5462..da10513b3d 100644--- a/crates/router/src/connector/rapyd.rs+++ b/crates/router/src/connector/rapyd.rs@@ -788,12 +788,15 @@ impl api::IncomingWebhook for Rapyd {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let host = connector_utils::get_header_key_value("host", request.headers)?;let connector = self.id();- let url_path = format!("https://{host}/webhooks/{merchant_id}/{connector}");+ let url_path = format!(+ "https://{host}/webhooks/{}/{connector}",+ merchant_id.get_string_repr()+ );let salt = connector_utils::get_header_key_value("salt", request.headers)?;let timestamp = connector_utils::get_header_key_value("timestamp", request.headers)?;let stringify_auth = String::from_utf8(connector_webhook_secrets.secret.to_vec())@@ -819,7 +822,7 @@ impl api::IncomingWebhook for Rapyd {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,connector_label: &str,diff --git a/crates/router/src/connector/razorpay.rs b/crates/router/src/connector/razorpay.rsindex 737ead477c..3dcb636b42 100644--- a/crates/router/src/connector/razorpay.rs+++ b/crates/router/src/connector/razorpay.rs@@ -643,7 +643,7 @@ impl api::IncomingWebhook for Razorpay {async fn verify_webhook_source(&self,_request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: common_utils::crypto::Encryptable<masking::Secret<serde_json::Value>,diff --git a/crates/router/src/connector/riskified.rs b/crates/router/src/connector/riskified.rsindex b37e794ec8..0f8ebb4613 100644--- a/crates/router/src/connector/riskified.rs+++ b/crates/router/src/connector/riskified.rs@@ -570,7 +570,7 @@ impl api::IncomingWebhook for Riskified {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,connector_label: &str,@@ -605,7 +605,7 @@ impl api::IncomingWebhook for Riskified {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {Ok(request.body.to_vec())diff --git a/crates/router/src/connector/signifyd.rs b/crates/router/src/connector/signifyd.rsindex c6b3e01ab5..6ba2dce986 100644--- a/crates/router/src/connector/signifyd.rs+++ b/crates/router/src/connector/signifyd.rs@@ -678,7 +678,7 @@ impl api::IncomingWebhook for Signifyd {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {Ok(request.body.to_vec())@@ -687,7 +687,7 @@ impl api::IncomingWebhook for Signifyd {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,connector_label: &str,diff --git a/crates/router/src/connector/square.rs b/crates/router/src/connector/square.rsindex 27f4dd2c25..9b9c68a5f2 100644--- a/crates/router/src/connector/square.rs+++ b/crates/router/src/connector/square.rs@@ -863,7 +863,7 @@ impl api::IncomingWebhook for Square {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let header_value = requestdiff --git a/crates/router/src/connector/stax.rs b/crates/router/src/connector/stax.rsindex d49a9f2b4f..8524a19309 100644--- a/crates/router/src/connector/stax.rs+++ b/crates/router/src/connector/stax.rs@@ -852,7 +852,7 @@ impl api::IncomingWebhook for Stax {async fn verify_webhook_source(&self,_request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: common_utils::crypto::Encryptable<Secret<serde_json::Value>>,_connector_label: &str,diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rsindex 7e4b644203..82ed9577a8 100644--- a/crates/router/src/connector/stripe.rs+++ b/crates/router/src/connector/stripe.rs@@ -2175,7 +2175,7 @@ impl api::IncomingWebhook for Stripe {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let mut security_header_kvs = get_signature_elements_from_header(request.headers)?;diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rsindex 6ec8b37982..deb7ec7961 100644--- a/crates/router/src/connector/trustpay.rs+++ b/crates/router/src/connector/trustpay.rs@@ -960,7 +960,7 @@ impl api::IncomingWebhook for Trustpay {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let trustpay_response: trustpay::TrustpayWebhookResponse = requestdiff --git a/crates/router/src/connector/volt.rs b/crates/router/src/connector/volt.rsindex b7da867696..202dcba7ed 100644--- a/crates/router/src/connector/volt.rs+++ b/crates/router/src/connector/volt.rs@@ -664,7 +664,7 @@ impl api::IncomingWebhook for Volt {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let x_volt_timed =diff --git a/crates/router/src/connector/worldline.rs b/crates/router/src/connector/worldline.rsindex ae5e6c1b4a..901f9ab8e4 100644--- a/crates/router/src/connector/worldline.rs+++ b/crates/router/src/connector/worldline.rs@@ -787,7 +787,7 @@ impl api::IncomingWebhook for Worldline {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {Ok(request.body.to_vec())diff --git a/crates/router/src/connector/worldline/transformers.rs b/crates/router/src/connector/worldline/transformers.rsindex 365ddda4d5..11d9da7785 100644--- a/crates/router/src/connector/worldline/transformers.rs+++ b/crates/router/src/connector/worldline/transformers.rs@@ -757,7 +757,7 @@ pub struct WebhookBody {pub api_version: Option<String>,pub id: String,pub created: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,#[serde(rename = "type")]pub event_type: WebhookEvent,pub payment: Option<serde_json::Value>,diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rsindex c44ae7afdd..33c9393ced 100644--- a/crates/router/src/connector/worldpay.rs+++ b/crates/router/src/connector/worldpay.rs@@ -730,7 +730,7 @@ impl api::IncomingWebhook for Worldpay {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let secret_str = std::str::from_utf8(&connector_webhook_secrets.secret)diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rsindex 892b664472..cab949789b 100644--- a/crates/router/src/connector/worldpay/transformers.rs+++ b/crates/router/src/connector/worldpay/transformers.rs@@ -145,7 +145,11 @@ implcurrency: item.router_data.request.currency.to_string(),},narrative: InstructionNarrative {- line1: item.router_data.merchant_id.clone().replace('_', "-"),+ line1: item+ .router_data+ .merchant_id+ .get_string_repr()+ .replace('_', "-"),..Default::default()},payment_instrument: fetch_payment_instrument(diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rsindex e76216f4dc..9490ff138d 100644--- a/crates/router/src/connector/zen.rs+++ b/crates/router/src/connector/zen.rs@@ -588,7 +588,7 @@ impl api::IncomingWebhook for Zen {fn get_webhook_source_verification_message(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {let webhook_body: zen::ZenWebhookBody = request@@ -608,7 +608,7 @@ impl api::IncomingWebhook for Zen {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,connector_label: &str,diff --git a/crates/router/src/connector/zsl.rs b/crates/router/src/connector/zsl.rsindex f71a5e86b5..d2341a510e 100644--- a/crates/router/src/connector/zsl.rs+++ b/crates/router/src/connector/zsl.rs@@ -418,7 +418,7 @@ impl api::IncomingWebhook for Zsl {async fn verify_webhook_source(&self,request: &api::IncomingWebhookRequestDetails<'_>,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,connector_account_details: common_utils::crypto::Encryptable<Secret<serde_json::Value>>,_connector_label: &str,diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex 4a816a95ab..33d24eecce 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -61,10 +61,10 @@ pub fn create_merchant_publishable_key() -> String {pub async fn insert_merchant_configs(db: &dyn StorageInterface,- merchant_id: &String,+ merchant_id: &id_type::MerchantId,) -> RouterResult<()> {db.insert_config(configs::ConfigNew {- key: format!("{}_requires_cvv", merchant_id),+ key: merchant_id.get_requires_cvv_key(),config: "true".to_string(),}).await@@ -72,7 +72,7 @@ pub async fn insert_merchant_configs(.attach_printable("Error while setting requires_cvv config")?;db.insert_config(configs::ConfigNew {- key: utils::get_merchant_fingerprint_secret_key(merchant_id),+ key: merchant_id.get_merchant_fingerprint_secret_key(),config: utils::generate_id(consts::FINGERPRINT_SECRET_LENGTH, "fs"),}).await@@ -89,7 +89,7 @@ fn add_publishable_key_to_decision_service() {let state = state.clone();let publishable_key = merchant_account.publishable_key.clone();- let merchant_id = merchant_account.merchant_id.clone();+ let merchant_id = merchant_account.get_id().clone();authentication::decision::spawn_tracked_job(async move {@@ -192,7 +192,7 @@ pub async fn create_merchant_account(let master_key = db.get_master_key();let key_manager_state = &(&state).into();- let merchant_id = req.get_merchant_reference_id().get_string_repr().to_owned();+ let merchant_id = req.get_merchant_reference_id();let identifier = km_types::Identifier::Merchant(merchant_id.clone());#[cfg(feature = "keymanager_create")]{@@ -319,7 +319,7 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {let parent_merchant_id = get_parent_merchant(state,self.sub_merchants_enabled,- self.parent_merchant_id,+ self.parent_merchant_id.as_ref(),&key_store,).await?;@@ -331,11 +331,10 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {let key = key_store.key.clone().into_inner();let key_manager_state = state.into();- let mut merchant_account = async {+ let merchant_account = async {Ok::<_, error_stack::Report<common_utils::errors::CryptoError>>(- domain::MerchantAccount {- id: None,- merchant_id: self.merchant_id.get_string_repr().to_owned(),+ domain::MerchantAccountSetter {+ merchant_id: self.merchant_id,merchant_name: self.merchant_name.async_lift(|inner| {@@ -395,11 +394,13 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {.await.change_context(errors::ApiErrorResponse::InternalServerError)?;+ let mut domain_merchant_account = domain::MerchantAccount::from(merchant_account);+CreateBusinessProfile::new(self.primary_business_details.clone())- .create_business_profiles(state, &mut merchant_account, &key_store)+ .create_business_profiles(state, &mut domain_merchant_account, &key_store).await?;- Ok(merchant_account)+ Ok(domain_merchant_account)}}@@ -757,7 +758,7 @@ pub async fn create_business_profile_from_business_labels(state: &SessionState,db: &dyn StorageInterface,key_store: &domain::MerchantKeyStore,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,new_business_details: Vec<admin_types::PrimaryBusinessDetails>,) -> RouterResult<()> {let key_manager_state = &state.into();@@ -825,7 +826,7 @@ pub async fn create_business_profile_from_business_labels(pub async fn update_business_profile_cascade(state: SessionState,merchant_account_update: api::MerchantAccountUpdate,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> RouterResult<()> {if merchant_account_update.return_url.is_some()|| merchant_account_update.webhook_details.is_some()@@ -842,7 +843,7 @@ pub async fn update_business_profile_cascade(.list_business_profile_by_merchant_id(&merchant_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: merchant_id.to_string(),+ id: merchant_id.get_string_repr().to_owned(),})?;let business_profile_update = admin_types::BusinessProfileUpdate {@@ -892,7 +893,7 @@ pub async fn update_business_profile_cascade(pub async fn merchant_account_update(state: SessionState,- merchant_id: &String,+ merchant_id: &id_type::MerchantId,req: api::MerchantAccountUpdate,) -> RouterResponse<api::MerchantAccountResponse> {let db = state.store.as_ref();@@ -985,7 +986,7 @@ pub async fn merchant_account_update(};// Update the business profile, This is for backwards compatibility- update_business_profile_cascade(state.clone(), req.clone(), merchant_id.to_string()).await?;+ update_business_profile_cascade(state.clone(), req.clone(), merchant_id.to_owned()).await?;let identifier = km_types::Identifier::Merchant(key_store.merchant_id.clone());let updated_merchant_account = storage::MerchantAccountUpdate::Update {@@ -1029,7 +1030,7 @@ pub async fn merchant_account_update(parent_merchant_id: get_parent_merchant(&state,req.sub_merchants_enabled,- req.parent_merchant_id,+ req.parent_merchant_id.as_ref(),&key_store,).await?,@@ -1072,7 +1073,7 @@ pub async fn merchant_account_update(pub async fn merchant_account_delete(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> RouterResponse<api::MerchantAccountDeleteResponse> {let mut is_deleted = false;let db = state.store.as_ref();@@ -1116,7 +1117,7 @@ pub async fn merchant_account_delete();match db- .delete_config_by_key(format!("{}_requires_cvv", merchant_id).as_str())+ .delete_config_by_key(merchant_id.get_requires_cvv_key().as_str()).await{Ok(_) => Ok::<_, errors::ApiErrorResponse>(()),@@ -1143,9 +1144,9 @@ pub async fn merchant_account_delete(async fn get_parent_merchant(state: &SessionState,sub_merchants_enabled: Option<bool>,- parent_merchant: Option<String>,+ parent_merchant: Option<&id_type::MerchantId>,key_store: &domain::MerchantKeyStore,-) -> RouterResult<Option<String>> {+) -> RouterResult<Option<id_type::MerchantId>> {Ok(match sub_merchants_enabled {Some(true) => {Some(@@ -1161,20 +1162,20 @@ async fn get_parent_merchant(errors::ApiErrorResponse::InvalidDataValue { field_name: "parent_merchant_id" }))?.await?- .merchant_id+ .get_id().to_owned())}_ => None,})}-async fn validate_merchant_id<S: Into<String>>(+async fn validate_merchant_id(state: &SessionState,- merchant_id: S,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,) -> RouterResult<domain::MerchantAccount> {let db = &*state.store;- db.find_merchant_account_by_merchant_id(&state.into(), &merchant_id.into(), key_store)+ db.find_merchant_account_by_merchant_id(&state.into(), merchant_id, key_store).await.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)}@@ -1217,7 +1218,7 @@ fn validate_certificate_in_mca_metadata(pub async fn create_payment_connector(state: SessionState,req: api::MerchantConnectorCreate,- merchant_id: &String,+ merchant_id: &id_type::MerchantId,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {let store = state.store.as_ref();let key_manager_state = &(&state).into();@@ -1350,7 +1351,7 @@ pub async fn create_payment_connector(Some(process_open_banking_connectors(&state,- merchant_id.as_str(),+ merchant_id,&auth,&req.connector_type,&req.connector_name,@@ -1400,7 +1401,7 @@ pub async fn create_payment_connector(validate_pm_auth(val,&state,- merchant_id.clone().as_str(),+ merchant_id,&key_store,merchant_account,&Some(profile_id.clone()),@@ -1415,7 +1416,7 @@ pub async fn create_payment_connector(let conn_auth = Secret::new(connector_auth);let identifier = km_types::Identifier::Merchant(key_store.merchant_id.clone());let merchant_connector_account = domain::MerchantConnectorAccount {- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),connector_type: req.connector_type,connector_name: req.connector_name.to_string(),merchant_connector_id: utils::generate_id(consts::ID_LENGTH, "mca"),@@ -1444,7 +1445,7 @@ pub async fn create_payment_connector(connector_webhook_details.encode_to_value().change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable(format!("Failed to serialize api_models::admin::MerchantConnectorWebhookDetails for Merchant: {}", merchant_id))+ .attach_printable(format!("Failed to serialize api_models::admin::MerchantConnectorWebhookDetails for Merchant: {:?}", merchant_id)).map(Some)?.map(Secret::new)}@@ -1475,9 +1476,12 @@ pub async fn create_payment_connector(_ => api_enums::TransactionType::Payment,};- let mut default_routing_config =- routing_helpers::get_merchant_default_config(&*state.store, merchant_id, &transaction_type)- .await?;+ let mut default_routing_config = routing_helpers::get_merchant_default_config(+ &*state.store,+ merchant_id.get_string_repr(),+ &transaction_type,+ )+ .await?;let mut default_routing_config_for_profile = routing_helpers::get_merchant_default_config(&*state.clone().store,@@ -1512,7 +1516,7 @@ pub async fn create_payment_connector(default_routing_config.push(choice.clone());routing_helpers::update_merchant_default_config(&*state.store,- merchant_id,+ merchant_id.get_string_repr(),default_routing_config.clone(),&transaction_type,)@@ -1535,7 +1539,7 @@ pub async fn create_payment_connector(1,&add_attributes([("connector", req.connector_name.to_string()),- ("merchant", merchant_id.to_string()),+ ("merchant", merchant_id.get_string_repr().to_owned()),]),);@@ -1546,7 +1550,7 @@ pub async fn create_payment_connector(async fn validate_pm_auth(val: serde_json::Value,state: &SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,merchant_account: domain::MerchantAccount,profile_id: &Option<String>,@@ -1567,7 +1571,7 @@ async fn validate_pm_auth().await.change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {- id: merchant_account.merchant_id.clone(),+ id: merchant_account.get_id().get_string_repr().to_owned(),})?;for conn_choice in config.enabled_payment_methods {@@ -1592,7 +1596,7 @@ async fn validate_pm_auth(pub async fn retrieve_payment_connector(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,merchant_connector_id: String,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {let store = state.store.as_ref();@@ -1628,7 +1632,7 @@ pub async fn retrieve_payment_connector(pub async fn list_payment_connectors(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> RouterResponse<Vec<api_models::admin::MerchantConnectorResponse>> {let store = state.store.as_ref();let key_manager_state = &(&state).into();@@ -1668,7 +1672,7 @@ pub async fn list_payment_connectors(pub async fn update_payment_connector(state: SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_connector_id: &str,req: api_models::admin::MerchantConnectorUpdate,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {@@ -1745,7 +1749,6 @@ pub async fn update_payment_connector(}}let payment_connector = storage::MerchantConnectorAccountUpdate::Update {- merchant_id: None,connector_type: Some(req.connector_type),connector_name: None,merchant_connector_id: None,@@ -1819,7 +1822,7 @@ pub async fn update_payment_connector(pub async fn delete_payment_connector(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,merchant_connector_id: String,) -> RouterResponse<api::MerchantConnectorDeleteResponse> {let db = state.store.as_ref();@@ -1870,7 +1873,7 @@ pub async fn delete_payment_connector(pub async fn kv_for_merchant(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,enable: bool,) -> RouterResponse<api_models::admin::ToggleKVResponse> {let db = state.store.as_ref();@@ -1936,7 +1939,7 @@ pub async fn kv_for_merchant(Ok(service_api::ApplicationResponse::Json(api_models::admin::ToggleKVResponse {- merchant_id: updated_merchant_account.merchant_id,+ merchant_id: updated_merchant_account.get_id().to_owned(),kv_enabled: kv_status,},))@@ -1974,7 +1977,7 @@ pub async fn toggle_kv_for_all_merchants(pub async fn check_merchant_account_kv_status(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> RouterResponse<api_models::admin::ToggleKVResponse> {let db = state.store.as_ref();let key_manager_state = &(&state).into();@@ -2000,7 +2003,7 @@ pub async fn check_merchant_account_kv_status(Ok(service_api::ApplicationResponse::Json(api_models::admin::ToggleKVResponse {- merchant_id: merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),kv_enabled: kv_status,},))@@ -2054,7 +2057,7 @@ pub async fn create_and_insert_business_profile(pub async fn create_business_profile(state: SessionState,request: api::BusinessProfileCreate,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> RouterResponse<api_models::admin::BusinessProfileResponse> {if let Some(session_expiry) = &request.session_expiry {helpers::validate_session_expiry(session_expiry.to_owned())?;@@ -2118,7 +2121,7 @@ pub async fn create_business_profile(pub async fn list_business_profile(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> RouterResponse<Vec<api_models::admin::BusinessProfileResponse>> {let db = state.store.as_ref();let key_store = db@@ -2149,7 +2152,7 @@ pub async fn list_business_profile(pub async fn retrieve_business_profile(state: SessionState,profile_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> RouterResponse<api_models::admin::BusinessProfileResponse> {let db = state.store.as_ref();let key_store = db@@ -2178,7 +2181,7 @@ pub async fn retrieve_business_profile(pub async fn delete_business_profile(state: SessionState,profile_id: String,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> RouterResponse<bool> {let db = state.store.as_ref();let delete_result = db@@ -2194,7 +2197,7 @@ pub async fn delete_business_profile(pub async fn update_business_profile(state: SessionState,profile_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,request: api::BusinessProfileUpdate,) -> RouterResponse<api::BusinessProfileResponse> {let db = state.store.as_ref();@@ -2214,7 +2217,7 @@ pub async fn update_business_profile(.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound).attach_printable("Error while fetching the key store by merchant_id")?;- if business_profile.merchant_id != merchant_id {+ if business_profile.merchant_id != *merchant_id {Err(errors::ApiErrorResponse::AccessForbidden {resource: profile_id.to_string(),})?@@ -2386,7 +2389,7 @@ pub async fn extended_card_info_toggle(pub async fn connector_agnostic_mit_toggle(state: SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,profile_id: &str,connector_agnostic_mit_choice: admin_types::ConnectorAgnosticMitChoice,) -> RouterResponse<admin_types::ConnectorAgnosticMitChoice> {@@ -2399,7 +2402,7 @@ pub async fn connector_agnostic_mit_toggle(id: profile_id.to_string(),})?;- if business_profile.merchant_id != merchant_id {+ if business_profile.merchant_id != *merchant_id {Err(errors::ApiErrorResponse::AccessForbidden {resource: profile_id.to_string(),})?@@ -2902,7 +2905,7 @@ pub fn validate_status_and_disabled(async fn process_open_banking_connectors(state: &SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,auth: &types::ConnectorAuthType,connector_type: &api_enums::ConnectorType,connector: &api_enums::Connector,@@ -3066,7 +3069,7 @@ fn validate_bank_account_data(data: &types::MerchantAccountData) -> RouterResultasync fn connector_recipient_create_call(state: &SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_name: String,auth: &types::ConnectorAuthType,data: &types::MerchantAccountData,@@ -3151,19 +3154,21 @@ async fn connector_recipient_create_call(async fn locker_recipient_create_call(state: &SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,data: &types::MerchantAccountData,) -> RouterResult<String> {let enc_data = serde_json::to_string(data).change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to convert to MerchantAccountData json to String")?;- let cust_id = id_type::CustomerId::from(merchant_id.to_string().into())+ let merchant_id_string = merchant_id.get_string_repr().to_owned();++ let cust_id = id_type::CustomerId::from(merchant_id_string.into()).change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to convert to CustomerId")?;let payload = transformers::StoreLockerReq::LockerGeneric(transformers::StoreGenericReq {- merchant_id,+ merchant_id: merchant_id.to_owned(),merchant_customer_id: cust_id.clone(),enc_data,ttl: state.conf.locker.ttl_for_storage_in_secs,diff --git a/crates/router/src/core/api_keys.rs b/crates/router/src/core/api_keys.rsindex 6af82a6b7a..f06050c530 100644--- a/crates/router/src/core/api_keys.rs+++ b/crates/router/src/core/api_keys.rs@@ -112,7 +112,7 @@ impl PlaintextApiKey {pub async fn create_api_key(state: SessionState,api_key: api::CreateApiKeyRequest,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> RouterResponse<api::CreateApiKeyResponse> {let api_key_config = state.conf.api_keys.get_inner();let store = state.store.as_ref();@@ -123,7 +123,7 @@ pub async fn create_api_key(store.get_merchant_key_store_by_merchant_id(&(&state).into(),- merchant_id.as_str(),+ &merchant_id,&store.get_master_key().to_vec().into(),).await@@ -172,7 +172,7 @@ pub async fn create_api_key(metrics::API_KEY_CREATED.add(&metrics::CONTEXT,1,- &add_attributes([("merchant", merchant_id)]),+ &add_attributes([("merchant", merchant_id.get_string_repr().to_owned())]),);// Add process to process_tracker for email reminder, only if expiry is set to future date@@ -266,7 +266,7 @@ pub async fn add_api_key_expiry_task(#[instrument(skip_all)]pub async fn retrieve_api_key(state: SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> RouterResponse<api::RetrieveApiKeyResponse> {let store = state.store.as_ref();@@ -438,7 +438,7 @@ pub async fn update_api_key_expiry_task(#[instrument(skip_all)]pub async fn revoke_api_key(state: SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> RouterResponse<api::RevokeApiKeyResponse> {let store = state.store.as_ref();@@ -525,7 +525,7 @@ pub async fn revoke_api_key_expiry_task(#[instrument(skip_all)]pub async fn list_api_keys(state: SessionState,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,limit: Option<i64>,offset: Option<i64>,) -> RouterResponse<Vec<api::RetrieveApiKeyResponse>> {diff --git a/crates/router/src/core/api_locking.rs b/crates/router/src/core/api_locking.rsindex 8723c5fc14..9b45fecee4 100644--- a/crates/router/src/core/api_locking.rs+++ b/crates/router/src/core/api_locking.rs@@ -38,17 +38,24 @@ pub struct LockingInput {}impl LockingInput {- fn get_redis_locking_key(&self, merchant_id: String) -> String {+ fn get_redis_locking_key(&self, merchant_id: common_utils::id_type::MerchantId) -> String {format!("{}_{}_{}_{}",- API_LOCK_PREFIX, merchant_id, self.api_identifier, self.unique_locking_key+ API_LOCK_PREFIX,+ merchant_id.get_string_repr(),+ self.api_identifier,+ self.unique_locking_key)}}impl LockAction {#[instrument(skip_all)]- pub async fn perform_locking_action<A>(self, state: &A, merchant_id: String) -> RouterResult<()>+ pub async fn perform_locking_action<A>(+ self,+ state: &A,+ merchant_id: common_utils::id_type::MerchantId,+ ) -> RouterResult<()>whereA: SessionStateInfo,{@@ -109,7 +116,11 @@ impl LockAction {}#[instrument(skip_all)]- pub async fn free_lock_action<A>(self, state: &A, merchant_id: String) -> RouterResult<()>+ pub async fn free_lock_action<A>(+ self,+ state: &A,+ merchant_id: common_utils::id_type::MerchantId,+ ) -> RouterResult<()>whereA: SessionStateInfo,{diff --git a/crates/router/src/core/apple_pay_certificates_migration.rs b/crates/router/src/core/apple_pay_certificates_migration.rsindex 87c1593571..8fe61f75ca 100644--- a/crates/router/src/core/apple_pay_certificates_migration.rs+++ b/crates/router/src/core/apple_pay_certificates_migration.rs@@ -93,13 +93,15 @@ pub async fn apple_pay_certificates_migration(match merchant_connector_accounts_update {Ok(_) => {- logger::debug!("Merchant connector accounts updated for merchant id {merchant_id}");- migration_successful_merchant_ids.push(merchant_id.to_string());+ logger::debug!(+ "Merchant connector accounts updated for merchant id {merchant_id:?}"+ );+ migration_successful_merchant_ids.push(merchant_id.clone());}Err(error) => {logger::debug!(- "Merchant connector accounts update failed with error {error} for merchant id {merchant_id}");- migration_failed_merchant_ids.push(merchant_id.to_string());+ "Merchant connector accounts update failed with error {error} for merchant id {merchant_id:?}");+ migration_failed_merchant_ids.push(merchant_id.clone());}};}diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rsindex ec799365f7..7cc03ab9ea 100644--- a/crates/router/src/core/authentication.rs+++ b/crates/router/src/core/authentication.rs@@ -20,7 +20,7 @@ use crate::{#[allow(clippy::too_many_arguments)]pub async fn perform_authentication(state: &SessionState,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,authentication_connector: String,payment_method_data: payments::PaymentMethodData,payment_method: common_enums::PaymentMethod,@@ -94,7 +94,7 @@ pub async fn perform_post_authentication(let authentication = state.store.find_authentication_by_merchant_id_authentication_id(- business_profile.merchant_id.clone(),+ &business_profile.merchant_id,authentication_id.clone(),).awaitdiff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rsindex 1be40a0ab6..569f2beea5 100644--- a/crates/router/src/core/authentication/transformers.rs+++ b/crates/router/src/core/authentication/transformers.rs@@ -26,7 +26,7 @@ const IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_AUTHENTICATION_FLOW: &str =#[allow(clippy::too_many_arguments)]pub fn construct_authentication_router_data(- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,authentication_connector: String,payment_method_data: payments::PaymentMethodData,payment_method: PaymentMethod,@@ -103,7 +103,7 @@ pub fn construct_pre_authentication_router_data<F: Clone>(authentication_connector: String,card_holder_account_number: cards::CardNumber,merchant_connector_account: &payments_helpers::MerchantConnectorAccountType,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> RouterResult<types::RouterData<F,@@ -127,7 +127,7 @@ pub fn construct_pre_authentication_router_data<F: Clone>(pub fn construct_router_data<F: Clone, Req, Res>(authentication_connector_name: String,payment_method: PaymentMethod,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,address: types::PaymentAddress,request_data: Req,merchant_connector_account: &payments_helpers::MerchantConnectorAccountType,diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rsindex b7638e7a41..0ed5599983 100644--- a/crates/router/src/core/authentication/utils.rs+++ b/crates/router/src/core/authentication/utils.rs@@ -176,7 +176,7 @@ impl ForeignFrom<common_enums::AuthenticationStatus> for common_enums::AttemptStpub async fn create_new_authentication(state: &SessionState,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,authentication_connector: String,token: String,profile_id: String,diff --git a/crates/router/src/core/blocklist.rs b/crates/router/src/core/blocklist.rsindex 947acc506d..16833773a5 100644--- a/crates/router/src/core/blocklist.rs+++ b/crates/router/src/core/blocklist.rs@@ -15,7 +15,7 @@ pub async fn add_entry_to_blocklist(merchant_account: domain::MerchantAccount,body: api_blocklist::AddToBlocklistRequest,) -> RouterResponse<api_blocklist::AddToBlocklistResponse> {- utils::insert_entry_into_blocklist(&state, merchant_account.merchant_id, body)+ utils::insert_entry_into_blocklist(&state, merchant_account.get_id(), body).await.map(services::ApplicationResponse::Json)}@@ -25,7 +25,7 @@ pub async fn remove_entry_from_blocklist(merchant_account: domain::MerchantAccount,body: api_blocklist::DeleteFromBlocklistRequest,) -> RouterResponse<api_blocklist::DeleteFromBlocklistResponse> {- utils::delete_entry_from_blocklist(&state, merchant_account.merchant_id, body)+ utils::delete_entry_from_blocklist(&state, merchant_account.get_id(), body).await.map(services::ApplicationResponse::Json)}@@ -35,7 +35,7 @@ pub async fn list_blocklist_entries(merchant_account: domain::MerchantAccount,query: api_blocklist::ListBlocklistQuery,) -> RouterResponse<Vec<api_blocklist::BlocklistResponse>> {- utils::list_blocklist_entries_for_merchant(&state, merchant_account.merchant_id, query)+ utils::list_blocklist_entries_for_merchant(&state, merchant_account.get_id(), query).await.map(services::ApplicationResponse::Json)}@@ -45,7 +45,7 @@ pub async fn toggle_blocklist_guard(merchant_account: domain::MerchantAccount,query: api_blocklist::ToggleBlocklistQuery,) -> RouterResponse<api_blocklist::ToggleBlocklistResponse> {- utils::toggle_blocklist_guard_for_merchant(&state, merchant_account.merchant_id, query)+ utils::toggle_blocklist_guard_for_merchant(&state, merchant_account.get_id(), query).await.map(services::ApplicationResponse::Json)}diff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rsindex c739a86ee5..8edd75d3df 100644--- a/crates/router/src/core/blocklist/utils.rs+++ b/crates/router/src/core/blocklist/utils.rs@@ -19,21 +19,21 @@ use crate::{pub async fn delete_entry_from_blocklist(state: &SessionState,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,request: api_blocklist::DeleteFromBlocklistRequest,) -> RouterResult<api_blocklist::DeleteFromBlocklistResponse> {let blocklist_entry = match request {api_blocklist::DeleteFromBlocklistRequest::CardBin(bin) => {- delete_card_bin_blocklist_entry(state, &bin, &merchant_id).await?+ delete_card_bin_blocklist_entry(state, &bin, merchant_id).await?}api_blocklist::DeleteFromBlocklistRequest::ExtendedCardBin(xbin) => {- delete_card_bin_blocklist_entry(state, &xbin, &merchant_id).await?+ delete_card_bin_blocklist_entry(state, &xbin, merchant_id).await?}api_blocklist::DeleteFromBlocklistRequest::Fingerprint(fingerprint_id) => state.store- .delete_blocklist_entry_by_merchant_id_fingerprint_id(&merchant_id, &fingerprint_id)+ .delete_blocklist_entry_by_merchant_id_fingerprint_id(merchant_id, &fingerprint_id).await.to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError {message: "no blocklist record for the given fingerprint id was found".to_string(),@@ -45,10 +45,10 @@ pub async fn delete_entry_from_blocklist(pub async fn toggle_blocklist_guard_for_merchant(state: &SessionState,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,query: api_blocklist::ToggleBlocklistQuery,) -> CustomResult<api_blocklist::ToggleBlocklistResponse, errors::ApiErrorResponse> {- let key = get_blocklist_guard_key(merchant_id.as_str());+ let key = merchant_id.get_blocklist_guard_key();let maybe_guard = state.store.find_config_by_key(&key).await;let new_config = configs::ConfigNew {key: key.clone(),@@ -87,21 +87,15 @@ pub async fn toggle_blocklist_guard_for_merchant(})}-/// Provides the identifier for the specific merchant's blocklist guard config-#[inline(always)]-pub fn get_blocklist_guard_key(merchant_id: &str) -> String {- format!("guard_blocklist_for_{merchant_id}")-}-pub async fn list_blocklist_entries_for_merchant(state: &SessionState,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,query: api_blocklist::ListBlocklistQuery,) -> RouterResult<Vec<api_blocklist::BlocklistResponse>> {state.store.list_blocklist_entries_by_merchant_id_data_kind(- &merchant_id,+ merchant_id,query.data_kind,query.limit.into(),query.offset.into(),@@ -139,7 +133,7 @@ fn validate_extended_card_bin(bin: &str) -> RouterResult<()> {pub async fn insert_entry_into_blocklist(state: &SessionState,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,to_block: api_blocklist::AddToBlocklistRequest,) -> RouterResult<api_blocklist::AddToBlocklistResponse> {let blocklist_entry = match &to_block {@@ -148,7 +142,7 @@ pub async fn insert_entry_into_blocklist(duplicate_check_insert_bin(bin,state,- &merchant_id,+ merchant_id,common_enums::BlocklistDataKind::CardBin,).await?@@ -159,7 +153,7 @@ pub async fn insert_entry_into_blocklist(duplicate_check_insert_bin(bin,state,- &merchant_id,+ merchant_id,common_enums::BlocklistDataKind::ExtendedCardBin,).await?@@ -168,7 +162,7 @@ pub async fn insert_entry_into_blocklist(api_blocklist::AddToBlocklistRequest::Fingerprint(fingerprint_id) => {let blocklist_entry_result = state.store- .find_blocklist_entry_by_merchant_id_fingerprint_id(&merchant_id, fingerprint_id)+ .find_blocklist_entry_by_merchant_id_fingerprint_id(merchant_id, fingerprint_id).await;match blocklist_entry_result {@@ -192,7 +186,7 @@ pub async fn insert_entry_into_blocklist(state.store.insert_blocklist_entry(storage::BlocklistNew {- merchant_id: merchant_id.clone(),+ merchant_id: merchant_id.to_owned(),fingerprint_id: fingerprint_id.clone(),data_kind: api_models::enums::enums::BlocklistDataKind::PaymentMethod,metadata: None,@@ -208,9 +202,9 @@ pub async fn insert_entry_into_blocklist(pub async fn get_merchant_fingerprint_secret(state: &SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> RouterResult<String> {- let key = utils::get_merchant_fingerprint_secret_key(merchant_id);+ let key = merchant_id.get_merchant_fingerprint_secret_key();let config_fetch_result = state.store.find_config_by_key(&key).await;match config_fetch_result {@@ -243,7 +237,7 @@ pub async fn get_merchant_fingerprint_secret(async fn duplicate_check_insert_bin(bin: &str,state: &SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,data_kind: common_enums::BlocklistDataKind,) -> RouterResult<storage::Blocklist> {let blocklist_entry_result = state@@ -271,7 +265,7 @@ async fn duplicate_check_insert_bin(state.store.insert_blocklist_entry(storage::BlocklistNew {- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),fingerprint_id: bin.to_string(),data_kind,metadata: None,@@ -285,7 +279,7 @@ async fn duplicate_check_insert_bin(async fn delete_card_bin_blocklist_entry(state: &SessionState,bin: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> RouterResult<storage::Blocklist> {state.store@@ -306,9 +300,8 @@ whereF: Send + Clone,{let db = &state.store;- let merchant_id = &merchant_account.merchant_id;- let merchant_fingerprint_secret =- get_merchant_fingerprint_secret(state, merchant_id.as_str()).await?;+ let merchant_id = merchant_account.get_id();+ let merchant_fingerprint_secret = get_merchant_fingerprint_secret(state, merchant_id).await?;// Hashed Fingerprint to check whether or not this payment should be blocked.let card_number_fingerprint = if let Some(api_models::payments::PaymentMethodData::Card(card)) =@@ -452,7 +445,7 @@ wherepub async fn generate_payment_fingerprint(state: &SessionState,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,payment_method_data: Option<crate::types::api::PaymentMethodData>,) -> CustomResult<Option<String>, errors::ApiErrorResponse> {let merchant_fingerprint_secret = get_merchant_fingerprint_secret(state, &merchant_id).await?;diff --git a/crates/router/src/core/conditional_config.rs b/crates/router/src/core/conditional_config.rsindex c34f8e7116..e845d54ee7 100644--- a/crates/router/src/core/conditional_config.rs+++ b/crates/router/src/core/conditional_config.rs@@ -8,9 +8,7 @@ use error_stack::ResultExt;use euclid::frontend::ast;use storage_impl::redis::cache;-use super::routing::helpers::{- get_payment_config_routing_id, update_merchant_active_algorithm_ref,-};+use super::routing::helpers::update_merchant_active_algorithm_ref;use crate::{core::errors::{self, RouterResponse},routes::SessionState,@@ -62,7 +60,7 @@ pub async fn upsert_conditional_config(.attach_printable("Could not decode the routing algorithm")?.unwrap_or_default();- let key = get_payment_config_routing_id(merchant_account.merchant_id.as_str());+ let key = merchant_account.get_id().get_payment_config_routing_id();let read_config_key = db.find_config_by_key(&key).await;ast::lowering::lower_program(prog.clone())@@ -157,7 +155,7 @@ pub async fn delete_conditional_config(merchant_account: domain::MerchantAccount,) -> RouterResponse<()> {let db = state.store.as_ref();- let key = get_payment_config_routing_id(&merchant_account.merchant_id);+ let key = merchant_account.get_id().get_payment_config_routing_id();let mut algo_id: routing::RoutingAlgorithmRef = merchant_account.routing_algorithm.clone()@@ -185,7 +183,7 @@ pub async fn retrieve_conditional_config(merchant_account: domain::MerchantAccount,) -> RouterResponse<DecisionManagerResponse> {let db = state.store.as_ref();- let algorithm_id = get_payment_config_routing_id(merchant_account.merchant_id.as_str());+ let algorithm_id = merchant_account.get_id().get_payment_config_routing_id();let algo_config = db.find_config_by_key(&algorithm_id).awaitdiff --git a/crates/router/src/core/connector_onboarding.rs b/crates/router/src/core/connector_onboarding.rsindex d6c20cc281..c3de228d9a 100644--- a/crates/router/src/core/connector_onboarding.rs+++ b/crates/router/src/core/connector_onboarding.rs@@ -82,7 +82,9 @@ pub async fn sync_onboarding_status(let auth_details = oss_types::ConnectorAuthType::SignatureKey {api_key: connector_onboarding_conf.paypal.client_secret.clone(),key1: connector_onboarding_conf.paypal.client_id.clone(),- api_secret: Secret::new(paypal_onboarding_data.payer_id.clone()),+ api_secret: Secret::new(+ paypal_onboarding_data.payer_id.get_string_repr().to_owned(),+ ),};let update_mca_data = paypal::update_mca(&state,diff --git a/crates/router/src/core/connector_onboarding/paypal.rs b/crates/router/src/core/connector_onboarding/paypal.rsindex 6f28cfcbf8..5dda818b0f 100644--- a/crates/router/src/core/connector_onboarding/paypal.rs+++ b/crates/router/src/core/connector_onboarding/paypal.rs@@ -140,7 +140,7 @@ async fn find_paypal_merchant_by_tracking_id(pub async fn update_mca(state: &SessionState,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,connector_id: String,auth_details: oss_types::ConnectorAuthType,) -> RouterResult<oss_api_types::MerchantConnectorResponse> {diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rsindex d34e2f081e..16f79e375b 100644--- a/crates/router/src/core/customers.rs+++ b/crates/router/src/core/customers.rs@@ -48,7 +48,7 @@ pub async fn create_customer(let merchant_reference_id = customer_data.get_merchant_reference_id();- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let merchant_reference_id_customer = MerchantReferenceIdForCustomer {customer_id: merchant_reference_id.as_ref(),@@ -124,7 +124,7 @@ impl CustomerCreateBridge for customers::CustomerRequest {) -> errors::CustomResult<domain::Customer, errors::CustomersErrorResponse> {// Setting default billing address to Dblet address = self.get_address();- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let key = key_store.key.get_inner().peek();let customer_billing_address_struct = AddressStructForDbEntry {@@ -163,7 +163,7 @@ impl CustomerCreateBridge for customers::CustomerRequest {customer_id: merchant_reference_id.to_owned().ok_or(errors::CustomersErrorResponse::InternalServerError)?,- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),name: encryptable_customer.name,email: encryptable_customer.email,phone: encryptable_customer.phone,@@ -266,7 +266,7 @@ impl CustomerCreateBridge for customers::CustomerRequest {struct AddressStructForDbEntry<'a> {address: Option<&'a api_models::payments::AddressDetails>,customer_data: &'a customers::CustomerRequest,- merchant_id: &'a str,+ merchant_id: &'a id_type::MerchantId,customer_id: Option<&'a id_type::CustomerId>,storage_scheme: common_enums::MerchantStorageScheme,key_store: &'a domain::MerchantKeyStore,@@ -314,7 +314,7 @@ impl<'a> AddressStructForDbEntry<'a> {struct MerchantReferenceIdForCustomer<'a> {customer_id: Option<&'a id_type::CustomerId>,- merchant_id: &'a str,+ merchant_id: &'a id_type::MerchantId,merchant_account: &'a domain::MerchantAccount,key_store: &'a domain::MerchantKeyStore,key_manager_state: &'a KeyManagerState,@@ -377,7 +377,7 @@ pub async fn retrieve_customer(.find_customer_by_customer_id_merchant_id(key_manager_state,&req.customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -400,7 +400,7 @@ pub async fn retrieve_customer(#[instrument(skip(state))]pub async fn list_customers(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,key_store: domain::MerchantKeyStore,) -> errors::CustomerResponse<Vec<customers::CustomerResponse>> {let db = state.store.as_ref();@@ -432,7 +432,7 @@ pub async fn delete_customer(.find_customer_by_customer_id_merchant_id(key_manager_state,&req.customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -440,7 +440,7 @@ pub async fn delete_customer(.switch()?;let customer_mandates = db- .find_mandate_by_merchant_id_customer_id(&merchant_account.merchant_id, &req.customer_id)+ .find_mandate_by_merchant_id_customer_id(merchant_account.get_id(), &req.customer_id).await.switch()?;@@ -453,7 +453,7 @@ pub async fn delete_customer(match db.find_payment_method_by_customer_id_merchant_id_list(&req.customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),None,).await@@ -465,14 +465,14 @@ pub async fn delete_customer(cards::delete_card_from_locker(&state,&req.customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),pm.locker_id.as_ref().unwrap_or(&pm.payment_method_id),).await.switch()?;}db.delete_payment_method_by_merchant_id_payment_method_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&pm.payment_method_id,).await@@ -529,7 +529,7 @@ pub async fn delete_customer(.update_address_by_merchant_id_customer_id(key_manager_state,&req.customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),update_address,&key_store,)@@ -569,7 +569,7 @@ pub async fn delete_customer(db.update_customer_by_customer_id_merchant_id(key_manager_state,req.customer_id.clone(),- merchant_account.merchant_id,+ merchant_account.get_id().to_owned(),customer_orig,updated_customer,&key_store,@@ -613,7 +613,7 @@ pub async fn update_customer(.find_customer_by_customer_id_merchant_id(key_manager_state,customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -632,7 +632,7 @@ pub async fn update_customer(customer_address,key,merchant_account.storage_scheme,- merchant_account.merchant_id.clone(),+ merchant_account.get_id().clone(),).await.switch()@@ -642,8 +642,9 @@ pub async fn update_customer(.await.switch().attach_printable(format!(- "Failed while updating address: merchant_id: {}, customer_id: {:?}",- merchant_account.merchant_id, customer_id+ "Failed while updating address: merchant_id: {:?}, customer_id: {:?}",+ merchant_account.get_id(),+ customer_id))?,)}@@ -654,7 +655,7 @@ pub async fn update_customer(.get_domain_address(&state,customer_address,- &merchant_account.merchant_id,+ merchant_account.get_id(),&customer.customer_id,key,merchant_account.storage_scheme,@@ -699,7 +700,7 @@ pub async fn update_customer(.update_customer_by_customer_id_merchant_id(key_manager_state,customer_id.to_owned(),- merchant_account.merchant_id.to_owned(),+ merchant_account.get_id().to_owned(),customer,storage::CustomerUpdate::Update {name: encryptable_customer.name,diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rsindex 6a7f531f5a..0584851e60 100644--- a/crates/router/src/core/disputes.rs+++ b/crates/router/src/core/disputes.rs@@ -30,7 +30,7 @@ pub async fn retrieve_dispute() -> RouterResponse<api_models::disputes::DisputeResponse> {let dispute = state.store- .find_dispute_by_merchant_id_dispute_id(&merchant_account.merchant_id, &req.dispute_id)+ .find_dispute_by_merchant_id_dispute_id(merchant_account.get_id(), &req.dispute_id).await.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound {dispute_id: req.dispute_id,@@ -47,7 +47,7 @@ pub async fn retrieve_disputes_list() -> RouterResponse<Vec<api_models::disputes::DisputeResponse>> {let disputes = state.store- .find_disputes_by_merchant_id(&merchant_account.merchant_id, constraints)+ .find_disputes_by_merchant_id(merchant_account.get_id(), constraints).await.to_not_found_response(errors::ApiErrorResponse::InternalServerError).attach_printable("Unable to retrieve disputes")?;@@ -68,7 +68,7 @@ pub async fn accept_dispute(let db = &state.store;let dispute = state.store- .find_dispute_by_merchant_id_dispute_id(&merchant_account.merchant_id, &req.dispute_id)+ .find_dispute_by_merchant_id_dispute_id(merchant_account.get_id(), &req.dispute_id).await.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound {dispute_id: req.dispute_id,@@ -91,7 +91,7 @@ pub async fn accept_dispute(.find_payment_intent_by_payment_id_merchant_id(&(&state).into(),&dispute.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -100,7 +100,7 @@ pub async fn accept_dispute(let payment_attempt = db.find_payment_attempt_by_attempt_id_merchant_id(&dispute.attempt_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -170,7 +170,7 @@ pub async fn submit_evidence(let db = &state.store;let dispute = state.store- .find_dispute_by_merchant_id_dispute_id(&merchant_account.merchant_id, &req.dispute_id)+ .find_dispute_by_merchant_id_dispute_id(merchant_account.get_id(), &req.dispute_id).await.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound {dispute_id: req.dispute_id.clone(),@@ -205,7 +205,7 @@ pub async fn submit_evidence(.find_payment_intent_by_payment_id_merchant_id(&(&state).into(),&dispute.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -214,7 +214,7 @@ pub async fn submit_evidence(let payment_attempt = db.find_payment_attempt_by_attempt_id_merchant_id(&dispute.attempt_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -339,7 +339,7 @@ pub async fn attach_evidence(.clone().ok_or(errors::ApiErrorResponse::MissingDisputeId)?;let dispute = db- .find_dispute_by_merchant_id_dispute_id(&merchant_account.merchant_id, &dispute_id)+ .find_dispute_by_merchant_id_dispute_id(merchant_account.get_id(), &dispute_id).await.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound {dispute_id: dispute_id.clone(),@@ -410,7 +410,7 @@ pub async fn retrieve_dispute_evidence() -> RouterResponse<Vec<api_models::disputes::DisputeEvidenceBlock>> {let dispute = state.store- .find_dispute_by_merchant_id_dispute_id(&merchant_account.merchant_id, &req.dispute_id)+ .find_dispute_by_merchant_id_dispute_id(merchant_account.get_id(), &req.dispute_id).await.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound {dispute_id: req.dispute_id,@@ -434,7 +434,7 @@ pub async fn delete_evidence(let dispute_id = delete_evidence_request.dispute_id.clone();let dispute = state.store- .find_dispute_by_merchant_id_dispute_id(&merchant_account.merchant_id, &dispute_id)+ .find_dispute_by_merchant_id_dispute_id(merchant_account.get_id(), &dispute_id).await.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound {dispute_id: dispute_id.clone(),diff --git a/crates/router/src/core/disputes/transformers.rs b/crates/router/src/core/disputes/transformers.rsindex d37410d5ef..7cd8781577 100644--- a/crates/router/src/core/disputes/transformers.rs+++ b/crates/router/src/core/disputes/transformers.rs@@ -210,7 +210,7 @@ pub async fn get_dispute_evidence_block() -> CustomResult<api_models::disputes::DisputeEvidenceBlock, errors::ApiErrorResponse> {let file_metadata = state.store- .find_file_metadata_by_merchant_id_file_id(&merchant_account.merchant_id, &file_id)+ .find_file_metadata_by_merchant_id_file_id(merchant_account.get_id(), &file_id).await.change_context(errors::ApiErrorResponse::FileNotFound).attach_printable("Unable to retrieve file_metadata")?;diff --git a/crates/router/src/core/files.rs b/crates/router/src/core/files.rsindex 9ba5c29ce7..243b93a448 100644--- a/crates/router/src/core/files.rs+++ b/crates/router/src/core/files.rs@@ -24,10 +24,14 @@ pub async fn files_create_core().await?;let file_id = common_utils::generate_id(consts::ID_LENGTH, "file");- let file_key = format!("{}/{}", merchant_account.merchant_id, file_id);+ let file_key = format!(+ "{}/{}",+ merchant_account.get_id().get_string_repr(),+ file_id+ );let file_new = diesel_models::file::FileMetadataNew {file_id: file_id.clone(),- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),file_name: create_file_request.file_name.clone(),file_size: create_file_request.file_size,file_type: create_file_request.file_type.to_string(),@@ -86,7 +90,7 @@ pub async fn files_delete_core(state.store.as_ref()- .delete_file_metadata_by_merchant_id_file_id(&merchant_account.merchant_id, &req.file_id)+ .delete_file_metadata_by_merchant_id_file_id(merchant_account.get_id(), &req.file_id).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Unable to delete file_metadata")?;@@ -102,7 +106,7 @@ pub async fn files_retrieve_core(let file_metadata_object = state.store.as_ref()- .find_file_metadata_by_merchant_id_file_id(&merchant_account.merchant_id, &req.file_id)+ .find_file_metadata_by_merchant_id_file_id(merchant_account.get_id(), &req.file_id).await.change_context(errors::ApiErrorResponse::FileNotFound).attach_printable("Unable to retrieve file_metadata")?;diff --git a/crates/router/src/core/files/helpers.rs b/crates/router/src/core/files/helpers.rsindex ed95e7790e..36c71f9a4f 100644--- a/crates/router/src/core/files/helpers.rs+++ b/crates/router/src/core/files/helpers.rs@@ -43,7 +43,7 @@ pub async fn validate_file_upload(.ok_or(errors::ApiErrorResponse::MissingDisputeId)?;let dispute = state.store- .find_dispute_by_merchant_id_dispute_id(&merchant_account.merchant_id, dispute_id)+ .find_dispute_by_merchant_id_dispute_id(merchant_account.get_id(), dispute_id).await.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound {dispute_id: dispute_id.to_string(),@@ -87,7 +87,7 @@ pub async fn delete_file_using_file_id() -> CustomResult<(), errors::ApiErrorResponse> {let file_metadata_object = state.store- .find_file_metadata_by_merchant_id_file_id(&merchant_account.merchant_id, &file_key)+ .find_file_metadata_by_merchant_id_file_id(merchant_account.get_id(), &file_key).await.change_context(errors::ApiErrorResponse::FileNotFound)?;let (provider, provider_file_id) = match (@@ -181,7 +181,7 @@ pub async fn retrieve_file_and_provider_file_id_from_file_id(Some(file_key) => {let file_metadata_object = state.store- .find_file_metadata_by_merchant_id_file_id(&merchant_account.merchant_id, &file_key)+ .find_file_metadata_by_merchant_id_file_id(merchant_account.get_id(), &file_key).await.change_context(errors::ApiErrorResponse::FileNotFound)?;let (provider, provider_file_id) = match (@@ -248,7 +248,7 @@ pub async fn upload_and_get_provider_provider_file_id_profile_id(.ok_or(errors::ApiErrorResponse::MissingDisputeId)?;let dispute = state.store- .find_dispute_by_merchant_id_dispute_id(&merchant_account.merchant_id, &dispute_id)+ .find_dispute_by_merchant_id_dispute_id(merchant_account.get_id(), &dispute_id).await.to_not_found_response(errors::ApiErrorResponse::DisputeNotFound { dispute_id })?;let connector_data = api::ConnectorData::get_connector_by_name(@@ -263,7 +263,7 @@ pub async fn upload_and_get_provider_provider_file_id_profile_id(.find_payment_intent_by_payment_id_merchant_id(&state.into(),&dispute.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,merchant_account.storage_scheme,)@@ -273,7 +273,7 @@ pub async fn upload_and_get_provider_provider_file_id_profile_id(.store.find_payment_attempt_by_attempt_id_merchant_id(&dispute.attempt_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).awaitdiff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rsindex 8ddd0b7aa2..dfd8e085f6 100644--- a/crates/router/src/core/fraud_check.rs+++ b/crates/router/src/core/fraud_check.rs@@ -165,7 +165,7 @@ where).await.change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {- id: merchant_account.merchant_id.clone(),+ id: merchant_account.get_id().get_string_repr().to_owned(),}).ok();@@ -658,7 +658,7 @@ pub async fn frm_fulfillment_core(.find_payment_intent_by_payment_id_merchant_id(&(&state).into(),&req.payment_id.clone(),- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -672,7 +672,7 @@ pub async fn frm_fulfillment_core(let existing_fraud_check = db.find_fraud_check_by_payment_id_if_present(req.payment_id.clone(),- merchant_account.merchant_id.clone(),+ merchant_account.get_id().clone(),).await.change_context(invalid_request_error.to_owned())?;@@ -720,7 +720,7 @@ pub async fn make_fulfillment_api_call(let payment_attempt = db.find_payment_attempt_by_attempt_id_merchant_id(&payment_intent.active_attempt.get_id(),- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).awaitdiff --git a/crates/router/src/core/fraud_check/flows/checkout_flow.rs b/crates/router/src/core/fraud_check/flows/checkout_flow.rsindex 47ab1810f7..4aae07382f 100644--- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs+++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs@@ -54,7 +54,7 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudClet router_data = RouterData {flow: std::marker::PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),customer_id,connector: connector_id.to_string(),payment_id: self.payment_intent.payment_id.clone(),diff --git a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rsindex 05aafb92f9..a16dc2b16e 100644--- a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs+++ b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs@@ -40,7 +40,7 @@ pub async fn construct_fulfillment_router_data<'a>(let merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),None,key_store,&profile_id,@@ -60,7 +60,7 @@ pub async fn construct_fulfillment_router_data<'a>()?;let router_data = RouterData {flow: std::marker::PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),connector,payment_id: payment_attempt.payment_id.clone(),attempt_id: payment_attempt.attempt_id.clone(),@@ -95,7 +95,7 @@ pub async fn construct_fulfillment_router_data<'a>(payment_method_balance: None,connector_request_reference_id: core_utils::get_connector_request_reference_id(&state.conf,- &merchant_account.merchant_id,+ merchant_account.get_id(),payment_attempt,),#[cfg(feature = "payouts")]diff --git a/crates/router/src/core/fraud_check/flows/record_return.rs b/crates/router/src/core/fraud_check/flows/record_return.rsindex 2f26312408..3933a37676 100644--- a/crates/router/src/core/fraud_check/flows/record_return.rs+++ b/crates/router/src/core/fraud_check/flows/record_return.rs@@ -50,7 +50,7 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudChlet currency = self.payment_attempt.clone().currency;let router_data = RouterData {flow: std::marker::PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),customer_id,connector: connector_id.to_string(),payment_id: self.payment_intent.payment_id.clone(),diff --git a/crates/router/src/core/fraud_check/flows/sale_flow.rs b/crates/router/src/core/fraud_check/flows/sale_flow.rsindex fee1964a42..58764edd63 100644--- a/crates/router/src/core/fraud_check/flows/sale_flow.rs+++ b/crates/router/src/core/fraud_check/flows/sale_flow.rs@@ -47,7 +47,7 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckResplet router_data = RouterData {flow: std::marker::PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),customer_id,connector: connector_id.to_string(),payment_id: self.payment_intent.payment_id.clone(),diff --git a/crates/router/src/core/fraud_check/flows/transaction_flow.rs b/crates/router/src/core/fraud_check/flows/transaction_flow.rsindex c5d00c4a8e..1be03b846b 100644--- a/crates/router/src/core/fraud_check/flows/transaction_flow.rs+++ b/crates/router/src/core/fraud_check/flows/transaction_flow.rs@@ -57,7 +57,7 @@ impllet router_data = RouterData {flow: std::marker::PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),customer_id,connector: connector_id.to_string(),payment_id: self.payment_intent.payment_id.clone(),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.rsindex 698eb43385..ca7f110e89 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@@ -84,7 +84,7 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPost {let existing_fraud_check = db.find_fraud_check_by_payment_id_if_present(payment_data.payment_intent.payment_id.clone(),- payment_data.merchant_account.merchant_id.clone(),+ payment_data.merchant_account.get_id().clone(),).await.ok();@@ -94,7 +94,7 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPost {db.insert_fraud_check_response(FraudCheckNew {frm_id: utils::generate_id(consts::ID_LENGTH, "frm"),payment_id: payment_data.payment_intent.payment_id.clone(),- merchant_id: payment_data.merchant_account.merchant_id.clone(),+ merchant_id: payment_data.merchant_account.get_id().clone(),attempt_id: payment_data.payment_attempt.attempt_id.clone(),created_at: common_utils::date_time::now(),frm_name: frm_connector_details.connector_name,diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rsindex 6a0bd78130..05b803074d 100644--- a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs+++ b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs@@ -79,7 +79,7 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPre {let existing_fraud_check = db.find_fraud_check_by_payment_id_if_present(payment_data.payment_intent.payment_id.clone(),- payment_data.merchant_account.merchant_id.clone(),+ payment_data.merchant_account.get_id().clone(),).await.ok();@@ -90,7 +90,7 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPre {db.insert_fraud_check_response(FraudCheckNew {frm_id: Uuid::new_v4().simple().to_string(),payment_id: payment_data.payment_intent.payment_id.clone(),- merchant_id: payment_data.merchant_account.merchant_id.clone(),+ merchant_id: payment_data.merchant_account.get_id().clone(),attempt_id: payment_data.payment_attempt.attempt_id.clone(),created_at: common_utils::date_time::now(),frm_name: frm_connector_details.connector_name,diff --git a/crates/router/src/core/fraud_check/types.rs b/crates/router/src/core/fraud_check/types.rsindex bc30ad83b1..d35e3227e6 100644--- a/crates/router/src/core/fraud_check/types.rs+++ b/crates/router/src/core/fraud_check/types.rs@@ -43,7 +43,7 @@ pub struct PaymentDetails {}#[derive(Clone, Default, Debug)]pub struct FrmMerchantAccount {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,}#[derive(Clone, Debug)]diff --git a/crates/router/src/core/locker_migration.rs b/crates/router/src/core/locker_migration.rsindex 22b3b29e03..9eecbc17e4 100644--- a/crates/router/src/core/locker_migration.rs+++ b/crates/router/src/core/locker_migration.rs@@ -14,7 +14,7 @@ use crate::{pub async fn rust_locker_migration(state: SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<services::ApplicationResponse<MigrateCardResponse>, errors::ApiErrorResponse> {let db = state.store.as_ref();let key_manager_state = &(&state).into();@@ -79,7 +79,7 @@ pub async fn call_to_locker(state: &SessionState,payment_methods: Vec<PaymentMethod>,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_account: &domain::MerchantAccount,) -> CustomResult<usize, errors::ApiErrorResponse> {let mut cards_moved = 0;@@ -149,7 +149,7 @@ pub async fn call_to_locker(.await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable(format!(- "Card migration failed for merchant_id: {merchant_id}, customer_id: {customer_id:?}, payment_method_id: {} ",+ "Card migration failed for merchant_id: {merchant_id:?}, customer_id: {customer_id:?}, payment_method_id: {} ",pm.payment_method_id));@@ -164,7 +164,7 @@ pub async fn call_to_locker(cards_moved += 1;logger::info!(- "Card migrated for merchant_id: {merchant_id}, customer_id: {customer_id:?}, payment_method_id: {} ",+ "Card migrated for merchant_id: {merchant_id:?}, customer_id: {customer_id:?}, payment_method_id: {} ",pm.payment_method_id);}diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rsindex e9cddebe09..e74f7f11a7 100644--- a/crates/router/src/core/mandate.rs+++ b/crates/router/src/core/mandate.rs@@ -41,7 +41,7 @@ pub async fn get_mandate(.store.as_ref().find_mandate_by_merchant_id_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req.mandate_id,merchant_account.storage_scheme,)@@ -68,7 +68,7 @@ pub async fn revoke_mandate(let db = state.store.as_ref();let mandate = db.find_mandate_by_merchant_id_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req.mandate_id,merchant_account.storage_scheme,)@@ -88,7 +88,7 @@ pub async fn revoke_mandate(let merchant_connector_account = payment_helper::get_merchant_connector_account(&state,- &merchant_account.merchant_id,+ merchant_account.get_id(),None,&key_store,&profile_id,@@ -130,7 +130,7 @@ pub async fn revoke_mandate(Ok(_) => {let update_mandate = db.update_mandate_by_merchant_id_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req.mandate_id,storage::MandateUpdate::StatusUpdate {mandate_status: storage::enums::MandateStatus::Revoked,@@ -172,7 +172,7 @@ pub async fn revoke_mandate(#[instrument(skip(db))]pub async fn update_connector_mandate_id(db: &dyn StorageInterface,- merchant_account: String,+ merchant_id: &id_type::MerchantId,mandate_ids_opt: Option<String>,payment_method_id: Option<String>,resp: Result<types::PaymentsResponseData, types::ErrorResponse>,@@ -191,7 +191,7 @@ pub async fn update_connector_mandate_id(//Ignore updation if the payment_attempt mandate_id or connector_mandate_id is not presentif let Some((mandate_id, connector_id)) = mandate_ids_opt.zip(connector_mandate_id) {let mandate = db- .find_mandate_by_merchant_id_mandate_id(&merchant_account, &mandate_id, storage_scheme)+ .find_mandate_by_merchant_id_mandate_id(merchant_id, &mandate_id, storage_scheme).await.change_context(errors::ApiErrorResponse::MandateNotFound)?;@@ -211,7 +211,7 @@ pub async fn update_connector_mandate_id(// only update the connector_mandate_id if existing is noneif mandate.connector_mandate_id.is_none() {db.update_mandate_by_merchant_id_mandate_id(- &merchant_account,+ merchant_id,&mandate_id,update_mandate_details,mandate,@@ -234,15 +234,15 @@ pub async fn get_customer_mandates(let mandates = state.store.find_mandate_by_merchant_id_customer_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req.get_merchant_reference_id(),).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable_lazy(|| {format!(- "Failed while finding mandate: merchant_id: {}, customer_id: {:?}",- merchant_account.merchant_id,+ "Failed while finding mandate: merchant_id: {:?}, customer_id: {:?}",+ merchant_account.get_id(),req.get_merchant_reference_id())})?;@@ -281,7 +281,7 @@ pub async fn update_mandate_procedure<F, FData>(state: &SessionState,resp: types::RouterData<F, FData, types::PaymentsResponseData>,mandate: Mandate,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,pm_id: Option<String>,storage_scheme: MerchantStorageScheme,) -> errors::RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>@@ -371,7 +371,7 @@ wherelet orig_mandate = state.store.find_mandate_by_merchant_id_mandate_id(- resp.merchant_id.as_ref(),+ &resp.merchant_id,mandate_id,storage_scheme,)@@ -484,7 +484,7 @@ pub async fn retrieve_mandates_list(let mandates = state.store.as_ref()- .find_mandates_by_merchant_id(&merchant_account.merchant_id, constraints)+ .find_mandates_by_merchant_id(merchant_account.get_id(), constraints).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Unable to retrieve mandates")?;diff --git a/crates/router/src/core/mandate/helpers.rs b/crates/router/src/core/mandate/helpers.rsindex a4eb18371f..9899d85fc7 100644--- a/crates/router/src/core/mandate/helpers.rs+++ b/crates/router/src/core/mandate/helpers.rs@@ -23,7 +23,7 @@ pub async fn get_profile_id_for_mandate(.find_payment_intent_by_payment_id_merchant_id(&state.into(),payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,merchant_account.storage_scheme,)diff --git a/crates/router/src/core/mandate/utils.rs b/crates/router/src/core/mandate/utils.rsindex d158f17317..81dbfd1d41 100644--- a/crates/router/src/core/mandate/utils.rs+++ b/crates/router/src/core/mandate/utils.rs@@ -28,7 +28,7 @@ pub async fn construct_mandate_revoke_router_data(.change_context(errors::ApiErrorResponse::InternalServerError)?;let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),customer_id: Some(mandate.customer_id),connector_customer: None,connector: mandate.connector,diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rsindex bf50405ba8..a6d50fe615 100644--- a/crates/router/src/core/payment_link.rs+++ b/crates/router/src/core/payment_link.rs@@ -53,7 +53,7 @@ pub async fn initiate_payment_link_flow(state: SessionState,merchant_account: domain::MerchantAccount,key_store: domain::MerchantKeyStore,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,payment_id: String,) -> RouterResponse<services::PaymentLinkFormData> {let db = &*state.store;@@ -314,7 +314,7 @@ pub async fn list_payment_link() -> RouterResponse<Vec<api_models::payments::RetrievePaymentLinkResponse>> {let db = state.store.as_ref();let payment_link = db- .list_payment_link_by_merchant_id(&merchant.merchant_id, constraints)+ .list_payment_link_by_merchant_id(merchant.get_id(), constraints).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Unable to retrieve payment link")?;@@ -492,7 +492,7 @@ pub async fn get_payment_link_status(state: SessionState,merchant_account: domain::MerchantAccount,key_store: domain::MerchantKeyStore,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,payment_id: String,) -> RouterResponse<services::PaymentLinkFormData> {let db = &*state.store;diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 86cb1fc1b1..6566d30e12 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -189,7 +189,7 @@ pub async fn create_pm_collect_db_entry(.customer_id.get_string_repr().to_string(),- merchant_id: merchant_account.merchant_id.to_string(),+ merchant_id: merchant_account.get_id().to_owned(),link_type: common_enums::GenericLinkType::PaymentMethodCollect,link_data,url: pm_collect_link_data.link.clone(),@@ -380,7 +380,7 @@ pub async fn add_payment_method_status_update_task(payment_method: &diesel_models::PaymentMethod,prev_status: enums::PaymentMethodStatus,curr_status: enums::PaymentMethodStatus,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> Result<(), errors::ProcessTrackerError> {let created_at = payment_method.created_at;let schedule_time =@@ -390,7 +390,7 @@ pub async fn add_payment_method_status_update_task(payment_method_id: payment_method.payment_method_id.clone(),prev_status,curr_status,- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),};let runner = storage::ProcessTrackerRunner::PaymentMethodStatusUpdateWorkflow;diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex fd8da0e24f..47f3ba0ab4 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -86,7 +86,7 @@ pub async fn create_payment_method(customer_id: &id_type::CustomerId,payment_method_id: &str,locker_id: Option<String>,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,pm_metadata: Option<serde_json::Value>,customer_acceptance: Option<serde_json::Value>,payment_method_data: Option<Encryption>,@@ -121,7 +121,7 @@ pub async fn create_payment_method(.insert_payment_method(storage::PaymentMethodNew {customer_id: customer_id.to_owned(),- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),payment_method_id: payment_method_id.to_string(),locker_id,payment_method: req.payment_method,@@ -160,7 +160,7 @@ pub async fn create_payment_method(if customer.default_payment_method_id.is_none() && req.payment_method.is_some() {let _ = set_default_payment_method(state,- merchant_id.to_string(),+ merchant_id,key_store.clone(),customer_id,payment_method_id.to_owned(),@@ -175,14 +175,14 @@ pub async fn create_payment_method(pub fn store_default_payment_method(req: &api::PaymentMethodCreate,customer_id: &id_type::CustomerId,- merchant_id: &String,+ merchant_id: &id_type::MerchantId,) -> (api::PaymentMethodResponse,Option<payment_methods::DataDuplicationCheck>,) {let pm_id = generate_id(consts::ID_LENGTH, "pm");let payment_method_response = api::PaymentMethodResponse {- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),customer_id: Some(customer_id.to_owned()),payment_method_id: pm_id,payment_method: req.payment_method,@@ -251,7 +251,7 @@ pub async fn get_or_insert_payment_method(resp,&req,key_store,- &merchant_account.merchant_id,+ merchant_account.get_id(),customer_id,resp.metadata.clone().map(|val| val.expose()),None,@@ -274,7 +274,7 @@ pub async fn get_or_insert_payment_method(pub async fn migrate_payment_method(state: routes::SessionState,req: api::PaymentMethodMigrate,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_account: &domain::MerchantAccount,key_store: &domain::MerchantKeyStore,) -> errors::RouterResponse<api::PaymentMethodResponse> {@@ -326,7 +326,7 @@ pub async fn migrate_payment_method(skip_locker_call_and_migrate_payment_method(state,&req,- merchant_id.into(),+ merchant_id.to_owned(),key_store,merchant_account,card_bin_details.clone(),@@ -449,7 +449,7 @@ implpub async fn skip_locker_call_and_migrate_payment_method(state: routes::SessionState,req: &api::PaymentMethodMigrate,- merchant_id: String,+ merchant_id: id_type::MerchantId,key_store: &domain::MerchantKeyStore,merchant_account: &domain::MerchantAccount,card: api_models::payment_methods::CardDetailFromLocker,@@ -508,7 +508,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(.insert_payment_method(storage::PaymentMethodNew {customer_id: customer_id.to_owned(),- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),payment_method_id: payment_method_id.to_string(),locker_id: None,payment_method: req.payment_method,@@ -549,7 +549,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(if customer.default_payment_method_id.is_none() && req.payment_method.is_some() {let _ = set_default_payment_method(&state,- merchant_id.to_string(),+ &merchant_id,key_store.clone(),&customer_id,payment_method_id.to_owned(),@@ -590,7 +590,7 @@ pub async fn get_client_secret_or_add_payment_method(merchant_account: &domain::MerchantAccount,key_store: &domain::MerchantKeyStore,) -> errors::RouterResponse<api::PaymentMethodResponse> {- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let customer_id = req.customer_id.clone().get_required_value("customer_id")?;#[cfg(not(feature = "payouts"))]@@ -625,7 +625,7 @@ pub async fn get_client_secret_or_add_payment_method(&customer_id,payment_method_id.as_str(),None,- merchant_id.as_str(),+ merchant_id,None,None,None,@@ -722,7 +722,7 @@ pub async fn add_payment_method_data(.find_customer_by_customer_id_merchant_id(&(&state).into(),&customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -837,7 +837,7 @@ pub async fn add_payment_method_data(if customer.default_payment_method_id.is_none() {let _ = set_default_payment_method(&state,- merchant_account.merchant_id.clone(),+ merchant_account.get_id(),key_store.clone(),&customer_id,pm_id,@@ -885,7 +885,7 @@ pub async fn add_payment_method() -> errors::RouterResponse<api::PaymentMethodResponse> {req.validate()?;let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let customer_id = req.customer_id.clone().get_required_value("customer_id")?;let payment_method = req.payment_method.get_required_value("payment_method")?;let payment_method_billing_address: Option<Encryptable<Secret<serde_json::Value>>> = req@@ -1129,7 +1129,7 @@ pub async fn insert_payment_method(resp: &api::PaymentMethodResponse,req: &api::PaymentMethodCreate,key_store: &domain::MerchantKeyStore,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,pm_metadata: Option<serde_json::Value>,customer_acceptance: Option<serde_json::Value>,@@ -1495,7 +1495,7 @@ pub async fn add_bank_to_locker(let payload =payment_methods::StoreLockerReq::LockerGeneric(payment_methods::StoreGenericReq {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),merchant_customer_id: customer_id.to_owned(),enc_data,ttl: state.conf.locker.ttl_for_storage_in_secs,@@ -1511,7 +1511,7 @@ pub async fn add_bank_to_locker(bank.clone(),store_resp.card_reference,req,- &merchant_account.merchant_id,+ merchant_account.get_id(),);Ok((payment_method_resp, store_resp.duplication_check))}@@ -1569,7 +1569,7 @@ pub async fn add_card_to_locker(pub async fn get_card_from_locker(state: &routes::SessionState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,card_reference: &str,) -> errors::RouterResult<Card> {metrics::GET_FROM_LOCKER.add(&metrics::CONTEXT, 1, &[]);@@ -1611,7 +1611,7 @@ pub async fn get_card_from_locker(pub async fn delete_card_from_locker(state: &routes::SessionState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,card_reference: &str,) -> errors::RouterResult<payment_methods::DeleteCardResp> {metrics::DELETE_FROM_LOCKER.add(&metrics::CONTEXT, 1, &[]);@@ -1649,7 +1649,7 @@ pub async fn add_card_hs(errors::VaultError,> {let payload = payment_methods::StoreLockerReq::LockerCard(payment_methods::StoreCardReq {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),merchant_customer_id: customer_id.to_owned(),requestor_card_reference: card_reference.map(str::to_string),card: Card {@@ -1670,7 +1670,7 @@ pub async fn add_card_hs(card.clone(),store_card_payload.card_reference,req,- &merchant_account.merchant_id,+ merchant_account.get_id(),);Ok((payment_method_resp, store_card_payload.duplication_check))}@@ -1707,7 +1707,7 @@ pub async fn get_payment_method_from_hs_locker<'a>(state: &'a routes::SessionState,key_store: &domain::MerchantKeyStore,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_method_reference: &'a str,locker_choice: Option<api_enums::LockerChoice>,) -> errors::CustomResult<Secret<String>, errors::VaultError> {@@ -1769,9 +1769,9 @@ pub async fn get_payment_method_from_hs_locker<'a>(}#[instrument(skip_all)]-pub async fn call_to_locker_hs<'a>(+pub async fn call_to_locker_hs(state: &routes::SessionState,- payload: &payment_methods::StoreLockerReq<'a>,+ payload: &payment_methods::StoreLockerReq,customer_id: &id_type::CustomerId,locker_choice: api_enums::LockerChoice,) -> errors::CustomResult<payment_methods::StoreCardRespPayload, errors::VaultError> {@@ -1866,7 +1866,7 @@ pub async fn update_payment_method_connector_mandate_details(pub async fn get_card_from_hs_locker<'a>(state: &'a routes::SessionState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,card_reference: &'a str,locker_choice: api_enums::LockerChoice,) -> errors::CustomResult<Card, errors::VaultError> {@@ -1923,7 +1923,7 @@ pub async fn get_card_from_hs_locker<'a>(pub async fn delete_card_from_hs_locker<'a>(state: &routes::SessionState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,card_reference: &'a str,) -> errors::RouterResult<payment_methods::DeleteCardResp> {let locker = &state.conf.locker;@@ -1968,10 +1968,10 @@ pub async fn delete_card_from_hs_locker<'a>(}///Mock api for local testing-pub async fn mock_call_to_locker_hs<'a>(+pub async fn mock_call_to_locker_hs(db: &dyn db::StorageInterface,card_id: &str,- payload: &payment_methods::StoreLockerReq<'a>,+ payload: &payment_methods::StoreLockerReq,card_cvc: Option<String>,payment_method_id: Option<String>,customer_id: Option<&id_type::CustomerId>,@@ -1981,7 +1981,7 @@ pub async fn mock_call_to_locker_hs<'a>(external_id: uuid::Uuid::new_v4().to_string(),card_fingerprint: uuid::Uuid::new_v4().to_string(),card_global_fingerprint: uuid::Uuid::new_v4().to_string(),- merchant_id: "".to_string(),+ merchant_id: id_type::MerchantId::default(),card_number: "4111111111111111".to_string(),card_exp_year: "2099".to_string(),card_exp_month: "12".to_string(),@@ -1994,7 +1994,7 @@ pub async fn mock_call_to_locker_hs<'a>(};locker_mock_up = match payload {payment_methods::StoreLockerReq::LockerCard(store_card_req) => storage::LockerMockUpNew {- merchant_id: store_card_req.merchant_id.to_string(),+ merchant_id: store_card_req.merchant_id.to_owned(),card_number: store_card_req.card.card_number.peek().to_string(),card_exp_year: store_card_req.card.card_exp_year.peek().to_string(),card_exp_month: store_card_req.card.card_exp_month.peek().to_string(),@@ -2004,7 +2004,7 @@ pub async fn mock_call_to_locker_hs<'a>(},payment_methods::StoreLockerReq::LockerGeneric(store_generic_req) => {storage::LockerMockUpNew {- merchant_id: store_generic_req.merchant_id.to_string(),+ merchant_id: store_generic_req.merchant_id.to_owned(),enc_card_data: Some(store_generic_req.enc_data.to_owned()),..locker_mock_up}@@ -2084,7 +2084,7 @@ pub async fn mock_get_payment_method<'a>(.payment_method_id.unwrap_or(locker_mock_up.card_id),external_id: locker_mock_up.external_id,- merchant_id: Some(locker_mock_up.merchant_id),+ merchant_id: Some(locker_mock_up.merchant_id.to_owned()),nickname: locker_mock_up.nickname,customer_id: locker_mock_up.customer_id,duplicate: locker_mock_up.duplicate,@@ -2243,7 +2243,7 @@ pub async fn list_payment_methods(pi.shipping_address_id.clone(),&key_store,&pi.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -2260,7 +2260,7 @@ pub async fn list_payment_methods(pi.billing_address_id.clone(),&key_store,&pi.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -2325,7 +2325,7 @@ pub async fn list_payment_methods(let all_mcas = db.find_merchant_connector_account_by_merchant_id_and_disabled_list(key_manager_state,- &merchant_account.merchant_id,+ merchant_account.get_id(),false,&key_store,)@@ -2351,7 +2351,7 @@ pub async fn list_payment_methods(let business_profile = core_utils::validate_and_get_business_profile(db,profile_id.as_ref(),- &merchant_account.merchant_id,+ merchant_account.get_id(),).await?;@@ -2371,7 +2371,8 @@ pub async fn list_payment_methods(})?;format!("pm_filters_cgraph_{}_{}",- &merchant_account.merchant_id, profile_id+ merchant_account.get_id(),+ profile_id)};@@ -2468,7 +2469,7 @@ pub async fn list_payment_methods(match db.find_payment_method_by_customer_id_merchant_id_list(&customer.customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),None,).await@@ -3704,7 +3705,7 @@ pub async fn list_customer_payment_method(.find_customer_by_customer_id_merchant_id(&state.into(),customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -3713,7 +3714,7 @@ pub async fn list_customer_payment_method(let is_requires_cvv = db.find_config_by_key_unwrap_or(- format!("{}_requires_cvv", merchant_account.merchant_id).as_str(),+ &merchant_account.get_id().get_requires_cvv_key(),Some("true".to_string()),).await@@ -3725,14 +3726,13 @@ pub async fn list_customer_payment_method(let resp = db.find_payment_method_by_customer_id_merchant_id_status(customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),common_enums::PaymentMethodStatus::Active,limit,merchant_account.storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;- //let mca = query::find_mca_by_merchant_id(conn, &merchant_account.merchant_id)?;let mut customer_pms = Vec::new();let profile_id = payment_intent@@ -3755,7 +3755,7 @@ pub async fn list_customer_payment_method(let business_profile = core_utils::validate_and_get_business_profile(db,profile_id.as_ref(),- &merchant_account.merchant_id,+ merchant_account.get_id(),).await?;@@ -3883,7 +3883,7 @@ pub async fn list_customer_payment_method(let mca_enabled = get_mca_status(state,&key_store,- &merchant_account.merchant_id,+ merchant_account.get_id(),is_connector_agnostic_mit_enabled,connector_mandate_details,pm.network_transaction_id.as_ref(),@@ -3982,7 +3982,7 @@ pub async fn list_customer_payment_method(.store.find_payment_attempt_by_payment_id_merchant_id_attempt_id(&payment_intent.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&payment_intent.active_attempt.get_id(),merchant_account.storage_scheme,)@@ -4014,7 +4014,7 @@ pub async fn list_customer_payment_method(pub async fn get_mca_status(state: &routes::SessionState,key_store: &domain::MerchantKeyStore,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,is_connector_agnostic_mit_enabled: bool,connector_mandate_details: Option<storage::PaymentsMandateReference>,network_transaction_id: Option<&String>,@@ -4033,7 +4033,7 @@ pub async fn get_mca_status().await.change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {- id: merchant_id.to_string(),+ id: merchant_id.get_string_repr().to_owned(),})?;let mut mca_ids = HashSet::new();@@ -4298,7 +4298,7 @@ async fn get_bank_account_connector_details(}pub async fn set_default_payment_method(state: &routes::SessionState,- merchant_id: String,+ merchant_id: &id_type::MerchantId,key_store: domain::MerchantKeyStore,customer_id: &id_type::CustomerId,payment_method_id: String,@@ -4312,7 +4312,7 @@ pub async fn set_default_payment_method(.find_customer_by_customer_id_merchant_id(key_manager_state,customer_id,- &merchant_id,+ merchant_id,&key_store,storage_scheme,)@@ -4328,7 +4328,7 @@ pub async fn set_default_payment_method(.get_required_value("payment_method")?;utils::when(- &payment_method.customer_id != customer_id || payment_method.merchant_id != merchant_id,+ &payment_method.customer_id != customer_id || payment_method.merchant_id != *merchant_id,|| {Err(errors::ApiErrorResponse::PreconditionFailed {message: "The payment_method_id is not valid".to_string(),@@ -4400,7 +4400,7 @@ pub async fn get_bank_from_hs_locker(key_store: &domain::MerchantKeyStore,temp_token: &str,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,token_ref: &str,) -> errors::RouterResult<api::BankPayout> {let payment_method = get_payment_method_from_hs_locker(@@ -4605,7 +4605,7 @@ pub async fn delete_payment_method(.find_customer_by_customer_id_merchant_id(key_manager_state,&key.customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -4631,7 +4631,7 @@ pub async fn delete_payment_method(}db.delete_payment_method_by_merchant_id_payment_method_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),pm_id.payment_method_id.as_str(),).awaitdiff --git a/crates/router/src/core/payment_methods/migration.rs b/crates/router/src/core/payment_methods/migration.rsindex 83e9993478..d548d03ab4 100644--- a/crates/router/src/core/payment_methods/migration.rs+++ b/crates/router/src/core/payment_methods/migration.rs@@ -12,7 +12,7 @@ use crate::{pub async fn migrate_payment_methods(state: routes::SessionState,payment_methods: Vec<PaymentMethodRecord>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_account: &domain::MerchantAccount,key_store: &domain::MerchantKeyStore,) -> errors::RouterResponse<Vec<PaymentMethodMigrationResponse>> {@@ -58,7 +58,8 @@ fn parse_csv(data: &[u8]) -> csv::Result<Vec<PaymentMethodRecord>> {}pub fn get_payment_method_records(form: PaymentMethodsMigrateForm,-) -> Result<(String, Vec<PaymentMethodRecord>), errors::ApiErrorResponse> {+) -> Result<(common_utils::id_type::MerchantId, Vec<PaymentMethodRecord>), errors::ApiErrorResponse>+{match parse_csv(form.file.data.to_bytes()) {Ok(records) => {if let Some(first_record) = records.first() {diff --git a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs b/crates/router/src/core/payment_methods/surcharge_decision_configs.rsindex fd209e78da..6a3ceeada1 100644--- a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs+++ b/crates/router/src/core/payment_methods/surcharge_decision_configs.rs@@ -378,10 +378,10 @@ fn get_surcharge_details_from_surcharge_output(#[instrument(skip_all)]pub async fn ensure_algorithm_cached(store: &dyn StorageInterface,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,algorithm_id: &str,) -> ConditionalConfigResult<VirInterpreterBackendCacheWrapper> {- let key = format!("surcharge_dsl_{merchant_id}");+ let key = merchant_id.get_surcharge_dsk_key();let value_to_cache = || async {let config: diesel_models::Config = store.find_config_by_key(algorithm_id).await?;diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rsindex 6bfadabdb3..9ca2bffc88 100644--- a/crates/router/src/core/payment_methods/transformers.rs+++ b/crates/router/src/core/payment_methods/transformers.rs@@ -21,12 +21,12 @@ use crate::{#[derive(Debug, Serialize)]#[serde(untagged)]-pub enum StoreLockerReq<'a> {- LockerCard(StoreCardReq<'a>),- LockerGeneric(StoreGenericReq<'a>),+pub enum StoreLockerReq {+ LockerCard(StoreCardReq),+ LockerGeneric(StoreGenericReq),}-impl StoreLockerReq<'_> {+impl StoreLockerReq {pub fn update_requestor_card_reference(&mut self, card_reference: Option<String>) {match self {Self::LockerCard(c) => c.requestor_card_reference = card_reference,@@ -36,8 +36,8 @@ impl StoreLockerReq<'_> {}#[derive(Debug, Deserialize, Serialize)]-pub struct StoreCardReq<'a> {- pub merchant_id: &'a str,+pub struct StoreCardReq {+ pub merchant_id: id_type::MerchantId,pub merchant_customer_id: id_type::CustomerId,#[serde(skip_serializing_if = "Option::is_none")]pub requestor_card_reference: Option<String>,@@ -46,8 +46,8 @@ pub struct StoreCardReq<'a> {}#[derive(Debug, Deserialize, Serialize)]-pub struct StoreGenericReq<'a> {- pub merchant_id: &'a str,+pub struct StoreGenericReq {+ pub merchant_id: id_type::MerchantId,pub merchant_customer_id: id_type::CustomerId,#[serde(rename = "enc_card_data")]pub enc_data: String,@@ -76,8 +76,8 @@ pub enum DataDuplicationCheck {}#[derive(Debug, Deserialize, Serialize)]-pub struct CardReqBody<'a> {- pub merchant_id: &'a str,+pub struct CardReqBody {+ pub merchant_id: id_type::MerchantId,pub merchant_customer_id: id_type::CustomerId,pub card_reference: String,}@@ -105,12 +105,12 @@ pub struct DeleteCardResp {#[derive(Debug, Deserialize, Serialize)]#[serde(rename_all = "camelCase")]-pub struct AddCardRequest<'a> {+pub struct AddCardRequest {pub card_number: cards::CardNumber,pub customer_id: id_type::CustomerId,pub card_exp_month: Secret<String>,pub card_exp_year: Secret<String>,- pub merchant_id: &'a str,+ pub merchant_id: id_type::MerchantId,pub email_address: Option<Email>,pub name_on_card: Option<Secret<String>>,pub nickname: Option<String>,@@ -124,7 +124,7 @@ pub struct AddCardResponse {pub card_fingerprint: Secret<String>,pub card_global_fingerprint: Secret<String>,#[serde(rename = "merchant_id")]- pub merchant_id: Option<String>,+ pub merchant_id: Option<id_type::MerchantId>,pub card_number: Option<cards::CardNumber>,pub card_exp_year: Option<Secret<String>>,pub card_exp_month: Option<Secret<String>>,@@ -140,7 +140,7 @@ pub struct AddPaymentMethodResponse {pub payment_method_id: String,pub external_id: String,#[serde(rename = "merchant_id")]- pub merchant_id: Option<String>,+ pub merchant_id: Option<id_type::MerchantId>,pub nickname: Option<String>,pub customer_id: Option<id_type::CustomerId>,pub duplicate: Option<bool>,@@ -285,10 +285,10 @@ pub async fn mk_basilisk_req(Ok(jwe_body)}-pub async fn mk_add_locker_request_hs<'a>(+pub async fn mk_add_locker_request_hs(jwekey: &settings::Jwekey,locker: &settings::Locker,- payload: &StoreLockerReq<'a>,+ payload: &StoreLockerReq,locker_choice: api_enums::LockerChoice,) -> CustomResult<services::Request, errors::VaultError> {let payload = payload@@ -317,7 +317,7 @@ pub fn mk_add_bank_response_hs(bank: api::BankPayout,bank_reference: String,req: api::PaymentMethodCreate,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> api::PaymentMethodResponse {api::PaymentMethodResponse {merchant_id: merchant_id.to_owned(),@@ -341,7 +341,7 @@ pub fn mk_add_card_response_hs(card: api::CardDetail,card_reference: String,req: api::PaymentMethodCreate,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> api::PaymentMethodResponse {let card_number = card.card_number.clone();let last4_digits = card_number.get_last4();@@ -390,13 +390,13 @@ pub async fn mk_get_card_request_hs(jwekey: &settings::Jwekey,locker: &settings::Locker,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,card_reference: &str,locker_choice: Option<api_enums::LockerChoice>,) -> CustomResult<services::Request, errors::VaultError> {let merchant_customer_id = customer_id.to_owned();let card_req_body = CardReqBody {- merchant_id,+ merchant_id: merchant_id.to_owned(),merchant_customer_id,card_reference: card_reference.to_owned(),};@@ -462,12 +462,12 @@ pub async fn mk_delete_card_request_hs(jwekey: &settings::Jwekey,locker: &settings::Locker,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,card_reference: &str,) -> CustomResult<services::Request, errors::VaultError> {let merchant_customer_id = customer_id.to_owned();let card_req_body = CardReqBody {- merchant_id,+ merchant_id: merchant_id.to_owned(),merchant_customer_id,card_reference: card_reference.to_owned(),};@@ -492,24 +492,6 @@ pub async fn mk_delete_card_request_hs(Ok(request)}-pub fn mk_delete_card_request(- locker: &settings::Locker,- merchant_id: &'static str,- card_id: &'static str,-) -> CustomResult<services::Request, errors::VaultError> {- let delete_card_req = GetCard {- merchant_id,- card_id,- };- let mut url = locker.host.to_owned();- url.push_str("/card/deleteCard");- let mut request = services::Request::new(services::Method::Post, &url);- request.add_default_headers();-- request.set_body(RequestContent::FormUrlEncoded(Box::new(delete_card_req)));- Ok(request)-}-pub fn mk_delete_card_response(response: DeleteCardResponse,) -> errors::RouterResult<DeleteCardResp> {diff --git a/crates/router/src/core/payment_methods/validator.rs b/crates/router/src/core/payment_methods/validator.rsindex 23470fb3ef..c45f6df837 100644--- a/crates/router/src/core/payment_methods/validator.rs+++ b/crates/router/src/core/payment_methods/validator.rs@@ -24,7 +24,7 @@ pub async fn validate_request_and_initiate_payment_method_collect_link(// Validate customer_idlet db: &dyn StorageInterface = &*state.store;let customer_id = req.customer_id.clone();- let merchant_id = merchant_account.merchant_id.clone();+ let merchant_id = merchant_account.get_id().clone();match db.find_customer_by_customer_id_merchant_id(&state.into(),@@ -40,7 +40,7 @@ pub async fn validate_request_and_initiate_payment_method_collect_link(if err.current_context().is_db_not_found() {Err(err).change_context(errors::ApiErrorResponse::InvalidRequestData {message: format!(- "customer [{}] not found for merchant [{}]",+ "customer [{}] not found for merchant [{:?}]",customer_id.get_string_repr(),merchant_id),@@ -102,7 +102,8 @@ pub async fn validate_request_and_initiate_payment_method_collect_link(None => default_config.expiry,};let link = Secret::new(format!(- "{domain}/payment_methods/collect/{merchant_id}/{pm_collect_link_id}"+ "{domain}/payment_methods/collect/{}/{pm_collect_link_id}",+ merchant_id.get_string_repr()));let enabled_payment_methods = match (&req.enabled_payment_methods, &merchant_config) {(Some(enabled_payment_methods), _) => enabled_payment_methods.clone(),diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 8d83cfb803..e1d98c5056 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -135,7 +135,7 @@ where{let operation: BoxedOperation<'_, F, Req> = Box::new(operation);- tracing::Span::current().record("merchant_id", merchant_account.merchant_id.as_str());+ tracing::Span::current().record("merchant_id", merchant_account.get_id().get_string_repr());let (operation, validate_result) = operation.to_validate_request()?.validate_request(&req, &merchant_account)?;@@ -274,7 +274,7 @@ wherepayment_sync::get_sync_process_schedule_time(&*state.store,connector.connector.id(),- &merchant_account.merchant_id,+ merchant_account.get_id(),0,).await@@ -365,7 +365,7 @@ wherepayment_sync::get_sync_process_schedule_time(&*state.store,connector_data.connector.id(),- &merchant_account.merchant_id,+ merchant_account.get_id(),0,).await@@ -401,11 +401,9 @@ where#[cfg(feature = "retry")]{use crate::core::payments::retry::{self, GsmValidation};- let config_bool = retry::config_should_call_gsm(- &*state.store,- &merchant_account.merchant_id,- )- .await;+ let config_bool =+ retry::config_should_call_gsm(&*state.store, merchant_account.get_id())+ .await;if config_bool && router_data.should_call_gsm() {router_data = retry::do_gsm_actions(@@ -633,7 +631,7 @@ wherelet output = perform_decision_management(state,algorithm_ref,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),payment_data,).await@@ -856,7 +854,7 @@ fn is_start_pay<Op: Debug>(operation: &Op) -> bool {pub struct PaymentsRedirectResponseData {pub connector: Option<String>,pub param: Option<String>,- pub merchant_id: Option<String>,+ pub merchant_id: Option<id_type::MerchantId>,pub json_payload: Option<serde_json::Value>,pub resource_id: api::PaymentIdType,pub force_sync: bool,@@ -907,7 +905,10 @@ pub trait PaymentRedirectFlow: Sync {"connector",req.connector.to_owned().unwrap_or("null".to_string()),),- ("merchant_id", merchant_account.merchant_id.to_owned()),+ (+ "merchant_id",+ merchant_account.get_id().get_string_repr().to_owned(),+ ),]),);let connector = req.connector.clone().get_required_value("connector")?;@@ -1198,7 +1199,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {connector: String,payment_id: String,) -> RouterResult<Self::PaymentFlowResponse> {- let merchant_id = merchant_account.merchant_id.clone();+ let merchant_id = merchant_account.get_id().clone();let payment_intent = state.store.find_payment_intent_by_payment_id_merchant_id(@@ -1226,7 +1227,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {let authentication = state.store.find_authentication_by_merchant_id_authentication_id(- merchant_id.clone(),+ &merchant_id,authentication_id.clone(),).await@@ -1333,7 +1334,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {// When intent status is RequiresCustomerAction, Set poll_id in redis to allow the fetch status of poll through retrieve_poll_status api from clientif payments_response.status == common_enums::IntentStatus::RequiresCustomerAction {let req_poll_id = utils::get_external_authentication_request_poll_id(&payment_id);- let poll_id = utils::get_poll_id(merchant_id.clone(), req_poll_id.clone());+ let poll_id = utils::get_poll_id(&merchant_id, req_poll_id.clone());let redis_conn = state.store.get_redis_conn()@@ -1433,7 +1434,7 @@ pub async fn call_connector_service<F, RouterDReq, ApiRequest>(payment_data: &mut PaymentData<F>,customer: &Option<domain::Customer>,call_connector_action: CallConnectorAction,- validate_result: &operations::ValidateResult<'_>,+ validate_result: &operations::ValidateResult,schedule_time: Option<time::PrimitiveDateTime>,header_payload: HeaderPayload,frm_suggestion: Option<storage_enums::FrmSuggestion>,@@ -1720,14 +1721,15 @@ pub async fn get_merchant_bank_data_for_open_banking_connectors(let final_recipient_data = if let Some(id) = recipient_id {if contains {// Customer Id for OpenBanking connectors will be merchant_id as the account data stored at locker belongs to the merchant- let cust_id = id_type::CustomerId::from(merchant_account.merchant_id.clone().into())+ let merchant_id_str = merchant_account.get_id().get_string_repr().to_owned();+ let cust_id = id_type::CustomerId::from(merchant_id_str.into()).change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to convert to CustomerId")?;let locker_resp = cards::get_payment_method_from_hs_locker(state,key_store,&cust_id,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),id.as_str(),Some(enums::LockerChoice::HyperswitchCardVault),)@@ -1764,7 +1766,7 @@ whereF: Send + Clone + Sync,{let merchant_id = &payment_data.payment_attempt.merchant_id;- let blocklist_enabled_key = format!("guard_blocklist_for_{merchant_id}");+ let blocklist_enabled_key = merchant_id.get_blocklist_guard_key();let blocklist_guard_enabled = state.store.find_config_by_key_unwrap_or(&blocklist_enabled_key, Some("false".to_string()))@@ -2254,7 +2256,7 @@ wherelet merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),payment_data.creds_identifier.to_owned(),key_store,&profile_id,@@ -2494,7 +2496,7 @@ pub async fn get_connector_tokenization_action_when_confirm_true<F, Req>(state: &SessionState,operation: &BoxedOperation<'_, F, Req>,payment_data: &mut PaymentData<F>,- validate_result: &operations::ValidateResult<'_>,+ validate_result: &operations::ValidateResult,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_key_store: &domain::MerchantKeyStore,customer: &Option<domain::Customer>,@@ -2623,7 +2625,7 @@ pub async fn tokenize_in_router_when_confirm_false_or_external_authentication<F,state: &SessionState,operation: &BoxedOperation<'_, F, Req>,payment_data: &mut PaymentData<F>,- validate_result: &operations::ValidateResult<'_>,+ validate_result: &operations::ValidateResult,merchant_key_store: &domain::MerchantKeyStore,customer: &Option<domain::Customer>,business_profile: Option<&diesel_models::business_profile::BusinessProfile>,@@ -2880,7 +2882,7 @@ pub async fn list_payments() -> RouterResponse<api::PaymentListResponse> {use hyperswitch_domain_models::errors::StorageError;helpers::validate_payment_list_request(&constraints)?;- let merchant_id = &merchant.merchant_id;+ let merchant_id = merchant.get_id();let db = state.store.as_ref();let payment_intents = helpers::filter_by_constraints(&state,@@ -2956,7 +2958,7 @@ pub async fn apply_filters_on_payments(let list: Vec<(storage::PaymentIntent, storage::PaymentAttempt)> = db.get_filtered_payment_intents_attempt(&(&state).into(),- &merchant.merchant_id,+ merchant.get_id(),&constraints.clone().into(),&merchant_key_store,merchant.storage_scheme,@@ -2969,7 +2971,7 @@ pub async fn apply_filters_on_payments(let active_attempt_ids = db.get_filtered_active_attempt_ids_for_total_count(- &merchant.merchant_id,+ merchant.get_id(),&constraints.clone().into(),merchant.storage_scheme,)@@ -2978,7 +2980,7 @@ pub async fn apply_filters_on_payments(let total_count = db.get_total_count_of_filtered_payment_attempts(- &merchant.merchant_id,+ merchant.get_id(),&active_attempt_ids,constraints.connector,constraints.payment_method,@@ -3010,7 +3012,7 @@ pub async fn get_filters_for_payments(let pi = db.filter_payment_intents_by_time_range_constraints(&(&state).into(),- &merchant.merchant_id,+ merchant.get_id(),&time_range,&merchant_key_store,merchant.storage_scheme,@@ -3021,7 +3023,7 @@ pub async fn get_filters_for_payments(let filters = db.get_filters_for_payments(pi.as_slice(),- &merchant.merchant_id,+ merchant.get_id(),// since OLAP doesn't have KV. Force to get the data from PSQL.storage_enums::MerchantStorageScheme::PostgresOnly,)@@ -3046,7 +3048,7 @@ pub async fn get_payment_filters(merchant: domain::MerchantAccount,) -> RouterResponse<api::PaymentListFiltersV2> {let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =- super::admin::list_payment_connectors(state, merchant.merchant_id).await?+ super::admin::list_payment_connectors(state, merchant.get_id().to_owned()).await?{data} else {@@ -3443,7 +3445,7 @@ where#[cfg(feature = "retry")]let should_do_retry =- retry::config_should_call_gsm(&*state.store, &merchant_account.merchant_id).await;+ retry::config_should_call_gsm(&*state.store, merchant_account.get_id()).await;#[cfg(feature = "retry")]if payment_data.payment_attempt.payment_method_type@@ -3946,7 +3948,7 @@ wherelet connectors = routing::perform_static_routing_v1(state,- &merchant_account.merchant_id,+ merchant_account.get_id(),algorithm_ref,&transaction_data,)@@ -4018,7 +4020,7 @@ pub async fn payment_external_authentication(req: api_models::payments::PaymentsExternalAuthenticationRequest,) -> RouterResponse<api_models::payments::PaymentsExternalAuthenticationResponse> {let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let payment_id = req.payment_id;let payment_intent = db@@ -4059,7 +4061,7 @@ pub async fn payment_external_authentication(.find_customer_by_customer_id_merchant_id(&(&state).into(),customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,storage_scheme,)@@ -4118,7 +4120,7 @@ pub async fn payment_external_authentication(.await?;let authentication = db.find_authentication_by_merchant_id_authentication_id(- merchant_id.to_string(),+ merchant_id,payment_attempt.authentication_id.clone()@@ -4229,7 +4231,7 @@ pub async fn payment_external_authentication(#[instrument(skip_all)]pub async fn get_extended_card_info(state: SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,payment_id: String,) -> RouterResponse<payments_api::ExtendedCardInfoResponse> {let redis_conn = state@@ -4298,7 +4300,7 @@ pub async fn payments_manual_update(.find_payment_intent_by_payment_id_merchant_id(&(&state).into(),&payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)diff --git a/crates/router/src/core/payments/access_token.rs b/crates/router/src/core/payments/access_token.rsindex 39d2c4d437..78ef29e473 100644--- a/crates/router/src/core/payments/access_token.rs+++ b/crates/router/src/core/payments/access_token.rs@@ -64,7 +64,7 @@ pub async fn add_access_token<.connector_name.supports_access_token(router_data.payment_method){- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let store = &*state.store;// `merchant_connector_id` may not be present in the below cases@@ -88,8 +88,8 @@ pub async fn add_access_token<let res = match old_access_token {Some(access_token) => {router_env::logger::debug!(- "Access token found in redis for merchant_id: {}, payment_id: {}, connector: {} which has expiry of: {} seconds",- merchant_account.merchant_id,+ "Access token found in redis for merchant_id: {:?}, payment_id: {}, connector: {} which has expiry of: {} seconds",+ merchant_account.get_id(),router_data.payment_id,connector.connector_name,access_token.expiresdiff --git a/crates/router/src/core/payments/conditional_configs.rs b/crates/router/src/core/payments/conditional_configs.rsindex 7ec9a74915..4f5b84af76 100644--- a/crates/router/src/core/payments/conditional_configs.rs+++ b/crates/router/src/core/payments/conditional_configs.rs@@ -21,7 +21,7 @@ pub type ConditionalConfigResult<O> = errors::CustomResult<O, ConfigError>;pub async fn perform_decision_management<F: Clone>(state: &routes::SessionState,algorithm_ref: routing::RoutingAlgorithmRef,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_data: &mut payments::PaymentData<F>,) -> ConditionalConfigResult<ConditionalConfigs> {let algorithm_id = if let Some(id) = algorithm_ref.config_algo_id {@@ -31,7 +31,7 @@ pub async fn perform_decision_management<F: Clone>(};let db = &*state.store;- let key = format!("dsl_{merchant_id}");+ let key = merchant_id.get_dsl_config();let find_key_from_db = || async {let config = db.find_config_by_key(&algorithm_id).await?;diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 183ee97ede..6dd8f19472 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -146,7 +146,7 @@ pub async fn create_or_update_address_for_payment_by_request(session_state: &SessionState,req_address: Option<&api::Address>,address_id: Option<&str>,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: Option<&id_type::CustomerId>,merchant_key_store: &domain::MerchantKeyStore,payment_id: &str,@@ -279,7 +279,7 @@ pub async fn create_or_find_address_for_payment_by_request(state: &SessionState,req_address: Option<&api::Address>,address_id: Option<&str>,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: Option<&id_type::CustomerId>,merchant_key_store: &domain::MerchantKeyStore,payment_id: &str,@@ -339,7 +339,7 @@ pub async fn create_or_find_address_for_payment_by_request(pub async fn get_domain_address(session_state: &SessionState,address: &api_models::payments::Address,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key: &[u8],storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<domain::Address, common_utils::errors::CryptoError> {@@ -355,7 +355,7 @@ pub async fn get_domain_address(.and_then(|phone| phone.number.clone()),email: address.email.clone(),}),- Identifier::Merchant(merchant_id.to_string()),+ Identifier::Merchant(merchant_id.to_owned()),key,).await?;@@ -365,7 +365,7 @@ pub async fn get_domain_address(id: None,phone_number: encryptable_address.phone_number,country_code: address.phone.as_ref().and_then(|a| a.country_code.clone()),- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),address_id: generate_id(consts::ID_LENGTH, "add"),city: address_details.and_then(|address_details| address_details.city.clone()),country: address_details.and_then(|address_details| address_details.country),@@ -390,7 +390,7 @@ pub async fn get_address_by_id(address_id: Option<String>,merchant_key_store: &domain::MerchantKeyStore,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Option<domain::Address>, errors::ApiErrorResponse> {match address_id {@@ -480,7 +480,7 @@ pub async fn get_token_pm_type_mandate_details(verify_mandate_details_for_recurring_payments(&payment_method_info.merchant_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&payment_method_info.customer_id,customer_id,)?;@@ -530,7 +530,7 @@ pub async fn get_token_pm_type_mandate_details(.store.find_payment_method_by_customer_id_merchant_id_list(customer_id,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),None,).await@@ -650,7 +650,7 @@ pub async fn get_token_for_recurring_mandate(let mandate = db.find_mandate_by_merchant_id_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),mandate_id.as_str(),merchant_account.storage_scheme,)@@ -774,8 +774,8 @@ pub async fn get_token_for_recurring_mandate(/// Check weather the merchant id in the request/// and merchant id in the merchant account are same.pub fn validate_merchant_id(- merchant_id: &str,- request_merchant_id: Option<&str>,+ merchant_id: &id_type::MerchantId,+ request_merchant_id: Option<&id_type::MerchantId>,) -> CustomResult<(), errors::ApiErrorResponse> {// Get Merchant Id from the merchant// or get from merchant account@@ -1091,7 +1091,10 @@ pub fn create_startpay_url() -> String {format!("{}/payments/redirect/{}/{}/{}",- base_url, payment_intent.payment_id, payment_intent.merchant_id, payment_attempt.attempt_id+ base_url,+ payment_intent.payment_id,+ payment_intent.merchant_id.get_string_repr(),+ payment_attempt.attempt_id)}@@ -1104,7 +1107,10 @@ pub fn create_redirect_url(let creds_identifier_path = creds_identifier.map_or_else(String::new, |cd| format!("/{}", cd));format!("{}/payments/{}/{}/redirect/response/{}",- router_base_url, payment_attempt.payment_id, payment_attempt.merchant_id, connector_name,+ router_base_url,+ payment_attempt.payment_id,+ payment_attempt.merchant_id.get_string_repr(),+ connector_name,) + creds_identifier_path.as_ref()}@@ -1125,18 +1131,23 @@ pub fn create_authorize_url() -> String {format!("{}/payments/{}/{}/authorize/{}",- router_base_url, payment_attempt.payment_id, payment_attempt.merchant_id, connector_name+ router_base_url,+ payment_attempt.payment_id,+ payment_attempt.merchant_id.get_string_repr(),+ connector_name)}pub fn create_webhook_url(router_base_url: &String,- merchant_id: &String,+ merchant_id: &id_type::MerchantId,connector_name: &String,) -> String {format!("{}/webhooks/{}/{}",- router_base_url, merchant_id, connector_name+ router_base_url,+ merchant_id.get_string_repr(),+ connector_name)}pub fn create_complete_authorize_url(@@ -1146,7 +1157,10 @@ pub fn create_complete_authorize_url() -> String {format!("{}/payments/{}/{}/redirect/complete/{}",- router_base_url, payment_attempt.payment_id, payment_attempt.merchant_id, connector_name+ router_base_url,+ payment_attempt.payment_id,+ payment_attempt.merchant_id.get_string_repr(),+ connector_name)}@@ -1219,8 +1233,8 @@ pub fn verify_mandate_details(}pub fn verify_mandate_details_for_recurring_payments(- mandate_merchant_id: &str,- merchant_id: &str,+ mandate_merchant_id: &id_type::MerchantId,+ merchant_id: &id_type::MerchantId,mandate_customer_id: &id_type::CustomerId,customer_id: &id_type::CustomerId,) -> RouterResult<()> {@@ -1400,7 +1414,7 @@ pub(crate) async fn get_payment_method_create_request(pub async fn get_customer_from_details<F: Clone>(state: &SessionState,customer_id: Option<id_type::CustomerId>,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_data: &mut PaymentData<F>,merchant_key_store: &domain::MerchantKeyStore,storage_scheme: enums::MerchantStorageScheme,@@ -1524,7 +1538,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R>(operation: BoxedOperation<'a, F, R>,payment_data: &mut PaymentData<F>,req: Option<CustomerDetails>,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: common_enums::enums::MerchantStorageScheme,) -> CustomResult<(BoxedOperation<'a, F, R>, Option<domain::Customer>), errors::StorageError> {@@ -1645,7 +1659,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R>(db.update_customer_by_customer_id_merchant_id(key_manager_state,customer_id,- merchant_id.to_string(),+ merchant_id.to_owned(),c,customer_update,key_store,@@ -1659,7 +1673,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R>(None => {let new_customer = domain::Customer {customer_id,- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),name: encryptable_customer.name,email: encryptable_customer.email,phone: encryptable_customer.phone,@@ -2474,7 +2488,7 @@ wherepub(super) async fn filter_by_constraints(state: &SessionState,constraints: &api::PaymentListConstraints,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Vec<PaymentIntent>, errors::DataStorageError> {@@ -2611,7 +2625,7 @@ pub fn make_merchant_url_with_response(pub async fn make_ephemeral_key(state: SessionState,customer_id: id_type::CustomerId,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> errors::RouterResponse<ephemeral_key::EphemeralKey> {let store = &state.store;let id = utils::generate_id(consts::ID_LENGTH, "eki");@@ -2619,7 +2633,7 @@ pub async fn make_ephemeral_key(let ek = ephemeral_key::EphemeralKeyNew {id,customer_id,- merchant_id,+ merchant_id: merchant_id.to_owned(),secret,};let ek = store@@ -2734,7 +2748,7 @@ pub fn check_if_operation_confirm<Op: std::fmt::Debug>(operations: Op) -> bool {#[allow(clippy::too_many_arguments)]pub fn generate_mandate(- merchant_id: String,+ merchant_id: id_type::MerchantId,payment_id: String,connector: String,setup_mandate_details: Option<MandateData>,@@ -2912,7 +2926,7 @@ pub async fn verify_payment_intent_time_and_client_secret(.find_payment_intent_by_payment_id_merchant_id(&state.into(),&payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,merchant_account.storage_scheme,)@@ -3010,7 +3024,7 @@ mod tests {fn test_authenticate_client_secret_session_not_expired() {let payment_intent = PaymentIntent {payment_id: "23".to_string(),- merchant_id: "22".to_string(),+ merchant_id: id_type::MerchantId::default(),status: storage_enums::IntentStatus::RequiresCapture,amount: MinorUnit::new(200),currency: None,@@ -3075,7 +3089,7 @@ mod tests {common_utils::date_time::now().saturating_sub(time::Duration::seconds(20 * 60));let payment_intent = PaymentIntent {payment_id: "23".to_string(),- merchant_id: "22".to_string(),+ merchant_id: id_type::MerchantId::default(),status: storage_enums::IntentStatus::RequiresCapture,amount: MinorUnit::new(200),currency: None,@@ -3136,7 +3150,7 @@ mod tests {fn test_authenticate_client_secret_expired() {let payment_intent = PaymentIntent {payment_id: "23".to_string(),- merchant_id: "22".to_string(),+ merchant_id: id_type::MerchantId::default(),status: storage_enums::IntentStatus::RequiresCapture,amount: MinorUnit::new(200),currency: None,@@ -3199,7 +3213,7 @@ mod tests {#[instrument(skip_all)]pub async fn insert_merchant_connector_creds_to_config(db: &dyn StorageInterface,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_connector_details: admin::MerchantConnectorDetailsWrap,) -> RouterResult<()> {if let Some(encoded_data) = merchant_connector_details.encoded_data {@@ -3208,10 +3222,8 @@ pub async fn insert_merchant_connector_creds_to_config(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to get redis connection")?;- let key = format!(- "mcd_{merchant_id}_{}",- merchant_connector_details.creds_identifier- );+ let key =+ merchant_id.get_creds_identifier_key(&merchant_connector_details.creds_identifier);redis.serialize_and_set_key_with_expiry(@@ -3306,7 +3318,7 @@ impl MerchantConnectorAccountType {#[instrument(skip_all)]pub async fn get_merchant_connector_account(state: &SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,creds_identifier: Option<String>,key_store: &domain::MerchantKeyStore,profile_id: &String,@@ -3317,31 +3329,32 @@ pub async fn get_merchant_connector_account(let key_manager_state = &state.into();match creds_identifier {Some(creds_identifier) => {- let key = format!("mcd_{merchant_id}_{creds_identifier}");+ let key = merchant_id.get_creds_identifier_key(&creds_identifier);+ let cloned_key = key.clone();let redis_fetch = || async {db.get_redis_conn().change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to get redis connection").async_and_then(|redis| async move {redis- .get_and_deserialize_key(key.as_str(), "String")+ .get_and_deserialize_key(key.clone().as_str(), "String").await.change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {id: key.clone(),},)- .attach_printable(key + ": Not found in Redis")+ .attach_printable(key.clone() + ": Not found in Redis")}).await};let db_fetch = || async {- db.find_config_by_key(format!("mcd_{merchant_id}_{creds_identifier}").as_str())+ db.find_config_by_key(cloned_key.as_str()).await.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {- id: format!("mcd_{merchant_id}_{creds_identifier}"),+ id: cloned_key.to_owned(),},)};@@ -3494,7 +3507,10 @@ pub fn get_attempt_type(metrics::MANUAL_RETRY_REQUEST_COUNT.add(&metrics::CONTEXT,1,- &add_attributes([("merchant_id", payment_attempt.merchant_id.clone())]),+ &add_attributes([(+ "merchant_id",+ payment_attempt.merchant_id.get_string_repr().to_owned(),+ )]),);match payment_attempt.status {enums::AttemptStatus::Started@@ -3518,7 +3534,10 @@ pub fn get_attempt_type(metrics::MANUAL_RETRY_VALIDATION_FAILED.add(&metrics::CONTEXT,1,- &add_attributes([("merchant_id", payment_attempt.merchant_id.clone())]),+ &add_attributes([(+ "merchant_id",+ payment_attempt.merchant_id.get_string_repr().to_owned(),+ )]),);Err(errors::ApiErrorResponse::InternalServerError).attach_printable("Payment Attempt unexpected state")@@ -3530,7 +3549,10 @@ pub fn get_attempt_type(metrics::MANUAL_RETRY_VALIDATION_FAILED.add(&metrics::CONTEXT,1,- &add_attributes([("merchant_id", payment_attempt.merchant_id.clone())]),+ &add_attributes([(+ "merchant_id",+ payment_attempt.merchant_id.get_string_repr().to_owned(),+ )]),);Err(report!(errors::ApiErrorResponse::PreconditionFailed {message:@@ -3545,7 +3567,10 @@ pub fn get_attempt_type(metrics::MANUAL_RETRY_COUNT.add(&metrics::CONTEXT,1,- &add_attributes([("merchant_id", payment_attempt.merchant_id.clone())]),+ &add_attributes([(+ "merchant_id",+ payment_attempt.merchant_id.get_string_repr().to_owned(),+ )]),);Ok(AttemptType::New)}@@ -3751,7 +3776,7 @@ pub fn is_manual_retry_allowed(intent_status: &storage_enums::IntentStatus,attempt_status: &storage_enums::AttemptStatus,connector_request_reference_id_config: &ConnectorRequestReferenceIdConfig,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> Option<bool> {let is_payment_status_eligible_for_retry = match intent_status {enums::IntentStatus::Failed => match attempt_status {@@ -4201,7 +4226,7 @@ wherelet merchant_connector_account_type = get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),payment_data.creds_identifier.to_owned(),key_store,profile_id,@@ -4221,7 +4246,7 @@ where.store.find_merchant_connector_account_by_merchant_id_and_disabled_list(&state.into(),- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),false,key_store,)@@ -5002,7 +5027,10 @@ pub async fn get_payment_external_authentication_flow_during_confirm<F: Clone>(})}-pub fn get_redis_key_for_extended_card_info(merchant_id: &str, payment_id: &str) -> String {+pub fn get_redis_key_for_extended_card_info(+ merchant_id: &id_type::MerchantId,+ payment_id: &str,+) -> String {format!("{merchant_id}_{payment_id}_extended_card_info")}@@ -5037,11 +5065,11 @@ wherepub async fn config_skip_saving_wallet_at_connector(db: &dyn StorageInterface,- merchant_id: &String,+ merchant_id: &id_type::MerchantId,) -> CustomResult<Option<Vec<storage_enums::PaymentMethodType>>, errors::ApiErrorResponse> {let config = db.find_config_by_key_unwrap_or(- format!("skip_saving_wallet_at_connector_{}", merchant_id).as_str(),+ &merchant_id.get_skip_saving_wallet_at_connector_key(),Some("[]".to_string()),).await;@@ -5084,7 +5112,7 @@ pub async fn validate_merchant_connector_ids_in_connector_mandate_details(state: &SessionState,key_store: &domain::MerchantKeyStore,connector_mandate_details: &api_models::payment_methods::PaymentsMandateReference,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,card_network: Option<api_enums::CardNetwork>,) -> CustomResult<(), errors::ApiErrorResponse> {let db = &*state.store;diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rsindex 70cc77aa53..336755c6e3 100644--- a/crates/router/src/core/payments/operations.rs+++ b/crates/router/src/core/payments/operations.rs@@ -72,8 +72,8 @@ pub trait Operation<F: Clone, T>: Send + std::fmt::Debug {}#[derive(Clone)]-pub struct ValidateResult<'a> {- pub merchant_id: &'a str,+pub struct ValidateResult {+ pub merchant_id: common_utils::id_type::MerchantId,pub payment_id: api::PaymentIdType,pub storage_scheme: enums::MerchantStorageScheme,pub requeue: bool,@@ -81,11 +81,11 @@ pub struct ValidateResult<'a> {#[allow(clippy::type_complexity)]pub trait ValidateRequest<F, R> {- fn validate_request<'a, 'b>(+ fn validate_request<'b>(&'b self,request: &R,- merchant_account: &'a domain::MerchantAccount,- ) -> RouterResult<(BoxedOperation<'b, F, R>, ValidateResult<'a>)>;+ merchant_account: &domain::MerchantAccount,+ ) -> RouterResult<(BoxedOperation<'b, F, R>, ValidateResult)>;}pub struct GetTrackerResponse<'a, F: Clone, R> {diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rsindex 5b18512fe2..3cbcc0bb83 100644--- a/crates/router/src/core/payments/operations/payment_approve.rs+++ b/crates/router/src/core/payments/operations/payment_approve.rs@@ -43,7 +43,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCaptureRequest>_payment_confirm_source: Option<common_enums::PaymentSource>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsCaptureRequest>> {let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let (mut payment_intent, payment_attempt, currency, amount);@@ -131,11 +131,11 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCaptureRequest>payment_intent.billing_address_id = billing_address.clone().map(|i| i.address_id);let frm_response = db- .find_fraud_check_by_payment_id(payment_intent.payment_id.clone(), merchant_account.merchant_id.clone())+ .find_fraud_check_by_payment_id(payment_intent.payment_id.clone(), merchant_account.get_id().clone()).await.change_context(errors::ApiErrorResponse::PaymentNotFound).attach_printable_lazy(|| {- format!("Error while retrieving frm_response, merchant_id: {}, payment_id: {attempt_id}", &merchant_account.merchant_id)+ format!("Error while retrieving frm_response, merchant_id: {}, payment_id: {attempt_id}", merchant_account.get_id().get_string_repr())});let payment_data = PaymentData {@@ -261,10 +261,10 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsCaptureRequest> for Paymenmerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsCaptureRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {- let request_merchant_id = request.merchant_id.as_deref();- helpers::validate_merchant_id(&merchant_account.merchant_id, request_merchant_id)+ let request_merchant_id = request.merchant_id.as_ref();+ helpers::validate_merchant_id(merchant_account.get_id(), request_merchant_id).change_context(errors::ApiErrorResponse::InvalidDataFormat {field_name: "merchant_id".to_string(),expected_format: "merchant_id from merchant account".to_string(),@@ -273,7 +273,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsCaptureRequest> for PaymenOk((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: api::PaymentIdType::PaymentIntentId(crate::core::utils::validate_id(request.payment_id.clone(),"payment_id",diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rsindex a8a2756a58..4e771659a8 100644--- a/crates/router/src/core/payments/operations/payment_cancel.rs+++ b/crates/router/src/core/payments/operations/payment_cancel.rs@@ -43,7 +43,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCancelRequest>_payment_confirm_source: Option<common_enums::PaymentSource>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsCancelRequest>> {let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let payment_id = payment_id.get_payment_intent_id()@@ -129,7 +129,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCancelRequest>.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),mcd,).await@@ -288,12 +288,12 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsCancelRequest> for Paymentmerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsCancelRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {Ok((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: api::PaymentIdType::PaymentIntentId(request.payment_id.to_owned()),storage_scheme: merchant_account.storage_scheme,requeue: false,diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rsindex 03a3d031e1..cc94201622 100644--- a/crates/router/src/core/payments/operations/payment_capture.rs+++ b/crates/router/src/core/payments/operations/payment_capture.rs@@ -44,7 +44,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentData<F>, api::PaymentsCaptu_payment_confirm_source: Option<common_enums::PaymentSource>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsCaptureRequest>> {let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let (payment_intent, mut payment_attempt, currency, amount);@@ -175,7 +175,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentData<F>, api::PaymentsCaptu.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),mcd,).await@@ -323,12 +323,12 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsCaptureRequest> for Paymenmerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsCaptureRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {Ok((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: api::PaymentIdType::PaymentIntentId(request.payment_id.to_owned()),storage_scheme: merchant_account.storage_scheme,requeue: false,diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex c687539275..664a7c9bb0 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -45,7 +45,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co_payment_confirm_source: Option<common_enums::PaymentSource>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest>> {let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let (mut payment_intent, mut payment_attempt, currency, amount);@@ -203,7 +203,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Costate,request.shipping.as_ref(),payment_intent.shipping_address_id.clone().as_deref(),- merchant_id.as_ref(),+ merchant_id,payment_intent.customer_id.as_ref(),key_store,payment_id.as_ref(),@@ -500,15 +500,15 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for CompleteAuthomerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {let payment_id = request.payment_id.clone().ok_or(report!(errors::ApiErrorResponse::PaymentNotFound))?;- let request_merchant_id = request.merchant_id.as_deref();- helpers::validate_merchant_id(&merchant_account.merchant_id, request_merchant_id)+ let request_merchant_id = request.merchant_id.as_ref();+ helpers::validate_merchant_id(merchant_account.get_id(), request_merchant_id).change_context(errors::ApiErrorResponse::InvalidDataFormat {field_name: "merchant_id".to_string(),expected_format: "merchant_id from merchant account".to_string(),@@ -528,7 +528,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for CompleteAuthoOk((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: payment_id.and_then(|id| core_utils::validate_id(id, "payment_id"))?,storage_scheme: merchant_account.storage_scheme,requeue: matches!(diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex ad3f8fb013..52d76289d8 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -61,7 +61,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Paauth_flow: services::AuthFlow,payment_confirm_source: Option<common_enums::PaymentSource>,) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest>> {- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let (currency, amount);@@ -78,7 +78,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa.find_payment_intent_by_payment_id_merchant_id(&state.into(),&payment_id,- m_merchant_id.as_str(),+ &m_merchant_id,key_store,storage_scheme,)@@ -168,7 +168,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pastore.find_payment_attempt_by_payment_id_merchant_id_attempt_id(m_payment_id.as_str(),- m_merchant_id.as_str(),+ &m_merchant_id,attempt_id.as_str(),storage_scheme,)@@ -193,7 +193,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa&session_state,m_request_shipping.as_ref(),m_payment_intent_shipping_address_id.as_deref(),- m_merchant_id.as_str(),+ &m_merchant_id,m_payment_intent_customer_id.as_ref().or(m_customer_details_customer_id.as_ref()),@@ -221,7 +221,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa&session_state,m_request_billing.as_ref(),m_payment_intent_billing_address_id.as_deref(),- m_merchant_id.as_ref(),+ &m_merchant_id,m_payment_intent_customer_id.as_ref().or(m_customer_details_customer_id.as_ref()),@@ -244,7 +244,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(store.as_ref(),- m_merchant_id.as_str(),+ &m_merchant_id,mcd,).await@@ -489,7 +489,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa&session_state,n_request_payment_method_billing_address.as_ref(),n_payment_method_billing_address_id.as_deref(),- m_merchant_id.as_str(),+ &m_merchant_id,m_payment_intent_customer_id.as_ref().or(m_customer_details_customer_id.as_ref()),@@ -1390,7 +1390,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentConfirmerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {helpers::validate_customer_information(request)?;@@ -1398,8 +1398,8 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentConfirhelpers::validate_max_amount(amount)?;}- let request_merchant_id = request.merchant_id.as_deref();- helpers::validate_merchant_id(&merchant_account.merchant_id, request_merchant_id)+ let request_merchant_id = request.merchant_id.as_ref();+ helpers::validate_merchant_id(merchant_account.get_id(), request_merchant_id).change_context(errors::ApiErrorResponse::InvalidDataFormat {field_name: "merchant_id".to_string(),expected_format: "merchant_id from merchant account".to_string(),@@ -1434,7 +1434,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentConfirOk((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: payment_id.and_then(|id| core_utils::validate_id(id, "payment_id"))?,storage_scheme: merchant_account.storage_scheme,requeue: matches!(diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex c3fc3adcb2..b7f86b6838 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -70,7 +70,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest>> {let db = &*state.store;let ephemeral_key = Self::get_ephemeral_key(request, state, merchant_account).await;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let (payment_intent, payment_attempt);@@ -236,7 +236,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pacreate_payment_link(request,payment_link_config,- merchant_id.clone(),+ merchant_id,payment_id.clone(),db,amount,@@ -392,7 +392,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),mcd,).await@@ -697,7 +697,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentCreatemerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {helpers::validate_customer_information(request)?;@@ -718,8 +718,8 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentCreateerrors::ApiErrorResponse::PaymentNotFound))?;- let request_merchant_id = request.merchant_id.as_deref();- helpers::validate_merchant_id(&merchant_account.merchant_id, request_merchant_id)+ let request_merchant_id = request.merchant_id.as_ref();+ helpers::validate_merchant_id(merchant_account.get_id(), request_merchant_id).change_context(errors::ApiErrorResponse::MerchantAccountNotFound)?;helpers::validate_request_amount_and_amount_to_capture(@@ -782,7 +782,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentCreateOk((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id,storage_scheme: merchant_account.storage_scheme,requeue: matches!(@@ -799,7 +799,7 @@ impl PaymentCreate {#[allow(clippy::too_many_arguments)]pub async fn make_payment_attempt(payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,money: (api::Amount, enums::Currency),payment_method: Option<enums::PaymentMethod>,payment_method_type: Option<enums::PaymentMethodType>,@@ -924,7 +924,7 @@ impl PaymentCreate {Ok((storage::PaymentAttemptNew {payment_id: payment_id.to_string(),- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),attempt_id,status,currency,@@ -1116,7 +1116,7 @@ impl PaymentCreate {Ok(storage::PaymentIntent {payment_id: payment_id.to_string(),- merchant_id: merchant_account.merchant_id.to_string(),+ merchant_id: merchant_account.get_id().to_owned(),status,amount: MinorUnit::from(amount),currency,@@ -1178,7 +1178,7 @@ impl PaymentCreate {Some(customer_id) => helpers::make_ephemeral_key(state.clone(),customer_id.clone(),- merchant_account.merchant_id.clone(),+ merchant_account.get_id().to_owned().clone(),).await.ok()@@ -1207,7 +1207,7 @@ pub fn payments_create_request_validation(async fn create_payment_link(request: &api::PaymentsRequest,payment_link_config: api_models::admin::PaymentLinkConfig,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: String,db: &dyn StorageInterface,amount: api::Amount,@@ -1221,7 +1221,7 @@ async fn create_payment_link(let payment_link = format!("{}/payment_link/{}/{}",domain_name,- merchant_id.clone(),+ merchant_id.get_string_repr(),payment_id.clone());diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rsindex a83079a6a4..4e46791c8e 100644--- a/crates/router/src/core/payments/operations/payment_reject.rs+++ b/crates/router/src/core/payments/operations/payment_reject.rs@@ -40,7 +40,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, PaymentsCancelRequest> for P_payment_confirm_source: Option<common_enums::PaymentSource>,) -> RouterResult<operations::GetTrackerResponse<'a, F, PaymentsCancelRequest>> {let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let payment_id = payment_id.get_payment_intent_id()@@ -113,11 +113,11 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, PaymentsCancelRequest> for Plet amount = payment_attempt.get_total_amount().into();let frm_response = db- .find_fraud_check_by_payment_id(payment_intent.payment_id.clone(), merchant_account.merchant_id.clone())+ .find_fraud_check_by_payment_id(payment_intent.payment_id.clone(), merchant_account.get_id().clone()).await.change_context(errors::ApiErrorResponse::PaymentNotFound).attach_printable_lazy(|| {- format!("Error while retrieving frm_response, merchant_id: {}, payment_id: {attempt_id}", &merchant_account.merchant_id)+ format!("Error while retrieving frm_response, merchant_id: {}, payment_id: {attempt_id}", merchant_account.get_id())});let profile_id = payment_intent@@ -266,12 +266,12 @@ impl<F: Send + Clone> ValidateRequest<F, PaymentsCancelRequest> for PaymentRejecmerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, PaymentsCancelRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {Ok((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: api::PaymentIdType::PaymentIntentId(request.payment_id.to_owned()),storage_scheme: merchant_account.storage_scheme,requeue: false,diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 808b2ae618..a9449e38d2 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -1335,7 +1335,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(async move {mandate::update_connector_mandate_id(m_db.as_ref(),- m_router_data_merchant_id.clone(),+ &m_router_data_merchant_id,m_payment_data_mandate_id,m_payment_method_id,m_router_data_response,@@ -1372,7 +1372,14 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>("connector",payment_data.payment_attempt.connector.unwrap_or_default(),),- ("merchant_id", payment_data.payment_attempt.merchant_id),+ (+ "merchant_id",+ payment_data+ .payment_attempt+ .merchant_id+ .get_string_repr()+ .to_owned(),+ ),]),);Err(error_stack::Report::new(diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex 00f599d409..e65fcbc390 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -47,7 +47,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsSessionRequest>.change_context(errors::ApiErrorResponse::PaymentNotFound)?;let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let mut payment_intent = db@@ -139,7 +139,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsSessionRequest>.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),mcd,).await@@ -270,7 +270,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsSessionRequest> for Paymenmerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsSessionRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {//paymentid is already generated and should be sent in the requestlet given_payment_id = request.payment_id.clone();@@ -278,7 +278,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsSessionRequest> for PaymenOk((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: api::PaymentIdType::PaymentIntentId(given_payment_id),storage_scheme: merchant_account.storage_scheme,requeue: false,@@ -360,7 +360,7 @@ wherelet all_connector_accounts = db.find_merchant_connector_account_by_merchant_id_and_disabled_list(&state.into(),- &merchant_account.merchant_id,+ merchant_account.get_id(),false,key_store,)diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex 98befe122c..0172b5f264 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -42,7 +42,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsStartRequest> flet (mut payment_intent, payment_attempt, currency, amount);let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let payment_id = payment_id.get_payment_intent_id()@@ -236,10 +236,10 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsStartRequest> for PaymentSmerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsStartRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {- let request_merchant_id = Some(&request.merchant_id[..]);- helpers::validate_merchant_id(&merchant_account.merchant_id, request_merchant_id)+ let request_merchant_id = Some(&request.merchant_id);+ helpers::validate_merchant_id(merchant_account.get_id(), request_merchant_id).change_context(errors::ApiErrorResponse::InvalidDataFormat {field_name: "merchant_id".to_string(),expected_format: "merchant_id from merchant account".to_string(),@@ -250,7 +250,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsStartRequest> for PaymentSOk((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: api::PaymentIdType::PaymentIntentId(payment_id),storage_scheme: merchant_account.storage_scheme,requeue: false,diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rsindex fff096d9b4..a7ba54a377 100644--- a/crates/router/src/core/payments/operations/payment_status.rs+++ b/crates/router/src/core/payments/operations/payment_status.rs@@ -223,7 +223,7 @@ async fn get_tracker_for_sync<(payment_intent, payment_attempt) = get_payment_intent_payment_attempt(state,payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,storage_scheme,)@@ -241,7 +241,7 @@ async fn get_tracker_for_sync<payment_intent.shipping_address_id.clone(),key_store,&payment_intent.payment_id.clone(),- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await?;@@ -250,7 +250,7 @@ async fn get_tracker_for_sync<payment_intent.billing_address_id.clone(),key_store,&payment_intent.payment_id.clone(),- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await?;@@ -260,7 +260,7 @@ async fn get_tracker_for_sync<payment_attempt.payment_method_billing_address_id.clone(),key_store,&payment_intent.payment_id.clone(),- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await?;@@ -270,11 +270,11 @@ async fn get_tracker_for_sync<let attempts = match request.expand_attempts {Some(true) => {Some(db- .find_attempts_by_merchant_id_payment_id(&merchant_account.merchant_id, &payment_id_str, storage_scheme)+ .find_attempts_by_merchant_id_payment_id(merchant_account.get_id(), &payment_id_str, storage_scheme).await.change_context(errors::ApiErrorResponse::PaymentNotFound).attach_printable_lazy(|| {- format!("Error while retrieving attempt list for, merchant_id: {}, payment_id: {payment_id_str}",&merchant_account.merchant_id)+ format!("Error while retrieving attempt list for, merchant_id: {:?}, payment_id: {payment_id_str}",merchant_account.get_id())})?)},_ => None,@@ -291,7 +291,7 @@ async fn get_tracker_for_sync<.await.change_context(errors::ApiErrorResponse::PaymentNotFound).attach_printable_lazy(|| {- format!("Error while retrieving capture list for, merchant_id: {}, payment_id: {payment_id_str}", merchant_account.merchant_id)+ format!("Error while retrieving capture list for, merchant_id: {:?}, payment_id: {payment_id_str}", merchant_account.get_id())})?;Some(payment_types::MultipleCaptureData::new_for_sync(captures,@@ -304,46 +304,48 @@ async fn get_tracker_for_sync<let refunds = db.find_refund_by_payment_id_merchant_id(&payment_id_str,- &merchant_account.merchant_id,+ merchant_account.get_id(),storage_scheme,).await.change_context(errors::ApiErrorResponse::PaymentNotFound).attach_printable_lazy(|| {format!(- "Failed while getting refund list for, payment_id: {}, merchant_id: {}",- &payment_id_str, merchant_account.merchant_id+ "Failed while getting refund list for, payment_id: {}, merchant_id: {:?}",+ &payment_id_str,+ merchant_account.get_id())})?;let authorizations = db.find_all_authorizations_by_merchant_id_payment_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&payment_id_str,).await.change_context(errors::ApiErrorResponse::PaymentNotFound).attach_printable_lazy(|| {format!(- "Failed while getting authorizations list for, payment_id: {}, merchant_id: {}",- &payment_id_str, merchant_account.merchant_id+ "Failed while getting authorizations list for, payment_id: {}, merchant_id: {:?}",+ &payment_id_str,+ merchant_account.get_id())})?;let disputes = db- .find_disputes_by_merchant_id_payment_id(&merchant_account.merchant_id, &payment_id_str)+ .find_disputes_by_merchant_id_payment_id(merchant_account.get_id(), &payment_id_str).await.change_context(errors::ApiErrorResponse::PaymentNotFound).attach_printable_lazy(|| {- format!("Error while retrieving dispute list for, merchant_id: {}, payment_id: {payment_id_str}", &merchant_account.merchant_id)+ format!("Error while retrieving dispute list for, merchant_id: {:?}, payment_id: {payment_id_str}", merchant_account.get_id())})?;let frm_response = db- .find_fraud_check_by_payment_id(payment_id_str.to_string(), merchant_account.merchant_id.clone())+ .find_fraud_check_by_payment_id(payment_id_str.to_string(), merchant_account.get_id().clone()).await.change_context(errors::ApiErrorResponse::PaymentNotFound).attach_printable_lazy(|| {- format!("Error while retrieving frm_response, merchant_id: {}, payment_id: {payment_id_str}", &merchant_account.merchant_id)+ format!("Error while retrieving frm_response, merchant_id: {:?}, payment_id: {payment_id_str}", merchant_account.get_id())});let contains_encoded_data = payment_attempt.encoded_data.is_some();@@ -356,12 +358,8 @@ async fn get_tracker_for_sync<.merchant_connector_details.to_owned().async_map(|mcd| async {- helpers::insert_merchant_connector_creds_to_config(- db,- &merchant_account.merchant_id,- mcd,- )- .await+ helpers::insert_merchant_connector_creds_to_config(db, merchant_account.get_id(), mcd)+ .await}).await.transpose()?;@@ -405,7 +403,7 @@ async fn get_tracker_for_sync<let merchant_id = payment_intent.merchant_id.clone();let authentication = payment_attempt.authentication_id.clone().async_map(|authentication_id| async move {db.find_authentication_by_merchant_id_authentication_id(- merchant_id,+ &merchant_id,authentication_id.clone(),).await@@ -481,16 +479,16 @@ async fn get_tracker_for_sync<}impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRetrieveRequest> for PaymentStatus {- fn validate_request<'a, 'b>(+ fn validate_request<'b>(&'b self,request: &api::PaymentsRetrieveRequest,- merchant_account: &'a domain::MerchantAccount,+ merchant_account: &domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRetrieveRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {- let request_merchant_id = request.merchant_id.as_deref();- helpers::validate_merchant_id(&merchant_account.merchant_id, request_merchant_id)+ let request_merchant_id = request.merchant_id.as_ref();+ helpers::validate_merchant_id(merchant_account.get_id(), request_merchant_id).change_context(errors::ApiErrorResponse::InvalidDataFormat {field_name: "merchant_id".to_string(),expected_format: "merchant_id from merchant account".to_string(),@@ -499,7 +497,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRetrieveRequest> for PaymeOk((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: request.resource_id.clone(),storage_scheme: merchant_account.storage_scheme,requeue: false,@@ -511,7 +509,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRetrieveRequest> for Paymepub async fn get_payment_intent_payment_attempt(state: &SessionState,payment_id: &api::PaymentIdType,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: enums::MerchantStorageScheme,) -> RouterResult<(storage::PaymentIntent, storage::PaymentAttempt)> {diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex d7fcdf6e14..3a5cd00b9c 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -57,7 +57,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Palet payment_id = payment_id.get_payment_intent_id().change_context(errors::ApiErrorResponse::PaymentNotFound)?;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let db = &*state.store;@@ -393,7 +393,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),mcd,).await@@ -806,7 +806,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentUpdatemerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {helpers::validate_customer_information(request)?;@@ -821,8 +821,8 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentUpdate.clone().ok_or(report!(errors::ApiErrorResponse::PaymentNotFound))?;- let request_merchant_id = request.merchant_id.as_deref();- helpers::validate_merchant_id(&merchant_account.merchant_id, request_merchant_id)+ let request_merchant_id = request.merchant_id.as_ref();+ helpers::validate_merchant_id(merchant_account.get_id(), request_merchant_id).change_context(errors::ApiErrorResponse::InvalidDataFormat {field_name: "merchant_id".to_string(),expected_format: "merchant_id from merchant account".to_string(),@@ -861,7 +861,7 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentUpdateOk((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: payment_id.and_then(|id| core_utils::validate_id(id, "payment_id"))?,storage_scheme: merchant_account.storage_scheme,requeue: matches!(diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rsindex 20c2e051b6..c7311059ba 100644--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs@@ -48,7 +48,7 @@ impl<F: Send + Clone>) -> RouterResult<operations::GetTrackerResponse<'a, F, PaymentsIncrementalAuthorizationRequest>>{let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let storage_scheme = merchant_account.storage_scheme;let payment_id = payment_id.get_payment_intent_id()@@ -273,12 +273,12 @@ impl<F: Send + Clone> ValidateRequest<F, PaymentsIncrementalAuthorizationRequestmerchant_account: &'a domain::MerchantAccount,) -> RouterResult<(BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest>,- operations::ValidateResult<'a>,+ operations::ValidateResult,)> {Ok((Box::new(self),operations::ValidateResult {- merchant_id: &merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),payment_id: api::PaymentIdType::PaymentIntentId(request.payment_id.to_owned()),storage_scheme: merchant_account.storage_scheme,requeue: false,diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rsindex 99cb6aaec6..29512c2139 100644--- a/crates/router/src/core/payments/retry.rs+++ b/crates/router/src/core/payments/retry.rs@@ -41,7 +41,7 @@ pub async fn do_gsm_actions<F, ApiRequest, FData>(key_store: &domain::MerchantKeyStore,operation: &operations::BoxedOperation<'_, F, ApiRequest>,customer: &Option<domain::Customer>,- validate_result: &operations::ValidateResult<'_>,+ validate_result: &operations::ValidateResult,schedule_time: Option<time::PrimitiveDateTime>,frm_suggestion: Option<storage_enums::FrmSuggestion>,business_profile: &storage::business_profile::BusinessProfile,@@ -73,7 +73,7 @@ wherelet should_step_up = if step_up_possible && is_no_three_ds_payment {is_step_up_enabled_for_merchant_connector(state,- &merchant_account.merchant_id,+ merchant_account.get_id(),original_connector_data.connector_name,).await@@ -111,7 +111,7 @@ wherematch get_gsm_decision(gsm) {api_models::gsm::GsmDecision::Retry => {- retries = get_retries(state, retries, &merchant_account.merchant_id).await;+ retries = get_retries(state, retries, merchant_account.get_id()).await;if retries.is_none() || retries == Some(0) {metrics::AUTO_RETRY_EXHAUSTED_COUNT.add(&metrics::CONTEXT, 1, &[]);@@ -166,10 +166,10 @@ where#[instrument(skip_all)]pub async fn is_step_up_enabled_for_merchant_connector(state: &app::SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: types::Connector,) -> bool {- let key = format!("step_up_enabled_{merchant_id}");+ let key = merchant_id.get_step_up_enabled_key();let db = &*state.store;db.find_config_by_key_unwrap_or(key.as_str(), Some("[]".to_string())).await@@ -191,12 +191,13 @@ pub async fn is_step_up_enabled_for_merchant_connector(pub async fn get_retries(state: &app::SessionState,retries: Option<i32>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> Option<i32> {match retries {Some(retries) => Some(retries),None => {- let key = format!("max_auto_retries_enabled_{merchant_id}");+ let key = merchant_id.get_max_auto_retries_enabled();+let db = &*state.store;db.find_config_by_key(key.as_str()).await@@ -278,7 +279,7 @@ pub async fn do_retry<F, ApiRequest, FData>(key_store: &domain::MerchantKeyStore,payment_data: &mut payments::PaymentData<F>,router_data: types::RouterData<F, FData, types::PaymentsResponseData>,- validate_result: &operations::ValidateResult<'_>,+ validate_result: &operations::ValidateResult,schedule_time: Option<time::PrimitiveDateTime>,is_step_up: bool,frm_suggestion: Option<storage_enums::FrmSuggestion>,@@ -534,10 +535,13 @@ pub fn make_new_payment_attempt(}}-pub async fn config_should_call_gsm(db: &dyn StorageInterface, merchant_id: &String) -> bool {+pub async fn config_should_call_gsm(+ db: &dyn StorageInterface,+ merchant_id: &common_utils::id_type::MerchantId,+) -> bool {let config = db.find_config_by_key_unwrap_or(- format!("should_call_gsm_{}", merchant_id).as_str(),+ &merchant_id.get_should_call_gsm_key(),Some("false".to_string()),).await;diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rsindex ff9f6ddbf3..151192fb8b 100644--- a/crates/router/src/core/payments/routing.rs+++ b/crates/router/src/core/payments/routing.rs@@ -252,7 +252,7 @@ wherepub async fn perform_static_routing_v1<F: Clone>(state: &SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,algorithm_ref: routing_types::RoutingAlgorithmRef,transaction_data: &routing::TransactionData<'_, F>,) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {@@ -312,7 +312,7 @@ pub async fn perform_static_routing_v1<F: Clone>(async fn ensure_algorithm_cached_v1(state: &SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,algorithm_id: &str,profile_id: Option<String>,transaction_type: &api_enums::TransactionType,@@ -324,12 +324,18 @@ async fn ensure_algorithm_cached_v1(.change_context(errors::RoutingError::ProfileIdMissing)?;match transaction_type {- api_enums::TransactionType::Payment => {- format!("routing_config_{merchant_id}_{profile_id}")+ common_enums::TransactionType::Payment => {+ format!(+ "routing_config_{}_{profile_id}",+ merchant_id.get_string_repr()+ )}#[cfg(feature = "payouts")]- api_enums::TransactionType::Payout => {- format!("routing_config_po_{merchant_id}_{profile_id}")+ common_enums::TransactionType::Payout => {+ format!(+ "routing_config_po_{}_{profile_id}",+ merchant_id.get_string_repr()+ )}}};@@ -492,10 +498,12 @@ pub async fn get_merchant_cgraph<'a>(.get_required_value("profile_id").change_context(errors::RoutingError::ProfileIdMissing)?;match transaction_type {- api_enums::TransactionType::Payment => format!("cgraph_{}_{}", merchant_id, profile_id),+ api_enums::TransactionType::Payment => {+ format!("cgraph_{}_{}", merchant_id.get_string_repr(), profile_id)+ }#[cfg(feature = "payouts")]api_enums::TransactionType::Payout => {- format!("cgraph_po_{}_{}", merchant_id, profile_id)+ format!("cgraph_po_{}_{}", merchant_id.get_string_repr(), profile_id)}}};diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rsindex 4016336713..144c7e87e2 100644--- a/crates/router/src/core/payments/tokenization.rs+++ b/crates/router/src/core/payments/tokenization.rs@@ -189,7 +189,7 @@ where).await?;let customer_id = customer_id.to_owned().get_required_value("customer_id")?;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let (mut resp, duplication_check) = if !state.conf.locker.locker_enabled {skip_saving_card_in_locker(merchant_account,@@ -411,7 +411,7 @@ where&resp,&payment_method_create_request.clone(),key_store,- &merchant_account.merchant_id,+ merchant_account.get_id(),&customer_id,resp.metadata.clone().map(|val| val.expose()),customer_acceptance,@@ -641,7 +641,7 @@ async fn skip_saving_card_in_locker(api_models::payment_methods::PaymentMethodResponse,Option<payment_methods::transformers::DataDuplicationCheck>,)> {- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let customer_id = payment_method_request.clone().customer_id@@ -679,7 +679,7 @@ async fn skip_saving_card_in_locker(saved_to_locker: false,};let pm_resp = api::PaymentMethodResponse {- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),customer_id: Some(customer_id),payment_method_id,payment_method: payment_method_request.payment_method,@@ -701,7 +701,7 @@ async fn skip_saving_card_in_locker(None => {let pm_id = common_utils::generate_id(consts::ID_LENGTH, "pm");let payment_method_response = api::PaymentMethodResponse {- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),customer_id: Some(customer_id),payment_method_id: pm_id,payment_method: payment_method_request.payment_method,@@ -731,7 +731,7 @@ pub async fn save_in_locker(Option<payment_methods::transformers::DataDuplicationCheck>,)> {payment_method_request.validate()?;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let customer_id = payment_method_request.customer_id.clone()@@ -751,7 +751,7 @@ pub async fn save_in_locker(None => {let pm_id = common_utils::generate_id(consts::ID_LENGTH, "pm");let payment_method_response = api::PaymentMethodResponse {- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.clone(),customer_id: Some(customer_id),payment_method_id: pm_id,payment_method: payment_method_request.payment_method,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 4df4880653..f28dd10fc9 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -142,7 +142,7 @@ whererouter_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),customer_id,connector: connector_id.to_owned(),payment_id: payment_data.payment_attempt.payment_id.clone(),@@ -186,7 +186,7 @@ whererecurring_mandate_payment_data: payment_data.recurring_mandate_payment_data,connector_request_reference_id: core_utils::get_connector_request_reference_id(&state.conf,- &merchant_account.merchant_id,+ merchant_account.get_id(),&payment_data.payment_attempt,),preprocessing_id: payment_data.payment_attempt.preprocessing_step_id,@@ -900,7 +900,7 @@ where1,&add_attributes([("operation", format!("{:?}", operation)),- ("merchant", merchant_id),+ ("merchant", merchant_id.get_string_repr().to_owned()),("payment_method_type", payment_method_type),("payment_method", payment_method),]),diff --git a/crates/router/src/core/payout_link.rs b/crates/router/src/core/payout_link.rsindex 78ff9900f6..d4dd01b4dd 100644--- a/crates/router/src/core/payout_link.rs+++ b/crates/router/src/core/payout_link.rs@@ -32,7 +32,7 @@ pub async fn initiate_payout_link(request_headers: &header::HeaderMap,) -> RouterResponse<services::GenericLinkFormData> {let db: &dyn StorageInterface = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();// Fetch payoutlet payout = db.find_payout_by_merchant_id_payout_id(@@ -270,7 +270,7 @@ pub async fn filter_payout_methods(let all_mcas = db.find_merchant_connector_account_by_merchant_id_and_disabled_list(key_manager_state,- &merchant_account.merchant_id,+ merchant_account.get_id(),false,key_store,)diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex 6db3c1edf4..3f6cfd1174 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -6,6 +6,8 @@ pub mod validator;use std::vec::IntoIter;use api_models::{self, admin, enums as api_enums, payouts::PayoutLinkResponse};+#[cfg(feature = "payout_retry")]+use common_enums::PayoutRetryType;use common_utils::{consts,crypto::Encryptable,@@ -178,8 +180,8 @@ pub async fn make_connector_decision({let config_bool = retry::config_should_call_gsm_payout(&*state.store,- &merchant_account.merchant_id,- retry::PayoutRetryType::SingleConnector,+ merchant_account.get_id(),+ PayoutRetryType::SingleConnector,).await;@@ -215,8 +217,8 @@ pub async fn make_connector_decision({let config_multiple_connector_bool = retry::config_should_call_gsm_payout(&*state.store,- &merchant_account.merchant_id,- retry::PayoutRetryType::MultiConnector,+ merchant_account.get_id(),+ PayoutRetryType::MultiConnector,).await;@@ -234,8 +236,8 @@ pub async fn make_connector_decision(let config_single_connector_bool = retry::config_should_call_gsm_payout(&*state.store,- &merchant_account.merchant_id,- retry::PayoutRetryType::SingleConnector,+ merchant_account.get_id(),+ PayoutRetryType::SingleConnector,).await;@@ -709,7 +711,7 @@ pub async fn payouts_list_core(constraints: payouts::PayoutListConstraints,) -> RouterResponse<payouts::PayoutListResponse> {validator::validate_payout_list_request(&constraints)?;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let db = state.store.as_ref();let payouts = helpers::filter_by_constraints(db,@@ -815,7 +817,7 @@ pub async fn payouts_filtered_list_core(diesel_models::Customer,)> = db.filter_payouts_and_attempts(- &merchant_account.merchant_id,+ merchant_account.get_id(),&filters.clone().into(),merchant_account.storage_scheme,)@@ -827,7 +829,7 @@ pub async fn payouts_filtered_list_core(&(&state).into(),c,&key_store.key,- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await{@@ -865,7 +867,7 @@ pub async fn payouts_list_available_filters_core(let db = state.store.as_ref();let payout = db.filter_payouts_by_time_range_constraints(- &merchant_account.merchant_id,+ merchant_account.get_id(),&time_range,merchant_account.storage_scheme,)@@ -875,7 +877,7 @@ pub async fn payouts_list_available_filters_core(let filters = db.get_filters_for_payouts(payout.as_slice(),- &merchant_account.merchant_id,+ merchant_account.get_id(),storage_enums::MerchantStorageScheme::PostgresOnly,).await@@ -1081,7 +1083,7 @@ pub async fn create_recipient(let db = &*state.store;if let Some(customer) = customer_details {let customer_id = customer.customer_id.to_owned();- let merchant_id = merchant_account.merchant_id.to_owned();+ let merchant_id = merchant_account.get_id().to_owned();if let Some(updated_customer) =customers::update_connector_customer_in_customers(&connector_label,@@ -2092,7 +2094,7 @@ pub async fn response_handler(let response = api::PayoutCreateResponse {payout_id: payouts.payout_id.to_owned(),- merchant_id: merchant_account.merchant_id.to_owned(),+ merchant_id: merchant_account.get_id().to_owned(),amount: payouts.amount,currency: payouts.destination_currency.to_owned(),connector: payout_attempt.connector.to_owned(),@@ -2146,7 +2148,7 @@ pub async fn payout_create_db_entries(stored_payout_method_data: Option<&payouts::PayoutMethodData>,) -> RouterResult<PayoutData> {let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();// Get or create customerlet customer_details = payments::CustomerDetails {@@ -2182,7 +2184,7 @@ pub async fn payout_create_db_entries(state,&business_profile,&customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),req,payout_id,)@@ -2240,7 +2242,7 @@ pub async fn payout_create_db_entries(let payouts_req = storage::PayoutsNew {payout_id: payout_id.to_string(),- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),customer_id: customer_id.to_owned(),address_id: address_id.to_owned(),payout_type,@@ -2326,7 +2328,7 @@ pub async fn make_payout_data(req: &payouts::PayoutRequest,) -> RouterResult<PayoutData> {let db = &*state.store;- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let payout_id = match req {payouts::PayoutRequest::PayoutActionRequest(r) => r.payout_id.clone(),payouts::PayoutRequest::PayoutCreateRequest(r) => r.payout_id.clone().unwrap_or_default(),@@ -2395,7 +2397,7 @@ pub async fn make_payout_data(None,Some(&payout_token),&customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),payouts.payout_type,key_store,None,@@ -2471,7 +2473,7 @@ pub async fn add_external_account_addition_task(async fn validate_and_get_business_profile(state: &SessionState,profile_id: &String,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> RouterResult<storage::BusinessProfile> {let db = &*state.store;if let Some(business_profile) =@@ -2492,7 +2494,7 @@ pub async fn create_payout_link(state: &SessionState,business_profile: &storage::BusinessProfile,customer_id: &CustomerId,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,req: &payouts::PayoutCreateRequest,payout_id: &String,) -> RouterResult<PayoutLink> {@@ -2548,7 +2550,10 @@ pub async fn create_payout_link(.session_expiry.as_ref().map_or(default_config.expiry, |expiry| *expiry);- let url = format!("{base_url}/payout_link/{merchant_id}/{payout_id}");+ let url = format!(+ "{base_url}/payout_link/{}/{payout_id}",+ merchant_id.get_string_repr()+ );let link = url::Url::parse(&url).change_context(errors::ApiErrorResponse::InternalServerError).attach_printable_lazy(|| format!("Failed to form payout link URL - {}", url))?;@@ -2592,7 +2597,7 @@ pub async fn create_payout_link(pub async fn create_payout_link_db_entry(state: &SessionState,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,payout_link_data: &PayoutLinkData,return_url: Option<String>,) -> RouterResult<PayoutLink> {@@ -2605,7 +2610,7 @@ pub async fn create_payout_link_db_entry(let payout_link = GenericLinkNew {link_id: payout_link_data.payout_link_id.to_string(),primary_reference: payout_link_data.payout_id.to_string(),- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),link_type: common_enums::GenericLinkType::PayoutLink,link_status: GenericLinkStatus::PayoutLink(PayoutLinkStatus::Initiated),link_data,diff --git a/crates/router/src/core/payouts/access_token.rs b/crates/router/src/core/payouts/access_token.rsindex c70f3c3667..b7f52b259c 100644--- a/crates/router/src/core/payouts/access_token.rs+++ b/crates/router/src/core/payouts/access_token.rs@@ -61,7 +61,7 @@ pub async fn add_access_token_for_payout<F: Clone + 'static>(.connector_name.supports_access_token_for_payout(payout_type){- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let store = &*state.store;let old_access_token = store.get_access_token(merchant_id, connector.connector.id())diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rsindex c3aa128f2f..41229552ad 100644--- a/crates/router/src/core/payouts/helpers.rs+++ b/crates/router/src/core/payouts/helpers.rs@@ -50,7 +50,7 @@ pub async fn make_payout_method_data<'a>(payout_method_data: Option<&api::PayoutMethodData>,payout_token: Option<&str>,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payout_type: Option<api_enums::PayoutType>,merchant_key_store: &domain::MerchantKeyStore,payout_data: Option<&mut PayoutData>,@@ -213,7 +213,7 @@ pub async fn save_payout_data_to_locker(card_type: None,};let payload = StoreLockerReq::LockerCard(StoreCardReq {- merchant_id: merchant_account.merchant_id.as_ref(),+ merchant_id: merchant_account.get_id().clone(),merchant_customer_id: payout_attempt.customer_id.to_owned(),card: Card {card_number: card.card_number.to_owned(),@@ -266,7 +266,7 @@ pub async fn save_payout_data_to_locker(Ok(hex::encode(e.peek()))})?;let payload = StoreLockerReq::LockerGeneric(StoreGenericReq {- merchant_id: merchant_account.merchant_id.as_ref(),+ merchant_id: merchant_account.get_id().to_owned(),merchant_customer_id: payout_attempt.customer_id.to_owned(),enc_data,ttl: state.conf.locker.ttl_for_storage_in_secs,@@ -506,7 +506,7 @@ pub async fn save_payout_data_to_locker(&payout_attempt.customer_id,&payment_method_id,Some(stored_resp.card_reference.clone()),- &merchant_account.merchant_id,+ merchant_account.get_id(),None,None,card_details_encrypted.clone().map(Into::into),@@ -535,7 +535,7 @@ pub async fn save_payout_data_to_locker(cards::delete_card_from_hs_locker(state,&payout_attempt.customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),card_reference,).await@@ -559,7 +559,7 @@ 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(- &merchant_account.merchant_id,+ merchant_account.get_id(),&existing_pm.payment_method_id,).await@@ -611,7 +611,7 @@ pub async fn get_or_create_customer_details(.clone().unwrap_or_else(generate_customer_id_of_default_length);- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();let key = key_store.key.get_inner().peek();let key_manager_state = &state.into();@@ -646,7 +646,7 @@ pub async fn get_or_create_customer_details(let customer = domain::Customer {customer_id,- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned().clone(),name: encryptable_customer.name,email: encryptable_customer.email,phone: encryptable_customer.phone,@@ -964,7 +964,7 @@ pub fn is_eligible_for_local_payout_cancellation(status: api_enums::PayoutStatuspub(super) async fn filter_by_constraints(db: &dyn StorageInterface,constraints: &api::PayoutListConstraints,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: storage::enums::MerchantStorageScheme,) -> CustomResult<Vec<storage::Payouts>, errors::DataStorageError> {let result = dbdiff --git a/crates/router/src/core/payouts/retry.rs b/crates/router/src/core/payouts/retry.rsindex fa61ab8a22..284f81a170 100644--- a/crates/router/src/core/payouts/retry.rs+++ b/crates/router/src/core/payouts/retry.rs@@ -1,5 +1,6 @@use std::{cmp::Ordering, str::FromStr, vec::IntoIter};+use common_enums::PayoutRetryType;use error_stack::{report, ResultExt};use router_env::{logger,@@ -18,13 +19,6 @@ use crate::{utils,};-#[derive(Clone, Debug, serde::Serialize)]-#[serde(rename_all = "snake_case")]-pub enum PayoutRetryType {- SingleConnector,- MultiConnector,-}-#[instrument(skip_all)]#[allow(clippy::too_many_arguments)]pub async fn do_gsm_multiple_connector_actions(@@ -49,7 +43,7 @@ pub async fn do_gsm_multiple_connector_actions(retries = get_retries(state,retries,- &merchant_account.merchant_id,+ merchant_account.get_id(),PayoutRetryType::MultiConnector,).await;@@ -121,7 +115,7 @@ pub async fn do_gsm_single_connector_actions(retries = get_retries(state,retries,- &merchant_account.merchant_id,+ merchant_account.get_id(),PayoutRetryType::SingleConnector,).await;@@ -160,20 +154,13 @@ pub async fn do_gsm_single_connector_actions(pub async fn get_retries(state: &app::SessionState,retries: Option<i32>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,retry_type: PayoutRetryType,) -> Option<i32> {match retries {Some(retries) => Some(retries),None => {- let key = match retry_type {- PayoutRetryType::SingleConnector => {- format!("max_auto_single_connector_payout_retries_enabled_{merchant_id}")- }- PayoutRetryType::MultiConnector => {- format!("max_auto_multiple_connector_payout_retries_enabled_{merchant_id}")- }- };+ let key = merchant_id.get_max_auto_single_connector_payout_retries_enabled(retry_type);let db = &*state.store;db.find_config_by_key(key.as_str()).await@@ -318,17 +305,10 @@ pub async fn modify_trackers(pub async fn config_should_call_gsm_payout(db: &dyn StorageInterface,- merchant_id: &String,+ merchant_id: &common_utils::id_type::MerchantId,retry_type: PayoutRetryType,) -> bool {- let key = match retry_type {- PayoutRetryType::SingleConnector => {- format!("should_call_gsm_single_connector_payout_{}", merchant_id)- }- PayoutRetryType::MultiConnector => {- format!("should_call_gsm_multiple_connector_payout_{}", merchant_id)- }- };+ let key = merchant_id.get_should_call_gsm_payout_key(retry_type);let config = db.find_config_by_key_unwrap_or(key.as_str(), Some("false".to_string())).await;diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rsindex a1332181f6..7d5b8c05ee 100644--- a/crates/router/src/core/payouts/validator.rs+++ b/crates/router/src/core/payouts/validator.rs@@ -26,7 +26,7 @@ use crate::{pub async fn validate_uniqueness_of_payout_id_against_merchant_id(db: &dyn StorageInterface,payout_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: storage::enums::MerchantStorageScheme,) -> RouterResult<Option<storage::Payouts>> {let maybe_payouts = db@@ -56,7 +56,7 @@ pub async fn validate_create_request(req: &payouts::PayoutCreateRequest,merchant_key_store: &domain::MerchantKeyStore,) -> RouterResult<(String, Option<payouts::PayoutMethodData>, String)> {- let merchant_id = &merchant_account.merchant_id;+ let merchant_id = merchant_account.get_id();if let Some(payout_link) = &req.payout_link {if *payout_link {@@ -86,7 +86,7 @@ pub async fn validate_create_request(.await.attach_printable_lazy(|| {format!(- "Unique violation while checking payout_id: {} against merchant_id: {}",+ "Unique violation while checking payout_id: {} against merchant_id: {:?}",payout_id.to_owned(),merchant_id)@@ -109,7 +109,7 @@ pub async fn validate_create_request(req.payout_method_data.as_ref(),Some(&payout_token),&customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),req.payout_type,merchant_key_store,None,diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rsindex df28d257b3..f2d5d2d7d5 100644--- a/crates/router/src/core/pm_auth.rs+++ b/crates/router/src/core/pm_auth.rs@@ -125,7 +125,7 @@ pub async fn create_link_token(pi.billing_address_id.clone(),&key_store,&pi.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -140,20 +140,20 @@ pub async fn create_link_token(.store.find_by_merchant_connector_account_merchant_id_merchant_connector_id(&(&state).into(),- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),&selected_config.mca_id,&key_store,).await.change_context(ApiErrorResponse::MerchantConnectorAccountNotFound {- id: merchant_account.merchant_id.clone(),+ id: merchant_account.get_id().get_string_repr().to_owned(),})?;let auth_type = helpers::get_connector_auth_type(merchant_connector_account)?;let router_data = pm_auth_types::LinkTokenRouterData {flow: std::marker::PhantomData,- merchant_id: Some(merchant_account.merchant_id),+ merchant_id: Some(merchant_account.get_id().clone()),connector: Some(connector_name.to_string()),request: pm_auth_types::LinkTokenRequest {client_name: "HyperSwitch".to_string(),@@ -235,13 +235,13 @@ pub async fn exchange_token_core(.store.find_by_merchant_connector_account_merchant_id_merchant_connector_id(&(&state).into(),- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),&config.mca_id,&key_store,).await.change_context(ApiErrorResponse::MerchantConnectorAccountNotFound {- id: merchant_account.merchant_id.clone(),+ id: merchant_account.get_id().get_string_repr().to_owned(),})?;let auth_type = helpers::get_connector_auth_type(merchant_connector_account.clone())?;@@ -297,7 +297,7 @@ async fn store_bank_details_in_payment_methods(.find_payment_intent_by_payment_id_merchant_id(&(&state).into(),&payload.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),&key_store,merchant_account.storage_scheme,)@@ -311,7 +311,7 @@ async fn store_bank_details_in_payment_methods(let payment_methods = db.find_payment_method_by_customer_id_merchant_id_list(&customer_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),None,).await@@ -459,7 +459,7 @@ async fn store_bank_details_in_payment_methods(let now = common_utils::date_time::now();let pm_new = storage::PaymentMethodNew {customer_id: customer_id.clone(),- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),payment_method_id: pm_id,payment_method: Some(enums::PaymentMethod::BankDebit),payment_method_type: Some(creds.payment_method_type),@@ -555,7 +555,7 @@ pub async fn get_bank_account_creds(let router_data_bank_details = pm_auth_types::BankDetailsRouterData {flow: std::marker::PhantomData,- merchant_id: Some(merchant_account.merchant_id.clone()),+ merchant_id: Some(merchant_account.get_id().clone()),connector: Some(connector_name.to_string()),request: pm_auth_types::BankAccountCredentialsRequest {access_token: access_token.clone(),@@ -784,7 +784,7 @@ pub async fn retrieve_payment_method_from_auth_service(payment_intent.billing_address_id.clone(),key_store,&payment_intent.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await?;diff --git a/crates/router/src/core/poll.rs b/crates/router/src/core/poll.rsindex 53b4b02e61..f0a464be28 100644--- a/crates/router/src/core/poll.rs+++ b/crates/router/src/core/poll.rs@@ -21,7 +21,7 @@ pub async fn retrieve_poll_status(.attach_printable("Failed to get redis connection")?;let request_poll_id = req.poll_id;// prepend 'poll_{merchant_id}_' to restrict access to only fetching Poll IDs, as this is a freely passed string in the request- let poll_id = super::utils::get_poll_id(merchant_account.merchant_id, request_poll_id.clone());+ let poll_id = super::utils::get_poll_id(merchant_account.get_id(), request_poll_id.clone());let redis_value = redis_conn.get_key::<Option<String>>(poll_id.as_str()).awaitdiff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rsindex 374c37dc21..5a8e12992c 100644--- a/crates/router/src/core/refunds.rs+++ b/crates/router/src/core/refunds.rs@@ -53,7 +53,7 @@ pub async fn refund_create_core(let db = &*state.store;let (merchant_id, payment_intent, payment_attempt, amount);- merchant_id = &merchant_account.merchant_id;+ merchant_id = merchant_account.get_id();payment_intent = db.find_payment_intent_by_payment_id_merchant_id(@@ -112,12 +112,7 @@ pub async fn refund_create_core(req.merchant_connector_details.to_owned().async_map(|mcd| async {- payments::helpers::insert_merchant_connector_creds_to_config(- db,- merchant_id.as_str(),- mcd,- )- .await+ payments::helpers::insert_merchant_connector_creds_to_config(db, merchant_id, mcd).await}).await.transpose()?;@@ -301,7 +296,10 @@ pub async fn trigger_refund_to_gateway(1,&add_attributes([("connector", connector.connector_name.to_string()),- ("merchant_id", merchant_account.merchant_id.clone()),+ (+ "merchant_id",+ merchant_account.get_id().get_string_repr().to_owned(),+ ),]),);storage::RefundUpdate::ErrorUpdate {@@ -402,7 +400,7 @@ pub async fn refund_retrieve_core(let db = &*state.store;let (merchant_id, payment_intent, payment_attempt, refund, response);- merchant_id = &merchant_account.merchant_id;+ merchant_id = merchant_account.get_id();refund = db.find_refund_by_merchant_id_refund_id(@@ -443,12 +441,7 @@ pub async fn refund_retrieve_core(.merchant_connector_details.to_owned().async_map(|mcd| async {- payments::helpers::insert_merchant_connector_creds_to_config(- db,- merchant_id.as_str(),- mcd,- )- .await+ payments::helpers::insert_merchant_connector_creds_to_config(db, merchant_id, mcd).await}).await.transpose()?;@@ -596,7 +589,10 @@ pub async fn sync_refund_with_gateway(1,&add_attributes([("connector", connector.connector_name.to_string()),- ("merchant_id", merchant_account.merchant_id.clone()),+ (+ "merchant_id",+ merchant_account.get_id().get_string_repr().to_owned(),+ ),]),);let refund_connector_transaction_id = err.connector_transaction_id;@@ -650,7 +646,7 @@ pub async fn refund_update_core(let db = state.store.as_ref();let refund = db.find_refund_by_merchant_id_refund_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req.refund_id,merchant_account.storage_scheme,)@@ -735,7 +731,7 @@ pub async fn validate_and_create_refund(let predicate = req.merchant_id.as_ref()- .map(|merchant_id| merchant_id != &merchant_account.merchant_id);+ .map(|merchant_id| merchant_id != merchant_account.get_id());utils::when(predicate.unwrap_or(false), || {Err(report!(errors::ApiErrorResponse::InvalidDataFormat {@@ -752,7 +748,7 @@ pub async fn validate_and_create_refund(let all_refunds = db.find_refund_by_merchant_id_connector_transaction_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&connecter_transaction_id,merchant_account.storage_scheme,)@@ -799,7 +795,7 @@ pub async fn validate_and_create_refund(.set_internal_reference_id(utils::generate_id(consts::ID_LENGTH, "refid")).set_external_reference_id(Some(refund_id.clone())).set_payment_id(req.payment_id)- .set_merchant_id(merchant_account.merchant_id.clone())+ .set_merchant_id(merchant_account.get_id().clone()).set_connector_transaction_id(connecter_transaction_id.to_string()).set_connector(connector).set_refund_type(req.refund_type.unwrap_or_default().foreign_into())@@ -868,7 +864,7 @@ pub async fn refund_list(let refund_list = db.filter_refund_by_constraints(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req,merchant_account.storage_scheme,limit,@@ -884,7 +880,7 @@ pub async fn refund_list(let total_count = db.get_total_count_of_refunds(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req,merchant_account.storage_scheme,)@@ -910,7 +906,7 @@ pub async fn refund_filter_list(let db = state.store;let filter_list = db.filter_refund_by_meta_constraints(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req,merchant_account.storage_scheme,)@@ -946,7 +942,7 @@ pub async fn refund_manual_update(let refund = state.store.find_refund_by_merchant_id_refund_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&req.refund_id,merchant_account.storage_scheme,)@@ -983,7 +979,7 @@ pub async fn get_filters_for_refunds(merchant_account: domain::MerchantAccount,) -> RouterResponse<api_models::refunds::RefundListFilters> {let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =- super::admin::list_payment_connectors(state, merchant_account.merchant_id).await?+ super::admin::list_payment_connectors(state, merchant_account.get_id().to_owned()).await?{data} else {@@ -1452,7 +1448,7 @@ pub async fn add_refund_execute_task(pub async fn get_refund_sync_process_schedule_time(db: &dyn db::StorageInterface,connector: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,retry_count: i32,) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> {let redis_mapping: errors::CustomResult<process_data::ConnectorPTMapping, errors::RedisError> =diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rsindex b17217737b..c8ba5d6a0d 100644--- a/crates/router/src/core/routing.rs+++ b/crates/router/src/core/routing.rs@@ -49,7 +49,7 @@ pub async fn retrieve_merchant_routing_dictionary(let routing_metadata = state.store.list_routing_algorithm_metadata_by_merchant_id_transaction_type(- &merchant_account.merchant_id,+ merchant_account.get_id(),transaction_type,i64::from(query_params.limit.unwrap_or_default()),i64::from(query_params.offset.unwrap_or_default()),@@ -101,7 +101,7 @@ pub async fn create_routing_config(let algorithm_id = common_utils::generate_id(consts::ROUTING_CONFIG_ID_LENGTH,- &format!("routing_{}", &merchant_account.merchant_id),+ &format!("routing_{}", merchant_account.get_id().get_string_repr()),);let profile_id = request@@ -112,17 +112,13 @@ pub async fn create_routing_config(}).attach_printable("Profile_id not provided")?;- core_utils::validate_and_get_business_profile(- db,- Some(&profile_id),- &merchant_account.merchant_id,- )- .await?;+ core_utils::validate_and_get_business_profile(db, Some(&profile_id), merchant_account.get_id())+ .await?;helpers::validate_connectors_in_routing_config(&state,&key_store,- &merchant_account.merchant_id,+ merchant_account.get_id(),&profile_id,&algorithm,)@@ -132,7 +128,7 @@ pub async fn create_routing_config(let algo = RoutingAlgorithm {algorithm_id: algorithm_id.clone(),profile_id,- merchant_id: merchant_account.merchant_id,+ merchant_id: merchant_account.get_id().to_owned(),name: name.clone(),description: Some(description.clone()),kind: algorithm.get_kind().foreign_into(),@@ -164,7 +160,7 @@ pub async fn link_routing_config(let routing_algorithm = db.find_routing_algorithm_by_algorithm_id_merchant_id(&algorithm_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),).await.change_context(errors::ApiErrorResponse::ResourceIdNotFound)?;@@ -172,7 +168,7 @@ pub async fn link_routing_config(let business_profile = core_utils::validate_and_get_business_profile(db,Some(&routing_algorithm.profile_id),- &merchant_account.merchant_id,+ merchant_account.get_id(),).await?.get_required_value("BusinessProfile")@@ -232,7 +228,7 @@ pub async fn retrieve_routing_config(let routing_algorithm = db.find_routing_algorithm_by_algorithm_id_merchant_id(&algorithm_id.0,- &merchant_account.merchant_id,+ merchant_account.get_id(),).await.to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound)?;@@ -240,7 +236,7 @@ pub async fn retrieve_routing_config(core_utils::validate_and_get_business_profile(db,Some(&routing_algorithm.profile_id),- &merchant_account.merchant_id,+ merchant_account.get_id(),).await?.get_required_value("BusinessProfile")@@ -271,7 +267,7 @@ pub async fn unlink_routing_config(let business_profile = core_utils::validate_and_get_business_profile(db,Some(&profile_id),- &merchant_account.merchant_id,+ merchant_account.get_id(),).await?;match business_profile {@@ -338,9 +334,12 @@ pub async fn update_default_routing_config() -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> {metrics::ROUTING_UPDATE_CONFIG.add(&metrics::CONTEXT, 1, &[]);let db = state.store.as_ref();- let default_config =- helpers::get_merchant_default_config(db, &merchant_account.merchant_id, transaction_type)- .await?;+ let default_config = helpers::get_merchant_default_config(+ db,+ merchant_account.get_id().get_string_repr(),+ transaction_type,+ )+ .await?;utils::when(default_config.len() != updated_config.len(), || {Err(errors::ApiErrorResponse::PreconditionFailed {@@ -369,7 +368,7 @@ pub async fn update_default_routing_config(helpers::update_merchant_default_config(db,- &merchant_account.merchant_id,+ merchant_account.get_id().get_string_repr(),updated_config.clone(),transaction_type,)@@ -387,16 +386,16 @@ pub async fn retrieve_default_routing_config(metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG.add(&metrics::CONTEXT, 1, &[]);let db = state.store.as_ref();- helpers::get_merchant_default_config(db, &merchant_account.merchant_id, transaction_type)- .await- .map(|conn_choice| {- metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG_SUCCESS_RESPONSE.add(- &metrics::CONTEXT,- 1,- &[],- );- service_api::ApplicationResponse::Json(conn_choice)- })+ helpers::get_merchant_default_config(+ db,+ merchant_account.get_id().get_string_repr(),+ transaction_type,+ )+ .await+ .map(|conn_choice| {+ metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG_SUCCESS_RESPONSE.add(&metrics::CONTEXT, 1, &[]);+ service_api::ApplicationResponse::Json(conn_choice)+ })}pub async fn retrieve_linked_routing_config(@@ -412,14 +411,14 @@ pub async fn retrieve_linked_routing_config(core_utils::validate_and_get_business_profile(db,Some(&profile_id),- &merchant_account.merchant_id,+ merchant_account.get_id(),).await?.map(|profile| vec![profile]).get_required_value("BusinessProfile").change_context(errors::ApiErrorResponse::BusinessProfileNotFound { id: profile_id })?} else {- db.list_business_profile_by_merchant_id(&merchant_account.merchant_id)+ db.list_business_profile_by_merchant_id(merchant_account.get_id()).await.to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound)?};@@ -467,7 +466,7 @@ pub async fn retrieve_default_routing_config_for_profiles(let db = state.store.as_ref();let all_profiles = db- .list_business_profile_by_merchant_id(&merchant_account.merchant_id)+ .list_business_profile_by_merchant_id(merchant_account.get_id()).await.to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound).attach_printable("error retrieving all business profiles for merchant")?;@@ -510,7 +509,7 @@ pub async fn update_default_routing_config_for_profile(let business_profile = core_utils::validate_and_get_business_profile(db,Some(&profile_id),- &merchant_account.merchant_id,+ merchant_account.get_id(),).await?.get_required_value("BusinessProfile")diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rsindex 707ed41d95..5978ef521a 100644--- a/crates/router/src/core/routing/helpers.rs+++ b/crates/router/src/core/routing/helpers.rs@@ -23,55 +23,56 @@ use crate::{/// provides the complete merchant routing dictionary that is basically a list of all the routing/// configs a merchant configured with an active_id field that specifies the current active routing/// config-pub async fn get_merchant_routing_dictionary(- db: &dyn StorageInterface,- merchant_id: &str,-) -> RouterResult<routing_types::RoutingDictionary> {- let key = get_routing_dictionary_key(merchant_id);- let maybe_dict = db.find_config_by_key(&key).await;-- match maybe_dict {- Ok(config) => config- .config- .parse_struct("RoutingDictionary")- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Merchant routing dictionary has invalid structure"),-- Err(e) if e.current_context().is_db_not_found() => {- let new_dictionary = routing_types::RoutingDictionary {- merchant_id: merchant_id.to_string(),- active_id: None,- records: Vec::new(),- };-- let serialized = new_dictionary- .encode_to_string_of_json()- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Error serializing newly created merchant dictionary")?;-- let new_config = configs::ConfigNew {- key,- config: serialized,- };-- db.insert_config(new_config)- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Error inserting new routing dictionary for merchant")?;-- Ok(new_dictionary)- }-- Err(e) => Err(e)- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Error fetching routing dictionary for merchant"),- }-}+// pub async fn get_merchant_routing_dictionary(+// db: &dyn StorageInterface,+// merchant_id: &str,+// ) -> RouterResult<routing_types::RoutingDictionary> {+// let key = get_routing_dictionary_key(merchant_id);+// let maybe_dict = db.find_config_by_key(&key).await;++// match maybe_dict {+// Ok(config) => config+// .config+// .parse_struct("RoutingDictionary")+// .change_context(errors::ApiErrorResponse::InternalServerError)+// .attach_printable("Merchant routing dictionary has invalid structure"),++// Err(e) if e.current_context().is_db_not_found() => {+// let new_dictionary = routing_types::RoutingDictionary {+// merchant_id: merchant_id.to_owned(),+// active_id: None,+// records: Vec::new(),+// };++// let serialized = new_dictionary+// .encode_to_string_of_json()+// .change_context(errors::ApiErrorResponse::InternalServerError)+// .attach_printable("Error serializing newly created merchant dictionary")?;++// let new_config = configs::ConfigNew {+// key,+// config: serialized,+// };++// db.insert_config(new_config)+// .await+// .change_context(errors::ApiErrorResponse::InternalServerError)+// .attach_printable("Error inserting new routing dictionary for merchant")?;++// Ok(new_dictionary)+// }++// Err(e) => Err(e)+// .change_context(errors::ApiErrorResponse::InternalServerError)+// .attach_printable("Error fetching routing dictionary for merchant"),+// }+// }/// Provides us with all the configured configs of the Merchant in the ascending time configured/// manner and chooses the first of thempub async fn get_merchant_default_config(db: &dyn StorageInterface,+ // Cannot make this as merchant id domain type because, we are passing profile id also heremerchant_id: &str,transaction_type: &storage::enums::TransactionType,) -> RouterResult<Vec<routing_types::RoutableConnectorChoice>> {@@ -253,8 +254,13 @@ pub async fn update_business_profile_active_algorithm_ref(let profile_id = current_business_profile.profile_id.clone();- let routing_cache_key =- cache::CacheKind::Routing(format!("routing_config_{merchant_id}_{profile_id}").into());+ let routing_cache_key = cache::CacheKind::Routing(+ format!(+ "routing_config_{}_{profile_id}",+ merchant_id.get_string_repr()+ )+ .into(),+ );let (routing_algorithm, payout_routing_algorithm) = match transaction_type {storage::enums::TransactionType::Payment => (Some(ref_val), None),@@ -304,7 +310,7 @@ pub async fn update_business_profile_active_algorithm_ref(pub async fn validate_connectors_in_routing_config(state: &SessionState,key_store: &domain::MerchantKeyStore,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,profile_id: &str,routing_algorithm: &routing_types::RoutingAlgorithm,) -> RouterResult<()> {@@ -318,7 +324,7 @@ pub async fn validate_connectors_in_routing_config().await.change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {- id: merchant_id.to_string(),+ id: merchant_id.get_string_repr().to_owned(),})?;let name_mca_id_set = all_mcas@@ -426,10 +432,3 @@ pub fn get_default_config_key(storage::enums::TransactionType::Payout => format!("routing_default_po_{merchant_id}"),}}-pub fn get_payment_config_routing_id(merchant_id: &str) -> String {- format!("payment_config_id_{merchant_id}")-}--pub fn get_payment_method_surcharge_routing_id(merchant_id: &str) -> String {- format!("payment_method_surcharge_id_{merchant_id}")-}diff --git a/crates/router/src/core/surcharge_decision_config.rs b/crates/router/src/core/surcharge_decision_config.rsindex 55ea4ba16f..03e4f33737 100644--- a/crates/router/src/core/surcharge_decision_config.rs+++ b/crates/router/src/core/surcharge_decision_config.rs@@ -11,9 +11,7 @@ use error_stack::ResultExt;use euclid::frontend::ast;use storage_impl::redis::cache;-use super::routing::helpers::{- get_payment_method_surcharge_routing_id, update_merchant_active_algorithm_ref,-};+use super::routing::helpers::update_merchant_active_algorithm_ref;use crate::{core::errors::{self, RouterResponse},routes::SessionState,@@ -50,7 +48,9 @@ pub async fn upsert_surcharge_decision_config(.attach_printable("Could not decode the routing algorithm")?.unwrap_or_default();- let key = get_payment_method_surcharge_routing_id(merchant_account.merchant_id.as_str());+ let key = merchant_account+ .get_id()+ .get_payment_method_surcharge_routing_id();let read_config_key = db.find_config_by_key(&key).await;ast::lowering::lower_program(program.clone())@@ -147,7 +147,9 @@ pub async fn delete_surcharge_decision_config(merchant_account: domain::MerchantAccount,) -> RouterResponse<()> {let db = state.store.as_ref();- let key = get_payment_method_surcharge_routing_id(&merchant_account.merchant_id);+ let key = merchant_account+ .get_id()+ .get_payment_method_surcharge_routing_id();let mut algo_id: routing::RoutingAlgorithmRef = merchant_account.routing_algorithm.clone()@@ -175,8 +177,9 @@ pub async fn retrieve_surcharge_decision_config(merchant_account: domain::MerchantAccount,) -> RouterResponse<SurchargeDecisionManagerResponse> {let db = state.store.as_ref();- let algorithm_id =- get_payment_method_surcharge_routing_id(merchant_account.merchant_id.as_str());+ let algorithm_id = merchant_account+ .get_id()+ .get_payment_method_surcharge_routing_id();let algo_config = db.find_config_by_key(&algorithm_id).awaitdiff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rsindex e44493cff3..9389240c97 100644--- a/crates/router/src/core/user.rs+++ b/crates/router/src/core/user.rs@@ -197,7 +197,7 @@ pub async fn signin(let signin_strategy =if let Some(preferred_merchant_id) = user_from_db.get_preferred_merchant_id() {let preferred_role = user_from_db- .get_role_from_db_by_merchant_id(&state, preferred_merchant_id.as_str())+ .get_role_from_db_by_merchant_id(&state, &preferred_merchant_id).await.to_not_found_response(UserErrors::InternalServerError).attach_printable("User role with preferred_merchant_id not found")?;@@ -1110,7 +1110,9 @@ pub async fn create_internal_user(.store.get_merchant_key_store_by_merchant_id(key_manager_state,- consts::user_role::INTERNAL_USER_MERCHANT_ID,+ &common_utils::id_type::MerchantId::get_internal_user_merchant_id(+ consts::user_role::INTERNAL_USER_MERCHANT_ID,+ ),&state.store.get_master_key().to_vec().into(),).await@@ -1126,7 +1128,9 @@ pub async fn create_internal_user(.store.find_merchant_account_by_merchant_id(key_manager_state,- consts::user_role::INTERNAL_USER_MERCHANT_ID,+ &common_utils::id_type::MerchantId::get_internal_user_merchant_id(+ consts::user_role::INTERNAL_USER_MERCHANT_ID,+ ),&key_store,).await@@ -1195,7 +1199,7 @@ pub async fn switch_merchant_id(.store.get_merchant_key_store_by_merchant_id(key_manager_state,- request.merchant_id.as_str(),+ &request.merchant_id,&state.store.get_master_key().to_vec().into(),).await@@ -1211,7 +1215,7 @@ pub async fn switch_merchant_id(.store.find_merchant_account_by_merchant_id(key_manager_state,- request.merchant_id.as_str(),+ &request.merchant_id,&key_store,).await@@ -1294,7 +1298,7 @@ pub async fn create_merchant_account(if let Err(e) = role_insertion_res {let _ = state.store- .delete_merchant_account_by_merchant_id(new_merchant.get_merchant_id().as_str())+ .delete_merchant_account_by_merchant_id(&new_merchant.get_merchant_id()).await;return Err(e);}@@ -1386,7 +1390,7 @@ pub async fn list_users_for_merchant_account() -> UserResponse<user_api::ListUsersResponse> {let user_roles: HashMap<String, _> = state.store- .list_user_roles_by_merchant_id(user_from_token.merchant_id.as_str())+ .list_user_roles_by_merchant_id(&user_from_token.merchant_id).await.change_context(UserErrors::InternalServerError).attach_printable("No user roles for given merchant id")?@@ -1481,7 +1485,7 @@ pub async fn verify_email(let signin_strategy =if let Some(preferred_merchant_id) = user_from_db.get_preferred_merchant_id() {let preferred_role = user_from_db- .get_role_from_db_by_merchant_id(&state, preferred_merchant_id.as_str())+ .get_role_from_db_by_merchant_id(&state, &preferred_merchant_id).await.change_context(UserErrors::InternalServerError).attach_printable("User role with preferred_merchant_id not found")?;@@ -1626,7 +1630,7 @@ pub async fn verify_token(.merchant_id;Ok(ApplicationResponse::Json(user_api::VerifyTokenResponse {- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),user_email: user.email,}))}diff --git a/crates/router/src/core/user/dashboard_metadata.rs b/crates/router/src/core/user/dashboard_metadata.rsindex b279d852d4..6eb1dd572d 100644--- a/crates/router/src/core/user/dashboard_metadata.rs+++ b/crates/router/src/core/user/dashboard_metadata.rs@@ -707,7 +707,7 @@ pub async fn backfill_metadata(pub async fn get_merchant_connector_account_by_name(state: &SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: &str,key_store: &MerchantKeyStore,) -> UserResult<Option<domain::MerchantConnectorAccount>> {diff --git a/crates/router/src/core/user/sample_data.rs b/crates/router/src/core/user/sample_data.rsindex b679753b56..f5faf68435 100644--- a/crates/router/src/core/user/sample_data.rs+++ b/crates/router/src/core/user/sample_data.rs@@ -19,8 +19,7 @@ pub async fn generate_sample_data_for_user(req: SampleDataRequest,_req_state: ReqState,) -> SampleDataApiResponse<()> {- let sample_data =- generate_sample_data(&state, req, user_from_token.merchant_id.as_str()).await?;+ let sample_data = generate_sample_data(&state, req, &user_from_token.merchant_id).await?;let key_store = state.store@@ -74,13 +73,13 @@ pub async fn delete_sample_data_for_user(_req: SampleDataRequest,_req_state: ReqState,) -> SampleDataApiResponse<()> {- let merchant_id_del = user_from_token.merchant_id.as_str();+ let merchant_id_del = user_from_token.merchant_id;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,+ &merchant_id_del,&state.store.get_master_key().to_vec().into(),).await@@ -89,17 +88,17 @@ pub async fn delete_sample_data_for_user(state.store- .delete_payment_intents_for_sample_data(key_manager_state, merchant_id_del, &key_store)+ .delete_payment_intents_for_sample_data(key_manager_state, &merchant_id_del, &key_store).await.switch()?;state.store- .delete_payment_attempts_for_sample_data(merchant_id_del)+ .delete_payment_attempts_for_sample_data(&merchant_id_del).await.switch()?;state.store- .delete_refunds_for_sample_data(merchant_id_del)+ .delete_refunds_for_sample_data(&merchant_id_del).await.switch()?;diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rsindex 429907a73a..5d93c00909 100644--- a/crates/router/src/core/user_role.rs+++ b/crates/router/src/core/user_role.rs@@ -101,7 +101,7 @@ pub async fn update_user_role(.store.update_user_role_by_user_id_merchant_id(user_to_be_updated.get_user_id(),- user_role_to_be_updated.merchant_id.as_str(),+ &user_role_to_be_updated.merchant_id,UserRoleUpdate::UpdateRole {role_id: req.role_id.clone(),modified_by: user_from_token.user_id,@@ -335,7 +335,7 @@ pub async fn delete_user_role(match user_roles.iter()- .find(|&role| role.merchant_id == user_from_token.merchant_id.as_str())+ .find(|&role| role.merchant_id == user_from_token.merchant_id){Some(user_role) => {let role_info = roles::RoleInfo::from_role_id(@@ -362,7 +362,7 @@ pub async fn delete_user_role(.store.delete_user_role_by_user_id_merchant_id(user_from_db.get_user_id(),- user_from_token.merchant_id.as_str(),+ &user_from_token.merchant_id,).await.change_context(UserErrors::InternalServerError)@@ -379,7 +379,7 @@ pub async fn delete_user_role(.store.delete_user_role_by_user_id_merchant_id(user_from_db.get_user_id(),- user_from_token.merchant_id.as_str(),+ &user_from_token.merchant_id,).await.change_context(UserErrors::InternalServerError)diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex 3af36d493d..f25e13161a 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -56,7 +56,7 @@ pub async fn get_mca_for_payout<'a>(None => {let merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),None,key_store,&payout_data.profile_id,@@ -150,7 +150,7 @@ pub async fn construct_payout_router_data<'a, F>(let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.to_owned(),+ merchant_id: merchant_account.get_id().to_owned(),customer_id: customer_details.to_owned().map(|c| c.customer_id),connector_customer: connector_customer_id,connector: connector_name.to_string(),@@ -243,7 +243,7 @@ pub async fn construct_refund_router_data<'a, F>(let merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),creds_identifier,key_store,&profile_id,@@ -268,7 +268,7 @@ pub async fn construct_refund_router_data<'a, F>(let webhook_url = Some(helpers::create_webhook_url(&state.base_url.clone(),- &merchant_account.merchant_id,+ merchant_account.get_id(),&connector_id.to_string(),));let test_mode: Option<bool> = merchant_connector_account.is_test_mode_on();@@ -306,7 +306,7 @@ pub async fn construct_refund_router_data<'a, F>(let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),customer_id: payment_intent.customer_id.to_owned(),connector: connector_id.to_string(),payment_id: payment_attempt.payment_id.clone(),@@ -538,7 +538,7 @@ pub async fn construct_accept_dispute_router_data<'a>(let merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),None,key_store,&profile_id,@@ -557,7 +557,7 @@ pub async fn construct_accept_dispute_router_data<'a>(.get_required_value("payment_method_type")?;let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),connector: dispute.connector.to_string(),payment_id: payment_attempt.payment_id.clone(),attempt_id: payment_attempt.attempt_id.clone(),@@ -590,7 +590,7 @@ pub async fn construct_accept_dispute_router_data<'a>(preprocessing_id: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- &merchant_account.merchant_id,+ merchant_account.get_id(),payment_attempt,),#[cfg(feature = "payouts")]@@ -637,7 +637,7 @@ pub async fn construct_submit_evidence_router_data<'a>(let merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),None,key_store,&profile_id,@@ -656,7 +656,7 @@ pub async fn construct_submit_evidence_router_data<'a>(.get_required_value("payment_method_type")?;let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),connector: connector_id.to_string(),payment_id: payment_attempt.payment_id.clone(),attempt_id: payment_attempt.attempt_id.clone(),@@ -687,7 +687,7 @@ pub async fn construct_submit_evidence_router_data<'a>(payment_method_status: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- &merchant_account.merchant_id,+ merchant_account.get_id(),payment_attempt,),#[cfg(feature = "payouts")]@@ -734,7 +734,7 @@ pub async fn construct_upload_file_router_data<'a>(let merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),None,key_store,&profile_id,@@ -753,7 +753,7 @@ pub async fn construct_upload_file_router_data<'a>(.get_required_value("payment_method_type")?;let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),connector: connector_id.to_string(),payment_id: payment_attempt.payment_id.clone(),attempt_id: payment_attempt.attempt_id.clone(),@@ -789,7 +789,7 @@ pub async fn construct_upload_file_router_data<'a>(payment_method_balance: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- &merchant_account.merchant_id,+ merchant_account.get_id(),payment_attempt,),#[cfg(feature = "payouts")]@@ -835,7 +835,7 @@ pub async fn construct_defend_dispute_router_data<'a>(let merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),None,key_store,&profile_id,@@ -854,7 +854,7 @@ pub async fn construct_defend_dispute_router_data<'a>(.get_required_value("payment_method_type")?;let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),connector: connector_id.to_string(),payment_id: payment_attempt.payment_id.clone(),attempt_id: payment_attempt.attempt_id.clone(),@@ -888,7 +888,7 @@ pub async fn construct_defend_dispute_router_data<'a>(payment_method_balance: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- &merchant_account.merchant_id,+ merchant_account.get_id(),payment_attempt,),#[cfg(feature = "payouts")]@@ -928,7 +928,7 @@ pub async fn construct_retrieve_file_router_data<'a>(let merchant_connector_account = helpers::get_merchant_connector_account(state,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),None,key_store,profile_id,@@ -944,7 +944,7 @@ pub async fn construct_retrieve_file_router_data<'a>(.change_context(errors::ApiErrorResponse::InternalServerError)?;let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),connector: connector_id.to_string(),customer_id: None,connector_customer: None,@@ -999,7 +999,7 @@ pub async fn construct_retrieve_file_router_data<'a>(pub fn is_merchant_enabled_for_payment_id_as_connector_request_id(conf: &Settings,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> bool {let config_map = &conf.connector_request_reference_id_config@@ -1009,7 +1009,7 @@ pub fn is_merchant_enabled_for_payment_id_as_connector_request_id(pub fn get_connector_request_reference_id(conf: &Settings,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,) -> String {let is_config_enabled_for_merchant =@@ -1026,7 +1026,7 @@ pub fn get_connector_request_reference_id(pub async fn validate_and_get_business_profile(db: &dyn StorageInterface,profile_id: Option<&String>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> RouterResult<Option<storage::business_profile::BusinessProfile>> {profile_id.async_map(|profile_id| async {@@ -1108,7 +1108,7 @@ pub async fn get_profile_id_from_business_details(let _ = validate_and_get_business_profile(db,Some(profile_id),- &merchant_account.merchant_id,+ merchant_account.get_id(),).await?;}@@ -1120,7 +1120,7 @@ pub async fn get_profile_id_from_business_details(let business_profile = db.find_business_profile_by_profile_name_merchant_id(&profile_name,- &merchant_account.merchant_id,+ merchant_account.get_id(),).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {@@ -1136,8 +1136,8 @@ pub async fn get_profile_id_from_business_details(}}-pub fn get_poll_id(merchant_id: String, unique_id: String) -> String {- format!("poll_{}_{}", merchant_id, unique_id)+pub fn get_poll_id(merchant_id: &common_utils::id_type::MerchantId, unique_id: String) -> String {+ merchant_id.get_poll_id(&unique_id)}pub fn get_external_authentication_request_poll_id(payment_id: &String) -> String {diff --git a/crates/router/src/core/verification.rs b/crates/router/src/core/verification.rsindex 65ac568832..724f244d39 100644--- a/crates/router/src/core/verification.rs+++ b/crates/router/src/core/verification.rs@@ -11,7 +11,7 @@ const APPLEPAY_INTERNAL_MERCHANT_NAME: &str = "Applepay_merchant";pub async fn verify_merchant_creds_for_applepay(state: SessionState,body: verifications::ApplepayMerchantVerificationRequest,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> CustomResult<services::ApplicationResponse<ApplepayMerchantResponse>, errors::ApiErrorResponse>{let applepay_merchant_configs = state.conf.applepay_merchant_configs.get_inner();@@ -84,7 +84,7 @@ pub async fn verify_merchant_creds_for_applepay(pub async fn get_verified_apple_domains_with_mid_mca_id(state: SessionState,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,merchant_connector_id: String,) -> CustomResult<services::ApplicationResponse<verifications::ApplepayVerifiedDomainsResponse>,@@ -104,7 +104,7 @@ pub async fn get_verified_apple_domains_with_mid_mca_id(let verified_domains = db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(key_manager_state,- merchant_id.as_str(),+ &merchant_id,merchant_connector_id.as_str(),&key_store,)diff --git a/crates/router/src/core/verification/utils.rs b/crates/router/src/core/verification/utils.rsindex a59789b280..c286497e5c 100644--- a/crates/router/src/core/verification/utils.rs+++ b/crates/router/src/core/verification/utils.rs@@ -11,7 +11,7 @@ use crate::{pub async fn check_existence_and_add_domain_to_db(state: &SessionState,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,merchant_connector_id: String,domain_from_req: Vec<String>,) -> CustomResult<Vec<String>, errors::ApiErrorResponse> {@@ -49,7 +49,6 @@ pub async fn check_existence_and_add_domain_to_db(already_verified_domains.append(&mut new_verified_domains);let updated_mca = storage::MerchantConnectorAccountUpdate::Update {- merchant_id: None,connector_type: None,connector_name: None,connector_account_details: None,diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex 5c5346ce13..61207aebb9 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -86,7 +86,7 @@ pub async fn incoming_webhooks_wrapper<W: types::OutgoingWebhookType>(.attach_printable("Unable to extract request id from request").change_context(errors::ApiErrorResponse::InternalServerError)?;let auth_type = auth::AuthenticationType::WebhookAuth {- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),};let status_code = 200;let api_event = ApiEventsType::Webhooks {@@ -98,7 +98,7 @@ pub async fn incoming_webhooks_wrapper<W: types::OutgoingWebhookType>(.attach_printable("Could not convert webhook effect to string")?;let api_event = ApiEvent::new(- Some(merchant_account.merchant_id.clone()),+ Some(merchant_account.get_id().clone()),flow,&request_id,request_duration,@@ -135,7 +135,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(1,&[metrics::KeyValue::new(MERCHANT_ID,- merchant_account.merchant_id.clone(),+ merchant_account.get_id().get_string_repr().to_owned(),)],);let mut request_details = IncomingWebhookRequestDetails {@@ -160,7 +160,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(let decoded_body = connector.decode_webhook_body(&request_details,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_connector_account.clone().and_then(|merchant_connector_account| {@@ -200,7 +200,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(&metrics::CONTEXT,1,&[- metrics::KeyValue::new(MERCHANT_ID, merchant_account.merchant_id.clone()),+ metrics::KeyValue::new(MERCHANT_ID, merchant_account.get_id().clone()),metrics::KeyValue::new("connector", connector_name.to_string()),],);@@ -226,7 +226,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(let is_webhook_event_enabled = !utils::is_webhook_event_disabled(&*state.clone().store,connector_name.as_str(),- &merchant_account.merchant_id,+ merchant_account.get_id(),&event_type,).await;@@ -295,7 +295,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(.clone().verify_webhook_source(&request_details,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_connector_account.connector_webhook_details.clone(),merchant_connector_account.connector_account_details.clone(),connector_name.as_str(),@@ -318,7 +318,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(1,&[metrics::KeyValue::new(MERCHANT_ID,- merchant_account.merchant_id.clone(),+ merchant_account.get_id().clone(),)],);} else if connector.is_webhook_source_verification_mandatory() {@@ -478,7 +478,7 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(1,&[metrics::KeyValue::new(MERCHANT_ID,- merchant_account.merchant_id.clone(),+ merchant_account.get_id().get_string_repr().to_owned(),)],);WebhookResponseTracker::NoEffect@@ -516,7 +516,7 @@ async fn payments_incoming_webhook_flow(let payment_id = get_payment_id(state.store.as_ref(),&id,- merchant_account.merchant_id.as_str(),+ merchant_account.get_id(),merchant_account.storage_scheme,).await?;@@ -531,7 +531,7 @@ async fn payments_incoming_webhook_flow(lock_action.clone()- .perform_locking_action(&state, merchant_account.merchant_id.to_string())+ .perform_locking_action(&state, merchant_account.get_id().to_owned()).await?;let response = Box::pin(payments::payments_core::<@@ -548,7 +548,7 @@ async fn payments_incoming_webhook_flow(payments::operations::PaymentStatus,api::PaymentsRetrieveRequest {resource_id: id,- merchant_id: Some(merchant_account.merchant_id.clone()),+ merchant_id: Some(merchant_account.get_id().clone()),force_sync: true,connector: None,param: None,@@ -565,7 +565,7 @@ async fn payments_incoming_webhook_flow(.await;lock_action- .free_lock_action(&state, merchant_account.merchant_id.to_owned())+ .free_lock_action(&state, merchant_account.get_id().to_owned()).await?;match response {@@ -584,7 +584,7 @@ async fn payments_incoming_webhook_flow(metrics::WEBHOOK_PAYMENT_NOT_FOUND.add(&metrics::CONTEXT,1,- &add_attributes([("merchant_id", merchant_account.merchant_id.clone())]),+ &add_attributes([("merchant_id", merchant_account.get_id().clone())]),);return Ok(WebhookResponseTracker::NoEffect);}@@ -656,7 +656,7 @@ async fn payouts_incoming_webhook_flow(webhooks::ObjectReferenceId::PayoutId(payout_id_type) => match payout_id_type {webhooks::PayoutIdType::PayoutAttemptId(id) => db.find_payout_attempt_by_merchant_id_payout_attempt_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&id,merchant_account.storage_scheme,)@@ -665,7 +665,7 @@ async fn payouts_incoming_webhook_flow(.attach_printable("Failed to fetch the payout attempt")?,webhooks::PayoutIdType::ConnectorPayoutId(id) => db.find_payout_attempt_by_merchant_id_connector_payout_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&id,merchant_account.storage_scheme,)@@ -679,7 +679,7 @@ async fn payouts_incoming_webhook_flow(let payouts = db.find_payout_by_merchant_id_payout_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&payout_attempt.payout_id,merchant_account.storage_scheme,)@@ -780,7 +780,7 @@ async fn refunds_incoming_webhook_flow(webhooks::ObjectReferenceId::RefundId(refund_id_type) => match refund_id_type {webhooks::RefundIdType::RefundId(id) => db.find_refund_by_merchant_id_refund_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&id,merchant_account.storage_scheme,)@@ -789,7 +789,7 @@ async fn refunds_incoming_webhook_flow(.attach_printable("Failed to fetch the refund")?,webhooks::RefundIdType::ConnectorRefundId(id) => db.find_refund_by_merchant_id_connector_refund_id_connector(- &merchant_account.merchant_id,+ merchant_account.get_id(),&id,connector_name,merchant_account.storage_scheme,@@ -874,7 +874,7 @@ async fn get_payment_attempt_from_object_reference_id(match object_reference_id {api::ObjectReferenceId::PaymentId(api::PaymentIdType::ConnectorTransactionId(ref id)) => db.find_payment_attempt_by_merchant_id_connector_txn_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),id,merchant_account.storage_scheme,)@@ -883,7 +883,7 @@ async fn get_payment_attempt_from_object_reference_id(api::ObjectReferenceId::PaymentId(api::PaymentIdType::PaymentAttemptId(ref id)) => db.find_payment_attempt_by_attempt_id_merchant_id(id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -891,7 +891,7 @@ async fn get_payment_attempt_from_object_reference_id(api::ObjectReferenceId::PaymentId(api::PaymentIdType::PreprocessingId(ref id)) => db.find_payment_attempt_by_preprocessing_id_merchant_id(id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -906,7 +906,7 @@ async fn get_or_update_dispute_object(state: SessionState,option_dispute: Option<diesel_models::dispute::Dispute>,dispute_details: api::disputes::DisputePayload,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,event_type: webhooks::IncomingWebhookEvent,business_profile: &diesel_models::business_profile::BusinessProfile,@@ -1013,7 +1013,7 @@ async fn external_authentication_incoming_webhook_flow(webhooks::AuthenticationIdType::AuthenticationId(authentication_id) => state.store.find_authentication_by_merchant_id_authentication_id(- merchant_account.merchant_id.clone(),+ merchant_account.get_id(),authentication_id.clone(),).await@@ -1026,7 +1026,7 @@ async fn external_authentication_incoming_webhook_flow() => state.store.find_authentication_by_merchant_id_connector_authentication_id(- merchant_account.merchant_id.clone(),+ merchant_account.get_id().clone(),connector_authentication_id.clone(),).await@@ -1062,7 +1062,7 @@ async fn external_authentication_incoming_webhook_flow(payment_id: Some(api_models::payments::PaymentIdType::PaymentIntentId(payment_id,)),- merchant_id: Some(merchant_account.merchant_id.clone()),+ merchant_id: Some(merchant_account.get_id().clone()),..Default::default()};let payments_response = Box::pin(payments::payments_core::<@@ -1097,7 +1097,7 @@ async fn external_authentication_incoming_webhook_flow(payments_response.status.foreign_into();// Set poll_id as completed in redis to allow the fetch status of poll through retrieve_poll_status api from clientlet poll_id = core_utils::get_poll_id(- merchant_account.merchant_id.clone(),+ merchant_account.get_id(),core_utils::get_external_authentication_request_poll_id(&payment_id),);let redis_conn = state@@ -1170,7 +1170,7 @@ async fn mandates_incoming_webhook_flow(mandate_id,)) => db.find_mandate_by_merchant_id_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),mandate_id.as_str(),merchant_account.storage_scheme,)@@ -1180,7 +1180,7 @@ async fn mandates_incoming_webhook_flow(webhooks::MandateIdType::ConnectorMandateId(connector_mandate_id),) => db.find_mandate_by_merchant_id_connector_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),connector_mandate_id.as_str(),merchant_account.storage_scheme,)@@ -1195,7 +1195,7 @@ async fn mandates_incoming_webhook_flow(let mandate_id = mandate.mandate_id.clone();let updated_mandate = db.update_mandate_by_merchant_id_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&mandate_id,storage::MandateUpdate::StatusUpdate { mandate_status },mandate,@@ -1377,7 +1377,7 @@ async fn disputes_incoming_webhook_flow(.await?;let option_dispute = db.find_by_merchant_id_payment_id_connector_dispute_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&payment_attempt.payment_id,&dispute_details.connector_dispute_id,)@@ -1387,7 +1387,7 @@ async fn disputes_incoming_webhook_flow(state.clone(),option_dispute,dispute_details,- &merchant_account.merchant_id,+ merchant_account.get_id(),&payment_attempt,event_type,&business_profile,@@ -1516,7 +1516,7 @@ async fn bank_transfer_webhook_flow(async fn get_payment_id(db: &dyn StorageInterface,payment_id: &api::PaymentIdType,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: enums::MerchantStorageScheme,) -> errors::RouterResult<String> {let pay_id = || async {@@ -1574,7 +1574,7 @@ async fn verify_webhook_source_verification_call(> = connector_data.connector.get_connector_integration();let connector_webhook_secrets = connector.get_webhook_source_verification_merchant_secret(- &merchant_account.merchant_id,+ merchant_account.get_id(),connector_name,merchant_connector_account.connector_webhook_details.clone(),)@@ -1676,7 +1676,7 @@ async fn fetch_optional_mca_and_connector(let mca = db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(&state.into(),- &merchant_account.merchant_id,+ merchant_account.get_id(),connector_name_or_mca_id,key_store,)diff --git a/crates/router/src/core/webhooks/outgoing.rs b/crates/router/src/core/webhooks/outgoing.rsindex 7f30a58e20..39b9fac33b 100644--- a/crates/router/src/core/webhooks/outgoing.rs+++ b/crates/router/src/core/webhooks/outgoing.rs@@ -285,7 +285,7 @@ async fn trigger_webhook_to_merchant(1,&[metrics::KeyValue::new(MERCHANT_ID,- business_profile.merchant_id.clone(),+ business_profile.merchant_id.get_string_repr().to_owned(),)],);logger::debug!(outgoing_webhook_response=?response);@@ -435,7 +435,7 @@ fn raise_webhooks_analytics_event(state: SessionState,trigger_webhook_result: CustomResult<(), errors::WebhooksFlowError>,content: Option<api::OutgoingWebhookContent>,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,event: domain::Event,) {let error = if let Err(error) = trigger_webhook_result {@@ -649,7 +649,7 @@ enum ScheduleWebhookRetry {async fn update_event_if_client_error(state: SessionState,merchant_key_store: domain::MerchantKeyStore,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,error_message: String,) -> CustomResult<domain::Event, errors::WebhooksFlowError> {@@ -698,7 +698,7 @@ async fn update_event_if_client_error(async fn api_client_error_handler(state: SessionState,merchant_key_store: domain::MerchantKeyStore,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,client_error: error_stack::Report<errors::ApiClientError>,delivery_attempt: enums::WebhookDeliveryAttempt,@@ -739,7 +739,7 @@ async fn api_client_error_handler(async fn update_event_in_storage(state: SessionState,merchant_key_store: domain::MerchantKeyStore,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,response: reqwest::Response,) -> CustomResult<domain::Event, errors::WebhooksFlowError> {@@ -812,17 +812,20 @@ async fn update_event_in_storage(.change_context(errors::WebhooksFlowError::WebhookEventUpdationFailed)}-fn increment_webhook_outgoing_received_count(merchant_id: &str) {+fn increment_webhook_outgoing_received_count(merchant_id: &common_utils::id_type::MerchantId) {metrics::WEBHOOK_OUTGOING_RECEIVED_COUNT.add(&metrics::CONTEXT,1,- &[metrics::KeyValue::new(MERCHANT_ID, merchant_id.to_owned())],+ &[metrics::KeyValue::new(+ MERCHANT_ID,+ merchant_id.get_string_repr().to_owned(),+ )],)}async fn success_response_handler(state: SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,process_tracker: Option<storage::ProcessTracker>,business_status: &'static str,) -> CustomResult<(), errors::WebhooksFlowError> {@@ -843,7 +846,7 @@ async fn success_response_handler(async fn error_response_handler(state: SessionState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,delivery_attempt: enums::WebhookDeliveryAttempt,status_code: u16,log_message: &'static str,@@ -852,7 +855,10 @@ async fn error_response_handler(metrics::WEBHOOK_OUTGOING_NOT_RECEIVED_COUNT.add(&metrics::CONTEXT,1,- &[metrics::KeyValue::new(MERCHANT_ID, merchant_id.to_owned())],+ &[metrics::KeyValue::new(+ MERCHANT_ID,+ merchant_id.get_string_repr().to_owned(),+ )],);let error = report!(errors::WebhooksFlowError::NotReceivedByMerchant);diff --git a/crates/router/src/core/webhooks/types.rs b/crates/router/src/core/webhooks/types.rsindex 7559f692b1..d9eed529e8 100644--- a/crates/router/src/core/webhooks/types.rs+++ b/crates/router/src/core/webhooks/types.rs@@ -58,7 +58,7 @@ impl OutgoingWebhookType for webhooks::OutgoingWebhook {#[derive(Debug, serde::Serialize, serde::Deserialize)]pub(crate) struct OutgoingWebhookTrackingData {- pub(crate) merchant_id: String,+ pub(crate) merchant_id: common_utils::id_type::MerchantId,pub(crate) business_profile_id: String,pub(crate) event_type: enums::EventType,pub(crate) event_class: enums::EventClass,diff --git a/crates/router/src/core/webhooks/utils.rs b/crates/router/src/core/webhooks/utils.rsindex e0a0a86c78..f837fbba0d 100644--- a/crates/router/src/core/webhooks/utils.rs+++ b/crates/router/src/core/webhooks/utils.rs@@ -26,10 +26,10 @@ const IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_SOURCE_VERIFICATION_FLOW: &stpub async fn is_webhook_event_disabled(db: &dyn StorageInterface,connector_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event: &api::IncomingWebhookEvent,) -> bool {- let redis_key = format!("whconf_disabled_events_{merchant_id}_{connector_id}");+ let redis_key = merchant_id.get_webhook_config_disabled_events_key(connector_id);let merchant_webhook_disable_config_result: CustomResult<api::MerchantWebhookConfig,redis_interface::errors::RedisError,@@ -73,7 +73,7 @@ pub async fn construct_webhook_router_data<'a>(let router_data = types::RouterData {flow: PhantomData,- merchant_id: merchant_account.merchant_id.clone(),+ merchant_id: merchant_account.get_id().clone(),connector: connector_name.to_string(),customer_id: None,payment_id: IRRELEVANT_PAYMENT_ID_IN_SOURCE_VERIFICATION_FLOW.to_string(),diff --git a/crates/router/src/core/webhooks/webhook_events.rs b/crates/router/src/core/webhooks/webhook_events.rsindex 19118ad639..034cf936c1 100644--- a/crates/router/src/core/webhooks/webhook_events.rs+++ b/crates/router/src/core/webhooks/webhook_events.rs@@ -37,7 +37,7 @@ pub async fn list_initial_delivery_attempts(match account {MerchantAccountOrBusinessProfile::MerchantAccount(merchant_account) => store.list_initial_events_by_merchant_id_primary_object_id(key_manager_state,- &merchant_account.merchant_id,+ merchant_account.get_id(),&object_id,&key_store,)@@ -74,7 +74,7 @@ pub async fn list_initial_delivery_attempts(match account {MerchantAccountOrBusinessProfile::MerchantAccount(merchant_account) => store.list_initial_events_by_merchant_id_constraints(key_manager_state,- &merchant_account.merchant_id,+ merchant_account.get_id(),created_after,created_before,limit,@@ -122,7 +122,7 @@ pub async fn list_delivery_attempts(store.list_events_by_merchant_id_initial_attempt_id(key_manager_state,- &merchant_account.merchant_id,+ merchant_account.get_id(),&initial_attempt_id,&key_store,)@@ -272,10 +272,15 @@ async fn determine_identifier_and_get_key_store() -> errors::RouterResult<(MerchantAccountOrBusinessProfile, domain::MerchantKeyStore)> {let store = state.store.as_ref();let key_manager_state = &(&state).into();+ let merchant_id =+ common_utils::id_type::MerchantId::from(merchant_id_or_profile_id.clone().into())+ .change_context(errors::ApiErrorResponse::InvalidDataValue {+ field_name: "merchant_id",+ })?;match store.get_merchant_key_store_by_merchant_id(key_manager_state,- &merchant_id_or_profile_id,+ &merchant_id,&store.get_master_key().to_vec().into(),).await@@ -285,11 +290,7 @@ async fn determine_identifier_and_get_key_store(// Find a merchant account having `merchant_id` = `merchant_id_or_profile_id`.Ok(key_store) => {let merchant_account = store- .find_merchant_account_by_merchant_id(- key_manager_state,- &merchant_id_or_profile_id,- &key_store,- )+ .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store).await.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;diff --git a/crates/router/src/db.rs b/crates/router/src/db.rsindex 7a8f143f0b..1e415760fc 100644--- a/crates/router/src/db.rs+++ b/crates/router/src/db.rs@@ -299,7 +299,7 @@ impl FraudCheckInterface for KafkaStore {async fn find_fraud_check_by_payment_id(&self,payment_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> CustomResult<FraudCheck, StorageError> {let frm = self.diesel_store@@ -317,7 +317,7 @@ impl FraudCheckInterface for KafkaStore {async fn find_fraud_check_by_payment_id_if_present(&self,payment_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> CustomResult<Option<FraudCheck>, StorageError> {let frm = self.diesel_storediff --git a/crates/router/src/db/address.rs b/crates/router/src/db/address.rsindex 04a8f673a9..f15adbeea6 100644--- a/crates/router/src/db/address.rs+++ b/crates/router/src/db/address.rs@@ -64,7 +64,7 @@ whereasync fn find_address_by_merchant_id_payment_id_address_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,address_id: &str,key_store: &domain::MerchantKeyStore,@@ -75,7 +75,7 @@ where&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,address: storage_types::AddressUpdate,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Address>, errors::StorageError>;@@ -118,7 +118,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -130,7 +130,7 @@ mod storage {async fn find_address_by_merchant_id_payment_id_address_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,address_id: &str,key_store: &domain::MerchantKeyStore,@@ -147,7 +147,7 @@ mod storage {.map_err(|error| report!(errors::StorageError::from(error))).async_and_then(|address| async {address- .convert(state, key_store.key.get_inner(), merchant_id.to_string())+ .convert(state, key_store.key.get_inner(), merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)})@@ -171,7 +171,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -202,7 +202,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -232,7 +232,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -260,7 +260,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -273,7 +273,7 @@ mod storage {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,address: storage_types::AddressUpdate,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Address>, errors::StorageError> {@@ -291,7 +291,7 @@ mod storage {for address in addresses.into_iter() {output.push(address- .convert(state, key_store.key.get_inner(), merchant_id.to_string())+ .convert(state, key_store.key.get_inner(), merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)?,)@@ -346,7 +346,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -358,7 +358,7 @@ mod storage {async fn find_address_by_merchant_id_payment_id_address_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,address_id: &str,key_store: &domain::MerchantKeyStore,@@ -405,7 +405,9 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ common_utils::types::keymanager::Identifier::Merchant(+ key_store.merchant_id.clone(),+ ),).await.change_context(errors::StorageError::DecryptionError)@@ -428,7 +430,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -473,7 +475,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -514,7 +516,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -555,7 +557,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -619,7 +621,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?),@@ -649,7 +651,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -662,7 +664,7 @@ mod storage {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,address: storage_types::AddressUpdate,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Address>, errors::StorageError> {@@ -683,7 +685,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -716,7 +718,7 @@ impl AddressInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError),@@ -731,7 +733,7 @@ impl AddressInterface for MockDb {async fn find_address_by_merchant_id_payment_id_address_id(&self,state: &KeyManagerState,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,_payment_id: &str,address_id: &str,key_store: &domain::MerchantKeyStore,@@ -749,7 +751,7 @@ impl AddressInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError),@@ -785,7 +787,7 @@ impl AddressInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError),@@ -822,7 +824,7 @@ impl AddressInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError),@@ -853,7 +855,7 @@ impl AddressInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -877,7 +879,7 @@ impl AddressInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -887,7 +889,7 @@ impl AddressInterface for MockDb {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,address_update: storage_types::AddressUpdate,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Address>, errors::StorageError> {@@ -898,7 +900,7 @@ impl AddressInterface for MockDb {.iter_mut().find(|address| {address.customer_id.as_ref() == Some(customer_id)- && address.merchant_id == merchant_id+ && address.merchant_id == *merchant_id}).map(|a| {let address_updated =@@ -912,7 +914,7 @@ impl AddressInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?;diff --git a/crates/router/src/db/api_keys.rs b/crates/router/src/db/api_keys.rsindex ea63a88170..186bd004c1 100644--- a/crates/router/src/db/api_keys.rs+++ b/crates/router/src/db/api_keys.rs@@ -19,20 +19,20 @@ pub trait ApiKeyInterface {async fn update_api_key(&self,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,key_id: String,api_key: storage::ApiKeyUpdate,) -> CustomResult<storage::ApiKey, errors::StorageError>;async fn revoke_api_key(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> CustomResult<bool, errors::StorageError>;async fn find_api_key_by_merchant_id_key_id_optional(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> CustomResult<Option<storage::ApiKey>, errors::StorageError>;@@ -43,7 +43,7 @@ pub trait ApiKeyInterface {async fn list_api_keys_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,limit: Option<i64>,offset: Option<i64>,) -> CustomResult<Vec<storage::ApiKey>, errors::StorageError>;@@ -66,7 +66,7 @@ impl ApiKeyInterface for Store {#[instrument(skip_all)]async fn update_api_key(&self,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,key_id: String,api_key: storage::ApiKeyUpdate,) -> CustomResult<storage::ApiKey, errors::StorageError> {@@ -114,7 +114,7 @@ impl ApiKeyInterface for Store {#[instrument(skip_all)]async fn revoke_api_key(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -156,7 +156,7 @@ impl ApiKeyInterface for Store {#[instrument(skip_all)]async fn find_api_key_by_merchant_id_key_id_optional(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> CustomResult<Option<storage::ApiKey>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -198,7 +198,7 @@ impl ApiKeyInterface for Store {#[instrument(skip_all)]async fn list_api_keys_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,limit: Option<i64>,offset: Option<i64>,) -> CustomResult<Vec<storage::ApiKey>, errors::StorageError> {@@ -239,7 +239,7 @@ impl ApiKeyInterface for MockDb {async fn update_api_key(&self,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,key_id: String,api_key: storage::ApiKeyUpdate,) -> CustomResult<storage::ApiKey, errors::StorageError> {@@ -281,14 +281,14 @@ impl ApiKeyInterface for MockDb {async fn revoke_api_key(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> CustomResult<bool, errors::StorageError> {let mut locked_api_keys = self.api_keys.lock().await;// find the key to remove, if it existsif let Some(pos) = locked_api_keys.iter()- .position(|k| k.merchant_id == merchant_id && k.key_id == key_id)+ .position(|k| k.merchant_id == *merchant_id && k.key_id == key_id){// use `remove` instead of `swap_remove` so we have a consistent order, which might// matter to someone using limit/offset in `list_api_keys_by_merchant_id`@@ -301,7 +301,7 @@ impl ApiKeyInterface for MockDb {async fn find_api_key_by_merchant_id_key_id_optional(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_id: &str,) -> CustomResult<Option<storage::ApiKey>, errors::StorageError> {Ok(self@@ -309,7 +309,7 @@ impl ApiKeyInterface for MockDb {.lock().await.iter()- .find(|k| k.merchant_id == merchant_id && k.key_id == key_id)+ .find(|k| k.merchant_id == *merchant_id && k.key_id == key_id).cloned())}@@ -328,7 +328,7 @@ impl ApiKeyInterface for MockDb {async fn list_api_keys_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,limit: Option<i64>,offset: Option<i64>,) -> CustomResult<Vec<storage::ApiKey>, errors::StorageError> {@@ -360,7 +360,7 @@ impl ApiKeyInterface for MockDb {.lock().await.iter()- .filter(|k| k.merchant_id == merchant_id)+ .filter(|k| k.merchant_id == *merchant_id).skip(offset).take(limit).cloned()@@ -392,10 +392,12 @@ mod tests {.await.expect("Failed to create Mock store");+ let merchant_id = common_utils::id_type::MerchantId::from("merchant1".into()).unwrap();+let key1 = mockdb.insert_api_key(storage::ApiKeyNew {key_id: "key_id1".into(),- merchant_id: "merchant1".into(),+ merchant_id: merchant_id.clone(),name: "Key 1".into(),description: None,hashed_api_key: "hashed_key1".to_string().into(),@@ -410,7 +412,7 @@ mod tests {mockdb.insert_api_key(storage::ApiKeyNew {key_id: "key_id2".into(),- merchant_id: "merchant1".into(),+ merchant_id: merchant_id.clone(),name: "Key 2".into(),description: None,hashed_api_key: "hashed_key2".to_string().into(),@@ -423,20 +425,20 @@ mod tests {.unwrap();let found_key1 = mockdb- .find_api_key_by_merchant_id_key_id_optional("merchant1", "key_id1")+ .find_api_key_by_merchant_id_key_id_optional(&merchant_id, "key_id1").await.unwrap().unwrap();assert_eq!(found_key1.key_id, key1.key_id);assert!(mockdb- .find_api_key_by_merchant_id_key_id_optional("merchant1", "does_not_exist")+ .find_api_key_by_merchant_id_key_id_optional(&merchant_id, "does_not_exist").await.unwrap().is_none());mockdb.update_api_key(- "merchant1".into(),+ merchant_id.clone(),"key_id1".into(),storage::ApiKeyUpdate::LastUsedUpdate {last_used: datetime!(2023-02-04 1:11),@@ -445,7 +447,7 @@ mod tests {.await.unwrap();let updated_key1 = mockdb- .find_api_key_by_merchant_id_key_id_optional("merchant1", "key_id1")+ .find_api_key_by_merchant_id_key_id_optional(&merchant_id, "key_id1").await.unwrap().unwrap();@@ -453,16 +455,19 @@ mod tests {assert_eq!(mockdb- .list_api_keys_by_merchant_id("merchant1", None, None)+ .list_api_keys_by_merchant_id(&merchant_id, None, None).await.unwrap().len(),2);- mockdb.revoke_api_key("merchant1", "key_id1").await.unwrap();+ mockdb+ .revoke_api_key(&merchant_id, "key_id1")+ .await+ .unwrap();assert_eq!(mockdb- .list_api_keys_by_merchant_id("merchant1", None, None)+ .list_api_keys_by_merchant_id(&merchant_id, None, None).await.unwrap().len(),@@ -473,6 +478,8 @@ mod tests {#[allow(clippy::unwrap_used)]#[tokio::test]async fn test_api_keys_cache() {+ let merchant_id = common_utils::id_type::MerchantId::from("test_merchant".into()).unwrap();+#[allow(clippy::expect_used)]let db = MockDb::new(&redis_interface::RedisSettings::default()).await@@ -484,10 +491,9 @@ mod tests {.await.unwrap();- let merchant_id = "test_merchant";let api = storage::ApiKeyNew {key_id: "test_key".into(),- merchant_id: merchant_id.into(),+ merchant_id: merchant_id.clone(),name: "My test key".into(),description: None,hashed_api_key: "a_hashed_key".to_string().into(),@@ -506,19 +512,28 @@ mod tests {};let _: Option<storage::ApiKey> = cache::get_or_populate_in_memory(&db,- &format!("{}_{}", merchant_id, hashed_api_key.clone().into_inner()),+ &format!(+ "{}_{}",+ merchant_id.get_string_repr(),+ hashed_api_key.clone().into_inner()+ ),find_call,&ACCOUNTS_CACHE,).await.unwrap();- let delete_call = || async { db.revoke_api_key(merchant_id, &api.key_id).await };+ let delete_call = || async { db.revoke_api_key(&merchant_id, &api.key_id).await };cache::publish_and_redact(&db,CacheKind::Accounts(- format!("{}_{}", merchant_id, hashed_api_key.clone().into_inner()).into(),+ format!(+ "{}_{}",+ merchant_id.get_string_repr(),+ hashed_api_key.clone().into_inner()+ )+ .into(),),delete_call,)@@ -527,7 +542,11 @@ mod tests {assert!(ACCOUNTS_CACHE.get_val::<storage::ApiKey>(CacheKey {- key: format!("{}_{}", merchant_id, hashed_api_key.into_inner()),+ key: format!(+ "{}_{}",+ merchant_id.get_string_repr(),+ hashed_api_key.into_inner()+ ),prefix: String::default(),},).awaitdiff --git a/crates/router/src/db/authentication.rs b/crates/router/src/db/authentication.rsindex 43f30afd88..1307c53338 100644--- a/crates/router/src/db/authentication.rs+++ b/crates/router/src/db/authentication.rs@@ -18,13 +18,13 @@ pub trait AuthenticationInterface {async fn find_authentication_by_merchant_id_authentication_id(&self,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,authentication_id: String,) -> CustomResult<storage::Authentication, errors::StorageError>;async fn find_authentication_by_merchant_id_connector_authentication_id(&self,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,connector_authentication_id: String,) -> CustomResult<storage::Authentication, errors::StorageError>;@@ -52,13 +52,13 @@ impl AuthenticationInterface for Store {#[instrument(skip_all)]async fn find_authentication_by_merchant_id_authentication_id(&self,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,authentication_id: String,) -> CustomResult<storage::Authentication, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;storage::Authentication::find_by_merchant_id_authentication_id(&conn,- &merchant_id,+ merchant_id,&authentication_id,).await@@ -67,7 +67,7 @@ impl AuthenticationInterface for Store {async fn find_authentication_by_merchant_id_connector_authentication_id(&self,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,connector_authentication_id: String,) -> CustomResult<storage::Authentication, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -157,23 +157,23 @@ impl AuthenticationInterface for MockDb {async fn find_authentication_by_merchant_id_authentication_id(&self,- merchant_id: String,+ merchant_id: &common_utils::id_type::MerchantId,authentication_id: String,) -> CustomResult<storage::Authentication, errors::StorageError> {let authentications = self.authentications.lock().await;authentications.iter()- .find(|a| a.merchant_id == merchant_id && a.authentication_id == authentication_id)+ .find(|a| a.merchant_id == *merchant_id && a.authentication_id == authentication_id).ok_or(errors::StorageError::ValueNotFound(format!(- "cannot find authentication for authentication_id = {authentication_id} and merchant_id = {merchant_id}"+ "cannot find authentication for authentication_id = {authentication_id} and merchant_id = {merchant_id:?}")).into(),).cloned()}async fn find_authentication_by_merchant_id_connector_authentication_id(&self,- _merchant_id: String,+ _merchant_id: common_utils::id_type::MerchantId,_connector_authentication_id: String,) -> CustomResult<storage::Authentication, errors::StorageError> {Err(errors::StorageError::MockDbError)?@@ -199,7 +199,7 @@ impl AuthenticationInterface for MockDb {}).ok_or(errors::StorageError::ValueNotFound(format!(- "cannot find authentication for authentication_id = {authentication_id} and merchant_id = {merchant_id}"+ "cannot find authentication for authentication_id = {authentication_id} and merchant_id = {merchant_id:?}")).into(),)diff --git a/crates/router/src/db/authorization.rs b/crates/router/src/db/authorization.rsindex 7b7802d64e..40902ce888 100644--- a/crates/router/src/db/authorization.rs+++ b/crates/router/src/db/authorization.rs@@ -18,13 +18,13 @@ pub trait AuthorizationInterface {async fn find_all_authorizations_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> CustomResult<Vec<storage::Authorization>, errors::StorageError>;async fn update_authorization_by_merchant_id_authorization_id(&self,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,authorization_id: String,authorization: storage::AuthorizationUpdate,) -> CustomResult<storage::Authorization, errors::StorageError>;@@ -47,7 +47,7 @@ impl AuthorizationInterface for Store {#[instrument(skip_all)]async fn find_all_authorizations_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> CustomResult<Vec<storage::Authorization>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -59,7 +59,7 @@ impl AuthorizationInterface for Store {#[instrument(skip_all)]async fn update_authorization_by_merchant_id_authorization_id(&self,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,authorization_id: String,authorization: storage::AuthorizationUpdate,) -> CustomResult<storage::Authorization, errors::StorageError> {@@ -109,13 +109,13 @@ impl AuthorizationInterface for MockDb {async fn find_all_authorizations_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> CustomResult<Vec<storage::Authorization>, errors::StorageError> {let authorizations = self.authorizations.lock().await;let authorizations_found: Vec<storage::Authorization> = authorizations.iter()- .filter(|a| a.merchant_id == merchant_id && a.payment_id == payment_id)+ .filter(|a| a.merchant_id == *merchant_id && a.payment_id == payment_id).cloned().collect();@@ -124,7 +124,7 @@ impl AuthorizationInterface for MockDb {async fn update_authorization_by_merchant_id_authorization_id(&self,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,authorization_id: String,authorization_update: storage::AuthorizationUpdate,) -> CustomResult<storage::Authorization, errors::StorageError> {@@ -141,7 +141,7 @@ impl AuthorizationInterface for MockDb {}).ok_or(errors::StorageError::ValueNotFound(format!(- "cannot find authorization for authorization_id = {authorization_id} and merchant_id = {merchant_id}"+ "cannot find authorization for authorization_id = {authorization_id} and merchant_id = {merchant_id:?}")).into(),)diff --git a/crates/router/src/db/blocklist.rs b/crates/router/src/db/blocklist.rsindex 4a7236c95a..4740af9f81 100644--- a/crates/router/src/db/blocklist.rs+++ b/crates/router/src/db/blocklist.rs@@ -19,24 +19,24 @@ pub trait BlocklistInterface {async fn find_blocklist_entry_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> CustomResult<storage::Blocklist, errors::StorageError>;async fn delete_blocklist_entry_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> CustomResult<storage::Blocklist, errors::StorageError>;async fn list_blocklist_entries_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError>;async fn list_blocklist_entries_by_merchant_id_data_kind(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,data_kind: common_enums::BlocklistDataKind,limit: i64,offset: i64,@@ -60,7 +60,7 @@ impl BlocklistInterface for Store {#[instrument(skip_all)]async fn find_blocklist_entry_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> CustomResult<storage::Blocklist, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -72,7 +72,7 @@ impl BlocklistInterface for Store {#[instrument(skip_all)]async fn list_blocklist_entries_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;storage::Blocklist::list_by_merchant_id(&conn, merchant_id)@@ -83,7 +83,7 @@ impl BlocklistInterface for Store {#[instrument(skip_all)]async fn list_blocklist_entries_by_merchant_id_data_kind(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,data_kind: common_enums::BlocklistDataKind,limit: i64,offset: i64,@@ -103,7 +103,7 @@ impl BlocklistInterface for Store {#[instrument(skip_all)]async fn delete_blocklist_entry_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> CustomResult<storage::Blocklist, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -125,7 +125,7 @@ impl BlocklistInterface for MockDb {async fn find_blocklist_entry_by_merchant_id_fingerprint_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_fingerprint_id: &str,) -> CustomResult<storage::Blocklist, errors::StorageError> {Err(errors::StorageError::MockDbError)?@@ -133,14 +133,14 @@ impl BlocklistInterface for MockDb {async fn list_blocklist_entries_by_merchant_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> {Err(errors::StorageError::MockDbError)?}async fn list_blocklist_entries_by_merchant_id_data_kind(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_data_kind: common_enums::BlocklistDataKind,_limit: i64,_offset: i64,@@ -150,7 +150,7 @@ impl BlocklistInterface for MockDb {async fn delete_blocklist_entry_by_merchant_id_fingerprint_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_fingerprint_id: &str,) -> CustomResult<storage::Blocklist, errors::StorageError> {Err(errors::StorageError::MockDbError)?@@ -170,7 +170,7 @@ impl BlocklistInterface for KafkaStore {#[instrument(skip_all)]async fn find_blocklist_entry_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::Blocklist, errors::StorageError> {self.diesel_store@@ -181,7 +181,7 @@ impl BlocklistInterface for KafkaStore {#[instrument(skip_all)]async fn delete_blocklist_entry_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::Blocklist, errors::StorageError> {self.diesel_store@@ -192,7 +192,7 @@ impl BlocklistInterface for KafkaStore {#[instrument(skip_all)]async fn list_blocklist_entries_by_merchant_id_data_kind(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,data_kind: common_enums::BlocklistDataKind,limit: i64,offset: i64,@@ -205,7 +205,7 @@ impl BlocklistInterface for KafkaStore {#[instrument(skip_all)]async fn list_blocklist_entries_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> {self.diesel_store.list_blocklist_entries_by_merchant_id(merchant_id)diff --git a/crates/router/src/db/blocklist_fingerprint.rs b/crates/router/src/db/blocklist_fingerprint.rsindex 65671555c7..835bad5ea9 100644--- a/crates/router/src/db/blocklist_fingerprint.rs+++ b/crates/router/src/db/blocklist_fingerprint.rs@@ -19,7 +19,7 @@ pub trait BlocklistFingerprintInterface {async fn find_blocklist_fingerprint_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> CustomResult<storage::BlocklistFingerprint, errors::StorageError>;}@@ -41,7 +41,7 @@ impl BlocklistFingerprintInterface for Store {#[instrument(skip_all)]async fn find_blocklist_fingerprint_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint_id: &str,) -> CustomResult<storage::BlocklistFingerprint, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -66,7 +66,7 @@ impl BlocklistFingerprintInterface for MockDb {async fn find_blocklist_fingerprint_by_merchant_id_fingerprint_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_fingerprint_id: &str,) -> CustomResult<storage::BlocklistFingerprint, errors::StorageError> {Err(errors::StorageError::MockDbError)?@@ -88,7 +88,7 @@ impl BlocklistFingerprintInterface for KafkaStore {#[instrument(skip_all)]async fn find_blocklist_fingerprint_by_merchant_id_fingerprint_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::BlocklistFingerprint, errors::StorageError> {self.diesel_storediff --git a/crates/router/src/db/blocklist_lookup.rs b/crates/router/src/db/blocklist_lookup.rsindex 0f796946be..8829f3804e 100644--- a/crates/router/src/db/blocklist_lookup.rs+++ b/crates/router/src/db/blocklist_lookup.rs@@ -19,13 +19,13 @@ pub trait BlocklistLookupInterface {async fn find_blocklist_lookup_entry_by_merchant_id_fingerprint(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::BlocklistLookup, errors::StorageError>;async fn delete_blocklist_lookup_entry_by_merchant_id_fingerprint(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::BlocklistLookup, errors::StorageError>;}@@ -47,7 +47,7 @@ impl BlocklistLookupInterface for Store {#[instrument(skip_all)]async fn find_blocklist_lookup_entry_by_merchant_id_fingerprint(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::BlocklistLookup, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -59,7 +59,7 @@ impl BlocklistLookupInterface for Store {#[instrument(skip_all)]async fn delete_blocklist_lookup_entry_by_merchant_id_fingerprint(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::BlocklistLookup, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -81,7 +81,7 @@ impl BlocklistLookupInterface for MockDb {async fn find_blocklist_lookup_entry_by_merchant_id_fingerprint(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_fingerprint: &str,) -> CustomResult<storage::BlocklistLookup, errors::StorageError> {Err(errors::StorageError::MockDbError)?@@ -89,7 +89,7 @@ impl BlocklistLookupInterface for MockDb {async fn delete_blocklist_lookup_entry_by_merchant_id_fingerprint(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_fingerprint: &str,) -> CustomResult<storage::BlocklistLookup, errors::StorageError> {Err(errors::StorageError::MockDbError)?@@ -111,7 +111,7 @@ impl BlocklistLookupInterface for KafkaStore {#[instrument(skip_all)]async fn find_blocklist_lookup_entry_by_merchant_id_fingerprint(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::BlocklistLookup, errors::StorageError> {self.diesel_store@@ -122,7 +122,7 @@ impl BlocklistLookupInterface for KafkaStore {#[instrument(skip_all)]async fn delete_blocklist_lookup_entry_by_merchant_id_fingerprint(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,fingerprint: &str,) -> CustomResult<storage::BlocklistLookup, errors::StorageError> {self.diesel_storediff --git a/crates/router/src/db/business_profile.rs b/crates/router/src/db/business_profile.rsindex 5e7c9bd0b2..099cad9b80 100644--- a/crates/router/src/db/business_profile.rs+++ b/crates/router/src/db/business_profile.rs@@ -24,7 +24,7 @@ pub trait BusinessProfileInterface {async fn find_business_profile_by_profile_name_merchant_id(&self,profile_name: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<business_profile::BusinessProfile, errors::StorageError>;async fn update_business_profile_by_profile_id(@@ -36,12 +36,12 @@ pub trait BusinessProfileInterface {async fn delete_business_profile_by_profile_id_merchant_id(&self,profile_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError>;async fn list_business_profile_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<business_profile::BusinessProfile>, errors::StorageError>;}@@ -74,7 +74,7 @@ impl BusinessProfileInterface for Store {async fn find_business_profile_by_profile_name_merchant_id(&self,profile_name: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<business_profile::BusinessProfile, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;business_profile::BusinessProfile::find_by_profile_name_merchant_id(@@ -106,7 +106,7 @@ impl BusinessProfileInterface for Store {async fn delete_business_profile_by_profile_id_merchant_id(&self,profile_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;business_profile::BusinessProfile::delete_by_profile_id_merchant_id(@@ -121,7 +121,7 @@ impl BusinessProfileInterface for Store {#[instrument(skip_all)]async fn list_business_profile_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<business_profile::BusinessProfile>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;business_profile::BusinessProfile::list_business_profile_by_merchant_id(&conn, merchant_id)@@ -191,14 +191,14 @@ impl BusinessProfileInterface for MockDb {async fn delete_business_profile_by_profile_id_merchant_id(&self,profile_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let mut business_profiles = self.business_profiles.lock().await;let index = business_profiles.iter()- .position(|bp| bp.profile_id == profile_id && bp.merchant_id == merchant_id)+ .position(|bp| bp.profile_id == profile_id && bp.merchant_id == *merchant_id).ok_or::<errors::StorageError>(errors::StorageError::ValueNotFound(format!(- "No business profile found for profile_id = {} and merchant_id = {}",+ "No business profile found for profile_id = {} and merchant_id = {:?}",profile_id, merchant_id)))?;business_profiles.remove(index);@@ -207,14 +207,14 @@ impl BusinessProfileInterface for MockDb {async fn list_business_profile_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<business_profile::BusinessProfile>, errors::StorageError> {let business_profile_by_merchant_id = self.business_profiles.lock().await.iter()- .filter(|business_profile| business_profile.merchant_id == merchant_id)+ .filter(|business_profile| business_profile.merchant_id == *merchant_id).cloned().collect();@@ -224,7 +224,7 @@ impl BusinessProfileInterface for MockDb {async fn find_business_profile_by_profile_name_merchant_id(&self,_profile_name: &str,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<business_profile::BusinessProfile, errors::StorageError> {Err(errors::StorageError::MockDbError)?}diff --git a/crates/router/src/db/capture.rs b/crates/router/src/db/capture.rsindex 48aad6a9e3..34ef1bfddf 100644--- a/crates/router/src/db/capture.rs+++ b/crates/router/src/db/capture.rs@@ -16,7 +16,7 @@ pub trait CaptureInterface {async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,authorized_attempt_id: &str,storage_scheme: enums::MerchantStorageScheme,@@ -80,7 +80,7 @@ mod storage {#[instrument(skip_all)]async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,authorized_attempt_id: &str,_storage_scheme: enums::MerchantStorageScheme,@@ -151,7 +151,7 @@ mod storage {#[instrument(skip_all)]async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,authorized_attempt_id: &str,_storage_scheme: enums::MerchantStorageScheme,@@ -215,7 +215,7 @@ impl CaptureInterface for MockDb {}async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_payment_id: &str,_authorized_attempt_id: &str,_storage_scheme: enums::MerchantStorageScheme,diff --git a/crates/router/src/db/customers.rs b/crates/router/src/db/customers.rsindex 4bb29c3741..01c7d7737a 100644--- a/crates/router/src/db/customers.rs+++ b/crates/router/src/db/customers.rs@@ -25,14 +25,14 @@ whereasync fn delete_customer_by_customer_id_merchant_id(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError>;async fn find_customer_optional_by_customer_id_merchant_id(&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> CustomResult<Option<customer::Customer>, errors::StorageError>;@@ -42,7 +42,7 @@ where&self,state: &KeyManagerState,customer_id: id_type::CustomerId,- merchant_id: String,+ merchant_id: id_type::MerchantId,customer: customer::Customer,customer_update: storage_types::CustomerUpdate,key_store: &domain::MerchantKeyStore,@@ -53,7 +53,7 @@ where&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> CustomResult<customer::Customer, errors::StorageError>;@@ -61,7 +61,7 @@ whereasync fn list_customers_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<customer::Customer>, errors::StorageError>;@@ -113,7 +113,7 @@ mod storage {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> CustomResult<Option<customer::Customer>, errors::StorageError> {@@ -161,7 +161,7 @@ mod storage {c.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -182,7 +182,7 @@ mod storage {&self,state: &KeyManagerState,customer_id: id_type::CustomerId,- merchant_id: String,+ merchant_id: id_type::MerchantId,customer: customer::Customer,customer_update: storage_types::CustomerUpdate,key_store: &domain::MerchantKeyStore,@@ -203,7 +203,7 @@ mod storage {.map_err(|error| report!(errors::StorageError::from(error)))};let key = PartitionKey::MerchantIdCustomerId {- merchant_id: merchant_id.as_str(),+ merchant_id: &merchant_id,customer_id: customer_id.get_string_repr(),};let field = format!("cust_{}", customer_id.get_string_repr());@@ -253,7 +253,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -264,7 +264,7 @@ mod storage {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> CustomResult<customer::Customer, errors::StorageError> {@@ -309,7 +309,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?;@@ -327,7 +327,7 @@ mod storage {async fn list_customers_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<customer::Customer>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -343,7 +343,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -385,7 +385,7 @@ mod storage {}MerchantStorageScheme::RedisKv => {let key = PartitionKey::MerchantIdCustomerId {- merchant_id: merchant_id.as_str(),+ merchant_id: &merchant_id,customer_id: customer_id.get_string_repr(),};let field = format!("cust_{}", customer_id.get_string_repr());@@ -426,7 +426,7 @@ mod storage {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -436,7 +436,7 @@ mod storage {async fn delete_customer_by_customer_id_merchant_id(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;storage_types::Customer::delete_by_customer_id_merchant_id(@@ -483,7 +483,7 @@ mod storage {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,_storage_scheme: MerchantStorageScheme,) -> CustomResult<Option<customer::Customer>, errors::StorageError> {@@ -497,7 +497,7 @@ mod storage {.await.map_err(|error| report!(errors::StorageError::from(error)))?.async_map(|c| async {- c.convert(state, key_store.key.get_inner(), merchant_id.to_string())+ c.convert(state, key_store.key.get_inner(), merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)})@@ -520,7 +520,7 @@ mod storage {&self,state: &KeyManagerState,customer_id: id_type::CustomerId,- merchant_id: String,+ merchant_id: id_type::MerchantId,_customer: customer::Customer,customer_update: storage_types::CustomerUpdate,key_store: &domain::MerchantKeyStore,@@ -536,7 +536,7 @@ mod storage {.await.map_err(|error| report!(errors::StorageError::from(error))).async_and_then(|c| async {- c.convert(state, key_store.key.get_inner(), merchant_id)+ c.convert(state, key_store.key.get_inner(), merchant_id.into()).await.change_context(errors::StorageError::DecryptionError)})@@ -548,7 +548,7 @@ mod storage {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,_storage_scheme: MerchantStorageScheme,) -> CustomResult<customer::Customer, errors::StorageError> {@@ -562,7 +562,7 @@ mod storage {.await.map_err(|error| report!(errors::StorageError::from(error))).async_and_then(|c| async {- c.convert(state, key_store.key.get_inner(), merchant_id.to_string())+ c.convert(state, key_store.key.get_inner(), merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)})@@ -579,7 +579,7 @@ mod storage {async fn list_customers_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<customer::Customer>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -592,7 +592,7 @@ mod storage {let customers = try_join_all(encrypted_customers.into_iter().map(|encrypted_customer| async {encrypted_customer- .convert(state, key_store.key.get_inner(), merchant_id.to_string())+ .convert(state, key_store.key.get_inner(), merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)},@@ -622,7 +622,7 @@ mod storage {c.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -634,7 +634,7 @@ mod storage {async fn delete_customer_by_customer_id_merchant_id(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;storage_types::Customer::delete_by_customer_id_merchant_id(@@ -655,7 +655,7 @@ impl CustomerInterface for MockDb {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,_storage_scheme: MerchantStorageScheme,) -> CustomResult<Option<customer::Customer>, errors::StorageError> {@@ -663,7 +663,7 @@ impl CustomerInterface for MockDb {let customer = customers.iter().find(|customer| {- customer.customer_id == *customer_id && customer.merchant_id == merchant_id+ customer.customer_id == *customer_id && &customer.merchant_id == merchant_id}).cloned();customer@@ -671,7 +671,7 @@ impl CustomerInterface for MockDb {c.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -683,7 +683,7 @@ impl CustomerInterface for MockDb {async fn list_customers_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<customer::Customer>, errors::StorageError> {let customers = self.customers.lock().await;@@ -691,14 +691,14 @@ impl CustomerInterface for MockDb {let customers = try_join_all(customers.iter()- .filter(|customer| customer.merchant_id == merchant_id)+ .filter(|customer| customer.merchant_id == *merchant_id).map(|customer| async {customer.to_owned().convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -714,7 +714,7 @@ impl CustomerInterface for MockDb {&self,_state: &KeyManagerState,_customer_id: id_type::CustomerId,- _merchant_id: String,+ _merchant_id: id_type::MerchantId,_customer: customer::Customer,_customer_update: storage_types::CustomerUpdate,_key_store: &domain::MerchantKeyStore,@@ -728,7 +728,7 @@ impl CustomerInterface for MockDb {&self,_state: &KeyManagerState,_customer_id: &id_type::CustomerId,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,_key_store: &domain::MerchantKeyStore,_storage_scheme: MerchantStorageScheme,) -> CustomResult<customer::Customer, errors::StorageError> {@@ -756,7 +756,7 @@ impl CustomerInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -765,7 +765,7 @@ impl CustomerInterface for MockDb {async fn delete_customer_by_customer_id_merchant_id(&self,_customer_id: &id_type::CustomerId,- _merchant_id: &str,+ _merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {// [#172]: Implement function for `MockDb`Err(errors::StorageError::MockDbError)?diff --git a/crates/router/src/db/dashboard_metadata.rs b/crates/router/src/db/dashboard_metadata.rsindex 2cbe6ad975..f8aee34c49 100644--- a/crates/router/src/db/dashboard_metadata.rs+++ b/crates/router/src/db/dashboard_metadata.rs@@ -20,7 +20,7 @@ pub trait DashboardMetadataInterface {async fn update_metadata(&self,user_id: Option<String>,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,data_key: enums::DashboardMetadata,dashboard_metadata_update: storage::DashboardMetadataUpdate,@@ -29,14 +29,14 @@ pub trait DashboardMetadataInterface {async fn find_user_scoped_dashboard_metadata(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,data_keys: Vec<enums::DashboardMetadata>,) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError>;async fn find_merchant_scoped_dashboard_metadata(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,data_keys: Vec<enums::DashboardMetadata>,) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError>;@@ -44,13 +44,13 @@ pub trait DashboardMetadataInterface {async fn delete_all_user_scoped_dashboard_metadata_by_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError>;async fn delete_user_scoped_dashboard_metadata_by_merchant_id_data_key(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,data_key: enums::DashboardMetadata,) -> CustomResult<storage::DashboardMetadata, errors::StorageError>;}@@ -73,7 +73,7 @@ impl DashboardMetadataInterface for Store {async fn update_metadata(&self,user_id: Option<String>,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,data_key: enums::DashboardMetadata,dashboard_metadata_update: storage::DashboardMetadataUpdate,@@ -95,7 +95,7 @@ impl DashboardMetadataInterface for Store {async fn find_user_scoped_dashboard_metadata(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,data_keys: Vec<enums::DashboardMetadata>,) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {@@ -114,7 +114,7 @@ impl DashboardMetadataInterface for Store {#[instrument(skip_all)]async fn find_merchant_scoped_dashboard_metadata(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,data_keys: Vec<enums::DashboardMetadata>,) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {@@ -133,7 +133,7 @@ impl DashboardMetadataInterface for Store {async fn delete_all_user_scoped_dashboard_metadata_by_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;storage::DashboardMetadata::delete_all_user_scoped_dashboard_metadata_by_merchant_id(@@ -149,7 +149,7 @@ impl DashboardMetadataInterface for Store {async fn delete_user_scoped_dashboard_metadata_by_merchant_id_data_key(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,data_key: enums::DashboardMetadata,) -> CustomResult<storage::DashboardMetadata, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -202,7 +202,7 @@ impl DashboardMetadataInterface for MockDb {async fn update_metadata(&self,user_id: Option<String>,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,data_key: enums::DashboardMetadata,dashboard_metadata_update: storage::DashboardMetadataUpdate,@@ -237,7 +237,7 @@ impl DashboardMetadataInterface for MockDb {async fn find_user_scoped_dashboard_metadata(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,data_keys: Vec<enums::DashboardMetadata>,) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {@@ -250,7 +250,7 @@ impl DashboardMetadataInterface for MockDb {.clone().map(|user_id_inner| user_id_inner == user_id).unwrap_or(false)- && metadata_inner.merchant_id == merchant_id+ && metadata_inner.merchant_id == *merchant_id&& metadata_inner.org_id == *org_id&& data_keys.contains(&metadata_inner.data_key)})@@ -260,7 +260,7 @@ impl DashboardMetadataInterface for MockDb {if query_result.is_empty() {return Err(errors::StorageError::ValueNotFound(format!("No dashboard_metadata available for user_id = {user_id},\- merchant_id = {merchant_id}, org_id = {org_id:?} and data_keys = {data_keys:?}",+ merchant_id = {merchant_id:?}, org_id = {org_id:?} and data_keys = {data_keys:?}",)).into());}@@ -269,7 +269,7 @@ impl DashboardMetadataInterface for MockDb {async fn find_merchant_scoped_dashboard_metadata(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,data_keys: Vec<enums::DashboardMetadata>,) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {@@ -277,7 +277,7 @@ impl DashboardMetadataInterface for MockDb {let query_result = dashboard_metadata.iter().filter(|metadata_inner| {- metadata_inner.merchant_id == merchant_id+ metadata_inner.merchant_id == *merchant_id&& metadata_inner.org_id == *org_id&& data_keys.contains(&metadata_inner.data_key)})@@ -286,7 +286,7 @@ impl DashboardMetadataInterface for MockDb {if query_result.is_empty() {return Err(errors::StorageError::ValueNotFound(format!(- "No dashboard_metadata available for merchant_id = {merchant_id},\+ "No dashboard_metadata available for merchant_id = {merchant_id:?},\org_id = {org_id:?} and data_keyss = {data_keys:?}",)).into());@@ -296,7 +296,7 @@ impl DashboardMetadataInterface for MockDb {async fn delete_all_user_scoped_dashboard_metadata_by_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let mut dashboard_metadata = self.dashboard_metadata.lock().await;@@ -308,12 +308,12 @@ impl DashboardMetadataInterface for MockDb {.clone().map(|user_id_inner| user_id_inner == user_id).unwrap_or(false)- && metadata_inner.merchant_id == merchant_id)+ && metadata_inner.merchant_id == *merchant_id)});if dashboard_metadata.len() == initial_len {return Err(errors::StorageError::ValueNotFound(format!(- "No user available for user_id = {user_id} and merchant id = {merchant_id}"+ "No user available for user_id = {user_id} and merchant id = {merchant_id:?}")).into());}@@ -324,7 +324,7 @@ impl DashboardMetadataInterface for MockDb {async fn delete_user_scoped_dashboard_metadata_by_merchant_id_data_key(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,data_key: enums::DashboardMetadata,) -> CustomResult<storage::DashboardMetadata, errors::StorageError> {let mut dashboard_metadata = self.dashboard_metadata.lock().await;@@ -336,7 +336,7 @@ impl DashboardMetadataInterface for MockDb {.user_id.as_deref().map_or(false, |user_id_inner| user_id_inner == user_id)- && metadata_inner.merchant_id == merchant_id+ && metadata_inner.merchant_id == *merchant_id&& metadata_inner.data_key == data_key}).ok_or(errors::StorageError::ValueNotFound(diff --git a/crates/router/src/db/dispute.rs b/crates/router/src/db/dispute.rsindex 097ad9beab..4de14057c1 100644--- a/crates/router/src/db/dispute.rs+++ b/crates/router/src/db/dispute.rs@@ -17,26 +17,26 @@ pub trait DisputeInterface {async fn find_by_merchant_id_payment_id_connector_dispute_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,connector_dispute_id: &str,) -> CustomResult<Option<storage::Dispute>, errors::StorageError>;async fn find_dispute_by_merchant_id_dispute_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_id: &str,) -> CustomResult<storage::Dispute, errors::StorageError>;async fn find_disputes_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_constraints: api_models::disputes::DisputeListConstraints,) -> CustomResult<Vec<storage::Dispute>, errors::StorageError>;async fn find_disputes_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> CustomResult<Vec<storage::Dispute>, errors::StorageError>;@@ -64,7 +64,7 @@ impl DisputeInterface for Store {#[instrument(skip_all)]async fn find_by_merchant_id_payment_id_connector_dispute_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,connector_dispute_id: &str,) -> CustomResult<Option<storage::Dispute>, errors::StorageError> {@@ -82,7 +82,7 @@ impl DisputeInterface for Store {#[instrument(skip_all)]async fn find_dispute_by_merchant_id_dispute_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_id: &str,) -> CustomResult<storage::Dispute, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -94,7 +94,7 @@ impl DisputeInterface for Store {#[instrument(skip_all)]async fn find_disputes_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_constraints: api_models::disputes::DisputeListConstraints,) -> CustomResult<Vec<storage::Dispute>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -106,7 +106,7 @@ impl DisputeInterface for Store {#[instrument(skip_all)]async fn find_disputes_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> CustomResult<Vec<storage::Dispute>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -180,7 +180,7 @@ impl DisputeInterface for MockDb {}async fn find_by_merchant_id_payment_id_connector_dispute_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,connector_dispute_id: &str,) -> CustomResult<Option<storage::Dispute>, errors::StorageError> {@@ -190,7 +190,7 @@ impl DisputeInterface for MockDb {.await.iter().find(|d| {- d.merchant_id == merchant_id+ d.merchant_id == *merchant_id&& d.payment_id == payment_id&& d.connector_dispute_id == connector_dispute_id})@@ -199,22 +199,22 @@ impl DisputeInterface for MockDb {async fn find_dispute_by_merchant_id_dispute_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_id: &str,) -> CustomResult<storage::Dispute, errors::StorageError> {let locked_disputes = self.disputes.lock().await;locked_disputes.iter()- .find(|d| d.merchant_id == merchant_id && d.dispute_id == dispute_id)+ .find(|d| d.merchant_id == *merchant_id && d.dispute_id == dispute_id).cloned()- .ok_or(errors::StorageError::ValueNotFound(format!("No dispute available for merchant_id = {merchant_id} and dispute_id = {dispute_id}"))+ .ok_or(errors::StorageError::ValueNotFound(format!("No dispute available for merchant_id = {merchant_id:?} and dispute_id = {dispute_id}")).into())}async fn find_disputes_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_constraints: api_models::disputes::DisputeListConstraints,) -> CustomResult<Vec<storage::Dispute>, errors::StorageError> {let locked_disputes = self.disputes.lock().await;@@ -222,7 +222,7 @@ impl DisputeInterface for MockDb {Ok(locked_disputes.iter().filter(|d| {- d.merchant_id == merchant_id+ d.merchant_id == *merchant_id&& dispute_constraints.dispute_status.as_ref()@@ -285,14 +285,14 @@ impl DisputeInterface for MockDb {async fn find_disputes_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,) -> CustomResult<Vec<storage::Dispute>, errors::StorageError> {let locked_disputes = self.disputes.lock().await;Ok(locked_disputes.iter()- .filter(|d| d.merchant_id == merchant_id && d.payment_id == payment_id)+ .filter(|d| d.merchant_id == *merchant_id && d.payment_id == payment_id).cloned().collect())}@@ -381,7 +381,7 @@ mod tests {dispute_id: String,payment_id: String,attempt_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,connector_dispute_id: String,}@@ -417,11 +417,13 @@ mod tests {.await.expect("Failed to create a mock DB");+ let merchant_id = common_utils::id_type::MerchantId::from("merchant_1".into()).unwrap();+let created_dispute = mockdb.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_1".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -443,6 +445,8 @@ mod tests {#[tokio::test]async fn test_find_by_merchant_id_payment_id_connector_dispute_id() {+ let merchant_id = common_utils::id_type::MerchantId::from("merchant_1".into()).unwrap();+#[allow(clippy::expect_used)]let mockdb = MockDb::new(&RedisSettings::default()).await@@ -452,7 +456,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_1".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -463,7 +467,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_2".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_2".into(),}))@@ -472,7 +476,7 @@ mod tests {let found_dispute = mockdb.find_by_merchant_id_payment_id_connector_dispute_id(- "merchant_1",+ &merchant_id,"payment_1","connector_dispute_1",)@@ -486,6 +490,7 @@ mod tests {#[tokio::test]async fn test_find_dispute_by_merchant_id_dispute_id() {+ let merchant_id = common_utils::id_type::MerchantId::from("merchant_1".into()).unwrap();#[allow(clippy::expect_used)]let mockdb = MockDb::new(&RedisSettings::default()).await@@ -495,7 +500,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_1".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -506,7 +511,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_2".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -514,7 +519,7 @@ mod tests {.unwrap();let found_dispute = mockdb- .find_dispute_by_merchant_id_dispute_id("merchant_1", "dispute_1")+ .find_dispute_by_merchant_id_dispute_id(&merchant_id, "dispute_1").await.unwrap();@@ -523,6 +528,7 @@ mod tests {#[tokio::test]async fn test_find_disputes_by_merchant_id() {+ let merchant_id = common_utils::id_type::MerchantId::from("merchant_2".into()).unwrap();#[allow(clippy::expect_used)]let mockdb = MockDb::new(&RedisSettings::default()).await@@ -532,7 +538,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_1".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -543,7 +549,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_2".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_2".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -552,7 +558,7 @@ mod tests {let found_disputes = mockdb.find_disputes_by_merchant_id(- "merchant_1",+ &merchant_id,DisputeListConstraints {limit: None,dispute_status: None,@@ -577,6 +583,7 @@ mod tests {#[tokio::test]async fn test_find_disputes_by_merchant_id_payment_id() {+ let merchant_id = common_utils::id_type::MerchantId::from("merchant_1".into()).unwrap();#[allow(clippy::expect_used)]let mockdb = MockDb::new(&RedisSettings::default()).await@@ -586,7 +593,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_1".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -597,7 +604,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_2".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_2".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -605,7 +612,7 @@ mod tests {.unwrap();let found_disputes = mockdb- .find_disputes_by_merchant_id_payment_id("merchant_1", "payment_1")+ .find_disputes_by_merchant_id_payment_id(&merchant_id, "payment_1").await.unwrap();@@ -633,6 +640,8 @@ mod tests {#[tokio::test]async fn test_update_dispute_update() {+ let merchant_id =+ common_utils::id_type::MerchantId::from("merchant_1".into()).unwrap();#[allow(clippy::expect_used)]let mockdb = MockDb::new(&redis_interface::RedisSettings::default()).await@@ -642,7 +651,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_1".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -713,6 +722,8 @@ mod tests {#[tokio::test]async fn test_update_dispute_update_status() {+ let merchant_id =+ common_utils::id_type::MerchantId::from("merchant_1".into()).unwrap();#[allow(clippy::expect_used)]let mockdb = MockDb::new(&redis_interface::RedisSettings::default()).await@@ -722,7 +733,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_1".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))@@ -788,6 +799,8 @@ mod tests {#[tokio::test]async fn test_update_dispute_update_evidence() {+ let merchant_id =+ common_utils::id_type::MerchantId::from("merchant_1".into()).unwrap();#[allow(clippy::expect_used)]let mockdb = MockDb::new(&redis_interface::RedisSettings::default()).await@@ -797,7 +810,7 @@ mod tests {.insert_dispute(create_dispute_new(DisputeNewIds {dispute_id: "dispute_1".into(),attempt_id: "attempt_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: merchant_id.clone(),payment_id: "payment_1".into(),connector_dispute_id: "connector_dispute_1".into(),}))diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex 2fd8a09f17..4cb05ba5ba 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -31,7 +31,7 @@ whereasync fn find_event_by_merchant_id_event_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::Event, errors::StorageError>;@@ -39,7 +39,7 @@ whereasync fn list_initial_events_by_merchant_id_primary_object_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,primary_object_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError>;@@ -48,7 +48,7 @@ whereasync fn list_initial_events_by_merchant_id_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,created_after: Option<time::PrimitiveDateTime>,created_before: Option<time::PrimitiveDateTime>,limit: Option<i64>,@@ -59,7 +59,7 @@ whereasync fn list_events_by_merchant_id_initial_attempt_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,initial_attempt_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError>;@@ -95,7 +95,7 @@ whereasync fn update_event_by_merchant_id_event_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,event: domain::EventUpdate,merchant_key_store: &domain::MerchantKeyStore,@@ -122,7 +122,7 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -132,7 +132,7 @@ impl EventInterface for Store {async fn find_event_by_merchant_id_event_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::Event, errors::StorageError> {@@ -143,7 +143,7 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -153,7 +153,7 @@ impl EventInterface for Store {async fn list_initial_events_by_merchant_id_primary_object_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,primary_object_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -173,7 +173,7 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -188,7 +188,7 @@ impl EventInterface for Store {async fn list_initial_events_by_merchant_id_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,created_after: Option<time::PrimitiveDateTime>,created_before: Option<time::PrimitiveDateTime>,limit: Option<i64>,@@ -214,7 +214,7 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -229,7 +229,7 @@ impl EventInterface for Store {async fn list_events_by_merchant_id_initial_attempt_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,initial_attempt_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -249,7 +249,7 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -284,7 +284,7 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -325,7 +325,9 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ common_utils::types::keymanager::Identifier::Merchant(+ merchant_key_store.merchant_id.clone(),+ ),).await.change_context(errors::StorageError::DecryptionError)?,@@ -356,7 +358,7 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -371,7 +373,7 @@ impl EventInterface for Store {async fn update_event_by_merchant_id_event_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,event: domain::EventUpdate,merchant_key_store: &domain::MerchantKeyStore,@@ -383,7 +385,7 @@ impl EventInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -410,7 +412,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -419,7 +421,7 @@ impl EventInterface for MockDb {async fn find_event_by_merchant_id_event_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::Event, errors::StorageError> {@@ -435,7 +437,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -444,7 +446,7 @@ impl EventInterface for MockDb {.transpose()?.ok_or(errors::StorageError::ValueNotFound(format!(- "No event available with merchant_id = {merchant_id} and event_id = {event_id}"+ "No event available with merchant_id = {merchant_id:?} and event_id = {event_id}")).into(),)@@ -453,7 +455,7 @@ impl EventInterface for MockDb {async fn list_initial_events_by_merchant_id_primary_object_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,primary_object_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -475,7 +477,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?;@@ -488,7 +490,7 @@ impl EventInterface for MockDb {async fn list_initial_events_by_merchant_id_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,created_after: Option<time::PrimitiveDateTime>,created_before: Option<time::PrimitiveDateTime>,limit: Option<i64>,@@ -545,7 +547,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?;@@ -558,7 +560,7 @@ impl EventInterface for MockDb {async fn list_events_by_merchant_id_initial_attempt_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,initial_attempt_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -578,7 +580,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?;@@ -613,7 +615,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?;@@ -683,7 +685,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?;@@ -716,7 +718,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?;@@ -729,7 +731,7 @@ impl EventInterface for MockDb {async fn update_event_by_merchant_id_event_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,event_id: &str,event: domain::EventUpdate,merchant_key_store: &domain::MerchantKeyStore,@@ -757,7 +759,7 @@ impl EventInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -804,7 +806,7 @@ mod tests {let state = &Arc::new(app_state).get_session_state("public", || {}).unwrap();- let merchant_id = "merchant1";+ let merchant_id = common_utils::id_type::MerchantId::from("merchant_1".into()).unwrap();let business_profile_id = "profile1";let payment_id = "test_payment_id";let key_manager_state = &state.into();@@ -813,11 +815,11 @@ mod tests {.insert_merchant_key_store(key_manager_state,domain::MerchantKeyStore {- merchant_id: merchant_id.into(),+ merchant_id: merchant_id.clone(),key: domain::types::encrypt(key_manager_state,services::generate_aes256_key().unwrap().to_vec().into(),- Identifier::Merchant(merchant_id.to_string()),+ Identifier::Merchant(merchant_id.to_owned()),master_key,).await@@ -831,7 +833,7 @@ mod tests {let merchant_key_store = mockdb.get_merchant_key_store_by_merchant_id(key_manager_state,- merchant_id,+ &merchant_id,&master_key.to_vec().into(),).await@@ -870,7 +872,7 @@ mod tests {let updated_event = mockdb.update_event_by_merchant_id_event_id(key_manager_state,- merchant_id,+ &merchant_id,event_id,domain::EventUpdate::UpdateResponse {is_webhook_notified: true,diff --git a/crates/router/src/db/file.rs b/crates/router/src/db/file.rsindex da28404971..f81afa8d83 100644--- a/crates/router/src/db/file.rs+++ b/crates/router/src/db/file.rs@@ -17,13 +17,13 @@ pub trait FileMetadataInterface {async fn find_file_metadata_by_merchant_id_file_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,file_id: &str,) -> CustomResult<storage::FileMetadata, errors::StorageError>;async fn delete_file_metadata_by_merchant_id_file_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,file_id: &str,) -> CustomResult<bool, errors::StorageError>;@@ -50,7 +50,7 @@ impl FileMetadataInterface for Store {#[instrument(skip_all)]async fn find_file_metadata_by_merchant_id_file_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,file_id: &str,) -> CustomResult<storage::FileMetadata, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -62,7 +62,7 @@ impl FileMetadataInterface for Store {#[instrument(skip_all)]async fn delete_file_metadata_by_merchant_id_file_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,file_id: &str,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -96,7 +96,7 @@ impl FileMetadataInterface for MockDb {async fn find_file_metadata_by_merchant_id_file_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_file_id: &str,) -> CustomResult<storage::FileMetadata, errors::StorageError> {// TODO: Implement function for `MockDb`@@ -105,7 +105,7 @@ impl FileMetadataInterface for MockDb {async fn delete_file_metadata_by_merchant_id_file_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_file_id: &str,) -> CustomResult<bool, errors::StorageError> {// TODO: Implement function for `MockDb`diff --git a/crates/router/src/db/fraud_check.rs b/crates/router/src/db/fraud_check.rsindex 9e27f45101..20e3bfb32a 100644--- a/crates/router/src/db/fraud_check.rs+++ b/crates/router/src/db/fraud_check.rs@@ -25,13 +25,13 @@ pub trait FraudCheckInterface {async fn find_fraud_check_by_payment_id(&self,payment_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> CustomResult<FraudCheck, errors::StorageError>;async fn find_fraud_check_by_payment_id_if_present(&self,payment_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> CustomResult<Option<FraudCheck>, errors::StorageError>;}@@ -64,7 +64,7 @@ impl FraudCheckInterface for Store {async fn find_fraud_check_by_payment_id(&self,payment_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> CustomResult<FraudCheck, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;FraudCheck::get_with_payment_id(&conn, payment_id, merchant_id)@@ -76,7 +76,7 @@ impl FraudCheckInterface for Store {async fn find_fraud_check_by_payment_id_if_present(&self,payment_id: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,) -> CustomResult<Option<FraudCheck>, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;FraudCheck::get_with_payment_id_if_present(&conn, payment_id, merchant_id)@@ -103,7 +103,7 @@ impl FraudCheckInterface for MockDb {async fn find_fraud_check_by_payment_id(&self,_payment_id: String,- _merchant_id: String,+ _merchant_id: common_utils::id_type::MerchantId,) -> CustomResult<FraudCheck, errors::StorageError> {Err(errors::StorageError::MockDbError)?}@@ -111,7 +111,7 @@ impl FraudCheckInterface for MockDb {async fn find_fraud_check_by_payment_id_if_present(&self,_payment_id: String,- _merchant_id: String,+ _merchant_id: common_utils::id_type::MerchantId,) -> CustomResult<Option<FraudCheck>, errors::StorageError> {Err(errors::StorageError::MockDbError)?}diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rsindex 030af82dc9..003f3ff484 100644--- a/crates/router/src/db/kafka_store.rs+++ b/crates/router/src/db/kafka_store.rs@@ -160,7 +160,7 @@ impl AddressInterface for KafkaStore {async fn find_address_by_merchant_id_payment_id_address_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,address_id: &str,key_store: &domain::MerchantKeyStore,@@ -193,7 +193,7 @@ impl AddressInterface for KafkaStore {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,address: storage::AddressUpdate,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Address>, errors::StorageError> {@@ -220,7 +220,7 @@ impl ApiKeyInterface for KafkaStore {async fn update_api_key(&self,- merchant_id: String,+ merchant_id: id_type::MerchantId,key_id: String,api_key: storage::ApiKeyUpdate,) -> CustomResult<storage::ApiKey, errors::StorageError> {@@ -231,7 +231,7 @@ impl ApiKeyInterface for KafkaStore {async fn revoke_api_key(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_id: &str,) -> CustomResult<bool, errors::StorageError> {self.diesel_store.revoke_api_key(merchant_id, key_id).await@@ -239,7 +239,7 @@ impl ApiKeyInterface for KafkaStore {async fn find_api_key_by_merchant_id_key_id_optional(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_id: &str,) -> CustomResult<Option<storage::ApiKey>, errors::StorageError> {self.diesel_store@@ -258,7 +258,7 @@ impl ApiKeyInterface for KafkaStore {async fn list_api_keys_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,limit: Option<i64>,offset: Option<i64>,) -> CustomResult<Vec<storage::ApiKey>, errors::StorageError> {@@ -344,7 +344,7 @@ impl CustomerInterface for KafkaStore {async fn delete_customer_by_customer_id_merchant_id(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {self.diesel_store.delete_customer_by_customer_id_merchant_id(customer_id, merchant_id)@@ -355,7 +355,7 @@ impl CustomerInterface for KafkaStore {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> CustomResult<Option<domain::Customer>, errors::StorageError> {@@ -374,7 +374,7 @@ impl CustomerInterface for KafkaStore {&self,state: &KeyManagerState,customer_id: id_type::CustomerId,- merchant_id: String,+ merchant_id: id_type::MerchantId,customer: domain::Customer,customer_update: storage::CustomerUpdate,key_store: &domain::MerchantKeyStore,@@ -396,7 +396,7 @@ impl CustomerInterface for KafkaStore {async fn list_customers_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Customer>, errors::StorageError> {self.diesel_store@@ -408,7 +408,7 @@ impl CustomerInterface for KafkaStore {&self,state: &KeyManagerState,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> CustomResult<domain::Customer, errors::StorageError> {@@ -457,7 +457,7 @@ impl DisputeInterface for KafkaStore {async fn find_by_merchant_id_payment_id_connector_dispute_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,connector_dispute_id: &str,) -> CustomResult<Option<storage::Dispute>, errors::StorageError> {@@ -472,7 +472,7 @@ impl DisputeInterface for KafkaStore {async fn find_dispute_by_merchant_id_dispute_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,dispute_id: &str,) -> CustomResult<storage::Dispute, errors::StorageError> {self.diesel_store@@ -482,7 +482,7 @@ impl DisputeInterface for KafkaStore {async fn find_disputes_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,dispute_constraints: api_models::disputes::DisputeListConstraints,) -> CustomResult<Vec<storage::Dispute>, errors::StorageError> {self.diesel_store@@ -512,7 +512,7 @@ impl DisputeInterface for KafkaStore {async fn find_disputes_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,) -> CustomResult<Vec<storage::Dispute>, errors::StorageError> {self.diesel_store@@ -560,7 +560,7 @@ impl EventInterface for KafkaStore {async fn find_event_by_merchant_id_event_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,event_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::Event, errors::StorageError> {@@ -572,7 +572,7 @@ impl EventInterface for KafkaStore {async fn list_initial_events_by_merchant_id_primary_object_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,primary_object_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -589,7 +589,7 @@ impl EventInterface for KafkaStore {async fn list_initial_events_by_merchant_id_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,created_after: Option<PrimitiveDateTime>,created_before: Option<PrimitiveDateTime>,limit: Option<i64>,@@ -612,7 +612,7 @@ impl EventInterface for KafkaStore {async fn list_events_by_merchant_id_initial_attempt_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,initial_attempt_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -686,7 +686,7 @@ impl EventInterface for KafkaStore {async fn update_event_by_merchant_id_event_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,event_id: &str,event: domain::EventUpdate,merchant_key_store: &domain::MerchantKeyStore,@@ -731,7 +731,7 @@ impl LockerMockUpInterface for KafkaStore {impl MandateInterface for KafkaStore {async fn find_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::Mandate, errors::StorageError> {@@ -742,7 +742,7 @@ impl MandateInterface for KafkaStore {async fn find_mandate_by_merchant_id_connector_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_mandate_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::Mandate, errors::StorageError> {@@ -757,7 +757,7 @@ impl MandateInterface for KafkaStore {async fn find_mandate_by_merchant_id_customer_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,) -> CustomResult<Vec<storage::Mandate>, errors::StorageError> {self.diesel_store@@ -767,7 +767,7 @@ impl MandateInterface for KafkaStore {async fn update_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,mandate_update: storage::MandateUpdate,mandate: storage::Mandate,@@ -786,7 +786,7 @@ impl MandateInterface for KafkaStore {async fn find_mandates_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_constraints: api_models::mandates::MandateListConstraints,) -> CustomResult<Vec<storage::Mandate>, errors::StorageError> {self.diesel_store@@ -827,7 +827,7 @@ impl PaymentLinkInterface for KafkaStore {async fn list_payment_link_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_link_constraints: api_models::payments::PaymentLinkListConstraints,) -> CustomResult<Vec<storage::PaymentLink>, errors::StorageError> {self.diesel_store@@ -852,7 +852,7 @@ impl MerchantAccountInterface for KafkaStore {async fn find_merchant_account_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantAccount, errors::StorageError> {self.diesel_store@@ -875,7 +875,7 @@ impl MerchantAccountInterface for KafkaStore {async fn update_specific_fields_in_merchant(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_account: storage::MerchantAccountUpdate,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantAccount, errors::StorageError> {@@ -916,7 +916,7 @@ impl MerchantAccountInterface for KafkaStore {async fn delete_merchant_account_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {self.diesel_store.delete_merchant_account_by_merchant_id(merchant_id)@@ -927,7 +927,7 @@ impl MerchantAccountInterface for KafkaStore {async fn list_multiple_merchant_accounts(&self,state: &KeyManagerState,- merchant_ids: Vec<String>,+ merchant_ids: Vec<id_type::MerchantId>,) -> CustomResult<Vec<domain::MerchantAccount>, errors::StorageError> {self.diesel_store.list_multiple_merchant_accounts(state, merchant_ids)@@ -939,7 +939,7 @@ impl MerchantAccountInterface for KafkaStore {impl ConnectorAccessToken for KafkaStore {async fn get_access_token(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_connector_id: &str,) -> CustomResult<Option<AccessToken>, errors::StorageError> {self.diesel_store@@ -949,7 +949,7 @@ impl ConnectorAccessToken for KafkaStore {async fn set_access_token(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_connector_id: &str,access_token: AccessToken,) -> CustomResult<(), errors::StorageError> {@@ -970,7 +970,7 @@ impl FileMetadataInterface for KafkaStore {async fn find_file_metadata_by_merchant_id_file_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,file_id: &str,) -> CustomResult<storage::FileMetadata, errors::StorageError> {self.diesel_store@@ -980,7 +980,7 @@ impl FileMetadataInterface for KafkaStore {async fn delete_file_metadata_by_merchant_id_file_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,file_id: &str,) -> CustomResult<bool, errors::StorageError> {self.diesel_store@@ -1015,7 +1015,7 @@ impl MerchantConnectorAccountInterface for KafkaStore {async fn find_merchant_connector_account_by_merchant_id_connector_label(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -1032,7 +1032,7 @@ impl MerchantConnectorAccountInterface for KafkaStore {async fn find_merchant_connector_account_by_merchant_id_connector_name(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_name: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {@@ -1077,7 +1077,7 @@ impl MerchantConnectorAccountInterface for KafkaStore {async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_connector_id: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -1094,7 +1094,7 @@ impl MerchantConnectorAccountInterface for KafkaStore {async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,get_disabled: bool,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {@@ -1122,7 +1122,7 @@ impl MerchantConnectorAccountInterface for KafkaStore {async fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,merchant_connector_id: &str,) -> CustomResult<bool, errors::StorageError> {self.diesel_store@@ -1239,7 +1239,7 @@ impl PaymentAttemptInterface for KafkaStore {&self,connector_transaction_id: &str,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PaymentAttempt, errors::DataStorageError> {self.diesel_store@@ -1254,7 +1254,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_txn_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PaymentAttempt, errors::DataStorageError> {@@ -1270,7 +1270,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,attempt_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PaymentAttempt, errors::DataStorageError> {@@ -1287,7 +1287,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn find_payment_attempt_by_attempt_id_merchant_id(&self,attempt_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PaymentAttempt, errors::DataStorageError> {self.diesel_store@@ -1298,7 +1298,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PaymentAttempt, errors::DataStorageError> {self.diesel_store@@ -1313,7 +1313,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PaymentAttempt, errors::DataStorageError> {self.diesel_store@@ -1328,7 +1328,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,preprocessing_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PaymentAttempt, errors::DataStorageError> {self.diesel_store@@ -1343,7 +1343,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn get_filters_for_payments(&self,pi: &[hyperswitch_domain_models::payments::PaymentIntent],- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<hyperswitch_domain_models::payments::payment_attempt::PaymentListFilters,@@ -1356,7 +1356,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn get_total_count_of_filtered_payment_attempts(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,active_attempt_ids: &[String],connector: Option<Vec<api_models::enums::Connector>>,payment_method: Option<Vec<common_enums::PaymentMethod>>,@@ -1381,7 +1381,7 @@ impl PaymentAttemptInterface for KafkaStore {async fn find_attempts_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<Vec<storage::PaymentAttempt>, errors::DataStorageError> {@@ -1451,7 +1451,7 @@ impl PaymentIntentInterface for KafkaStore {&self,state: &KeyManagerState,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PaymentIntent, errors::DataStorageError> {@@ -1470,7 +1470,7 @@ impl PaymentIntentInterface for KafkaStore {async fn filter_payment_intent_by_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,filters: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -1490,7 +1490,7 @@ impl PaymentIntentInterface for KafkaStore {async fn filter_payment_intents_by_time_range_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,time_range: &api_models::payments::TimeRange,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -1510,7 +1510,7 @@ impl PaymentIntentInterface for KafkaStore {async fn get_filtered_payment_intents_attempt(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,key_store: &domain::MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -1535,7 +1535,7 @@ impl PaymentIntentInterface for KafkaStore {#[cfg(feature = "olap")]async fn get_filtered_active_attempt_ids_for_total_count(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,storage_scheme: MerchantStorageScheme,) -> CustomResult<Vec<String>, errors::DataStorageError> {@@ -1574,7 +1574,7 @@ impl PaymentMethodInterface for KafkaStore {async fn find_payment_method_by_customer_id_merchant_id_list(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,limit: Option<i64>,) -> CustomResult<Vec<storage::PaymentMethod>, errors::StorageError> {self.diesel_store@@ -1585,7 +1585,7 @@ impl PaymentMethodInterface for KafkaStore {async fn find_payment_method_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,limit: Option<i64>,storage_scheme: MerchantStorageScheme,@@ -1604,7 +1604,7 @@ impl PaymentMethodInterface for KafkaStore {async fn get_payment_method_count_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,) -> CustomResult<i64, errors::StorageError> {self.diesel_store@@ -1649,7 +1649,7 @@ impl PaymentMethodInterface for KafkaStore {async fn delete_payment_method_by_merchant_id_payment_method_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_method_id: &str,) -> CustomResult<storage::PaymentMethod, errors::StorageError> {self.diesel_store@@ -1666,7 +1666,7 @@ impl PayoutAttemptInterface for KafkaStore {}impl PayoutAttemptInterface for KafkaStore {async fn find_payout_attempt_by_merchant_id_payout_attempt_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payout_attempt_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PayoutAttempt, errors::DataStorageError> {@@ -1681,7 +1681,7 @@ impl PayoutAttemptInterface for KafkaStore {async fn find_payout_attempt_by_merchant_id_connector_payout_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_payout_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::PayoutAttempt, errors::DataStorageError> {@@ -1748,7 +1748,7 @@ impl PayoutAttemptInterface for KafkaStore {async fn get_filters_for_payouts(&self,payouts: &[hyperswitch_domain_models::payouts::payouts::Payouts],- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<hyperswitch_domain_models::payouts::payout_attempt::PayoutListFilters,@@ -1768,7 +1768,7 @@ impl PayoutsInterface for KafkaStore {}impl PayoutsInterface for KafkaStore {async fn find_payout_by_merchant_id_payout_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payout_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::Payouts, errors::DataStorageError> {@@ -1814,7 +1814,7 @@ impl PayoutsInterface for KafkaStore {async fn find_optional_payout_by_merchant_id_payout_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payout_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<Option<storage::Payouts>, errors::DataStorageError> {@@ -1826,7 +1826,7 @@ impl PayoutsInterface for KafkaStore {#[cfg(feature = "olap")]async fn filter_payouts_by_constraints(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,storage_scheme: MerchantStorageScheme,) -> CustomResult<Vec<storage::Payouts>, errors::DataStorageError> {@@ -1838,7 +1838,7 @@ impl PayoutsInterface for KafkaStore {#[cfg(feature = "olap")]async fn filter_payouts_and_attempts(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,storage_scheme: MerchantStorageScheme,) -> CustomResult<@@ -1857,7 +1857,7 @@ impl PayoutsInterface for KafkaStore {#[cfg(feature = "olap")]async fn filter_payouts_by_time_range_constraints(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,time_range: &api_models::payments::TimeRange,storage_scheme: MerchantStorageScheme,) -> CustomResult<Vec<storage::Payouts>, errors::DataStorageError> {@@ -1975,7 +1975,7 @@ impl CaptureInterface for KafkaStore {async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,authorized_attempt_id: &str,storage_scheme: MerchantStorageScheme,@@ -1996,7 +1996,7 @@ impl RefundInterface for KafkaStore {async fn find_refund_by_internal_reference_id_merchant_id(&self,internal_reference_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::Refund, errors::StorageError> {self.diesel_store@@ -2011,7 +2011,7 @@ impl RefundInterface for KafkaStore {async fn find_refund_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {self.diesel_store@@ -2021,7 +2021,7 @@ impl RefundInterface for KafkaStore {async fn find_refund_by_merchant_id_refund_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,refund_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage::Refund, errors::StorageError> {@@ -2032,7 +2032,7 @@ impl RefundInterface for KafkaStore {async fn find_refund_by_merchant_id_connector_refund_id_connector(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_refund_id: &str,connector: &str,storage_scheme: MerchantStorageScheme,@@ -2070,7 +2070,7 @@ impl RefundInterface for KafkaStore {async fn find_refund_by_merchant_id_connector_transaction_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_transaction_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {@@ -2103,7 +2103,7 @@ impl RefundInterface for KafkaStore {#[cfg(feature = "olap")]async fn filter_refund_by_constraints(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,storage_scheme: MerchantStorageScheme,limit: i64,@@ -2123,7 +2123,7 @@ impl RefundInterface for KafkaStore {#[cfg(feature = "olap")]async fn filter_refund_by_meta_constraints(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,refund_details: &api_models::payments::TimeRange,storage_scheme: MerchantStorageScheme,) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {@@ -2135,7 +2135,7 @@ impl RefundInterface for KafkaStore {#[cfg(feature = "olap")]async fn get_total_count_of_refunds(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,storage_scheme: MerchantStorageScheme,) -> CustomResult<i64, errors::StorageError> {@@ -2161,7 +2161,7 @@ impl MerchantKeyStoreInterface for KafkaStore {async fn get_merchant_key_store_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key: &Secret<Vec<u8>>,) -> CustomResult<domain::MerchantKeyStore, errors::StorageError> {self.diesel_store@@ -2171,7 +2171,7 @@ impl MerchantKeyStoreInterface for KafkaStore {async fn delete_merchant_key_store_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {self.diesel_store.delete_merchant_key_store_by_merchant_id(merchant_id)@@ -2182,7 +2182,7 @@ impl MerchantKeyStoreInterface for KafkaStore {async fn list_multiple_key_stores(&self,state: &KeyManagerState,- merchant_ids: Vec<String>,+ merchant_ids: Vec<id_type::MerchantId>,key: &Secret<Vec<u8>>,) -> CustomResult<Vec<domain::MerchantKeyStore>, errors::StorageError> {self.diesel_store@@ -2235,7 +2235,7 @@ impl BusinessProfileInterface for KafkaStore {async fn delete_business_profile_by_profile_id_merchant_id(&self,profile_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {self.diesel_store.delete_business_profile_by_profile_id_merchant_id(profile_id, merchant_id)@@ -2244,7 +2244,7 @@ impl BusinessProfileInterface for KafkaStore {async fn list_business_profile_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<Vec<business_profile::BusinessProfile>, errors::StorageError> {self.diesel_store.list_business_profile_by_merchant_id(merchant_id)@@ -2254,7 +2254,7 @@ impl BusinessProfileInterface for KafkaStore {async fn find_business_profile_by_profile_name_merchant_id(&self,profile_name: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<business_profile::BusinessProfile, errors::StorageError> {self.diesel_store.find_business_profile_by_profile_name_merchant_id(profile_name, merchant_id)@@ -2309,7 +2309,7 @@ impl RoutingAlgorithmInterface for KafkaStore {async fn find_routing_algorithm_by_algorithm_id_merchant_id(&self,algorithm_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<storage::RoutingAlgorithm, errors::StorageError> {self.diesel_store.find_routing_algorithm_by_algorithm_id_merchant_id(algorithm_id, merchant_id)@@ -2339,7 +2339,7 @@ impl RoutingAlgorithmInterface for KafkaStore {async fn list_routing_algorithm_metadata_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,limit: i64,offset: i64,) -> CustomResult<Vec<storage::RoutingProfileMetadata>, errors::StorageError> {@@ -2350,7 +2350,7 @@ impl RoutingAlgorithmInterface for KafkaStore {async fn list_routing_algorithm_metadata_by_merchant_id_transaction_type(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,transaction_type: &enums::TransactionType,limit: i64,offset: i64,@@ -2542,7 +2542,7 @@ impl UserRoleInterface for KafkaStore {async fn find_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<user_storage::UserRole, errors::StorageError> {self.diesel_store.find_user_role_by_user_id_merchant_id(user_id, merchant_id)@@ -2552,7 +2552,7 @@ impl UserRoleInterface for KafkaStore {async fn update_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,update: user_storage::UserRoleUpdate,) -> CustomResult<user_storage::UserRole, errors::StorageError> {self.diesel_store@@ -2574,7 +2574,7 @@ impl UserRoleInterface for KafkaStore {async fn delete_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<user_storage::UserRole, errors::StorageError> {self.diesel_store.delete_user_role_by_user_id_merchant_id(user_id, merchant_id)@@ -2601,10 +2601,10 @@ impl UserRoleInterface for KafkaStore {async fn list_user_roles_by_merchant_id(&self,- user_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<Vec<user_storage::UserRole>, errors::StorageError> {self.diesel_store- .list_user_roles_by_merchant_id(user_id)+ .list_user_roles_by_merchant_id(merchant_id).await}}@@ -2621,7 +2621,7 @@ impl DashboardMetadataInterface for KafkaStore {async fn update_metadata(&self,user_id: Option<String>,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,data_key: enums::DashboardMetadata,dashboard_metadata_update: storage::DashboardMetadataUpdate,@@ -2640,7 +2640,7 @@ impl DashboardMetadataInterface for KafkaStore {async fn find_user_scoped_dashboard_metadata(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,data_keys: Vec<enums::DashboardMetadata>,) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {@@ -2651,7 +2651,7 @@ impl DashboardMetadataInterface for KafkaStore {async fn find_merchant_scoped_dashboard_metadata(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,data_keys: Vec<enums::DashboardMetadata>,) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> {@@ -2663,7 +2663,7 @@ impl DashboardMetadataInterface for KafkaStore {async fn delete_all_user_scoped_dashboard_metadata_by_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {self.diesel_store.delete_all_user_scoped_dashboard_metadata_by_merchant_id(user_id, merchant_id)@@ -2673,7 +2673,7 @@ impl DashboardMetadataInterface for KafkaStore {async fn delete_user_scoped_dashboard_metadata_by_merchant_id_data_key(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,data_key: enums::DashboardMetadata,) -> CustomResult<storage::DashboardMetadata, errors::StorageError> {self.diesel_store@@ -2754,7 +2754,7 @@ impl BatchSampleDataInterface for KafkaStore {async fn delete_payment_intents_for_sample_data(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,) -> CustomResult<Vec<hyperswitch_domain_models::payments::PaymentIntent>,@@ -2776,7 +2776,7 @@ impl BatchSampleDataInterface for KafkaStore {async fn delete_payment_attempts_for_sample_data(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<Vec<hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt>,hyperswitch_domain_models::errors::StorageError,@@ -2798,7 +2798,7 @@ impl BatchSampleDataInterface for KafkaStore {async fn delete_refunds_for_sample_data(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<Vec<diesel_models::Refund>, hyperswitch_domain_models::errors::StorageError>{let refunds_list = self@@ -2828,7 +2828,7 @@ impl AuthorizationInterface for KafkaStore {async fn find_all_authorizations_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_id: &str,) -> CustomResult<Vec<storage::Authorization>, errors::StorageError> {self.diesel_store@@ -2838,7 +2838,7 @@ impl AuthorizationInterface for KafkaStore {async fn update_authorization_by_merchant_id_authorization_id(&self,- merchant_id: String,+ merchant_id: id_type::MerchantId,authorization_id: String,authorization: storage::AuthorizationUpdate,) -> CustomResult<storage::Authorization, errors::StorageError> {@@ -2876,7 +2876,7 @@ impl AuthenticationInterface for KafkaStore {async fn find_authentication_by_merchant_id_authentication_id(&self,- merchant_id: String,+ merchant_id: &id_type::MerchantId,authentication_id: String,) -> CustomResult<storage::Authentication, errors::StorageError> {self.diesel_store@@ -2886,7 +2886,7 @@ impl AuthenticationInterface for KafkaStore {async fn find_authentication_by_merchant_id_connector_authentication_id(&self,- merchant_id: String,+ merchant_id: id_type::MerchantId,connector_authentication_id: String,) -> CustomResult<storage::Authentication, errors::StorageError> {self.diesel_store@@ -2948,7 +2948,7 @@ impl RoleInterface for KafkaStore {async fn find_role_by_role_id_in_merchant_scope(&self,role_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<storage::Role, errors::StorageError> {self.diesel_store@@ -2975,7 +2975,7 @@ impl RoleInterface for KafkaStore {async fn list_all_roles(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<Vec<storage::Role>, errors::StorageError> {self.diesel_store.list_all_roles(merchant_id, org_id).awaitdiff --git a/crates/router/src/db/locker_mock_up.rs b/crates/router/src/db/locker_mock_up.rsindex 0fb675025c..abae3fe246 100644--- a/crates/router/src/db/locker_mock_up.rs+++ b/crates/router/src/db/locker_mock_up.rs@@ -141,7 +141,7 @@ mod tests {pub struct LockerMockUpIds {card_id: String,external_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,customer_id: id_type::CustomerId,}@@ -175,7 +175,7 @@ mod tests {.insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds {card_id: "card_1".into(),external_id: "external_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: id_type::MerchantId::default(),customer_id: generate_customer_id_of_default_length(),})).await@@ -185,7 +185,7 @@ mod tests {.insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds {card_id: "card_2".into(),external_id: "external_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: id_type::MerchantId::default(),customer_id: generate_customer_id_of_default_length(),})).await;@@ -206,7 +206,7 @@ mod tests {.insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds {card_id: "card_1".into(),external_id: "external_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: id_type::MerchantId::default(),customer_id: generate_customer_id_of_default_length(),})).await@@ -236,7 +236,7 @@ mod tests {.insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds {card_id: "card_1".into(),external_id: "external_1".into(),- merchant_id: "merchant_1".into(),+ merchant_id: id_type::MerchantId::default(),customer_id: generate_customer_id_of_default_length(),})).awaitdiff --git a/crates/router/src/db/mandate.rs b/crates/router/src/db/mandate.rsindex e69e3318ae..bdc51c8ad8 100644--- a/crates/router/src/db/mandate.rs+++ b/crates/router/src/db/mandate.rs@@ -11,27 +11,27 @@ use crate::{pub trait MandateInterface {async fn find_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage_types::Mandate, errors::StorageError>;async fn find_mandate_by_merchant_id_connector_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_mandate_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage_types::Mandate, errors::StorageError>;async fn find_mandate_by_merchant_id_customer_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError>;async fn update_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,mandate_update: storage_types::MandateUpdate,mandate: storage_types::Mandate,@@ -40,7 +40,7 @@ pub trait MandateInterface {async fn find_mandates_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_constraints: api_models::mandates::MandateListConstraints,) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError>;@@ -77,7 +77,7 @@ mod storage {#[instrument(skip_all)]async fn find_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage_types::Mandate, errors::StorageError> {@@ -123,7 +123,7 @@ mod storage {#[instrument(skip_all)]async fn find_mandate_by_merchant_id_connector_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_mandate_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<storage_types::Mandate, errors::StorageError> {@@ -143,8 +143,11 @@ mod storage {match storage_scheme {MerchantStorageScheme::PostgresOnly => database_call().await,MerchantStorageScheme::RedisKv => {- let lookup_id =- format!("mid_{}_conn_mandate_{}", merchant_id, connector_mandate_id);+ let lookup_id = format!(+ "mid_{}_conn_mandate_{}",+ merchant_id.get_string_repr(),+ connector_mandate_id+ );let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -175,7 +178,7 @@ mod storage {#[instrument(skip_all)]async fn find_mandate_by_merchant_id_customer_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -187,7 +190,7 @@ mod storage {#[instrument(skip_all)]async fn update_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,mandate_update: storage_types::MandateUpdate,mandate: storage_types::Mandate,@@ -227,7 +230,11 @@ mod storage {let rev_lookup = diesel_models::ReverseLookupNew {sk_id: field.clone(),pk_id: key_str.clone(),- lookup_id: format!("mid_{}_conn_mandate_{}", merchant_id, val),+ lookup_id: format!(+ "mid_{}_conn_mandate_{}",+ merchant_id.get_string_repr(),+ val+ ),source: "mandate".to_string(),updated_by: storage_scheme.to_string(),};@@ -271,7 +278,7 @@ mod storage {#[instrument(skip_all)]async fn find_mandates_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_constraints: api_models::mandates::MandateListConstraints,) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -301,11 +308,11 @@ mod storage {.map_err(|error| report!(errors::StorageError::from(error))),MerchantStorageScheme::RedisKv => {let mandate_id = mandate.mandate_id.clone();- let merchant_id = mandate.merchant_id.clone();+ let merchant_id = &mandate.merchant_id.to_owned();let connector_mandate_id = mandate.connector_mandate_id.clone();let key = PartitionKey::MerchantIdMandateId {- merchant_id: merchant_id.as_str(),+ merchant_id,mandate_id: mandate_id.as_str(),};let key_str = key.to_string();@@ -320,8 +327,11 @@ mod storage {};if let Some(connector_val) = connector_mandate_id {- let lookup_id =- format!("mid_{}_conn_mandate_{}", merchant_id, connector_val);+ let lookup_id = format!(+ "mid_{}_conn_mandate_{}",+ merchant_id.get_string_repr(),+ connector_val+ );let reverse_lookup_entry = diesel_models::ReverseLookupNew {sk_id: field.clone(),@@ -381,7 +391,7 @@ mod storage {#[instrument(skip_all)]async fn find_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,_storage_scheme: MerchantStorageScheme,) -> CustomResult<storage_types::Mandate, errors::StorageError> {@@ -394,7 +404,7 @@ mod storage {#[instrument(skip_all)]async fn find_mandate_by_merchant_id_connector_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_mandate_id: &str,_storage_scheme: MerchantStorageScheme,) -> CustomResult<storage_types::Mandate, errors::StorageError> {@@ -411,7 +421,7 @@ mod storage {#[instrument(skip_all)]async fn find_mandate_by_merchant_id_customer_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -423,7 +433,7 @@ mod storage {#[instrument(skip_all)]async fn update_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,mandate_update: storage_types::MandateUpdate,_mandate: storage_types::Mandate,@@ -443,7 +453,7 @@ mod storage {#[instrument(skip_all)]async fn find_mandates_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_constraints: api_models::mandates::MandateListConstraints,) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -471,7 +481,7 @@ mod storage {impl MandateInterface for MockDb {async fn find_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,_storage_scheme: MerchantStorageScheme,) -> CustomResult<storage_types::Mandate, errors::StorageError> {@@ -479,7 +489,7 @@ impl MandateInterface for MockDb {.lock().await.iter()- .find(|mandate| mandate.merchant_id == merchant_id && mandate.mandate_id == mandate_id)+ .find(|mandate| mandate.merchant_id == *merchant_id && mandate.mandate_id == mandate_id).cloned().ok_or_else(|| errors::StorageError::ValueNotFound("mandate not found".to_string())).map_err(|err| err.into())@@ -487,7 +497,7 @@ impl MandateInterface for MockDb {async fn find_mandate_by_merchant_id_connector_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,connector_mandate_id: &str,_storage_scheme: MerchantStorageScheme,) -> CustomResult<storage_types::Mandate, errors::StorageError> {@@ -496,7 +506,7 @@ impl MandateInterface for MockDb {.await.iter().find(|mandate| {- mandate.merchant_id == merchant_id+ mandate.merchant_id == *merchant_id&& mandate.connector_mandate_id == Some(connector_mandate_id.to_string())}).cloned()@@ -506,7 +516,7 @@ impl MandateInterface for MockDb {async fn find_mandate_by_merchant_id_customer_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {return Ok(self@@ -515,7 +525,7 @@ impl MandateInterface for MockDb {.await.iter().filter(|mandate| {- mandate.merchant_id == merchant_id && &mandate.customer_id == customer_id+ mandate.merchant_id == *merchant_id && &mandate.customer_id == customer_id}).cloned().collect());@@ -523,7 +533,7 @@ impl MandateInterface for MockDb {async fn update_mandate_by_merchant_id_mandate_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_id: &str,mandate_update: storage_types::MandateUpdate,_mandate: storage_types::Mandate,@@ -532,7 +542,7 @@ impl MandateInterface for MockDb {let mut mandates = self.mandates.lock().await;match mandates.iter_mut()- .find(|mandate| mandate.merchant_id == merchant_id && mandate.mandate_id == mandate_id)+ .find(|mandate| mandate.merchant_id == *merchant_id && mandate.mandate_id == mandate_id){Some(mandate) => {let m_update = diesel_models::MandateUpdateInternal::from(mandate_update);@@ -547,12 +557,12 @@ impl MandateInterface for MockDb {async fn find_mandates_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,mandate_constraints: api_models::mandates::MandateListConstraints,) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {let mandates = self.mandates.lock().await;let mandates_iter = mandates.iter().filter(|mandate| {- let mut checker = mandate.merchant_id == merchant_id;+ let mut checker = mandate.merchant_id == *merchant_id;if let Some(created_time) = mandate_constraints.created_time {checker &= mandate.created_at == created_time;}diff --git a/crates/router/src/db/merchant_account.rs b/crates/router/src/db/merchant_account.rsindex ae5ca36017..1907b9bdea 100644--- a/crates/router/src/db/merchant_account.rs+++ b/crates/router/src/db/merchant_account.rs@@ -39,7 +39,7 @@ whereasync fn find_merchant_account_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantAccount, errors::StorageError>;@@ -59,7 +59,7 @@ whereasync fn update_specific_fields_in_merchant(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_account: storage::MerchantAccountUpdate,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantAccount, errors::StorageError>;@@ -79,14 +79,14 @@ whereasync fn delete_merchant_account_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError>;#[cfg(feature = "olap")]async fn list_multiple_merchant_accounts(&self,state: &KeyManagerState,- merchant_ids: Vec<String>,+ merchant_ids: Vec<common_utils::id_type::MerchantId>,) -> CustomResult<Vec<domain::MerchantAccount>, errors::StorageError>;}@@ -110,7 +110,7 @@ impl MerchantAccountInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -120,7 +120,7 @@ impl MerchantAccountInterface for Store {async fn find_merchant_account_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantAccount, errors::StorageError> {let fetch_func = || async {@@ -137,7 +137,7 @@ impl MerchantAccountInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_id.to_string(),+ merchant_id.to_owned().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -145,15 +145,20 @@ impl MerchantAccountInterface for Store {#[cfg(feature = "accounts_cache")]{- cache::get_or_populate_in_memory(self, merchant_id, fetch_func, &ACCOUNTS_CACHE)- .await?- .convert(- state,- merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),- )- .await- .change_context(errors::StorageError::DecryptionError)+ cache::get_or_populate_in_memory(+ self,+ merchant_id.get_string_repr(),+ fetch_func,+ &ACCOUNTS_CACHE,+ )+ .await?+ .convert(+ state,+ merchant_key_store.key.get_inner(),+ merchant_key_store.merchant_id.clone().into(),+ )+ .await+ .change_context(errors::StorageError::DecryptionError)}}@@ -182,7 +187,7 @@ impl MerchantAccountInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -192,7 +197,7 @@ impl MerchantAccountInterface for Store {async fn update_specific_fields_in_merchant(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_account: storage::MerchantAccountUpdate,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantAccount, errors::StorageError> {@@ -213,7 +218,7 @@ impl MerchantAccountInterface for Store {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -252,7 +257,7 @@ impl MerchantAccountInterface for Store {let key_store = self.get_merchant_key_store_by_merchant_id(state,- &merchant_account.merchant_id,+ merchant_account.get_id(),&self.get_master_key().to_vec().into(),).await?;@@ -262,7 +267,7 @@ impl MerchantAccountInterface for Store {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -292,7 +297,7 @@ impl MerchantAccountInterface for Store {try_join_all(encrypted_merchant_accounts.iter().map(|merchant_account| {self.get_merchant_key_store_by_merchant_id(state,- &merchant_account.merchant_id,+ merchant_account.get_id(),&db_master_key,)}))@@ -307,7 +312,7 @@ impl MerchantAccountInterface for Store {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -321,7 +326,7 @@ impl MerchantAccountInterface for Store {#[instrument(skip_all)]async fn delete_merchant_account_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -358,7 +363,7 @@ impl MerchantAccountInterface for Store {async fn list_multiple_merchant_accounts(&self,state: &KeyManagerState,- merchant_ids: Vec<String>,+ merchant_ids: Vec<common_utils::id_type::MerchantId>,) -> CustomResult<Vec<domain::MerchantAccount>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -374,7 +379,7 @@ impl MerchantAccountInterface for Store {state,encrypted_merchant_accounts.iter()- .map(|merchant_account| &merchant_account.merchant_id)+ .map(|merchant_account| merchant_account.get_id()).cloned().collect(),&db_master_key,@@ -389,17 +394,17 @@ impl MerchantAccountInterface for Store {let merchant_accounts =futures::future::try_join_all(encrypted_merchant_accounts.into_iter().map(|merchant_account| async {- let key_store = key_stores_by_id.get(&merchant_account.merchant_id).ok_or(+ let key_store = key_stores_by_id.get(merchant_account.get_id()).ok_or(errors::StorageError::ValueNotFound(format!(- "merchant_key_store with merchant_id = {}",- merchant_account.merchant_id+ "merchant_key_store with merchant_id = {:?}",+ merchant_account.get_id())),)?;merchant_account.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -462,7 +467,7 @@ impl MerchantAccountInterface for MockDb {.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -472,19 +477,19 @@ impl MerchantAccountInterface for MockDb {async fn find_merchant_account_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantAccount, errors::StorageError> {let accounts = self.merchant_accounts.lock().await;let account: Option<domain::MerchantAccount> = accounts.iter()- .find(|account| account.merchant_id == merchant_id)+ .find(|account| account.merchant_id == *merchant_id).cloned().async_map(|a| async {a.convert(state,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -513,7 +518,7 @@ impl MerchantAccountInterface for MockDb {async fn update_specific_fields_in_merchant(&self,_state: &KeyManagerState,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_merchant_account: storage::MerchantAccountUpdate,_merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantAccount, errors::StorageError> {@@ -539,7 +544,7 @@ impl MerchantAccountInterface for MockDb {async fn delete_merchant_account_by_merchant_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {// [#172]: Implement function for `MockDb`Err(errors::StorageError::MockDbError)?@@ -558,7 +563,7 @@ impl MerchantAccountInterface for MockDb {async fn list_multiple_merchant_accounts(&self,_state: &KeyManagerState,- _merchant_ids: Vec<String>,+ _merchant_ids: Vec<common_utils::id_type::MerchantId>,) -> CustomResult<Vec<domain::MerchantAccount>, errors::StorageError> {Err(errors::StorageError::MockDbError)?}@@ -578,7 +583,7 @@ async fn publish_and_redact_merchant_account_cache(CacheKind::CGraph(format!("cgraph_{}_{}",- merchant_account.merchant_id.clone(),+ merchant_account.get_id().clone(),profile_id,).into(),@@ -586,7 +591,7 @@ async fn publish_and_redact_merchant_account_cache(});let mut cache_keys = vec![CacheKind::Accounts(- merchant_account.merchant_id.as_str().into(),+ merchant_account.get_id().get_string_repr().into(),)];cache_keys.extend(publishable_key.into_iter());@@ -601,7 +606,9 @@ async fn publish_and_redact_all_merchant_account_cache(store: &dyn super::StorageInterface,merchant_accounts: &[storage::MerchantAccount],) -> CustomResult<(), errors::StorageError> {- let merchant_ids = merchant_accounts.iter().map(|m| m.merchant_id.clone());+ let merchant_ids = merchant_accounts+ .iter()+ .map(|m| m.merchant_id.get_string_repr().to_string());let publishable_keys = merchant_accounts.iter().filter_map(|m| m.publishable_key.clone());diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rsindex 078980f918..f48007d15b 100644--- a/crates/router/src/db/merchant_connector_account.rs+++ b/crates/router/src/db/merchant_connector_account.rs@@ -28,13 +28,13 @@ use crate::{pub trait ConnectorAccessToken {async fn get_access_token(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id_or_connector_name: &str,) -> CustomResult<Option<types::AccessToken>, errors::StorageError>;async fn set_access_token(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id_or_connector_name: &str,access_token: types::AccessToken,) -> CustomResult<(), errors::StorageError>;@@ -45,7 +45,7 @@ impl ConnectorAccessToken for Store {#[instrument(skip_all)]async fn get_access_token(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id_or_connector_name: &str,) -> CustomResult<Option<types::AccessToken>, errors::StorageError> {//TODO: Handle race condition@@ -75,7 +75,7 @@ impl ConnectorAccessToken for Store {#[instrument(skip_all)]async fn set_access_token(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id_or_connector_name: &str,access_token: types::AccessToken,) -> CustomResult<(), errors::StorageError> {@@ -98,7 +98,7 @@ impl ConnectorAccessToken for Store {impl ConnectorAccessToken for MockDb {async fn get_access_token(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_merchant_connector_id_or_connector_name: &str,) -> CustomResult<Option<types::AccessToken>, errors::StorageError> {Ok(None)@@ -106,7 +106,7 @@ impl ConnectorAccessToken for MockDb {async fn set_access_token(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_merchant_connector_id_or_connector_name: &str,_access_token: types::AccessToken,) -> CustomResult<(), errors::StorageError> {@@ -125,7 +125,7 @@ whereasync fn find_merchant_connector_account_by_merchant_id_connector_label(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_label: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError>;@@ -141,7 +141,7 @@ whereasync fn find_merchant_connector_account_by_merchant_id_connector_name(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError>;@@ -156,7 +156,7 @@ whereasync fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError>;@@ -164,7 +164,7 @@ whereasync fn find_merchant_connector_account_by_merchant_id_and_disabled_list(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,get_disabled: bool,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError>;@@ -187,7 +187,7 @@ whereasync fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id: &str,) -> CustomResult<bool, errors::StorageError>;}@@ -198,7 +198,7 @@ impl MerchantConnectorAccountInterface for Store {async fn find_merchant_connector_account_by_merchant_id_connector_label(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_label: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -217,7 +217,7 @@ impl MerchantConnectorAccountInterface for Store {{find_call().await?- .convert(state, key_store.key.get_inner(), merchant_id.to_string())+ .convert(state, key_store.key.get_inner(), merchant_id.clone().into()).await.change_context(errors::StorageError::DeserializationFailed)}@@ -235,7 +235,7 @@ impl MerchantConnectorAccountInterface for Store {item.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -270,7 +270,7 @@ impl MerchantConnectorAccountInterface for Store {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DeserializationFailed)@@ -289,7 +289,7 @@ impl MerchantConnectorAccountInterface for Store {item.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -302,7 +302,7 @@ impl MerchantConnectorAccountInterface for Store {async fn find_merchant_connector_account_by_merchant_id_connector_name(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {@@ -321,7 +321,7 @@ impl MerchantConnectorAccountInterface for Store {item.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -336,7 +336,7 @@ impl MerchantConnectorAccountInterface for Store {async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -358,7 +358,7 @@ impl MerchantConnectorAccountInterface for Store {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -368,7 +368,11 @@ impl MerchantConnectorAccountInterface for Store {{cache::get_or_populate_in_memory(self,- &format!("{}_{}", merchant_id, merchant_connector_id),+ &format!(+ "{}_{}",+ merchant_id.get_string_repr(),+ merchant_connector_id+ ),find_call,&cache::ACCOUNTS_CACHE,)@@ -376,7 +380,7 @@ impl MerchantConnectorAccountInterface for Store {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -401,7 +405,7 @@ impl MerchantConnectorAccountInterface for Store {item.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -413,7 +417,7 @@ impl MerchantConnectorAccountInterface for Store {async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,get_disabled: bool,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {@@ -428,7 +432,7 @@ impl MerchantConnectorAccountInterface for Store {item.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -495,10 +499,16 @@ impl MerchantConnectorAccountInterface for Store {format!("{}_{}", _profile_id, _connector_name).into(),),cache::CacheKind::Accounts(- format!("{}_{}", _merchant_id, _merchant_connector_id).into(),+ format!(+ "{}_{}",+ _merchant_id.get_string_repr(),+ _merchant_connector_id+ )+ .into(),),cache::CacheKind::CGraph(- format!("cgraph_{}_{_profile_id}", _merchant_id).into(),+ format!("cgraph_{}_{_profile_id}", _merchant_id.get_string_repr())+ .into(),),],|| update,@@ -568,7 +578,7 @@ impl MerchantConnectorAccountInterface for Store {item.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -586,13 +596,22 @@ impl MerchantConnectorAccountInterface for Store {format!("{}_{}", _profile_id, _connector_name).into(),),cache::CacheKind::Accounts(- format!("{}_{}", _merchant_id, _merchant_connector_id).into(),+ format!(+ "{}_{}",+ _merchant_id.get_string_repr(),+ _merchant_connector_id+ )+ .into(),),cache::CacheKind::CGraph(- format!("cgraph_{}_{_profile_id}", _merchant_id).into(),+ format!("cgraph_{}_{_profile_id}", _merchant_id.get_string_repr()).into(),),cache::CacheKind::PmFiltersCGraph(- format!("pm_filters_cgraph_{}_{_profile_id}", _merchant_id).into(),+ format!(+ "pm_filters_cgraph_{}_{_profile_id}",+ _merchant_id.get_string_repr()+ )+ .into(),),],update_call,@@ -609,7 +628,7 @@ impl MerchantConnectorAccountInterface for Store {#[instrument(skip_all)]async fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id: &str,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -646,13 +665,18 @@ impl MerchantConnectorAccountInterface for Store {self,[cache::CacheKind::Accounts(- format!("{}_{}", mca.merchant_id, _profile_id).into(),+ format!("{}_{}", mca.merchant_id.get_string_repr(), _profile_id).into(),),cache::CacheKind::CGraph(- format!("cgraph_{}_{_profile_id}", mca.merchant_id).into(),+ format!("cgraph_{}_{_profile_id}", mca.merchant_id.get_string_repr())+ .into(),),cache::CacheKind::PmFiltersCGraph(- format!("pm_filters_cgraph_{}_{_profile_id}", mca.merchant_id).into(),+ format!(+ "pm_filters_cgraph_{}_{_profile_id}",+ mca.merchant_id.get_string_repr()+ )+ .into(),),],delete_call,@@ -683,7 +707,7 @@ impl MerchantConnectorAccountInterface for MockDb {async fn find_merchant_connector_account_by_merchant_id_connector_label(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -693,7 +717,7 @@ impl MerchantConnectorAccountInterface for MockDb {.await.iter().find(|account| {- account.merchant_id == merchant_id+ account.merchant_id == *merchant_id&& account.connector_label == Some(connector.to_string())}).cloned()@@ -702,7 +726,7 @@ impl MerchantConnectorAccountInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -722,7 +746,7 @@ impl MerchantConnectorAccountInterface for MockDb {async fn find_merchant_connector_account_by_merchant_id_connector_name(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {@@ -732,7 +756,7 @@ impl MerchantConnectorAccountInterface for MockDb {.await.iter().filter(|account| {- account.merchant_id == merchant_id && account.connector_name == connector_name+ account.merchant_id == *merchant_id && account.connector_name == connector_name}).cloned().collect::<Vec<_>>();@@ -743,7 +767,7 @@ impl MerchantConnectorAccountInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -776,7 +800,7 @@ impl MerchantConnectorAccountInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError),@@ -790,7 +814,7 @@ impl MerchantConnectorAccountInterface for MockDb {async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -800,7 +824,7 @@ impl MerchantConnectorAccountInterface for MockDb {.await.iter().find(|account| {- account.merchant_id == merchant_id+ account.merchant_id == *merchant_id&& account.merchant_connector_id == merchant_connector_id}).cloned()@@ -809,7 +833,7 @@ impl MerchantConnectorAccountInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -865,7 +889,7 @@ impl MerchantConnectorAccountInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -874,7 +898,7 @@ impl MerchantConnectorAccountInterface for MockDb {async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,get_disabled: bool,key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::MerchantConnectorAccount>, errors::StorageError> {@@ -885,9 +909,9 @@ impl MerchantConnectorAccountInterface for MockDb {.iter().filter(|account: &&storage::MerchantConnectorAccount| {if get_disabled {- account.merchant_id == merchant_id+ account.merchant_id == *merchant_id} else {- account.merchant_id == merchant_id && account.disabled == Some(false)+ account.merchant_id == *merchant_id && account.disabled == Some(false)}}).cloned()@@ -900,7 +924,7 @@ impl MerchantConnectorAccountInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)?,@@ -933,7 +957,7 @@ impl MerchantConnectorAccountInterface for MockDb {.convert(state,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(errors::StorageError::DecryptionError)@@ -953,12 +977,12 @@ impl MerchantConnectorAccountInterface for MockDb {async fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_connector_id: &str,) -> CustomResult<bool, errors::StorageError> {let mut accounts = self.merchant_connector_accounts.lock().await;match accounts.iter().position(|account| {- account.merchant_id == merchant_id+ account.merchant_id == *merchant_id&& account.merchant_connector_id == merchant_connector_id}) {Some(index) => {@@ -1038,7 +1062,8 @@ mod merchant_connector_account_cache_tests {.await.unwrap();- let merchant_id = "test_merchant";+ let merchant_id = common_utils::id_type::MerchantId::from("test_merchant".into()).unwrap();+let connector_label = "stripe_USA";let merchant_connector_id = "simple_merchant_connector_id";let profile_id = "pro_max_ultra";@@ -1046,11 +1071,11 @@ mod merchant_connector_account_cache_tests {db.insert_merchant_key_store(key_manager_state,domain::MerchantKeyStore {- merchant_id: merchant_id.into(),+ merchant_id: merchant_id.clone(),key: domain::types::encrypt(key_manager_state,services::generate_aes256_key().unwrap().to_vec().into(),- Identifier::Merchant(merchant_id.to_string()),+ Identifier::Merchant(merchant_id.clone()),master_key,).await@@ -1065,7 +1090,7 @@ mod merchant_connector_account_cache_tests {let merchant_key = db.get_merchant_key_store_by_merchant_id(key_manager_state,- merchant_id,+ &merchant_id,&master_key.to_vec().into(),).await@@ -1073,7 +1098,7 @@ mod merchant_connector_account_cache_tests {let mca = domain::MerchantConnectorAccount {id: Some(1),- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),connector_name: "stripe".to_string(),connector_account_details: domain::types::encrypt(key_manager_state,@@ -1143,7 +1168,7 @@ mod merchant_connector_account_cache_tests {let delete_call = || async {db.delete_merchant_connector_account_by_merchant_id_merchant_connector_id(- merchant_id,+ &merchant_id,merchant_connector_id,).awaitdiff --git a/crates/router/src/db/merchant_key_store.rs b/crates/router/src/db/merchant_key_store.rsindex 21c1a18442..9540a420e9 100644--- a/crates/router/src/db/merchant_key_store.rs+++ b/crates/router/src/db/merchant_key_store.rs@@ -28,20 +28,20 @@ pub trait MerchantKeyStoreInterface {async fn get_merchant_key_store_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key: &Secret<Vec<u8>>,) -> CustomResult<domain::MerchantKeyStore, errors::StorageError>;async fn delete_merchant_key_store_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError>;#[cfg(feature = "olap")]async fn list_multiple_key_stores(&self,state: &KeyManagerState,- merchant_ids: Vec<String>,+ merchant_ids: Vec<common_utils::id_type::MerchantId>,key: &Secret<Vec<u8>>,) -> CustomResult<Vec<domain::MerchantKeyStore>, errors::StorageError>;@@ -72,7 +72,7 @@ impl MerchantKeyStoreInterface for Store {.insert(&conn).await.map_err(|error| report!(errors::StorageError::from(error)))?- .convert(state, key, merchant_id)+ .convert(state, key, merchant_id.into()).await.change_context(errors::StorageError::DecryptionError)}@@ -81,7 +81,7 @@ impl MerchantKeyStoreInterface for Store {async fn get_merchant_key_store_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key: &Secret<Vec<u8>>,) -> CustomResult<domain::MerchantKeyStore, errors::StorageError> {let fetch_func = || async {@@ -99,7 +99,7 @@ impl MerchantKeyStoreInterface for Store {{fetch_func().await?- .convert(state, key, merchant_id.to_string())+ .convert(state, key, merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)}@@ -114,7 +114,7 @@ impl MerchantKeyStoreInterface for Store {&ACCOUNTS_CACHE,).await?- .convert(state, key, merchant_id.to_string())+ .convert(state, key, merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)}@@ -123,7 +123,7 @@ impl MerchantKeyStoreInterface for Store {#[instrument(skip_all)]async fn delete_merchant_key_store_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let delete_func = || async {let conn = connection::pg_connection_write(self).await?;@@ -142,7 +142,8 @@ impl MerchantKeyStoreInterface for Store {#[cfg(feature = "accounts_cache")]{- let key_store_cache_key = format!("merchant_key_store_{}", merchant_id);+ let key_store_cache_key =+ format!("merchant_key_store_{}", merchant_id.get_string_repr());cache::publish_and_redact(self,CacheKind::Accounts(key_store_cache_key.into()),@@ -157,7 +158,7 @@ impl MerchantKeyStoreInterface for Store {async fn list_multiple_key_stores(&self,state: &KeyManagerState,- merchant_ids: Vec<String>,+ merchant_ids: Vec<common_utils::id_type::MerchantId>,key: &Secret<Vec<u8>>,) -> CustomResult<Vec<domain::MerchantKeyStore>, errors::StorageError> {let fetch_func = || async {@@ -174,7 +175,7 @@ impl MerchantKeyStoreInterface for Store {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)+ .convert(state, key, merchant_id.into()).await.change_context(errors::StorageError::DecryptionError)}))@@ -198,7 +199,7 @@ impl MerchantKeyStoreInterface for Store {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)+ .convert(state, key, merchant_id.into()).await.change_context(errors::StorageError::DecryptionError)}))@@ -222,7 +223,7 @@ impl MerchantKeyStoreInterface for MockDb {{Err(errors::StorageError::DuplicateValue {entity: "merchant_key_store",- key: Some(merchant_key_store.merchant_id.clone()),+ key: Some(merchant_key_store.merchant_id.get_string_repr().to_owned()),})?;}@@ -232,7 +233,7 @@ 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)+ .convert(state, key, merchant_id.into()).await.change_context(errors::StorageError::DecryptionError)}@@ -240,33 +241,33 @@ impl MerchantKeyStoreInterface for MockDb {async fn get_merchant_key_store_by_merchant_id(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key: &Secret<Vec<u8>>,) -> CustomResult<domain::MerchantKeyStore, errors::StorageError> {self.merchant_key_store.lock().await.iter()- .find(|merchant_key| merchant_key.merchant_id == merchant_id)+ .find(|merchant_key| merchant_key.merchant_id == *merchant_id).cloned().ok_or(errors::StorageError::ValueNotFound(String::from("merchant_key_store",)))?- .convert(state, key, merchant_id.to_string())+ .convert(state, key, merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)}async fn delete_merchant_key_store_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let mut merchant_key_stores = self.merchant_key_store.lock().await;let index = merchant_key_stores.iter()- .position(|mks| mks.merchant_id == merchant_id)+ .position(|mks| mks.merchant_id == *merchant_id).ok_or(errors::StorageError::ValueNotFound(format!(- "No merchant key store found for merchant_id = {}",+ "No merchant key store found for merchant_id = {:?}",merchant_id)))?;merchant_key_stores.remove(index);@@ -277,7 +278,7 @@ impl MerchantKeyStoreInterface for MockDb {async fn list_multiple_key_stores(&self,state: &KeyManagerState,- merchant_ids: Vec<String>,+ merchant_ids: Vec<common_utils::id_type::MerchantId>,key: &Secret<Vec<u8>>,) -> CustomResult<Vec<domain::MerchantKeyStore>, errors::StorageError> {let merchant_key_stores = self.merchant_key_store.lock().await;@@ -288,7 +289,7 @@ impl MerchantKeyStoreInterface for MockDb {.map(|merchant_key| async {merchant_key.to_owned()- .convert(state, key, merchant_key.merchant_id.clone())+ .convert(state, key, merchant_key.merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)}),@@ -307,7 +308,7 @@ 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())+ .convert(state, key, merchant_key.merchant_id.clone().into()).await.change_context(errors::StorageError::DecryptionError)}))@@ -353,14 +354,14 @@ mod tests {.await.expect("Failed to create mock DB");let master_key = mock_db.get_master_key();- let merchant_id = "merchant1";- let identifier = Identifier::Merchant(merchant_id.to_string());+ let merchant_id = common_utils::id_type::MerchantId::from("merchant1".into()).unwrap();+ let identifier = Identifier::Merchant(merchant_id.clone());let key_manager_state = &state.into();let merchant_key1 = mock_db.insert_merchant_key_store(key_manager_state,domain::MerchantKeyStore {- merchant_id: merchant_id.into(),+ merchant_id: merchant_id.clone(),key: domain::types::encrypt(key_manager_state,services::generate_aes256_key().unwrap().to_vec().into(),@@ -379,7 +380,7 @@ mod tests {let found_merchant_key1 = mock_db.get_merchant_key_store_by_merchant_id(key_manager_state,- merchant_id,+ &merchant_id,&master_key.to_vec().into(),).await@@ -392,7 +393,7 @@ mod tests {.insert_merchant_key_store(key_manager_state,domain::MerchantKeyStore {- merchant_id: merchant_id.into(),+ merchant_id: merchant_id.clone(),key: domain::types::encrypt(key_manager_state,services::generate_aes256_key().unwrap().to_vec().into(),@@ -408,10 +409,13 @@ mod tests {.await;assert!(insert_duplicate_merchant_key1_result.is_err());+ let non_existent_merchant_id =+ common_utils::id_type::MerchantId::from("non_existent".into()).unwrap();+let find_non_existent_merchant_key_result = mock_db.get_merchant_key_store_by_merchant_id(key_manager_state,- "non_existent",+ &non_existent_merchant_id,&master_key.to_vec().into(),).await;@@ -420,7 +424,7 @@ mod tests {let find_merchant_key_with_incorrect_master_key_result = mock_db.get_merchant_key_store_by_merchant_id(key_manager_state,- merchant_id,+ &merchant_id,&vec![0; 32].into(),).await;diff --git a/crates/router/src/db/payment_link.rs b/crates/router/src/db/payment_link.rsindex c3f7876793..50be9ec728 100644--- a/crates/router/src/db/payment_link.rs+++ b/crates/router/src/db/payment_link.rs@@ -23,7 +23,7 @@ pub trait PaymentLinkInterface {async fn list_payment_link_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_link_constraints: api_models::payments::PaymentLinkListConstraints,) -> CustomResult<Vec<storage::PaymentLink>, errors::StorageError>;}@@ -56,7 +56,7 @@ impl PaymentLinkInterface for Store {#[instrument(skip_all)]async fn list_payment_link_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_link_constraints: api_models::payments::PaymentLinkListConstraints,) -> CustomResult<Vec<storage::PaymentLink>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -86,7 +86,7 @@ impl PaymentLinkInterface for MockDb {async fn list_payment_link_by_merchant_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_payment_link_constraints: api_models::payments::PaymentLinkListConstraints,) -> CustomResult<Vec<storage::PaymentLink>, errors::StorageError> {// TODO: Implement function for `MockDb`xdiff --git a/crates/router/src/db/payment_method.rs b/crates/router/src/db/payment_method.rsindex 9ec25b1d1b..b0fed03e9b 100644--- a/crates/router/src/db/payment_method.rs+++ b/crates/router/src/db/payment_method.rs@@ -25,14 +25,14 @@ pub trait PaymentMethodInterface {async fn find_payment_method_by_customer_id_merchant_id_list(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,limit: Option<i64>,) -> CustomResult<Vec<storage_types::PaymentMethod>, errors::StorageError>;async fn find_payment_method_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,limit: Option<i64>,storage_scheme: MerchantStorageScheme,@@ -41,7 +41,7 @@ pub trait PaymentMethodInterface {async fn get_payment_method_count_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,) -> CustomResult<i64, errors::StorageError>;@@ -60,7 +60,7 @@ pub trait PaymentMethodInterface {async fn delete_payment_method_by_merchant_id_payment_method_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_method_id: &str,) -> CustomResult<storage_types::PaymentMethod, errors::StorageError>;}@@ -190,7 +190,7 @@ mod storage {async fn get_payment_method_count_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,) -> CustomResult<i64, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -366,7 +366,7 @@ mod storage {async fn find_payment_method_by_customer_id_merchant_id_list(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,limit: Option<i64>,) -> CustomResult<Vec<storage_types::PaymentMethod>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -384,7 +384,7 @@ mod storage {async fn find_payment_method_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,limit: Option<i64>,storage_scheme: MerchantStorageScheme,@@ -440,7 +440,7 @@ mod storage {async fn delete_payment_method_by_merchant_id_payment_method_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_method_id: &str,) -> CustomResult<storage_types::PaymentMethod, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -499,7 +499,7 @@ mod storage {async fn get_payment_method_count_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,) -> CustomResult<i64, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -544,7 +544,7 @@ mod storage {async fn find_payment_method_by_customer_id_merchant_id_list(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,limit: Option<i64>,) -> CustomResult<Vec<storage_types::PaymentMethod>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -562,7 +562,7 @@ mod storage {async fn find_payment_method_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,limit: Option<i64>,_storage_scheme: MerchantStorageScheme,@@ -581,7 +581,7 @@ mod storage {async fn delete_payment_method_by_merchant_id_payment_method_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_method_id: &str,) -> CustomResult<storage_types::PaymentMethod, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -641,7 +641,7 @@ impl PaymentMethodInterface for MockDb {async fn get_payment_method_count_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,) -> CustomResult<i64, errors::StorageError> {let payment_methods = self.payment_methods.lock().await;@@ -649,7 +649,7 @@ impl PaymentMethodInterface for MockDb {.iter().filter(|pm| {pm.customer_id == *customer_id- && pm.merchant_id == merchant_id+ && pm.merchant_id == *merchant_id&& pm.status == status}).count();@@ -704,13 +704,13 @@ impl PaymentMethodInterface for MockDb {async fn find_payment_method_by_customer_id_merchant_id_list(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,_limit: Option<i64>,) -> CustomResult<Vec<storage_types::PaymentMethod>, errors::StorageError> {let payment_methods = self.payment_methods.lock().await;let payment_methods_found: Vec<storage_types::PaymentMethod> = payment_methods.iter()- .filter(|pm| pm.customer_id == *customer_id && pm.merchant_id == merchant_id)+ .filter(|pm| pm.customer_id == *customer_id && pm.merchant_id == *merchant_id).cloned().collect();@@ -727,7 +727,7 @@ impl PaymentMethodInterface for MockDb {async fn find_payment_method_by_customer_id_merchant_id_status(&self,customer_id: &id_type::CustomerId,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,status: common_enums::PaymentMethodStatus,_limit: Option<i64>,_storage_scheme: MerchantStorageScheme,@@ -737,7 +737,7 @@ impl PaymentMethodInterface for MockDb {.iter().filter(|pm| {pm.customer_id == *customer_id- && pm.merchant_id == merchant_id+ && pm.merchant_id == *merchant_id&& pm.status == status}).cloned()@@ -755,12 +755,12 @@ impl PaymentMethodInterface for MockDb {async fn delete_payment_method_by_merchant_id_payment_method_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,payment_method_id: &str,) -> CustomResult<storage_types::PaymentMethod, errors::StorageError> {let mut payment_methods = self.payment_methods.lock().await;match payment_methods.iter().position(|pm| {- pm.merchant_id == merchant_id && pm.payment_method_id == payment_method_id+ pm.merchant_id == *merchant_id && pm.payment_method_id == payment_method_id}) {Some(index) => {let deleted_payment_method = payment_methods.remove(index);diff --git a/crates/router/src/db/refund.rs b/crates/router/src/db/refund.rsindex a36af01471..67be1d30e0 100644--- a/crates/router/src/db/refund.rs+++ b/crates/router/src/db/refund.rs@@ -20,27 +20,27 @@ pub trait RefundInterface {async fn find_refund_by_internal_reference_id_merchant_id(&self,internal_reference_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_types::Refund, errors::StorageError>;async fn find_refund_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError>;async fn find_refund_by_merchant_id_refund_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_id: &str,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_types::Refund, errors::StorageError>;async fn find_refund_by_merchant_id_connector_refund_id_connector(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_refund_id: &str,connector: &str,storage_scheme: enums::MerchantStorageScheme,@@ -55,7 +55,7 @@ pub trait RefundInterface {async fn find_refund_by_merchant_id_connector_transaction_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_transaction_id: &str,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError>;@@ -69,7 +69,7 @@ pub trait RefundInterface {#[cfg(feature = "olap")]async fn filter_refund_by_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,storage_scheme: enums::MerchantStorageScheme,limit: i64,@@ -79,7 +79,7 @@ pub trait RefundInterface {#[cfg(feature = "olap")]async fn filter_refund_by_meta_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::payments::TimeRange,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError>;@@ -87,7 +87,7 @@ pub trait RefundInterface {#[cfg(feature = "olap")]async fn get_total_count_of_refunds(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<i64, errors::StorageError>;@@ -112,7 +112,7 @@ mod storage {async fn find_refund_by_internal_reference_id_merchant_id(&self,internal_reference_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_types::Refund, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -140,7 +140,7 @@ mod storage {#[instrument(skip_all)]async fn find_refund_by_merchant_id_connector_transaction_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_transaction_id: &str,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> {@@ -170,7 +170,7 @@ mod storage {#[instrument(skip_all)]async fn find_refund_by_merchant_id_refund_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_id: &str,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_types::Refund, errors::StorageError> {@@ -183,7 +183,7 @@ mod storage {#[instrument(skip_all)]async fn find_refund_by_merchant_id_connector_refund_id_connector(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_refund_id: &str,connector: &str,_storage_scheme: enums::MerchantStorageScheme,@@ -203,7 +203,7 @@ mod storage {async fn find_refund_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;@@ -216,7 +216,7 @@ mod storage {#[instrument(skip_all)]async fn filter_refund_by_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,_storage_scheme: enums::MerchantStorageScheme,limit: i64,@@ -238,7 +238,7 @@ mod storage {#[instrument(skip_all)]async fn filter_refund_by_meta_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::payments::TimeRange,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {@@ -255,7 +255,7 @@ mod storage {#[instrument(skip_all)]async fn get_total_count_of_refunds(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<i64, errors::StorageError> {@@ -296,7 +296,7 @@ mod storage {async fn find_refund_by_internal_reference_id_merchant_id(&self,internal_reference_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_types::Refund, errors::StorageError> {let database_call = || async {@@ -315,7 +315,10 @@ mod storage {match storage_scheme {enums::MerchantStorageScheme::PostgresOnly => database_call().await,enums::MerchantStorageScheme::RedisKv => {- let lookup_id = format!("ref_inter_ref_{merchant_id}_{internal_reference_id}");+ let lookup_id = format!(+ "ref_inter_ref_{}_{internal_reference_id}",+ merchant_id.get_string_repr()+ );let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -415,7 +418,8 @@ mod storage {sk_id: field.clone(),lookup_id: format!("ref_ref_id_{}_{}",- created_refund.merchant_id, created_refund.refund_id+ created_refund.merchant_id.get_string_repr(),+ created_refund.refund_id),pk_id: key_str.clone(),source: "refund".to_string(),@@ -426,7 +430,8 @@ mod storage {sk_id: field.clone(),lookup_id: format!("ref_inter_ref_{}_{}",- created_refund.merchant_id, created_refund.internal_reference_id+ created_refund.merchant_id.get_string_repr(),+ created_refund.internal_reference_id),pk_id: key_str.clone(),source: "refund".to_string(),@@ -439,7 +444,7 @@ mod storage {sk_id: field.clone(),lookup_id: format!("ref_connector_{}_{}_{}",- created_refund.merchant_id,+ created_refund.merchant_id.get_string_repr(),connector_refund_id,created_refund.connector),@@ -482,7 +487,7 @@ mod storage {#[instrument(skip_all)]async fn find_refund_by_merchant_id_connector_transaction_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_transaction_id: &str,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> {@@ -502,8 +507,10 @@ mod storage {match storage_scheme {enums::MerchantStorageScheme::PostgresOnly => database_call().await,enums::MerchantStorageScheme::RedisKv => {- let lookup_id =- format!("pa_conn_trans_{merchant_id}_{connector_transaction_id}");+ let lookup_id = format!(+ "pa_conn_trans_{}_{connector_transaction_id}",+ merchant_id.get_string_repr()+ );let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -598,7 +605,7 @@ mod storage {#[instrument(skip_all)]async fn find_refund_by_merchant_id_refund_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_id: &str,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_types::Refund, errors::StorageError> {@@ -614,7 +621,8 @@ mod storage {match storage_scheme {enums::MerchantStorageScheme::PostgresOnly => database_call().await,enums::MerchantStorageScheme::RedisKv => {- let lookup_id = format!("ref_ref_id_{merchant_id}_{refund_id}");+ let lookup_id =+ format!("ref_ref_id_{}_{refund_id}", merchant_id.get_string_repr());let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -644,7 +652,7 @@ mod storage {#[instrument(skip_all)]async fn find_refund_by_merchant_id_connector_refund_id_connector(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_refund_id: &str,connector: &str,storage_scheme: enums::MerchantStorageScheme,@@ -666,8 +674,10 @@ mod storage {match storage_scheme {enums::MerchantStorageScheme::PostgresOnly => database_call().await,enums::MerchantStorageScheme::RedisKv => {- let lookup_id =- format!("ref_connector_{merchant_id}_{connector_refund_id}_{connector}");+ let lookup_id = format!(+ "ref_connector_{}_{connector_refund_id}_{connector}",+ merchant_id.get_string_repr()+ );let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -698,7 +708,7 @@ mod storage {async fn find_refund_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> {let database_call = || async {@@ -742,7 +752,7 @@ mod storage {#[instrument(skip_all)]async fn filter_refund_by_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,_storage_scheme: enums::MerchantStorageScheme,limit: i64,@@ -764,7 +774,7 @@ mod storage {#[instrument(skip_all)]async fn filter_refund_by_meta_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::payments::TimeRange,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {@@ -778,7 +788,7 @@ mod storage {#[instrument(skip_all)]async fn get_total_count_of_refunds(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<i64, errors::StorageError> {@@ -799,14 +809,14 @@ impl RefundInterface for MockDb {async fn find_refund_by_internal_reference_id_merchant_id(&self,internal_reference_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_types::Refund, errors::StorageError> {let refunds = self.refunds.lock().await;refunds.iter().find(|refund| {- refund.merchant_id == merchant_id+ refund.merchant_id == *merchant_id&& refund.internal_reference_id == internal_reference_id}).cloned()@@ -858,7 +868,7 @@ impl RefundInterface for MockDb {}async fn find_refund_by_merchant_id_connector_transaction_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_transaction_id: &str,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> {@@ -867,7 +877,7 @@ impl RefundInterface for MockDb {Ok(refunds.iter().take_while(|refund| {- refund.merchant_id == merchant_id+ refund.merchant_id == *merchant_id&& refund.connector_transaction_id == connector_transaction_id}).cloned()@@ -898,7 +908,7 @@ impl RefundInterface for MockDb {async fn find_refund_by_merchant_id_refund_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_id: &str,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<storage_types::Refund, errors::StorageError> {@@ -906,7 +916,7 @@ impl RefundInterface for MockDb {refunds.iter()- .find(|refund| refund.merchant_id == merchant_id && refund.refund_id == refund_id)+ .find(|refund| refund.merchant_id == *merchant_id && refund.refund_id == refund_id).cloned().ok_or_else(|| {errors::StorageError::DatabaseError(DatabaseError::NotFound.into()).into()@@ -915,7 +925,7 @@ impl RefundInterface for MockDb {async fn find_refund_by_merchant_id_connector_refund_id_connector(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_refund_id: &str,connector: &str,_storage_scheme: enums::MerchantStorageScheme,@@ -925,7 +935,7 @@ impl RefundInterface for MockDb {refunds.iter().find(|refund| {- refund.merchant_id == merchant_id+ refund.merchant_id == *merchant_id&& refund.connector_refund_id == Some(connector_refund_id.to_string())&& refund.connector == connector})@@ -938,14 +948,14 @@ impl RefundInterface for MockDb {async fn find_refund_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> {let refunds = self.refunds.lock().await;Ok(refunds.iter()- .filter(|refund| refund.merchant_id == merchant_id && refund.payment_id == payment_id)+ .filter(|refund| refund.merchant_id == *merchant_id && refund.payment_id == payment_id).cloned().collect::<Vec<_>>())}@@ -953,7 +963,7 @@ impl RefundInterface for MockDb {#[cfg(feature = "olap")]async fn filter_refund_by_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,_storage_scheme: enums::MerchantStorageScheme,limit: i64,@@ -994,7 +1004,7 @@ impl RefundInterface for MockDb {let refunds = self.refunds.lock().await;let filtered_refunds = refunds.iter()- .filter(|refund| refund.merchant_id == merchant_id)+ .filter(|refund| refund.merchant_id == *merchant_id).filter(|refund| {refund_details.payment_id@@ -1059,7 +1069,7 @@ impl RefundInterface for MockDb {#[cfg(feature = "olap")]async fn filter_refund_by_meta_constraints(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::payments::TimeRange,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {@@ -1106,7 +1116,7 @@ impl RefundInterface for MockDb {#[cfg(feature = "olap")]async fn get_total_count_of_refunds(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_details: &api_models::refunds::RefundListRequest,_storage_scheme: enums::MerchantStorageScheme,) -> CustomResult<i64, errors::StorageError> {@@ -1145,7 +1155,7 @@ impl RefundInterface for MockDb {let refunds = self.refunds.lock().await;let filtered_refunds = refunds.iter()- .filter(|refund| refund.merchant_id == merchant_id)+ .filter(|refund| refund.merchant_id == *merchant_id).filter(|refund| {refund_details.payment_iddiff --git a/crates/router/src/db/role.rs b/crates/router/src/db/role.rsindex 8891533338..15dfc14d37 100644--- a/crates/router/src/db/role.rs+++ b/crates/router/src/db/role.rs@@ -26,7 +26,7 @@ pub trait RoleInterface {async fn find_role_by_role_id_in_merchant_scope(&self,role_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<storage::Role, errors::StorageError>;@@ -43,7 +43,7 @@ pub trait RoleInterface {async fn list_all_roles(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<Vec<storage::Role>, errors::StorageError>;}@@ -76,7 +76,7 @@ impl RoleInterface for Store {async fn find_role_by_role_id_in_merchant_scope(&self,role_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<storage::Role, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -111,7 +111,7 @@ impl RoleInterface for Store {#[instrument(skip_all)]async fn list_all_roles(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<Vec<storage::Role>, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -174,7 +174,7 @@ impl RoleInterface for MockDb {async fn find_role_by_role_id_in_merchant_scope(&self,role_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<storage::Role, errors::StorageError> {let roles = self.roles.lock().await;@@ -182,14 +182,14 @@ impl RoleInterface for MockDb {.iter().find(|role| {role.role_id == role_id- && (role.merchant_id == merchant_id+ && (role.merchant_id == *merchant_id|| (role.org_id == *org_id && role.scope == enums::RoleScope::Organization))}).cloned().ok_or(errors::StorageError::ValueNotFound(format!("No role available in merchant scope for role_id = {role_id}, \- merchant_id = {merchant_id} and org_id = {org_id:?}"+ merchant_id = {merchant_id:?} and org_id = {org_id:?}")).into(),)@@ -246,7 +246,7 @@ impl RoleInterface for MockDb {async fn list_all_roles(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<Vec<storage::Role>, errors::StorageError> {let roles = self.roles.lock().await;@@ -254,7 +254,7 @@ impl RoleInterface for MockDb {let roles_list: Vec<_> = roles.iter().filter(|role| {- role.merchant_id == merchant_id+ role.merchant_id == *merchant_id|| (role.org_id == *org_id&& role.scope == diesel_models::enums::RoleScope::Organization)})@@ -263,7 +263,7 @@ impl RoleInterface for MockDb {if roles_list.is_empty() {return Err(errors::StorageError::ValueNotFound(format!(- "No role found for merchant id = {} and org_id = {:?}",+ "No role found for merchant id = {:?} and org_id = {:?}",merchant_id, org_id)).into());diff --git a/crates/router/src/db/routing_algorithm.rs b/crates/router/src/db/routing_algorithm.rsindex f65933d898..b5e877b529 100644--- a/crates/router/src/db/routing_algorithm.rs+++ b/crates/router/src/db/routing_algorithm.rs@@ -27,7 +27,7 @@ pub trait RoutingAlgorithmInterface {async fn find_routing_algorithm_by_algorithm_id_merchant_id(&self,algorithm_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<routing_storage::RoutingAlgorithm>;async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(@@ -45,14 +45,14 @@ pub trait RoutingAlgorithmInterface {async fn list_routing_algorithm_metadata_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,limit: i64,offset: i64,) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>>;async fn list_routing_algorithm_metadata_by_merchant_id_transaction_type(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,transaction_type: &common_enums::TransactionType,limit: i64,offset: i64,@@ -93,7 +93,7 @@ impl RoutingAlgorithmInterface for Store {async fn find_routing_algorithm_by_algorithm_id_merchant_id(&self,algorithm_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<routing_storage::RoutingAlgorithm> {let conn = connection::pg_connection_write(self).await?;routing_storage::RoutingAlgorithm::find_by_algorithm_id_merchant_id(@@ -139,7 +139,7 @@ impl RoutingAlgorithmInterface for Store {#[instrument(skip_all)]async fn list_routing_algorithm_metadata_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,limit: i64,offset: i64,) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> {@@ -156,7 +156,7 @@ impl RoutingAlgorithmInterface for Store {async fn list_routing_algorithm_metadata_by_merchant_id_transaction_type(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,transaction_type: &common_enums::TransactionType,limit: i64,offset: i64,@@ -194,7 +194,7 @@ impl RoutingAlgorithmInterface for MockDb {async fn find_routing_algorithm_by_algorithm_id_merchant_id(&self,_algorithm_id: &str,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<routing_storage::RoutingAlgorithm> {Err(errors::StorageError::MockDbError)?}@@ -218,7 +218,7 @@ impl RoutingAlgorithmInterface for MockDb {async fn list_routing_algorithm_metadata_by_merchant_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_limit: i64,_offset: i64,) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> {@@ -227,7 +227,7 @@ impl RoutingAlgorithmInterface for MockDb {async fn list_routing_algorithm_metadata_by_merchant_id_transaction_type(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_transaction_type: &common_enums::TransactionType,_limit: i64,_offset: i64,diff --git a/crates/router/src/db/user/sample_data.rs b/crates/router/src/db/user/sample_data.rsindex cabf62b850..3bcbb624cb 100644--- a/crates/router/src/db/user/sample_data.rs+++ b/crates/router/src/db/user/sample_data.rs@@ -39,18 +39,18 @@ pub trait BatchSampleDataInterface {async fn delete_payment_intents_for_sample_data(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_store: &MerchantKeyStore,) -> CustomResult<Vec<PaymentIntent>, StorageError>;async fn delete_payment_attempts_for_sample_data(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<PaymentAttempt>, StorageError>;async fn delete_refunds_for_sample_data(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<Refund>, StorageError>;}@@ -81,7 +81,7 @@ impl BatchSampleDataInterface for Store {state,payment_intent,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),)})).map(|join_result| join_result.change_context(StorageError::DecryptionError))@@ -120,7 +120,7 @@ impl BatchSampleDataInterface for Store {async fn delete_payment_intents_for_sample_data(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,key_store: &MerchantKeyStore,) -> CustomResult<Vec<PaymentIntent>, StorageError> {let conn = pg_connection_write(self)@@ -135,7 +135,7 @@ impl BatchSampleDataInterface for Store {state,payment_intent,key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),)})).map(|join_result| join_result.change_context(StorageError::DecryptionError))@@ -145,7 +145,7 @@ impl BatchSampleDataInterface for Store {async fn delete_payment_attempts_for_sample_data(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<PaymentAttempt>, StorageError> {let conn = pg_connection_write(self).await@@ -161,7 +161,7 @@ impl BatchSampleDataInterface for Store {}async fn delete_refunds_for_sample_data(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<Refund>, StorageError> {let conn = pg_connection_write(self).await@@ -200,20 +200,20 @@ impl BatchSampleDataInterface for storage_impl::MockDb {async fn delete_payment_intents_for_sample_data(&self,_state: &KeyManagerState,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_key_store: &MerchantKeyStore,) -> CustomResult<Vec<PaymentIntent>, StorageError> {Err(StorageError::MockDbError)?}async fn delete_payment_attempts_for_sample_data(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<PaymentAttempt>, StorageError> {Err(StorageError::MockDbError)?}async fn delete_refunds_for_sample_data(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<Refund>, StorageError> {Err(StorageError::MockDbError)?}diff --git a/crates/router/src/db/user_key_store.rs b/crates/router/src/db/user_key_store.rsindex 111989a293..eef0d0c837 100644--- a/crates/router/src/db/user_key_store.rs+++ b/crates/router/src/db/user_key_store.rs@@ -1,4 +1,7 @@-use common_utils::{errors::CustomResult, types::keymanager::KeyManagerState};+use common_utils::{+ errors::CustomResult,+ types::keymanager::{self, KeyManagerState},+};use error_stack::{report, ResultExt};use masking::Secret;use router_env::{instrument, tracing};@@ -57,7 +60,7 @@ impl UserKeyStoreInterface for Store {.insert(&conn).await.map_err(|error| report!(errors::StorageError::from(error)))?- .convert(state, key, user_id)+ .convert(state, key, keymanager::Identifier::User(user_id)).await.change_context(errors::StorageError::DecryptionError)}@@ -74,7 +77,7 @@ 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, user_id.to_string())+ .convert(state, key, keymanager::Identifier::User(user_id.to_owned())).await.change_context(errors::StorageError::DecryptionError)}@@ -96,7 +99,7 @@ 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, user_id)+ .convert(state, key, keymanager::Identifier::User(user_id)).await.change_context(errors::StorageError::DecryptionError)}))@@ -131,7 +134,7 @@ 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, user_id)+ .convert(state, key, keymanager::Identifier::User(user_id)).await.change_context(errors::StorageError::DecryptionError)}@@ -149,7 +152,7 @@ impl UserKeyStoreInterface for MockDb {let user_id = user_key.user_id.clone();user_key.to_owned()- .convert(state, key, user_id)+ .convert(state, key, keymanager::Identifier::User(user_id)).await.change_context(errors::StorageError::DecryptionError)}))@@ -173,7 +176,7 @@ impl UserKeyStoreInterface for MockDb {"No user_key_store is found for user_id={}",user_id)))?- .convert(state, key, user_id.to_string())+ .convert(state, key, keymanager::Identifier::User(user_id.to_owned())).await.change_context(errors::StorageError::DecryptionError)}diff --git a/crates/router/src/db/user_role.rs b/crates/router/src/db/user_role.rsindex 50ea4ecc9a..7f16cedd57 100644--- a/crates/router/src/db/user_role.rs+++ b/crates/router/src/db/user_role.rs@@ -28,13 +28,13 @@ pub trait UserRoleInterface {async fn find_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<storage::UserRole, errors::StorageError>;async fn update_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,update: storage::UserRoleUpdate,) -> CustomResult<storage::UserRole, errors::StorageError>;@@ -48,7 +48,7 @@ pub trait UserRoleInterface {async fn delete_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<storage::UserRole, errors::StorageError>;async fn list_user_roles_by_user_id(@@ -58,7 +58,7 @@ pub trait UserRoleInterface {async fn list_user_roles_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<Vec<storage::UserRole>, errors::StorageError>;async fn transfer_org_ownership_between_users(@@ -98,7 +98,7 @@ impl UserRoleInterface for Store {async fn find_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<storage::UserRole, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;storage::UserRole::find_by_user_id_merchant_id(@@ -114,7 +114,7 @@ impl UserRoleInterface for Store {async fn update_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,update: storage::UserRoleUpdate,) -> CustomResult<storage::UserRole, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -150,7 +150,7 @@ impl UserRoleInterface for Store {async fn delete_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<storage::UserRole, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -177,7 +177,7 @@ impl UserRoleInterface for Store {#[instrument(skip_all)]async fn list_user_roles_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;storage::UserRole::list_by_merchant_id(&conn, merchant_id.to_owned())@@ -224,7 +224,7 @@ impl UserRoleInterface for Store {let new_org_admin_merchant_ids = new_org_admin_user_roles.iter().map(|user_role| user_role.merchant_id.to_owned())- .collect::<HashSet<String>>();+ .collect::<HashSet<_>>();let now = common_utils::date_time::now();@@ -318,16 +318,16 @@ impl UserRoleInterface for MockDb {async fn find_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<storage::UserRole, errors::StorageError> {let user_roles = self.user_roles.lock().await;user_roles.iter()- .find(|user_role| user_role.user_id == user_id && user_role.merchant_id == merchant_id)+ .find(|user_role| user_role.user_id == user_id && user_role.merchant_id == *merchant_id).cloned().ok_or(errors::StorageError::ValueNotFound(format!(- "No user role available for user_id = {user_id} and merchant_id = {merchant_id}"+ "No user role available for user_id = {user_id} and merchant_id = {merchant_id:?}")).into(),)@@ -336,13 +336,13 @@ impl UserRoleInterface for MockDb {async fn update_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,update: storage::UserRoleUpdate,) -> CustomResult<storage::UserRole, errors::StorageError> {let mut user_roles = self.user_roles.lock().await;user_roles.iter_mut()- .find(|user_role| user_role.user_id == user_id && user_role.merchant_id == merchant_id)+ .find(|user_role| user_role.user_id == user_id && user_role.merchant_id == *merchant_id).map(|user_role| {*user_role = match &update {storage::UserRoleUpdate::UpdateRole {@@ -366,7 +366,7 @@ impl UserRoleInterface for MockDb {}).ok_or(errors::StorageError::ValueNotFound(format!(- "No user role available for user_id = {user_id} and merchant_id = {merchant_id}"+ "No user role available for user_id = {user_id} and merchant_id = {merchant_id:?}")).into(),)@@ -442,7 +442,7 @@ impl UserRoleInterface for MockDb {let new_org_admin_merchant_ids = new_org_admin_user_roles.iter().map(|user_role| user_role.merchant_id.to_owned())- .collect::<HashSet<String>>();+ .collect::<HashSet<_>>();let now = common_utils::date_time::now();@@ -476,13 +476,13 @@ impl UserRoleInterface for MockDb {async fn delete_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<storage::UserRole, errors::StorageError> {let mut user_roles = self.user_roles.lock().await;match user_roles.iter()- .position(|role| role.user_id == user_id && role.merchant_id == merchant_id)+ .position(|role| role.user_id == user_id && role.merchant_id == *merchant_id){Some(index) => Ok(user_roles.remove(index)),None => Err(errors::StorageError::ValueNotFound(@@ -512,7 +512,7 @@ impl UserRoleInterface for MockDb {async fn list_user_roles_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {let user_roles = self.user_roles.lock().await;@@ -520,7 +520,7 @@ impl UserRoleInterface for MockDb {.iter().cloned().filter_map(|ele| {- if ele.merchant_id == merchant_id {+ if ele.merchant_id == *merchant_id {return Some(ele);}None@@ -541,7 +541,7 @@ impl UserRoleInterface for super::KafkaStore {async fn update_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,update: storage::UserRoleUpdate,) -> CustomResult<storage::UserRole, errors::StorageError> {self.diesel_store@@ -557,7 +557,7 @@ impl UserRoleInterface for super::KafkaStore {async fn delete_user_role_by_user_id_merchant_id(&self,user_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<storage::UserRole, errors::StorageError> {self.diesel_store.delete_user_role_by_user_id_merchant_id(user_id, merchant_id)@@ -571,7 +571,7 @@ impl UserRoleInterface for super::KafkaStore {}async fn list_user_roles_by_merchant_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {self.diesel_store.list_user_roles_by_merchant_id(merchant_id)diff --git a/crates/router/src/events/api_logs.rs b/crates/router/src/events/api_logs.rsindex 9eb8f1021a..e818b7440b 100644--- a/crates/router/src/events/api_logs.rs+++ b/crates/router/src/events/api_logs.rs@@ -24,7 +24,7 @@ use crate::{#[derive(Clone, Debug, Eq, PartialEq, Serialize)]#[serde(rename_all = "snake_case")]pub struct ApiEvent {- merchant_id: Option<String>,+ merchant_id: Option<common_utils::id_type::MerchantId>,api_flow: String,created_at_timestamp: i128,request_id: String,@@ -47,7 +47,7 @@ pub struct ApiEvent {impl ApiEvent {#[allow(clippy::too_many_arguments)]pub fn new(- merchant_id: Option<String>,+ merchant_id: Option<common_utils::id_type::MerchantId>,api_flow: &impl FlowMetric,request_id: &RequestId,latency: u128,diff --git a/crates/router/src/events/outgoing_webhook_logs.rs b/crates/router/src/events/outgoing_webhook_logs.rsindex 9accf0ff0d..7ab100c250 100644--- a/crates/router/src/events/outgoing_webhook_logs.rs+++ b/crates/router/src/events/outgoing_webhook_logs.rs@@ -9,7 +9,7 @@ use crate::services::kafka::KafkaMessage;#[derive(Clone, Debug, PartialEq, Serialize)]#[serde(rename_all = "snake_case")]pub struct OutgoingWebhookEvent {- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,event_id: String,event_type: OutgoingWebhookEventType,#[serde(flatten)]@@ -90,7 +90,7 @@ impl OutgoingWebhookEventMetric for OutgoingWebhookContent {impl OutgoingWebhookEvent {pub fn new(- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,event_id: String,event_type: OutgoingWebhookEventType,content: Option<OutgoingWebhookEventContent>,diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rsindex e6c4ff8dc6..05f65b8e47 100644--- a/crates/router/src/routes/admin.rs+++ b/crates/router/src/routes/admin.rs@@ -1,6 +1,4 @@use actix_web::{web, HttpRequest, HttpResponse};-#[cfg(feature = "olap")]-use common_utils::id_type;use router_env::{instrument, tracing, Flow};use super::app::AppState;@@ -35,7 +33,7 @@ pub async fn organization_create(pub async fn organization_update(state: web::Data<AppState>,req: HttpRequest,- org_id: web::Path<id_type::OrganizationId>,+ org_id: web::Path<common_utils::id_type::OrganizationId>,json_payload: web::Json<admin::OrganizationRequest>,) -> HttpResponse {let flow = Flow::OrganizationUpdate;@@ -58,7 +56,7 @@ pub async fn organization_update(pub async fn organization_retrieve(state: web::Data<AppState>,req: HttpRequest,- org_id: web::Path<id_type::OrganizationId>,+ org_id: web::Path<common_utils::id_type::OrganizationId>,) -> HttpResponse {let flow = Flow::OrganizationRetrieve;let organization_id = org_id.into_inner();@@ -114,7 +112,7 @@ pub async fn merchant_account_create(pub async fn retrieve_merchant_account(state: web::Data<AppState>,req: HttpRequest,- mid: web::Path<String>,+ mid: web::Path<common_utils::id_type::MerchantId>,) -> HttpResponse {let flow = Flow::MerchantsAccountRetrieve;let merchant_id = mid.into_inner();@@ -181,7 +179,7 @@ pub async fn merchant_account_list(pub async fn update_merchant_account(state: web::Data<AppState>,req: HttpRequest,- mid: web::Path<String>,+ mid: web::Path<common_utils::id_type::MerchantId>,json_payload: web::Json<admin::MerchantAccountUpdate>,) -> HttpResponse {let flow = Flow::MerchantsAccountUpdate;@@ -225,7 +223,7 @@ pub async fn update_merchant_account(pub async fn delete_merchant_account(state: web::Data<AppState>,req: HttpRequest,- mid: web::Path<String>,+ mid: web::Path<common_utils::id_type::MerchantId>,) -> HttpResponse {let flow = Flow::MerchantsAccountDelete;let mid = mid.into_inner();@@ -261,7 +259,7 @@ pub async fn delete_merchant_account(pub async fn payment_connector_create(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,json_payload: web::Json<admin::MerchantConnectorCreate>,) -> HttpResponse {let flow = Flow::MerchantConnectorsCreate;@@ -307,7 +305,7 @@ pub async fn payment_connector_create(pub async fn payment_connector_retrieve(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> HttpResponse {let flow = Flow::MerchantConnectorsRetrieve;let (merchant_id, merchant_connector_id) = path.into_inner();@@ -359,7 +357,7 @@ pub async fn payment_connector_retrieve(pub async fn payment_connector_list(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,) -> HttpResponse {let flow = Flow::MerchantConnectorsList;let merchant_id = path.into_inner();@@ -406,7 +404,7 @@ pub async fn payment_connector_list(pub async fn payment_connector_update(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,json_payload: web::Json<api_models::admin::MerchantConnectorUpdate>,) -> HttpResponse {let flow = Flow::MerchantConnectorsUpdate;@@ -455,7 +453,7 @@ pub async fn payment_connector_update(pub async fn payment_connector_delete(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> HttpResponse {let flow = Flow::MerchantConnectorsDelete;let (merchant_id, merchant_connector_id) = path.into_inner();@@ -492,7 +490,7 @@ pub async fn payment_connector_delete(pub async fn merchant_account_toggle_kv(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,json_payload: web::Json<admin::ToggleKVRequest>,) -> HttpResponse {let flow = Flow::ConfigKeyUpdate;@@ -540,7 +538,7 @@ pub async fn business_profile_create(state: web::Data<AppState>,req: HttpRequest,json_payload: web::Json<admin::BusinessProfileCreate>,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,) -> HttpResponse {let flow = Flow::BusinessProfileCreate;let payload = json_payload.into_inner();@@ -568,7 +566,7 @@ pub async fn business_profile_create(pub async fn business_profile_retrieve(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> HttpResponse {let flow = Flow::BusinessProfileRetrieve;let (merchant_id, profile_id) = path.into_inner();@@ -595,7 +593,7 @@ pub async fn business_profile_retrieve(pub async fn business_profile_update(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,json_payload: web::Json<api_models::admin::BusinessProfileUpdate>,) -> HttpResponse {let flow = Flow::BusinessProfileUpdate;@@ -623,7 +621,7 @@ pub async fn business_profile_update(pub async fn business_profile_delete(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> HttpResponse {let flow = Flow::BusinessProfileDelete;let (merchant_id, profile_id) = path.into_inner();@@ -643,7 +641,7 @@ pub async fn business_profile_delete(pub async fn business_profiles_list(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,) -> HttpResponse {let flow = Flow::BusinessProfileList;let merchant_id = path.into_inner();@@ -671,7 +669,7 @@ pub async fn business_profiles_list(pub async fn toggle_connector_agnostic_mit(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,json_payload: web::Json<api_models::admin::ConnectorAgnosticMitChoice>,) -> HttpResponse {let flow = Flow::ToggleConnectorAgnosticMit;@@ -699,7 +697,7 @@ pub async fn toggle_connector_agnostic_mit(pub async fn merchant_account_kv_status(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,) -> HttpResponse {let flow = Flow::ConfigKeyFetch;let merchant_id = path.into_inner();diff --git a/crates/router/src/routes/api_keys.rs b/crates/router/src/routes/api_keys.rsindex f1170f0f0b..3513984979 100644--- a/crates/router/src/routes/api_keys.rs+++ b/crates/router/src/routes/api_keys.rs@@ -29,7 +29,7 @@ use crate::{pub async fn api_key_create(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,json_payload: web::Json<api_types::CreateApiKeyRequest>,) -> impl Responder {let flow = Flow::ApiKeyCreate;@@ -78,7 +78,7 @@ pub async fn api_key_create(pub async fn api_key_retrieve(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::ApiKeyRetrieve;let (merchant_id, key_id) = path.into_inner();@@ -124,7 +124,7 @@ pub async fn api_key_retrieve(pub async fn api_key_update(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,json_payload: web::Json<api_types::UpdateApiKeyRequest>,) -> impl Responder {let flow = Flow::ApiKeyUpdate;@@ -174,7 +174,7 @@ pub async fn api_key_update(pub async fn api_key_revoke(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::ApiKeyRevoke;let (merchant_id, key_id) = path.into_inner();@@ -219,7 +219,7 @@ pub async fn api_key_revoke(pub async fn api_key_list(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,query: web::Query<api_types::ListApiKeyConstraints>,) -> impl Responder {let flow = Flow::ApiKeyList;diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex 0970da6e0a..309a94c141 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -170,7 +170,6 @@ pub trait AppStateInfo {#[cfg(feature = "email")]fn email_client(&self) -> Arc<dyn EmailService>;fn add_request_id(&mut self, request_id: RequestId);- fn add_merchant_id(&mut self, merchant_id: Option<String>);fn add_flow_name(&mut self, flow_name: String);fn get_request_id(&self) -> Option<String>;}@@ -191,9 +190,6 @@ impl AppStateInfo for AppState {self.request_id.replace(request_id);}- fn add_merchant_id(&mut self, merchant_id: Option<String>) {- self.api_client.add_merchant_id(merchant_id);- }fn add_flow_name(&mut self, flow_name: String) {self.api_client.add_flow_name(flow_name);}diff --git a/crates/router/src/routes/customers.rs b/crates/router/src/routes/customers.rsindex cf89f2f547..0ccf6f9a77 100644--- a/crates/router/src/routes/customers.rs+++ b/crates/router/src/routes/customers.rs@@ -81,7 +81,11 @@ pub async fn customers_list(state: web::Data<AppState>, req: HttpRequest) -> Htt&req,(),|state, auth, _, _| {- list_customers(state, auth.merchant_account.merchant_id, auth.key_store)+ list_customers(+ state,+ auth.merchant_account.get_id().to_owned(),+ auth.key_store,+ )},auth::auth_type(&auth::ApiKeyAuth,diff --git a/crates/router/src/routes/ephemeral_key.rs b/crates/router/src/routes/ephemeral_key.rsindex 9b10093846..93041bbd0a 100644--- a/crates/router/src/routes/ephemeral_key.rs+++ b/crates/router/src/routes/ephemeral_key.rs@@ -25,7 +25,7 @@ pub async fn ephemeral_key_create(helpers::make_ephemeral_key(state,req.get_merchant_reference_id(),- auth.merchant_account.merchant_id,+ auth.merchant_account.get_id().to_owned(),)},&auth::ApiKeyAuth,diff --git a/crates/router/src/routes/locker_migration.rs b/crates/router/src/routes/locker_migration.rsindex 2a8b1ca791..6ebad77377 100644--- a/crates/router/src/routes/locker_migration.rs+++ b/crates/router/src/routes/locker_migration.rs@@ -10,7 +10,7 @@ use crate::{pub async fn rust_locker_migration(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,) -> HttpResponse {let flow = Flow::RustLockerMigration;let merchant_id = path.into_inner();diff --git a/crates/router/src/routes/metrics/request.rs b/crates/router/src/routes/metrics/request.rsindex 5ec2692da9..572f3dc933 100644--- a/crates/router/src/routes/metrics/request.rs+++ b/crates/router/src/routes/metrics/request.rs@@ -25,14 +25,18 @@ whereresult}-pub fn status_code_metrics(status_code: String, flow: String, merchant_id: String) {+pub fn status_code_metrics(+ status_code: String,+ flow: String,+ merchant_id: common_utils::id_type::MerchantId,+) {super::REQUEST_STATUS.add(&super::CONTEXT,1,&add_attributes([("status_code", status_code),("flow", flow),- ("merchant_id", merchant_id),+ ("merchant_id", merchant_id.get_string_repr().to_owned()),]),)}diff --git a/crates/router/src/routes/payment_link.rs b/crates/router/src/routes/payment_link.rsindex fed182f03a..33d3c21ef9 100644--- a/crates/router/src/routes/payment_link.rs+++ b/crates/router/src/routes/payment_link.rs@@ -54,7 +54,7 @@ pub async fn payment_link_retrieve(pub async fn initiate_payment_link(state: web::Data<AppState>,req: actix_web::HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::PaymentLinkInitiate;let (merchant_id, payment_id) = path.into_inner();@@ -128,7 +128,7 @@ pub async fn payments_link_list(pub async fn payment_link_status(state: web::Data<AppState>,req: actix_web::HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::PaymentLinkStatus;let (merchant_id, payment_id) = path.into_inner();diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rsindex 17a3a21d0e..05d56c8248 100644--- a/crates/router/src/routes/payment_methods.rs+++ b/crates/router/src/routes/payment_methods.rs@@ -95,7 +95,7 @@ pub async fn migrate_payment_method_api(async fn get_merchant_account(state: &SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<(MerchantKeyStore, domain::MerchantAccount), errors::ApiErrorResponse> {let key_manager_state = &state.into();let key_store = state@@ -131,33 +131,36 @@ pub async fn migrate_payment_methods(Ok((merchant_id, records)) => (merchant_id, records),Err(e) => return api::log_and_return_error_response(e.into()),};- let merchant_id = merchant_id.as_str();Box::pin(api::server_wrap(flow,state,&req,records,- |state, _, req, _| async move {- let (key_store, merchant_account) = get_merchant_account(&state, merchant_id).await?;- // Create customers if they are not already present- customers::migrate_customers(- state.clone(),- req.iter()- .map(|e| CustomerRequest::from(e.clone()))- .collect(),- merchant_account.clone(),- key_store.clone(),- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)?;- Box::pin(migration::migrate_payment_methods(- state,- req,- merchant_id,- &merchant_account,- &key_store,- ))- .await+ |state, _, req, _| {+ let merchant_id = merchant_id.clone();+ async move {+ let (key_store, merchant_account) =+ get_merchant_account(&state, &merchant_id).await?;+ // Create customers if they are not already present+ customers::migrate_customers(+ state.clone(),+ req.iter()+ .map(|e| CustomerRequest::from(e.clone()))+ .collect(),+ merchant_account.clone(),+ key_store.clone(),+ )+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)?;+ Box::pin(migration::migrate_payment_methods(+ state,+ req,+ &merchant_id,+ &merchant_account,+ &key_store,+ ))+ .await+ }},&auth::AdminApiAuth,api_locking::LockAction::NotApplicable,@@ -376,7 +379,7 @@ pub async fn initiate_pm_collect_link_flow(pub async fn render_pm_collect_link(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(id_type::MerchantId, String)>,) -> HttpResponse {let flow = Flow::PaymentMethodCollectLink;let (merchant_id, pm_collect_link_id) = path.into_inner();@@ -546,7 +549,7 @@ pub async fn default_payment_method_set_api(|state, auth: auth::AuthenticationData, default_payment_method, _| async move {cards::set_default_payment_method(&state,- auth.merchant_account.merchant_id,+ auth.merchant_account.get_id(),auth.key_store,customer_id,default_payment_method.payment_method_id,diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rsindex 008528ee2e..2bac740d37 100644--- a/crates/router/src/routes/payments.rs+++ b/crates/router/src/routes/payments.rs@@ -170,7 +170,7 @@ pub async fn payments_create(pub async fn payments_start(state: web::Data<app::AppState>,req: actix_web::HttpRequest,- path: web::Path<(String, String, String)>,+ path: web::Path<(String, common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::PaymentsStart;let (payment_id, merchant_id, attempt_id) = path.into_inner();@@ -661,7 +661,7 @@ pub async fn payments_redirect_response(state: web::Data<app::AppState>,req: actix_web::HttpRequest,json_payload: Option<web::Form<serde_json::Value>>,- path: web::Path<(String, String, String)>,+ path: web::Path<(String, common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::PaymentsRedirect;let (payment_id, merchant_id, connector) = path.into_inner();@@ -723,7 +723,7 @@ pub async fn payments_redirect_response(pub async fn payments_redirect_response_with_creds_identifier(state: web::Data<app::AppState>,req: actix_web::HttpRequest,- path: web::Path<(String, String, String, String)>,+ path: web::Path<(String, common_utils::id_type::MerchantId, String, String)>,) -> impl Responder {let (payment_id, merchant_id, connector, creds_identifier) = path.into_inner();let param_string = req.query_string();@@ -767,7 +767,7 @@ pub async fn payments_complete_authorize_redirect(state: web::Data<app::AppState>,req: actix_web::HttpRequest,json_payload: Option<web::Form<serde_json::Value>>,- path: web::Path<(String, String, String)>,+ path: web::Path<(String, common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::PaymentsRedirect;let (payment_id, merchant_id, connector) = path.into_inner();@@ -1365,7 +1365,7 @@ pub async fn post_3ds_payments_authorize(state: web::Data<app::AppState>,req: actix_web::HttpRequest,json_payload: Option<web::Form<serde_json::Value>>,- path: web::Path<(String, String, String)>,+ path: web::Path<(String, common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::PaymentsAuthorize;@@ -1450,7 +1450,11 @@ pub async fn retrieve_extended_card_info(&req,payment_id,|state, auth, payment_id, _| {- payments::get_extended_card_info(state, auth.merchant_account.merchant_id, payment_id)+ payments::get_extended_card_info(+ state,+ auth.merchant_account.get_id().to_owned(),+ payment_id,+ )},&auth::ApiKeyAuth,api_locking::LockAction::NotApplicable,diff --git a/crates/router/src/routes/payout_link.rs b/crates/router/src/routes/payout_link.rsindex e3a0327c32..7bac4c5519 100644--- a/crates/router/src/routes/payout_link.rs+++ b/crates/router/src/routes/payout_link.rs@@ -15,7 +15,7 @@ use crate::{pub async fn render_payout_link(state: web::Data<AppState>,req: actix_web::HttpRequest,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::PayoutLinkInitiate;let (merchant_id, payout_id) = path.into_inner();diff --git a/crates/router/src/routes/recon.rs b/crates/router/src/routes/recon.rsindex d8100e8d34..be489a8ea0 100644--- a/crates/router/src/routes/recon.rs+++ b/crates/router/src/routes/recon.rs@@ -89,13 +89,13 @@ pub async fn send_recon_request(let key_store = db.get_merchant_key_store_by_merchant_id(key_manager_state,- merchant_id.as_str(),+ &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.as_str(), &key_store)+ .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store).await.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;diff --git a/crates/router/src/routes/verification.rs b/crates/router/src/routes/verification.rsindex 0066266311..25e64e95bd 100644--- a/crates/router/src/routes/verification.rs+++ b/crates/router/src/routes/verification.rs@@ -13,7 +13,7 @@ pub async fn apple_pay_merchant_registration(state: web::Data<AppState>,req: HttpRequest,json_payload: web::Json<verifications::ApplepayMerchantVerificationRequest>,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::MerchantId>,) -> impl Responder {let flow = Flow::Verification;let merchant_id = path.into_inner();@@ -57,7 +57,7 @@ pub async fn retrieve_apple_pay_verified_domains(|state, _, _, _| {verification::get_verified_apple_domains_with_mid_mca_id(state,- merchant_id.to_string(),+ merchant_id.to_owned(),mca_id.to_string(),)},diff --git a/crates/router/src/routes/webhooks.rs b/crates/router/src/routes/webhooks.rsindex a198fe730f..43b50b0460 100644--- a/crates/router/src/routes/webhooks.rs+++ b/crates/router/src/routes/webhooks.rs@@ -15,7 +15,7 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(state: web::Data<AppState>,req: HttpRequest,body: web::Bytes,- path: web::Path<(String, String)>,+ path: web::Path<(common_utils::id_type::MerchantId, String)>,) -> impl Responder {let flow = Flow::IncomingWebhookReceive;let (merchant_id, connector_id_or_name) = path.into_inner();diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rsindex ea9ce17743..129be81e41 100644--- a/crates/router/src/services/api.rs+++ b/crates/router/src/services/api.rs@@ -849,14 +849,12 @@ wherelet merchant_id = auth_type.get_merchant_id()- .unwrap_or("MERCHANT_ID_NOT_FOUND")- .to_string();-- app_state.add_merchant_id(Some(merchant_id.clone()));+ .cloned()+ .unwrap_or(common_utils::id_type::MerchantId::get_merchant_id_not_found());app_state.add_flow_name(flow.to_string());- tracing::Span::current().record("merchant_id", &merchant_id);+ tracing::Span::current().record("merchant_id", merchant_id.get_string_repr().to_owned());let output = {lock_action@@ -938,7 +936,7 @@ wheremetrics::request::status_code_metrics(status_code.to_string(),flow.to_string(),- merchant_id.to_string(),+ merchant_id.to_owned(),);outputdiff --git a/crates/router/src/services/api/client.rs b/crates/router/src/services/api/client.rsindex 4dda8eab62..56bb00b246 100644--- a/crates/router/src/services/api/client.rs+++ b/crates/router/src/services/api/client.rs@@ -184,7 +184,6 @@ wherefn add_request_id(&mut self, request_id: RequestId);fn get_request_id(&self) -> Option<String>;- fn add_merchant_id(&mut self, _merchant_id: Option<String>);fn add_flow_name(&mut self, flow_name: String);}@@ -368,8 +367,6 @@ impl ApiClient for ProxyClient {self.request_id.clone()}- fn add_merchant_id(&mut self, _merchant_id: Option<String>) {}-fn add_flow_name(&mut self, _flow_name: String) {}}@@ -421,7 +418,5 @@ impl ApiClient for MockApiClient {None}- fn add_merchant_id(&mut self, _merchant_id: Option<String>) {}-fn add_flow_name(&mut self, _flow_name: String) {}}diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rsindex 001eb3d168..0ee09913e2 100644--- a/crates/router/src/services/authentication.rs+++ b/crates/router/src/services/authentication.rs@@ -56,12 +56,12 @@ pub struct AuthenticationData {)]pub enum AuthenticationType {ApiKey {- merchant_id: String,+ merchant_id: id_type::MerchantId,key_id: String,},AdminApiKey,MerchantJwt {- merchant_id: String,+ merchant_id: id_type::MerchantId,user_id: Option<String>,},UserJwt {@@ -77,13 +77,13 @@ pub enum AuthenticationType {role_id: Option<String>,},MerchantId {- merchant_id: String,+ merchant_id: id_type::MerchantId,},PublishableKey {- merchant_id: String,+ merchant_id: id_type::MerchantId,},WebhookAuth {- merchant_id: String,+ merchant_id: id_type::MerchantId,},NoAuth,}@@ -100,7 +100,7 @@ impl events::EventInfo for AuthenticationType {}impl AuthenticationType {- pub fn get_merchant_id(&self) -> Option<&str> {+ pub fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {match self {Self::ApiKey {merchant_id,@@ -112,7 +112,7 @@ impl AuthenticationType {merchant_id,user_id: _,}- | Self::WebhookAuth { merchant_id } => Some(merchant_id.as_ref()),+ | Self::WebhookAuth { merchant_id } => Some(merchant_id),Self::AdminApiKey| Self::UserJwt { .. }| Self::SinglePurposeJwt { .. }@@ -166,7 +166,7 @@ impl SinglePurposeToken {#[derive(serde::Serialize, serde::Deserialize)]pub struct AuthToken {pub user_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub role_id: String,pub exp: u64,pub org_id: id_type::OrganizationId,@@ -176,7 +176,7 @@ pub struct AuthToken {impl AuthToken {pub async fn new_token(user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,role_id: String,settings: &Settings,org_id: id_type::OrganizationId,@@ -197,7 +197,7 @@ impl AuthToken {#[derive(Clone)]pub struct UserFromToken {pub user_id: String,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub role_id: String,pub org_id: id_type::OrganizationId,}@@ -216,18 +216,18 @@ pub struct SinglePurposeOrLoginToken {}pub trait AuthInfo {- fn get_merchant_id(&self) -> Option<&str>;+ fn get_merchant_id(&self) -> Option<&id_type::MerchantId>;}impl AuthInfo for () {- fn get_merchant_id(&self) -> Option<&str> {+ fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {None}}impl AuthInfo for AuthenticationData {- fn get_merchant_id(&self) -> Option<&str> {- Some(&self.merchant_account.merchant_id)+ fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {+ Some(self.merchant_account.get_id())}}@@ -349,7 +349,7 @@ whereOk((auth.clone(),AuthenticationType::ApiKey {- merchant_id: auth.merchant_account.merchant_id.clone(),+ merchant_id: auth.merchant_account.get_id().clone(),key_id: stored_api_key.key_id,},))@@ -529,7 +529,7 @@ where}}#[derive(Debug)]-pub struct MerchantIdAuth(pub String);+pub struct MerchantIdAuth(pub id_type::MerchantId);#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for MerchantIdAuth@@ -546,7 +546,7 @@ where.store().get_merchant_key_store_by_merchant_id(key_manager_state,- self.0.as_ref(),+ &self.0,&state.store().get_master_key().to_vec().into(),).await@@ -561,7 +561,7 @@ wherelet merchant = state.store()- .find_merchant_account_by_merchant_id(key_manager_state, self.0.as_ref(), &key_store)+ .find_merchant_account_by_merchant_id(key_manager_state, &self.0, &key_store).await.map_err(|e| {if e.current_context().is_db_not_found() {@@ -578,7 +578,7 @@ whereOk((auth.clone(),AuthenticationType::MerchantId {- merchant_id: auth.merchant_account.merchant_id.clone(),+ merchant_id: auth.merchant_account.get_id().clone(),},))}@@ -615,7 +615,7 @@ where(auth.clone(),AuthenticationType::PublishableKey {- merchant_id: auth.merchant_account.merchant_id.clone(),+ merchant_id: auth.merchant_account.get_id().clone(),},)})@@ -694,7 +694,7 @@ where}pub struct JWTAuthMerchantFromRoute {- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub required_permission: Permission,}@@ -754,7 +754,7 @@ whereauthorization::check_authorization(&self.required_permission, &permissions)?;// Check if token has access to MerchantId that has been requested through path or query param- if payload.merchant_id == self.merchant_id_or_profile_id {+ if payload.merchant_id.get_string_repr() == self.merchant_id_or_profile_id {return Ok(((),AuthenticationType::MerchantJwt {@@ -856,7 +856,7 @@ whereOk((auth.clone(),AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.merchant_id.clone(),+ merchant_id: auth.merchant_account.get_id().clone(),user_id: None,},))@@ -911,7 +911,7 @@ whereOk(((auth.clone(), payload.user_id.clone()),AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.merchant_id.clone(),+ merchant_id: auth.merchant_account.get_id().clone(),user_id: None,},))@@ -1011,7 +1011,7 @@ whereOk((auth.clone(),AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.merchant_id.clone(),+ merchant_id: auth.merchant_account.get_id().clone(),user_id: Some(payload.user_id),},))@@ -1281,7 +1281,7 @@ pub struct ReconUser {}#[cfg(feature = "recon")]impl AuthInfo for ReconUser {- fn get_merchant_id(&self) -> Option<&str> {+ fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {None}}diff --git a/crates/router/src/services/authentication/decision.rs b/crates/router/src/services/authentication/decision.rsindex 2a48a8c318..d665b0caaf 100644--- a/crates/router/src/services/authentication/decision.rs+++ b/crates/router/src/services/authentication/decision.rs@@ -65,7 +65,10 @@ pub enum AuthRuleType {#[serde(tag = "type", rename_all = "snake_case")]pub enum Identifiers {/// [`ApiKey`] is an authentication method that uses an API key. This is used with [`ApiKey`]- ApiKey { merchant_id: String, key_id: String },+ ApiKey {+ merchant_id: common_utils::id_type::MerchantId,+ key_id: String,+ },/// [`PublishableKey`] is an authentication method that uses a publishable key. This is used with [`PublishableKey`]PublishableKey { merchant_id: String },}@@ -76,7 +79,7 @@ pub enum Identifiers {pub async fn add_api_key(state: &SessionState,api_key: Secret<String>,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,key_id: String,expiry: Option<u64>,) -> CustomResult<(), ApiClientError> {@@ -104,7 +107,7 @@ pub async fn add_api_key(pub async fn add_publishable_key(state: &SessionState,api_key: Secret<String>,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,expiry: Option<u64>,) -> CustomResult<(), ApiClientError> {let decision_config = if let Some(config) = &state.conf.decision {@@ -118,7 +121,9 @@ pub async fn add_publishable_key(expiry,variant: AuthRuleType::ApiKey {api_key,- identifiers: Identifiers::PublishableKey { merchant_id },+ identifiers: Identifiers::PublishableKey {+ merchant_id: merchant_id.get_string_repr().to_owned(),+ },},};diff --git a/crates/router/src/services/authorization.rs b/crates/router/src/services/authorization.rsindex 2fb809d482..ea1264bde0 100644--- a/crates/router/src/services/authorization.rs+++ b/crates/router/src/services/authorization.rs@@ -79,7 +79,7 @@ fn get_permissions_from_predefined_roles(role_id: &str) -> Option<Vec<permissionasync fn get_permissions_from_db<A>(state: &A,role_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> RouterResult<Vec<permissions::Permission>>wherediff --git a/crates/router/src/services/authorization/roles.rs b/crates/router/src/services/authorization/roles.rsindex 5ffd99a2d0..cda2371282 100644--- a/crates/router/src/services/authorization/roles.rs+++ b/crates/router/src/services/authorization/roles.rs@@ -69,7 +69,7 @@ impl RoleInfo {pub async fn from_role_id(state: &SessionState,role_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> CustomResult<Self, errors::StorageError> {if let Some(role) = predefined_roles::PREDEFINED_ROLES.get(role_id) {diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rsindex 8af9d0b58c..d2376feb74 100644--- a/crates/router/src/services/connector_integration_interface.rs+++ b/crates/router/src/services/connector_integration_interface.rs@@ -113,7 +113,7 @@ impl api::IncomingWebhook for ConnectorEnum {async fn decode_webhook_body(&self,request: &IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,connector_name: &str,) -> CustomResult<Vec<u8>, errors::ConnectorError> {@@ -153,7 +153,7 @@ impl api::IncomingWebhook for ConnectorEnum {async fn get_webhook_source_verification_merchant_secret(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: &str,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,) -> CustomResult<api_models::webhooks::ConnectorWebhookSecrets, errors::ConnectorError> {@@ -195,7 +195,7 @@ impl api::IncomingWebhook for ConnectorEnum {fn get_webhook_source_verification_message(&self,request: &IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,) -> CustomResult<Vec<u8>, errors::ConnectorError> {match self {@@ -215,7 +215,7 @@ impl api::IncomingWebhook for ConnectorEnum {async fn verify_webhook_source(&self,request: &IncomingWebhookRequestDetails<'_>,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,connector_account_details: crypto::Encryptable<masking::Secret<serde_json::Value>>,connector_name: &str,diff --git a/crates/router/src/services/conversion_impls.rs b/crates/router/src/services/conversion_impls.rsindex 741dabe7fa..e5d39bab83 100644--- a/crates/router/src/services/conversion_impls.rs+++ b/crates/router/src/services/conversion_impls.rs@@ -27,7 +27,7 @@ fn get_default_router_data<F, Req, Resp>() -> RouterData<F, Req, Resp> {RouterData {flow: std::marker::PhantomData,- merchant_id: get_irrelevant_id_string("merchant_id", flow_name),+ merchant_id: common_utils::id_type::MerchantId::get_irrelevant_merchant_id(),customer_id: None,connector_customer: None,connector: get_irrelevant_id_string("connector", flow_name),diff --git a/crates/router/src/services/email/types.rs b/crates/router/src/services/email/types.rsindex 1d4e77ff68..56505316a6 100644--- a/crates/router/src/services/email/types.rs+++ b/crates/router/src/services/email/types.rs@@ -47,7 +47,7 @@ pub enum EmailBody {},ProFeatureRequest {feature_name: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,user_name: String,user_email: String,},@@ -150,7 +150,7 @@ Email : {user_email}#[derive(serde::Serialize, serde::Deserialize)]pub struct EmailToken {email: String,- merchant_id: Option<String>,+ merchant_id: Option<common_utils::id_type::MerchantId>,flow: domain::Origin,exp: u64,}@@ -158,7 +158,7 @@ pub struct EmailToken {impl EmailToken {pub async fn new_token(email: domain::UserEmail,- merchant_id: Option<String>,+ merchant_id: Option<common_utils::id_type::MerchantId>,flow: domain::Origin,settings: &configs::Settings,) -> CustomResult<String, UserErrors> {@@ -177,8 +177,8 @@ impl EmailToken {pii::Email::try_from(self.email.clone())}- pub fn get_merchant_id(&self) -> Option<&str> {- self.merchant_id.as_deref()+ pub fn get_merchant_id(&self) -> Option<&common_utils::id_type::MerchantId> {+ self.merchant_id.as_ref()}pub fn get_flow(&self) -> domain::Origin {@@ -325,7 +325,7 @@ pub struct InviteUser {pub user_name: domain::UserName,pub settings: std::sync::Arc<configs::Settings>,pub subject: &'static str,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub auth_id: Option<String>,}@@ -366,7 +366,7 @@ pub struct InviteRegisteredUser {pub user_name: domain::UserName,pub settings: std::sync::Arc<configs::Settings>,pub subject: &'static str,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub auth_id: Option<String>,}@@ -476,7 +476,7 @@ impl EmailData for BizEmailProd {pub struct ProFeatureRequest {pub recipient_email: domain::UserEmail,pub feature_name: String,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub user_name: domain::UserName,pub settings: std::sync::Arc<configs::Settings>,pub subject: String,diff --git a/crates/router/src/services/kafka/authentication.rs b/crates/router/src/services/kafka/authentication.rsindex dce648aff6..be3e093334 100644--- a/crates/router/src/services/kafka/authentication.rs+++ b/crates/router/src/services/kafka/authentication.rs@@ -4,7 +4,7 @@ use time::OffsetDateTime;#[derive(serde::Serialize, Debug)]pub struct KafkaAuthentication<'a> {pub authentication_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub authentication_connector: &'a String,pub connector_authentication_id: Option<&'a String>,pub authentication_data: Option<serde_json::Value>,@@ -88,7 +88,11 @@ impl<'a> KafkaAuthentication<'a> {impl<'a> super::KafkaMessage for KafkaAuthentication<'a> {fn key(&self) -> String {- format!("{}_{}", self.merchant_id, self.authentication_id)+ format!(+ "{}_{}",+ self.merchant_id.get_string_repr(),+ self.authentication_id+ )}fn event_type(&self) -> crate::events::EventType {diff --git a/crates/router/src/services/kafka/authentication_event.rs b/crates/router/src/services/kafka/authentication_event.rsindex 6dbebe6ca7..3f10c7596a 100644--- a/crates/router/src/services/kafka/authentication_event.rs+++ b/crates/router/src/services/kafka/authentication_event.rs@@ -5,7 +5,7 @@ use time::OffsetDateTime;#[derive(serde::Serialize, Debug)]pub struct KafkaAuthenticationEvent<'a> {pub authentication_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub authentication_connector: &'a String,pub connector_authentication_id: Option<&'a String>,pub authentication_data: Option<serde_json::Value>,@@ -89,7 +89,11 @@ impl<'a> KafkaAuthenticationEvent<'a> {impl<'a> super::KafkaMessage for KafkaAuthenticationEvent<'a> {fn key(&self) -> String {- format!("{}_{}", self.merchant_id, self.authentication_id)+ format!(+ "{}_{}",+ self.merchant_id.get_string_repr(),+ self.authentication_id+ )}fn event_type(&self) -> crate::events::EventType {diff --git a/crates/router/src/services/kafka/dispute.rs b/crates/router/src/services/kafka/dispute.rsindex 1950fb253a..b4b493a79d 100644--- a/crates/router/src/services/kafka/dispute.rs+++ b/crates/router/src/services/kafka/dispute.rs@@ -13,7 +13,7 @@ pub struct KafkaDispute<'a> {pub dispute_status: &'a storage_enums::DisputeStatus,pub payment_id: &'a String,pub attempt_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub connector_status: &'a String,pub connector_dispute_id: &'a String,pub connector_reason: Option<&'a String>,@@ -66,7 +66,9 @@ impl<'a> super::KafkaMessage for KafkaDispute<'a> {fn key(&self) -> String {format!("{}_{}_{}",- self.merchant_id, self.payment_id, self.dispute_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.dispute_id)}diff --git a/crates/router/src/services/kafka/dispute_event.rs b/crates/router/src/services/kafka/dispute_event.rsindex 71e0a11e04..d6cb5d5849 100644--- a/crates/router/src/services/kafka/dispute_event.rs+++ b/crates/router/src/services/kafka/dispute_event.rs@@ -14,7 +14,7 @@ pub struct KafkaDisputeEvent<'a> {pub dispute_status: &'a storage_enums::DisputeStatus,pub payment_id: &'a String,pub attempt_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub connector_status: &'a String,pub connector_dispute_id: &'a String,pub connector_reason: Option<&'a String>,@@ -67,7 +67,9 @@ impl<'a> super::KafkaMessage for KafkaDisputeEvent<'a> {fn key(&self) -> String {format!("{}_{}_{}",- self.merchant_id, self.payment_id, self.dispute_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.dispute_id)}diff --git a/crates/router/src/services/kafka/fraud_check.rs b/crates/router/src/services/kafka/fraud_check.rsindex e52fbbbc9a..cf67ac14dd 100644--- a/crates/router/src/services/kafka/fraud_check.rs+++ b/crates/router/src/services/kafka/fraud_check.rs@@ -10,7 +10,7 @@ use time::OffsetDateTime;pub struct KafkaFraudCheck<'a> {pub frm_id: &'a String,pub payment_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub attempt_id: &'a String,#[serde(with = "time::serde::timestamp")]pub created_at: OffsetDateTime,@@ -57,7 +57,10 @@ impl<'a> super::KafkaMessage for KafkaFraudCheck<'a> {fn key(&self) -> String {format!("{}_{}_{}_{}",- self.merchant_id, self.payment_id, self.attempt_id, self.frm_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.attempt_id,+ self.frm_id)}diff --git a/crates/router/src/services/kafka/fraud_check_event.rs b/crates/router/src/services/kafka/fraud_check_event.rsindex 57dc4d2087..88d1465ce1 100644--- a/crates/router/src/services/kafka/fraud_check_event.rs+++ b/crates/router/src/services/kafka/fraud_check_event.rs@@ -9,7 +9,7 @@ use time::OffsetDateTime;pub struct KafkaFraudCheckEvent<'a> {pub frm_id: &'a String,pub payment_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub attempt_id: &'a String,#[serde(default, with = "time::serde::timestamp::milliseconds")]pub created_at: OffsetDateTime,@@ -56,7 +56,10 @@ impl<'a> super::KafkaMessage for KafkaFraudCheckEvent<'a> {fn key(&self) -> String {format!("{}_{}_{}_{}",- self.merchant_id, self.payment_id, self.attempt_id, self.frm_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.attempt_id,+ self.frm_id)}diff --git a/crates/router/src/services/kafka/payment_attempt.rs b/crates/router/src/services/kafka/payment_attempt.rsindex c321093776..df566ad8a8 100644--- a/crates/router/src/services/kafka/payment_attempt.rs+++ b/crates/router/src/services/kafka/payment_attempt.rs@@ -9,7 +9,7 @@ use time::OffsetDateTime;#[derive(serde::Serialize, Debug)]pub struct KafkaPaymentAttempt<'a> {pub payment_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub attempt_id: &'a String,pub status: storage_enums::AttemptStatus,pub amount: MinorUnit,@@ -108,7 +108,9 @@ impl<'a> super::KafkaMessage for KafkaPaymentAttempt<'a> {fn key(&self) -> String {format!("{}_{}_{}",- self.merchant_id, self.payment_id, self.attempt_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.attempt_id)}diff --git a/crates/router/src/services/kafka/payment_attempt_event.rs b/crates/router/src/services/kafka/payment_attempt_event.rsindex bb4d69eda2..95c5d9edd5 100644--- a/crates/router/src/services/kafka/payment_attempt_event.rs+++ b/crates/router/src/services/kafka/payment_attempt_event.rs@@ -10,7 +10,7 @@ use time::OffsetDateTime;#[derive(serde::Serialize, Debug)]pub struct KafkaPaymentAttemptEvent<'a> {pub payment_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub attempt_id: &'a String,pub status: storage_enums::AttemptStatus,pub amount: MinorUnit,@@ -109,7 +109,9 @@ impl<'a> super::KafkaMessage for KafkaPaymentAttemptEvent<'a> {fn key(&self) -> String {format!("{}_{}_{}",- self.merchant_id, self.payment_id, self.attempt_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.attempt_id)}diff --git a/crates/router/src/services/kafka/payment_intent.rs b/crates/router/src/services/kafka/payment_intent.rsindex 7d9896692a..d1bd5b2a54 100644--- a/crates/router/src/services/kafka/payment_intent.rs+++ b/crates/router/src/services/kafka/payment_intent.rs@@ -8,7 +8,7 @@ use time::OffsetDateTime;#[derive(serde::Serialize, Debug)]pub struct KafkaPaymentIntent<'a> {pub payment_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a id_type::MerchantId,pub status: storage_enums::IntentStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,@@ -86,7 +86,7 @@ impl<'a> KafkaPaymentIntent<'a> {impl<'a> super::KafkaMessage for KafkaPaymentIntent<'a> {fn key(&self) -> String {- format!("{}_{}", self.merchant_id, self.payment_id)+ format!("{}_{}", self.merchant_id.get_string_repr(), self.payment_id)}fn event_type(&self) -> crate::events::EventType {diff --git a/crates/router/src/services/kafka/payment_intent_event.rs b/crates/router/src/services/kafka/payment_intent_event.rsindex b11b6b2211..cce53cbd59 100644--- a/crates/router/src/services/kafka/payment_intent_event.rs+++ b/crates/router/src/services/kafka/payment_intent_event.rs@@ -9,7 +9,7 @@ use time::OffsetDateTime;#[derive(serde::Serialize, Debug)]pub struct KafkaPaymentIntentEvent<'a> {pub payment_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a id_type::MerchantId,pub status: storage_enums::IntentStatus,pub amount: MinorUnit,pub currency: Option<storage_enums::Currency>,@@ -87,7 +87,7 @@ impl<'a> KafkaPaymentIntentEvent<'a> {impl<'a> super::KafkaMessage for KafkaPaymentIntentEvent<'a> {fn key(&self) -> String {- format!("{}_{}", self.merchant_id, self.payment_id)+ format!("{}_{}", self.merchant_id.get_string_repr(), self.payment_id)}fn event_type(&self) -> crate::events::EventType {diff --git a/crates/router/src/services/kafka/payout.rs b/crates/router/src/services/kafka/payout.rsindex 8796d2ca90..655639ed91 100644--- a/crates/router/src/services/kafka/payout.rs+++ b/crates/router/src/services/kafka/payout.rs@@ -7,7 +7,7 @@ use time::OffsetDateTime;pub struct KafkaPayout<'a> {pub payout_id: &'a String,pub payout_attempt_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a id_type::MerchantId,pub customer_id: &'a id_type::CustomerId,pub address_id: &'a String,pub profile_id: &'a String,@@ -79,7 +79,11 @@ impl<'a> KafkaPayout<'a> {impl<'a> super::KafkaMessage for KafkaPayout<'a> {fn key(&self) -> String {- format!("{}_{}", self.merchant_id, self.payout_attempt_id)+ format!(+ "{}_{}",+ self.merchant_id.get_string_repr(),+ self.payout_attempt_id+ )}fn event_type(&self) -> crate::events::EventType {diff --git a/crates/router/src/services/kafka/refund.rs b/crates/router/src/services/kafka/refund.rsindex 14b317b52e..1aaf5d2ccb 100644--- a/crates/router/src/services/kafka/refund.rs+++ b/crates/router/src/services/kafka/refund.rs@@ -7,7 +7,7 @@ pub struct KafkaRefund<'a> {pub internal_reference_id: &'a String,pub refund_id: &'a String, //merchant_reference idpub payment_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub connector_transaction_id: &'a String,pub connector: &'a String,pub connector_refund_id: Option<&'a String>,@@ -63,7 +63,10 @@ impl<'a> super::KafkaMessage for KafkaRefund<'a> {fn key(&self) -> String {format!("{}_{}_{}_{}",- self.merchant_id, self.payment_id, self.attempt_id, self.refund_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.attempt_id,+ self.refund_id)}diff --git a/crates/router/src/services/kafka/refund_event.rs b/crates/router/src/services/kafka/refund_event.rsindex fea0b8c45e..9480220104 100644--- a/crates/router/src/services/kafka/refund_event.rs+++ b/crates/router/src/services/kafka/refund_event.rs@@ -8,7 +8,7 @@ pub struct KafkaRefundEvent<'a> {pub internal_reference_id: &'a String,pub refund_id: &'a String, //merchant_reference idpub payment_id: &'a String,- pub merchant_id: &'a String,+ pub merchant_id: &'a common_utils::id_type::MerchantId,pub connector_transaction_id: &'a String,pub connector: &'a String,pub connector_refund_id: Option<&'a String>,@@ -64,7 +64,10 @@ impl<'a> super::KafkaMessage for KafkaRefundEvent<'a> {fn key(&self) -> String {format!("{}_{}_{}_{}",- self.merchant_id, self.payment_id, self.attempt_id, self.refund_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.attempt_id,+ self.refund_id)}diff --git a/crates/router/src/types.rs b/crates/router/src/types.rsindex c5e536de3a..641553642a 100644--- a/crates/router/src/types.rs+++ b/crates/router/src/types.rs@@ -602,7 +602,7 @@ pub struct AuthenticatePaymentFlowResponse {#[derive(Debug, Clone, Default, serde::Deserialize, serde::Serialize)]pub struct ConnectorResponse {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub connector: String,pub payment_id: String,pub amount: i64,diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rsindex 2228293320..26dcb056e9 100644--- a/crates/router/src/types/api/admin.rs+++ b/crates/router/src/types/api/admin.rs@@ -43,6 +43,7 @@ impl ForeignFrom<diesel_models::organization::Organization> for OrganizationRespimpl ForeignTryFrom<domain::MerchantAccount> for MerchantAccountResponse {type Error = error_stack::Report<errors::ParsingError>;fn foreign_try_from(item: domain::MerchantAccount) -> Result<Self, Self::Error> {+ let merchant_id = item.get_id().to_owned();let primary_business_details: Vec<api_models::admin::PrimaryBusinessDetails> = item.primary_business_details.parse_value("primary_business_details")?;@@ -53,7 +54,7 @@ impl ForeignTryFrom<domain::MerchantAccount> for MerchantAccountResponse {.transpose()?;Ok(Self {- merchant_id: item.merchant_id,+ merchant_id,merchant_name: item.merchant_name,return_url: item.return_url,enable_payment_response_hash: item.enable_payment_response_hash,@@ -183,6 +184,7 @@ pub async fn create_business_profile(> {// Generate a unique profile idlet profile_id = common_utils::generate_id_with_default_len("pro");+ let merchant_id = merchant_account.get_id().to_owned();let current_time = common_utils::date_time::now();@@ -238,7 +240,7 @@ pub async fn create_business_profile(Ok(storage::business_profile::BusinessProfileNew {profile_id,- merchant_id: merchant_account.merchant_id,+ merchant_id,profile_name: request.profile_name.unwrap_or("default".to_string()),created_at: current_time,modified_at: current_time,diff --git a/crates/router/src/types/api/connector_onboarding/paypal.rs b/crates/router/src/types/api/connector_onboarding/paypal.rsindex 22bab6968a..a1f3155cd4 100644--- a/crates/router/src/types/api/connector_onboarding/paypal.rs+++ b/crates/router/src/types/api/connector_onboarding/paypal.rs@@ -148,13 +148,13 @@ impl PartnerReferralRequest {#[derive(serde::Deserialize, Debug)]pub struct SellerStatusResponse {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub links: Vec<HateoasLink>,}#[derive(serde::Deserialize, Debug)]pub struct SellerStatusDetailsResponse {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub primary_email_confirmed: bool,pub payments_receivable: bool,pub products: Vec<SellerStatusProducts>,@@ -227,8 +227,8 @@ impl SellerStatusDetailsResponse {.and_then(|ppcp_custom| ppcp_custom.vetting_status.clone())}- fn get_payer_id(&self) -> String {- self.merchant_id.to_string()+ fn get_payer_id(&self) -> common_utils::id_type::MerchantId {+ self.merchant_id.to_owned()}}diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rsindex 859f02d8fc..e54ee8706f 100644--- a/crates/router/src/types/api/verify_connector.rs+++ b/crates/router/src/types/api/verify_connector.rs@@ -79,7 +79,7 @@ impl VerifyConnectorData {attempt_id: attempt_id.clone(),description: None,customer_id: None,- merchant_id: consts::VERIFY_CONNECTOR_MERCHANT_ID.to_string(),+ merchant_id: common_utils::id_type::MerchantId::default(),reference_id: None,access_token,session_token: None,diff --git a/crates/router/src/types/domain/address.rs b/crates/router/src/types/domain/address.rsindex e14ab8ea64..c7604622f3 100644--- a/crates/router/src/types/domain/address.rs+++ b/crates/router/src/types/domain/address.rs@@ -37,7 +37,7 @@ pub struct Address {#[serde(skip_serializing)]#[serde(with = "custom_serde::iso8601")]pub modified_at: PrimitiveDateTime,- pub merchant_id: String,+ pub merchant_id: id_type::MerchantId,pub updated_by: String,pub email: crypto::OptionalEncryptableEmail,}@@ -77,7 +77,7 @@ impl behaviour::Conversion for CustomerAddress {state: &KeyManagerState,other: Self::DstType,key: &Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: Identifier,) -> CustomResult<Self, ValidationError> {let customer_id =other@@ -87,7 +87,7 @@ impl behaviour::Conversion for CustomerAddress {field_name: "customer_id".to_string(),})?;- let address = Address::convert_back(state, other, key, key_store_ref_id).await?;+ let address = Address::convert_back(state, other, key, key_manager_identifier).await?;Ok(Self {address,@@ -123,7 +123,7 @@ impl behaviour::Conversion for PaymentAddress {state: &KeyManagerState,other: Self::DstType,key: &Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: Identifier,) -> CustomResult<Self, ValidationError> {let payment_id = other.payment_id@@ -134,7 +134,7 @@ impl behaviour::Conversion for PaymentAddress {let customer_id = other.customer_id.clone();- let address = Address::convert_back(state, other, key, key_store_ref_id).await?;+ let address = Address::convert_back(state, other, key, key_manager_identifier).await?;Ok(Self {address,@@ -188,7 +188,7 @@ impl behaviour::Conversion for Address {state: &KeyManagerState,other: Self::DstType,key: &Secret<Vec<u8>>,- _key_store_ref_id: String,+ _key_manager_identifier: Identifier,) -> CustomResult<Self, ValidationError> {let identifier = Identifier::Merchant(other.merchant_id.clone());let decrypted: FxHashMap<String, Encryptable<Secret<String>>> = types::batch_decrypt(diff --git a/crates/router/src/types/domain/event.rs b/crates/router/src/types/domain/event.rsindex c5eca1ab5e..67183a2d3a 100644--- a/crates/router/src/types/domain/event.rs+++ b/crates/router/src/types/domain/event.rs@@ -1,6 +1,6 @@use common_utils::{crypto::OptionalEncryptableSecretString,- types::keymanager::{Identifier, KeyManagerState, ToEncryptable},+ types::keymanager::{KeyManagerState, ToEncryptable},};use diesel_models::{enums::{EventClass, EventObjectType, EventType, WebhookDeliveryAttempt},@@ -24,7 +24,7 @@ pub struct Event {pub primary_object_id: String,pub primary_object_type: EventObjectType,pub created_at: time::PrimitiveDateTime,- pub merchant_id: Option<String>,+ pub merchant_id: Option<common_utils::id_type::MerchantId>,pub business_profile_id: Option<String>,pub primary_object_created_at: Option<time::PrimitiveDateTime>,pub idempotent_event_id: Option<String>,@@ -87,7 +87,7 @@ impl super::behaviour::Conversion for Event {state: &KeyManagerState,item: Self::DstType,key: &Secret<Vec<u8>>,- key_store_ref_id: String,+ key_manager_identifier: common_utils::types::keymanager::Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized,@@ -98,7 +98,7 @@ impl super::behaviour::Conversion for Event {request: item.request.clone(),response: item.response.clone(),}),- Identifier::Merchant(key_store_ref_id.clone()),+ key_manager_identifier,key.peek(),).awaitdiff --git a/crates/router/src/types/domain/merchant_connector_account.rs b/crates/router/src/types/domain/merchant_connector_account.rsindex bd0bfe15e5..6b0436b6f2 100644--- a/crates/router/src/types/domain/merchant_connector_account.rs+++ b/crates/router/src/types/domain/merchant_connector_account.rs@@ -17,7 +17,7 @@ use super::{#[derive(Clone, Debug)]pub struct MerchantConnectorAccount {pub id: Option<i32>,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub connector_name: String,pub connector_account_details: Encryptable<Secret<serde_json::Value>>,pub test_mode: Option<bool>,@@ -45,7 +45,6 @@ pub struct MerchantConnectorAccount {#[derive(Debug)]pub enum MerchantConnectorAccountUpdate {Update {- merchant_id: Option<String>,connector_type: Option<enums::ConnectorType>,connector_name: Option<String>,connector_account_details: Option<Encryptable<Secret<serde_json::Value>>>,@@ -110,7 +109,7 @@ impl behaviour::Conversion for MerchantConnectorAccount {state: &KeyManagerState,other: Self::DstType,key: &Secret<Vec<u8>>,- _key_store_ref_id: String,+ _key_manager_identifier: Identifier,) -> CustomResult<Self, ValidationError> {let identifier = Identifier::Merchant(other.merchant_id.clone());Ok(Self {@@ -202,7 +201,6 @@ impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateIntefn from(merchant_connector_account_update: MerchantConnectorAccountUpdate) -> Self {match merchant_connector_account_update {MerchantConnectorAccountUpdate::Update {- merchant_id,connector_type,connector_name,connector_account_details,@@ -219,7 +217,6 @@ impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateIntestatus,connector_wallets_details,} => Self {- merchant_id,connector_type,connector_name,connector_account_details: connector_account_details.map(Encryption::from),@@ -242,7 +239,6 @@ impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInteconnector_wallets_details,} => Self {connector_wallets_details: Some(Encryption::from(connector_wallets_details)),- merchant_id: None,connector_type: None,connector_name: None,connector_account_details: None,diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rsindex e7813ec3d2..9c1c722b28 100644--- a/crates/router/src/types/domain/user.rs+++ b/crates/router/src/types/domain/user.rs@@ -338,9 +338,18 @@ impl MerchantId {}}+impl TryFrom<MerchantId> for id_type::MerchantId {+ type Error = error_stack::Report<UserErrors>;+ fn try_from(value: MerchantId) -> Result<Self, Self::Error> {+ Self::from(value.0.into())+ .change_context(UserErrors::MerchantIdParsingError)+ .attach_printable("Could not convert user merchant_id to merchant_id type")+ }+}+#[derive(Clone)]pub struct NewUserMerchant {- merchant_id: MerchantId,+ merchant_id: id_type::MerchantId,company_name: Option<UserCompanyName>,new_organization: NewUserOrganization,}@@ -359,8 +368,8 @@ impl NewUserMerchant {self.company_name.clone().map(UserCompanyName::get_secret)}- pub fn get_merchant_id(&self) -> String {- self.merchant_id.get_secret()+ pub fn get_merchant_id(&self) -> id_type::MerchantId {+ self.merchant_id.clone()}pub fn get_new_organization(&self) -> NewUserOrganization {@@ -372,14 +381,14 @@ impl NewUserMerchant {.store.get_merchant_key_store_by_merchant_id(&(&state).into(),- self.get_merchant_id().as_str(),+ &self.get_merchant_id(),&state.store.get_master_key().to_vec().into(),).await.is_ok(){return Err(UserErrors::MerchantAccountCreationError(format!(- "Merchant with {} already exists",+ "Merchant with {:?} already exists",self.get_merchant_id())).into());@@ -412,11 +421,7 @@ impl NewUserMerchant {))]fn create_merchant_account_request(&self) -> UserResult<admin_api::MerchantAccountCreate> {Ok(admin_api::MerchantAccountCreate {- merchant_id: id_type::MerchantId::from(self.get_merchant_id().into())- .change_context(UserErrors::MerchantIdParsingError)- .attach_printable(- "Unable to convert to MerchantId type because of constraint violations",- )?,+ merchant_id: self.get_merchant_id(),metadata: None,locker_id: None,return_url: None,@@ -464,10 +469,8 @@ impl TryFrom<user_api::SignUpRequest> for NewUserMerchant {type Error = error_stack::Report<UserErrors>;fn try_from(value: user_api::SignUpRequest) -> UserResult<Self> {- let merchant_id = MerchantId::new(format!(- "merchant_{}",- common_utils::date_time::now_unix_timestamp()- ))?;+ let merchant_id = id_type::MerchantId::new_from_unix_timestamp();+let new_organization = NewUserOrganization::from(value);Ok(Self {@@ -482,10 +485,7 @@ impl TryFrom<user_api::ConnectAccountRequest> for NewUserMerchant {type Error = error_stack::Report<UserErrors>;fn try_from(value: user_api::ConnectAccountRequest) -> UserResult<Self> {- let merchant_id = MerchantId::new(format!(- "merchant_{}",- common_utils::date_time::now_unix_timestamp()- ))?;+ let merchant_id = id_type::MerchantId::new_from_unix_timestamp();let new_organization = NewUserOrganization::from(value);Ok(Self {@@ -505,7 +505,7 @@ impl TryFrom<user_api::SignUpWithMerchantIdRequest> for NewUserMerchant {Ok(Self {company_name,- merchant_id,+ merchant_id: id_type::MerchantId::try_from(merchant_id)?,new_organization,})}@@ -517,8 +517,9 @@ impl TryFrom<(user_api::CreateInternalUserRequest, id_type::OrganizationId)> forfn try_from(value: (user_api::CreateInternalUserRequest, id_type::OrganizationId),) -> UserResult<Self> {- let merchant_id =- MerchantId::new(consts::user_role::INTERNAL_USER_MERCHANT_ID.to_string())?;+ let merchant_id = id_type::MerchantId::get_internal_user_merchant_id(+ consts::user_role::INTERNAL_USER_MERCHANT_ID,+ );let new_organization = NewUserOrganization::from(value);Ok(Self {@@ -532,7 +533,7 @@ impl TryFrom<(user_api::CreateInternalUserRequest, id_type::OrganizationId)> forimpl TryFrom<InviteeUserRequestWithInvitedUserToken> for NewUserMerchant {type Error = error_stack::Report<UserErrors>;fn try_from(value: InviteeUserRequestWithInvitedUserToken) -> UserResult<Self> {- let merchant_id = MerchantId::new(value.clone().1.merchant_id)?;+ let merchant_id = value.clone().1.merchant_id;let new_organization = NewUserOrganization::from(value);Ok(Self {company_name: None,@@ -550,12 +551,9 @@ impl TryFrom<UserMerchantCreateRequestWithToken> for NewUserMerchant {fn try_from(value: UserMerchantCreateRequestWithToken) -> UserResult<Self> {let merchant_id = if matches!(env::which(), env::Env::Production) {- MerchantId::new(value.1.company_name.clone())?+ id_type::MerchantId::try_from(MerchantId::new(value.1.company_name.clone())?)?} else {- MerchantId::new(format!(- "merchant_{}",- common_utils::date_time::now_unix_timestamp()- ))?+ id_type::MerchantId::new_from_unix_timestamp()};Ok(Self {merchant_id,@@ -918,14 +916,14 @@ impl UserFromStorage {Ok(days_left_for_password_rotate.whole_days() < 0)}- pub fn get_preferred_merchant_id(&self) -> Option<String> {+ pub fn get_preferred_merchant_id(&self) -> Option<id_type::MerchantId> {self.0.preferred_merchant_id.clone()}pub async fn get_role_from_db_by_merchant_id(&self,state: &SessionState,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> CustomResult<UserRole, errors::StorageError> {state.storediff --git a/crates/router/src/types/domain/user_key_store.rs b/crates/router/src/types/domain/user_key_store.rsindex 40c8acd569..b0b57732cc 100644--- a/crates/router/src/types/domain/user_key_store.rs+++ b/crates/router/src/types/domain/user_key_store.rs@@ -34,7 +34,7 @@ impl super::behaviour::Conversion for UserKeyStore {state: &KeyManagerState,item: Self::DstType,key: &Secret<Vec<u8>>,- _key_store_ref_id: String,+ _key_manager_identifier: Identifier,) -> CustomResult<Self, ValidationError>whereSelf: Sized,diff --git a/crates/router/src/types/fraud_check.rs b/crates/router/src/types/fraud_check.rsindex da9e961031..4995cc59cd 100644--- a/crates/router/src/types/fraud_check.rs+++ b/crates/router/src/types/fraud_check.rs@@ -18,7 +18,7 @@ pub type FrmSaleType =#[derive(Debug, Clone)]pub struct FrmRouterData {- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,pub connector: String,pub payment_id: String,pub attempt_id: String,diff --git a/crates/router/src/types/storage/dispute.rs b/crates/router/src/types/storage/dispute.rsindex b76325acfc..2728b29bc0 100644--- a/crates/router/src/types/storage/dispute.rs+++ b/crates/router/src/types/storage/dispute.rs@@ -11,7 +11,7 @@ use crate::{connection::PgPooledConn, logger};pub trait DisputeDbExt: Sized {async fn filter_by_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_list_constraints: api_models::disputes::DisputeListConstraints,) -> CustomResult<Vec<Self>, errors::DatabaseError>;}@@ -20,7 +20,7 @@ pub trait DisputeDbExt: Sized {impl DisputeDbExt for Dispute {async fn filter_by_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,dispute_list_constraints: api_models::disputes::DisputeListConstraints,) -> CustomResult<Vec<Self>, errors::DatabaseError> {let mut filter = <Self as HasTable>::table()diff --git a/crates/router/src/types/storage/mandate.rs b/crates/router/src/types/storage/mandate.rsindex 648011ade3..c575e433e5 100644--- a/crates/router/src/types/storage/mandate.rs+++ b/crates/router/src/types/storage/mandate.rs@@ -13,7 +13,7 @@ use crate::{connection::PgPooledConn, logger};pub trait MandateDbExt: Sized {async fn filter_by_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,mandate_list_constraints: api_models::mandates::MandateListConstraints,) -> CustomResult<Vec<Self>, errors::DatabaseError>;}@@ -22,7 +22,7 @@ pub trait MandateDbExt: Sized {impl MandateDbExt for Mandate {async fn filter_by_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,mandate_list_constraints: api_models::mandates::MandateListConstraints,) -> CustomResult<Vec<Self>, errors::DatabaseError> {let mut filter = <Self as HasTable>::table()diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rsindex 0478e423b7..18560837bc 100644--- a/crates/router/src/types/storage/payment_attempt.rs+++ b/crates/router/src/types/storage/payment_attempt.rs@@ -153,7 +153,7 @@ mod tests {let current_time = common_utils::date_time::now();let payment_id = Uuid::new_v4().to_string();let attempt_id = Uuid::new_v4().to_string();- let merchant_id = Uuid::new_v4().to_string();+ let merchant_id = common_utils::id_type::MerchantId::new_from_unix_timestamp();let connector = types::Connector::DummyConnector1.to_string();let payment_attempt = PaymentAttemptNew {@@ -195,12 +195,13 @@ mod tests {async fn test_payment_attempt_mandate_field() {let state = create_single_connection_test_transaction_pool().await;let uuid = Uuid::new_v4().to_string();+ let merchant_id = common_utils::id_type::MerchantId::from("merchant1".into()).unwrap();let current_time = common_utils::date_time::now();let connector = types::Connector::DummyConnector1.to_string();let payment_attempt = PaymentAttemptNew {payment_id: uuid.clone(),- merchant_id: "1".to_string(),+ merchant_id: merchant_id.clone(),connector: Some(connector),created_at: current_time.into(),modified_at: current_time.into(),@@ -221,7 +222,7 @@ mod tests {let response = store.find_payment_attempt_by_payment_id_merchant_id_attempt_id(&uuid,- "1",+ &merchant_id,&uuid,enums::MerchantStorageScheme::PostgresOnly,)diff --git a/crates/router/src/types/storage/payment_link.rs b/crates/router/src/types/storage/payment_link.rsindex 6b4869817c..9a251d760b 100644--- a/crates/router/src/types/storage/payment_link.rs+++ b/crates/router/src/types/storage/payment_link.rs@@ -16,7 +16,7 @@ use crate::{pub trait PaymentLinkDbExt: Sized {async fn filter_by_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_link_list_constraints: api_models::payments::PaymentLinkListConstraints,) -> CustomResult<Vec<Self>, errors::DatabaseError>;}@@ -25,7 +25,7 @@ pub trait PaymentLinkDbExt: Sized {impl PaymentLinkDbExt for PaymentLink {async fn filter_by_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_link_list_constraints: api_models::payments::PaymentLinkListConstraints,) -> CustomResult<Vec<Self>, errors::DatabaseError> {let mut filter = <Self as HasTable>::table()diff --git a/crates/router/src/types/storage/payment_method.rs b/crates/router/src/types/storage/payment_method.rsindex 308aa36256..8a8f89f901 100644--- a/crates/router/src/types/storage/payment_method.rs+++ b/crates/router/src/types/storage/payment_method.rs@@ -116,5 +116,5 @@ pub struct PaymentMethodStatusTrackingData {pub payment_method_id: String,pub prev_status: enums::PaymentMethodStatus,pub curr_status: enums::PaymentMethodStatus,- pub merchant_id: String,+ pub merchant_id: common_utils::id_type::MerchantId,}diff --git a/crates/router/src/types/storage/refund.rs b/crates/router/src/types/storage/refund.rsindex 75030721ec..1860771d02 100644--- a/crates/router/src/types/storage/refund.rs+++ b/crates/router/src/types/storage/refund.rs@@ -19,7 +19,7 @@ use crate::{connection::PgPooledConn, logger};pub trait RefundDbExt: Sized {async fn filter_by_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_list_details: &api_models::refunds::RefundListRequest,limit: i64,offset: i64,@@ -27,13 +27,13 @@ pub trait RefundDbExt: Sized {async fn filter_by_meta_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_list_details: &api_models::payments::TimeRange,) -> CustomResult<api_models::refunds::RefundListMetaData, errors::DatabaseError>;async fn get_refunds_count(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_list_details: &api_models::refunds::RefundListRequest,) -> CustomResult<i64, errors::DatabaseError>;}@@ -42,7 +42,7 @@ pub trait RefundDbExt: Sized {impl RefundDbExt for Refund {async fn filter_by_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_list_details: &api_models::refunds::RefundListRequest,limit: i64,offset: i64,@@ -150,7 +150,7 @@ impl RefundDbExt for Refund {async fn filter_by_meta_constraints(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_list_details: &api_models::payments::TimeRange,) -> CustomResult<api_models::refunds::RefundListMetaData, errors::DatabaseError> {let start_time = refund_list_details.start_time;@@ -205,7 +205,7 @@ impl RefundDbExt for Refund {async fn get_refunds_count(conn: &PgPooledConn,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,refund_list_details: &api_models::refunds::RefundListRequest,) -> CustomResult<i64, errors::DatabaseError> {let mut filter = <Self as HasTable>::table()diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rsindex cd1019f4a0..ea3a36b518 100644--- a/crates/router/src/utils.rs+++ b/crates/router/src/utils.rs@@ -210,7 +210,7 @@ pub async fn find_payment_intent_from_payment_id_type(.find_payment_intent_by_payment_id_merchant_id(&key_manager_state,&payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,merchant_account.storage_scheme,)@@ -219,7 +219,7 @@ pub async fn find_payment_intent_from_payment_id_type(payments::PaymentIdType::ConnectorTransactionId(connector_transaction_id) => {let attempt = db.find_payment_attempt_by_merchant_id_connector_txn_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&connector_transaction_id,merchant_account.storage_scheme,)@@ -228,7 +228,7 @@ pub async fn find_payment_intent_from_payment_id_type(db.find_payment_intent_by_payment_id_merchant_id(&key_manager_state,&attempt.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,merchant_account.storage_scheme,)@@ -239,7 +239,7 @@ pub async fn find_payment_intent_from_payment_id_type(let attempt = db.find_payment_attempt_by_attempt_id_merchant_id(&attempt_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -247,7 +247,7 @@ pub async fn find_payment_intent_from_payment_id_type(db.find_payment_intent_by_payment_id_merchant_id(&key_manager_state,&attempt.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,merchant_account.storage_scheme,)@@ -271,7 +271,7 @@ pub async fn find_payment_intent_from_refund_id_type(let refund = match refund_id_type {webhooks::RefundIdType::RefundId(id) => db.find_refund_by_merchant_id_refund_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&id,merchant_account.storage_scheme,)@@ -279,7 +279,7 @@ pub async fn find_payment_intent_from_refund_id_type(.to_not_found_response(errors::ApiErrorResponse::RefundNotFound)?,webhooks::RefundIdType::ConnectorRefundId(id) => db.find_refund_by_merchant_id_connector_refund_id_connector(- &merchant_account.merchant_id,+ merchant_account.get_id(),&id,connector_name,merchant_account.storage_scheme,@@ -290,7 +290,7 @@ pub async fn find_payment_intent_from_refund_id_type(let attempt = db.find_payment_attempt_by_attempt_id_merchant_id(&refund.attempt_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -298,7 +298,7 @@ pub async fn find_payment_intent_from_refund_id_type(db.find_payment_intent_by_payment_id_merchant_id(&state.into(),&attempt.payment_id,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,merchant_account.storage_scheme,)@@ -316,7 +316,7 @@ pub async fn find_payment_intent_from_mandate_id_type(let mandate = match mandate_id_type {webhooks::MandateIdType::MandateId(mandate_id) => db.find_mandate_by_merchant_id_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),mandate_id.as_str(),merchant_account.storage_scheme,)@@ -324,7 +324,7 @@ pub async fn find_payment_intent_from_mandate_id_type(.to_not_found_response(errors::ApiErrorResponse::MandateNotFound)?,webhooks::MandateIdType::ConnectorMandateId(connector_mandate_id) => db.find_mandate_by_merchant_id_connector_mandate_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),connector_mandate_id.as_str(),merchant_account.storage_scheme,)@@ -337,7 +337,7 @@ pub async fn find_payment_intent_from_mandate_id_type(.original_payment_id.ok_or(errors::ApiErrorResponse::InternalServerError).attach_printable("original_payment_id not present in mandate record")?,- &merchant_account.merchant_id,+ merchant_account.get_id(),key_store,merchant_account.storage_scheme,)@@ -355,14 +355,14 @@ pub async fn find_mca_from_authentication_id_type(let authentication = match authentication_id_type {webhooks::AuthenticationIdType::AuthenticationId(authentication_id) => db.find_authentication_by_merchant_id_authentication_id(- merchant_account.merchant_id.clone(),+ merchant_account.get_id(),authentication_id,).await.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?,webhooks::AuthenticationIdType::ConnectorAuthenticationId(connector_authentication_id) => {db.find_authentication_by_merchant_id_connector_authentication_id(- merchant_account.merchant_id.clone(),+ merchant_account.get_id().clone(),connector_authentication_id,).await@@ -371,7 +371,7 @@ pub async fn find_mca_from_authentication_id_type(};db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(&state.into(),- &merchant_account.merchant_id,+ merchant_account.get_id(),&authentication.merchant_connector_id,key_store,)@@ -392,7 +392,7 @@ pub async fn get_mca_from_payment_intent(let payment_attempt = db.find_payment_attempt_by_attempt_id_merchant_id(&payment_intent.active_attempt.get_id(),- &merchant_account.merchant_id,+ merchant_account.get_id(),merchant_account.storage_scheme,).await@@ -402,7 +402,7 @@ pub async fn get_mca_from_payment_intent(Some(merchant_connector_id) => db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(key_manager_state,- &merchant_account.merchant_id,+ merchant_account.get_id(),&merchant_connector_id,key_store,)@@ -454,7 +454,7 @@ pub async fn get_mca_from_payout_attempt(let payout = match payout_id_type {webhooks::PayoutIdType::PayoutAttemptId(payout_attempt_id) => db.find_payout_attempt_by_merchant_id_payout_attempt_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&payout_attempt_id,merchant_account.storage_scheme,)@@ -462,7 +462,7 @@ pub async fn get_mca_from_payout_attempt(.to_not_found_response(errors::ApiErrorResponse::PayoutNotFound)?,webhooks::PayoutIdType::ConnectorPayoutId(connector_payout_id) => db.find_payout_attempt_by_merchant_id_connector_payout_id(- &merchant_account.merchant_id,+ merchant_account.get_id(),&connector_payout_id,merchant_account.storage_scheme,)@@ -474,7 +474,7 @@ pub async fn get_mca_from_payout_attempt(Some(merchant_connector_id) => db.find_by_merchant_connector_account_merchant_id_merchant_connector_id(key_manager_state,- &merchant_account.merchant_id,+ merchant_account.get_id(),&merchant_connector_id,key_store,)@@ -677,14 +677,14 @@ pub trait CustomerAddress {address_details: payments::AddressDetails,key: &[u8],storage_scheme: storage::enums::MerchantStorageScheme,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> CustomResult<storage::AddressUpdate, common_utils::errors::CryptoError>;async fn get_domain_address(&self,state: &SessionState,address_details: payments::AddressDetails,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,key: &[u8],storage_scheme: storage::enums::MerchantStorageScheme,@@ -700,7 +700,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {address_details: payments::AddressDetails,key: &[u8],storage_scheme: storage::enums::MerchantStorageScheme,- merchant_id: String,+ merchant_id: id_type::MerchantId,) -> CustomResult<storage::AddressUpdate, common_utils::errors::CryptoError> {let encrypted_data = batch_encrypt(&state.into(),@@ -736,7 +736,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {&self,state: &SessionState,address_details: payments::AddressDetails,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,customer_id: &id_type::CustomerId,key: &[u8],storage_scheme: storage::enums::MerchantStorageScheme,@@ -748,7 +748,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {phone_number: self.phone.clone(),email: self.email.clone(),}),- Identifier::Merchant(merchant_id.to_string()),+ Identifier::Merchant(merchant_id.to_owned()),key,).await?;@@ -767,7 +767,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {last_name: encryptable_address.last_name,phone_number: encryptable_address.phone_number,country_code: self.phone_country_code.clone(),- merchant_id: merchant_id.to_string(),+ merchant_id: merchant_id.to_owned(),address_id: generate_id(consts::ID_LENGTH, "add"),created_at: common_utils::date_time::now(),modified_at: common_utils::date_time::now(),@@ -785,7 +785,7 @@ impl CustomerAddress for api_models::customers::CustomerRequest {pub fn add_apple_pay_flow_metrics(apple_pay_flow: &Option<domain::ApplePayFlow>,connector: Option<String>,- merchant_id: String,+ merchant_id: id_type::MerchantId,) {if let Some(flow) = apple_pay_flow {match flow {@@ -797,7 +797,7 @@ pub fn add_apple_pay_flow_metrics("connector",connector.to_owned().unwrap_or("null".to_string()),),- ("merchant_id", merchant_id.to_owned()),+ ("merchant_id", merchant_id.get_string_repr().to_owned()),]),),domain::ApplePayFlow::Manual => metrics::APPLE_PAY_MANUAL_FLOW.add(@@ -808,7 +808,7 @@ pub fn add_apple_pay_flow_metrics("connector",connector.to_owned().unwrap_or("null".to_string()),),- ("merchant_id", merchant_id.to_owned()),+ ("merchant_id", merchant_id.get_string_repr().to_owned()),]),),}@@ -819,7 +819,7 @@ pub fn add_apple_pay_payment_status_metrics(payment_attempt_status: enums::AttemptStatus,apple_pay_flow: Option<domain::ApplePayFlow>,connector: Option<String>,- merchant_id: String,+ merchant_id: id_type::MerchantId,) {if payment_attempt_status == enums::AttemptStatus::Charged {if let Some(flow) = apple_pay_flow {@@ -833,7 +833,7 @@ pub fn add_apple_pay_payment_status_metrics("connector",connector.to_owned().unwrap_or("null".to_string()),),- ("merchant_id", merchant_id.to_owned()),+ ("merchant_id", merchant_id.get_string_repr().to_owned()),]),)}@@ -846,7 +846,7 @@ pub fn add_apple_pay_payment_status_metrics("connector",connector.to_owned().unwrap_or("null".to_string()),),- ("merchant_id", merchant_id.to_owned()),+ ("merchant_id", merchant_id.get_string_repr().to_owned()),]),),}@@ -863,7 +863,7 @@ pub fn add_apple_pay_payment_status_metrics("connector",connector.to_owned().unwrap_or("null".to_string()),),- ("merchant_id", merchant_id.to_owned()),+ ("merchant_id", merchant_id.get_string_repr().to_owned()),]),)}@@ -875,7 +875,7 @@ pub fn add_apple_pay_payment_status_metrics("connector",connector.to_owned().unwrap_or("null".to_string()),),- ("merchant_id", merchant_id.to_owned()),+ ("merchant_id", merchant_id.get_string_repr().to_owned()),]),),}@@ -998,10 +998,6 @@ pub async fn flatten_join_error<T>(handle: Handle<T>) -> RouterResult<T> {}}-pub(crate) fn get_merchant_fingerprint_secret_key(merchant_id: impl AsRef<str>) -> String {- format!("fingerprint_secret_{}", merchant_id.as_ref())-}-#[cfg(test)]mod tests {use crate::utils;diff --git a/crates/router/src/utils/connector_onboarding.rs b/crates/router/src/utils/connector_onboarding.rsindex 0bc8e58fcc..b66190f450 100644--- a/crates/router/src/utils/connector_onboarding.rs+++ b/crates/router/src/utils/connector_onboarding.rs@@ -43,7 +43,7 @@ pub fn is_enabled(pub async fn check_if_connector_exists(state: &SessionState,connector_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,) -> RouterResult<()> {let key_manager_state = &state.into();let key_store = statediff --git a/crates/router/src/utils/user.rs b/crates/router/src/utils/user.rsindex 6c52ecda4c..58215bf1bc 100644--- a/crates/router/src/utils/user.rs+++ b/crates/router/src/utils/user.rs@@ -100,7 +100,7 @@ pub async fn generate_jwt_auth_token(pub async fn generate_jwt_auth_token_with_custom_role_attributes(state: &SessionState,user: &UserFromStorage,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,role_id: String,) -> UserResult<Secret<String>> {@@ -152,7 +152,7 @@ pub fn get_multiple_merchant_details_with_status() -> UserResult<Vec<user_api::UserMerchantAccount>> {let merchant_account_map = merchant_accounts.into_iter()- .map(|merchant_account| (merchant_account.merchant_id.clone(), merchant_account))+ .map(|merchant_account| (merchant_account.get_id().clone(), merchant_account)).collect::<HashMap<_, _>>();let role_map = rolesdiff --git a/crates/router/src/utils/user/dashboard_metadata.rs b/crates/router/src/utils/user/dashboard_metadata.rsindex 225dc81765..5814f64f75 100644--- a/crates/router/src/utils/user/dashboard_metadata.rs+++ b/crates/router/src/utils/user/dashboard_metadata.rs@@ -20,7 +20,7 @@ use crate::{pub async fn insert_merchant_scoped_metadata_to_db(state: &SessionState,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,metadata_key: DBEnum,metadata_value: impl serde::Serialize,@@ -53,7 +53,7 @@ pub async fn insert_merchant_scoped_metadata_to_db(pub async fn insert_user_scoped_metadata_to_db(state: &SessionState,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,metadata_key: DBEnum,metadata_value: impl serde::Serialize,@@ -86,7 +86,7 @@ pub async fn insert_user_scoped_metadata_to_db(pub async fn get_merchant_scoped_metadata_from_db(state: &SessionState,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,metadata_keys: Vec<DBEnum>,) -> UserResult<Vec<DashboardMetadata>> {@@ -100,7 +100,7 @@ pub async fn get_merchant_scoped_metadata_from_db(pub async fn get_user_scoped_metadata_from_db(state: &SessionState,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,metadata_keys: Vec<DBEnum>,) -> UserResult<Vec<DashboardMetadata>> {@@ -124,7 +124,7 @@ pub async fn get_user_scoped_metadata_from_db(pub async fn update_merchant_scoped_metadata(state: &SessionState,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,metadata_key: DBEnum,metadata_value: impl serde::Serialize,@@ -152,7 +152,7 @@ pub async fn update_merchant_scoped_metadata(pub async fn update_user_scoped_metadata(state: &SessionState,user_id: String,- merchant_id: String,+ merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,metadata_key: DBEnum,metadata_value: impl serde::Serialize,diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rsindex 0909f4ffbe..b1ab16ac03 100644--- a/crates/router/src/utils/user/sample_data.rs+++ b/crates/router/src/utils/user/sample_data.rs@@ -19,9 +19,8 @@ use crate::{pub async fn generate_sample_data(state: &SessionState,req: SampleDataRequest,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,) -> SampleDataResult<Vec<(PaymentIntent, PaymentAttemptBatchNew, Option<RefundNew>)>> {- let merchant_id = merchant_id.to_string();let sample_data_size: usize = req.record.unwrap_or(100);let key_manager_state = &state.into();if !(10..=100).contains(&sample_data_size) {@@ -32,7 +31,7 @@ pub async fn generate_sample_data(.store.get_merchant_key_store_by_merchant_id(key_manager_state,- merchant_id.as_str(),+ merchant_id,&state.store.get_master_key().to_vec().into(),).await@@ -40,7 +39,7 @@ pub async fn generate_sample_data(let merchant_from_db = state.store- .find_merchant_account_by_merchant_id(key_manager_state, merchant_id.as_str(), &key_store)+ .find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store).await.change_context::<SampleDataError>(SampleDataError::DataDoesNotExist)?;@@ -71,7 +70,7 @@ pub async fn generate_sample_data(state.store- .list_business_profile_by_merchant_id(&merchant_id)+ .list_business_profile_by_merchant_id(merchant_id).await.change_context(SampleDataError::InternalServerError).attach_printable("Failed to get business profile")?diff --git a/crates/router/src/utils/user_role.rs b/crates/router/src/utils/user_role.rsindex d304c31c1c..99c020e0ee 100644--- a/crates/router/src/utils/user_role.rs+++ b/crates/router/src/utils/user_role.rs@@ -77,7 +77,7 @@ pub fn validate_role_groups(groups: &[PermissionGroup]) -> UserResult<()> {pub async fn validate_role_name(state: &SessionState,role_name: &domain::RoleName,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> UserResult<()> {let role_name_str = role_name.clone().get_role_name();@@ -109,7 +109,7 @@ pub async fn set_role_permissions_in_cache_by_user_role(set_role_permissions_in_cache_if_required(state,user_role.role_id.as_str(),- user_role.merchant_id.as_str(),+ &user_role.merchant_id,&user_role.org_id,).await@@ -120,7 +120,7 @@ pub async fn set_role_permissions_in_cache_by_user_role(pub async fn set_role_permissions_in_cache_if_required(state: &SessionState,role_id: &str,- merchant_id: &str,+ merchant_id: &id_type::MerchantId,org_id: &id_type::OrganizationId,) -> UserResult<()> {if roles::predefined_roles::PREDEFINED_ROLES.contains_key(role_id) {diff --git a/crates/router/src/workflows/api_key_expiry.rs b/crates/router/src/workflows/api_key_expiry.rsindex e49a5f86c3..b26e9862e8 100644--- a/crates/router/src/workflows/api_key_expiry.rs+++ b/crates/router/src/workflows/api_key_expiry.rs@@ -33,7 +33,7 @@ impl ProcessTrackerWorkflow<SessionState> for ApiKeyExpiryWorkflow {.store.get_merchant_key_store_by_merchant_id(key_manager_satte,- tracking_data.merchant_id.as_str(),+ &tracking_data.merchant_id,&state.store.get_master_key().to_vec().into(),).await?;@@ -41,7 +41,7 @@ impl ProcessTrackerWorkflow<SessionState> for ApiKeyExpiryWorkflow {let merchant_account = db.find_merchant_account_by_merchant_id(key_manager_satte,- tracking_data.merchant_id.as_str(),+ &tracking_data.merchant_id,&key_store,).await?;diff --git a/crates/router/src/workflows/attach_payout_account_workflow.rs b/crates/router/src/workflows/attach_payout_account_workflow.rsindex 7ff0faefa6..37de784d5e 100644--- a/crates/router/src/workflows/attach_payout_account_workflow.rs+++ b/crates/router/src/workflows/attach_payout_account_workflow.rs@@ -35,7 +35,7 @@ impl ProcessTrackerWorkflow<SessionState> for AttachPayoutAccountWorkflow {let key_store = db.get_merchant_key_store_by_merchant_id(key_manager_state,- merchant_id.as_ref(),+ &merchant_id,&db.get_master_key().to_vec().into(),).await?;diff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rsindex d181aedd18..5334e4e93a 100644--- a/crates/router/src/workflows/outgoing_webhook_retry.rs+++ b/crates/router/src/workflows/outgoing_webhook_retry.rs@@ -263,7 +263,7 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {#[instrument(skip_all)]pub(crate) async fn get_webhook_delivery_retry_schedule_time(db: &dyn StorageInterface,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,retry_count: i32,) -> Option<time::PrimitiveDateTime> {let key = "pt_mapping_outgoing_webhooks";@@ -308,7 +308,7 @@ pub(crate) async fn get_webhook_delivery_retry_schedule_time(#[instrument(skip_all)]pub(crate) async fn retry_webhook_delivery_task(db: &dyn StorageInterface,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,process: storage::ProcessTracker,) -> errors::CustomResult<(), errors::StorageError> {let schedule_time =diff --git a/crates/router/src/workflows/payment_method_status_update.rs b/crates/router/src/workflows/payment_method_status_update.rsindex fa0631cc5c..5120f1ba19 100644--- a/crates/router/src/workflows/payment_method_status_update.rs+++ b/crates/router/src/workflows/payment_method_status_update.rs@@ -35,7 +35,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentMethodStatusUpdateWorkflow.store.get_merchant_key_store_by_merchant_id(key_manager_state,- merchant_id.as_str(),+ &merchant_id,&state.store.get_master_key().to_vec().into(),).await?;diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rsindex 2bc7b183ec..d626241e32 100644--- a/crates/router/src/workflows/payment_sync.rs+++ b/crates/router/src/workflows/payment_sync.rs@@ -229,7 +229,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {pub async fn get_sync_process_schedule_time(db: &dyn StorageInterface,connector: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,retry_count: i32,) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> {let mapping: common_utils::errors::CustomResult<@@ -262,7 +262,7 @@ pub async fn get_sync_process_schedule_time(pub async fn retry_sync_task(db: &dyn StorageInterface,connector: String,- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,pt: storage::ProcessTracker,) -> Result<bool, sch_errors::ProcessTrackerError> {let schedule_time =@@ -289,12 +289,19 @@ mod tests {#[test]fn test_get_default_schedule_time() {- let schedule_time_delta =- scheduler_utils::get_schedule_time(process_data::ConnectorPTMapping::default(), "-", 0)- .unwrap();- let first_retry_time_delta =- scheduler_utils::get_schedule_time(process_data::ConnectorPTMapping::default(), "-", 1)- .unwrap();+ let merchant_id = common_utils::id_type::MerchantId::from("-".into()).unwrap();+ let schedule_time_delta = scheduler_utils::get_schedule_time(+ process_data::ConnectorPTMapping::default(),+ &merchant_id,+ 0,+ )+ .unwrap();+ let first_retry_time_delta = scheduler_utils::get_schedule_time(+ process_data::ConnectorPTMapping::default(),+ &merchant_id,+ 1,+ )+ .unwrap();let cpt_default = process_data::ConnectorPTMapping::default().default_mapping;assert_eq!(vec![schedule_time_delta, first_retry_time_delta],diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rsindex d7eda4db83..72663079f2 100644--- a/crates/router/tests/connectors/aci.rs+++ b/crates/router/tests/connectors/aci.rs@@ -20,9 +20,11 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {.aci.expect("Missing ACI connector authentication configuration");+ let merchant_id = id_type::MerchantId::from("aci".into()).unwrap();+types::RouterData {flow: PhantomData,- merchant_id: String::from("aci"),+ merchant_id,customer_id: Some(id_type::CustomerId::from("aci".into()).unwrap()),connector: "aci".to_string(),payment_id: uuid::Uuid::new_v4().to_string(),@@ -131,9 +133,11 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {.aci.expect("Missing ACI connector authentication configuration");+ let merchant_id = id_type::MerchantId::from("aci".into()).unwrap();+types::RouterData {flow: PhantomData,- merchant_id: String::from("aci"),+ merchant_id,customer_id: Some(id_type::CustomerId::from("aci".into()).unwrap()),connector: "aci".to_string(),payment_id: uuid::Uuid::new_v4().to_string(),diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rsindex c3d9b6e0c3..612d2863e5 100644--- a/crates/router/tests/connectors/utils.rs+++ b/crates/router/tests/connectors/utils.rs@@ -481,9 +481,11 @@ pub trait ConnectorActions: Connector {req: Req,info: Option<PaymentInfo>,) -> RouterData<Flow, Req, Res> {+ let merchant_id = common_utils::id_type::MerchantId::from(self.get_name().into()).unwrap();+RouterData {flow: PhantomData,- merchant_id: self.get_name(),+ merchant_id,customer_id: Some(common_utils::generate_customer_id_of_default_length()),connector: self.get_name(),payment_id: uuid::Uuid::new_v4().to_string(),diff --git a/crates/router/tests/integration_demo.rs b/crates/router/tests/integration_demo.rsindex 777e0a6829..773f3c3ab7 100644--- a/crates/router/tests/integration_demo.rs+++ b/crates/router/tests/integration_demo.rs@@ -15,11 +15,14 @@ async fn create_merchant_account() {let admin_client = client.admin("test_admin");let expected = "merchant_12345";+ let expected_merchant_id_type =+ common_utils::id_type::MerchantId::from("merchant_12345".into()).unwrap();+let hlist_pat![merchant_id, _api_key]: HList![MerchantId, ApiKey] = admin_client.create_merchant_account(&server, expected.to_owned()).await;- assert_eq!(expected, *merchant_id);+ assert_eq!(expected_merchant_id_type, *merchant_id);}/// Example of unit testdiff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex 997ae51cf3..31d5e52c3c 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -285,6 +285,9 @@ async fn payments_create_core() {Box::new(services::MockApiClient),)).await;++ let merchant_id = id_type::MerchantId::from("juspay_merchant".into()).unwrap();+let state = Arc::new(app_state).get_session_state("public", || {}).unwrap();@@ -293,7 +296,7 @@ async fn payments_create_core() {.store.get_merchant_key_store_by_merchant_id(key_manager_state,- "juspay_merchant",+ &merchant_id,&state.store.get_master_key().to_vec().into(),).await@@ -301,7 +304,7 @@ async fn payments_create_core() {let merchant_account = state.store- .find_merchant_account_by_merchant_id(key_manager_state, "juspay_merchant", &key_store)+ .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store).await.unwrap();@@ -309,7 +312,7 @@ async fn payments_create_core() {payment_id: Some(api::PaymentIdType::PaymentIntentId("pay_mbabizu24mvu3mela5njyhpit10".to_string(),)),- merchant_id: Some("jarnura".to_string()),+ merchant_id: Some(merchant_id),amount: Some(MinorUnit::new(6540).into()),currency: Some(api_enums::Currency::USD),capture_method: Some(api_enums::CaptureMethod::Automatic),@@ -475,14 +478,14 @@ async fn payments_create_core_adyen_no_redirect() {.unwrap();let customer_id = format!("cust_{}", Uuid::new_v4());- let merchant_id = "arunraj".to_string();+ let merchant_id = id_type::MerchantId::from("juspay_merchant".into()).unwrap();let payment_id = "pay_mbabizu24mvu3mela5njyhpit10".to_string();let key_manager_state = &(&state).into();let key_store = state.store.get_merchant_key_store_by_merchant_id(key_manager_state,- "juspay_merchant",+ &merchant_id,&state.store.get_master_key().to_vec().into(),).await@@ -490,7 +493,7 @@ async fn payments_create_core_adyen_no_redirect() {let merchant_account = state.store- .find_merchant_account_by_merchant_id(key_manager_state, "juspay_merchant", &key_store)+ .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store).await.unwrap();diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex fcf106a9ef..20bf10da72 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -45,6 +45,9 @@ async fn payments_create_core() {Box::new(services::MockApiClient),)).await;++ let merchant_id = id_type::MerchantId::from("juspay_merchant".into()).unwrap();+let state = Arc::new(app_state).get_session_state("public", || {}).unwrap();@@ -53,7 +56,7 @@ async fn payments_create_core() {.store.get_merchant_key_store_by_merchant_id(key_manager_state,- "juspay_merchant",+ &merchant_id,&state.store.get_master_key().to_vec().into(),).await@@ -61,7 +64,7 @@ async fn payments_create_core() {let merchant_account = state.store- .find_merchant_account_by_merchant_id(key_manager_state, "juspay_merchant", &key_store)+ .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store).await.unwrap();@@ -69,7 +72,7 @@ async fn payments_create_core() {payment_id: Some(api::PaymentIdType::PaymentIntentId("pay_mbabizu24mvu3mela5njyhpit10".to_string(),)),- merchant_id: Some("jarnura".to_string()),+ merchant_id: Some(merchant_id),amount: Some(MinorUnit::new(6540).into()),currency: Some(api_enums::Currency::USD),capture_method: Some(api_enums::CaptureMethod::Automatic),@@ -242,14 +245,14 @@ async fn payments_create_core_adyen_no_redirect() {.unwrap();let customer_id = format!("cust_{}", Uuid::new_v4());- let merchant_id = "arunraj".to_string();+ let merchant_id = id_type::MerchantId::from("juspay_merchant".into()).unwrap();let payment_id = "pay_mbabizu24mvu3mela5njyhpit10".to_string();let key_manager_state = &(&state).into();let key_store = state.store.get_merchant_key_store_by_merchant_id(key_manager_state,- "juspay_merchant",+ &merchant_id,&state.store.get_master_key().to_vec().into(),).await@@ -257,7 +260,7 @@ async fn payments_create_core_adyen_no_redirect() {let merchant_account = state.store- .find_merchant_account_by_merchant_id(key_manager_state, "juspay_merchant", &key_store)+ .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store).await.unwrap();diff --git a/crates/router/tests/utils.rs b/crates/router/tests/utils.rsindex 5d48d6e8ad..96ea3c7d02 100644--- a/crates/router/tests/utils.rs+++ b/crates/router/tests/utils.rs@@ -103,7 +103,7 @@ impl AppClient<Admin> {pub async fn create_connector<T: DeserializeOwned, S, B>(&self,app: &S,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_name: &str,api_key: &str,) -> T@@ -384,7 +384,7 @@ macro_rules! hlist_pat {#[derive(Deserialize, Deref)]pub struct MerchantId {- merchant_id: String,+ merchant_id: common_utils::id_type::MerchantId,}#[derive(Deserialize, Deref)]diff --git a/crates/scheduler/src/consumer/types/process_data.rs b/crates/scheduler/src/consumer/types/process_data.rsindex 98d0fe530e..f68ad4795d 100644--- a/crates/scheduler/src/consumer/types/process_data.rs+++ b/crates/scheduler/src/consumer/types/process_data.rs@@ -12,7 +12,7 @@ pub struct RetryMapping {#[derive(Serialize, Deserialize)]pub struct ConnectorPTMapping {pub default_mapping: RetryMapping,- pub custom_merchant_mapping: HashMap<String, RetryMapping>,+ pub custom_merchant_mapping: HashMap<common_utils::id_type::MerchantId, RetryMapping>,pub max_retries_count: i32,}@@ -57,7 +57,7 @@ pub struct OutgoingWebhookRetryProcessTrackerMapping {pub default_mapping: RetryMapping,/// Merchant-specific retry configuration.- pub custom_merchant_mapping: HashMap<String, RetryMapping>,+ pub custom_merchant_mapping: HashMap<common_utils::id_type::MerchantId, RetryMapping>,}impl Default for OutgoingWebhookRetryProcessTrackerMapping {diff --git a/crates/scheduler/src/utils.rs b/crates/scheduler/src/utils.rsindex f4f3a7c1bb..8c2424d501 100644--- a/crates/scheduler/src/utils.rs+++ b/crates/scheduler/src/utils.rs@@ -251,9 +251,12 @@ pub fn get_process_tracker_id<'a>(runner: storage::ProcessTrackerRunner,task_name: &'a str,txn_id: &'a str,- merchant_id: &'a str,+ merchant_id: &'a common_utils::id_type::MerchantId,) -> String {- format!("{runner}_{task_name}_{txn_id}_{merchant_id}")+ format!(+ "{runner}_{task_name}_{txn_id}_{}",+ merchant_id.get_string_repr()+ )}pub fn get_time_from_delta(delta: Option<i32>) -> Option<time::PrimitiveDateTime> {@@ -300,10 +303,10 @@ pub fn add_histogram_metrics(pub fn get_schedule_time(mapping: process_data::ConnectorPTMapping,- merchant_name: &str,+ merchant_id: &common_utils::id_type::MerchantId,retry_count: i32,) -> Option<i32> {- let mapping = match mapping.custom_merchant_mapping.get(merchant_name) {+ let mapping = match mapping.custom_merchant_mapping.get(merchant_id) {Some(map) => map.clone(),None => mapping.default_mapping,};@@ -335,10 +338,10 @@ pub fn get_pm_schedule_time(pub fn get_outgoing_webhook_retry_schedule_time(mapping: process_data::OutgoingWebhookRetryProcessTrackerMapping,- merchant_name: &str,+ merchant_id: &common_utils::id_type::MerchantId,retry_count: i32,) -> Option<i32> {- let retry_mapping = match mapping.custom_merchant_mapping.get(merchant_name) {+ let retry_mapping = match mapping.custom_merchant_mapping.get(merchant_id) {Some(map) => map.clone(),None => mapping.default_mapping,};diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rsindex d55f812c5a..7bb0c700d7 100644--- a/crates/storage_impl/src/lib.rs+++ b/crates/storage_impl/src/lib.rs@@ -330,7 +330,11 @@ impl UniqueConstraints for diesel_models::Address {impl UniqueConstraints for diesel_models::PaymentIntent {fn unique_constraints(&self) -> Vec<String> {- vec![format!("pi_{}_{}", self.merchant_id, self.payment_id)]+ vec![format!(+ "pi_{}_{}",+ self.merchant_id.get_string_repr(),+ self.payment_id+ )]}fn table_name(&self) -> &str {"PaymentIntent"@@ -341,7 +345,9 @@ impl UniqueConstraints for diesel_models::PaymentAttempt {fn unique_constraints(&self) -> Vec<String> {vec![format!("pa_{}_{}_{}",- self.merchant_id, self.payment_id, self.attempt_id+ self.merchant_id.get_string_repr(),+ self.payment_id,+ self.attempt_id)]}fn table_name(&self) -> &str {@@ -351,7 +357,11 @@ impl UniqueConstraints for diesel_models::PaymentAttempt {impl UniqueConstraints for diesel_models::Refund {fn unique_constraints(&self) -> Vec<String> {- vec![format!("refund_{}_{}", self.merchant_id, self.refund_id)]+ vec![format!(+ "refund_{}_{}",+ self.merchant_id.get_string_repr(),+ self.refund_id+ )]}fn table_name(&self) -> &str {"Refund"@@ -370,7 +380,11 @@ impl UniqueConstraints for diesel_models::ReverseLookup {#[cfg(feature = "payouts")]impl UniqueConstraints for diesel_models::Payouts {fn unique_constraints(&self) -> Vec<String> {- vec![format!("po_{}_{}", self.merchant_id, self.payout_id)]+ vec![format!(+ "po_{}_{}",+ self.merchant_id.get_string_repr(),+ self.payout_id+ )]}fn table_name(&self) -> &str {"Payouts"@@ -382,7 +396,8 @@ impl UniqueConstraints for diesel_models::PayoutAttempt {fn unique_constraints(&self) -> Vec<String> {vec![format!("poa_{}_{}",- self.merchant_id, self.payout_attempt_id+ self.merchant_id.get_string_repr(),+ self.payout_attempt_id)]}fn table_name(&self) -> &str {@@ -401,7 +416,11 @@ impl UniqueConstraints for diesel_models::PaymentMethod {impl UniqueConstraints for diesel_models::Mandate {fn unique_constraints(&self) -> Vec<String> {- vec![format!("mand_{}_{}", self.merchant_id, self.mandate_id)]+ vec![format!(+ "mand_{}_{}",+ self.merchant_id.get_string_repr(),+ self.mandate_id+ )]}fn table_name(&self) -> &str {"Mandate"@@ -413,7 +432,7 @@ impl UniqueConstraints for diesel_models::Customer {vec![format!("customer_{}_{}",self.customer_id.get_string_repr(),- self.merchant_id+ self.merchant_id.get_string_repr(),)]}fn table_name(&self) -> &str {diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rsindex ee183968e2..ed3c47b9c9 100644--- a/crates/storage_impl/src/mock_db/payment_attempt.rs+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs@@ -16,7 +16,7 @@ impl PaymentAttemptInterface for MockDb {async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,_payment_id: &str,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_attempt_id: &str,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {@@ -27,7 +27,7 @@ impl PaymentAttemptInterface for MockDb {async fn get_filters_for_payments(&self,_pi: &[hyperswitch_domain_models::payments::PaymentIntent],- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<hyperswitch_domain_models::payments::payment_attempt::PaymentListFilters,@@ -38,7 +38,7 @@ impl PaymentAttemptInterface for MockDb {async fn get_total_count_of_filtered_payment_attempts(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_active_attempt_ids: &[String],_connector: Option<Vec<Connector>>,_payment_method: Option<Vec<PaymentMethod>>,@@ -53,7 +53,7 @@ impl PaymentAttemptInterface for MockDb {async fn find_payment_attempt_by_attempt_id_merchant_id(&self,_attempt_id: &str,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`@@ -63,7 +63,7 @@ impl PaymentAttemptInterface for MockDb {async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,_preprocessing_id: &str,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`@@ -72,7 +72,7 @@ impl PaymentAttemptInterface for MockDb {async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_txn_id: &str,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {@@ -82,7 +82,7 @@ impl PaymentAttemptInterface for MockDb {async fn find_attempts_by_merchant_id_payment_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_payment_id: &str,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Vec<PaymentAttempt>, StorageError> {@@ -191,7 +191,7 @@ impl PaymentAttemptInterface for MockDb {&self,_connector_transaction_id: &str,_payment_id: &str,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {// [#172]: Implement function for `MockDb`@@ -203,7 +203,7 @@ impl PaymentAttemptInterface for MockDb {async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {let payment_attempts = self.payment_attempts.lock().await;@@ -212,7 +212,7 @@ impl PaymentAttemptInterface for MockDb {.iter().find(|payment_attempt| {payment_attempt.payment_id == payment_id- && payment_attempt.merchant_id == merchant_id+ && payment_attempt.merchant_id.eq(merchant_id)}).cloned().unwrap())@@ -221,7 +221,7 @@ impl PaymentAttemptInterface for MockDb {async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentAttempt, StorageError> {let payment_attempts = self.payment_attempts.lock().await;@@ -230,7 +230,7 @@ impl PaymentAttemptInterface for MockDb {.iter().find(|payment_attempt| {payment_attempt.payment_id == payment_id- && payment_attempt.merchant_id == merchant_id+ && payment_attempt.merchant_id.eq(merchant_id)&& (payment_attempt.status == storage_enums::AttemptStatus::PartialCharged|| payment_attempt.status == storage_enums::AttemptStatus::Charged)})diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rsindex 3e183b94c2..59951045a1 100644--- a/crates/storage_impl/src/mock_db/payment_intent.rs+++ b/crates/storage_impl/src/mock_db/payment_intent.rs@@ -20,7 +20,7 @@ impl PaymentIntentInterface for MockDb {async fn filter_payment_intent_by_constraints(&self,_state: &KeyManagerState,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_filters: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,_key_store: &MerchantKeyStore,_storage_scheme: storage_enums::MerchantStorageScheme,@@ -32,7 +32,7 @@ impl PaymentIntentInterface for MockDb {async fn filter_payment_intents_by_time_range_constraints(&self,_state: &KeyManagerState,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_time_range: &api_models::payments::TimeRange,_key_store: &MerchantKeyStore,_storage_scheme: storage_enums::MerchantStorageScheme,@@ -43,7 +43,7 @@ impl PaymentIntentInterface for MockDb {#[cfg(feature = "olap")]async fn get_filtered_active_attempt_ids_for_total_count(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,_storage_scheme: storage_enums::MerchantStorageScheme,) -> error_stack::Result<Vec<String>, StorageError> {@@ -54,7 +54,7 @@ impl PaymentIntentInterface for MockDb {async fn get_filtered_payment_intents_attempt(&self,_state: &KeyManagerState,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,_key_store: &MerchantKeyStore,_storage_scheme: storage_enums::MerchantStorageScheme,@@ -103,7 +103,7 @@ impl PaymentIntentInterface for MockDb {state,diesel_payment_intent_update.apply_changeset(diesel_payment_intent),key_store.key.get_inner(),- key_store.merchant_id.clone(),+ key_store.merchant_id.clone().into(),).await.change_context(StorageError::DecryptionError)?;@@ -117,7 +117,7 @@ impl PaymentIntentInterface for MockDb {&self,_state: &KeyManagerState,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_key_store: &MerchantKeyStore,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PaymentIntent, StorageError> {@@ -126,7 +126,8 @@ impl PaymentIntentInterface for MockDb {Ok(payment_intents.iter().find(|payment_intent| {- payment_intent.payment_id == payment_id && payment_intent.merchant_id == merchant_id+ payment_intent.payment_id == payment_id+ && payment_intent.merchant_id.eq(merchant_id)}).cloned().unwrap())diff --git a/crates/storage_impl/src/mock_db/payout_attempt.rs b/crates/storage_impl/src/mock_db/payout_attempt.rsindex 652dde93a6..efdd2cf631 100644--- a/crates/storage_impl/src/mock_db/payout_attempt.rs+++ b/crates/storage_impl/src/mock_db/payout_attempt.rs@@ -37,7 +37,7 @@ impl PayoutAttemptInterface for MockDb {async fn find_payout_attempt_by_merchant_id_payout_attempt_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_payout_attempt_id: &str,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PayoutAttempt, StorageError> {@@ -47,7 +47,7 @@ impl PayoutAttemptInterface for MockDb {async fn find_payout_attempt_by_merchant_id_connector_payout_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_connector_payout_id: &str,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<PayoutAttempt, StorageError> {@@ -58,7 +58,7 @@ impl PayoutAttemptInterface for MockDb {async fn get_filters_for_payouts(&self,_payouts: &[Payouts],- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<hyperswitch_domain_models::payouts::payout_attempt::PayoutListFilters,diff --git a/crates/storage_impl/src/mock_db/payouts.rs b/crates/storage_impl/src/mock_db/payouts.rsindex 04e1321f1e..53d34a39a2 100644--- a/crates/storage_impl/src/mock_db/payouts.rs+++ b/crates/storage_impl/src/mock_db/payouts.rs@@ -14,7 +14,7 @@ use super::MockDb;impl PayoutsInterface for MockDb {async fn find_payout_by_merchant_id_payout_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_payout_id: &str,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Payouts, StorageError> {@@ -44,7 +44,7 @@ impl PayoutsInterface for MockDb {async fn find_optional_payout_by_merchant_id_payout_id(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_payout_id: &str,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Option<Payouts>, StorageError> {@@ -55,7 +55,7 @@ impl PayoutsInterface for MockDb {#[cfg(feature = "olap")]async fn filter_payouts_by_constraints(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Vec<Payouts>, StorageError> {@@ -66,7 +66,7 @@ impl PayoutsInterface for MockDb {#[cfg(feature = "olap")]async fn filter_payouts_and_attempts(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Vec<(Payouts, PayoutAttempt, diesel_models::Customer)>, StorageError> {@@ -77,7 +77,7 @@ impl PayoutsInterface for MockDb {#[cfg(feature = "olap")]async fn filter_payouts_by_time_range_constraints(&self,- _merchant_id: &str,+ _merchant_id: &common_utils::id_type::MerchantId,_time_range: &api_models::payments::TimeRange,_storage_scheme: storage_enums::MerchantStorageScheme,) -> CustomResult<Vec<Payouts>, StorageError> {diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rsindex b536ba4552..f5d28f7698 100644--- a/crates/storage_impl/src/payments/payment_attempt.rs+++ b/crates/storage_impl/src/payments/payment_attempt.rs@@ -80,7 +80,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {&self,connector_transaction_id: &str,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentAttempt, errors::StorageError> {let conn = pg_connection_read(self).await?;@@ -102,7 +102,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentAttempt, errors::StorageError> {let conn = pg_connection_read(self).await?;@@ -123,7 +123,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentAttempt, errors::StorageError> {let conn = pg_connection_read(self).await?;@@ -143,7 +143,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {#[instrument(skip_all)]async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_txn_id: &str,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentAttempt, errors::StorageError> {@@ -165,7 +165,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,attempt_id: &str,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentAttempt, errors::StorageError> {@@ -189,7 +189,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {async fn get_filters_for_payments(&self,pi: &[PaymentIntent],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentListFilters, errors::StorageError> {let conn = pg_connection_read(self).await?;@@ -229,7 +229,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,preprocessing_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentAttempt, errors::StorageError> {let conn = pg_connection_read(self).await?;@@ -250,7 +250,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {#[instrument(skip_all)]async fn find_attempts_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,_storage_scheme: MerchantStorageScheme,) -> CustomResult<Vec<PaymentAttempt>, errors::StorageError> {@@ -272,7 +272,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {async fn find_payment_attempt_by_attempt_id_merchant_id(&self,attempt_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PaymentAttempt, errors::StorageError> {let conn = pg_connection_read(self).await?;@@ -289,7 +289,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {#[instrument(skip_all)]async fn get_total_count_of_filtered_payment_attempts(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,active_attempt_ids: &[String],connector: Option<Vec<Connector>>,payment_method: Option<Vec<PaymentMethod>>,@@ -435,7 +435,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {let reverse_lookup = ReverseLookupNew {lookup_id: format!("pa_{}_{}",- &created_attempt.merchant_id, &created_attempt.attempt_id,+ created_attempt.merchant_id.get_string_repr(),+ &created_attempt.attempt_id,),pk_id: key_str.clone(),sk_id: field.clone(),@@ -527,7 +528,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {add_connector_txn_id_to_reverse_lookup(self,key_str.as_str(),- this.merchant_id.as_str(),+ &this.merchant_id,updated_attempt.attempt_id.as_str(),connector_transaction_id.as_str(),storage_scheme,@@ -539,7 +540,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {add_connector_txn_id_to_reverse_lookup(self,key_str.as_str(),- this.merchant_id.as_str(),+ &this.merchant_id,updated_attempt.attempt_id.as_str(),connector_transaction_id.as_str(),storage_scheme,@@ -555,7 +556,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {add_preprocessing_id_to_reverse_lookup(self,key_str.as_str(),- this.merchant_id.as_str(),+ &this.merchant_id,updated_attempt.attempt_id.as_str(),preprocessing_id.as_str(),storage_scheme,@@ -567,7 +568,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {add_preprocessing_id_to_reverse_lookup(self,key_str.as_str(),- this.merchant_id.as_str(),+ &this.merchant_id,updated_attempt.attempt_id.as_str(),preprocessing_id.as_str(),storage_scheme,@@ -598,7 +599,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {&self,connector_transaction_id: &str,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError> {let storage_scheme =@@ -616,7 +617,10 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {}MerchantStorageScheme::RedisKv => {// We assume that PaymentAttempt <=> PaymentIntent is a one-to-one relation for now- let lookup_id = format!("pa_conn_trans_{merchant_id}_{connector_transaction_id}");+ let lookup_id = format!(+ "pa_conn_trans_{}_{connector_transaction_id}",+ merchant_id.get_string_repr()+ );let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -649,7 +653,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError> {let database_call = || {@@ -703,7 +707,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {async fn find_payment_attempt_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError> {let database_call = || {@@ -759,7 +763,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn find_payment_attempt_by_merchant_id_connector_txn_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_txn_id: &str,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError> {@@ -776,7 +780,10 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {.await}MerchantStorageScheme::RedisKv => {- let lookup_id = format!("pa_conn_trans_{merchant_id}_{connector_txn_id}");+ let lookup_id = format!(+ "pa_conn_trans_{}_{connector_txn_id}",+ merchant_id.get_string_repr()+ );let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -821,7 +828,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(&self,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,attempt_id: &str,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError> {@@ -870,7 +877,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {async fn find_payment_attempt_by_attempt_id_merchant_id(&self,attempt_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError> {let storage_scheme =@@ -886,7 +893,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {.await}MerchantStorageScheme::RedisKv => {- let lookup_id = format!("pa_{merchant_id}_{attempt_id}");+ let lookup_id = format!("pa_{}_{attempt_id}", merchant_id.get_string_repr());let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -931,7 +938,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {async fn find_payment_attempt_by_preprocessing_id_merchant_id(&self,preprocessing_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentAttempt, errors::StorageError> {let storage_scheme =@@ -947,7 +954,10 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {.await}MerchantStorageScheme::RedisKv => {- let lookup_id = format!("pa_preprocessing_{merchant_id}_{preprocessing_id}");+ let lookup_id = format!(+ "pa_preprocessing_{}_{preprocessing_id}",+ merchant_id.get_string_repr()+ );let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -991,7 +1001,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn find_attempts_by_merchant_id_payment_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payment_id: &str,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<PaymentAttempt>, errors::StorageError> {@@ -1037,7 +1047,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {async fn get_filters_for_payments(&self,pi: &[PaymentIntent],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentListFilters, errors::StorageError> {self.router_store@@ -1048,7 +1058,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn get_total_count_of_filtered_payment_attempts(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,active_attempt_ids: &[String],connector: Option<Vec<Connector>>,payment_method: Option<Vec<PaymentMethod>>,@@ -2276,14 +2286,18 @@ impl DataModelExt for PaymentAttemptUpdate {async fn add_connector_txn_id_to_reverse_lookup<T: DatabaseStore>(store: &KVRouterStore<T>,key: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,updated_attempt_attempt_id: &str,connector_transaction_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<ReverseLookup, errors::StorageError> {let field = format!("pa_{}", updated_attempt_attempt_id);let reverse_lookup_new = ReverseLookupNew {- lookup_id: format!("pa_conn_trans_{}_{}", merchant_id, connector_transaction_id),+ lookup_id: format!(+ "pa_conn_trans_{}_{}",+ merchant_id.get_string_repr(),+ connector_transaction_id+ ),pk_id: key.to_owned(),sk_id: field.clone(),source: "payment_attempt".to_string(),@@ -2299,14 +2313,18 @@ async fn add_connector_txn_id_to_reverse_lookup<T: DatabaseStore>(async fn add_preprocessing_id_to_reverse_lookup<T: DatabaseStore>(store: &KVRouterStore<T>,key: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,updated_attempt_attempt_id: &str,preprocessing_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<ReverseLookup, errors::StorageError> {let field = format!("pa_{}", updated_attempt_attempt_id);let reverse_lookup_new = ReverseLookupNew {- lookup_id: format!("pa_preprocessing_{}_{}", merchant_id, preprocessing_id),+ lookup_id: format!(+ "pa_preprocessing_{}_{}",+ merchant_id.get_string_repr(),+ preprocessing_id+ ),pk_id: key.to_owned(),sk_id: field.clone(),source: "payment_attempt".to_string(),diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rsindex a982d0ffdc..ea91732631 100644--- a/crates/storage_impl/src/payments/payment_intent.rs+++ b/crates/storage_impl/src/payments/payment_intent.rs@@ -215,7 +215,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {state,diesel_intent,merchant_key_store.key.get_inner(),- merchant_id,+ merchant_id.into(),).await.change_context(StorageError::DecryptionError)?;@@ -230,7 +230,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {&self,state: &KeyManagerState,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_key_store: &MerchantKeyStore,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, StorageError> {@@ -274,7 +274,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {state,diesel_payment_intent,merchant_key_store.key.get_inner(),- merchant_id.to_string(),+ merchant_id.to_owned().into(),).await.change_context(StorageError::DecryptionError)@@ -291,7 +291,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(&conn,- payment.merchant_id.as_str(),+ &payment.merchant_id,attempt_id.as_str(),).await@@ -311,7 +311,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {async fn filter_payment_intent_by_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFetchConstraints,merchant_key_store: &MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -331,7 +331,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {async fn filter_payment_intents_by_time_range_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &api_models::payments::TimeRange,merchant_key_store: &MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -351,7 +351,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {async fn get_filtered_payment_intents_attempt(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFetchConstraints,merchant_key_store: &MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -370,7 +370,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {#[cfg(feature = "olap")]async fn get_filtered_active_attempt_ids_for_total_count(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,constraints: &PaymentIntentFetchConstraints,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<String>, StorageError> {@@ -410,7 +410,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {state,diesel_payment_intent,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(StorageError::DecryptionError)@@ -443,7 +443,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {state,diesel_payment_intent,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(StorageError::DecryptionError)@@ -454,7 +454,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {&self,state: &KeyManagerState,payment_id: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,merchant_key_store: &MerchantKeyStore,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PaymentIntent, StorageError> {@@ -471,7 +471,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {state,diesel_payment_intent,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),).await.change_context(StorageError::DecryptionError)@@ -491,7 +491,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(&conn,- payment.merchant_id.as_str(),+ &payment.merchant_id,attempt_id.as_str(),).await@@ -512,7 +512,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {async fn filter_payment_intent_by_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PaymentIntentFetchConstraints,merchant_key_store: &MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -619,7 +619,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {state,diesel_payment_intent,merchant_key_store.key.get_inner(),- merchant_key_store.merchant_id.clone(),+ merchant_key_store.merchant_id.clone().into(),)})).map(|join_result| join_result.change_context(StorageError::DecryptionError))@@ -638,7 +638,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {async fn filter_payment_intents_by_time_range_constraints(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &api_models::payments::TimeRange,merchant_key_store: &MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -660,7 +660,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {async fn get_filtered_payment_intents_attempt(&self,state: &KeyManagerState,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,constraints: &PaymentIntentFetchConstraints,merchant_key_store: &MerchantKeyStore,storage_scheme: MerchantStorageScheme,@@ -811,7 +811,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {state,pi,merchant_key_store.key.get_inner(),- merchant_id.to_string(),+ merchant_id.to_owned().into(),).map(|payment_intent| {payment_intent.map(|payment_intent| {@@ -834,7 +834,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {#[instrument(skip_all)]async fn get_filtered_active_attempt_ids_for_total_count(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,constraints: &PaymentIntentFetchConstraints,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<String>, StorageError> {diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rsindex 5f04592596..b17ba1b6d7 100644--- a/crates/storage_impl/src/payouts/payout_attempt.rs+++ b/crates/storage_impl/src/payouts/payout_attempt.rs@@ -96,7 +96,8 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {let reverse_lookup = ReverseLookupNew {lookup_id: format!("poa_{}_{}",- &created_attempt.merchant_id, &created_attempt.payout_attempt_id,+ &created_attempt.merchant_id.get_string_repr(),+ &created_attempt.payout_attempt_id,),pk_id: key_str.clone(),sk_id: field.clone(),@@ -197,7 +198,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {add_connector_payout_id_to_reverse_lookup(self,key_str.as_str(),- this.merchant_id.as_str(),+ &this.merchant_id,updated_attempt.payout_attempt_id.as_str(),new.as_str(),storage_scheme,@@ -208,7 +209,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {add_connector_payout_id_to_reverse_lookup(self,key_str.as_str(),- this.merchant_id.as_str(),+ &this.merchant_id,updated_attempt.payout_attempt_id.as_str(),new.as_str(),storage_scheme,@@ -236,7 +237,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn find_payout_attempt_by_merchant_id_payout_attempt_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_attempt_id: &str,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PayoutAttempt, errors::StorageError> {@@ -253,7 +254,8 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {.await}MerchantStorageScheme::RedisKv => {- let lookup_id = format!("poa_{merchant_id}_{payout_attempt_id}");+ let lookup_id =+ format!("poa_{}_{payout_attempt_id}", merchant_id.get_string_repr());let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -296,7 +298,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn find_payout_attempt_by_merchant_id_connector_payout_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_payout_id: &str,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PayoutAttempt, errors::StorageError> {@@ -311,7 +313,10 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {.await}MerchantStorageScheme::RedisKv => {- let lookup_id = format!("po_conn_payout_{merchant_id}_{connector_payout_id}");+ let lookup_id = format!(+ "po_conn_payout_{}_{connector_payout_id}",+ merchant_id.get_string_repr()+ );let lookup = fallback_reverse_lookup_not_found!(self.get_lookup_by_lookup_id(&lookup_id, storage_scheme).await,@@ -355,7 +360,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {async fn get_filters_for_payouts(&self,payouts: &[Payouts],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PayoutListFilters, errors::StorageError> {self.router_store@@ -407,7 +412,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for crate::RouterStore<T> {#[instrument(skip_all)]async fn find_payout_attempt_by_merchant_id_payout_attempt_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_attempt_id: &str,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PayoutAttempt, errors::StorageError> {@@ -428,7 +433,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for crate::RouterStore<T> {#[instrument(skip_all)]async fn find_payout_attempt_by_merchant_id_connector_payout_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,connector_payout_id: &str,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<PayoutAttempt, errors::StorageError> {@@ -450,7 +455,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for crate::RouterStore<T> {async fn get_filters_for_payouts(&self,payouts: &[Payouts],- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,_storage_scheme: MerchantStorageScheme,) -> CustomResult<PayoutListFilters, errors::StorageError> {let conn = pg_connection_read(self).await?;@@ -639,14 +644,18 @@ impl DataModelExt for PayoutAttemptUpdate {async fn add_connector_payout_id_to_reverse_lookup<T: DatabaseStore>(store: &KVRouterStore<T>,key: &str,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,updated_attempt_attempt_id: &str,connector_payout_id: &str,storage_scheme: MerchantStorageScheme,) -> CustomResult<ReverseLookup, errors::StorageError> {let field = format!("poa_{}", updated_attempt_attempt_id);let reverse_lookup_new = ReverseLookupNew {- lookup_id: format!("po_conn_payout_{}_{}", merchant_id, connector_payout_id),+ lookup_id: format!(+ "po_conn_payout_{}_{}",+ merchant_id.get_string_repr(),+ connector_payout_id+ ),pk_id: key.to_owned(),sk_id: field.clone(),source: "payout_attempt".to_string(),diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rsindex 7a9dba0f20..eabe8f5db8 100644--- a/crates/storage_impl/src/payouts/payouts.rs+++ b/crates/storage_impl/src/payouts/payouts.rs@@ -192,7 +192,7 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn find_payout_by_merchant_id_payout_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Payouts, StorageError> {@@ -236,7 +236,7 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn find_optional_payout_by_merchant_id_payout_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Option<Payouts>, StorageError> {@@ -291,7 +291,7 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn filter_payouts_by_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PayoutFetchConstraints,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<Payouts>, StorageError> {@@ -304,7 +304,7 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {#[instrument(skip_all)]async fn filter_payouts_and_attempts(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PayoutFetchConstraints,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<(Payouts, PayoutAttempt, diesel_models::Customer)>, StorageError>@@ -318,7 +318,7 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {#[instrument[skip_all]]async fn filter_payouts_by_time_range_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &api_models::payments::TimeRange,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<Payouts>, StorageError> {@@ -370,7 +370,7 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {#[instrument(skip_all)]async fn find_payout_by_merchant_id_payout_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Payouts, StorageError> {@@ -387,7 +387,7 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {#[instrument(skip_all)]async fn find_optional_payout_by_merchant_id_payout_id(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,payout_id: &str,_storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Option<Payouts>, StorageError> {@@ -405,7 +405,7 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {#[instrument(skip_all)]async fn filter_payouts_by_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PayoutFetchConstraints,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<Payouts>, StorageError> {@@ -521,7 +521,7 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {#[instrument(skip_all)]async fn filter_payouts_and_attempts(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,filters: &PayoutFetchConstraints,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<(Payouts, PayoutAttempt, DieselCustomer)>, StorageError> {@@ -655,7 +655,7 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {#[instrument(skip_all)]async fn filter_payouts_by_time_range_constraints(&self,- merchant_id: &str,+ merchant_id: &common_utils::id_type::MerchantId,time_range: &api_models::payments::TimeRange,storage_scheme: MerchantStorageScheme,) -> error_stack::Result<Vec<Payouts>, StorageError> {diff --git a/crates/storage_impl/src/redis/kv_store.rs b/crates/storage_impl/src/redis/kv_store.rsindex c39e67eb84..b33deffda7 100644--- a/crates/storage_impl/src/redis/kv_store.rs+++ b/crates/storage_impl/src/redis/kv_store.rs@@ -24,26 +24,26 @@ pub trait KvStorePartition {#[derive(Clone)]pub enum PartitionKey<'a> {MerchantIdPaymentId {- merchant_id: &'a str,+ merchant_id: &'a common_utils::id_type::MerchantId,payment_id: &'a str,},CombinationKey {combination: &'a str,},MerchantIdCustomerId {- merchant_id: &'a str,+ merchant_id: &'a common_utils::id_type::MerchantId,customer_id: &'a str,},MerchantIdPayoutId {- merchant_id: &'a str,+ merchant_id: &'a common_utils::id_type::MerchantId,payout_id: &'a str,},MerchantIdPayoutAttemptId {- merchant_id: &'a str,+ merchant_id: &'a common_utils::id_type::MerchantId,payout_attempt_id: &'a str,},MerchantIdMandateId {- merchant_id: &'a str,+ merchant_id: &'a common_utils::id_type::MerchantId,mandate_id: &'a str,},}@@ -54,24 +54,39 @@ impl<'a> std::fmt::Display for PartitionKey<'a> {PartitionKey::MerchantIdPaymentId {merchant_id,payment_id,- } => f.write_str(&format!("mid_{merchant_id}_pid_{payment_id}")),+ } => f.write_str(&format!(+ "mid_{}_pid_{payment_id}",+ merchant_id.get_string_repr()+ )),PartitionKey::CombinationKey { combination } => f.write_str(combination),PartitionKey::MerchantIdCustomerId {merchant_id,customer_id,- } => f.write_str(&format!("mid_{merchant_id}_cust_{customer_id}")),+ } => f.write_str(&format!(+ "mid_{}_cust_{customer_id}",+ merchant_id.get_string_repr()+ )),PartitionKey::MerchantIdPayoutId {merchant_id,payout_id,- } => f.write_str(&format!("mid_{merchant_id}_po_{payout_id}")),+ } => f.write_str(&format!(+ "mid_{}_po_{payout_id}",+ merchant_id.get_string_repr()+ )),PartitionKey::MerchantIdPayoutAttemptId {merchant_id,payout_attempt_id,- } => f.write_str(&format!("mid_{merchant_id}_poa_{payout_attempt_id}")),+ } => f.write_str(&format!(+ "mid_{}_poa_{payout_attempt_id}",+ merchant_id.get_string_repr()+ )),PartitionKey::MerchantIdMandateId {merchant_id,mandate_id,- } => f.write_str(&format!("mid_{merchant_id}_mandate_{mandate_id}")),+ } => f.write_str(&format!(+ "mid_{}_mandate_{mandate_id}",+ merchant_id.get_string_repr()+ )),}}}diff --git a/justfile b/justfileindex 9b9ad5a854..bc63a81b83 100644--- a/justfile+++ b/justfile@@ -10,10 +10,6 @@ fmt *FLAGS:check_flags := '--all-targets'-# Check compilation of Rust code-check *FLAGS:- cargo check {{ check_flags }} {{ FLAGS }}-alias c := check# Check compilation of Rust code and catch common mistakes@@ -27,7 +23,7 @@ clippy *FLAGS:jq -r '[ ( .workspace_members | sort ) as $package_ids # Store workspace crate package IDs in `package_ids` array| .packages[] | select( IN(.id; $package_ids[]) ) | .features | keys[] ] | unique # Select all unique features from all workspace crates- | del( .[] | select( any( . ; . == ("v2", "merchant_account_v2", "payment_v2", "customer_v2") ) ) ) # Exclude some features from features list+ | del( .[] | select( any( . ; test("(([a-z_]+)_)?v2") ) ) ) # Exclude some features from features list| join(",") # Construct a comma-separated string of features for passing to `cargo`')"@@ -67,6 +63,22 @@ check_v2 *FLAGS:cargo clippy {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}set +x+check *FLAGS:+ #! /usr/bin/env bash+ set -euo pipefail++ FEATURES="$(cargo metadata --all-features --format-version 1 | \+ jq -r '+ [ ( .workspace_members | sort ) as $package_ids # Store workspace crate package IDs in `package_ids` array+ | .packages[] | select( IN(.id; $package_ids[]) ) | .features | keys[] ] | unique # Select all unique features from all workspace crates+ | del( .[] | select( any( . ; test("(([a-z_]+)_)?v2") ) ) ) # Exclude some features from features list+ | join(",") # Construct a comma-separated string of features for passing to `cargo`+ ')"++ set -x+ cargo clippy {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}+ set +x+alias cl := clippy# Build binaries