feat(business_profile): add tax_connector_id column in business_profile table (#5576)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: swangi-kumari <swangi.12015941@lpu.in>
Co-authored-by: Swangi Kumari <85639103+swangi-kumari@users.noreply.github.com>
This commit is contained in:
Sagnik Mitra
2024-08-26 13:30:37 +05:30
committed by GitHub
parent 0eaadc42b7
commit 963a2547e8
11 changed files with 168 additions and 2 deletions

View File

@ -3105,6 +3105,15 @@
"type": "object",
"description": "These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.",
"nullable": true
},
"tax_connector_id": {
"type": "string",
"description": "Merchant Connector id to be stored for tax_calculator connector",
"nullable": true
},
"is_tax_connector_enabled": {
"type": "boolean",
"description": "Indicates if tax_calculator connector is enabled or not.\nIf set to `true` tax_connector_id will be checked."
}
},
"additionalProperties": false
@ -3116,7 +3125,8 @@
"id",
"profile_name",
"enable_payment_response_hash",
"redirect_to_merchant_with_http_post"
"redirect_to_merchant_with_http_post",
"is_tax_connector_enabled"
],
"properties": {
"merchant_id": {
@ -3277,6 +3287,15 @@
}
],
"nullable": true
},
"tax_connector_id": {
"type": "string",
"description": "Merchant Connector id to be stored for tax_calculator connector",
"nullable": true
},
"is_tax_connector_enabled": {
"type": "boolean",
"description": "Indicates if tax_calculator connector is enabled or not.\nIf set to `true` tax_connector_id will be checked."
}
}
},

View File

@ -7334,6 +7334,15 @@
"type": "object",
"description": "These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.",
"nullable": true
},
"tax_connector_id": {
"type": "string",
"description": "Merchant Connector id to be stored for tax_calculator connector",
"nullable": true
},
"is_tax_connector_enabled": {
"type": "boolean",
"description": "Indicates if tax_calculator connector is enabled or not.\nIf set to `true` tax_connector_id will be checked."
}
},
"additionalProperties": false
@ -7345,7 +7354,8 @@
"profile_id",
"profile_name",
"enable_payment_response_hash",
"redirect_to_merchant_with_http_post"
"redirect_to_merchant_with_http_post",
"is_tax_connector_enabled"
],
"properties": {
"merchant_id": {
@ -7515,6 +7525,15 @@
"type": "object",
"description": "These key-value pairs are sent as additional custom headers in the outgoing webhook request.",
"nullable": true
},
"tax_connector_id": {
"type": "string",
"description": "Merchant Connector id to be stored for tax_calculator connector",
"nullable": true
},
"is_tax_connector_enabled": {
"type": "boolean",
"description": "Indicates if tax_calculator connector is enabled or not.\nIf set to `true` tax_connector_id will be checked."
}
}
},

View File

@ -1953,6 +1953,14 @@ pub struct BusinessProfileCreate {
/// These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
/// Merchant Connector id to be stored for tax_calculator connector
pub tax_connector_id: Option<String>,
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
#[serde(default)]
pub is_tax_connector_enabled: bool,
}
#[nutype::nutype(
@ -2048,6 +2056,14 @@ pub struct BusinessProfileCreate {
/// These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
/// Merchant Connector id to be stored for tax_calculator connector
pub tax_connector_id: Option<String>,
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
#[serde(default)]
pub is_tax_connector_enabled: bool,
}
#[cfg(all(
@ -2160,6 +2176,13 @@ pub struct BusinessProfileResponse {
/// These key-value pairs are sent as additional custom headers in the outgoing webhook request.
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, Secret<String>>>,
/// Merchant Connector id to be stored for tax_calculator connector
pub tax_connector_id: Option<String>,
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
pub is_tax_connector_enabled: bool,
}
#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
@ -2260,6 +2283,13 @@ pub struct BusinessProfileResponse {
/// Whether the order fulfillment time is calculated from the origin or the time of creating the payment, or confirming the payment
#[schema(value_type = Option<OrderFulfillmentTimeOrigin>, example = "create")]
pub order_fulfillment_time_origin: Option<api_enums::OrderFulfillmentTimeOrigin>,
/// Merchant Connector id to be stored for tax_calculator connector
pub tax_connector_id: Option<String>,
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
pub is_tax_connector_enabled: bool,
}
#[cfg(all(
@ -2364,6 +2394,13 @@ pub struct BusinessProfileUpdate {
/// These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
/// Merchant Connector id to be stored for tax_calculator connector
pub tax_connector_id: Option<String>,
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
pub is_tax_connector_enabled: Option<bool>,
}
#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
@ -2456,6 +2493,13 @@ pub struct BusinessProfileUpdate {
/// These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs.
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
/// Merchant Connector id to be stored for tax_calculator connector
pub tax_connector_id: Option<String>,
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
pub is_tax_connector_enabled: Option<bool>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]

