From e4a0ff1c190c0d711aacc67cd25d57bf6c481f0d Mon Sep 17 00:00:00 2001 From: Swangi Kumari <85639103+swangi-kumari@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:40:58 +0530 Subject: [PATCH] refactor(connector): [Mifinity] add a field language_preference in payment request for mifinity payment method data (#5326) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- api-reference/openapi_spec.json | 26 +++++++++++ crates/api_models/src/enums.rs | 2 + crates/api_models/src/payments.rs | 1 + .../src/payment_method_data.rs | 2 + crates/router/src/configs/defaults.rs | 45 +++++++++++++++++++ .../src/connector/mifinity/transformers.rs | 4 ++ 6 files changed, 80 insertions(+) diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index fe58feb053..085d699f85 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -9766,6 +9766,28 @@ "enum": [ "user_vpa_id" ] + }, + { + "type": "object", + "required": [ + "language_preference" + ], + "properties": { + "language_preference": { + "type": "object", + "required": [ + "options" + ], + "properties": { + "options": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } } ], "description": "Possible field type of required fields in payment_method_data" @@ -12177,6 +12199,10 @@ "date_of_birth": { "type": "string", "format": "date" + }, + "language_preference": { + "type": "string", + "nullable": true } } }, diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs index 62e976b093..b36e0ffe44 100644 --- a/crates/api_models/src/enums.rs +++ b/crates/api_models/src/enums.rs @@ -470,6 +470,7 @@ pub enum FieldType { DropDown { options: Vec }, UserDateOfBirth, UserVpaId, + LanguagePreference { options: Vec }, } impl FieldType { @@ -556,6 +557,7 @@ impl PartialEq for FieldType { ) => options_self.eq(options_other), (Self::UserDateOfBirth, Self::UserDateOfBirth) => true, (Self::UserVpaId, Self::UserVpaId) => true, + (Self::LanguagePreference { .. }, Self::LanguagePreference { .. }) => true, _unused => false, } } diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index d63ac8a030..bcc67100e1 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -2785,6 +2785,7 @@ pub struct SwishQrData {} pub struct MifinityData { #[schema(value_type = Date)] pub date_of_birth: Secret, + pub language_preference: Option, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs index b4e6d2f3bc..005e21743d 100644 --- a/crates/hyperswitch_domain_models/src/payment_method_data.rs +++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs @@ -120,6 +120,7 @@ pub enum WalletData { #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct MifinityData { pub date_of_birth: Secret, + pub language_preference: Option, } #[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)] @@ -620,6 +621,7 @@ impl From for WalletData { api_models::payments::WalletData::Mifinity(mifinity_data) => { Self::Mifinity(MifinityData { date_of_birth: mifinity_data.date_of_birth, + language_preference: mifinity_data.language_preference, }) } } diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index d7366a517f..8d19fe3ebc 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -8224,6 +8224,51 @@ impl Default for super::settings::RequiredFields { value: None, } ), + ( + "payment_method_data.wallet.mifinity.language_preference".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.wallet.mifinity.language_preference".to_string(), + display_name: "language_preference".to_string(), + field_type: enums::FieldType::LanguagePreference{ + options: vec![ + "BR".to_string(), + "PT_BR".to_string(), + "CN".to_string(), + "ZH_CN".to_string(), + "DE".to_string(), + "DK".to_string(), + "DA".to_string(), + "DA_DK".to_string(), + "EN".to_string(), + "ES".to_string(), + "FI".to_string(), + "FR".to_string(), + "GR".to_string(), + "EL".to_string(), + "EL_GR".to_string(), + "HR".to_string(), + "IT".to_string(), + "JP".to_string(), + "JA".to_string(), + "JA_JP".to_string(), + "LA".to_string(), + "ES_LA".to_string(), + "NL".to_string(), + "NO".to_string(), + "PL".to_string(), + "PT".to_string(), + "RU".to_string(), + "SV".to_string(), + "SE".to_string(), + "SV_SE".to_string(), + "ZH".to_string(), + "TW".to_string(), + "ZH_TW".to_string(), + ] + }, + value: None, + } + ), ]), } ), diff --git a/crates/router/src/connector/mifinity/transformers.rs b/crates/router/src/connector/mifinity/transformers.rs index 5f0e4b9c9d..5d18834de8 100644 --- a/crates/router/src/connector/mifinity/transformers.rs +++ b/crates/router/src/connector/mifinity/transformers.rs @@ -63,6 +63,8 @@ pub struct MifinityPaymentsRequest { destination_account_number: Secret, brand_id: Secret, return_url: String, + #[serde(skip_serializing_if = "Option::is_none")] + language_preference: Option, } #[derive(Debug, Serialize, PartialEq)] @@ -136,6 +138,7 @@ impl TryFrom<&MifinityRouterData<&types::PaymentsAuthorizeRouterData>> for Mifin let destination_account_number = metadata.destination_account_number; let trace_id = item.router_data.connector_request_reference_id.clone(); let brand_id = metadata.brand_id; + let language_preference = data.language_preference; Ok(Self { money, client, @@ -147,6 +150,7 @@ impl TryFrom<&MifinityRouterData<&types::PaymentsAuthorizeRouterData>> for Mifin destination_account_number, brand_id, return_url: item.router_data.request.get_router_return_url()?, + language_preference, }) } domain::WalletData::AliPayQr(_)