feat(business_profile): add business_profile config to enable external vault (#7876)

This commit is contained in:
Sakil Mostak
2025-05-12 19:20:06 +05:30
committed by GitHub
parent cf34be1728
commit 8cb5bfc02a
11 changed files with 167 additions and 2 deletions

View File

@ -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
}
}
},

View File

@ -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)]

View File

@ -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 {

View File

@ -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>,
}

View File

@ -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,
})
}
}

View File

@ -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,

View File

@ -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),
},
)))
}

View File

@ -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),
})
}
}

View File

@ -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
{

View File

@ -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;

View File

@ -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;