View File

@ -56,6 +56,8 @@ pub struct BusinessProfile {
pub outgoing_webhook_custom_http_headers: Option<Encryption>,
pub always_collect_billing_details_from_wallet_connector: Option<bool>,
pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: Option<bool>,
}
#[cfg(all(
@ -96,6 +98,8 @@ pub struct BusinessProfileNew {
pub outgoing_webhook_custom_http_headers: Option<Encryption>,
pub always_collect_billing_details_from_wallet_connector: Option<bool>,
pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: Option<bool>,
}
#[cfg(all(
@ -133,6 +137,8 @@ pub struct BusinessProfileUpdateInternal {
pub outgoing_webhook_custom_http_headers: Option<Encryption>,
pub always_collect_billing_details_from_wallet_connector: Option<bool>,
pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: Option<bool>,
}
#[cfg(all(
@ -169,6 +175,8 @@ impl BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers,
always_collect_billing_details_from_wallet_connector,
always_collect_shipping_details_from_wallet_connector,
tax_connector_id,
is_tax_connector_enabled,
} = self;
BusinessProfile {
profile_id: source.profile_id,
@ -219,6 +227,8 @@ impl BusinessProfileUpdateInternal {
always_collect_shipping_details_from_wallet_connector:
always_collect_shipping_details_from_wallet_connector
.or(source.always_collect_shipping_details_from_wallet_connector),
tax_connector_id: tax_connector_id.or(source.tax_connector_id),
is_tax_connector_enabled: is_tax_connector_enabled.or(source.is_tax_connector_enabled),
}
}
}
@ -265,6 +275,8 @@ pub struct BusinessProfile {
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: Option<bool>,
}
#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
@ -304,6 +316,8 @@ pub struct BusinessProfileNew {
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: Option<bool>,
}
#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
@ -340,6 +354,8 @@ pub struct BusinessProfileUpdateInternal {
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: Option<bool>,
}
#[cfg(all(feature = "v2", feature = "business_profile_v2"))]
@ -375,6 +391,8 @@ impl BusinessProfileUpdateInternal {
frm_routing_algorithm_id,
payout_routing_algorithm_id,
default_fallback_routing,
tax_connector_id,
is_tax_connector_enabled,
} = self;
BusinessProfile {
profile_id: source.profile_id,
@ -429,6 +447,8 @@ impl BusinessProfileUpdateInternal {
payout_routing_algorithm_id: payout_routing_algorithm_id
.or(source.payout_routing_algorithm_id),
default_fallback_routing: default_fallback_routing.or(source.default_fallback_routing),
tax_connector_id: tax_connector_id.or(source.tax_connector_id),
is_tax_connector_enabled: is_tax_connector_enabled.or(source.is_tax_connector_enabled),
}
}
}
@ -476,6 +496,8 @@ impl From<BusinessProfileNew> for BusinessProfile {
frm_routing_algorithm_id: new.frm_routing_algorithm_id,
payout_routing_algorithm_id: new.payout_routing_algorithm_id,
default_fallback_routing: new.default_fallback_routing,
tax_connector_id: new.tax_connector_id,
is_tax_connector_enabled: new.is_tax_connector_enabled,
}
}
}

View File

@ -205,6 +205,9 @@ diesel::table! {
outgoing_webhook_custom_http_headers -> Nullable<Bytea>,
always_collect_billing_details_from_wallet_connector -> Nullable<Bool>,
always_collect_shipping_details_from_wallet_connector -> Nullable<Bool>,
#[max_length = 64]
tax_connector_id -> Nullable<Varchar>,
is_tax_connector_enabled -> Nullable<Bool>,
}
}

View File

@ -212,6 +212,9 @@ diesel::table! {
#[max_length = 64]
payout_routing_algorithm_id -> Nullable<Varchar>,
default_fallback_routing -> Nullable<Jsonb>,
#[max_length = 64]
tax_connector_id -> Nullable<Varchar>,
is_tax_connector_enabled -> Nullable<Bool>,
}
}

View File

