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
feat(business_profile): add token field selector column to business profile (#10190)
Sakil Mostakad92f7f986ae
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 33053fd3c3..563127dac5 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -18144,6 +18144,14 @@}],"nullable": true+ },+ "vault_token_selector": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/VaultTokenField"+ },+ "description": "Fields to tokenization in vault",+ "nullable": true}}},@@ -37073,6 +37081,33 @@"hyperswitch_sdk"]},+ "VaultTokenField": {+ "type": "object",+ "properties": {+ "token_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/VaultTokenType"+ }+ ],+ "nullable": true+ }+ }+ },+ "VaultTokenType": {+ "type": "string",+ "description": "Fields that can be tokenized with vault",+ "enum": [+ "card_number",+ "card_cvc",+ "card_expiry_year",+ "card_expiry_month",+ "network_token",+ "network_token_expiry_year",+ "network_token_expiry_month",+ "network_token_cryptogram"+ ]+ },"Venmo": {"type": "object","required": [diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 4872ca6a9c..771e80c6f6 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -11860,6 +11860,14 @@}],"nullable": true+ },+ "vault_token_selector": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/VaultTokenField"+ },+ "description": "Fields to tokenization in vault",+ "nullable": true}}},@@ -27324,6 +27332,33 @@}]},+ "VaultTokenField": {+ "type": "object",+ "properties": {+ "token_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/VaultTokenType"+ }+ ],+ "nullable": true+ }+ }+ },+ "VaultTokenType": {+ "type": "string",+ "description": "Fields that can be tokenized with vault",+ "enum": [+ "card_number",+ "card_cvc",+ "card_expiry_year",+ "card_expiry_month",+ "network_token",+ "network_token_expiry_year",+ "network_token_expiry_month",+ "network_token_cryptogram"+ ]+ },"Venmo": {"type": "object","required": [diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex 4886866b6e..2aa68bad3e 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -296,6 +296,16 @@ pub struct ExternalVaultConnectorDetails {/// External vault to be used for storing payment method information#[schema(value_type = Option<VaultSdk>)]pub vault_sdk: Option<common_enums::VaultSdk>,++ /// Fields to tokenization in vault+ pub vault_token_selector: Option<Vec<VaultTokenField>>,+}++#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]+pub struct VaultTokenField {+ /// Type of field to be tokenized in+ #[schema(value_type = Option<VaultTokenType>)]+ pub token_type: common_enums::VaultTokenType,}#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 2eef9c15ac..b6330145a0 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -9992,3 +9992,39 @@ pub enum ExemptionIndicator {/// Recurring transaction exemption (subsequent payment in a series).RecurringOperation,}++/// Fields that can be tokenized with vault+#[derive(+ Clone,+ Debug,+ Eq,+ Hash,+ PartialEq,+ serde::Deserialize,+ serde::Serialize,+ strum::Display,+ strum::VariantNames,+ strum::EnumIter,+ strum::EnumString,+ ToSchema,+)]+#[router_derive::diesel_enum(storage_type = "db_enum")]+#[serde(rename_all = "snake_case")]+pub enum VaultTokenType {+ /// Card number+ CardNumber,+ /// Card cvc+ CardCvc,+ /// Card expiry year+ CardExpiryYear,+ /// Card expiry month+ CardExpiryMonth,+ /// Network token+ NetworkToken,+ /// Token expiry year+ NetworkTokenExpiryYear,+ /// Token expiry month+ NetworkTokenExpiryMonth,+ /// Token cryptogram+ NetworkTokenCryptogram,+}diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rsindex da4c6c6bcb..630d632712 100644--- a/crates/diesel_models/src/business_profile.rs+++ b/crates/diesel_models/src/business_profile.rs@@ -768,6 +768,13 @@ common_utils::impl_to_sql_from_sql_json!(AuthenticationConnectorDetails);pub struct ExternalVaultConnectorDetails {pub vault_connector_id: common_utils::id_type::MerchantConnectorAccountId,pub vault_sdk: Option<VaultSdk>,+ pub vault_token_selector: Option<Vec<VaultTokenField>>,+}++#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression)]+#[diesel(sql_type = diesel::sql_types::Jsonb)]+pub struct VaultTokenField {+ pub token_type: common_enums::VaultTokenType,}common_utils::impl_to_sql_from_sql_json!(ExternalVaultConnectorDetails);diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex e56e9f079b..db907cd2c8 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -422,7 +422,9 @@ Never share your secret api keys. Keep them guarded and secure.api_models::enums::ExternalVaultEnabled,api_models::enums::GooglePayCardFundingSource,api_models::enums::VaultSdk,+ api_models::enums::VaultTokenType,api_models::admin::ExternalVaultConnectorDetails,+ api_models::admin::VaultTokenField,api_models::admin::MerchantConnectorCreate,api_models::admin::AdditionalMerchantData,api_models::admin::ConnectorWalletDetails,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex 9aa6e607a1..74adf7cbb5 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -240,6 +240,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::admin::MerchantConnectorListResponse,api_models::admin::AuthenticationConnectorDetails,api_models::admin::ExternalVaultConnectorDetails,+ api_models::admin::VaultTokenField,api_models::admin::ExtendedCardInfoConfig,api_models::admin::BusinessGenericLinkConfig,api_models::admin::BusinessCollectLinkConfig,@@ -350,6 +351,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::enums::PaymentLinkShowSdkTerms,api_models::enums::OrganizationType,api_models::enums::GooglePayCardFundingSource,+ api_models::enums::VaultTokenType,api_models::admin::MerchantConnectorCreate,api_models::admin::AdditionalMerchantData,api_models::admin::CardTestingGuardConfig,diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex 83cc245ea5..d7d4cbc662 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -1964,6 +1964,12 @@ impl ForeignFrom<api_models::admin::ExternalVaultConnectorDetails>Self {vault_connector_id: item.vault_connector_id,vault_sdk: item.vault_sdk,+ vault_token_selector: item.vault_token_selector.map(|vault_token_selector| {+ vault_token_selector+ .into_iter()+ .map(ForeignFrom::foreign_from)+ .collect()+ }),}}}@@ -1975,6 +1981,32 @@ impl ForeignFrom<diesel_models::business_profile::ExternalVaultConnectorDetails>Self {vault_connector_id: item.vault_connector_id,vault_sdk: item.vault_sdk,+ vault_token_selector: item.vault_token_selector.map(|vault_token_selector| {+ vault_token_selector+ .into_iter()+ .map(ForeignFrom::foreign_from)+ .collect()+ }),+ }+ }+}++impl ForeignFrom<api_models::admin::VaultTokenField>+ for diesel_models::business_profile::VaultTokenField+{+ fn foreign_from(item: api_models::admin::VaultTokenField) -> Self {+ Self {+ token_type: item.token_type,+ }+ }+}++impl ForeignFrom<diesel_models::business_profile::VaultTokenField>+ for api_models::admin::VaultTokenField+{+ fn foreign_from(item: diesel_models::business_profile::VaultTokenField) -> Self {+ Self {+ token_type: item.token_type,}}}