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(business_profile): add business_profile config to enable external vault (#7876)

Sakil Mostak8cb5bfc02ac1
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index fa4bdbb8b2..bcc9719563 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -10206,6 +10206,16 @@
}
}
},
+ "ExternalVaultConnectorDetails": {
+ "type": "object",
+ "properties": {
+ "vault_connector_id": {
+ "type": "string",
+ "description": "Merchant Connector id to be stored for vault connector",
+ "nullable": true
+ }
+ }
+ },
"FeatureMatrixListResponse": {
"type": "object",
"required": [
@@ -19941,6 +19951,19 @@
}
],
"nullable": true
+ },
+ "is_external_vault_enabled": {
+ "type": "boolean",
+ "description": "Indicates if external vault is enabled or not.",
+ "nullable": true
+ },
+ "external_vault_connector_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ExternalVaultConnectorDetails"
+ }
+ ],
+ "nullable": true
}
},
"additionalProperties": false
@@ -20191,6 +20214,19 @@
}
],
"nullable": true
+ },
+ "is_external_vault_enabled": {
+ "type": "boolean",
+ "description": "Indicates if external vault is enabled or not.",
+ "nullable": true
+ },
+ "external_vault_connector_details": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ExternalVaultConnectorDetails"
+ }
+ ],
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index efa62de92d..26501e87fc 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -281,6 +281,13 @@ pub struct AuthenticationConnectorDetails {
pub three_ds_requestor_app_url: Option<String>,
}
+#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
+pub struct ExternalVaultConnectorDetails {
+ /// Merchant Connector id to be stored for vault connector
+ #[schema(value_type = Option<String>)]
+ pub vault_connector_id: id_type::MerchantConnectorAccountId,
+}
+
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
pub struct MerchantAccountMetadata {
pub compatible_connector: Option<api_enums::Connector>,
@@ -2124,6 +2131,12 @@ pub struct ProfileCreate {
//Merchant country for the profile
#[schema(value_type = Option<CountryAlpha2>, example = "US")]
pub merchant_business_country: Option<api_enums::CountryAlpha2>,
+
+ /// Indicates if external vault is enabled or not.
+ pub is_external_vault_enabled: Option<bool>,
+
+ /// External Vault Connector Details
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
}
#[cfg(feature = "v1")]
@@ -2423,6 +2436,12 @@ pub struct ProfileResponse {
//Merchant country for the profile
#[schema(value_type = Option<CountryAlpha2>, example = "US")]
pub merchant_business_country: Option<api_enums::CountryAlpha2>,
+
+ /// Indicates if external vault is enabled or not.
+ pub is_external_vault_enabled: Option<bool>,
+
+ /// External Vault Connector Details
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
}
#[cfg(feature = "v1")]
@@ -2697,6 +2716,12 @@ pub struct ProfileUpdate {
//Merchant country for the profile
#[schema(value_type = Option<CountryAlpha2>, example = "US")]
pub merchant_business_country: Option<api_enums::CountryAlpha2>,
+
+ /// Indicates if external vault is enabled or not.
+ pub is_external_vault_enabled: Option<bool>,
+
+ /// External Vault Connector Details
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rs
index 6a0854e180..06081fc060 100644
--- a/crates/diesel_models/src/business_profile.rs
+++ b/crates/diesel_models/src/business_profile.rs
@@ -364,6 +364,8 @@ pub struct Profile {
pub three_ds_decision_manager_config: Option<common_types::payments::DecisionManagerRecord>,
pub should_collect_cvv_during_payment:
Option<primitive_wrappers::ShouldCollectCvvDuringPayment>,
+ pub is_external_vault_enabled: Option<bool>,
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
pub revenue_recovery_retry_algorithm_type: Option<common_enums::RevenueRecoveryAlgorithmType>,
pub revenue_recovery_retry_algorithm_data: Option<RevenueRecoveryAlgorithmData>,
}
@@ -436,6 +438,8 @@ pub struct ProfileNew {
pub id: common_utils::id_type::ProfileId,
pub revenue_recovery_retry_algorithm_type: Option<common_enums::RevenueRecoveryAlgorithmType>,
pub revenue_recovery_retry_algorithm_data: Option<RevenueRecoveryAlgorithmData>,
+ pub is_external_vault_enabled: Option<bool>,
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
}
#[cfg(feature = "v2")]
@@ -490,6 +494,8 @@ pub struct ProfileUpdateInternal {
Option<primitive_wrappers::ShouldCollectCvvDuringPayment>,
pub revenue_recovery_retry_algorithm_type: Option<common_enums::RevenueRecoveryAlgorithmType>,
pub revenue_recovery_retry_algorithm_data: Option<RevenueRecoveryAlgorithmData>,
+ pub is_external_vault_enabled: Option<bool>,
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
}
#[cfg(feature = "v2")]
@@ -541,6 +547,8 @@ impl ProfileUpdateInternal {
merchant_business_country,
revenue_recovery_retry_algorithm_type,
revenue_recovery_retry_algorithm_data,
+ is_external_vault_enabled,
+ external_vault_connector_details,
} = self;
Profile {
id: source.id,
@@ -625,6 +633,10 @@ impl ProfileUpdateInternal {
.or(source.revenue_recovery_retry_algorithm_type),
revenue_recovery_retry_algorithm_data: revenue_recovery_retry_algorithm_data
.or(source.revenue_recovery_retry_algorithm_data),
+ is_external_vault_enabled: is_external_vault_enabled
+ .or(source.is_external_vault_enabled),
+ external_vault_connector_details: external_vault_connector_details
+ .or(source.external_vault_connector_details),
}
}
}
@@ -639,6 +651,14 @@ pub struct AuthenticationConnectorDetails {
common_utils::impl_to_sql_from_sql_json!(AuthenticationConnectorDetails);
+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression)]
+#[diesel(sql_type = diesel::sql_types::Jsonb)]
+pub struct ExternalVaultConnectorDetails {
+ pub vault_connector_id: common_utils::id_type::MerchantConnectorAccountId,
+}
+
+common_utils::impl_to_sql_from_sql_json!(ExternalVaultConnectorDetails);
+
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression)]
#[diesel(sql_type = diesel::sql_types::Jsonb)]
pub struct CardTestingGuardConfig {
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index d9df67f0fb..5349ccf728 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -232,6 +232,8 @@ diesel::table! {
default_fallback_routing -> Nullable<Jsonb>,
three_ds_decision_manager_config -> Nullable<Jsonb>,
should_collect_cvv_during_payment -> Nullable<Bool>,
+ is_external_vault_enabled -> Nullable<Bool>,
+ external_vault_connector_details -> Nullable<Jsonb>,
revenue_recovery_retry_algorithm_type -> Nullable<RevenueRecoveryAlgorithmType>,
revenue_recovery_retry_algorithm_data -> Nullable<Jsonb>,
}
diff --git a/crates/hyperswitch_domain_models/src/business_profile.rs b/crates/hyperswitch_domain_models/src/business_profile.rs
index 619357cba2..0ba7aa4e5b 100644
--- a/crates/hyperswitch_domain_models/src/business_profile.rs
+++ b/crates/hyperswitch_domain_models/src/business_profile.rs
@@ -8,12 +8,14 @@ use common_utils::{
pii, type_name,
types::keymanager,
};
-#[cfg(feature = "v2")]
-use diesel_models::business_profile::RevenueRecoveryAlgorithmData;
use diesel_models::business_profile::{
AuthenticationConnectorDetails, BusinessPaymentLinkConfig, BusinessPayoutLinkConfig,
CardTestingGuardConfig, ProfileUpdateInternal, WebhookDetails,
};
+#[cfg(feature = "v2")]
+use diesel_models::business_profile::{
+ ExternalVaultConnectorDetails, RevenueRecoveryAlgorithmData,
+};
use error_stack::ResultExt;
use masking::{PeekInterface, Secret};
@@ -905,6 +907,8 @@ pub struct Profile {
pub merchant_business_country: Option<api_enums::CountryAlpha2>,
pub revenue_recovery_retry_algorithm_type: Option<common_enums::RevenueRecoveryAlgorithmType>,
pub revenue_recovery_retry_algorithm_data: Option<RevenueRecoveryAlgorithmData>,
+ pub is_external_vault_enabled: Option<bool>,
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
}
#[cfg(feature = "v2")]
@@ -957,6 +961,8 @@ pub struct ProfileSetter {
pub merchant_business_country: Option<api_enums::CountryAlpha2>,
pub revenue_recovery_retry_algorithm_type: Option<common_enums::RevenueRecoveryAlgorithmType>,
pub revenue_recovery_retry_algorithm_data: Option<RevenueRecoveryAlgorithmData>,
+ pub is_external_vault_enabled: Option<bool>,
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
}
#[cfg(feature = "v2")]
@@ -1014,6 +1020,8 @@ impl From<ProfileSetter> for Profile {
merchant_business_country: value.merchant_business_country,
revenue_recovery_retry_algorithm_type: value.revenue_recovery_retry_algorithm_type,
revenue_recovery_retry_algorithm_data: value.revenue_recovery_retry_algorithm_data,
+ is_external_vault_enabled: value.is_external_vault_enabled,
+ external_vault_connector_details: value.external_vault_connector_details,
}
}
}
@@ -1072,6 +1080,8 @@ pub struct ProfileGeneralUpdate {
pub card_testing_secret_key: OptionalEncryptableName,
pub is_debit_routing_enabled: bool,
pub merchant_business_country: Option<api_enums::CountryAlpha2>,
+ pub is_external_vault_enabled: Option<bool>,
+ pub external_vault_connector_details: Option<ExternalVaultConnectorDetails>,
}
#[cfg(feature = "v2")]
@@ -1147,6 +1157,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
card_testing_secret_key,
is_debit_routing_enabled,
merchant_business_country,
+ is_external_vault_enabled,
+ external_vault_connector_details,
} = *update;
Self {
profile_name,
@@ -1195,6 +1207,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled,
+ external_vault_connector_details,
}
}
ProfileUpdate::RoutingAlgorithmUpdate {
@@ -1246,6 +1260,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
ProfileUpdate::ExtendedCardInfoUpdate {
is_extended_card_info_enabled,
@@ -1295,6 +1311,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
ProfileUpdate::ConnectorAgnosticMitUpdate {
is_connector_agnostic_mit_enabled,
@@ -1344,6 +1362,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
ProfileUpdate::DefaultRoutingFallbackUpdate {
default_fallback_routing,
@@ -1393,6 +1413,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
ProfileUpdate::NetworkTokenizationUpdate {
is_network_tokenization_enabled,
@@ -1442,6 +1464,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
ProfileUpdate::CollectCvvDuringPaymentUpdate {
should_collect_cvv_during_payment,
@@ -1491,6 +1515,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
ProfileUpdate::DecisionManagerRecordUpdate {
three_ds_decision_manager_config,
@@ -1540,6 +1566,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
ProfileUpdate::CardTestingSecretKeyUpdate {
card_testing_secret_key,
@@ -1589,6 +1617,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
ProfileUpdate::RevenueRecoveryAlgorithmUpdate {
revenue_recovery_retry_algorithm_type,
@@ -1639,6 +1669,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
merchant_business_country: None,
revenue_recovery_retry_algorithm_type: Some(revenue_recovery_retry_algorithm_type),
revenue_recovery_retry_algorithm_data,
+ is_external_vault_enabled: None,
+ external_vault_connector_details: None,
},
}
}
@@ -1710,6 +1742,8 @@ impl super::behaviour::Conversion for Profile {
merchant_business_country: self.merchant_business_country,
revenue_recovery_retry_algorithm_type: self.revenue_recovery_retry_algorithm_type,
revenue_recovery_retry_algorithm_data: self.revenue_recovery_retry_algorithm_data,
+ is_external_vault_enabled: self.is_external_vault_enabled,
+ external_vault_connector_details: self.external_vault_connector_details,
})
}
@@ -1801,6 +1835,8 @@ impl super::behaviour::Conversion for Profile {
merchant_business_country: item.merchant_business_country,
revenue_recovery_retry_algorithm_type: item.revenue_recovery_retry_algorithm_type,
revenue_recovery_retry_algorithm_data: item.revenue_recovery_retry_algorithm_data,
+ is_external_vault_enabled: item.is_external_vault_enabled,
+ external_vault_connector_details: item.external_vault_connector_details,
})
}
.await
@@ -1866,6 +1902,8 @@ impl super::behaviour::Conversion for Profile {
merchant_business_country: self.merchant_business_country,
revenue_recovery_retry_algorithm_type: self.revenue_recovery_retry_algorithm_type,
revenue_recovery_retry_algorithm_data: self.revenue_recovery_retry_algorithm_data,
+ is_external_vault_enabled: self.is_external_vault_enabled,
+ external_vault_connector_details: self.external_vault_connector_details,
})
}
}
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index aafd626c7b..ccc41bc78a 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -203,6 +203,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::admin::MerchantConnectorResponse,
api_models::admin::MerchantConnectorListResponse,
api_models::admin::AuthenticationConnectorDetails,
+ api_models::admin::ExternalVaultConnectorDetails,
api_models::admin::ExtendedCardInfoConfig,
api_models::admin::BusinessGenericLinkConfig,
api_models::admin::BusinessCollectLinkConfig,
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 097e2c7bcf..27c8a9fb8f 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -4052,6 +4052,10 @@ impl ProfileCreateBridge for api::ProfileCreate {
merchant_business_country: self.merchant_business_country,
revenue_recovery_retry_algorithm_type: None,
revenue_recovery_retry_algorithm_data: None,
+ is_external_vault_enabled: self.is_external_vault_enabled,
+ external_vault_connector_details: self
+ .external_vault_connector_details
+ .map(ForeignInto::foreign_into),
}))
}
}
@@ -4486,6 +4490,10 @@ impl ProfileUpdateBridge for api::ProfileUpdate {
card_testing_secret_key,
is_debit_routing_enabled: self.is_debit_routing_enabled.unwrap_or_default(),
merchant_business_country: self.merchant_business_country,
+ is_external_vault_enabled: self.is_external_vault_enabled,
+ external_vault_connector_details: self
+ .external_vault_connector_details
+ .map(ForeignInto::foreign_into),
},
)))
}
diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rs
index 4bd6dfbe5d..344cccc129 100644
--- a/crates/router/src/types/api/admin.rs
+++ b/crates/router/src/types/api/admin.rs
@@ -274,6 +274,10 @@ impl ForeignTryFrom<domain::Profile> for ProfileResponse {
is_clear_pan_retries_enabled: item.is_clear_pan_retries_enabled,
is_debit_routing_enabled: Some(item.is_debit_routing_enabled),
merchant_business_country: item.merchant_business_country,
+ is_external_vault_enabled: item.is_external_vault_enabled,
+ external_vault_connector_details: item
+ .external_vault_connector_details
+ .map(ForeignInto::foreign_into),
})
}
}
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index f6b7491274..e171aa5a59 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -2056,6 +2056,26 @@ impl ForeignFrom<diesel_models::business_profile::AuthenticationConnectorDetails
}
}
+impl ForeignFrom<api_models::admin::ExternalVaultConnectorDetails>
+ for diesel_models::business_profile::ExternalVaultConnectorDetails
+{
+ fn foreign_from(item: api_models::admin::ExternalVaultConnectorDetails) -> Self {
+ Self {
+ vault_connector_id: item.vault_connector_id,
+ }
+ }
+}
+
+impl ForeignFrom<diesel_models::business_profile::ExternalVaultConnectorDetails>
+ for api_models::admin::ExternalVaultConnectorDetails
+{
+ fn foreign_from(item: diesel_models::business_profile::ExternalVaultConnectorDetails) -> Self {
+ Self {
+ vault_connector_id: item.vault_connector_id,
+ }
+ }
+}
+
impl ForeignFrom<api_models::admin::CardTestingGuardConfig>
for diesel_models::business_profile::CardTestingGuardConfig
{
diff --git a/v2_compatible_migrations/2025-04-28-095013_add-is_external_vault_enabled-and-vault_connector_details-column-to-business_profile-table/down.sql b/v2_compatible_migrations/2025-04-28-095013_add-is_external_vault_enabled-and-vault_connector_details-column-to-business_profile-table/down.sql
new file mode 100644
index 0000000000..979f19bbcd
--- /dev/null
+++ b/v2_compatible_migrations/2025-04-28-095013_add-is_external_vault_enabled-and-vault_connector_details-column-to-business_profile-table/down.sql
@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+-- This file should undo anything in `up.sql`
+ALTER TABLE business_profile DROP COLUMN IF EXISTS is_external_vault_enabled;
+
+ALTER TABLE business_profile DROP COLUMN IF EXISTS external_vault_connector_details;
\ No newline at end of file
diff --git a/v2_compatible_migrations/2025-04-28-095013_add-is_external_vault_enabled-and-vault_connector_details-column-to-business_profile-table/up.sql b/v2_compatible_migrations/2025-04-28-095013_add-is_external_vault_enabled-and-vault_connector_details-column-to-business_profile-table/up.sql
new file mode 100644
index 0000000000..71fd55d705
--- /dev/null
+++ b/v2_compatible_migrations/2025-04-28-095013_add-is_external_vault_enabled-and-vault_connector_details-column-to-business_profile-table/up.sql
@@ -0,0 +1,6 @@
+-- Your SQL goes here
+ALTER TABLE business_profile
+ADD COLUMN IF NOT EXISTS is_external_vault_enabled BOOLEAN;
+
+ALTER TABLE business_profile
+ADD COLUMN IF NOT EXISTS external_vault_connector_details JSONB;
\ No newline at end of file