@ -53,6 +53,8 @@ pub struct BusinessProfile {
pub outgoing_webhook_custom_http_headers: OptionalEncryptableValue,
pub always_collect_billing_details_from_wallet_connector: Option<bool>,
pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: bool,
}
#[cfg(all(
@ -85,6 +87,8 @@ pub struct BusinessProfileGeneralUpdate {
pub outgoing_webhook_custom_http_headers: OptionalEncryptableValue,
pub always_collect_billing_details_from_wallet_connector: Option<bool>,
pub always_collect_shipping_details_from_wallet_connector: Option<bool>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: Option<bool>,
}
#[cfg(all(
@ -141,6 +145,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers,
always_collect_billing_details_from_wallet_connector,
always_collect_shipping_details_from_wallet_connector,
tax_connector_id,
is_tax_connector_enabled,
} = *update;
Self {
@ -172,6 +178,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
.map(Encryption::from),
always_collect_billing_details_from_wallet_connector,
always_collect_shipping_details_from_wallet_connector,
tax_connector_id,
is_tax_connector_enabled,
}
}
BusinessProfileUpdate::RoutingAlgorithmUpdate {
@ -205,6 +213,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers: None,
always_collect_billing_details_from_wallet_connector: None,
always_collect_shipping_details_from_wallet_connector: None,
tax_connector_id: None,
is_tax_connector_enabled: None,
},
BusinessProfileUpdate::ExtendedCardInfoUpdate {
is_extended_card_info_enabled,
@ -236,6 +246,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers: None,
always_collect_billing_details_from_wallet_connector: None,
always_collect_shipping_details_from_wallet_connector: None,
tax_connector_id: None,
is_tax_connector_enabled: None,
},
BusinessProfileUpdate::ConnectorAgnosticMitUpdate {
is_connector_agnostic_mit_enabled,
@ -267,6 +279,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
outgoing_webhook_custom_http_headers: None,
always_collect_billing_details_from_wallet_connector: None,
always_collect_shipping_details_from_wallet_connector: None,
tax_connector_id: None,
is_tax_connector_enabled: None,
},
}
}
@ -319,6 +333,8 @@ impl super::behaviour::Conversion for BusinessProfile {
.always_collect_billing_details_from_wallet_connector,
always_collect_shipping_details_from_wallet_connector: self
.always_collect_shipping_details_from_wallet_connector,
tax_connector_id: self.tax_connector_id,
is_tax_connector_enabled: Some(self.is_tax_connector_enabled),
})
}
@ -380,6 +396,8 @@ impl super::behaviour::Conversion for BusinessProfile {
.and_then(|val| val.try_into_optionaloperation())
})
.await?,
tax_connector_id: item.tax_connector_id,
is_tax_connector_enabled: item.is_tax_connector_enabled.unwrap_or(false),
})
}
.await
@ -426,6 +444,8 @@ impl super::behaviour::Conversion for BusinessProfile {
.always_collect_billing_details_from_wallet_connector,
always_collect_shipping_details_from_wallet_connector: self
.always_collect_shipping_details_from_wallet_connector,
tax_connector_id: self.tax_connector_id,
is_tax_connector_enabled: Some(self.is_tax_connector_enabled),
})
}
}
@ -465,6 +485,8 @@ pub struct BusinessProfile {
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<String>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
pub tax_connector_id: Option<String>,
pub is_tax_connector_enabled: bool,
}
impl BusinessProfile {
@ -590,6 +612,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
frm_routing_algorithm_id: None,
payout_routing_algorithm_id: None,
default_fallback_routing: None,
tax_connector_id: None,
is_tax_connector_enabled: None,
}
}
BusinessProfileUpdate::RoutingAlgorithmUpdate {
@ -625,6 +649,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
frm_routing_algorithm_id: None,
payout_routing_algorithm_id,
default_fallback_routing: None,
tax_connector_id: None,
is_tax_connector_enabled: None,
},
BusinessProfileUpdate::ExtendedCardInfoUpdate {
is_extended_card_info_enabled,
@ -658,6 +684,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
order_fulfillment_time_origin: None,
frm_routing_algorithm_id: None,
default_fallback_routing: None,
tax_connector_id: None,
is_tax_connector_enabled: None,
},
BusinessProfileUpdate::ConnectorAgnosticMitUpdate {
is_connector_agnostic_mit_enabled,
@ -691,6 +719,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
order_fulfillment_time_origin: None,
frm_routing_algorithm_id: None,
default_fallback_routing: None,
tax_connector_id: None,
is_tax_connector_enabled: None,
},
BusinessProfileUpdate::DefaultRoutingFallbackUpdate {
default_fallback_routing,
@ -724,6 +754,8 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
order_fulfillment_time_origin: None,
frm_routing_algorithm_id: None,
default_fallback_routing,
tax_connector_id: None,
is_tax_connector_enabled: None,
},
}
}
@ -775,6 +807,8 @@ impl super::behaviour::Conversion for BusinessProfile {
order_fulfillment_time_origin: self.order_fulfillment_time_origin,
frm_routing_algorithm_id: self.frm_routing_algorithm_id,
default_fallback_routing: self.default_fallback_routing,
tax_connector_id: self.tax_connector_id,
is_tax_connector_enabled: Some(self.is_tax_connector_enabled),
})
}
@ -838,6 +872,8 @@ impl super::behaviour::Conversion for BusinessProfile {
frm_routing_algorithm_id: item.frm_routing_algorithm_id,
payout_routing_algorithm_id: item.payout_routing_algorithm_id,
default_fallback_routing: item.default_fallback_routing,
tax_connector_id: item.tax_connector_id,
is_tax_connector_enabled: item.is_tax_connector_enabled.unwrap_or(false),
})
}
.await
@ -886,6 +922,8 @@ impl super::behaviour::Conversion for BusinessProfile {
frm_routing_algorithm_id: self.frm_routing_algorithm_id,
payout_routing_algorithm_id: self.payout_routing_algorithm_id,
default_fallback_routing: self.default_fallback_routing,
tax_connector_id: self.tax_connector_id,
is_tax_connector_enabled: Some(self.is_tax_connector_enabled),
})
}
}

