From cbc262fbdfe59a3984864be91325f3bb942736ae Mon Sep 17 00:00:00 2001 From: sweta-sharma <77436883+Sweta-Kumari-Sharma@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:50:24 +0530 Subject: [PATCH] refactor(dynamic_fields): Multiple SDK queries fixed (#7380) --- crates/api_models/src/enums.rs | 1 + crates/connector_configs/src/transformer.rs | 3 ++ .../connector_configs/toml/development.toml | 2 ++ .../hyperswitch_domain_models/src/address.rs | 16 ++++++++--- .../payment_connector_required_fields.rs | 28 +++++++++---------- crates/router/src/core/payments.rs | 6 ++-- 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs index bd328c75a0..212504baaa 100644 --- a/crates/api_models/src/enums.rs +++ b/crates/api_models/src/enums.rs @@ -233,6 +233,7 @@ pub enum FieldType { UserShippingAddressPincode, UserShippingAddressState, UserShippingAddressCountry { options: Vec }, + UserSocialSecurityNumber, UserBlikCode, UserBank, UserBankAccountNumber, diff --git a/crates/connector_configs/src/transformer.rs b/crates/connector_configs/src/transformer.rs index ed3319816d..63c7d99ee1 100644 --- a/crates/connector_configs/src/transformer.rs +++ b/crates/connector_configs/src/transformer.rs @@ -66,6 +66,9 @@ impl DashboardRequestPayload { (_, PaymentMethodType::DirectCarrierBilling) => { Some(api_models::enums::PaymentExperience::CollectOtp) } + (_, PaymentMethodType::Cashapp) | (_, PaymentMethodType::Swish) => { + Some(api_models::enums::PaymentExperience::DisplayQrCode) + } _ => Some(api_models::enums::PaymentExperience::RedirectToUrl), }, } diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml index f9cbeb878c..30b2be968f 100644 --- a/crates/connector_configs/toml/development.toml +++ b/crates/connector_configs/toml/development.toml @@ -189,6 +189,7 @@ merchant_secret="Source verification key" payment_method_type = "momo" [[adyen.wallet]] payment_method_type = "swish" + payment_experience = "display_qr_code" [[adyen.wallet]] payment_method_type = "touch_n_go" [[adyen.voucher]] @@ -3329,6 +3330,7 @@ merchant_secret="Source verification key" payment_method_type = "ali_pay" [[stripe.wallet]] payment_method_type = "cashapp" + payment_experience = "display_qr_code" is_verifiable = true [stripe.connector_auth.HeaderKey] api_key="Secret Key" diff --git a/crates/hyperswitch_domain_models/src/address.rs b/crates/hyperswitch_domain_models/src/address.rs index c9beb359c4..f8e38ae8a3 100644 --- a/crates/hyperswitch_domain_models/src/address.rs +++ b/crates/hyperswitch_domain_models/src/address.rs @@ -23,10 +23,18 @@ impl Address { .email .clone() .or(other.and_then(|other| other.email.clone())), - phone: self - .phone - .clone() - .or(other.and_then(|other| other.phone.clone())), + phone: { + self.phone + .clone() + .and_then(|phone_details| { + if phone_details.number.is_some() { + Some(phone_details) + } else { + None + } + }) + .or_else(|| other.and_then(|other| other.phone.clone())) + }, } } } diff --git a/crates/router/src/configs/defaults/payment_connector_required_fields.rs b/crates/router/src/configs/defaults/payment_connector_required_fields.rs index caa24ae110..ddf69c69d6 100644 --- a/crates/router/src/configs/defaults/payment_connector_required_fields.rs +++ b/crates/router/src/configs/defaults/payment_connector_required_fields.rs @@ -3595,9 +3595,9 @@ impl Default for settings::RequiredFields { } ), ( - "payment_method_data.billing.phone.number".to_string(), + "billing.phone.number".to_string(), RequiredFieldInfo { - required_field: "billing.phone.number".to_string(), + required_field: "payment_method_data.billing.phone.number".to_string(), display_name: "phone_number".to_string(), field_type: enums::FieldType::UserPhoneNumber, value: None, @@ -7186,9 +7186,9 @@ impl Default for settings::RequiredFields { } ), ( - "payment_method_data.billing.phone.number".to_string(), + "billing.phone.number".to_string(), RequiredFieldInfo { - required_field: "billing.phone.number".to_string(), + required_field: "payment_method_data.billing.phone.number".to_string(), display_name: "phone_number".to_string(), field_type: enums::FieldType::UserPhoneNumber, value: None, @@ -9964,9 +9964,9 @@ impl Default for settings::RequiredFields { common: HashMap::new(), non_mandate: HashMap::from([ ( - "payment_method_data.billing.phone.number".to_string(), + "billing.phone.number".to_string(), RequiredFieldInfo { - required_field: "billing.phone.number".to_string(), + required_field: "payment_method_data.billing.phone.number".to_string(), display_name: "phone_number".to_string(), field_type: enums::FieldType::UserPhoneNumber, value: None, @@ -11309,7 +11309,7 @@ impl Default for settings::RequiredFields { } ), ( - "payment_method_data.billing.phone.number".to_string(), + "billing.phone.number".to_string(), RequiredFieldInfo { required_field: "payment_method_data.billing.phone.number".to_string(), display_name: "phone_number".to_string(), @@ -11539,9 +11539,9 @@ impl Default for settings::RequiredFields { } ), ( - "payment_method_data.billing.phone.number".to_string(), + "billing.phone.number".to_string(), RequiredFieldInfo { - required_field: "billing.phone.number".to_string(), + required_field: "payment_method_data.billing.phone.number".to_string(), display_name: "phone_number".to_string(), field_type: enums::FieldType::UserPhoneNumber, value: None, @@ -11661,9 +11661,9 @@ impl Default for settings::RequiredFields { } ), ( - "payment_method_data.billing.phone.number".to_string(), + "billing.phone.number".to_string(), RequiredFieldInfo { - required_field: "billing.phone.number".to_string(), + required_field: "payment_method_data.billing.phone.number".to_string(), display_name: "phone_number".to_string(), field_type: enums::FieldType::UserPhoneNumber, value: None, @@ -11789,7 +11789,7 @@ impl Default for settings::RequiredFields { RequiredFieldInfo { required_field: "payment_method_data.voucher.boleto.social_security_number".to_string(), display_name: "social_security_number".to_string(), - field_type: enums::FieldType::Text, + field_type: enums::FieldType::UserSocialSecurityNumber, value: None, } ), @@ -13431,7 +13431,7 @@ impl Default for settings::RequiredFields { ( "payment_method_data.gift_card.number".to_string(), RequiredFieldInfo { - required_field: "payment_method_data.gift_card.number".to_string(), + required_field: "payment_method_data.gift_card.givex.number".to_string(), display_name: "gift_card_number".to_string(), field_type: enums::FieldType::UserCardNumber, value: None, @@ -13440,7 +13440,7 @@ impl Default for settings::RequiredFields { ( "payment_method_data.gift_card.cvc".to_string(), RequiredFieldInfo { - required_field: "payment_method_data.gift_card.cvc".to_string(), + required_field: "payment_method_data.gift_card.givex.cvc".to_string(), display_name: "gift_card_cvc".to_string(), field_type: enums::FieldType::UserCardCvc, value: None, diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index e608de8f1e..5a6fddf7af 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -4563,8 +4563,10 @@ where (router_data, should_continue_payment) } } - Some(domain::PaymentMethodData::GiftCard(_)) => { - if connector.connector_name == router_types::Connector::Adyen { + Some(domain::PaymentMethodData::GiftCard(gift_card_data)) => { + if connector.connector_name == router_types::Connector::Adyen + && matches!(gift_card_data.deref(), domain::GiftCardData::Givex(..)) + { router_data = router_data.preprocessing_steps(state, connector).await?; let is_error_in_response = router_data.response.is_err();