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: introduce a domain type for profile ID (#5687)
Sanchith Hegdeb63d723b8bd2
diff --git a/Cargo.lock b/Cargo.lockindex 5a8ebcc0f3..4a37b597d3 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2096,6 +2096,7 @@ name = "connector_configs"version = "0.1.0"dependencies = ["api_models",+ "common_utils","serde","serde_with","toml 0.8.12",diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.jsonindex bdbdd9aec7..125f15d868 100644--- a/api-reference-v2/openapi_spec.json+++ b/api-reference-v2/openapi_spec.json@@ -8445,7 +8445,8 @@},"profile_id": {"type": "string",- "description": "Identifier for the business profile, if not provided default will be chosen from merchant account"+ "description": "Identifier for the business profile, if not provided default will be chosen from merchant account",+ "maxLength": 64},"connector_account_details": {"allOf": [diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.jsonindex cfd2fe4350..fdc8c8ba87 100644--- a/api-reference/openapi_spec.json+++ b/api-reference/openapi_spec.json@@ -7786,7 +7786,7 @@},"profile_id": {"type": "string",- "description": "The default business profile that must be used for creating merchant accounts and payments",+ "description": "The identifier for business profile. This must be used for creating merchant accounts, payments and payouts","example": "pro_abcdefghijklmnopqrstuvwxyz","maxLength": 64},@@ -12510,7 +12510,7 @@},"default_profile": {"type": "string",- "description": "The default business profile that must be used for creating merchant accounts and payments\nTo unset this field, pass an empty string",+ "description": "The default business profile that must be used for creating merchant accounts and payments","nullable": true,"maxLength": 64},@@ -12548,7 +12548,8 @@"profile_id": {"type": "string","description": "Identifier for the business profile, if not provided default will be chosen from merchant account",- "nullable": true+ "nullable": true,+ "maxLength": 64},"connector_account_details": {"allOf": [diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex 18ad5dbf84..a23b891f65 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -330,9 +330,8 @@ pub struct MerchantAccountUpdate {pub frm_routing_algorithm: Option<serde_json::Value>,/// The default business profile that must be used for creating merchant accounts and payments- /// To unset this field, pass an empty string- #[schema(max_length = 64)]- pub default_profile: Option<String>,+ #[schema(max_length = 64, value_type = Option<String>)]+ pub default_profile: Option<id_type::ProfileId>,/// Default payment method collect link config#[schema(value_type = Option<BusinessCollectLinkConfig>)]@@ -526,8 +525,8 @@ pub struct MerchantAccountResponse {pub is_recon_enabled: bool,/// The default business profile that must be used for creating merchant accounts and payments- #[schema(max_length = 64)]- pub default_profile: Option<String>,+ #[schema(max_length = 64, value_type = Option<String>)]+ pub default_profile: Option<id_type::ProfileId>,/// Used to indicate the status of the recon module for a merchant account#[schema(value_type = ReconStatus, example = "not_requested")]@@ -699,7 +698,8 @@ pub struct MerchantConnectorCreate {pub connector_label: Option<String>,/// Identifier for the business profile, if not provided default will be chosen from merchant account- pub profile_id: String,+ #[schema(max_length = 64, value_type = String)]+ pub profile_id: id_type::ProfileId,/// An object containing the required details/credentials for a Connector account.#[schema(value_type = Option<MerchantConnectorDetails>,example = json!({ "auth_type": "HeaderKey","api_key": "Basic MyVerySecretApiKey" }))]@@ -829,7 +829,8 @@ pub struct MerchantConnectorCreate {pub connector_label: Option<String>,/// Identifier for the business profile, if not provided default will be chosen from merchant account- pub profile_id: Option<String>,+ #[schema(max_length = 64, value_type = Option<String>)]+ pub profile_id: Option<id_type::ProfileId>,/// An object containing the required details/credentials for a Connector account.#[schema(value_type = Option<MerchantConnectorDetails>,example = json!({ "auth_type": "HeaderKey","api_key": "Basic MyVerySecretApiKey" }))]@@ -1063,8 +1064,8 @@ pub struct MerchantConnectorResponse {pub id: String,/// Identifier for the business profile, if not provided default will be chosen from merchant account- #[schema(max_length = 64)]- pub profile_id: String,+ #[schema(max_length = 64, value_type = String)]+ pub profile_id: id_type::ProfileId,/// An object containing the required details/credentials for a Connector account.#[schema(value_type = Option<MerchantConnectorDetails>,example = json!({ "auth_type": "HeaderKey","api_key": "Basic MyVerySecretApiKey" }))]@@ -1170,8 +1171,8 @@ pub struct MerchantConnectorResponse {pub merchant_connector_id: String,/// Identifier for the business profile, if not provided default will be chosen from merchant account- #[schema(max_length = 64)]- pub profile_id: String,+ #[schema(max_length = 64, value_type = String)]+ pub profile_id: id_type::ProfileId,/// An object containing the required details/credentials for a Connector account.#[schema(value_type = Option<MerchantConnectorDetails>,example = json!({ "auth_type": "HeaderKey","api_key": "Basic MyVerySecretApiKey" }))]@@ -1294,8 +1295,8 @@ pub struct MerchantConnectorListResponse {pub merchant_connector_id: String,/// Identifier for the business profile, if not provided default will be chosen from merchant account- #[schema(max_length = 64)]- pub profile_id: String,+ #[schema(max_length = 64, value_type = String)]+ pub profile_id: id_type::ProfileId,/// An object containing the details about the payment methods that need to be enabled under this merchant connector account#[schema(example = json!([@@ -1403,8 +1404,8 @@ pub struct MerchantConnectorListResponse {pub id: String,/// Identifier for the business profile, if not provided default will be chosen from merchant account- #[schema(max_length = 64)]- pub profile_id: String,+ #[schema(max_length = 64, value_type = String)]+ pub profile_id: id_type::ProfileId,/// An object containing the details about the payment methods that need to be enabled under this merchant connector account#[schema(example = json!([@@ -2076,9 +2077,9 @@ pub struct BusinessProfileResponse {#[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")]- pub profile_id: String,+ /// The identifier for business profile. This must be used for creating merchant accounts, payments and payouts+ #[schema(max_length = 64, value_type = String, example = "pro_abcdefghijklmnopqrstuvwxyz")]+ pub profile_id: id_type::ProfileId,/// Name of the business profile#[schema(max_length = 64)]@@ -2193,8 +2194,8 @@ pub struct BusinessProfileResponse {pub merchant_id: id_type::MerchantId,/// The identifier for business profile. This must be used for creating merchant accounts, payments and payouts- #[schema(max_length = 64, example = "pro_abcdefghijklmnopqrstuvwxyz")]- pub id: String,+ #[schema(max_length = 64, value_type = String, example = "pro_abcdefghijklmnopqrstuvwxyz")]+ pub id: id_type::ProfileId,/// Name of the business profile#[schema(max_length = 64)]diff --git a/crates/api_models/src/connector_onboarding.rs b/crates/api_models/src/connector_onboarding.rsindex 1ed18392dc..de4b8843df 100644--- a/crates/api_models/src/connector_onboarding.rs+++ b/crates/api_models/src/connector_onboarding.rs@@ -15,7 +15,7 @@ pub enum ActionUrlResponse {#[derive(serde::Deserialize, serde::Serialize, Debug, Clone)]pub struct OnboardingSyncRequest {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub connector_id: String,pub connector: enums::Connector,}diff --git a/crates/api_models/src/disputes.rs b/crates/api_models/src/disputes.rsindex e4c38cef86..5e9db4cdfd 100644--- a/crates/api_models/src/disputes.rs+++ b/crates/api_models/src/disputes.rs@@ -44,7 +44,8 @@ pub struct DisputeResponse {#[serde(with = "common_utils::custom_serde::iso8601")]pub created_at: PrimitiveDateTime,/// The `profile_id` associated with the dispute- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<common_utils::id_type::ProfileId>,/// The `merchant_connector_id` of the connector / processor through which the dispute was processedpub merchant_connector_id: Option<String>,}@@ -109,7 +110,8 @@ pub struct DisputeListConstraints {/// limit on the number of objects to returnpub limit: Option<i64>,/// The identifier for business profile- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<common_utils::id_type::ProfileId>,/// status of the disputepub dispute_status: Option<DisputeStatus>,/// stage of the disputediff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 99735f5792..be657cb948 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -480,7 +480,8 @@ pub struct PaymentsRequest {/// The business profile to be used for this payment, if not passed the default business profile associated with the merchant account will be used. It is mandatory in case multiple business profiles have been set up.#[remove_in(PaymentsUpdateRequest, PaymentsConfirmRequest)]- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<id_type::ProfileId>,#[remove_in(PaymentsConfirmRequest)]#[schema(value_type = Option<RequestSurchargeDetails>)]@@ -3815,7 +3816,8 @@ pub struct PaymentsResponse {/// Details for Payment linkpub payment_link: Option<PaymentLinkResponse>,/// The business profile that is associated with this payment- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<id_type::ProfileId>,/// Details of surcharge applied on this paymentpub surcharge_details: Option<RequestSurchargeDetails>,@@ -4031,7 +4033,7 @@ pub struct PaymentListFilterConstraints {/// The identifier for paymentpub payment_id: Option<String>,/// The identifier for business profile- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,/// The identifier for customerpub customer_id: Option<id_type::CustomerId>,/// The limit on the number of objects. The default limit is 10 and max limit is 20diff --git a/crates/api_models/src/payouts.rs b/crates/api_models/src/payouts.rsindex 0010c2988e..b755a07d7f 100644--- a/crates/api_models/src/payouts.rs+++ b/crates/api_models/src/payouts.rs@@ -144,7 +144,8 @@ pub struct PayoutCreateRequest {pub payout_token: Option<String>,/// The business profile to use for this payout, especially if there are multiple business profiles associated with the account, otherwise default business profile associated with the merchant account will be used.- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<id_type::ProfileId>,/// The send method which will be required for processing payouts, check options for better understanding.#[schema(value_type = Option<PayoutSendPriority>, example = "instant")]@@ -481,7 +482,8 @@ pub struct PayoutCreateResponse {pub error_code: Option<String>,/// The business profile that is associated with this payout- pub profile_id: String,+ #[schema(value_type = String)]+ pub profile_id: id_type::ProfileId,/// Time when the payout was created#[schema(example = "2022-09-10T10:11:12Z")]@@ -685,7 +687,8 @@ pub struct PayoutListFilterConstraints {)]pub payout_id: Option<String>,/// The identifier for business profile- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<id_type::ProfileId>,/// The identifier for customer#[schema(value_type = Option<String>,example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]pub customer_id: Option<id_type::CustomerId>,diff --git a/crates/api_models/src/refunds.rs b/crates/api_models/src/refunds.rsindex dd6f1a2250..656416dce9 100644--- a/crates/api_models/src/refunds.rs+++ b/crates/api_models/src/refunds.rs@@ -156,7 +156,8 @@ pub struct RefundResponse {#[schema(example = "stripe")]pub connector: String,/// The id of business profile for this refund- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<common_utils::id_type::ProfileId>,/// The merchant_connector_id of the processor through which this payment went throughpub merchant_connector_id: Option<String>,/// Charge specific fields for controlling the revert of funds from either platform or connected account@@ -171,7 +172,8 @@ pub struct RefundListRequest {/// The identifier for the refundpub refund_id: Option<String>,/// The identifier for business profile- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<common_utils::id_type::ProfileId>,/// Limit on the number of objects to returnpub limit: Option<i64>,/// The starting point within a list of objectsdiff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rsindex 2c52f726c8..04a58aed0d 100644--- a/crates/api_models/src/routing.rs+++ b/crates/api_models/src/routing.rs@@ -36,7 +36,8 @@ pub struct RoutingConfigRequest {pub name: String,pub description: String,pub algorithm: RoutingAlgorithm,- pub profile_id: String,+ #[schema(value_type = String)]+ pub profile_id: common_utils::id_type::ProfileId,}#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "routing_v2")))]@@ -45,12 +46,14 @@ pub struct RoutingConfigRequest {pub name: Option<String>,pub description: Option<String>,pub algorithm: Option<RoutingAlgorithm>,- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<common_utils::id_type::ProfileId>,}#[derive(Debug, serde::Serialize, ToSchema)]pub struct ProfileDefaultRoutingConfig {- pub profile_id: String,+ #[schema(value_type = String)]+ pub profile_id: common_utils::id_type::ProfileId,pub connectors: Vec<RoutableConnectorChoice>,}@@ -62,13 +65,13 @@ pub struct RoutingRetrieveQuery {#[derive(Debug, serde::Deserialize, serde::Serialize)]pub struct RoutingRetrieveLinkQuery {- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,}#[derive(Debug, serde::Deserialize, serde::Serialize)]pub struct RoutingRetrieveLinkQueryWrapper {pub routing_query: RoutingRetrieveQuery,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]/// Response of the retrieved routing configs for a merchant account@@ -87,7 +90,8 @@ pub enum LinkedRoutingConfigRetrieveResponse {/// Routing Algorithm specific to merchantspub struct MerchantRoutingAlgorithm {pub id: String,- pub profile_id: String,+ #[schema(value_type = String)]+ pub profile_id: common_utils::id_type::ProfileId,pub name: String,pub description: String,pub algorithm: RoutingAlgorithm,@@ -257,10 +261,9 @@ pub enum RoutingAlgorithmKind {}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]-pub struct RoutingPayloadWrapper {pub updated_config: Vec<RoutableConnectorChoice>,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]@@ -453,8 +456,8 @@ impl RoutingAlgorithmRef {pub struct RoutingDictionaryRecord {pub id: String,-- pub profile_id: String,+ #[schema(value_type = String)]+ pub profile_id: common_utils::id_type::ProfileId,pub name: String,pub kind: RoutingAlgorithmKind,pub description: String,@@ -485,6 +488,6 @@ pub struct RoutingAlgorithmId {#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]pub struct RoutingLinkWrapper {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub algorithm_id: RoutingAlgorithmId,}diff --git a/crates/api_models/src/user.rs b/crates/api_models/src/user.rsindex 9867aba7b3..1fdf47425e 100644--- a/crates/api_models/src/user.rs+++ b/crates/api_models/src/user.rs@@ -405,6 +405,6 @@ pub struct ListMerchantsForUserInOrgResponse {#[derive(Debug, serde::Serialize)]pub struct ListProfilesForUserInOrgAndMerchantAccountResponse {- pub profile_id: String,+ pub profile_id: id_type::ProfileId,pub profile_name: String,}diff --git a/crates/api_models/src/user/sample_data.rs b/crates/api_models/src/user/sample_data.rsindex 6d20b20f36..dc95de913f 100644--- a/crates/api_models/src/user/sample_data.rs+++ b/crates/api_models/src/user/sample_data.rs@@ -19,5 +19,5 @@ pub struct SampleDataRequest {pub auth_type: Option<Vec<AuthenticationType>>,pub business_country: Option<CountryAlpha2>,pub business_label: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,}diff --git a/crates/api_models/src/webhook_events.rs b/crates/api_models/src/webhook_events.rsindex fa61cc0f25..f9741147cd 100644--- a/crates/api_models/src/webhook_events.rs+++ b/crates/api_models/src/webhook_events.rs@@ -26,7 +26,8 @@ pub struct EventListConstraints {pub object_id: Option<String>,/// Filter all events associated with the specified business profile ID.- pub profile_id: Option<String>,+ #[schema(value_type = Option<String>)]+ pub profile_id: Option<common_utils::id_type::ProfileId>,}#[derive(Debug)]@@ -54,8 +55,8 @@ pub struct EventListItemResponse {pub merchant_id: common_utils::id_type::MerchantId,/// The identifier for the Business Profile.- #[schema(max_length = 64, example = "SqB0zwDGR5wHppWf0bx7GKr1f2")]- pub profile_id: String,+ #[schema(max_length = 64, value_type = String, example = "SqB0zwDGR5wHppWf0bx7GKr1f2")]+ pub profile_id: common_utils::id_type::ProfileId,/// The identifier for the object (Payment Intent ID, Refund ID, etc.)#[schema(max_length = 64, example = "QHrfd5LUDdZaKtAjdJmMu0dMa1")]diff --git a/crates/common_utils/src/events.rs b/crates/common_utils/src/events.rsindex 4377714396..48b2e9d98c 100644--- a/crates/common_utils/src/events.rs+++ b/crates/common_utils/src/events.rs@@ -35,6 +35,9 @@ pub enum ApiEventsType {Customer {customer_id: id_type::CustomerId,},+ BusinessProfile {+ profile_id: id_type::ProfileId,+ },User {user_id: String,},diff --git a/crates/common_utils/src/id_type.rs b/crates/common_utils/src/id_type.rsindex 55e2e3ffb1..cc4c56d6ab 100644--- a/crates/common_utils/src/id_type.rs+++ b/crates/common_utils/src/id_type.rs@@ -6,6 +6,7 @@ use std::{borrow::Cow, fmt::Debug};mod customer;mod merchant;mod organization;+mod profile;mod global_id;@@ -19,6 +20,7 @@ use diesel::{};pub use merchant::MerchantId;pub use organization::OrganizationId;+pub use profile::ProfileId;use serde::{Deserialize, Serialize};use thiserror::Error;@@ -198,6 +200,12 @@ where}}+/// An interface to generate object identifiers.+pub trait GenerateId {+ /// Generates a random object identifier.+ fn generate() -> Self;+}+#[cfg(test)]mod alphanumeric_id_tests {#![allow(clippy::unwrap_used)]diff --git a/crates/common_utils/src/id_type/customer.rs b/crates/common_utils/src/id_type/customer.rsindex 6504912596..9d02f20138 100644--- a/crates/common_utils/src/id_type/customer.rs+++ b/crates/common_utils/src/id_type/customer.rs@@ -9,6 +9,7 @@ crate::impl_debug_id_type!(CustomerId);crate::impl_default_id_type!(CustomerId, "cus");crate::impl_try_from_cow_str_id_type!(CustomerId, "customer_id");+crate::impl_generate_id_id_type!(CustomerId, "cus");crate::impl_serializable_secret_id_type!(CustomerId);crate::impl_queryable_id_type!(CustomerId);crate::impl_to_sql_from_sql_id_type!(CustomerId);diff --git a/crates/common_utils/src/id_type/merchant.rs b/crates/common_utils/src/id_type/merchant.rsindex 8358f39051..08b80249ae 100644--- a/crates/common_utils/src/id_type/merchant.rs+++ b/crates/common_utils/src/id_type/merchant.rs@@ -25,6 +25,7 @@ crate::impl_debug_id_type!(MerchantId);crate::impl_default_id_type!(MerchantId, "mer");crate::impl_try_from_cow_str_id_type!(MerchantId, "merchant_id");+crate::impl_generate_id_id_type!(MerchantId, "mer");crate::impl_serializable_secret_id_type!(MerchantId);crate::impl_queryable_id_type!(MerchantId);crate::impl_to_sql_from_sql_id_type!(MerchantId);diff --git a/crates/common_utils/src/id_type/organization.rs b/crates/common_utils/src/id_type/organization.rsindex 336442e605..f88a62daa1 100644--- a/crates/common_utils/src/id_type/organization.rs+++ b/crates/common_utils/src/id_type/organization.rs@@ -9,6 +9,7 @@ crate::impl_debug_id_type!(OrganizationId);crate::impl_default_id_type!(OrganizationId, "org");crate::impl_try_from_cow_str_id_type!(OrganizationId, "organization_id");+crate::impl_generate_id_id_type!(OrganizationId, "org");crate::impl_serializable_secret_id_type!(OrganizationId);crate::impl_queryable_id_type!(OrganizationId);crate::impl_to_sql_from_sql_id_type!(OrganizationId);diff --git a/crates/common_utils/src/id_type/profile.rs b/crates/common_utils/src/id_type/profile.rsnew file mode 100644index 0000000000..e9d90e7bba--- /dev/null+++ b/crates/common_utils/src/id_type/profile.rs@@ -0,0 +1,22 @@+crate::id_type!(+ ProfileId,+ "A type for profile_id that can be used for business profile ids"+);+crate::impl_id_type_methods!(ProfileId, "profile_id");++// This is to display the `ProfileId` as ProfileId(abcd)+crate::impl_debug_id_type!(ProfileId);+crate::impl_try_from_cow_str_id_type!(ProfileId, "profile_id");++crate::impl_generate_id_id_type!(ProfileId, "pro");+crate::impl_serializable_secret_id_type!(ProfileId);+crate::impl_queryable_id_type!(ProfileId);+crate::impl_to_sql_from_sql_id_type!(ProfileId);++impl crate::events::ApiEventMetric for ProfileId {+ fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> {+ Some(crate::events::ApiEventsType::BusinessProfile {+ profile_id: self.clone(),+ })+ }+}diff --git a/crates/common_utils/src/lib.rs b/crates/common_utils/src/lib.rsindex 400da34998..67a67bee5c 100644--- a/crates/common_utils/src/lib.rs+++ b/crates/common_utils/src/lib.rs@@ -214,12 +214,23 @@ fn generate_ref_id_with_default_length<const MAX_LENGTH: u8, const MIN_LENGTH: u/// Generate a customer id with default length, with prefix as `cus`pub fn generate_customer_id_of_default_length() -> id_type::CustomerId {- id_type::CustomerId::default()+ use id_type::GenerateId;++ id_type::CustomerId::generate()}/// Generate a organization id with default length, with prefix as `org`pub fn generate_organization_id_of_default_length() -> id_type::OrganizationId {- id_type::OrganizationId::default()+ use id_type::GenerateId;++ id_type::OrganizationId::generate()+}++/// Generate a profile id with default length, with prefix as `pro`+pub fn generate_profile_id_of_default_length() -> id_type::ProfileId {+ use id_type::GenerateId;++ id_type::ProfileId::generate()}/// Generate a nanoid with the given prefix and a default lengthdiff --git a/crates/common_utils/src/macros.rs b/crates/common_utils/src/macros.rsindex 06554ee9b5..94d8074c30 100644--- a/crates/common_utils/src/macros.rs+++ b/crates/common_utils/src/macros.rs@@ -233,6 +233,18 @@ mod id_type {};}+ /// Implements the `GenerateId` trait on the specified ID type.+ #[macro_export]+ macro_rules! impl_generate_id_id_type {+ ($type:ty, $prefix:literal) => {+ impl $crate::id_type::GenerateId for $type {+ fn generate() -> Self {+ Self($crate::generate_ref_id_with_default_length($prefix))+ }+ }+ };+ }+/// Implements the `SerializableSecret` trait on the specified ID type.#[macro_export]macro_rules! impl_serializable_secret_id_type {diff --git a/crates/connector_configs/Cargo.toml b/crates/connector_configs/Cargo.tomlindex 1541a0864c..1809d75583 100644--- a/crates/connector_configs/Cargo.toml+++ b/crates/connector_configs/Cargo.toml@@ -17,6 +17,7 @@ payouts = ["api_models/payouts"][dependencies]# First party cratesapi_models = { version = "0.1.0", path = "../api_models", package = "api_models" }+common_utils = { version = "0.1.0", path = "../common_utils" }# Third party cratesserde = { version = "1.0.197", features = ["derive"] }diff --git a/crates/connector_configs/src/common_config.rs b/crates/connector_configs/src/common_config.rsindex 88b8165853..d0becb8046 100644--- a/crates/connector_configs/src/common_config.rs+++ b/crates/connector_configs/src/common_config.rs@@ -161,7 +161,7 @@ pub struct Provider {#[serde(rename_all = "snake_case")]pub struct ConnectorApiIntegrationPayload {pub connector_type: String,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub connector_name: api_models::enums::Connector,#[serde(skip_deserializing)]#[schema(example = "stripe_US_travel")]diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rsindex cb518805eb..606644255b 100644--- a/crates/diesel_models/src/authentication.rs+++ b/crates/diesel_models/src/authentication.rs@@ -41,7 +41,7 @@ pub struct Authentication {pub acs_reference_number: Option<String>,pub acs_trans_id: Option<String>,pub acs_signed_content: Option<String>,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub payment_id: Option<String>,pub merchant_connector_id: String,pub ds_trans_id: Option<String>,@@ -88,7 +88,7 @@ pub struct AuthenticationNew {pub acs_reference_number: Option<String>,pub acs_trans_id: Option<String>,pub acs_signed_content: Option<String>,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub payment_id: Option<String>,pub merchant_connector_id: String,pub ds_trans_id: Option<String>,diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rsindex cab1aec410..20add83bd2 100644--- a/crates/diesel_models/src/business_profile.rs+++ b/crates/diesel_models/src/business_profile.rs@@ -25,7 +25,7 @@ use crate::schema_v2::business_profile;#[derive(Clone, Debug, Identifiable, Queryable, Selectable, router_derive::DebugAsDisplay)]#[diesel(table_name = business_profile, primary_key(profile_id), check_for_backend(diesel::pg::Pg))]pub struct BusinessProfile {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_id: common_utils::id_type::MerchantId,pub profile_name: String,pub created_at: time::PrimitiveDateTime,@@ -67,7 +67,7 @@ pub struct BusinessProfile {#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]#[diesel(table_name = business_profile, primary_key(profile_id))]pub struct BusinessProfileNew {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_id: common_utils::id_type::MerchantId,pub profile_name: String,pub created_at: time::PrimitiveDateTime,@@ -242,7 +242,7 @@ impl BusinessProfileUpdateInternal {#[derive(Clone, Debug, Identifiable, Queryable, Selectable, router_derive::DebugAsDisplay)]#[diesel(table_name = business_profile, primary_key(profile_id), check_for_backend(diesel::pg::Pg))]pub struct BusinessProfile {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_id: common_utils::id_type::MerchantId,pub profile_name: String,pub created_at: time::PrimitiveDateTime,@@ -283,7 +283,7 @@ pub struct BusinessProfile {#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]#[diesel(table_name = business_profile, primary_key(profile_id))]pub struct BusinessProfileNew {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_id: common_utils::id_type::MerchantId,pub profile_name: String,pub created_at: time::PrimitiveDateTime,diff --git a/crates/diesel_models/src/dispute.rs b/crates/diesel_models/src/dispute.rsindex 704b1781e2..14fe16c982 100644--- a/crates/diesel_models/src/dispute.rs+++ b/crates/diesel_models/src/dispute.rs@@ -27,7 +27,7 @@ pub struct DisputeNew {pub connector_updated_at: Option<PrimitiveDateTime>,pub connector: String,pub evidence: Option<Secret<serde_json::Value>>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub merchant_connector_id: Option<String>,pub dispute_amount: i64,}@@ -56,7 +56,7 @@ pub struct Dispute {pub modified_at: PrimitiveDateTime,pub connector: String,pub evidence: Secret<serde_json::Value>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub merchant_connector_id: Option<String>,pub dispute_amount: i64,}diff --git a/crates/diesel_models/src/events.rs b/crates/diesel_models/src/events.rsindex 20c811654a..2cc2bfff3b 100644--- a/crates/diesel_models/src/events.rs+++ b/crates/diesel_models/src/events.rs@@ -22,7 +22,7 @@ pub struct EventNew {pub primary_object_type: storage_enums::EventObjectType,pub created_at: PrimitiveDateTime,pub merchant_id: Option<common_utils::id_type::MerchantId>,- pub business_profile_id: Option<String>,+ pub business_profile_id: Option<common_utils::id_type::ProfileId>,pub primary_object_created_at: Option<PrimitiveDateTime>,pub idempotent_event_id: Option<String>,pub initial_attempt_id: Option<String>,@@ -51,7 +51,7 @@ pub struct Event {#[serde(with = "custom_serde::iso8601")]pub created_at: PrimitiveDateTime,pub merchant_id: Option<common_utils::id_type::MerchantId>,- pub business_profile_id: Option<String>,+ pub business_profile_id: Option<common_utils::id_type::ProfileId>,// This column can be used to partition the database table, so that all events related to a// single object would reside in the same partitionpub primary_object_created_at: Option<PrimitiveDateTime>,diff --git a/crates/diesel_models/src/file.rs b/crates/diesel_models/src/file.rsindex e5ad3568d7..523bb1f26e 100644--- a/crates/diesel_models/src/file.rs+++ b/crates/diesel_models/src/file.rs@@ -17,7 +17,7 @@ pub struct FileMetadataNew {pub file_upload_provider: Option<common_enums::FileUploadProvider>,pub available: bool,pub connector_label: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub merchant_connector_id: Option<String>,}@@ -36,7 +36,7 @@ pub struct FileMetadata {#[serde(with = "custom_serde::iso8601")]pub created_at: time::PrimitiveDateTime,pub connector_label: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub merchant_connector_id: Option<String>,}@@ -46,7 +46,7 @@ pub enum FileMetadataUpdate {provider_file_id: Option<String>,file_upload_provider: Option<common_enums::FileUploadProvider>,available: bool,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,merchant_connector_id: Option<String>,},}@@ -57,7 +57,7 @@ pub struct FileMetadataUpdateInternal {provider_file_id: Option<String>,file_upload_provider: Option<common_enums::FileUploadProvider>,available: bool,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,merchant_connector_id: Option<String>,}diff --git a/crates/diesel_models/src/merchant_account.rs b/crates/diesel_models/src/merchant_account.rsindex b3ef64b3e3..ac7635e88c 100644--- a/crates/diesel_models/src/merchant_account.rs+++ b/crates/diesel_models/src/merchant_account.rs@@ -52,7 +52,7 @@ pub struct MerchantAccount {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 default_profile: Option<common_utils::id_type::ProfileId>,pub recon_status: storage_enums::ReconStatus,pub payment_link_config: Option<serde_json::Value>,pub pm_collect_link_config: Option<serde_json::Value>,@@ -87,7 +87,7 @@ pub struct MerchantAccountSetter {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 default_profile: Option<common_utils::id_type::ProfileId>,pub recon_status: storage_enums::ReconStatus,pub payment_link_config: Option<serde_json::Value>,pub pm_collect_link_config: Option<serde_json::Value>,@@ -241,7 +241,7 @@ pub struct MerchantAccountNew {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 default_profile: Option<common_utils::id_type::ProfileId>,pub recon_status: storage_enums::ReconStatus,pub payment_link_config: Option<serde_json::Value>,pub pm_collect_link_config: Option<serde_json::Value>,@@ -306,7 +306,7 @@ pub struct MerchantAccountUpdateInternal {pub payout_routing_algorithm: Option<serde_json::Value>,pub organization_id: Option<common_utils::id_type::OrganizationId>,pub is_recon_enabled: Option<bool>,- pub default_profile: Option<Option<String>>,+ pub default_profile: Option<Option<common_utils::id_type::ProfileId>>,pub recon_status: Option<storage_enums::ReconStatus>,pub payment_link_config: Option<serde_json::Value>,pub pm_collect_link_config: Option<serde_json::Value>,diff --git a/crates/diesel_models/src/merchant_connector_account.rs b/crates/diesel_models/src/merchant_connector_account.rsindex 876240f44a..61f2af238e 100644--- a/crates/diesel_models/src/merchant_connector_account.rs+++ b/crates/diesel_models/src/merchant_connector_account.rs@@ -48,7 +48,7 @@ pub struct MerchantConnectorAccount {pub connector_webhook_details: Option<pii::SecretSerdeValue>,#[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]pub frm_config: Option<Vec<pii::SecretSerdeValue>>,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,#[diesel(deserialize_as = super::OptionalDieselArray<String>)]pub applepay_verified_domains: Option<Vec<String>>,pub pm_auth_config: Option<pii::SecretSerdeValue>,@@ -95,7 +95,7 @@ pub struct MerchantConnectorAccount {pub connector_webhook_details: Option<pii::SecretSerdeValue>,#[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]pub frm_config: Option<Vec<pii::SecretSerdeValue>>,- pub profile_id: String,+ pub profile_id: id_type::ProfileId,#[diesel(deserialize_as = super::OptionalDieselArray<String>)]pub applepay_verified_domains: Option<Vec<String>>,pub pm_auth_config: Option<pii::SecretSerdeValue>,@@ -139,7 +139,7 @@ pub struct MerchantConnectorAccountNew {pub connector_webhook_details: Option<pii::SecretSerdeValue>,#[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]pub frm_config: Option<Vec<pii::SecretSerdeValue>>,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,#[diesel(deserialize_as = super::OptionalDieselArray<String>)]pub applepay_verified_domains: Option<Vec<String>>,pub pm_auth_config: Option<pii::SecretSerdeValue>,@@ -166,7 +166,7 @@ pub struct MerchantConnectorAccountNew {pub connector_webhook_details: Option<pii::SecretSerdeValue>,#[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]pub frm_config: Option<Vec<pii::SecretSerdeValue>>,- pub profile_id: String,+ pub profile_id: id_type::ProfileId,#[diesel(deserialize_as = super::OptionalDieselArray<String>)]pub applepay_verified_domains: Option<Vec<String>>,pub pm_auth_config: Option<pii::SecretSerdeValue>,diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rsindex bdea1fe52a..7bd1652ab5 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -47,7 +47,7 @@ pub struct PaymentIntent {pub connector_metadata: Option<serde_json::Value>,pub feature_metadata: Option<serde_json::Value>,pub attempt_count: i16,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,// Denotes the action(approve or reject) taken by merchant in case of manual review.// Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto paymentpub merchant_decision: Option<String>,@@ -108,7 +108,7 @@ pub struct PaymentIntent {pub connector_metadata: Option<serde_json::Value>,pub feature_metadata: Option<serde_json::Value>,pub attempt_count: i16,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,// Denotes the action(approve or reject) taken by merchant in case of manual review.// Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto paymentpub merchant_decision: Option<String>,@@ -170,7 +170,7 @@ pub struct PaymentIntentNew {pub connector_metadata: Option<serde_json::Value>,pub feature_metadata: Option<serde_json::Value>,pub attempt_count: i16,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub merchant_decision: Option<String>,pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,diff --git a/crates/diesel_models/src/payment_link.rs b/crates/diesel_models/src/payment_link.rsindex 347a730eb6..51e3b89d60 100644--- a/crates/diesel_models/src/payment_link.rs+++ b/crates/diesel_models/src/payment_link.rs@@ -23,7 +23,7 @@ pub struct PaymentLink {pub custom_merchant_name: Option<String>,pub payment_link_config: Option<serde_json::Value>,pub description: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub secure_link: Option<String>,}@@ -54,6 +54,6 @@ pub struct PaymentLinkNew {pub custom_merchant_name: Option<String>,pub payment_link_config: Option<serde_json::Value>,pub description: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub secure_link: Option<String>,}diff --git a/crates/diesel_models/src/payout_attempt.rs b/crates/diesel_models/src/payout_attempt.rsindex 17600e0cd7..7e9b2ec4e1 100644--- a/crates/diesel_models/src/payout_attempt.rs+++ b/crates/diesel_models/src/payout_attempt.rs@@ -27,7 +27,7 @@ pub struct PayoutAttempt {pub created_at: PrimitiveDateTime,#[serde(with = "common_utils::custom_serde::iso8601")]pub last_modified_at: PrimitiveDateTime,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_connector_id: Option<String>,pub routing_info: Option<serde_json::Value>,}@@ -59,11 +59,11 @@ pub struct PayoutAttemptNew {pub error_code: Option<String>,pub business_country: Option<storage_enums::CountryAlpha2>,pub business_label: Option<String>,- #[serde(default, with = "common_utils::custom_serde::iso8601::option")]- pub created_at: Option<PrimitiveDateTime>,- #[serde(default, with = "common_utils::custom_serde::iso8601::option")]- pub last_modified_at: Option<PrimitiveDateTime>,- pub profile_id: String,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub created_at: PrimitiveDateTime,+ #[serde(with = "common_utils::custom_serde::iso8601")]+ pub last_modified_at: PrimitiveDateTime,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_connector_id: Option<String>,pub routing_info: Option<serde_json::Value>,}diff --git a/crates/diesel_models/src/payouts.rs b/crates/diesel_models/src/payouts.rsindex cb8f6f9a88..8acdc4a0a5 100644--- a/crates/diesel_models/src/payouts.rs+++ b/crates/diesel_models/src/payouts.rs@@ -31,7 +31,7 @@ pub struct Payouts {#[serde(with = "common_utils::custom_serde::iso8601")]pub last_modified_at: PrimitiveDateTime,pub attempt_count: i16,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub status: storage_enums::PayoutStatus,pub confirm: Option<bool>,pub payout_link_id: Option<String>,@@ -72,7 +72,7 @@ pub struct PayoutsNew {#[serde(with = "common_utils::custom_serde::iso8601")]pub last_modified_at: PrimitiveDateTime,pub attempt_count: i16,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub status: storage_enums::PayoutStatus,pub confirm: Option<bool>,pub payout_link_id: Option<String>,@@ -92,7 +92,7 @@ pub enum PayoutsUpdate {return_url: Option<String>,entity_type: storage_enums::PayoutEntityType,metadata: Option<pii::SecretSerdeValue>,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,status: Option<storage_enums::PayoutStatus>,confirm: Option<bool>,payout_type: Option<storage_enums::PayoutType>,@@ -126,7 +126,7 @@ pub struct PayoutsUpdateInternal {pub entity_type: Option<storage_enums::PayoutEntityType>,pub metadata: Option<pii::SecretSerdeValue>,pub payout_method_id: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub status: Option<storage_enums::PayoutStatus>,pub last_modified_at: PrimitiveDateTime,pub attempt_count: Option<i16>,diff --git a/crates/diesel_models/src/query/business_profile.rs b/crates/diesel_models/src/query/business_profile.rsindex fb80449cdc..807648b5dc 100644--- a/crates/diesel_models/src/query/business_profile.rs+++ b/crates/diesel_models/src/query/business_profile.rs@@ -40,7 +40,10 @@ impl BusinessProfile {}}- pub async fn find_by_profile_id(conn: &PgPooledConn, profile_id: &str) -> StorageResult<Self> {+ pub async fn find_by_profile_id(+ conn: &PgPooledConn,+ profile_id: &common_utils::id_type::ProfileId,+ ) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,dsl::profile_id.eq(profile_id.to_owned()),@@ -51,7 +54,7 @@ impl BusinessProfile {pub async fn find_by_merchant_id_profile_id(conn: &PgPooledConn,merchant_id: &common_utils::id_type::MerchantId,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -97,7 +100,7 @@ impl BusinessProfile {pub async fn delete_by_profile_id_merchant_id(conn: &PgPooledConn,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,merchant_id: &common_utils::id_type::MerchantId,) -> StorageResult<bool> {generics::generic_delete::<<Self as HasTable>::Table, _>(diff --git a/crates/diesel_models/src/query/events.rs b/crates/diesel_models/src/query/events.rsindex 8b2a1a001f..34222e6e7d 100644--- a/crates/diesel_models/src/query/events.rs+++ b/crates/diesel_models/src/query/events.rs@@ -118,7 +118,7 @@ impl Event {pub async fn list_initial_attempts_by_profile_id_primary_object_id(conn: &PgPooledConn,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,primary_object_id: &str,) -> StorageResult<Vec<Self>> {generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(@@ -137,7 +137,7 @@ impl Event {pub async fn list_initial_attempts_by_profile_id_constraints(conn: &PgPooledConn,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,created_after: Option<time::PrimitiveDateTime>,created_before: Option<time::PrimitiveDateTime>,limit: Option<i64>,@@ -187,7 +187,7 @@ impl Event {pub async fn list_by_profile_id_initial_attempt_id(conn: &PgPooledConn,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,initial_attempt_id: &str,) -> 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 e4dcdba597..7eeddd5d59 100644--- a/crates/diesel_models/src/query/merchant_connector_account.rs+++ b/crates/diesel_models/src/query/merchant_connector_account.rs@@ -78,7 +78,7 @@ impl MerchantConnectorAccount {pub async fn find_by_profile_id_connector_name(conn: &PgPooledConn,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,connector_name: &str,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(diff --git a/crates/diesel_models/src/query/routing_algorithm.rs b/crates/diesel_models/src/query/routing_algorithm.rsindex 0f3b709d26..f0fc75430e 100644--- a/crates/diesel_models/src/query/routing_algorithm.rs+++ b/crates/diesel_models/src/query/routing_algorithm.rs@@ -34,7 +34,7 @@ impl RoutingAlgorithm {pub async fn find_by_algorithm_id_profile_id(conn: &PgPooledConn,algorithm_id: &str,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> StorageResult<Self> {generics::generic_find_one::<<Self as HasTable>::Table, _, _>(conn,@@ -48,7 +48,7 @@ impl RoutingAlgorithm {pub async fn find_metadata_by_algorithm_id_profile_id(conn: &PgPooledConn,algorithm_id: &str,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> StorageResult<RoutingProfileMetadata> {Self::table().select((@@ -68,7 +68,7 @@ impl RoutingAlgorithm {).limit(1).load_async::<(- String,+ common_utils::id_type::ProfileId,String,String,Option<String>,@@ -109,7 +109,7 @@ impl RoutingAlgorithm {pub async fn list_metadata_by_profile_id(conn: &PgPooledConn,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,limit: i64,offset: i64,) -> StorageResult<Vec<RoutingProfileMetadata>> {@@ -129,7 +129,7 @@ impl RoutingAlgorithm {.offset(offset).load_async::<(String,- String,+ common_utils::id_type::ProfileId,String,Option<String>,enums::RoutingAlgorithmKind,@@ -188,7 +188,7 @@ impl RoutingAlgorithm {.offset(offset).order(dsl::modified_at.desc()).load_async::<(- String,+ common_utils::id_type::ProfileId,String,String,Option<String>,@@ -250,7 +250,7 @@ impl RoutingAlgorithm {.offset(offset).order(dsl::modified_at.desc()).load_async::<(- String,+ common_utils::id_type::ProfileId,String,String,Option<String>,diff --git a/crates/diesel_models/src/query/user_role.rs b/crates/diesel_models/src/query/user_role.rsindex b4789b3c16..7904d3c264 100644--- a/crates/diesel_models/src/query/user_role.rs+++ b/crates/diesel_models/src/query/user_role.rs@@ -83,7 +83,7 @@ impl UserRole {user_id: String,org_id: id_type::OrganizationId,merchant_id: id_type::MerchantId,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,version: UserRoleVersion,) -> StorageResult<Self> {// Checking in user roles, for a user in token hierarchy, only one of the relation will be true, either org level, merchant level or profile level@@ -116,7 +116,7 @@ impl UserRole {user_id: String,org_id: id_type::OrganizationId,merchant_id: id_type::MerchantId,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,update: UserRoleUpdate,version: UserRoleVersion,) -> StorageResult<Self> {@@ -156,7 +156,7 @@ impl UserRole {user_id: String,org_id: id_type::OrganizationId,merchant_id: id_type::MerchantId,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,version: UserRoleVersion,) -> StorageResult<Self> {// Checking in user roles, for a user in token hierarchy, only one of the relation will be true, either org level, merchant level or profile level@@ -190,7 +190,7 @@ impl UserRole {user_id: String,org_id: Option<id_type::OrganizationId>,merchant_id: Option<id_type::MerchantId>,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,entity_id: Option<String>,version: Option<UserRoleVersion>,) -> StorageResult<Vec<Self>> {diff --git a/crates/diesel_models/src/refund.rs b/crates/diesel_models/src/refund.rsindex e4a74a6d66..3b73a60367 100644--- a/crates/diesel_models/src/refund.rs+++ b/crates/diesel_models/src/refund.rs@@ -46,7 +46,7 @@ pub struct Refund {pub attempt_id: String,pub refund_reason: Option<String>,pub refund_error_code: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub updated_by: String,pub merchant_connector_id: Option<String>,pub charges: Option<ChargeRefunds>,@@ -88,7 +88,7 @@ pub struct RefundNew {pub description: Option<String>,pub attempt_id: String,pub refund_reason: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<common_utils::id_type::ProfileId>,pub updated_by: String,pub merchant_connector_id: Option<String>,pub charges: Option<ChargeRefunds>,diff --git a/crates/diesel_models/src/routing_algorithm.rs b/crates/diesel_models/src/routing_algorithm.rsindex e2566783e9..6be0be3d5e 100644--- a/crates/diesel_models/src/routing_algorithm.rs+++ b/crates/diesel_models/src/routing_algorithm.rs@@ -7,7 +7,7 @@ use crate::{enums, schema::routing_algorithm};#[diesel(table_name = routing_algorithm, primary_key(algorithm_id), check_for_backend(diesel::pg::Pg))]pub struct RoutingAlgorithm {pub algorithm_id: String,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_id: common_utils::id_type::MerchantId,pub name: String,pub description: Option<String>,@@ -29,7 +29,7 @@ pub struct RoutingAlgorithmMetadata {}pub struct RoutingProfileMetadata {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub algorithm_id: String,pub name: String,pub description: Option<String>,diff --git a/crates/diesel_models/src/user_role.rs b/crates/diesel_models/src/user_role.rsindex 1a006f2a4a..b508c86211 100644--- a/crates/diesel_models/src/user_role.rs+++ b/crates/diesel_models/src/user_role.rs@@ -18,7 +18,7 @@ pub struct UserRole {pub last_modified_by: String,pub created_at: PrimitiveDateTime,pub last_modified: PrimitiveDateTime,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,pub entity_id: Option<String>,pub entity_type: Option<EntityType>,pub version: enums::UserRoleVersion,@@ -36,7 +36,7 @@ pub struct UserRoleNew {pub last_modified_by: String,pub created_at: PrimitiveDateTime,pub last_modified: PrimitiveDateTime,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,pub entity_id: Option<String>,pub entity_type: Option<EntityType>,pub version: enums::UserRoleVersion,diff --git a/crates/hyperswitch_domain_models/src/business_profile.rs b/crates/hyperswitch_domain_models/src/business_profile.rsindex ec072521d9..9a6edc50e7 100644--- a/crates/hyperswitch_domain_models/src/business_profile.rs+++ b/crates/hyperswitch_domain_models/src/business_profile.rs@@ -23,7 +23,7 @@ use crate::type_encryption::{crypto_operation, AsyncLift, CryptoOperation};))]#[derive(Clone, Debug)]pub struct BusinessProfile {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_id: common_utils::id_type::MerchantId,pub profile_name: String,pub created_at: time::PrimitiveDateTime,@@ -453,7 +453,7 @@ impl super::behaviour::Conversion for BusinessProfile {#[cfg(all(feature = "v2", feature = "business_profile_v2"))]#[derive(Clone, Debug)]pub struct BusinessProfile {- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub merchant_id: common_utils::id_type::MerchantId,pub profile_name: String,pub created_at: time::PrimitiveDateTime,diff --git a/crates/hyperswitch_domain_models/src/merchant_account.rs b/crates/hyperswitch_domain_models/src/merchant_account.rsindex c86dff60ea..50b1effd27 100644--- a/crates/hyperswitch_domain_models/src/merchant_account.rs+++ b/crates/hyperswitch_domain_models/src/merchant_account.rs@@ -45,7 +45,7 @@ pub struct MerchantAccount {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 default_profile: Option<common_utils::id_type::ProfileId>,pub recon_status: diesel_models::enums::ReconStatus,pub payment_link_config: Option<serde_json::Value>,pub pm_collect_link_config: Option<serde_json::Value>,@@ -82,7 +82,7 @@ pub struct MerchantAccountSetter {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 default_profile: Option<common_utils::id_type::ProfileId>,pub recon_status: diesel_models::enums::ReconStatus,pub payment_link_config: Option<serde_json::Value>,pub pm_collect_link_config: Option<serde_json::Value>,@@ -231,7 +231,7 @@ pub enum MerchantAccountUpdate {intent_fulfillment_time: Option<i64>,frm_routing_algorithm: Option<serde_json::Value>,payout_routing_algorithm: Option<serde_json::Value>,- default_profile: Option<Option<String>>,+ default_profile: Option<Option<common_utils::id_type::ProfileId>>,payment_link_config: Option<serde_json::Value>,pm_collect_link_config: Option<serde_json::Value>,},diff --git a/crates/hyperswitch_domain_models/src/merchant_connector_account.rs b/crates/hyperswitch_domain_models/src/merchant_connector_account.rsindex 9e2f6918b4..76b7cd4a85 100644--- a/crates/hyperswitch_domain_models/src/merchant_connector_account.rs+++ b/crates/hyperswitch_domain_models/src/merchant_connector_account.rs@@ -36,7 +36,7 @@ pub struct MerchantConnectorAccount {pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,pub connector_webhook_details: Option<pii::SecretSerdeValue>,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub applepay_verified_domains: Option<Vec<String>>,pub pm_auth_config: Option<pii::SecretSerdeValue>,pub status: enums::ConnectorStatus,@@ -71,7 +71,7 @@ pub struct MerchantConnectorAccount {pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,pub connector_webhook_details: Option<pii::SecretSerdeValue>,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub applepay_verified_domains: Option<Vec<String>>,pub pm_auth_config: Option<pii::SecretSerdeValue>,pub status: enums::ConnectorStatus,diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex 3f7cfde2f7..11a2c3c316 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -44,7 +44,7 @@ pub struct PaymentIntent {pub connector_metadata: Option<serde_json::Value>,pub feature_metadata: Option<serde_json::Value>,pub attempt_count: i16,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,pub payment_link_id: Option<String>,// Denotes the action(approve or reject) taken by merchant in case of manual review.// Manual review can occur when the transaction is marked as risky by the frm_processor, payment processor or when there is underpayment/over payment incase of crypto paymentdiff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex c129e83d55..4c59a90ba1 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -133,7 +133,7 @@ pub struct PaymentIntentNew {pub connector_metadata: Option<serde_json::Value>,pub feature_metadata: Option<serde_json::Value>,pub attempt_count: i16,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,pub merchant_decision: Option<String>,pub payment_link_id: Option<String>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,@@ -746,7 +746,7 @@ pub struct PaymentIntentListParams {pub payment_method_type: Option<Vec<storage_enums::PaymentMethodType>>,pub authentication_type: Option<Vec<storage_enums::AuthenticationType>>,pub merchant_connector_id: Option<Vec<String>>,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,pub customer_id: Option<id_type::CustomerId>,pub starting_after_id: Option<String>,pub ending_before_id: Option<String>,diff --git a/crates/hyperswitch_domain_models/src/payouts.rs b/crates/hyperswitch_domain_models/src/payouts.rsindex bb636d2dc4..952028fab3 100644--- a/crates/hyperswitch_domain_models/src/payouts.rs+++ b/crates/hyperswitch_domain_models/src/payouts.rs@@ -19,7 +19,7 @@ pub struct PayoutListParams {pub currency: Option<Vec<storage_enums::Currency>>,pub status: Option<Vec<storage_enums::PayoutStatus>>,pub payout_method: Option<Vec<common_enums::PayoutType>>,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,pub customer_id: Option<id_type::CustomerId>,pub starting_after_id: Option<String>,pub ending_before_id: Option<String>,diff --git a/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rsindex a1f08610f9..8182ed35ba 100644--- a/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs@@ -75,7 +75,7 @@ pub struct PayoutAttempt {pub created_at: PrimitiveDateTime,#[serde(with = "common_utils::custom_serde::iso8601")]pub last_modified_at: PrimitiveDateTime,- pub profile_id: String,+ pub profile_id: id_type::ProfileId,pub merchant_connector_id: Option<String>,pub routing_info: Option<serde_json::Value>,}@@ -96,41 +96,13 @@ pub struct PayoutAttemptNew {pub error_code: Option<String>,pub business_country: Option<storage_enums::CountryAlpha2>,pub business_label: Option<String>,- pub created_at: Option<PrimitiveDateTime>,- pub last_modified_at: Option<PrimitiveDateTime>,- pub profile_id: String,+ pub created_at: PrimitiveDateTime,+ pub last_modified_at: PrimitiveDateTime,+ pub profile_id: id_type::ProfileId,pub merchant_connector_id: Option<String>,pub routing_info: Option<serde_json::Value>,}-impl Default for PayoutAttemptNew {- fn default() -> Self {- let now = common_utils::date_time::now();-- Self {- payout_attempt_id: String::default(),- payout_id: String::default(),- customer_id: None,- merchant_id: id_type::MerchantId::default(),- address_id: None,- connector: None,- connector_payout_id: None,- payout_token: None,- status: storage_enums::PayoutStatus::default(),- is_eligible: None,- error_message: None,- error_code: None,- business_country: None,- business_label: None,- created_at: Some(now),- last_modified_at: Some(now),- profile_id: String::default(),- merchant_connector_id: None,- routing_info: None,- }- }-}-#[derive(Debug, Clone)]pub enum PayoutAttemptUpdate {StatusUpdate {diff --git a/crates/hyperswitch_domain_models/src/payouts/payouts.rs b/crates/hyperswitch_domain_models/src/payouts/payouts.rsindex 834b6bb3f7..e514dbfb4c 100644--- a/crates/hyperswitch_domain_models/src/payouts/payouts.rs+++ b/crates/hyperswitch_domain_models/src/payouts/payouts.rs@@ -106,7 +106,7 @@ pub struct Payouts {pub created_at: PrimitiveDateTime,pub last_modified_at: PrimitiveDateTime,pub attempt_count: i16,- pub profile_id: String,+ pub profile_id: id_type::ProfileId,pub status: storage_enums::PayoutStatus,pub confirm: Option<bool>,pub payout_link_id: Option<String>,@@ -131,10 +131,10 @@ pub struct PayoutsNew {pub return_url: Option<String>,pub entity_type: storage_enums::PayoutEntityType,pub metadata: Option<pii::SecretSerdeValue>,- pub created_at: Option<PrimitiveDateTime>,- pub last_modified_at: Option<PrimitiveDateTime>,+ pub created_at: PrimitiveDateTime,+ pub last_modified_at: PrimitiveDateTime,pub attempt_count: i16,- pub profile_id: String,+ pub profile_id: id_type::ProfileId,pub status: storage_enums::PayoutStatus,pub confirm: Option<bool>,pub payout_link_id: Option<String>,@@ -142,39 +142,6 @@ pub struct PayoutsNew {pub priority: Option<storage_enums::PayoutSendPriority>,}-impl Default for PayoutsNew {- fn default() -> Self {- let now = common_utils::date_time::now();-- Self {- payout_id: String::default(),- merchant_id: id_type::MerchantId::default(),- customer_id: None,- address_id: None,- payout_type: None,- payout_method_id: None,- amount: MinorUnit::new(i64::default()),- destination_currency: storage_enums::Currency::default(),- source_currency: storage_enums::Currency::default(),- description: None,- recurring: bool::default(),- auto_fulfill: bool::default(),- return_url: None,- entity_type: storage_enums::PayoutEntityType::default(),- metadata: None,- created_at: Some(now),- last_modified_at: Some(now),- attempt_count: 1,- profile_id: String::default(),- status: storage_enums::PayoutStatus::default(),- confirm: None,- payout_link_id: None,- client_secret: None,- priority: None,- }- }-}-#[derive(Debug, Serialize, Deserialize)]pub enum PayoutsUpdate {Update {@@ -187,7 +154,7 @@ pub enum PayoutsUpdate {return_url: Option<String>,entity_type: storage_enums::PayoutEntityType,metadata: Option<pii::SecretSerdeValue>,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,status: Option<storage_enums::PayoutStatus>,confirm: Option<bool>,payout_type: Option<storage_enums::PayoutType>,@@ -220,7 +187,7 @@ pub struct PayoutsUpdateInternal {pub entity_type: Option<storage_enums::PayoutEntityType>,pub metadata: Option<pii::SecretSerdeValue>,pub payout_method_id: Option<String>,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,pub status: Option<storage_enums::PayoutStatus>,pub attempt_count: Option<i16>,pub confirm: Option<bool>,diff --git a/crates/kgraph_utils/benches/evaluation.rs b/crates/kgraph_utils/benches/evaluation.rsindex ab2e8c80ca..5a078de1d7 100644--- a/crates/kgraph_utils/benches/evaluation.rs+++ b/crates/kgraph_utils/benches/evaluation.rs@@ -52,6 +52,8 @@ fn build_test_data(});}+ let profile_id = common_utils::generate_profile_id_of_default_length();+#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]let stripe_account = MerchantConnectorResponse {connector_type: api_enums::ConnectorType::FizOperations,@@ -64,7 +66,7 @@ fn build_test_data(connector_label: Some("something".to_string()),frm_configs: None,connector_webhook_details: None,- profile_id: "profile_id".to_string(),+ profile_id,applepay_verified_domains: None,pm_auth_config: None,status: api_enums::ConnectorStatus::Inactive,@@ -90,7 +92,7 @@ fn build_test_data(business_sub_label: Some("something".to_string()),frm_configs: None,connector_webhook_details: None,- profile_id: "profile_id".to_string(),+ profile_id,applepay_verified_domains: None,pm_auth_config: None,status: api_enums::ConnectorStatus::Inactive,diff --git a/crates/kgraph_utils/src/mca.rs b/crates/kgraph_utils/src/mca.rsindex d4e0466971..1e099589b0 100644--- a/crates/kgraph_utils/src/mca.rs+++ b/crates/kgraph_utils/src/mca.rs@@ -704,6 +704,8 @@ mod tests {fn build_test_data() -> ConstraintGraph<dir::DirValue> {use api_models::{admin::*, payment_methods::*};+ let profile_id = common_utils::generate_profile_id_of_default_length();+#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]let stripe_account = MerchantConnectorResponse {connector_type: api_enums::ConnectorType::FizOperations,@@ -752,7 +754,7 @@ mod tests {}]),frm_configs: None,connector_webhook_details: None,- profile_id: "profile_id".to_string(),+ profile_id,applepay_verified_domains: None,pm_auth_config: None,status: api_enums::ConnectorStatus::Inactive,@@ -813,7 +815,7 @@ mod tests {}]),frm_configs: None,connector_webhook_details: None,- profile_id: "profile_id".to_string(),+ profile_id,applepay_verified_domains: None,pm_auth_config: None,status: api_enums::ConnectorStatus::Inactive,diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex e90924a593..f78d5dca2e 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -721,7 +721,7 @@ pub async fn list_merchant_account(pub async fn get_merchant_account(state: SessionState,req: api::MerchantId,- _profile_id: Option<String>,+ _profile_id: Option<id_type::ProfileId>,) -> RouterResponse<api::MerchantAccountResponse> {let db = state.store.as_ref();let key_manager_state = &(&state).into();@@ -842,8 +842,6 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,) -> RouterResult<storage::MerchantAccountUpdate> {- use common_utils::ext_traits::ConfigExt;-let key_manager_state = &state.into();let key = key_store.key.get_inner().peek();@@ -885,21 +883,16 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {// This supports changing the business profile by passing in the profile_idlet business_profile_id_update = if let Some(ref profile_id) = self.default_profile {- if !profile_id.is_empty_after_trim() {- // Validate whether profile_id passed in request is valid and is linked to the merchant- core_utils::validate_and_get_business_profile(- state.store.as_ref(),- key_manager_state,- key_store,- Some(profile_id),- merchant_id,- )- .await?- .map(|business_profile| Some(business_profile.profile_id))- } else {- // If empty, Update profile_id to None in the database- Some(None)- }+ // Validate whether profile_id passed in request is valid and is linked to the merchant+ core_utils::validate_and_get_business_profile(+ state.store.as_ref(),+ key_manager_state,+ key_store,+ Some(profile_id),+ merchant_id,+ )+ .await?+ .map(|business_profile| Some(business_profile.profile_id))} else {None};@@ -1047,7 +1040,7 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {pub async fn merchant_account_update(state: SessionState,merchant_id: &id_type::MerchantId,- _profile_id: Option<String>,+ _profile_id: Option<id_type::ProfileId>,req: api::MerchantAccountUpdate,) -> RouterResponse<api::MerchantAccountResponse> {let db = state.store.as_ref();@@ -1765,7 +1758,7 @@ struct PMAuthConfigValidation<'a> {pm_auth_config: &'a Option<pii::SecretSerdeValue>,db: &'a dyn StorageInterface,merchant_id: &'a id_type::MerchantId,- profile_id: &'a String,+ profile_id: &'a id_type::ProfileId,key_store: &'a domain::MerchantKeyStore,key_manager_state: &'a KeyManagerState,}@@ -1877,7 +1870,7 @@ struct MerchantDefaultConfigUpdate<'a> {merchant_connector_id: &'a String,store: &'a dyn StorageInterface,merchant_id: &'a id_type::MerchantId,- profile_id: &'a String,+ profile_id: &'a id_type::ProfileId,transaction_type: &'a api_enums::TransactionType,}#[cfg(all(@@ -1897,7 +1890,7 @@ impl<'a> MerchantDefaultConfigUpdate<'a> {let mut default_routing_config_for_profile = routing::helpers::get_merchant_default_config(self.store,- self.profile_id,+ self.profile_id.get_string_repr(),self.transaction_type,).await?;@@ -1922,7 +1915,7 @@ impl<'a> MerchantDefaultConfigUpdate<'a> {default_routing_config_for_profile.push(choice);routing::helpers::update_merchant_default_config(self.store,- self.profile_id,+ self.profile_id.get_string_repr(),default_routing_config_for_profile.clone(),self.transaction_type,)@@ -1969,7 +1962,7 @@ impl<'a> DefaultFallbackRoutingConfigUpdate<'a> {profile_wrapper.update_default_fallback_routing_of_connectors_under_profile(self.store,- &default_routing_config_for_profile,+ default_routing_config_for_profile,self.key_manager_state,&self.key_store,)@@ -2438,7 +2431,9 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {).await?.get_required_value("BusinessProfile")- .change_context(errors::ApiErrorResponse::BusinessProfileNotFound { id: profile_id })?;+ .change_context(errors::ApiErrorResponse::BusinessProfileNotFound {+ id: profile_id.get_string_repr().to_owned(),+ })?;Ok(business_profile)}@@ -2614,7 +2609,9 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {.await?.get_required_value("BusinessProfile").change_context(- errors::ApiErrorResponse::BusinessProfileNotFound { id: profile_id },+ errors::ApiErrorResponse::BusinessProfileNotFound {+ id: profile_id.get_string_repr().to_owned(),+ },)?;Ok(business_profile)@@ -2746,7 +2743,7 @@ pub async fn create_connector(.await.to_duplicate_response(errors::ApiErrorResponse::DuplicateMerchantConnectorAccount {- profile_id: business_profile.profile_id.clone(),+ profile_id: business_profile.profile_id.get_string_repr().to_owned(),connector_label: merchant_connector_account.connector_label.unwrap_or_default(),@@ -2809,7 +2806,7 @@ async fn validate_pm_auth(merchant_id: &id_type::MerchantId,key_store: &domain::MerchantKeyStore,merchant_account: domain::MerchantAccount,- profile_id: &String,+ profile_id: &id_type::ProfileId,) -> RouterResponse<()> {let config =serde_json::from_value::<api_models::pm_auth::PaymentMethodAuthConfig>(val.expose())@@ -2858,7 +2855,7 @@ async fn validate_pm_auth(pub async fn retrieve_connector(state: SessionState,merchant_id: id_type::MerchantId,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,merchant_connector_id: String,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {let store = state.store.as_ref();@@ -2939,7 +2936,7 @@ pub async fn retrieve_connector(pub async fn list_payment_connectors(state: SessionState,merchant_id: id_type::MerchantId,- profile_id_list: Option<Vec<String>>,+ profile_id_list: Option<Vec<id_type::ProfileId>>,) -> RouterResponse<Vec<api_models::admin::MerchantConnectorListResponse>> {let store = state.store.as_ref();let key_manager_state = &(&state).into();@@ -2984,7 +2981,7 @@ pub async fn list_payment_connectors(pub async fn update_connector(state: SessionState,merchant_id: &id_type::MerchantId,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,merchant_connector_id: &str,req: api_models::admin::MerchantConnectorUpdate,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {@@ -3042,7 +3039,7 @@ pub async fn update_connector(.await.change_context(errors::ApiErrorResponse::DuplicateMerchantConnectorAccount {- profile_id,+ profile_id: profile_id.get_string_repr().to_owned(),connector_label: request_connector_label.unwrap_or_default(),},)@@ -3409,7 +3406,7 @@ impl BusinessProfileCreateBridge for api::BusinessProfileCreate {}// Generate a unique profile id- let profile_id = common_utils::generate_id_with_default_len("pro");+ let profile_id = common_utils::generate_profile_id_of_default_length();let profile_name = self.profile_name.unwrap_or("default".to_string());let current_time = date_time::now();@@ -3523,7 +3520,7 @@ impl BusinessProfileCreateBridge for api::BusinessProfileCreate {// Generate a unique profile id// TODO: the profile_id should be generated from the profile_name- let profile_id = common_utils::generate_id_with_default_len("pro");+ let profile_id = common_utils::generate_profile_id_of_default_length();let profile_name = self.profile_name;let current_time = date_time::now();@@ -3656,7 +3653,10 @@ pub async fn create_business_profile(.insert_business_profile(key_manager_state, &key_store, business_profile).await.to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError {- message: format!("Business Profile with the profile_id {profile_id} already exists"),+ message: format!(+ "Business Profile with the profile_id {} already exists",+ profile_id.get_string_repr()+ ),}).attach_printable("Failed to insert Business profile because of duplication error")?;@@ -3715,7 +3715,7 @@ pub async fn list_business_profile(pub async fn retrieve_business_profile(state: SessionState,- profile_id: String,+ profile_id: id_type::ProfileId,merchant_id: id_type::MerchantId,) -> RouterResponse<api_models::admin::BusinessProfileResponse> {let db = state.store.as_ref();@@ -3731,7 +3731,7 @@ pub async fn retrieve_business_profile(.find_business_profile_by_profile_id(&(&state).into(), &key_store, &profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id,+ id: profile_id.get_string_repr().to_owned(),})?;Ok(service_api::ApplicationResponse::Json(@@ -3743,7 +3743,7 @@ pub async fn retrieve_business_profile(pub async fn delete_business_profile(state: SessionState,- profile_id: String,+ profile_id: id_type::ProfileId,merchant_id: &id_type::MerchantId,) -> RouterResponse<bool> {let db = state.store.as_ref();@@ -3751,7 +3751,7 @@ pub async fn delete_business_profile(.delete_business_profile_by_profile_id_merchant_id(&profile_id, merchant_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id,+ id: profile_id.get_string_repr().to_owned(),})?;Ok(service_api::ApplicationResponse::Json(delete_result))@@ -3977,7 +3977,7 @@ impl BusinessProfileUpdateBridge for api::BusinessProfileUpdate {#[cfg(feature = "olap")]pub async fn update_business_profile(state: SessionState,- profile_id: &str,+ profile_id: &id_type::ProfileId,merchant_id: &id_type::MerchantId,request: api::BusinessProfileUpdate,) -> RouterResponse<api::BusinessProfileResponse> {@@ -3997,12 +3997,12 @@ pub async fn update_business_profile(.find_business_profile_by_profile_id(key_manager_state, &key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_owned(),+ id: profile_id.get_string_repr().to_owned(),})?;if business_profile.merchant_id != *merchant_id {Err(errors::ApiErrorResponse::AccessForbidden {- resource: profile_id.to_string(),+ resource: profile_id.get_string_repr().to_owned(),})?}@@ -4019,7 +4019,7 @@ pub async fn update_business_profile().await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_owned(),+ id: profile_id.get_string_repr().to_owned(),})?;Ok(service_api::ApplicationResponse::Json(@@ -4055,8 +4055,9 @@ impl BusinessProfileWrapper {storage_impl::redis::cache::CacheKind::Routing(format!(- "routing_config_{}_{profile_id}",- merchant_id.get_string_repr()+ "routing_config_{}_{}",+ merchant_id.get_string_repr(),+ profile_id.get_string_repr()).into(),)@@ -4177,7 +4178,7 @@ impl BusinessProfileWrapper {pub async fn extended_card_info_toggle(state: SessionState,merchant_id: &id_type::MerchantId,- profile_id: &str,+ profile_id: &id_type::ProfileId,ext_card_info_choice: admin_types::ExtendedCardInfoChoice,) -> RouterResponse<admin_types::ExtendedCardInfoChoice> {let db = state.store.as_ref();@@ -4197,7 +4198,7 @@ pub async fn extended_card_info_toggle(.find_business_profile_by_profile_id(key_manager_state, &key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;if business_profile.is_extended_card_info_enabled.is_none()@@ -4217,7 +4218,7 @@ pub async fn extended_card_info_toggle().await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_owned(),+ id: profile_id.get_string_repr().to_owned(),})?;}@@ -4227,7 +4228,7 @@ pub async fn extended_card_info_toggle(pub async fn connector_agnostic_mit_toggle(state: SessionState,merchant_id: &id_type::MerchantId,- profile_id: &str,+ profile_id: &id_type::ProfileId,connector_agnostic_mit_choice: admin_types::ConnectorAgnosticMitChoice,) -> RouterResponse<admin_types::ConnectorAgnosticMitChoice> {let db = state.store.as_ref();@@ -4247,12 +4248,12 @@ pub async fn connector_agnostic_mit_toggle(.find_business_profile_by_profile_id(key_manager_state, &key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;if business_profile.merchant_id != *merchant_id {Err(errors::ApiErrorResponse::AccessForbidden {- resource: profile_id.to_string(),+ resource: profile_id.get_string_repr().to_owned(),})?}@@ -4271,7 +4272,7 @@ pub async fn connector_agnostic_mit_toggle().await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_owned(),+ id: profile_id.get_string_repr().to_owned(),})?;}diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rsindex 87235582c0..58862d1890 100644--- a/crates/router/src/core/authentication/utils.rs+++ b/crates/router/src/core/authentication/utils.rs@@ -178,7 +178,7 @@ pub async fn create_new_authentication(merchant_id: common_utils::id_type::MerchantId,authentication_connector: String,token: String,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,payment_id: Option<String>,merchant_connector_id: String,) -> RouterResult<storage::Authentication> {@@ -285,7 +285,7 @@ pub async fn get_authentication_connector_data(.ok_or(errors::ApiErrorResponse::UnprocessableEntity {message: format!("No authentication_connector found for profile_id {}",- business_profile.profile_id+ business_profile.profile_id.get_string_repr()),}).attach_printable(diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rsindex 71e982031e..1044ca7822 100644--- a/crates/router/src/core/customers.rs+++ b/crates/router/src/core/customers.rs@@ -433,7 +433,7 @@ impl<'a> MerchantReferenceIdForCustomer<'a> {pub async fn retrieve_customer(state: SessionState,merchant_account: domain::MerchantAccount,- _profile_id: Option<String>,+ _profile_id: Option<id_type::ProfileId>,key_store: domain::MerchantKeyStore,req: customers::CustomerId,) -> errors::CustomerResponse<customers::CustomerResponse> {@@ -494,7 +494,7 @@ pub async fn retrieve_customer(pub async fn list_customers(state: SessionState,merchant_id: id_type::MerchantId,- _profile_id_list: Option<Vec<String>>,+ _profile_id_list: Option<Vec<id_type::ProfileId>>,key_store: domain::MerchantKeyStore,) -> errors::CustomerResponse<Vec<customers::CustomerResponse>> {let db = state.store.as_ref();diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rsindex 7321595930..24c6c0f8be 100644--- a/crates/router/src/core/disputes.rs+++ b/crates/router/src/core/disputes.rs@@ -26,7 +26,7 @@ use crate::{pub async fn retrieve_dispute(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,req: disputes::DisputeId,) -> RouterResponse<api_models::disputes::DisputeResponse> {let dispute = state@@ -45,7 +45,7 @@ pub async fn retrieve_dispute(pub async fn retrieve_disputes_list(state: SessionState,merchant_account: domain::MerchantAccount,- _profile_id_list: Option<Vec<String>>,+ _profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,constraints: api_models::disputes::DisputeListConstraints,) -> RouterResponse<Vec<api_models::disputes::DisputeResponse>> {let disputes = state@@ -65,7 +65,7 @@ pub async fn retrieve_disputes_list(pub async fn accept_dispute(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,key_store: domain::MerchantKeyStore,req: disputes::DisputeId,) -> RouterResponse<dispute_models::DisputeResponse> {@@ -169,7 +169,7 @@ pub async fn accept_dispute(pub async fn submit_evidence(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,key_store: domain::MerchantKeyStore,req: dispute_models::SubmitEvidenceRequest,) -> RouterResponse<dispute_models::DisputeResponse> {@@ -336,7 +336,7 @@ pub async fn submit_evidence(pub async fn attach_evidence(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,key_store: domain::MerchantKeyStore,attach_evidence_request: api::AttachEvidenceRequest,) -> RouterResponse<files_api_models::CreateFileResponse> {@@ -415,7 +415,7 @@ pub async fn attach_evidence(pub async fn retrieve_dispute_evidence(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,req: disputes::DisputeId,) -> RouterResponse<Vec<api_models::disputes::DisputeEvidenceBlock>> {let dispute = statediff --git a/crates/router/src/core/files/helpers.rs b/crates/router/src/core/files/helpers.rsindex b479d13156..14e404e88a 100644--- a/crates/router/src/core/files/helpers.rs+++ b/crates/router/src/core/files/helpers.rs@@ -245,7 +245,7 @@ pub async fn upload_and_get_provider_provider_file_id_profile_id((String,api_models::enums::FileUploadProvider,- Option<String>,+ Option<common_utils::id_type::ProfileId>,Option<String>,),errors::ApiErrorResponse,diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rsindex a5d78377a8..d185e3545b 100644--- a/crates/router/src/core/fraud_check.rs+++ b/crates/router/src/core/fraud_check.rs@@ -128,7 +128,7 @@ pub async fn should_call_frm<F: Send + Clone>() -> RouterResult<(bool,Option<FrmRoutingAlgorithm>,- Option<String>,+ Option<common_utils::id_type::ProfileId>,Option<FrmConfigsObject>,)> {// Frm routing algorithm is not present in the merchant account@@ -145,7 +145,7 @@ pub async fn should_call_frm<F: Send + Clone>() -> RouterResult<(bool,Option<FrmRoutingAlgorithm>,- Option<String>,+ Option<common_utils::id_type::ProfileId>,Option<FrmConfigsObject>,)> {use common_utils::ext_traits::OptionExt;@@ -327,7 +327,7 @@ pub async fn should_call_frm<F: Send + Clone>(Ok((is_frm_enabled,Some(frm_routing_algorithm_struct),- Some(profile_id.to_string()),+ Some(profile_id),Some(frm_configs_object),))}@@ -354,7 +354,7 @@ pub async fn make_frm_data_and_fraud_check_operation<'a, F>(merchant_account: &domain::MerchantAccount,payment_data: payments::PaymentData<F>,frm_routing_algorithm: FrmRoutingAlgorithm,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,frm_configs: FrmConfigsObject,_customer: &Option<domain::Customer>,) -> RouterResult<FrmInfo<F>>diff --git a/crates/router/src/core/fraud_check/types.rs b/crates/router/src/core/fraud_check/types.rsindex d35e3227e6..7f9d21216b 100644--- a/crates/router/src/core/fraud_check/types.rs+++ b/crates/router/src/core/fraud_check/types.rs@@ -69,7 +69,7 @@ pub struct FrmInfo<F> {#[derive(Clone, Debug)]pub struct ConnectorDetailsCore {pub connector_name: String,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,}#[derive(Clone)]pub struct PaymentToFrmData {diff --git a/crates/router/src/core/mandate/helpers.rs b/crates/router/src/core/mandate/helpers.rsindex 9899d85fc7..e5fa762aeb 100644--- a/crates/router/src/core/mandate/helpers.rs+++ b/crates/router/src/core/mandate/helpers.rs@@ -16,7 +16,7 @@ pub async fn get_profile_id_for_mandate(merchant_account: &domain::MerchantAccount,key_store: &domain::MerchantKeyStore,mandate: Mandate,-) -> CustomResult<String, errors::ApiErrorResponse> {+) -> CustomResult<common_utils::id_type::ProfileId, errors::ApiErrorResponse> {let profile_id = if let Some(ref payment_id) = mandate.original_payment_id {let pi = state.store@@ -35,6 +35,7 @@ pub async fn get_profile_id_for_mandate(.ok_or(errors::ApiErrorResponse::BusinessProfileNotFound {id: pi.profile_id+ .map(|profile_id| profile_id.get_string_repr().to_owned()).unwrap_or_else(|| "Profile id is Null".to_string()),})?;Ok(profile_id)diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rsindex e7f21ae0fd..bb39bede2d 100644--- a/crates/router/src/core/payment_link.rs+++ b/crates/router/src/core/payment_link.rs@@ -129,7 +129,7 @@ pub async fn form_payment_link_data(.find_business_profile_by_profile_id(key_manager_state, &key_store, &profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let return_url = if let Some(payment_create_return_url) = payment_intent.return_url.clone() {@@ -754,7 +754,7 @@ pub async fn get_payment_link_status(.find_business_profile_by_profile_id(key_manager_state, &key_store, &profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let return_url = if let Some(payment_create_return_url) = payment_intent.return_url.clone() {diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 274ef3c096..586e93a0fe 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -2734,7 +2734,7 @@ pub async fn list_payment_methods(format!("pm_filters_cgraph_{}_{}",merchant_account.get_id().get_string_repr(),- profile_id+ profile_id.get_string_repr())};@@ -4909,7 +4909,7 @@ async fn generate_saved_pm_response(pub async fn get_mca_status(state: &routes::SessionState,key_store: &domain::MerchantKeyStore,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,merchant_id: &id_type::MerchantId,is_connector_agnostic_mit_enabled: bool,connector_mandate_details: Option<storage::PaymentsMandateReference>,@@ -5789,7 +5789,7 @@ wherepub async fn list_countries_currencies_for_connector_payment_method(state: routes::SessionState,req: ListCountriesCurrenciesRequest,- _profile_id: Option<String>,+ _profile_id: Option<id_type::ProfileId>,) -> errors::RouterResponse<ListCountriesCurrenciesResponse> {Ok(services::ApplicationResponse::Json(list_countries_currencies_for_connector_payment_method_util(diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 6938d3c407..72a188a47e 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -106,7 +106,7 @@ pub async fn payments_operation_core<F, Req, Op, FData>(state: &SessionState,req_state: ReqState,merchant_account: domain::MerchantAccount,- profile_id_from_auth_layer: Option<String>,+ profile_id_from_auth_layer: Option<id_type::ProfileId>,key_store: domain::MerchantKeyStore,operation: Op,req: Req,@@ -828,7 +828,7 @@ pub async fn payments_core<F, Res, Req, Op, FData>(state: SessionState,req_state: ReqState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,key_store: domain::MerchantKeyStore,operation: Op,req: Req,@@ -1067,7 +1067,7 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {.find_business_profile_by_profile_id(key_manager_state, &merchant_key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;Ok(router_types::RedirectPaymentFlowResponse {payments_response,@@ -1201,7 +1201,7 @@ impl PaymentRedirectFlow for PaymentRedirectSync {.find_business_profile_by_profile_id(key_manager_state, &merchant_key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;Ok(router_types::RedirectPaymentFlowResponse {payments_response,@@ -1432,7 +1432,7 @@ impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize {.find_business_profile_by_profile_id(key_manager_state, &merchant_key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;Ok(router_types::AuthenticatePaymentFlowResponse {payments_response,@@ -2019,10 +2019,9 @@ where.as_ref().get_required_value("profile_id").change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?- .clone();+ .attach_printable("profile_id is not set in payment_intent")?;- format!("{connector_name}_{profile_id}")+ format!("{connector_name}_{}", profile_id.get_string_repr())};let (should_call_connector, existing_connector_customer_id) =@@ -2912,7 +2911,7 @@ pub fn is_operation_complete_authorize<Op: Debug>(operation: &Op) -> bool {pub async fn list_payments(state: SessionState,merchant: domain::MerchantAccount,- profile_id_list: Option<Vec<String>>,+ profile_id_list: Option<Vec<id_type::ProfileId>>,key_store: domain::MerchantKeyStore,constraints: api::PaymentListConstraints,) -> RouterResponse<api::PaymentListResponse> {@@ -2987,7 +2986,7 @@ pub async fn list_payments(pub async fn apply_filters_on_payments(state: SessionState,merchant: domain::MerchantAccount,- profile_id_list: Option<Vec<String>>,+ profile_id_list: Option<Vec<id_type::ProfileId>>,merchant_key_store: domain::MerchantKeyStore,constraints: api::PaymentListFilterConstraints,) -> RouterResponse<api::PaymentListResponseV2> {@@ -3085,7 +3084,7 @@ pub async fn get_filters_for_payments(pub async fn get_payment_filters(state: SessionState,merchant: domain::MerchantAccount,- profile_id_list: Option<Vec<String>>,+ profile_id_list: Option<Vec<id_type::ProfileId>>,) -> RouterResponse<api::PaymentListFiltersV2> {let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =super::admin::list_payment_connectors(state, merchant.get_id().to_owned(), profile_id_list)@@ -4329,7 +4328,7 @@ pub async fn payment_external_authentication(.find_business_profile_by_profile_id(key_manager_state, &key_store, profile_id).await.change_context(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let authentication_details = business_profilediff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 068a66a248..98d680197b 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -136,7 +136,7 @@ pub fn create_certificate(pub fn filter_mca_based_on_profile_and_connector_type(merchant_connector_accounts: Vec<domain::MerchantConnectorAccount>,- profile_id: &String,+ profile_id: &id_type::ProfileId,connector_type: ConnectorType,) -> Vec<domain::MerchantConnectorAccount> {merchant_connector_accounts@@ -3272,7 +3272,7 @@ pub async fn get_merchant_connector_account(merchant_id: &id_type::MerchantId,creds_identifier: Option<String>,key_store: &domain::MerchantKeyStore,- profile_id: &String,+ profile_id: &id_type::ProfileId,connector_name: &str,merchant_connector_id: Option<&String>,) -> RouterResult<MerchantConnectorAccountType> {@@ -3397,7 +3397,8 @@ pub async fn get_merchant_connector_account(.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {id: format!(- "profile id {profile_id} and connector name {connector_name}"+ "profile id {} and connector name {connector_name}",+ profile_id.get_string_repr()),},)@@ -3838,7 +3839,7 @@ mod test {pub async fn get_additional_payment_data(pm_data: &domain::PaymentMethodData,db: &dyn StorageInterface,- profile_id: &str,+ profile_id: &id_type::ProfileId,) -> Option<api_models::payments::AdditionalPaymentData> {match pm_data {domain::PaymentMethodData::Card(card_data) => {@@ -3846,7 +3847,7 @@ pub async fn get_additional_payment_data(let card_isin = Some(card_data.card_number.get_card_isin());let enable_extended_bin =db.find_config_by_key_unwrap_or(- format!("{}_enable_extended_card_bin", profile_id).as_str(),+ format!("{}_enable_extended_card_bin", profile_id.get_string_repr()).as_str(),Some("false".to_string())).await.map_err(|err| services::logger::error!(message="Failed to fetch the config", extended_card_bin_error=?err)).ok();@@ -4347,7 +4348,7 @@ where))]let fallback_connetors_list = crate::core::routing::helpers::get_merchant_default_config(&*state.clone().store,- profile_id,+ profile_id.get_string_repr(),&api_enums::TransactionType::Payment,).awaitdiff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rsindex 401e1c2c7a..7034cfab2f 100644--- a/crates/router/src/core/payments/operations/payment_approve.rs+++ b/crates/router/src/core/payments/operations/payment_approve.rs@@ -81,7 +81,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCaptureRequest>.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let attempt_id = payment_intent.active_attempt.get_id().clone();diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rsindex 84eaf97bfa..4a26e53344 100644--- a/crates/router/src/core/payments/operations/payment_cancel.rs+++ b/crates/router/src/core/payments/operations/payment_cancel.rs@@ -150,7 +150,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCancelRequest>.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let payment_data = PaymentData {diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rsindex 0d096e1d3a..de7ee99619 100644--- a/crates/router/src/core/payments/operations/payment_capture.rs+++ b/crates/router/src/core/payments/operations/payment_capture.rs@@ -196,7 +196,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentData<F>, api::PaymentsCaptu.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let payment_data = payments::PaymentData {diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex 8d4e6f7a5f..c7a2686724 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -290,7 +290,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let payment_data = PaymentData {diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 2e7131edce..273773a80b 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -164,7 +164,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa.map(|business_profile_result| {business_profile_result.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),},)})@@ -476,7 +476,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pahelpers::get_additional_payment_data(&payment_method_data.into(),store.as_ref(),- profile_id.as_ref(),+ &profile_id,).await})diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 2b80598adf..a455f1d4c5 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -140,7 +140,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa.await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),},)?};@@ -883,7 +883,7 @@ impl PaymentCreate {payment_method_billing_address_id: Option<String>,payment_method_info: &Option<PaymentMethod>,key_store: &domain::MerchantKeyStore,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,customer_acceptance: &Option<payments::CustomerAcceptance>,) -> RouterResult<(storage::PaymentAttemptNew,@@ -1083,7 +1083,7 @@ impl PaymentCreate {payment_link_data: Option<api_models::payments::PaymentLinkResponse>,billing_address_id: Option<String>,active_attempt_id: String,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,session_expiry: PrimitiveDateTime,) -> RouterResult<storage::PaymentIntent> {let created_at @ modified_at @ last_synced = common_utils::date_time::now();@@ -1293,7 +1293,7 @@ async fn create_payment_link(db: &dyn StorageInterface,amount: api::Amount,description: Option<String>,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,domain_name: String,session_expiry: PrimitiveDateTime,locale: Option<String>,diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rsindex a5d0b95a67..b148d5bbcc 100644--- a/crates/router/src/core/payments/operations/payment_reject.rs+++ b/crates/router/src/core/payments/operations/payment_reject.rs@@ -134,7 +134,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, PaymentsCancelRequest> for P.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let payment_data = PaymentData {diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex af5f234e2c..6b101b6bd1 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -159,7 +159,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsSessionRequest>.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let payment_data = PaymentData {diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex ae9397aa8e..9a29b36b55 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -144,7 +144,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsStartRequest> f.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let payment_data = PaymentData {diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rsindex 587bdc8ef0..f2453e52c8 100644--- a/crates/router/src/core/payments/operations/payment_status.rs+++ b/crates/router/src/core/payments/operations/payment_status.rs@@ -376,7 +376,7 @@ async fn get_tracker_for_sync<.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let payment_method_info =diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex e7045116f2..32d7b32059 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -419,7 +419,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let surcharge_details = request.surcharge_details.map(|request_surcharge_details| {diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rsindex 31883042ec..e3e3bf4260 100644--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs@@ -112,7 +112,7 @@ impl<F: Send + Clone>.find_business_profile_by_profile_id(key_manager_state, key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;let payment_data = payments::PaymentData {diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rsindex 30c1edb6e0..692a5924a0 100644--- a/crates/router/src/core/payments/routing.rs+++ b/crates/router/src/core/payments/routing.rs@@ -81,7 +81,7 @@ pub struct SessionRoutingPmTypeInput<'a> {routing_algorithm: &'a MerchantAccountRoutingAlgorithm,backend_input: dsl_inputs::BackendInput,allowed_connectors: FxHashMap<String, api::GetToken>,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,}type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;@@ -291,7 +291,7 @@ pub async fn perform_static_routing_v1<F: Clone>())]let fallback_config = routing::helpers::get_merchant_default_config(&*state.clone().store,- &business_profile.profile_id,+ business_profile.profile_id.get_string_repr(),&api_enums::TransactionType::from(transaction_data),).await@@ -342,22 +342,24 @@ async fn ensure_algorithm_cached_v1(state: &SessionState,merchant_id: &common_utils::id_type::MerchantId,algorithm_id: &str,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,transaction_type: &api_enums::TransactionType,) -> RoutingResult<Arc<CachedAlgorithm>> {let key = {match transaction_type {common_enums::TransactionType::Payment => {format!(- "routing_config_{}_{profile_id}",- merchant_id.get_string_repr()+ "routing_config_{}_{}",+ merchant_id.get_string_repr(),+ profile_id.get_string_repr(),)}#[cfg(feature = "payouts")]common_enums::TransactionType::Payout => {format!(- "routing_config_po_{}_{profile_id}",- merchant_id.get_string_repr()+ "routing_config_po_{}_{}",+ merchant_id.get_string_repr(),+ profile_id.get_string_repr())}}@@ -425,7 +427,7 @@ pub async fn refresh_routing_cache_v1(state: &SessionState,key: String,algorithm_id: &str,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,) -> RoutingResult<Arc<CachedAlgorithm>> {let algorithm = {let algorithm = state@@ -507,7 +509,7 @@ pub fn perform_volume_split(pub async fn get_merchant_cgraph<'a>(state: &SessionState,key_store: &domain::MerchantKeyStore,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,transaction_type: &api_enums::TransactionType,) -> RoutingResult<Arc<hyperswitch_constraint_graph::ConstraintGraph<euclid_dir::DirValue>>> {let merchant_id = &key_store.merchant_id;@@ -515,11 +517,19 @@ pub async fn get_merchant_cgraph<'a>(let key = {match transaction_type {api_enums::TransactionType::Payment => {- format!("cgraph_{}_{}", merchant_id.get_string_repr(), profile_id)+ format!(+ "cgraph_{}_{}",+ merchant_id.get_string_repr(),+ profile_id.get_string_repr()+ )}#[cfg(feature = "payouts")]api_enums::TransactionType::Payout => {- format!("cgraph_po_{}_{}", merchant_id.get_string_repr(), profile_id)+ format!(+ "cgraph_po_{}_{}",+ merchant_id.get_string_repr(),+ profile_id.get_string_repr()+ )}}};@@ -546,7 +556,7 @@ pub async fn refresh_cgraph_cache<'a>(state: &SessionState,key_store: &domain::MerchantKeyStore,key: String,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,transaction_type: &api_enums::TransactionType,) -> RoutingResult<Arc<hyperswitch_constraint_graph::ConstraintGraph<euclid_dir::DirValue>>> {let mut merchant_connector_accounts = state@@ -645,7 +655,7 @@ async fn perform_cgraph_filtering(chosen: Vec<routing_types::RoutableConnectorChoice>,backend_input: dsl_inputs::BackendInput,eligible_connectors: Option<&Vec<api_enums::RoutableConnectors>>,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,transaction_type: &api_enums::TransactionType,) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {let context = euclid_graph::AnalysisContext::from_dir_values(@@ -689,7 +699,7 @@ pub async fn perform_eligibility_analysis<F: Clone>(chosen: Vec<routing_types::RoutableConnectorChoice>,transaction_data: &routing::TransactionData<'_, F>,eligible_connectors: Option<&Vec<api_enums::RoutableConnectors>>,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {let backend_input = match transaction_data {routing::TransactionData::Payment(payment_data) => make_dsl_input(payment_data)?,@@ -728,9 +738,12 @@ pub async fn perform_fallback_routing<F: Clone>(.profile_id.as_ref().get_required_value("profile_id")- .change_context(errors::RoutingError::ProfileIdMissing)?,+ .change_context(errors::RoutingError::ProfileIdMissing)?+ .get_string_repr(),#[cfg(feature = "payouts")]- routing::TransactionData::Payout(payout_data) => &payout_data.payout_attempt.profile_id,+ routing::TransactionData::Payout(payout_data) => {+ payout_data.payout_attempt.profile_id.get_string_repr()+ }},&api_enums::TransactionType::from(transaction_data),)@@ -1015,7 +1028,7 @@ async fn perform_session_routing_for_pm_type(} else {routing::helpers::get_merchant_default_config(&*session_pm_input.state.clone().store,- &session_pm_input.profile_id,+ session_pm_input.profile_id.get_string_repr(),transaction_type,).await@@ -1036,7 +1049,7 @@ async fn perform_session_routing_for_pm_type(if final_selection.is_empty() {let fallback = routing::helpers::get_merchant_default_config(&*session_pm_input.state.clone().store,- &session_pm_input.profile_id,+ session_pm_input.profile_id.get_string_repr(),transaction_type,).awaitdiff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex f331639be5..ed847526a3 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -66,7 +66,7 @@ pub struct PayoutData {pub payouts: storage::Payouts,pub payout_attempt: storage::PayoutAttempt,pub payout_method_data: Option<payouts::PayoutMethodData>,- pub profile_id: String,+ pub profile_id: common_utils::id_type::ProfileId,pub should_terminate: bool,pub payout_link: Option<PayoutLink>,}@@ -514,7 +514,7 @@ pub async fn payouts_update_core(pub async fn payouts_retrieve_core(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,key_store: domain::MerchantKeyStore,req: payouts::PayoutRetrieveRequest,) -> RouterResponse<payouts::PayoutCreateResponse> {@@ -740,7 +740,7 @@ pub async fn payouts_fulfill_core(pub async fn payouts_list_core(_state: SessionState,_merchant_account: domain::MerchantAccount,- _profile_id_list: Option<Vec<String>>,+ _profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,_key_store: domain::MerchantKeyStore,_constraints: payouts::PayoutListConstraints,) -> RouterResponse<payouts::PayoutListResponse> {@@ -755,7 +755,7 @@ pub async fn payouts_list_core(pub async fn payouts_list_core(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id_list: Option<Vec<String>>,+ profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,key_store: domain::MerchantKeyStore,constraints: payouts::PayoutListConstraints,) -> RouterResponse<payouts::PayoutListResponse> {@@ -864,7 +864,7 @@ pub async fn payouts_list_core(pub async fn payouts_filtered_list_core(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id_list: Option<Vec<String>>,+ profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,key_store: domain::MerchantKeyStore,filters: payouts::PayoutListFilterConstraints,) -> RouterResponse<payouts::PayoutListResponse> {@@ -1143,7 +1143,11 @@ pub async fn create_recipient(let connector_name = connector_data.connector_name.to_string();// Create the connector label using {profile_id}_{connector_name}- let connector_label = format!("{}_{}", payout_data.profile_id, connector_name);+ let connector_label = format!(+ "{}_{}",+ payout_data.profile_id.get_string_repr(),+ connector_name+ );let (should_call_connector, _connector_customer_id) =helpers::should_call_payout_connector_create_customer(state,@@ -2217,7 +2221,7 @@ pub async fn payout_create_db_entries(key_store: &domain::MerchantKeyStore,req: &payouts::PayoutCreateRequest,payout_id: &String,- profile_id: &String,+ profile_id: &common_utils::id_type::ProfileId,stored_payout_method_data: Option<&payouts::PayoutMethodData>,locale: &String,customer: Option<&domain::Customer>,@@ -2291,7 +2295,7 @@ pub async fn payout_create_db_entries(let payouts_req = storage::PayoutsNew {payout_id: payout_id.to_string(),merchant_id: merchant_id.to_owned(),- customer_id,+ customer_id: customer_id.to_owned(),address_id: address_id.to_owned(),payout_type,amount,@@ -2303,7 +2307,7 @@ pub async fn payout_create_db_entries(return_url: req.return_url.to_owned(),entity_type: req.entity_type.unwrap_or_default(),payout_method_id,- profile_id: profile_id.to_string(),+ profile_id: profile_id.to_owned(),attempt_count: 1,metadata: req.metadata.clone(),confirm: req.confirm,@@ -2313,7 +2317,8 @@ pub async fn payout_create_db_entries(client_secret: Some(client_secret),priority: req.priority,status,- ..Default::default()+ created_at: common_utils::date_time::now(),+ last_modified_at: common_utils::date_time::now(),};let payouts = db.insert_payout(payouts_req, merchant_account.storage_scheme)@@ -2333,8 +2338,18 @@ pub async fn payout_create_db_entries(business_country: req.business_country.to_owned(),business_label: req.business_label.to_owned(),payout_token: req.payout_token.to_owned(),- profile_id: profile_id.to_string(),- ..Default::default()+ profile_id: profile_id.to_owned(),+ customer_id,+ address_id,+ connector: None,+ connector_payout_id: None,+ is_eligible: None,+ error_message: None,+ error_code: None,+ created_at: common_utils::date_time::now(),+ last_modified_at: common_utils::date_time::now(),+ merchant_connector_id: None,+ routing_info: None,};let payout_attempt = db.insert_payout_attempt(@@ -2371,7 +2386,7 @@ pub async fn payout_create_db_entries(pub async fn make_payout_data(_state: &SessionState,_merchant_account: &domain::MerchantAccount,- _auth_profile_id: Option<String>,+ _auth_profile_id: Option<common_utils::id_type::ProfileId>,_key_store: &domain::MerchantKeyStore,_req: &payouts::PayoutRequest,) -> RouterResult<PayoutData> {@@ -2382,7 +2397,7 @@ pub async fn make_payout_data(pub async fn make_payout_data(state: &SessionState,merchant_account: &domain::MerchantAccount,- auth_profile_id: Option<String>,+ auth_profile_id: Option<common_utils::id_type::ProfileId>,key_store: &domain::MerchantKeyStore,req: &payouts::PayoutRequest,) -> RouterResult<PayoutData> {@@ -2567,7 +2582,7 @@ pub async fn add_external_account_addition_task(async fn validate_and_get_business_profile(state: &SessionState,merchant_key_store: &domain::MerchantKeyStore,- profile_id: &String,+ profile_id: &common_utils::id_type::ProfileId,merchant_id: &common_utils::id_type::MerchantId,) -> RouterResult<domain::BusinessProfile> {let db = &*state.store;@@ -2587,7 +2602,7 @@ async fn validate_and_get_business_profile(db.find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})}}@@ -2726,7 +2741,7 @@ pub async fn create_payout_link_db_entry(pub async fn get_mca_from_profile_id(state: &SessionState,merchant_account: &domain::MerchantAccount,- profile_id: &String,+ profile_id: &common_utils::id_type::ProfileId,connector_name: &str,merchant_connector_id: Option<&String>,key_store: &domain::MerchantKeyStore,diff --git a/crates/router/src/core/payouts/retry.rs b/crates/router/src/core/payouts/retry.rsindex 284f81a170..08fef69988 100644--- a/crates/router/src/core/payouts/retry.rs+++ b/crates/router/src/core/payouts/retry.rs@@ -285,8 +285,16 @@ pub async fn modify_trackers(business_country: payout_data.payout_attempt.business_country.to_owned(),business_label: payout_data.payout_attempt.business_label.to_owned(),payout_token: payout_data.payout_attempt.payout_token.to_owned(),- profile_id: payout_data.payout_attempt.profile_id.to_string(),- ..Default::default()+ profile_id: payout_data.payout_attempt.profile_id.to_owned(),+ connector_payout_id: None,+ status: common_enums::PayoutStatus::default(),+ is_eligible: None,+ error_message: None,+ error_code: None,+ created_at: common_utils::date_time::now(),+ last_modified_at: common_utils::date_time::now(),+ merchant_connector_id: None,+ routing_info: None,};payout_data.payout_attempt = db.insert_payout_attempt(diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rsindex d425725645..bde753a90e 100644--- a/crates/router/src/core/payouts/validator.rs+++ b/crates/router/src/core/payouts/validator.rs@@ -56,7 +56,7 @@ pub async fn validate_create_request() -> RouterResult<(String,Option<payouts::PayoutMethodData>,- String,+ common_utils::id_type::ProfileId,Option<domain::Customer>,)> {let merchant_id = merchant_account.get_id();diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rsindex 878ec24185..8945034740 100644--- a/crates/router/src/core/refunds.rs+++ b/crates/router/src/core/refunds.rs@@ -47,7 +47,7 @@ use crate::{pub async fn refund_create_core(state: SessionState,merchant_account: domain::MerchantAccount,- _profile_id: Option<String>,+ _profile_id: Option<common_utils::id_type::ProfileId>,key_store: domain::MerchantKeyStore,req: refunds::RefundRequest,) -> RouterResponse<refunds::RefundResponse> {@@ -374,7 +374,7 @@ wherepub async fn refund_response_wrapper<'a, F, Fut, T, Req>(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,key_store: domain::MerchantKeyStore,request: Req,f: F,@@ -383,7 +383,7 @@ whereF: Fn(SessionState,domain::MerchantAccount,- Option<String>,+ Option<common_utils::id_type::ProfileId>,domain::MerchantKeyStore,Req,) -> Fut,@@ -401,7 +401,7 @@ wherepub async fn refund_retrieve_core(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,key_store: domain::MerchantKeyStore,request: refunds::RefundsRetrieveRequest,) -> RouterResult<storage::Refund> {@@ -865,7 +865,7 @@ pub async fn validate_and_create_refund(pub async fn refund_list(state: SessionState,merchant_account: domain::MerchantAccount,- _profile_id_list: Option<Vec<String>>,+ _profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,req: api_models::refunds::RefundListRequest,) -> RouterResponse<api_models::refunds::RefundListResponse> {let db = state.store;@@ -987,7 +987,7 @@ pub async fn refund_manual_update(pub async fn get_filters_for_refunds(state: SessionState,merchant_account: domain::MerchantAccount,- profile_id_list: Option<Vec<String>>,+ profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>,) -> RouterResponse<api_models::refunds::RefundListFilters> {let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =super::admin::list_payment_connectors(diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rsindex 640b12c52c..267a3d55ce 100644--- a/crates/router/src/core/routing.rs+++ b/crates/router/src/core/routing.rs@@ -50,7 +50,7 @@ impl RoutingAlgorithmUpdate {pub fn create_new_routing_algorithm(request: &routing_types::RoutingConfigRequest,merchant_id: &common_utils::id_type::MerchantId,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,transaction_type: &enums::TransactionType,) -> Self {let algorithm_id = common_utils::generate_id(@@ -279,7 +279,7 @@ pub async fn link_routing_config_under_profile(state: SessionState,merchant_account: domain::MerchantAccount,key_store: domain::MerchantKeyStore,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,algorithm_id: String,transaction_type: &enums::TransactionType,) -> RouterResponse<routing_types::RoutingDictionaryRecord> {@@ -377,7 +377,7 @@ pub async fn link_routing_config(.await?.get_required_value("BusinessProfile").change_context(errors::ApiErrorResponse::BusinessProfileNotFound {- id: routing_algorithm.profile_id.clone(),+ id: routing_algorithm.profile_id.get_string_repr().to_owned(),})?;let mut routing_ref: routing_types::RoutingAlgorithmRef = business_profile@@ -506,7 +506,7 @@ pub async fn unlink_routing_config_under_profile(state: SessionState,merchant_account: domain::MerchantAccount,key_store: domain::MerchantKeyStore,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,transaction_type: &enums::TransactionType,) -> RouterResponse<routing_types::RoutingDictionaryRecord> {metrics::ROUTING_UNLINK_CONFIG.add(&metrics::CONTEXT, 1, &[]);@@ -652,7 +652,7 @@ pub async fn update_default_fallback_routing(state: SessionState,merchant_account: domain::MerchantAccount,key_store: domain::MerchantKeyStore,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,updated_list_of_connectors: Vec<routing_types::RoutableConnectorChoice>,) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> {metrics::ROUTING_UPDATE_CONFIG.add(&metrics::CONTEXT, 1, &[]);@@ -788,7 +788,7 @@ pub async fn retrieve_default_fallback_algorithm_for_profile(state: SessionState,merchant_account: domain::MerchantAccount,key_store: domain::MerchantKeyStore,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> {metrics::ROUTING_RETRIEVE_DEFAULT_CONFIG.add(&metrics::CONTEXT, 1, &[]);let db = state.store.as_ref();@@ -844,7 +844,7 @@ pub async fn retrieve_routing_config_under_profile(merchant_account: domain::MerchantAccount,key_store: domain::MerchantKeyStore,query_params: RoutingRetrieveQuery,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,transaction_type: &enums::TransactionType,) -> RouterResponse<routing_types::LinkedRoutingConfigRetrieveResponse> {metrics::ROUTING_RETRIEVE_LINK_CONFIG.add(&metrics::CONTEXT, 1, &[]);@@ -908,7 +908,9 @@ pub async fn retrieve_linked_routing_config(.await?.map(|profile| vec![profile]).get_required_value("BusinessProfile")- .change_context(errors::ApiErrorResponse::BusinessProfileNotFound { id: profile_id })?+ .change_context(errors::ApiErrorResponse::BusinessProfileNotFound {+ id: profile_id.get_string_repr().to_owned(),+ })?} else {db.list_business_profile_by_merchant_id(key_manager_state,@@ -975,7 +977,13 @@ pub async fn retrieve_default_routing_config_for_profiles(let retrieve_config_futures = all_profiles.iter()- .map(|prof| helpers::get_merchant_default_config(db, &prof.profile_id, transaction_type))+ .map(|prof| {+ helpers::get_merchant_default_config(+ db,+ prof.profile_id.get_string_repr(),+ transaction_type,+ )+ }).collect::<Vec<_>>();let configs = futures::future::join_all(retrieve_config_futures)@@ -1003,7 +1011,7 @@ pub async fn update_default_routing_config_for_profile(merchant_account: domain::MerchantAccount,key_store: domain::MerchantKeyStore,updated_config: Vec<routing_types::RoutableConnectorChoice>,- profile_id: String,+ profile_id: common_utils::id_type::ProfileId,transaction_type: &enums::TransactionType,) -> RouterResponse<routing_types::ProfileDefaultRoutingConfig> {metrics::ROUTING_UPDATE_CONFIG_FOR_PROFILE.add(&metrics::CONTEXT, 1, &[]);@@ -1019,10 +1027,15 @@ pub async fn update_default_routing_config_for_profile().await?.get_required_value("BusinessProfile")- .change_context(errors::ApiErrorResponse::BusinessProfileNotFound { id: profile_id })?;- let default_config =- helpers::get_merchant_default_config(db, &business_profile.profile_id, transaction_type)- .await?;+ .change_context(errors::ApiErrorResponse::BusinessProfileNotFound {+ id: profile_id.get_string_repr().to_owned(),+ })?;+ let default_config = helpers::get_merchant_default_config(+ db,+ business_profile.profile_id.get_string_repr(),+ transaction_type,+ )+ .await?;utils::when(default_config.len() != updated_config.len(), || {Err(errors::ApiErrorResponse::PreconditionFailed {@@ -1061,7 +1074,7 @@ pub async fn update_default_routing_config_for_profile(helpers::update_merchant_default_config(db,- &business_profile.profile_id,+ business_profile.profile_id.get_string_repr(),updated_config.clone(),transaction_type,)diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rsindex 43da2bb2bd..5cbb1e9fdf 100644--- a/crates/router/src/core/routing/helpers.rs+++ b/crates/router/src/core/routing/helpers.rs@@ -207,8 +207,9 @@ pub async fn update_business_profile_active_algorithm_ref(let routing_cache_key = cache::CacheKind::Routing(format!(- "routing_config_{}_{profile_id}",- merchant_id.get_string_repr()+ "routing_config_{}_{}",+ merchant_id.get_string_repr(),+ profile_id.get_string_repr(),).into(),);@@ -300,13 +301,13 @@ impl MerchantConnectorAccounts {pub fn filter_by_profile<'a, T>(&'a self,- profile_id: &'a str,+ profile_id: &'a common_utils::id_type::ProfileId,func: impl Fn(&'a MerchantConnectorAccount) -> T,) -> FxHashSet<T>whereT: std::hash::Hash + Eq,{- self.filter_and_map(|mca| mca.profile_id == profile_id, func)+ self.filter_and_map(|mca| mca.profile_id == *profile_id, func)}}@@ -396,7 +397,7 @@ pub async fn validate_connectors_in_routing_config(state: &SessionState,key_store: &domain::MerchantKeyStore,merchant_id: &common_utils::id_type::MerchantId,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,routing_algorithm: &routing_types::RoutingAlgorithm,) -> RouterResult<()> {let all_mcas = &*state@@ -413,13 +414,13 @@ pub async fn validate_connectors_in_routing_config(})?;let name_mca_id_set = all_mcas.iter()- .filter(|mca| mca.profile_id == profile_id)+ .filter(|mca| mca.profile_id == *profile_id).map(|mca| (&mca.connector_name, mca.get_id())).collect::<FxHashSet<_>>();let name_set = all_mcas.iter()- .filter(|mca| mca.profile_id == profile_id)+ .filter(|mca| mca.profile_id == *profile_id).map(|mca| &mca.connector_name).collect::<FxHashSet<_>>();diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex 02a10252cd..c46fac1322 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -94,7 +94,11 @@ pub async fn construct_payout_router_data<'a, F>(let payouts = &payout_data.payouts;let payout_attempt = &payout_data.payout_attempt;let customer_details = &payout_data.customer_details;- let connector_label = format!("{}_{}", payout_data.profile_id, connector_name);+ let connector_label = format!(+ "{}_{}",+ payout_data.profile_id.get_string_repr(),+ connector_name+ );let connector_customer_id = customer_details.as_ref().and_then(|c| c.connector_customer.as_ref())@@ -394,6 +398,7 @@ pub fn validate_uuid(uuid: String, key: &str) -> Result<String, errors::ApiError#[cfg(test)]mod tests {+ #![allow(clippy::expect_used)]use super::*;#[test]@@ -425,23 +430,33 @@ mod tests {fn test_filter_objects_based_on_profile_id_list() {#[derive(PartialEq, Debug, Clone)]struct Object {- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,}impl Object {- pub fn new(profile_id: &str) -> Self {+ pub fn new(profile_id: &'static str) -> Self {Self {- profile_id: Some(profile_id.to_string()),+ profile_id: Some(+ common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from(+ profile_id,+ ))+ .expect("invalid profile ID"),+ ),}}}impl GetProfileId for Object {- fn get_profile_id(&self) -> Option<&String> {+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {self.profile_id.as_ref()}}+ fn new_profile_id(profile_id: &'static str) -> common_utils::id_type::ProfileId {+ common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from(profile_id))+ .expect("invalid profile ID")+ }+// non empty object_list and profile_id_listlet object_list = vec![Object::new("p1"),@@ -450,7 +465,11 @@ mod tests {Object::new("p4"),Object::new("p5"),];- let profile_id_list = vec!["p1".to_string(), "p2".to_string(), "p3".to_string()];+ let profile_id_list = vec![+ new_profile_id("p1"),+ new_profile_id("p2"),+ new_profile_id("p3"),+ ];let filtered_list =filter_objects_based_on_profile_id_list(Some(profile_id_list), object_list.clone());let expected_result = vec![Object::new("p1"), Object::new("p2"), Object::new("p2")];@@ -1040,7 +1059,7 @@ pub async fn validate_and_get_business_profile(db: &dyn StorageInterface,key_manager_state: &common_utils::types::keymanager::KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,- profile_id: Option<&String>,+ profile_id: Option<&common_utils::id_type::ProfileId>,merchant_id: &common_utils::id_type::MerchantId,) -> RouterResult<Option<domain::BusinessProfile>> {profile_id@@ -1052,7 +1071,7 @@ pub async fn validate_and_get_business_profile().await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_owned(),+ id: profile_id.get_string_repr().to_owned(),})}).await@@ -1061,7 +1080,7 @@ pub async fn validate_and_get_business_profile(// Check if the merchant_id of business profile is same as the current merchant_idif business_profile.merchant_id.ne(merchant_id) {Err(errors::ApiErrorResponse::AccessForbidden {- resource: business_profile.profile_id,+ resource: business_profile.profile_id.get_string_repr().to_owned(),}.into())} else {@@ -1123,10 +1142,10 @@ pub async fn get_profile_id_from_business_details(business_country: Option<api_models::enums::CountryAlpha2>,business_label: Option<&String>,merchant_account: &domain::MerchantAccount,- request_profile_id: Option<&String>,+ request_profile_id: Option<&common_utils::id_type::ProfileId>,db: &dyn StorageInterface,should_validate: bool,-) -> RouterResult<String> {+) -> RouterResult<common_utils::id_type::ProfileId> {match request_profile_id.or(merchant_account.default_profile.as_ref()) {Some(profile_id) => {// Check whether this business profile belongs to the merchant@@ -1297,55 +1316,55 @@ pub fn get_incremental_authorization_allowed_value(}pub(super) trait GetProfileId {- fn get_profile_id(&self) -> Option<&String>;+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId>;}impl GetProfileId for MerchantConnectorAccount {- fn get_profile_id(&self) -> Option<&String> {+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {Some(&self.profile_id)}}impl GetProfileId for storage::PaymentIntent {- fn get_profile_id(&self) -> Option<&String> {+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {self.profile_id.as_ref()}}impl<A> GetProfileId for (storage::PaymentIntent, A) {- fn get_profile_id(&self) -> Option<&String> {+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {self.0.get_profile_id()}}impl GetProfileId for diesel_models::Dispute {- fn get_profile_id(&self) -> Option<&String> {+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {self.profile_id.as_ref()}}impl GetProfileId for diesel_models::Refund {- fn get_profile_id(&self) -> Option<&String> {+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {self.profile_id.as_ref()}}#[cfg(feature = "payouts")]impl GetProfileId for storage::Payouts {- fn get_profile_id(&self) -> Option<&String> {+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {Some(&self.profile_id)}}#[cfg(feature = "payouts")]impl<T, F> GetProfileId for (storage::Payouts, T, F) {- fn get_profile_id(&self) -> Option<&String> {+ fn get_profile_id(&self) -> Option<&common_utils::id_type::ProfileId> {self.0.get_profile_id()}}/// Filter Objects based on profile idspub(super) fn filter_objects_based_on_profile_id_list<T: GetProfileId>(- profile_id_list_auth_layer: Option<Vec<String>>,+ profile_id_list_auth_layer: Option<Vec<common_utils::id_type::ProfileId>>,object_list: Vec<T>,) -> Vec<T> {if let Some(profile_id_list) = profile_id_list_auth_layer {@@ -1369,7 +1388,7 @@ pub(super) fn filter_objects_based_on_profile_id_list<T: GetProfileId>(}pub(super) fn validate_profile_id_from_auth_layer<T: GetProfileId + std::fmt::Debug>(- profile_id_auth_layer: Option<String>,+ profile_id_auth_layer: Option<common_utils::id_type::ProfileId>,object: &T,) -> RouterResult<()> {match (profile_id_auth_layer, object.get_profile_id()) {diff --git a/crates/router/src/core/verification.rs b/crates/router/src/core/verification.rsindex 795e188c8a..44bb67d0ba 100644--- a/crates/router/src/core/verification.rs+++ b/crates/router/src/core/verification.rs@@ -12,7 +12,7 @@ pub async fn verify_merchant_creds_for_applepay(state: SessionState,body: verifications::ApplepayMerchantVerificationRequest,merchant_id: common_utils::id_type::MerchantId,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,) -> CustomResult<services::ApplicationResponse<ApplepayMerchantResponse>, errors::ApiErrorResponse>{let applepay_merchant_configs = state.conf.applepay_merchant_configs.get_inner();diff --git a/crates/router/src/core/verification/utils.rs b/crates/router/src/core/verification/utils.rsindex dd0aa3edef..4b8e0ac074 100644--- a/crates/router/src/core/verification/utils.rs+++ b/crates/router/src/core/verification/utils.rs@@ -15,7 +15,7 @@ use crate::{pub async fn check_existence_and_add_domain_to_db(state: &SessionState,merchant_id: common_utils::id_type::MerchantId,- profile_id_from_auth_layer: Option<String>,+ profile_id_from_auth_layer: Option<common_utils::id_type::ProfileId>,merchant_connector_id: String,domain_from_req: Vec<String>,) -> CustomResult<Vec<String>, errors::ApiErrorResponse> {diff --git a/crates/router/src/core/verify_connector.rs b/crates/router/src/core/verify_connector.rsindex b6f03c27ab..f7fa06dee5 100644--- a/crates/router/src/core/verify_connector.rs+++ b/crates/router/src/core/verify_connector.rs@@ -19,7 +19,7 @@ use crate::{pub async fn verify_connector_credentials(state: SessionState,req: VerifyConnectorRequest,- _profile_id: Option<String>,+ _profile_id: Option<common_utils::id_type::ProfileId>,) -> errors::RouterResponse<()> {let boxed_connector = api::ConnectorData::get_connector_by_name(&state.conf.connectors,diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex d3e5873e9e..01a1046be3 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -347,14 +347,14 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>()?,};- let profile_id = merchant_connector_account.profile_id.as_ref();+ let profile_id = &merchant_connector_account.profile_id;let business_profile = state.store.find_business_profile_by_profile_id(key_manager_state, &key_store, profile_id).await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),})?;match flow_type {diff --git a/crates/router/src/core/webhooks/outgoing.rs b/crates/router/src/core/webhooks/outgoing.rsindex b075b15e7f..276d296a4c 100644--- a/crates/router/src/core/webhooks/outgoing.rs+++ b/crates/router/src/core/webhooks/outgoing.rs@@ -71,7 +71,7 @@ pub(crate) async fn create_event_and_trigger_outgoing_webhook(|| webhook_url_result.as_ref().is_ok_and(String::is_empty){logger::debug!(- business_profile_id=%business_profile.profile_id,+ business_profile_id=?business_profile.profile_id,%idempotent_event_id,"Outgoing webhooks are disabled in application configuration, or merchant webhook URL \could not be obtained; skipping outgoing webhooks for event"diff --git a/crates/router/src/core/webhooks/types.rs b/crates/router/src/core/webhooks/types.rsindex d9eed529e8..d9094bff00 100644--- a/crates/router/src/core/webhooks/types.rs+++ b/crates/router/src/core/webhooks/types.rs@@ -59,7 +59,7 @@ impl OutgoingWebhookType for webhooks::OutgoingWebhook {#[derive(Debug, serde::Serialize, serde::Deserialize)]pub(crate) struct OutgoingWebhookTrackingData {pub(crate) merchant_id: common_utils::id_type::MerchantId,- pub(crate) business_profile_id: String,+ pub(crate) business_profile_id: common_utils::id_type::ProfileId,pub(crate) event_type: enums::EventType,pub(crate) event_class: enums::EventClass,pub(crate) primary_object_id: String,diff --git a/crates/router/src/core/webhooks/webhook_events.rs b/crates/router/src/core/webhooks/webhook_events.rsindex cf4a8d8726..13f1e95fc2 100644--- a/crates/router/src/core/webhooks/webhook_events.rs+++ b/crates/router/src/core/webhooks/webhook_events.rs@@ -265,7 +265,7 @@ pub async fn retry_delivery_attempt(async fn get_account_and_key_store(state: SessionState,merchant_id: common_utils::id_type::MerchantId,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,) -> errors::RouterResult<(MerchantAccountOrBusinessProfile, domain::MerchantKeyStore)> {let store = state.store.as_ref();let key_manager_state = &(&state).into();@@ -292,13 +292,13 @@ async fn get_account_and_key_store(.await.attach_printable_lazy(|| {format!(- "Failed to find business profile by merchant_id `{merchant_id:?}` and profile_id `{profile_id}`. \- The merchant_id associated with the business profile `{profile_id}` may be \+ "Failed to find business profile by merchant_id `{merchant_id:?}` and profile_id `{profile_id:?}`. \+ The merchant_id associated with the business profile `{profile_id:?}` may be \different than the merchant_id specified (`{merchant_id:?}`).")}).to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id,+ id: profile_id.get_string_repr().to_owned(),})?;Ok((diff --git a/crates/router/src/db/business_profile.rs b/crates/router/src/db/business_profile.rsindex ed178f275f..8c81b0c3df 100644--- a/crates/router/src/db/business_profile.rs+++ b/crates/router/src/db/business_profile.rs@@ -33,7 +33,7 @@ where&self,key_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> CustomResult<domain::BusinessProfile, errors::StorageError>;async fn find_business_profile_by_merchant_id_profile_id(@@ -41,7 +41,7 @@ wherekey_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,merchant_id: &common_utils::id_type::MerchantId,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> CustomResult<domain::BusinessProfile, errors::StorageError>;async fn find_business_profile_by_profile_name_merchant_id(@@ -62,7 +62,7 @@ whereasync fn delete_business_profile_by_profile_id_merchant_id(&self,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError>;@@ -105,7 +105,7 @@ impl BusinessProfileInterface for Store {&self,key_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> CustomResult<domain::BusinessProfile, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;storage::BusinessProfile::find_by_profile_id(&conn, profile_id)@@ -125,7 +125,7 @@ impl BusinessProfileInterface for Store {key_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,merchant_id: &common_utils::id_type::MerchantId,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> CustomResult<domain::BusinessProfile, errors::StorageError> {let conn = connection::pg_connection_read(self).await?;storage::BusinessProfile::find_by_merchant_id_profile_id(&conn, merchant_id, profile_id)@@ -191,7 +191,7 @@ impl BusinessProfileInterface for Store {#[instrument(skip_all)]async fn delete_business_profile_by_profile_id_merchant_id(&self,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,merchant_id: &common_utils::id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -262,13 +262,13 @@ impl BusinessProfileInterface for MockDb {&self,key_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> CustomResult<domain::BusinessProfile, errors::StorageError> {self.business_profiles.lock().await.iter()- .find(|business_profile| business_profile.profile_id == profile_id)+ .find(|business_profile| business_profile.profile_id == *profile_id).cloned().async_map(|business_profile| async {business_profile@@ -284,7 +284,7 @@ impl BusinessProfileInterface for MockDb {.transpose()?.ok_or(errors::StorageError::ValueNotFound(format!(- "No business profile found for profile_id = {profile_id}"+ "No business profile found for profile_id = {profile_id:?}")).into(),)@@ -295,7 +295,7 @@ impl BusinessProfileInterface for MockDb {key_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,merchant_id: &common_utils::id_type::MerchantId,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> CustomResult<domain::BusinessProfile, errors::StorageError> {self.business_profiles.lock()@@ -303,7 +303,7 @@ impl BusinessProfileInterface for MockDb {.iter().find(|business_profile| {business_profile.merchant_id == *merchant_id- && business_profile.profile_id == profile_id+ && business_profile.profile_id == *profile_id}).cloned().async_map(|business_profile| async {@@ -320,7 +320,7 @@ impl BusinessProfileInterface for MockDb {.transpose()?.ok_or(errors::StorageError::ValueNotFound(format!(- "No business profile found for merchant_id = {merchant_id:?} and profile_id = {profile_id}"+ "No business profile found for merchant_id = {merchant_id:?} and profile_id = {profile_id:?}")).into(),)@@ -362,7 +362,7 @@ impl BusinessProfileInterface for MockDb {.transpose()?.ok_or(errors::StorageError::ValueNotFound(format!(- "No business profile found for profile_id = {profile_id}"+ "No business profile found for profile_id = {profile_id:?}")).into(),)@@ -370,18 +370,18 @@ impl BusinessProfileInterface for MockDb {async fn delete_business_profile_by_profile_id_merchant_id(&self,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,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(|business_profile| {- business_profile.profile_id == profile_id+ business_profile.profile_id == *profile_id&& business_profile.merchant_id == *merchant_id}).ok_or::<errors::StorageError>(errors::StorageError::ValueNotFound(format!(- "No business profile found for profile_id = {profile_id} and merchant_id = {merchant_id:?}"+ "No business profile found for profile_id = {profile_id:?} and merchant_id = {merchant_id:?}")))?;business_profiles.remove(index);Ok(true)diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex edd1eecff9..6aae49f1bd 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -67,7 +67,7 @@ whereasync fn list_initial_events_by_profile_id_primary_object_id(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,primary_object_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError>;@@ -76,7 +76,7 @@ whereasync fn list_initial_events_by_profile_id_constraints(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,created_after: Option<time::PrimitiveDateTime>,created_before: Option<time::PrimitiveDateTime>,limit: Option<i64>,@@ -256,7 +256,7 @@ impl EventInterface for Store {async fn list_initial_events_by_profile_id_primary_object_id(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,primary_object_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -291,7 +291,7 @@ impl EventInterface for Store {async fn list_initial_events_by_profile_id_constraints(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,created_after: Option<time::PrimitiveDateTime>,created_before: Option<time::PrimitiveDateTime>,limit: Option<i64>,@@ -554,7 +554,7 @@ impl EventInterface for MockDb {async fn list_initial_events_by_profile_id_primary_object_id(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,primary_object_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -589,7 +589,7 @@ impl EventInterface for MockDb {async fn list_initial_events_by_profile_id_constraints(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,created_after: Option<time::PrimitiveDateTime>,created_before: Option<time::PrimitiveDateTime>,limit: Option<i64>,@@ -737,7 +737,8 @@ mod tests {let merchant_id =common_utils::id_type::MerchantId::try_from(std::borrow::Cow::from("merchant_1")).unwrap();- let business_profile_id = "profile1";+ let business_profile_id =+ common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from("profile1")).unwrap();let payment_id = "test_payment_id";let key_manager_state = &state.into();let master_key = mockdb.get_master_key();diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rsindex c02304c7b4..37613d5961 100644--- a/crates/router/src/db/kafka_store.rs+++ b/crates/router/src/db/kafka_store.rs@@ -714,7 +714,7 @@ impl EventInterface for KafkaStore {async fn list_initial_events_by_profile_id_primary_object_id(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &id_type::ProfileId,primary_object_id: &str,merchant_key_store: &domain::MerchantKeyStore,) -> CustomResult<Vec<domain::Event>, errors::StorageError> {@@ -731,7 +731,7 @@ impl EventInterface for KafkaStore {async fn list_initial_events_by_profile_id_constraints(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &id_type::ProfileId,created_after: Option<PrimitiveDateTime>,created_before: Option<PrimitiveDateTime>,limit: Option<i64>,@@ -1129,7 +1129,7 @@ impl MerchantConnectorAccountInterface for KafkaStore {async fn find_merchant_connector_account_by_profile_id_connector_name(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &id_type::ProfileId,connector_name: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -2373,7 +2373,7 @@ impl BusinessProfileInterface for KafkaStore {&self,key_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,- profile_id: &str,+ profile_id: &id_type::ProfileId,) -> CustomResult<domain::BusinessProfile, errors::StorageError> {self.diesel_store.find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_id)@@ -2385,7 +2385,7 @@ impl BusinessProfileInterface for KafkaStore {key_manager_state: &KeyManagerState,merchant_key_store: &domain::MerchantKeyStore,merchant_id: &id_type::MerchantId,- profile_id: &str,+ profile_id: &id_type::ProfileId,) -> CustomResult<domain::BusinessProfile, errors::StorageError> {self.diesel_store.find_business_profile_by_merchant_id_profile_id(@@ -2416,7 +2416,7 @@ impl BusinessProfileInterface for KafkaStore {async fn delete_business_profile_by_profile_id_merchant_id(&self,- profile_id: &str,+ profile_id: &id_type::ProfileId,merchant_id: &id_type::MerchantId,) -> CustomResult<bool, errors::StorageError> {self.diesel_store@@ -2493,7 +2493,7 @@ impl RoutingAlgorithmInterface for KafkaStore {async fn find_routing_algorithm_by_profile_id_algorithm_id(&self,- profile_id: &str,+ profile_id: &id_type::ProfileId,algorithm_id: &str,) -> CustomResult<storage::RoutingAlgorithm, errors::StorageError> {self.diesel_store@@ -2514,7 +2514,7 @@ impl RoutingAlgorithmInterface for KafkaStore {async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(&self,algorithm_id: &str,- profile_id: &str,+ profile_id: &id_type::ProfileId,) -> CustomResult<storage::RoutingProfileMetadata, errors::StorageError> {self.diesel_store.find_routing_algorithm_metadata_by_algorithm_id_profile_id(algorithm_id, profile_id)@@ -2523,7 +2523,7 @@ impl RoutingAlgorithmInterface for KafkaStore {async fn list_routing_algorithm_metadata_by_profile_id(&self,- profile_id: &str,+ profile_id: &id_type::ProfileId,limit: i64,offset: i64,) -> CustomResult<Vec<storage::RoutingProfileMetadata>, errors::StorageError> {@@ -2807,7 +2807,7 @@ impl UserRoleInterface for KafkaStore {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {self.diesel_store@@ -2826,7 +2826,7 @@ impl UserRoleInterface for KafkaStore {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,update: user_storage::UserRoleUpdate,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {@@ -2847,7 +2847,7 @@ impl UserRoleInterface for KafkaStore {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {self.diesel_store@@ -2876,7 +2876,7 @@ impl UserRoleInterface for KafkaStore {user_id: &str,org_id: Option<&id_type::OrganizationId>,merchant_id: Option<&id_type::MerchantId>,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,entity_id: Option<&String>,version: Option<enums::UserRoleVersion>,) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {diff --git a/crates/router/src/db/merchant_account.rs b/crates/router/src/db/merchant_account.rsindex 5a828ebb0c..8aa013ab08 100644--- a/crates/router/src/db/merchant_account.rs+++ b/crates/router/src/db/merchant_account.rs@@ -589,7 +589,7 @@ async fn publish_and_redact_merchant_account_cache(format!("cgraph_{}_{}",merchant_account.get_id().get_string_repr(),- profile_id,+ profile_id.get_string_repr(),).into(),)diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rsindex f039728de4..1908e01e94 100644--- a/crates/router/src/db/merchant_connector_account.rs+++ b/crates/router/src/db/merchant_connector_account.rs@@ -141,7 +141,7 @@ whereasync fn find_merchant_connector_account_by_profile_id_connector_name(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,connector_name: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError>;@@ -290,7 +290,7 @@ impl MerchantConnectorAccountInterface for Store {async fn find_merchant_connector_account_by_profile_id_connector_name(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,connector_name: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -322,7 +322,7 @@ impl MerchantConnectorAccountInterface for Store {{cache::get_or_populate_in_memory(self,- &format!("{}_{}", profile_id, connector_name),+ &format!("{}_{}", profile_id.get_string_repr(), connector_name),find_call,&cache::ACCOUNTS_CACHE,)@@ -587,7 +587,7 @@ impl MerchantConnectorAccountInterface for Store {self,[cache::CacheKind::Accounts(- format!("{}_{}", _profile_id, _connector_name).into(),+ format!("{}_{}", _profile_id.get_string_repr(), _connector_name).into(),),cache::CacheKind::Accounts(format!(@@ -598,8 +598,12 @@ impl MerchantConnectorAccountInterface for Store {.into(),),cache::CacheKind::CGraph(- format!("cgraph_{}_{_profile_id}", _merchant_id.get_string_repr())- .into(),+ format!(+ "cgraph_{}_{}",+ _merchant_id.get_string_repr(),+ _profile_id.get_string_repr()+ )+ .into(),),],|| update,@@ -683,7 +687,7 @@ impl MerchantConnectorAccountInterface for Store {self,[cache::CacheKind::Accounts(- format!("{}_{}", _profile_id, _connector_name).into(),+ format!("{}_{}", _profile_id.get_string_repr(), _connector_name).into(),),cache::CacheKind::Accounts(format!(@@ -694,12 +698,18 @@ impl MerchantConnectorAccountInterface for Store {.into(),),cache::CacheKind::CGraph(- format!("cgraph_{}_{_profile_id}", _merchant_id.get_string_repr()).into(),+ format!(+ "cgraph_{}_{}",+ _merchant_id.get_string_repr(),+ _profile_id.get_string_repr()+ )+ .into(),),cache::CacheKind::PmFiltersCGraph(format!(- "pm_filters_cgraph_{}_{_profile_id}",- _merchant_id.get_string_repr()+ "pm_filters_cgraph_{}_{}",+ _merchant_id.get_string_repr(),+ _profile_id.get_string_repr(),).into(),),@@ -759,7 +769,7 @@ impl MerchantConnectorAccountInterface for Store {self,[cache::CacheKind::Accounts(- format!("{}_{}", _profile_id, _connector_name).into(),+ format!("{}_{}", _profile_id.get_string_repr(), _connector_name).into(),),cache::CacheKind::Accounts(format!(@@ -770,12 +780,18 @@ impl MerchantConnectorAccountInterface for Store {.into(),),cache::CacheKind::CGraph(- format!("cgraph_{}_{_profile_id}", _merchant_id.get_string_repr()).into(),+ format!(+ "cgraph_{}_{}",+ _merchant_id.get_string_repr(),+ _profile_id.get_string_repr()+ )+ .into(),),cache::CacheKind::PmFiltersCGraph(format!(- "pm_filters_cgraph_{}_{_profile_id}",- _merchant_id.get_string_repr()+ "pm_filters_cgraph_{}_{}",+ _merchant_id.get_string_repr(),+ _profile_id.get_string_repr()).into(),),@@ -835,16 +851,26 @@ impl MerchantConnectorAccountInterface for Store {self,[cache::CacheKind::Accounts(- format!("{}_{}", mca.merchant_id.get_string_repr(), _profile_id).into(),+ format!(+ "{}_{}",+ mca.merchant_id.get_string_repr(),+ _profile_id.get_string_repr()+ )+ .into(),),cache::CacheKind::CGraph(- format!("cgraph_{}_{_profile_id}", mca.merchant_id.get_string_repr())- .into(),+ format!(+ "cgraph_{}_{}",+ mca.merchant_id.get_string_repr(),+ _profile_id.get_string_repr()+ )+ .into(),),cache::CacheKind::PmFiltersCGraph(format!(- "pm_filters_cgraph_{}_{_profile_id}",- mca.merchant_id.get_string_repr()+ "pm_filters_cgraph_{}_{}",+ mca.merchant_id.get_string_repr(),+ _profile_id.get_string_repr()).into(),),@@ -890,16 +916,26 @@ impl MerchantConnectorAccountInterface for Store {self,[cache::CacheKind::Accounts(- format!("{}_{}", mca.merchant_id.get_string_repr(), _profile_id).into(),+ format!(+ "{}_{}",+ mca.merchant_id.get_string_repr(),+ _profile_id.get_string_repr()+ )+ .into(),),cache::CacheKind::CGraph(- format!("cgraph_{}_{_profile_id}", mca.merchant_id.get_string_repr())- .into(),+ format!(+ "cgraph_{}_{}",+ mca.merchant_id.get_string_repr(),+ _profile_id.get_string_repr()+ )+ .into(),),cache::CacheKind::PmFiltersCGraph(format!(- "pm_filters_cgraph_{}_{_profile_id}",- mca.merchant_id.get_string_repr()+ "pm_filters_cgraph_{}_{}",+ mca.merchant_id.get_string_repr(),+ _profile_id.get_string_repr()).into(),),@@ -1016,7 +1052,7 @@ impl MerchantConnectorAccountInterface for MockDb {async fn find_merchant_connector_account_by_profile_id_connector_name(&self,state: &KeyManagerState,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,connector_name: &str,key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {@@ -1475,7 +1511,9 @@ mod merchant_connector_account_cache_tests {let connector_label = "stripe_USA";let merchant_connector_id = "simple_merchant_connector_id";- let profile_id = "pro_max_ultra";+ let profile_id =+ common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from("pro_max_ultra"))+ .unwrap();let key_manager_state = &state.into();db.insert_merchant_key_store(key_manager_state,@@ -1536,7 +1574,7 @@ mod merchant_connector_account_cache_tests {created_at: date_time::now(),modified_at: date_time::now(),connector_webhook_details: None,- profile_id: profile_id.to_string(),+ profile_id: profile_id.to_owned(),applepay_verified_domains: None,pm_auth_config: None,status: common_enums::ConnectorStatus::Inactive,@@ -1564,7 +1602,7 @@ mod merchant_connector_account_cache_tests {Conversion::convert(db.find_merchant_connector_account_by_profile_id_connector_name(key_manager_state,- profile_id,+ &profile_id,&mca.connector_name,&merchant_key,)@@ -1576,7 +1614,11 @@ mod merchant_connector_account_cache_tests {};let _: storage::MerchantConnectorAccount = cache::get_or_populate_in_memory(&db,- &format!("{}_{}", merchant_id.get_string_repr(), profile_id),+ &format!(+ "{}_{}",+ merchant_id.get_string_repr(),+ profile_id.get_string_repr(),+ ),find_call,&ACCOUNTS_CACHE,)@@ -1644,7 +1686,9 @@ mod merchant_connector_account_cache_tests {.unwrap();let connector_label = "stripe_USA";let id = "simple_id";- let profile_id = "pro_max_ultra";+ let profile_id =+ common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from("pro_max_ultra"))+ .unwrap();let key_manager_state = &state.into();db.insert_merchant_key_store(key_manager_state,@@ -1701,7 +1745,7 @@ mod merchant_connector_account_cache_tests {created_at: date_time::now(),modified_at: date_time::now(),connector_webhook_details: None,- profile_id: profile_id.to_string(),+ profile_id: profile_id.to_owned(),applepay_verified_domains: None,pm_auth_config: None,status: common_enums::ConnectorStatus::Inactive,@@ -1748,7 +1792,11 @@ mod merchant_connector_account_cache_tests {let _: storage::MerchantConnectorAccount = cache::get_or_populate_in_memory(&db,- &format!("{}_{}", merchant_id.clone().get_string_repr(), profile_id),+ &format!(+ "{}_{}",+ merchant_id.clone().get_string_repr(),+ profile_id.get_string_repr()+ ),find_call,&ACCOUNTS_CACHE,)diff --git a/crates/router/src/db/routing_algorithm.rs b/crates/router/src/db/routing_algorithm.rsindex ad4b3bd919..5672777bfa 100644--- a/crates/router/src/db/routing_algorithm.rs+++ b/crates/router/src/db/routing_algorithm.rs@@ -20,7 +20,7 @@ pub trait RoutingAlgorithmInterface {async fn find_routing_algorithm_by_profile_id_algorithm_id(&self,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,algorithm_id: &str,) -> StorageResult<routing_storage::RoutingAlgorithm>;@@ -33,12 +33,12 @@ pub trait RoutingAlgorithmInterface {async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(&self,algorithm_id: &str,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> StorageResult<routing_storage::RoutingProfileMetadata>;async fn list_routing_algorithm_metadata_by_profile_id(&self,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,limit: i64,offset: i64,) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>>;@@ -76,7 +76,7 @@ impl RoutingAlgorithmInterface for Store {#[instrument(skip_all)]async fn find_routing_algorithm_by_profile_id_algorithm_id(&self,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,algorithm_id: &str,) -> StorageResult<routing_storage::RoutingAlgorithm> {let conn = connection::pg_connection_write(self).await?;@@ -109,7 +109,7 @@ impl RoutingAlgorithmInterface for Store {async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(&self,algorithm_id: &str,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,) -> StorageResult<routing_storage::RoutingProfileMetadata> {let conn = connection::pg_connection_write(self).await?;routing_storage::RoutingAlgorithm::find_metadata_by_algorithm_id_profile_id(@@ -124,7 +124,7 @@ impl RoutingAlgorithmInterface for Store {#[instrument(skip_all)]async fn list_routing_algorithm_metadata_by_profile_id(&self,- profile_id: &str,+ profile_id: &common_utils::id_type::ProfileId,limit: i64,offset: i64,) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> {@@ -185,7 +185,7 @@ impl RoutingAlgorithmInterface for MockDb {async fn find_routing_algorithm_by_profile_id_algorithm_id(&self,- _profile_id: &str,+ _profile_id: &common_utils::id_type::ProfileId,_algorithm_id: &str,) -> StorageResult<routing_storage::RoutingAlgorithm> {Err(errors::StorageError::MockDbError)?@@ -202,14 +202,14 @@ impl RoutingAlgorithmInterface for MockDb {async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id(&self,_algorithm_id: &str,- _profile_id: &str,+ _profile_id: &common_utils::id_type::ProfileId,) -> StorageResult<routing_storage::RoutingProfileMetadata> {Err(errors::StorageError::MockDbError)?}async fn list_routing_algorithm_metadata_by_profile_id(&self,- _profile_id: &str,+ _profile_id: &common_utils::id_type::ProfileId,_limit: i64,_offset: i64,) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> {diff --git a/crates/router/src/db/user_role.rs b/crates/router/src/db/user_role.rsindex f028437b34..524eaaaab7 100644--- a/crates/router/src/db/user_role.rs+++ b/crates/router/src/db/user_role.rs@@ -47,7 +47,7 @@ pub trait UserRoleInterface {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError>;@@ -56,7 +56,7 @@ pub trait UserRoleInterface {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,update: storage::UserRoleUpdate,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError>;@@ -66,7 +66,7 @@ pub trait UserRoleInterface {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError>;@@ -75,7 +75,7 @@ pub trait UserRoleInterface {user_id: &str,org_id: Option<&id_type::OrganizationId>,merchant_id: Option<&id_type::MerchantId>,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,entity_id: Option<&String>,version: Option<enums::UserRoleVersion>,) -> CustomResult<Vec<storage::UserRole>, errors::StorageError>;@@ -155,7 +155,7 @@ impl UserRoleInterface for Store {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -177,7 +177,7 @@ impl UserRoleInterface for Store {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,update: storage::UserRoleUpdate,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {@@ -201,7 +201,7 @@ impl UserRoleInterface for Store {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {let conn = connection::pg_connection_write(self).await?;@@ -222,7 +222,7 @@ impl UserRoleInterface for Store {user_id: &str,org_id: Option<&id_type::OrganizationId>,merchant_id: Option<&id_type::MerchantId>,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,entity_id: Option<&String>,version: Option<enums::UserRoleVersion>,) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {@@ -377,7 +377,7 @@ impl UserRoleInterface for MockDb {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {let user_roles = self.user_roles.lock().await;@@ -416,7 +416,7 @@ impl UserRoleInterface for MockDb {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,update: storage::UserRoleUpdate,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {@@ -470,7 +470,7 @@ impl UserRoleInterface for MockDb {user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,version: enums::UserRoleVersion,) -> CustomResult<storage::UserRole, errors::StorageError> {let mut user_roles = self.user_roles.lock().await;@@ -510,7 +510,7 @@ impl UserRoleInterface for MockDb {user_id: &str,org_id: Option<&id_type::OrganizationId>,merchant_id: Option<&id_type::MerchantId>,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,entity_id: Option<&String>,version: Option<enums::UserRoleVersion>,) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rsindex 80ee049484..343246e31a 100644--- a/crates/router/src/routes/admin.rs+++ b/crates/router/src/routes/admin.rs@@ -946,7 +946,10 @@ pub async fn business_profile_create(pub async fn business_profile_retrieve(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(common_utils::id_type::MerchantId, String)>,+ path: web::Path<(+ common_utils::id_type::MerchantId,+ common_utils::id_type::ProfileId,+ )>,) -> HttpResponse {let flow = Flow::BusinessProfileRetrieve;let (merchant_id, profile_id) = path.into_inner();@@ -975,7 +978,7 @@ pub async fn business_profile_retrieve(pub async fn business_profile_retrieve(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::ProfileId>,) -> HttpResponse {let flow = Flow::BusinessProfileRetrieve;let profile_id = path.into_inner();@@ -1015,7 +1018,10 @@ pub async fn business_profile_retrieve(pub async fn business_profile_update(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(common_utils::id_type::MerchantId, String)>,+ path: web::Path<(+ common_utils::id_type::MerchantId,+ common_utils::id_type::ProfileId,+ )>,json_payload: web::Json<api_models::admin::BusinessProfileUpdate>,) -> HttpResponse {let flow = Flow::BusinessProfileUpdate;@@ -1045,7 +1051,7 @@ pub async fn business_profile_update(pub async fn business_profile_update(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::ProfileId>,json_payload: web::Json<api_models::admin::BusinessProfileUpdate>,) -> HttpResponse {let flow = Flow::BusinessProfileUpdate;@@ -1081,7 +1087,10 @@ pub async fn business_profile_update(pub async fn business_profile_delete(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(common_utils::id_type::MerchantId, String)>,+ path: web::Path<(+ common_utils::id_type::MerchantId,+ common_utils::id_type::ProfileId,+ )>,) -> HttpResponse {let flow = Flow::BusinessProfileDelete;let (merchant_id, profile_id) = path.into_inner();@@ -1129,7 +1138,10 @@ pub async fn business_profiles_list(pub async fn toggle_connector_agnostic_mit(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(common_utils::id_type::MerchantId, String)>,+ path: web::Path<(+ common_utils::id_type::MerchantId,+ common_utils::id_type::ProfileId,+ )>,json_payload: web::Json<api_models::admin::ConnectorAgnosticMitChoice>,) -> HttpResponse {let flow = Flow::ToggleConnectorAgnosticMit;@@ -1200,7 +1212,10 @@ pub async fn merchant_account_transfer_keys(pub async fn toggle_extended_card_info(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<(common_utils::id_type::MerchantId, String)>,+ path: web::Path<(+ common_utils::id_type::MerchantId,+ common_utils::id_type::ProfileId,+ )>,json_payload: web::Json<api_models::admin::ExtendedCardInfoChoice>,) -> HttpResponse {let flow = Flow::ToggleExtendedCardInfo;diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rsindex 11cdf4eb7e..63c40580e5 100644--- a/crates/router/src/routes/payments.rs+++ b/crates/router/src/routes/payments.rs@@ -1327,7 +1327,7 @@ async fn authorize_verify_select<Op>(state: app::SessionState,req_state: ReqState,merchant_account: domain::MerchantAccount,- profile_id: Option<String>,+ profile_id: Option<common_utils::id_type::ProfileId>,key_store: domain::MerchantKeyStore,header_payload: HeaderPayload,req: api_models::payments::PaymentsRequest,diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rsindex 79e8ec11f2..61d89e5e77 100644--- a/crates/router/src/routes/routing.rs+++ b/crates/router/src/routes/routing.rs@@ -96,7 +96,7 @@ pub async fn routing_link_config(pub async fn routing_link_config(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::ProfileId>,json_payload: web::Json<routing_types::RoutingAlgorithmId>,transaction_type: &enums::TransactionType,) -> impl Responder {@@ -209,7 +209,7 @@ pub async fn list_routing_configs(pub async fn routing_unlink_config(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::ProfileId>,transaction_type: &enums::TransactionType,) -> impl Responder {let flow = Flow::RoutingUnlinkConfig;@@ -290,7 +290,7 @@ pub async fn routing_unlink_config(pub async fn routing_update_default_config(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::ProfileId>,json_payload: web::Json<Vec<routing_types::RoutableConnectorChoice>>,) -> impl Responder {let wrapper = routing_types::ProfileDefaultRoutingConfig {@@ -372,7 +372,7 @@ pub async fn routing_update_default_config(pub async fn routing_retrieve_default_config(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::ProfileId>,) -> impl Responder {Box::pin(oss_api::server_wrap(Flow::RoutingRetrieveDefaultConfig,@@ -674,7 +674,7 @@ pub async fn routing_retrieve_linked_config(state: web::Data<AppState>,req: HttpRequest,query: web::Query<RoutingRetrieveQuery>,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::ProfileId>,transaction_type: &enums::TransactionType,) -> impl Responder {use crate::services::authentication::AuthenticationData;@@ -753,7 +753,7 @@ pub async fn routing_retrieve_default_config_for_profiles(pub async fn routing_update_default_config_for_profile(state: web::Data<AppState>,req: HttpRequest,- path: web::Path<String>,+ path: web::Path<common_utils::id_type::ProfileId>,json_payload: web::Json<Vec<routing_types::RoutableConnectorChoice>>,transaction_type: &enums::TransactionType,) -> impl Responder {diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rsindex 9ab2e2e3b0..f1de552822 100644--- a/crates/router/src/services/authentication.rs+++ b/crates/router/src/services/authentication.rs@@ -59,14 +59,14 @@ mod detached;pub struct AuthenticationData {pub merchant_account: domain::MerchantAccount,pub key_store: domain::MerchantKeyStore,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,}#[derive(Clone, Debug)]pub struct AuthenticationDataWithMultipleProfiles {pub merchant_account: domain::MerchantAccount,pub key_store: domain::MerchantKeyStore,- pub profile_id_list: Option<Vec<String>>,+ pub profile_id_list: Option<Vec<id_type::ProfileId>>,}#[derive(Clone, Debug, Eq, PartialEq, Serialize)]@@ -195,7 +195,7 @@ pub struct AuthToken {pub role_id: String,pub exp: u64,pub org_id: id_type::OrganizationId,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,}#[cfg(feature = "olap")]@@ -206,7 +206,7 @@ impl AuthToken {role_id: String,settings: &Settings,org_id: id_type::OrganizationId,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,) -> UserResult<String> {let exp_duration = std::time::Duration::from_secs(consts::JWT_TOKEN_TIME_IN_SECS);let exp = jwt::generate_exp(exp_duration)?.as_secs();@@ -228,7 +228,7 @@ pub struct UserFromToken {pub merchant_id: id_type::MerchantId,pub role_id: String,pub org_id: id_type::OrganizationId,- pub profile_id: Option<String>,+ pub profile_id: Option<id_type::ProfileId>,}pub struct UserIdFromAuth {diff --git a/crates/router/src/services/kafka/authentication.rs b/crates/router/src/services/kafka/authentication.rsindex be3e093334..42079525d8 100644--- a/crates/router/src/services/kafka/authentication.rs+++ b/crates/router/src/services/kafka/authentication.rs@@ -35,7 +35,7 @@ pub struct KafkaAuthentication<'a> {pub acs_reference_number: Option<&'a String>,pub acs_trans_id: Option<&'a String>,pub acs_signed_content: Option<&'a String>,- pub profile_id: &'a String,+ pub profile_id: &'a common_utils::id_type::ProfileId,pub payment_id: Option<&'a String>,pub merchant_connector_id: &'a String,pub ds_trans_id: Option<&'a String>,diff --git a/crates/router/src/services/kafka/authentication_event.rs b/crates/router/src/services/kafka/authentication_event.rsindex 3f10c7596a..6213488a6d 100644--- a/crates/router/src/services/kafka/authentication_event.rs+++ b/crates/router/src/services/kafka/authentication_event.rs@@ -36,7 +36,7 @@ pub struct KafkaAuthenticationEvent<'a> {pub acs_reference_number: Option<&'a String>,pub acs_trans_id: Option<&'a String>,pub acs_signed_content: Option<&'a String>,- pub profile_id: &'a String,+ pub profile_id: &'a common_utils::id_type::ProfileId,pub payment_id: Option<&'a String>,pub merchant_connector_id: &'a String,pub ds_trans_id: Option<&'a String>,diff --git a/crates/router/src/services/kafka/dispute.rs b/crates/router/src/services/kafka/dispute.rsindex b4b493a79d..6f789cbe94 100644--- a/crates/router/src/services/kafka/dispute.rs+++ b/crates/router/src/services/kafka/dispute.rs@@ -30,7 +30,7 @@ pub struct KafkaDispute<'a> {pub modified_at: OffsetDateTime,pub connector: &'a String,pub evidence: &'a Secret<serde_json::Value>,- pub profile_id: Option<&'a String>,+ pub profile_id: Option<&'a common_utils::id_type::ProfileId>,pub merchant_connector_id: Option<&'a String>,}diff --git a/crates/router/src/services/kafka/dispute_event.rs b/crates/router/src/services/kafka/dispute_event.rsindex d6cb5d5849..e425491259 100644--- a/crates/router/src/services/kafka/dispute_event.rs+++ b/crates/router/src/services/kafka/dispute_event.rs@@ -31,7 +31,7 @@ pub struct KafkaDisputeEvent<'a> {pub modified_at: OffsetDateTime,pub connector: &'a String,pub evidence: &'a Secret<serde_json::Value>,- pub profile_id: Option<&'a String>,+ pub profile_id: Option<&'a common_utils::id_type::ProfileId>,pub merchant_connector_id: Option<&'a String>,}diff --git a/crates/router/src/services/kafka/payment_intent.rs b/crates/router/src/services/kafka/payment_intent.rsindex 3296956797..29aa563283 100644--- a/crates/router/src/services/kafka/payment_intent.rs+++ b/crates/router/src/services/kafka/payment_intent.rs@@ -33,7 +33,7 @@ pub struct KafkaPaymentIntent<'a> {pub business_country: Option<storage_enums::CountryAlpha2>,pub business_label: Option<&'a String>,pub attempt_count: i16,- pub profile_id: Option<&'a String>,+ pub profile_id: Option<&'a id_type::ProfileId>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,pub billing_details: Option<Encryptable<Secret<Value>>>,pub shipping_details: Option<Encryptable<Secret<Value>>>,diff --git a/crates/router/src/services/kafka/payment_intent_event.rs b/crates/router/src/services/kafka/payment_intent_event.rsindex f5186a0b2b..50d2c48a4b 100644--- a/crates/router/src/services/kafka/payment_intent_event.rs+++ b/crates/router/src/services/kafka/payment_intent_event.rs@@ -34,7 +34,7 @@ pub struct KafkaPaymentIntentEvent<'a> {pub business_country: Option<storage_enums::CountryAlpha2>,pub business_label: Option<&'a String>,pub attempt_count: i16,- pub profile_id: Option<&'a String>,+ pub profile_id: Option<&'a id_type::ProfileId>,pub payment_confirm_source: Option<storage_enums::PaymentSource>,pub billing_details: Option<Encryptable<Secret<Value>>>,pub shipping_details: Option<Encryptable<Secret<Value>>>,diff --git a/crates/router/src/services/kafka/payout.rs b/crates/router/src/services/kafka/payout.rsindex ca89a34f18..08733c4600 100644--- a/crates/router/src/services/kafka/payout.rs+++ b/crates/router/src/services/kafka/payout.rs@@ -10,7 +10,7 @@ pub struct KafkaPayout<'a> {pub merchant_id: &'a id_type::MerchantId,pub customer_id: Option<&'a id_type::CustomerId>,pub address_id: Option<&'a String>,- pub profile_id: &'a String,+ pub profile_id: &'a id_type::ProfileId,pub payout_method_id: Option<&'a String>,pub payout_type: Option<storage_enums::PayoutType>,pub amount: MinorUnit,diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rsindex 912cc1c1fa..c959c59bad 100644--- a/crates/router/src/types/api/admin.rs+++ b/crates/router/src/types/api/admin.rs@@ -250,7 +250,7 @@ pub async fn create_business_profile_from_merchant_account(use crate::core;// Generate a unique profile id- let profile_id = common_utils::generate_id_with_default_len("pro");+ let profile_id = common_utils::generate_profile_id_of_default_length();let merchant_id = merchant_account.get_id().to_owned();let current_time = common_utils::date_time::now();diff --git a/crates/router/src/types/domain/event.rs b/crates/router/src/types/domain/event.rsindex 872eb30390..badbb9df7b 100644--- a/crates/router/src/types/domain/event.rs+++ b/crates/router/src/types/domain/event.rs@@ -26,7 +26,7 @@ pub struct Event {pub primary_object_type: EventObjectType,pub created_at: time::PrimitiveDateTime,pub merchant_id: Option<common_utils::id_type::MerchantId>,- pub business_profile_id: Option<String>,+ pub business_profile_id: Option<common_utils::id_type::ProfileId>,pub primary_object_created_at: Option<time::PrimitiveDateTime>,pub idempotent_event_id: Option<String>,pub initial_attempt_id: Option<String>,diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rsindex ef07ab6a84..7e5f857134 100644--- a/crates/router/src/utils.rs+++ b/crates/router/src/utils.rs@@ -467,7 +467,10 @@ pub async fn get_mca_from_payment_intent(.await.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {- id: format!("profile_id {profile_id} and connector_name {connector_name}"),+ id: format!(+ "profile_id {} and connector_name {connector_name}",+ profile_id.get_string_repr()+ ),},)}@@ -556,7 +559,8 @@ pub async fn get_mca_from_payout_attempt(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {id: format!("profile_id {} and connector_name {}",- payout.profile_id, connector_name+ payout.profile_id.get_string_repr(),+ connector_name),},)@@ -603,7 +607,10 @@ pub async fn get_mca_from_object_reference_id(.await.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {- id: format!("profile_id {profile_id} and connector_name {connector_name}"),+ id: format!(+ "profile_id {} and connector_name {connector_name}",+ profile_id.get_string_repr()+ ),},)}diff --git a/crates/router/src/utils/user.rs b/crates/router/src/utils/user.rsindex 1de45b7436..30a0e1ca78 100644--- a/crates/router/src/utils/user.rs+++ b/crates/router/src/utils/user.rs@@ -114,7 +114,7 @@ pub async fn generate_jwt_auth_token_with_custom_role_attributes(merchant_id: id_type::MerchantId,org_id: id_type::OrganizationId,role_id: String,- profile_id: Option<String>,+ profile_id: Option<id_type::ProfileId>,) -> UserResult<Secret<String>> {let token = AuthToken::new_token(user.get_user_id().to_string(),diff --git a/crates/router/src/utils/user_role.rs b/crates/router/src/utils/user_role.rsindex 7aebbe1bbc..792a79c91e 100644--- a/crates/router/src/utils/user_role.rs+++ b/crates/router/src/utils/user_role.rs@@ -182,7 +182,7 @@ pub async fn update_v1_and_v2_user_roles_in_db(user_id: &str,org_id: &id_type::OrganizationId,merchant_id: &id_type::MerchantId,- profile_id: Option<&String>,+ profile_id: Option<&id_type::ProfileId>,update: UserRoleUpdate,) -> (Result<UserRole, Report<StorageError>>,diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rsindex c536ec7e4e..207af2ea4b 100644--- a/crates/router/src/workflows/payment_sync.rs+++ b/crates/router/src/workflows/payment_sync.rs@@ -177,7 +177,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {.await.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: profile_id.to_string(),+ id: profile_id.get_string_repr().to_owned(),},)?;diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rsindex aba6f2016b..08843a060a 100644--- a/crates/storage_impl/src/payouts/payout_attempt.rs+++ b/crates/storage_impl/src/payouts/payout_attempt.rs@@ -60,7 +60,6 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {payout_attempt_id: &payout_attempt_id,};let key_str = key.to_string();- let now = common_utils::date_time::now();let created_attempt = PayoutAttempt {payout_attempt_id: new_payout_attempt.payout_attempt_id.clone(),payout_id: new_payout_attempt.payout_id.clone(),@@ -76,8 +75,8 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {error_code: new_payout_attempt.error_code.clone(),business_country: new_payout_attempt.business_country,business_label: new_payout_attempt.business_label.clone(),- created_at: new_payout_attempt.created_at.unwrap_or(now),- last_modified_at: new_payout_attempt.last_modified_at.unwrap_or(now),+ created_at: new_payout_attempt.created_at,+ last_modified_at: new_payout_attempt.last_modified_at,profile_id: new_payout_attempt.profile_id.clone(),merchant_connector_id: new_payout_attempt.merchant_connector_id.clone(),routing_info: new_payout_attempt.routing_info.clone(),diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rsindex aee21771db..320aee2006 100644--- a/crates/storage_impl/src/payouts/payouts.rs+++ b/crates/storage_impl/src/payouts/payouts.rs@@ -91,7 +91,6 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {};let key_str = key.to_string();let field = format!("po_{}", new.payout_id);- let now = common_utils::date_time::now();let created_payout = Payouts {payout_id: new.payout_id.clone(),merchant_id: new.merchant_id.clone(),@@ -108,8 +107,8 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {return_url: new.return_url.clone(),entity_type: new.entity_type,metadata: new.metadata.clone(),- created_at: new.created_at.unwrap_or(now),- last_modified_at: new.last_modified_at.unwrap_or(now),+ created_at: new.created_at,+ last_modified_at: new.last_modified_at,profile_id: new.profile_id.clone(),status: new.status,attempt_count: new.attempt_count,@@ -936,10 +935,8 @@ impl DataModelExt for PayoutsNew {return_url: self.return_url,entity_type: self.entity_type,metadata: self.metadata,- created_at: self.created_at.unwrap_or_else(common_utils::date_time::now),- last_modified_at: self- .last_modified_at- .unwrap_or_else(common_utils::date_time::now),+ created_at: self.created_at,+ last_modified_at: self.last_modified_at,profile_id: self.profile_id,status: self.status,attempt_count: self.attempt_count,@@ -967,8 +964,8 @@ impl DataModelExt for PayoutsNew {return_url: storage_model.return_url,entity_type: storage_model.entity_type,metadata: storage_model.metadata,- created_at: Some(storage_model.created_at),- last_modified_at: Some(storage_model.last_modified_at),+ created_at: storage_model.created_at,+ last_modified_at: storage_model.last_modified_at,profile_id: storage_model.profile_id,status: storage_model.status,attempt_count: storage_model.attempt_count,diff --git a/scripts/ci-checks-v2.sh b/scripts/ci-checks-v2.shindex 151e5a382d..93bd2921a3 100755--- a/scripts/ci-checks-v2.sh+++ b/scripts/ci-checks-v2.sh@@ -1,8 +1,7 @@#!/usr/bin/env bashset -euo pipefail-crates_to_check=\-'api_models+crates_to_check='api_modelsdiesel_modelshyperswitch_domain_modelsstorage_impl'@@ -38,7 +37,7 @@ if [[ "${GITHUB_EVENT_NAME:-}" == 'pull_request' ]]; then# A package must be checked if it has been modifiedif grep --quiet --extended-regexp "^crates/${package_name}" <<< "${files_modified}"; thenif [[ "${package_name}" == "storage_impl" ]]; then- all_commands+=("cargo hack clippy --features 'v2,payment_v2,customer_v2,payment_methods_v2' -p storage_impl")+ all_commands+=("cargo hack clippy --features 'v2,payment_v2,customer_v2' -p storage_impl")elsevalid_features="$(features_to_run "$package_name")"all_commands+=("cargo hack clippy --feature-powerset --depth 2 --ignore-unknown-features --at-least-one-of 'v2 ' --include-features '${valid_features}' --package '${package_name}'")@@ -54,7 +53,7 @@ if [[ "${GITHUB_EVENT_NAME:-}" == 'pull_request' ]]; thenelse# If we are doing this locally or on merge queue, then check for all the V2 crates- all_commands+=("cargo hack clippy --features 'v2,payment_v2' -p storage_impl")+ all_commands+=("cargo hack clippy --features 'v2,payment_v2,customer_v2' -p storage_impl")common_command="cargo hack clippy --feature-powerset --depth 2 --ignore-unknown-features --at-least-one-of 'v2 '"while IFS= read -r crate; doif [[ "${crate}" != "storage_impl" ]]; then