View File

@ -3501,6 +3501,8 @@ impl BusinessProfileCreateBridge for api::BusinessProfileCreate {
.or(Some(false)),
outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers
.map(Into::into),
tax_connector_id: self.tax_connector_id,
is_tax_connector_enabled: self.is_tax_connector_enabled,
always_collect_billing_details_from_wallet_connector: self
.always_collect_billing_details_from_wallet_connector,
always_collect_shipping_details_from_wallet_connector: self
@ -3605,6 +3607,8 @@ impl BusinessProfileCreateBridge for api::BusinessProfileCreate {
.or(Some(common_utils::consts::DEFAULT_ORDER_FULFILLMENT_TIME)),
order_fulfillment_time_origin: self.order_fulfillment_time_origin,
default_fallback_routing: None,
tax_connector_id: self.tax_connector_id,
is_tax_connector_enabled: self.is_tax_connector_enabled,
})
}
}
@ -3871,6 +3875,8 @@ impl BusinessProfileUpdateBridge for api::BusinessProfileUpdate {
.always_collect_billing_details_from_wallet_connector,
always_collect_shipping_details_from_wallet_connector: self
.always_collect_shipping_details_from_wallet_connector,
tax_connector_id: self.tax_connector_id,
is_tax_connector_enabled: self.is_tax_connector_enabled,
},
)))
}

View File

@ -166,6 +166,8 @@ impl ForeignTryFrom<domain::BusinessProfile> for BusinessProfileResponse {
.always_collect_shipping_details_from_wallet_connector,
is_connector_agnostic_mit_enabled: item.is_connector_agnostic_mit_enabled,
outgoing_webhook_custom_http_headers,
tax_connector_id: item.tax_connector_id,
is_tax_connector_enabled: item.is_tax_connector_enabled,
})
}
}
@ -227,6 +229,8 @@ impl ForeignTryFrom<domain::BusinessProfile> for BusinessProfileResponse {
outgoing_webhook_custom_http_headers,
order_fulfillment_time,
order_fulfillment_time_origin: item.order_fulfillment_time_origin,
tax_connector_id: item.tax_connector_id,
is_tax_connector_enabled: item.is_tax_connector_enabled,
})
}
}
@ -345,5 +349,7 @@ pub async fn create_business_profile_from_merchant_account(
.always_collect_shipping_details_from_wallet_connector
.or(Some(false)),
outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers.map(Into::into),
tax_connector_id: request.tax_connector_id,
is_tax_connector_enabled: request.is_tax_connector_enabled,
})
}

View File

@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE business_profile DROP COLUMN IF EXISTS tax_connector_id;
ALTER TABLE business_profile DROP COLUMN IF EXISTS is_tax_connector_enabled;

View File

@ -0,0 +1,3 @@
-- Your SQL goes here
ALTER TABLE business_profile ADD COLUMN IF NOT EXISTS tax_connector_id VARCHAR(64);
ALTER TABLE business_profile ADD COLUMN IF NOT EXISTS is_tax_connector_enabled BOOLEAN;