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(router): [tsys_tansit] add merchant details to MCA metadata and discount-related fields to the hyperswitch payment request (#13400)
Akshaya Shankar0fb9c7998687
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex c2d691065a..dbea25b657 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -27723,11 +27723,29 @@"description": "Total amount for the item.","nullable": true},+ "discount_name": {+ "type": "string",+ "description": "Discount name applied to this item.",+ "nullable": true+ },"unit_discount_amount": {"type": "integer","format": "int64","description": "Discount amount applied to this item.","nullable": true+ },+ "discount_percentage": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Percentage"+ }+ ],+ "nullable": true+ },+ "discount_type": {+ "type": "string",+ "description": "Discount type applied to this item.",+ "nullable": true}}},@@ -37881,6 +37899,20 @@}}},+ "Percentage": {+ "type": "object",+ "description": "Represents Percentage Value between 0 and 100 both inclusive",+ "required": [+ "percentage"+ ],+ "properties": {+ "percentage": {+ "type": "number",+ "format": "double",+ "description": "Percentage value ranging between 0 and 100"+ }+ }+ },"PeriodUnit": {"type": "string","enum": [@@ -43846,7 +43878,7 @@"properties": {"percentage": {"type": "number",- "format": "float"+ "format": "double"}}},diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 5cf07ad208..6c29cec9cf 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -20113,11 +20113,29 @@"description": "Total amount for the item.","nullable": true},+ "discount_name": {+ "type": "string",+ "description": "Discount name applied to this item.",+ "nullable": true+ },"unit_discount_amount": {"type": "integer","format": "int64","description": "Discount amount applied to this item.","nullable": true+ },+ "discount_percentage": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Percentage"+ }+ ],+ "nullable": true+ },+ "discount_type": {+ "type": "string",+ "description": "Discount type applied to this item.",+ "nullable": true}}},@@ -27049,6 +27067,20 @@}}},+ "Percentage": {+ "type": "object",+ "description": "Represents Percentage Value between 0 and 100 both inclusive",+ "required": [+ "percentage"+ ],+ "properties": {+ "percentage": {+ "type": "number",+ "format": "double",+ "description": "Percentage value ranging between 0 and 100"+ }+ }+ },"PhoneDetails": {"type": "object","properties": {@@ -32002,7 +32034,7 @@"properties": {"percentage": {"type": "number",- "format": "float"+ "format": "double"}}},diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 4d37c51724..2b6ffda666 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -2389,7 +2389,7 @@ impl From<Surcharge> for SurchargeResponse {#[derive(Clone, Default, Debug, PartialEq, serde::Serialize, ToSchema)]pub struct SurchargePercentage {- percentage: f32,+ percentage: f64,}impl From<Percentage<SURCHARGE_PERCENTAGE_PRECISION_LENGTH>> for SurchargePercentage {diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 3b5e7350f8..2fa85b3a06 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -18,7 +18,7 @@ use common_types::{customers::DocumentKind, payments as common_payments_types, primitive_wrappers,};use common_utils::{- consts::default_payments_list_limit,+ consts::{default_payments_list_limit, DISCOUNT_PERCENTAGE_PRECISION_LENGTH},crypto,errors::ValidationError,ext_traits::{ConfigExt, Encode, ValueExt},@@ -26,7 +26,7 @@ use common_utils::{id_type,new_type::MaskedBankAccount,pii::{self, Email},- types::{AmountConvertor, MinorUnit, SemanticVersion, StringMajorUnit},+ types::{AmountConvertor, MinorUnit, Percentage, SemanticVersion, StringMajorUnit},};use error_stack::ResultExt;@@ -9559,6 +9559,9 @@ pub struct PaymentsRetrieveRequest {pub all_keys_required: Option<bool>,}+/// Percentage value used to represent the discount applied on an item.+pub type DiscountPercentage = Percentage<DISCOUNT_PERCENTAGE_PRECISION_LENGTH>;+#[derive(Debug, Default, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema, SmithyModel,)]@@ -9625,10 +9628,20 @@ pub struct OrderDetailsWithAmount {#[schema(value_type = Option<i64>)]#[smithy(value_type = "Option<i64>")]pub total_amount: Option<MinorUnit>, // total_amount,+ /// Discount name applied to this item.+ #[smithy(value_type = "Option<String>")]+ pub discount_name: Option<String>,/// Discount amount applied to this item.#[schema(value_type = Option<i64>)]#[smithy(value_type = "Option<i64>")]pub unit_discount_amount: Option<MinorUnit>,+ /// Discount percentage applied to this item.+ #[schema(value_type = Option<Percentage<DISCOUNT_PERCENTAGE_PRECISION_LENGTH>>)]+ #[smithy(value_type = "Option<Percentage<DISCOUNT_PERCENTAGE_PRECISION_LENGTH>>")]+ pub discount_percentage: Option<DiscountPercentage>,+ /// Discount type applied to this item.+ #[smithy(value_type = "Option<String>")]+ pub discount_type: Option<String>,}impl hyperswitch_masking::SerializableSecret for OrderDetailsWithAmount {}diff --git a/crates/common_utils/src/consts.rs b/crates/common_utils/src/consts.rsindex 24dc87be64..a5df3c4ac9 100644--- a/crates/common_utils/src/consts.rs+++ b/crates/common_utils/src/consts.rs@@ -46,6 +46,9 @@ pub fn default_payouts_list_limit() -> u32 {/// surcharge percentage maximum precision lengthpub const SURCHARGE_PERCENTAGE_PRECISION_LENGTH: u8 = 2;+/// discount percentage maximum precision length+pub const DISCOUNT_PERCENTAGE_PRECISION_LENGTH: u8 = 2;+/// installment interest rate maximum precision lengthpub const INSTALLMENT_INTEREST_RATE_PRECISION_LENGTH: u8 = 2;diff --git a/crates/common_utils/src/errors.rs b/crates/common_utils/src/errors.rsindex 07abe2334f..b62fee339f 100644--- a/crates/common_utils/src/errors.rs+++ b/crates/common_utils/src/errors.rs@@ -136,7 +136,7 @@ pub enum PercentageError {#[error("Failed apply percentage of {percentage} on {amount}")]UnableToApplyPercentage {/// percentage value- percentage: f32,+ percentage: f64,/// amount valueamount: MinorUnit,},diff --git a/crates/common_utils/src/types.rs b/crates/common_utils/src/types.rsindex 3fcc4ccc75..e069d10567 100644--- a/crates/common_utils/src/types.rs+++ b/crates/common_utils/src/types.rs@@ -54,11 +54,11 @@ use crate::{};/// Represents Percentage Value between 0 and 100 both inclusive-#[derive(Clone, Default, Debug, PartialEq, Serialize)]+#[derive(Clone, Default, Debug, PartialEq, Serialize, ToSchema)]pub struct Percentage<const PRECISION: u8> {// this value will range from 0 to 100, decimal length defined by precision macro/// Percentage value ranging between 0 and 100- percentage: f32,+ percentage: f64,}fn get_invalid_percentage_error_message(precision: u8) -> String {@@ -74,7 +74,7 @@ impl<const PRECISION: u8> Percentage<PRECISION> {if Self::is_valid_string_value(&value)? {Ok(Self {percentage: value- .parse::<f32>()+ .parse::<f64>().change_context(PercentageError::InvalidPercentageValue)?,})} else {@@ -83,7 +83,7 @@ impl<const PRECISION: u8> Percentage<PRECISION> {}}/// function to get percentage value- pub fn get_percentage(&self) -> f32 {+ pub fn get_percentage(&self) -> f64 {self.percentage}@@ -105,8 +105,7 @@ impl<const PRECISION: u8> Percentage<PRECISION> {"Cannot calculate percentage for amount greater than {max_amount}",))} else {- let percentage_f64 = f64::from(self.percentage);- let result = (amount as f64 * (percentage_f64 / 100.0)).ceil() as i64;+ let result = (amount as f64 * (self.percentage / 100.0)).ceil() as i64;Ok(MinorUnit::new(result))}}@@ -115,12 +114,12 @@ impl<const PRECISION: u8> Percentage<PRECISION> {let float_value = Self::is_valid_float_string(value)?;Ok(Self::is_valid_range(float_value) && Self::is_valid_precision_length(value))}- fn is_valid_float_string(value: &str) -> CustomResult<f32, PercentageError> {+ fn is_valid_float_string(value: &str) -> CustomResult<f64, PercentageError> {value- .parse::<f32>()+ .parse::<f64>().change_context(PercentageError::InvalidPercentageValue)}- fn is_valid_range(value: f32) -> bool {+ fn is_valid_range(value: f64) -> bool {(0.0..=100.0).contains(&value)}fn is_valid_precision_length(value: &str) -> bool {diff --git a/crates/common_utils/tests/percentage.rs b/crates/common_utils/tests/percentage.rsindex fbb350820e..06d6d86942 100644--- a/crates/common_utils/tests/percentage.rs+++ b/crates/common_utils/tests/percentage.rs@@ -117,7 +117,7 @@ fn deserialization_test_ok() -> Result<(), Box<dyn std::error::Error + Send + Syassert_eq!(percentage.get_percentage(),format!("{integer}.{decimal}")- .parse::<f32>()+ .parse::<f64>().unwrap_or_default())}diff --git a/crates/connector_configs/src/common_config.rs b/crates/connector_configs/src/common_config.rsindex 039a3b5abf..aa3c51e736 100644--- a/crates/connector_configs/src/common_config.rs+++ b/crates/connector_configs/src/common_config.rs@@ -113,6 +113,9 @@ pub struct ApiModelMetaData {pub platform_url: Option<String>,pub account_id: Option<serde_json::Value>,pub site: Option<String>,+ pub merchant_street_address: Option<String>,+ pub customer_service_phone_number: Option<String>,+ pub merchant_url: Option<String>,}#[serde_with::skip_serializing_none]diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rsindex 5d0a24ae54..5b81984439 100644--- a/crates/connector_configs/src/connector.rs+++ b/crates/connector_configs/src/connector.rs@@ -204,6 +204,9 @@ pub struct ConfigMetadata {pub kid: Option<InputData>,pub account_holder_name: Option<InputData>,pub private_key: Option<InputData>,+ pub merchant_street_address: Option<String>,+ pub customer_service_phone_number: Option<String>,+ pub merchant_url: Option<String>,}#[serde_with::skip_serializing_none]diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex f98dacc4d6..93cd70994b 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -5355,6 +5355,24 @@ key1="Transaction Key"api_secret="Developer Id"[tsys_transit.connector_webhook_details]merchant_secret="Source verification key"+[tsys_transit.metadata.merchant_street_address]+name="merchant_street_address"+label="Merchant Street Address"+placeholder="Enter street address"+required=false+type="Text"+[tsys_transit.metadata.customer_service_phone_number]+name="customer_service_phone_number"+label="Customer Service Number"+placeholder="Enter customer service phone number"+required=false+type="Text"+[tsys_transit.metadata.merchant_url]+name="merchant_url"+label="Merchant Url"+placeholder="Enter merchant url"+required=false+type="Text"[volt][[volt.bank_redirect]]diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.tomlindex 2b014c12a6..2a0a925ec2 100644--- a/crates/connector_configs/toml/production.toml+++ b/crates/connector_configs/toml/production.toml@@ -4903,6 +4903,24 @@ key1 = "Transaction Key"api_secret = "Developer Id"[tsys_transit.connector_webhook_details]merchant_secret = "Source verification key"+[tsys_transit.metadata.merchant_street_address]+name="merchant_street_address"+label="Merchant Street Address"+placeholder="Enter street address"+required=false+type="Text"+[tsys_transit.metadata.customer_service_phone_number]+name="customer_service_phone_number"+label="Customer Service Number"+placeholder="Enter customer service phone number"+required=false+type="Text"+[tsys_transit.metadata.merchant_url]+name="merchant_url"+label="Merchant Url"+placeholder="Enter merchant url"+required=false+type="Text"[volt][[volt.bank_redirect]]diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex 0cf122e2b5..43eb4f4c68 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -5315,6 +5315,24 @@ key1 = "Transaction Key"api_secret = "Developer Id"[tsys_transit.connector_webhook_details]merchant_secret = "Source verification key"+[tsys_transit.metadata.merchant_street_address]+name="merchant_street_address"+label="Merchant Street Address"+placeholder="Enter street address"+required=false+type="Text"+[tsys_transit.metadata.customer_service_phone_number]+name="customer_service_phone_number"+label="Customer Service Number"+placeholder="Enter customer service phone number"+required=false+type="Text"+[tsys_transit.metadata.merchant_url]+name="merchant_url"+label="Merchant Url"+placeholder="Enter merchant url"+required=false+type="Text"[volt][[volt.bank_redirect]]diff --git a/crates/diesel_models/src/types.rs b/crates/diesel_models/src/types.rsindex d92152884c..341de0dca6 100644--- a/crates/diesel_models/src/types.rs+++ b/crates/diesel_models/src/types.rs@@ -3,9 +3,10 @@ use common_enums::enums::PaymentConnectorTransmission;#[cfg(feature = "v2")]use common_utils::id_type;use common_utils::{+ consts::DISCOUNT_PERCENTAGE_PRECISION_LENGTH,hashing::HashedString,pii,- types::{MinorUnit, StringMajorUnit},+ types::{MinorUnit, Percentage, StringMajorUnit},};use diesel::{sql_types::{Json, Jsonb},@@ -55,8 +56,14 @@ pub struct OrderDetailsWithAmount {pub unit_of_measure: Option<String>,/// total amount of the productpub total_amount: Option<MinorUnit>,+ /// discount name on the unit+ pub discount_name: Option<String>,/// discount amount on the unitpub unit_discount_amount: Option<MinorUnit>,+ /// discount percentage on the unit+ pub discount_percentage: Option<Percentage<DISCOUNT_PERCENTAGE_PRECISION_LENGTH>>,+ /// discount type on the unit+ pub discount_type: Option<String>,}impl hyperswitch_masking::SerializableSecret for OrderDetailsWithAmount {}diff --git a/crates/hyperswitch_connectors/src/connectors/tsys_transit.rs b/crates/hyperswitch_connectors/src/connectors/tsys_transit.rsindex 652092b4e7..5d2a276611 100644--- a/crates/hyperswitch_connectors/src/connectors/tsys_transit.rs+++ b/crates/hyperswitch_connectors/src/connectors/tsys_transit.rs@@ -74,6 +74,9 @@ pub struct TsysTransitMetadataObject {pub commercial_card: Option<serde_json::Value>,#[serde(default)]pub tsys_transit: Option<serde_json::Value>,+ pub merchant_street_address: Option<Secret<String>>,+ pub customer_service_phone_number: Option<Secret<String>>,+ pub merchant_url: Option<url::Url>,}impl TryFrom<&Option<common_utils::pii::SecretSerdeValue>> for TsysTransitMetadataObject {diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rsindex 18f2e3443d..01485410ec 100644--- a/crates/hyperswitch_domain_models/src/lib.rs+++ b/crates/hyperswitch_domain_models/src/lib.rs@@ -1018,6 +1018,9 @@ impl ApiModelToDieselModelConvertor<ApiOrderDetailsWithAmount> for OrderDetailsWunit_of_measure,total_amount,unit_discount_amount,+ discount_name,+ discount_percentage,+ discount_type,} = from;Self {product_name,@@ -1040,6 +1043,9 @@ impl ApiModelToDieselModelConvertor<ApiOrderDetailsWithAmount> for OrderDetailsWunit_of_measure,total_amount,unit_discount_amount,+ discount_name,+ discount_percentage,+ discount_type,}}@@ -1065,6 +1071,9 @@ impl ApiModelToDieselModelConvertor<ApiOrderDetailsWithAmount> for OrderDetailsWunit_of_measure,total_amount,unit_discount_amount,+ discount_name,+ discount_percentage,+ discount_type,} = self;ApiOrderDetailsWithAmount {product_name,@@ -1087,6 +1096,9 @@ impl ApiModelToDieselModelConvertor<ApiOrderDetailsWithAmount> for OrderDetailsWunit_of_measure,total_amount,unit_discount_amount,+ discount_name,+ discount_percentage,+ discount_type,}}}diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex f6af814b18..0b93a8ef23 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -1181,6 +1181,7 @@ Never share your secret api keys. Keep them guarded and secure.common_types::payments::PaymentMethodsConfig,common_types::payments::TokenSource,common_types::payments::NetworkTransactionIdAndDecryptedWalletTokenDetails,+ common_utils::types::Percentage<{ common_utils::consts::DISCOUNT_PERCENTAGE_PRECISION_LENGTH }>,)),modifiers(&SecurityAddon))]diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex 50498b51cc..2b0c00fd05 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -197,6 +197,7 @@ Never share your secret api keys. Keep them guarded and secure.common_utils::types::StringMinorUnit,common_utils::types::TimeRange,common_utils::types::BrowserInformation,+ common_utils::types::Percentage<{ common_utils::consts::DISCOUNT_PERCENTAGE_PRECISION_LENGTH }>,common_utils::link_utils::GenericLinkUiConfig,common_utils::link_utils::EnabledPaymentMethod,common_utils::payout_method_utils::AdditionalPayoutMethodData,diff --git a/crates/router/src/core/unified_connector_service/connector_config.rs b/crates/router/src/core/unified_connector_service/connector_config.rsindex 67d720e6f3..d1c516b240 100644--- a/crates/router/src/core/unified_connector_service/connector_config.rs+++ b/crates/router/src/core/unified_connector_service/connector_config.rs@@ -158,6 +158,13 @@ pub struct PeachpaymentsMetadata {merchant_payment_method_route_id: Secret<String>,}+#[derive(Debug, serde::Deserialize)]+pub struct TsysTransitMetadata {+ merchant_street_address: Option<Secret<String>>,+ customer_service_phone_number: Option<Secret<String>>,+ merchant_url: Option<url::Url>,+}+/// Connector-specific configuration enum for all supported connectors#[derive(Debug, Clone, serde::Serialize)]pub enum ConnectorSpecificConfig {@@ -472,6 +479,9 @@ pub enum ConnectorSpecificConfig {device_id: Secret<String>,transaction_key: Secret<String>,developer_id: Secret<String>,+ merchant_street_address: Option<Secret<String>>,+ customer_service_phone_number: Option<Secret<String>>,+ merchant_url: Option<String>,},/// Bamboraapac connector configurationBamboraapac {@@ -1342,11 +1352,32 @@ impl ForeignTryFrom<(Connector, &ConnectorAuthType, Option<&serde_json::Value>)>api_key,key1,api_secret,- } => Ok(Self::TsysTransit {- device_id: api_key.clone(),- transaction_key: key1.clone(),- developer_id: api_secret.clone(),- }),+ } => {+ let tsys_transit_meta = metadata+ .map(|meta| {+ serde_json::from_value::<TsysTransitMetadata>(meta.clone())+ .map_err(|_| err("Invalid tsys transit metadata format"))+ })+ .transpose()?;++ Ok(Self::TsysTransit {+ device_id: api_key.clone(),+ transaction_key: key1.clone(),+ developer_id: api_secret.clone(),+ merchant_street_address: tsys_transit_meta+ .as_ref()+ .and_then(|metadata| metadata.merchant_street_address.clone()),+ customer_service_phone_number: tsys_transit_meta+ .as_ref()+ .and_then(|metadata| metadata.customer_service_phone_number.clone()),+ merchant_url: tsys_transit_meta.as_ref().and_then(|metadata| {+ metadata+ .merchant_url+ .as_ref()+ .map(|merchant_url| merchant_url.to_string())+ }),+ })+ }_ => Err(err("TsysTransit requires SignatureKey auth type")),},Connector::Wellsfargo => match auth {diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex cb7e9bec45..41d77352b7 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -120,9 +120,12 @@ fn build_ucs_order_details(unit_discount_amount: detail.unit_discount_amount.map(|amount| amount.get_amount_as_i64()),- discount_name: None,- discount_percentage: None,- discount_type: None,+ discount_name: detail.discount_name.clone(),+ discount_percentage: detail+ .discount_percentage+ .as_ref()+ .map(|value| value.get_percentage()),+ discount_type: detail.discount_type.clone(),}).collect()})diff --git a/crates/router/tests/connectors/payme.rs b/crates/router/tests/connectors/payme.rsindex 836c9d9937..2ee4ea8afb 100644--- a/crates/router/tests/connectors/payme.rs+++ b/crates/router/tests/connectors/payme.rs@@ -99,6 +99,9 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {unit_of_measure: None,total_amount: None,unit_discount_amount: None,+ discount_name: None,+ discount_percentage: None,+ discount_type: None,}]),router_return_url: Some("https://hyperswitch.io".to_string()),webhook_url: Some("https://hyperswitch.io".to_string()),@@ -409,6 +412,9 @@ async fn should_fail_payment_for_incorrect_cvc() {unit_of_measure: None,total_amount: None,unit_discount_amount: None,+ discount_name: None,+ discount_percentage: None,+ discount_type: None,}]),router_return_url: Some("https://hyperswitch.io".to_string()),webhook_url: Some("https://hyperswitch.io".to_string()),@@ -458,6 +464,9 @@ async fn should_fail_payment_for_invalid_exp_month() {unit_of_measure: None,total_amount: None,unit_discount_amount: None,+ discount_name: None,+ discount_percentage: None,+ discount_type: None,}]),router_return_url: Some("https://hyperswitch.io".to_string()),webhook_url: Some("https://hyperswitch.io".to_string()),@@ -507,6 +516,9 @@ async fn should_fail_payment_for_incorrect_expiry_year() {unit_of_measure: None,total_amount: None,unit_discount_amount: None,+ discount_name: None,+ discount_percentage: None,+ discount_type: None,}]),router_return_url: Some("https://hyperswitch.io".to_string()),webhook_url: Some("https://hyperswitch.io".to_string()),diff --git a/crates/router/tests/connectors/zen.rs b/crates/router/tests/connectors/zen.rsindex c8bd4482d0..ab9e589536 100644--- a/crates/router/tests/connectors/zen.rs+++ b/crates/router/tests/connectors/zen.rs@@ -343,6 +343,9 @@ async fn should_fail_payment_for_incorrect_card_number() {unit_of_measure: None,total_amount: None,unit_discount_amount: None,+ discount_name: None,+ discount_percentage: None,+ discount_type: None,}]),email: Some(Email::from_str("[email protected]").unwrap()),webhook_url: Some("https://1635-116-74-253-164.ngrok-free.app".to_string()),@@ -395,6 +398,9 @@ async fn should_fail_payment_for_incorrect_cvc() {unit_of_measure: None,total_amount: None,unit_discount_amount: None,+ discount_name: None,+ discount_percentage: None,+ discount_type: None,}]),email: Some(Email::from_str("[email protected]").unwrap()),webhook_url: Some("https://1635-116-74-253-164.ngrok-free.app".to_string()),@@ -447,6 +453,9 @@ async fn should_fail_payment_for_invalid_exp_month() {unit_of_measure: None,total_amount: None,unit_discount_amount: None,+ discount_name: None,+ discount_percentage: None,+ discount_type: None,}]),email: Some(Email::from_str("[email protected]").unwrap()),webhook_url: Some("https://1635-116-74-253-164.ngrok-free.app".to_string()),@@ -499,6 +508,9 @@ async fn should_fail_payment_for_incorrect_expiry_year() {unit_of_measure: None,total_amount: None,unit_discount_amount: None,+ discount_name: None,+ discount_percentage: None,+ discount_type: None,}]),email: Some(Email::from_str("[email protected]").unwrap()),webhook_url: Some("https://1635-116-74-253-164.ngrok-free.app".to_string()),diff --git a/crates/smithy-core/src/types.rs b/crates/smithy-core/src/types.rsindex 921f9659a2..c67f2a5e1e 100644--- a/crates/smithy-core/src/types.rs+++ b/crates/smithy-core/src/types.rs@@ -256,6 +256,36 @@ pub fn resolve_type_and_generate_shapes()}+ vt if vt.starts_with("Percentage<") && vt.ends_with('>') => {+ let shape_name = "PercentageValue".to_string();+ if !shapes.contains_key(&shape_name) && !generated_shapes.contains_key(&shape_name) {+ let mut members = HashMap::new();+ members.insert(+ "percentage".to_string(),+ SmithyMember {+ target: "smithy.api#Double".to_string(),+ documentation: Some(+ "Percentage value ranging between 0 and 100".to_string(),+ ),+ traits: vec![SmithyTrait::Required],+ },+ );+ generated_shapes.insert(+ shape_name.clone(),+ SmithyShape::Structure {+ members,+ documentation: Some(+ "Represents a percentage value between 0 and 100, precise to a \+ fixed number of decimal digits"+ .to_string(),+ ),+ traits: vec![],+ },+ );+ }+ shape_name+ }+_ => {if value_type.contains("::") {value_type.replace("::", ".")