Skip to content

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

feat(core): limit cell ID's length to 2 (#12688)

Kashifcb639e68f468
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 84ebd78a43..3041a8ca71 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -3829,7 +3829,7 @@
"examples": {
"Create a payment method session with customer_id": {
"value": {
- "customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz"
+ "customer_id": "0a_cus_abcdefghijklmnopqrstuvwxyz"
}
}
}
@@ -3888,7 +3888,7 @@
"examples": {
"Create a payment method session with customer_id": {
"value": {
- "customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz"
+ "customer_id": "0a_cus_abcdefghijklmnopqrstuvwxyz"
}
}
}
@@ -5003,7 +5003,7 @@
"examples": {
"Create a token with customer_id": {
"value": {
- "customer_id": "12345_cus_0196d94b9c207333a297cbcf31f2e8c8",
+ "customer_id": "0a_cus_0196d94b9c207333a297cbcf31f2e8c8",
"token_request": {
"payment_method_data": {
"card": {
@@ -5066,8 +5066,8 @@
"examples": {
"Delete a token entry with customer_id and session_id": {
"value": {
- "customer_id": "12345_cus_0196d94b9c207333a297cbcf31f2e8c8",
- "session_id": "12345_pms_01926c58bc6e77c09e809964e72af8c8"
+ "customer_id": "0a_cus_0196d94b9c207333a297cbcf31f2e8c8",
+ "session_id": "0a_pms_01926c58bc6e77c09e809964e72af8c8"
}
}
}
@@ -12661,7 +12661,7 @@
"id": {
"type": "string",
"description": "Unique identifier for the customer",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -12818,7 +12818,7 @@
"customer_id": {
"type": "string",
"description": "The unique identifier of the customer.",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -12995,7 +12995,7 @@
"id": {
"type": "string",
"description": "Unique identifier for the customer",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -13076,7 +13076,7 @@
"default_payment_method_id": {
"type": "string",
"description": "The identifier for the default payment method.",
- "example": "12345_pm_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_pm_01926c58bc6e77c09e809964e72af8c8",
"nullable": true,
"maxLength": 64
},
@@ -13161,7 +13161,7 @@
"default_payment_method_id": {
"type": "string",
"description": "The unique identifier of the payment method",
- "example": "12345_pm_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_pm_01926c58bc6e77c09e809964e72af8c8",
"nullable": true
},
"tax_registration_id": {
@@ -13363,12 +13363,12 @@
"customer_id": {
"type": "string",
"description": "Customer ID for which the tokenization is requested",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8"
},
"session_id": {
"type": "string",
"description": "Session ID associated with the tokenization request",
- "example": "12345_pms_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_pms_01926c58bc6e77c09e809964e72af8c8"
}
}
},
@@ -13381,7 +13381,7 @@
"id": {
"type": "string",
"description": "Unique identifier returned by the tokenization service",
- "example": "12345_tok_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_tok_01926c58bc6e77c09e809964e72af8c8"
}
}
},
@@ -15292,7 +15292,7 @@
"customer_id": {
"type": "string",
"description": "Customer ID for which the tokenization is requested",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8"
},
"token_request": {
"type": "object",
@@ -15311,7 +15311,7 @@
"id": {
"type": "string",
"description": "Unique identifier returned by the tokenization service",
- "example": "12345_tok_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_tok_01926c58bc6e77c09e809964e72af8c8"
},
"created_at": {
"type": "string",
@@ -18744,12 +18744,12 @@
"payment_method_id": {
"type": "string",
"description": "The payment method ID that was checked",
- "example": "12345_pm_019959146f92737389eb6927ce1eb7dc"
+ "example": "0a_pm_019959146f92737389eb6927ce1eb7dc"
},
"customer_id": {
"type": "string",
"description": "The customer ID associated with the payment method",
- "example": "12345_cus_0195dc62bb8e7312a44484536da76aef"
+ "example": "0a_cus_0195dc62bb8e7312a44484536da76aef"
}
}
},
@@ -20710,7 +20710,7 @@
"payment_method_id": {
"type": "string",
"description": "Identifier for Payment Method used for the payment attempt",
- "example": "12345_pm_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_pm_01926c58bc6e77c09e809964e72af8c8",
"nullable": true
},
"client_source": {
@@ -21582,7 +21582,7 @@
"customer_id": {
"type": "string",
"description": "The unique identifier of the customer.",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -22198,7 +22198,7 @@
"id": {
"type": "string",
"description": "The unique identifier of the Payment method",
- "example": "12345_pm_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_pm_01926c58bc6e77c09e809964e72af8c8"
}
}
},
@@ -22225,7 +22225,7 @@
"id": {
"type": "string",
"description": "The payment method ID associated with the token",
- "example": "12345_pm_019959146f92737389eb6927ce1eb7dc"
+ "example": "0a_pm_019959146f92737389eb6927ce1eb7dc"
},
"payment_method_token": {
"type": "string",
@@ -22284,7 +22284,7 @@
"customer_id": {
"type": "string",
"description": "The unique identifier of the customer.",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
}
@@ -22415,7 +22415,7 @@
"id": {
"type": "string",
"description": "The unique identifier of the Payment method",
- "example": "12345_pm_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_pm_01926c58bc6e77c09e809964e72af8c8"
},
"merchant_id": {
"type": "string",
@@ -22425,7 +22425,7 @@
"customer_id": {
"type": "string",
"description": "The unique identifier of the customer.",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -22572,12 +22572,12 @@
"id": {
"type": "string",
"description": "The unique identifier of the payment method.",
- "example": "12345_pm_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_pm_01926c58bc6e77c09e809964e72af8c8"
},
"customer_id": {
"type": "string",
"description": "The unique identifier of the customer.",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -22780,12 +22780,12 @@
"properties": {
"id": {
"type": "string",
- "example": "12345_pms_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_pms_01926c58bc6e77c09e809964e72af8c8"
},
"customer_id": {
"type": "string",
"description": "The customer id for which the payment methods session is to be created",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"nullable": true
},
"billing": {
@@ -22852,7 +22852,7 @@
"associated_token_id": {
"type": "string",
"description": "The token-id created if there is tokenization_data present",
- "example": "12345_tok_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_tok_01926c58bc6e77c09e809964e72af8c8",
"nullable": true
},
"storage_type": {
@@ -23572,7 +23572,7 @@
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -23976,7 +23976,7 @@
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -24110,7 +24110,7 @@
"id": {
"type": "string",
"description": "Unique identifier for the payment",
- "example": "12345_pay_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_pay_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -24127,7 +24127,7 @@
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"nullable": true,
"maxLength": 64,
"minLength": 32
@@ -24370,7 +24370,7 @@
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -24589,7 +24589,7 @@
"id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat have been done by a single merchant.",
- "example": "12345_pay_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_pay_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -24602,7 +24602,7 @@
"customer_id": {
"type": "string",
"description": "The identifier for the customer",
- "example": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ "example": "0a_cus_01926c58bc6e77c09e809964e72af8c8",
"maxLength": 64,
"minLength": 32
},
@@ -31655,7 +31655,7 @@
"payment_method_id": {
"type": "string",
"description": "The unique identifier of the payment method.",
- "example": "12345_pm_01926c58bc6e77c09e809964e72af8c8"
+ "example": "0a_pm_01926c58bc6e77c09e809964e72af8c8"
},
"token_type": {
"$ref": "#/components/schemas/TokenDataType"
diff --git a/config/config.example.toml b/config/config.example.toml
index d46b097424..b8a6d84661 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -1284,7 +1284,7 @@ connector_list = "tokenio"
[cell_information]
-id = "12345" # Default CellID for Global Cell Information
+id = "0a" # Default CellID for Global Cell Information
[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard" # Supported card networks for network tokenization
diff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.toml
index 6290ed8749..dee0751b5e 100644
--- a/config/deployments/env_specific.toml
+++ b/config/deployments/env_specific.toml
@@ -359,7 +359,7 @@ control_center_url = "http://localhost:9000"
encryption_key = "user_auth_table_encryption_key" # Encryption key used for encrypting data in user_authentication_methods table
[cell_information]
-id = "12345" # Default CellID for Global Cell Information
+id = "0a" # Default CellID for Global Cell Information
[network_tokenization_service] # Network Tokenization Service Configuration
generate_token_url= "" # base url to generate token
diff --git a/config/development.toml b/config/development.toml
index 8f0dcade50..486e63fb57 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -1430,7 +1430,7 @@ encryption_key = "A8EF32E029BC3342E54BF2E172A4D7AA43E8EF9D2C3A624A9F04E2EF79DC69
connector_list = "tokenio"
[cell_information]
-id = "12345"
+id = "0a"
[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard"
@@ -1580,4 +1580,4 @@ use_legacy_locker = false
[micro_services.authentication_service]
base_url = "http://localhost:8080"
-api_key = "api-key"
\ No newline at end of file
+api_key = "api-key"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 93d2e0ab32..57aef49bfa 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -1307,7 +1307,7 @@ apple_pay = { country = "AF,DZ,AW,AU,AZ,BS,BH,BD,BB,BZ,BM,BT,BO,BA,BW,BR,BN,BG,B
connector_list = "tokenio"
[cell_information]
-id = "12345"
+id = "0a"
[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard"
@@ -1446,4 +1446,4 @@ backup_file_path = "./config/superposition_seed.toml" # Path to a local file for
[micro_services.authentication_service]
base_url = "http://localhost:8080"
-api_key = "api-key"
\ No newline at end of file
+api_key = "api-key"
diff --git a/crates/api_models/src/customers.rs b/crates/api_models/src/customers.rs
index c2051b3eab..a301782ee6 100644
--- a/crates/api_models/src/customers.rs
+++ b/crates/api_models/src/customers.rs
@@ -255,7 +255,7 @@ pub struct CustomerResponse {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub id: id_type::GlobalCustomerId,
@@ -296,7 +296,7 @@ pub struct CustomerResponse {
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<pii::SecretSerdeValue>,
/// The identifier for the default payment method.
- #[schema(value_type = Option<String>, max_length = 64, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = Option<String>, max_length = 64, example = "0a_pm_01926c58bc6e77c09e809964e72af8c8")]
pub default_payment_method_id: Option<id_type::GlobalPaymentMethodId>,
/// The customer's tax registration number.
#[schema(max_length = 255, value_type = Option<String>, example = "123456789")]
@@ -342,7 +342,7 @@ pub struct CustomerDeleteResponse {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub id: id_type::GlobalCustomerId,
@@ -447,7 +447,7 @@ pub struct CustomerUpdateRequest {
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<pii::SecretSerdeValue>,
/// The unique identifier of the payment method
- #[schema(value_type = Option<String>, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = Option<String>, example = "0a_pm_01926c58bc6e77c09e809964e72af8c8")]
pub default_payment_method_id: Option<id_type::GlobalPaymentMethodId>,
/// The customer's tax registration number.
#[schema(max_length = 255, value_type = Option<String>, example = "123456789")]
diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs
index 3f516bfe67..36770920e5 100644
--- a/crates/api_models/src/payment_methods.rs
+++ b/crates/api_models/src/payment_methods.rs
@@ -141,7 +141,7 @@ pub struct PaymentMethodCreate {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -178,7 +178,7 @@ pub struct PaymentMethodIntentCreate {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: id_type::GlobalCustomerId,
@@ -1371,7 +1371,7 @@ pub struct ConnectorTokenDetails {
#[derive(Debug, serde::Serialize, serde::Deserialize, ToSchema, Clone)]
pub struct PaymentMethodResponse {
/// The unique identifier of the Payment method
- #[schema(value_type = String, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_pm_01926c58bc6e77c09e809964e72af8c8")]
pub id: id_type::GlobalPaymentMethodId,
/// Unique identifier for a merchant
@@ -1382,7 +1382,7 @@ pub struct PaymentMethodResponse {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -1447,7 +1447,7 @@ pub struct PaymentMethodResponse {
#[derive(Debug, serde::Serialize, serde::Deserialize, ToSchema, Clone)]
pub struct PaymentMethodDetailsResponse {
/// The unique identifier of the Payment method
- #[schema(value_type = String, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_pm_01926c58bc6e77c09e809964e72af8c8")]
pub id: id_type::GlobalPaymentMethodId,
/// Unique identifier for a merchant
@@ -1458,7 +1458,7 @@ pub struct PaymentMethodDetailsResponse {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -3225,7 +3225,7 @@ impl common_utils::events::ApiEventMetric for GetTokenDataRequest {}
#[derive(Debug, serde::Serialize, ToSchema)]
pub struct TokenDataResponse {
/// The unique identifier of the payment method.
- #[schema(value_type = String, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_pm_01926c58bc6e77c09e809964e72af8c8")]
pub payment_method_id: id_type::GlobalPaymentMethodId,
/// token type of the payment method
@@ -3320,7 +3320,7 @@ pub struct PaymentMethodDeleteResponse {
#[derive(Debug, serde::Serialize, ToSchema)]
pub struct PaymentMethodDeleteResponse {
/// The unique identifier of the Payment method
- #[schema(value_type = String, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_pm_01926c58bc6e77c09e809964e72af8c8")]
pub id: id_type::GlobalPaymentMethodId,
}
@@ -3373,14 +3373,14 @@ pub struct CustomerDefaultPaymentMethodResponse {
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
pub struct PaymentMethodResponseItem {
/// The unique identifier of the payment method.
- #[schema(value_type = String, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_pm_01926c58bc6e77c09e809964e72af8c8")]
pub id: id_type::GlobalPaymentMethodId,
/// The unique identifier of the customer.
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: id_type::GlobalCustomerId,
@@ -3445,7 +3445,7 @@ pub struct CustomerPaymentMethodResponseItem {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: id_type::GlobalCustomerId,
@@ -3708,7 +3708,7 @@ pub struct DefaultPaymentMethod {
#[cfg(feature = "v2")]
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
pub struct DefaultPaymentMethod {
- #[schema(value_type = String, max_length = 64, min_length = 1, example = "12345_cus_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, max_length = 64, min_length = 1, example = "0a_cus_01926c58bc6e77c09e809964e72af8c8")]
pub customer_id: String,
pub payment_method_id: String,
}
@@ -4508,11 +4508,11 @@ pub struct PaymentMethodSessionConfirmRequest {
#[cfg(feature = "v2")]
#[derive(Debug, serde::Serialize, ToSchema)]
pub struct PaymentMethodSessionResponse {
- #[schema(value_type = String, example = "12345_pms_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_pms_01926c58bc6e77c09e809964e72af8c8")]
pub id: id_type::GlobalPaymentMethodSessionId,
/// The customer id for which the payment methods session is to be created
- #[schema(value_type = Option<String>, example = "12345_cus_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = Option<String>, example = "0a_cus_01926c58bc6e77c09e809964e72af8c8")]
pub customer_id: Option<id_type::GlobalCustomerId>,
/// The billing address details of the customer. This will also be used for any new payment methods added during the session
@@ -4555,7 +4555,7 @@ pub struct PaymentMethodSessionResponse {
Option<Vec<common_types::payment_methods::AssociatedPaymentMethods>>,
/// The token-id created if there is tokenization_data present
- #[schema(value_type = Option<String>, example = "12345_tok_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = Option<String>, example = "0a_tok_01926c58bc6e77c09e809964e72af8c8")]
pub associated_token_id: Option<id_type::GlobalTokenId>,
/// The storage type for the payment method
@@ -4629,11 +4629,11 @@ pub struct NetworkTokenStatusCheckSuccessResponse {
pub card_expiry_year: Option<hyperswitch_masking::Secret<String>>,
/// The payment method ID that was checked
- #[schema(value_type = String, example = "12345_pm_019959146f92737389eb6927ce1eb7dc")]
+ #[schema(value_type = String, example = "0a_pm_019959146f92737389eb6927ce1eb7dc")]
pub payment_method_id: id_type::GlobalPaymentMethodId,
/// The customer ID associated with the payment method
- #[schema(value_type = String, example = "12345_cus_0195dc62bb8e7312a44484536da76aef")]
+ #[schema(value_type = String, example = "0a_cus_0195dc62bb8e7312a44484536da76aef")]
pub customer_id: id_type::GlobalCustomerId,
}
@@ -4681,7 +4681,7 @@ impl common_utils::events::ApiEventMetric for GetNetworkTokenEiligibilityRespons
#[derive(Debug, serde::Serialize, ToSchema)]
pub struct PaymentMethodGetTokenDetailsResponse {
/// The payment method ID associated with the token
- #[schema(value_type = String, example = "12345_pm_019959146f92737389eb6927ce1eb7dc")]
+ #[schema(value_type = String, example = "0a_pm_019959146f92737389eb6927ce1eb7dc")]
pub id: id_type::GlobalPaymentMethodId,
/// The token associated with the payment method
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index c4263977f2..1858aef374 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -269,7 +269,7 @@ pub struct PaymentsCreateIntentRequest {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -629,7 +629,7 @@ pub struct PaymentsIntentResponse {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -775,7 +775,7 @@ pub struct RevenueRecoveryGetIntentResponse {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -2176,7 +2176,7 @@ pub struct PaymentAttemptResponse {
pub connector_payment_id: Option<common_utils::types::ConnectorTransactionId>,
/// Identifier for Payment Method used for the payment attempt
- #[schema(value_type = Option<String>, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = Option<String>, example = "0a_pm_01926c58bc6e77c09e809964e72af8c8")]
pub payment_method_id: Option<id_type::GlobalPaymentMethodId>,
/// Value passed in X-CLIENT-SOURCE header during payments confirm request by the client
@@ -7699,7 +7699,7 @@ pub struct PaymentsListResponseItem {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_pay_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_pay_01926c58bc6e77c09e809964e72af8c8",
value_type = String,
)]
pub id: id_type::GlobalPaymentId,
@@ -7717,7 +7717,7 @@ pub struct PaymentsListResponseItem {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = Option<String>
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -7835,7 +7835,7 @@ pub struct RecoveryPaymentsListResponseItem {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_pay_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_pay_01926c58bc6e77c09e809964e72af8c8",
value_type = String,
)]
pub id: id_type::GlobalPaymentId,
@@ -7852,7 +7852,7 @@ pub struct RecoveryPaymentsListResponseItem {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = Option<String>
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -8083,7 +8083,7 @@ pub struct PaymentsRequest {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
@@ -8436,7 +8436,7 @@ pub struct PaymentsResponse {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_pay_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_pay_01926c58bc6e77c09e809964e72af8c8",
value_type = String,
)]
pub id: id_type::GlobalPaymentId,
@@ -8451,7 +8451,7 @@ pub struct PaymentsResponse {
#[schema(
min_length = 32,
max_length = 64,
- example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
+ example = "0a_cus_01926c58bc6e77c09e809964e72af8c8",
value_type = String
)]
pub customer_id: Option<id_type::GlobalCustomerId>,
diff --git a/crates/api_models/src/tokenization.rs b/crates/api_models/src/tokenization.rs
index 6b619a3432..33f90b4f8c 100644
--- a/crates/api_models/src/tokenization.rs
+++ b/crates/api_models/src/tokenization.rs
@@ -7,7 +7,7 @@ use utoipa::{schema, ToSchema};
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct GenericTokenizationResponse {
/// Unique identifier returned by the tokenization service
- #[schema(value_type = String, example = "12345_tok_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_tok_01926c58bc6e77c09e809964e72af8c8")]
pub id: id_type::GlobalTokenId,
/// Created time of the tokenization id
#[schema(value_type = PrimitiveDateTime,example = "2024-02-24T11:04:09.922Z")]
@@ -20,7 +20,7 @@ pub struct GenericTokenizationResponse {
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct GenericTokenizationRequest {
/// Customer ID for which the tokenization is requested
- #[schema(value_type = String, example = "12345_cus_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_cus_01926c58bc6e77c09e809964e72af8c8")]
pub customer_id: id_type::GlobalCustomerId,
/// Request for tokenization which contains the data to be tokenized
#[schema(value_type = Object,example = json!({ "city": "NY", "unit": "245" }))]
@@ -31,16 +31,16 @@ pub struct GenericTokenizationRequest {
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct DeleteTokenDataRequest {
/// Customer ID for which the tokenization is requested
- #[schema(value_type = String, example = "12345_cus_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_cus_01926c58bc6e77c09e809964e72af8c8")]
pub customer_id: id_type::GlobalCustomerId,
/// Session ID associated with the tokenization request
- #[schema(value_type = String, example = "12345_pms_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_pms_01926c58bc6e77c09e809964e72af8c8")]
pub session_id: id_type::GlobalPaymentMethodSessionId,
}
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct DeleteTokenDataResponse {
/// Unique identifier returned by the tokenization service
- #[schema(value_type = String, example = "12345_tok_01926c58bc6e77c09e809964e72af8c8")]
+ #[schema(value_type = String, example = "0a_tok_01926c58bc6e77c09e809964e72af8c8")]
pub id: id_type::GlobalTokenId,
}
diff --git a/crates/common_utils/src/consts.rs b/crates/common_utils/src/consts.rs
index 967c018e11..2bc6701132 100644
--- a/crates/common_utils/src/consts.rs
+++ b/crates/common_utils/src/consts.rs
@@ -92,7 +92,7 @@ pub const MAX_GLOBAL_ID_LENGTH: u8 = 64;
pub const MIN_REQUIRED_MERCHANT_REFERENCE_ID_LENGTH: u8 = 1;
/// Length of a cell identifier in a distributed system
-pub const CELL_IDENTIFIER_LENGTH: u8 = 5;
+pub const CELL_IDENTIFIER_LENGTH: u8 = 2;
/// General purpose base64 engine
pub const BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::general_purpose::STANDARD;
diff --git a/crates/common_utils/src/id_type/global_id.rs b/crates/common_utils/src/id_type/global_id.rs
index ff9f7d2286..c1450ce7e1 100644
--- a/crates/common_utils/src/id_type/global_id.rs
+++ b/crates/common_utils/src/id_type/global_id.rs
@@ -112,7 +112,7 @@ impl<'de> serde::Deserialize<'de> for CellId {
#[derive(Debug, Error, PartialEq, Eq)]
pub(crate) enum GlobalIdError {
/// The format for the global id is invalid
- #[error("The id format is invalid, expected format is {{cell_id:5}}_{{entity_prefix:3}}_{{uuid:32}}_{{random:24}}")]
+ #[error("The id format is invalid, expected format is {{cell_id:2}}_{{entity_prefix:3}}_{{uuid:32}}_{{random:24}}")]
InvalidIdFormat,
/// LengthIdError and AlphanumericIdError
@@ -180,7 +180,7 @@ where
}
/// Deserialize the global id from string
-/// The format should match {cell_id:5}_{entity_prefix:3}_{time_ordered_id:32}_{.*:24}
+/// The format should match {cell_id:2}_{entity_prefix:3}_{time_ordered_id:32}_{.*:24}
impl<'de> serde::Deserialize<'de> for GlobalId {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -197,28 +197,28 @@ mod global_id_tests {
#[test]
fn test_cell_id_from_str() {
- let cell_id_string = "12345";
+ let cell_id_string = "0a";
let cell_id = CellId::from_str(cell_id_string).unwrap();
assert_eq!(cell_id.get_string_repr(), cell_id_string);
}
#[test]
fn test_global_id_generate() {
- let cell_id_string = "12345";
+ let cell_id_string = "0a";
let entity = GlobalEntity::Customer;
let cell_id = CellId::from_str(cell_id_string).unwrap();
let global_id = GlobalId::generate(&cell_id, entity);
// Generate a regex for globalid
// Eg - 12abc_cus_abcdefghijklmnopqrstuvwxyz1234567890
- let regex = regex::Regex::new(r"[a-z0-9]{5}_cus_[a-z0-9]{32}").unwrap();
+ let regex = regex::Regex::new(r"[a-z0-9]{2}_cus_[a-z0-9]{32}").unwrap();
assert!(regex.is_match(&global_id.0 .0 .0));
}
#[test]
fn test_global_id_from_string() {
- let input_string = "12345_cus_abcdefghijklmnopqrstuvwxyz1234567890";
+ let input_string = "0a_cus_abcdefghijklmnopqrstuvwxyz1234567890";
let global_id = GlobalId::from_string(input_string.into()).unwrap();
assert_eq!(global_id.0 .0 .0, input_string);
}
@@ -226,9 +226,9 @@ mod global_id_tests {
#[test]
fn test_global_id_deser() {
let input_string_for_serde_json_conversion =
- r#""12345_cus_abcdefghijklmnopqrstuvwxyz1234567890""#;
+ r#""0a_cus_abcdefghijklmnopqrstuvwxyz1234567890""#;
- let input_string = "12345_cus_abcdefghijklmnopqrstuvwxyz1234567890";
+ let input_string = "0a_cus_abcdefghijklmnopqrstuvwxyz1234567890";
let global_id =
serde_json::from_str::<GlobalId>(input_string_for_serde_json_conversion).unwrap();
assert_eq!(global_id.0 .0 .0, input_string);
diff --git a/crates/common_utils/src/id_type/global_id/customer.rs b/crates/common_utils/src/id_type/global_id/customer.rs
index 63dbaa72e4..f182530e83 100644
--- a/crates/common_utils/src/id_type/global_id/customer.rs
+++ b/crates/common_utils/src/id_type/global_id/customer.rs
@@ -4,7 +4,7 @@ use crate::errors;
///
/// The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`.
///
-/// Example: `cell1_cus_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`
+/// Example: `0a_cus_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, diesel::expression::AsExpression)]
#[diesel(sql_type = diesel::sql_types::Text)]
pub struct GlobalCustomerId(super::GlobalId);
diff --git a/crates/common_utils/src/id_type/global_id/payment.rs b/crates/common_utils/src/id_type/global_id/payment.rs
index f86e3ed2f1..76af7e7ed6 100644
--- a/crates/common_utils/src/id_type/global_id/payment.rs
+++ b/crates/common_utils/src/id_type/global_id/payment.rs
@@ -9,7 +9,7 @@ crate::global_id_type!(
The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`.
-Example: `cell1_pay_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`"
+Example: `0a_pay_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`"
);
// Database related implementations so that this field can be used directly in the database tables
diff --git a/crates/common_utils/src/id_type/global_id/token.rs b/crates/common_utils/src/id_type/global_id/token.rs
index ad14458254..db949f223d 100644
--- a/crates/common_utils/src/id_type/global_id/token.rs
+++ b/crates/common_utils/src/id_type/global_id/token.rs
@@ -10,7 +10,7 @@ crate::global_id_type!(
The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`.
-Example: `cell1_tok_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`"
+Example: `0a_tok_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`"
);
// Database related implementations so that this field can be used directly in the database tables
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index 08c6980392..cefee9f1e1 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -821,7 +821,7 @@ impl AmountDetails {
#[derive(Clone, Debug, PartialEq, serde::Serialize, ToEncryption)]
pub struct PaymentIntent {
/// The global identifier for the payment intent. This is generated by the system.
- /// The format of the global id is `{cell_id:5}_pay_{time_ordered_uuid:32}`.
+ /// The format of the global id is `{cell_id:2}_pay_{time_ordered_uuid:32}`.
pub id: id_type::GlobalPaymentId,
/// The identifier for the merchant. This is automatically derived from the api key used to create the payment.
pub merchant_id: id_type::MerchantId,
diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs
index 250839a992..fa01fee0ef 100644
--- a/crates/openapi/src/routes/payment_method.rs
+++ b/crates/openapi/src/routes/payment_method.rs
@@ -625,7 +625,7 @@ pub async fn list_customer_payment_method_api_v1() {}
content = PaymentMethodSessionRequest,
examples (( "Create a payment method session with customer_id" = (
value =json!( {
- "customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz"
+ "customer_id": "0a_cus_abcdefghijklmnopqrstuvwxyz"
})
)))
),
@@ -659,7 +659,7 @@ pub fn payment_method_session_create() {}
content = PaymentMethodSessionRequest,
examples (( "Create a payment method session with customer_id" = (
value =json!( {
- "customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz"
+ "customer_id": "0a_cus_abcdefghijklmnopqrstuvwxyz"
})
)))
),
diff --git a/crates/openapi/src/routes/tokenization.rs b/crates/openapi/src/routes/tokenization.rs
index 0e60862a28..8e190960f7 100644
--- a/crates/openapi/src/routes/tokenization.rs
+++ b/crates/openapi/src/routes/tokenization.rs
@@ -12,7 +12,7 @@ use utoipa::OpenApi;
content = GenericTokenizationRequest,
examples(("Create a token with customer_id" = (
value = json!({
- "customer_id": "12345_cus_0196d94b9c207333a297cbcf31f2e8c8",
+ "customer_id": "0a_cus_0196d94b9c207333a297cbcf31f2e8c8",
"token_request": {
"payment_method_data": {
"card": {
@@ -46,8 +46,8 @@ pub async fn create_token_vault_api() {}
content = DeleteTokenDataRequest,
examples(("Delete a token entry with customer_id and session_id" = (
value = json!({
- "customer_id": "12345_cus_0196d94b9c207333a297cbcf31f2e8c8",
- "session_id": "12345_pms_01926c58bc6e77c09e809964e72af8c8",
+ "customer_id": "0a_cus_0196d94b9c207333a297cbcf31f2e8c8",
+ "session_id": "0a_pms_01926c58bc6e77c09e809964e72af8c8",
})
)))
),
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 8afa6cec40..a0476a3279 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -1390,7 +1390,7 @@ pub struct CellInformation {
impl Default for CellInformation {
fn default() -> Self {
Self {
- id: String::from("defid"),
+ id: String::from("00"),
}
}
}
@@ -1404,7 +1404,7 @@ impl Default for CellInformation {
// And a panic at application startup is considered acceptable.
#[allow(clippy::expect_used)]
let cell_id =
- id_type::CellId::from_string("defid").expect("Failed to create a default for Cell Id");
+ id_type::CellId::from_string("00").expect("Failed to create a default for Cell Id");
Self { id: cell_id }
}
}
diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rs
index 989067417d..b9b302e08d 100644
--- a/crates/router/src/core/customers.rs
+++ b/crates/router/src/core/customers.rs
@@ -52,11 +52,24 @@ pub fn generate_global_customer_id(cell_id: &str) -> String {
common_utils::generate_time_ordered_id(&prefix)
}
-pub fn is_customer_id_in_global_format(customer_id: &id_type::CustomerId, cell_id: &str) -> bool {
- customer_id
- .get_string_repr()
- .split_once('_')
- .is_some_and(|(prefix, _)| prefix == cell_id)
+pub fn is_global_customer_id_format(input: &str) -> bool {
+ let mut parts = input.split('_');
+ match (parts.next(), parts.next(), parts.next(), parts.next()) {
+ (Some(cell_id), Some(entity), Some(uuid), None) => {
+ !cell_id.is_empty()
+ && cell_id
+ .chars()
+ .all(|character| character.is_ascii_lowercase() || character.is_ascii_digit())
+ && entity == "cus"
+ && uuid.len() == 32
+ && uuid::Uuid::parse_str(uuid).is_ok()
+ }
+ _ => false,
+ }
+}
+
+pub fn is_customer_id_in_global_format(customer_id: &id_type::CustomerId) -> bool {
+ is_global_customer_id_format(customer_id.get_string_repr())
}
#[instrument(skip(state))]
@@ -1716,13 +1729,13 @@ mod tests {
#[test]
fn test_is_customer_id_in_global_format() {
- let cell_id = "12345";
-
let test_cases = [
- ("12345sbjabjbd", false),
- ("12345_cus_13igbfejs", true),
- ("12354_cus_12iufbeksjeb", false),
+ ("0asbjabjbd", false),
+ ("0a_cus_12345678123456781234567812345678", true),
+ ("abc12_cus_12345678123456781234567812345678", true),
+ ("1b_cus_12iufbeksjeb", false),
("efbc2_cus_217846821", false),
+ ("0a_pm_12345678123456781234567812345678", false),
];
for (customer_id_str, expected) in test_cases {
@@ -1730,7 +1743,7 @@ mod tests {
id_type::CustomerId::wrap(customer_id_str.to_string()).expect("valid customer id");
assert_eq!(
- is_customer_id_in_global_format(&customer_id, cell_id),
+ is_customer_id_in_global_format(&customer_id),
expected,
"failed for customer_id={customer_id_str}",
);
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index e010e10dd4..c8ca0de917 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -2118,10 +2118,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(
}
None => {
// Validate that the customer_id is not in GlobalCustomerId format
- if customers::is_customer_id_in_global_format(
- &customer_id,
- &state.conf.cell_information.id,
- ) {
+ if customers::is_customer_id_in_global_format(&customer_id) {
Err(report!(errors::StorageError::InvalidDataFormat(format!(
"customer_id '{}' format is not supported",
&customer_id.get_string_repr()
diff --git a/crates/router/src/routes/customers/migrate.rs b/crates/router/src/routes/customers/migrate.rs
index 3fe0268a86..0f97a44966 100644
--- a/crates/router/src/routes/customers/migrate.rs
+++ b/crates/router/src/routes/customers/migrate.rs
@@ -12,7 +12,7 @@ use error_stack::{report, ResultExt};
use router_env::{instrument, logger, tracing, Flow};
use crate::{
- core::{api_locking, errors},
+ core::{api_locking, customers, errors},
routes::{app::AppState, SessionState},
services::{api, authentication as auth, ApplicationResponse},
};
@@ -319,7 +319,7 @@ impl MigrationRow<Fetched> {
impl MigrationRow<V1Verified> {
fn classify_current_id(self) -> MigrationStepResult<MigrationRow<NeedsUpdate>> {
match self.old_id.as_deref() {
- Some(id) if is_global_customer_id_format(id) => Err(Box::new(self.result(
+ Some(id) if customers::is_global_customer_id_format(id) => Err(Box::new(self.result(
CustomerGlobalIdMigrationStatus::AlreadyGlobalId,
None,
"Customer id is already in global id format".to_string(),
@@ -429,22 +429,6 @@ impl<State> MigrationRow<State> {
}
}
-fn is_global_customer_id_format(id: &str) -> bool {
- let mut parts = id.split('_');
- match (parts.next(), parts.next(), parts.next(), parts.next()) {
- (Some(cell_id), Some(entity), Some(uuid), None) => {
- cell_id.len() == 5
- && cell_id
- .chars()
- .all(|character| character.is_ascii_lowercase() || character.is_ascii_digit())
- && entity == "cus"
- && uuid.len() == 32
- && uuid::Uuid::parse_str(uuid).is_ok()
- }
- _ => false,
- }
-}
-
fn log_row_result(result: &CustomerGlobalIdMigrationRowResult) {
logger::info!(
row_number = result.row_number,