From bd1c1dc41c0ffe3beef269ffe07886bcc40c2b17 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 21 Dec 2023 13:31:22 +0530 Subject: [PATCH 01/23] add dynamic fields for sofort aci --- crates/api_models/src/payments.rs | 4 ++-- crates/router/src/connector/adyen/transformers.rs | 5 +---- .../router/src/connector/paypal/transformers.rs | 7 ++++++- .../router/src/connector/stripe/transformers.rs | 15 ++++++++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 5efebb14f81..5adc4a4a0bf 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1258,7 +1258,7 @@ pub enum BankRedirectData { }, Sofort { /// The billing details for bank redirection - billing_details: BankRedirectBilling, + billing_details: Option, /// The country for bank payment #[schema(value_type = CountryAlpha2, example = "US")] @@ -1266,7 +1266,7 @@ pub enum BankRedirectData { /// The preferred language #[schema(example = "en")] - preferred_language: String, + preferred_language: Option, }, Trustly { /// The country for bank payment diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index 1793e3e07a8..eebd3e099dc 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -2743,10 +2743,7 @@ fn get_redirect_extra_details( country, preferred_language, .. - } => Ok(( - Some(preferred_language.to_string()), - Some(country.to_owned()), - )), + } => Ok((preferred_language.clone(), Some(country.to_owned()))), api_models::payments::BankRedirectData::OpenBankingUk { country, .. } => { let country = country.ok_or(errors::ConnectorError::MissingRequiredField { field_name: "country", diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index 2d3292359d3..c17ec46b341 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -350,7 +350,12 @@ fn get_payment_source( preferred_language: _, billing_details, } => Ok(PaymentSourceItem::Sofort(RedirectRequest { - name: billing_details.get_billing_name()?, + name: billing_details + .clone() + .ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "sofort.billing_details", + })? + .get_billing_name()?, country_code: *country, experience_context: ContextStruct { return_url: item.request.complete_authorize_url.clone(), diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 3a28f777907..b994c16cbd0 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1145,8 +1145,12 @@ impl TryFrom<&payments::BankRedirectData> for StripeBillingAddress { payments::BankRedirectData::Sofort { billing_details, .. } => Ok(Self { - name: billing_details.billing_name.clone(), - email: billing_details.email.clone(), + name: billing_details + .clone() + .and_then(|billing_data| billing_data.billing_name.clone()), + email: billing_details + .clone() + .and_then(|billing_data| billing_data.email.clone()), ..Self::default() }), payments::BankRedirectData::Bizum {} @@ -1632,7 +1636,12 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData { Box::new(StripeSofort { payment_method_data_type, country: country.to_owned(), - preferred_language: preferred_language.to_owned(), + preferred_language: preferred_language + .clone() + .ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "sofort.preferred_language", + })? + .to_owned(), }), ))), payments::BankRedirectData::OnlineBankingFpx { .. } => { From b3d0f999cb5617a8dffbff1bd7d1064b6f25b9e6 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 21 Dec 2023 14:33:44 +0530 Subject: [PATCH 02/23] add dynamic field changes for sofort aci --- crates/api_models/src/payments.rs | 2 +- crates/router/src/configs/defaults.rs | 27 +++++++++++++++++-- .../router/src/connector/aci/transformers.rs | 2 +- .../src/connector/adyen/transformers.rs | 2 +- .../src/connector/paypal/transformers.rs | 4 ++- .../src/connector/stripe/transformers.rs | 4 ++- 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 5adc4a4a0bf..d087d15c403 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1262,7 +1262,7 @@ pub enum BankRedirectData { /// The country for bank payment #[schema(value_type = CountryAlpha2, example = "US")] - country: api_enums::CountryAlpha2, + country: Option, /// The preferred language #[schema(example = "en")] diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index 83a34b87dd0..cde6859106c 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4460,10 +4460,33 @@ impl Default for super::settings::RequiredFields { ConnectorFields { fields: HashMap::from([ ( - enums::Connector::Stripe, + enums::Connector::Aci, RequiredFieldFinal { mandate: HashMap::new(), - non_mandate: HashMap::new(), + non_mandate: ( + "payment_method_data.bank_redirect.sofort.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.sofort.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "ES".to_string() , + "GB".to_string(), + "SE".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "CH".to_string(), + "BE".to_string(), + "FR".to_string(), + "FI".to_string(), + "IT".to_string(), + "PL".to_string(), + ] + }, + value: None, + } + ), common: HashMap::new(), } ), diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index e729eacf9d9..cc1dc757716 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -190,7 +190,7 @@ impl api_models::payments::BankRedirectData::Sofort { country, .. } => { Self::BankRedirect(Box::new(BankRedirectionPMData { payment_brand: PaymentBrand::Sofortueberweisung, - bank_account_country: Some(country.to_owned()), + bank_account_country: country.to_owned(), bank_account_bank_name: None, bank_account_bic: None, bank_account_iban: None, diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index eebd3e099dc..6dbb7a4b609 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -2743,7 +2743,7 @@ fn get_redirect_extra_details( country, preferred_language, .. - } => Ok((preferred_language.clone(), Some(country.to_owned()))), + } => Ok((preferred_language.clone(), country.clone())), api_models::payments::BankRedirectData::OpenBankingUk { country, .. } => { let country = country.ok_or(errors::ConnectorError::MissingRequiredField { field_name: "country", diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index c17ec46b341..62132a4319e 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -356,7 +356,9 @@ fn get_payment_source( field_name: "sofort.billing_details", })? .get_billing_name()?, - country_code: *country, + country_code: country.ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "country", + })?, experience_context: ContextStruct { return_url: item.request.complete_authorize_url.clone(), cancel_url: item.request.complete_authorize_url.clone(), diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index b994c16cbd0..550a9c4c0bf 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1635,7 +1635,9 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData { } => Ok(Self::BankRedirect(StripeBankRedirectData::StripeSofort( Box::new(StripeSofort { payment_method_data_type, - country: country.to_owned(), + country: country.ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "country", + })?.to_owned(), preferred_language: preferred_language .clone() .ok_or(errors::ConnectorError::MissingRequiredField { From dd67feed2ce66052b805fc9d2542a9a9304c501c Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 21 Dec 2023 15:01:01 +0530 Subject: [PATCH 03/23] add dynamic field changes for sofort aci --- crates/router/src/configs/defaults.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index cde6859106c..71da0ce250a 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4463,14 +4463,14 @@ impl Default for super::settings::RequiredFields { enums::Connector::Aci, RequiredFieldFinal { mandate: HashMap::new(), - non_mandate: ( - "payment_method_data.bank_redirect.sofort.country".to_string(), + non_mandate: HashMap::from([ + ("payment_method_data.bank_redirect.sofort.country".to_string(), RequiredFieldInfo { required_field: "payment_method_data.bank_redirect.sofort.country".to_string(), display_name: "country".to_string(), field_type: enums::FieldType::UserCountry { options: vec![ - "ES".to_string() , + "ES".to_string(), "GB".to_string(), "SE".to_string(), "AT".to_string(), @@ -4486,7 +4486,16 @@ impl Default for super::settings::RequiredFields { }, value: None, } - ), + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), common: HashMap::new(), } ), From 0bd5824c9a6cd346b87c59d59568be5d05e015b1 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 21 Dec 2023 15:31:48 +0530 Subject: [PATCH 04/23] add globalpay and mollie dynamic fields for sofort --- crates/router/src/configs/defaults.rs | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index 71da0ce250a..2d88025a4bf 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4499,7 +4499,48 @@ impl Default for super::settings::RequiredFields { common: HashMap::new(), } ), - ]), + ( + enums::Connector::Globalpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ("billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec![ + "ES".to_string(), + "GB".to_string(), + "SE".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "CH".to_string(), + "BE".to_string(), + "FR".to_string(), + "FI".to_string(), + "IT".to_string(), + "PL".to_string(), + ] + }, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Mollie, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + + ]), }, ), ( From 588c6b31a1c2d633412a75aadaa72df12d304716 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 21 Dec 2023 19:16:58 +0530 Subject: [PATCH 05/23] add dynamic fields for sofort --- crates/router/src/configs/defaults.rs | 220 +++++++++++++++++++++++++- 1 file changed, 219 insertions(+), 1 deletion(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index 2d88025a4bf..5b80610bd37 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4539,7 +4539,225 @@ impl Default for super::settings::RequiredFields { common: HashMap::new(), } ), - + ( + enums::Connector::Nexinets, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Nuvei, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::from([ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "AT".to_string(), + ] + }, + value: None, + } + )] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Paypal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ("payment_method_data.bank_redirect.sofort.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.sofort.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "ES".to_string(), + "GB".to_string(), + "SE".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "CH".to_string(), + "BE".to_string(), + "FR".to_string(), + "FI".to_string(), + "IT".to_string(), + "PL".to_string(), + ] + }, + value: None, + } + ), + ( + "payment_method_data.bank_redirect.sofort.billing_details.billing_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.sofort.billing_details.billing_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Shift4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.bank_redirect.sofort.preferred_language".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.sofort.preferred_language".to_string(), + display_name: "preferred_language".to_string(), + field_type: enums::FieldType::Text, + value: None, + } + ), + ("payment_method_data.bank_redirect.sofort.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.sofort.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "ES".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "BE".to_string(), + "IT".to_string(), + ] + }, + value: None, + } + ), + ]) + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec![ + "ES".to_string(), + "GB".to_string(), + "SE".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "CH".to_string(), + "BE".to_string(), + "FR".to_string(), + "FI".to_string(), + "IT".to_string(), + "PL".to_string(), + ] + }, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), ]), }, ), From 8679744c58da5b00f5bef8ce16c5953e0220610c Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:54:41 +0000 Subject: [PATCH 06/23] chore: run formatter --- crates/router/src/connector/stripe/transformers.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 550a9c4c0bf..dc0d07e59f1 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1635,9 +1635,11 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData { } => Ok(Self::BankRedirect(StripeBankRedirectData::StripeSofort( Box::new(StripeSofort { payment_method_data_type, - country: country.ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "country", - })?.to_owned(), + country: country + .ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "country", + })? + .to_owned(), preferred_language: preferred_language .clone() .ok_or(errors::ConnectorError::MissingRequiredField { From eb36df433bff93e02ff773005110f87a79a79480 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:03:20 +0000 Subject: [PATCH 07/23] docs(openapi): re-generate OpenAPI specification --- openapi/openapi_spec.json | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 3ffb98e56b9..af3fd721543 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -3648,13 +3648,16 @@ "sofort": { "type": "object", "required": [ - "billing_details", - "country", - "preferred_language" + "country" ], "properties": { "billing_details": { - "$ref": "#/components/schemas/BankRedirectBilling" + "allOf": [ + { + "$ref": "#/components/schemas/BankRedirectBilling" + } + ], + "nullable": true }, "country": { "$ref": "#/components/schemas/CountryAlpha2" @@ -3662,7 +3665,8 @@ "preferred_language": { "type": "string", "description": "The preferred language", - "example": "en" + "example": "en", + "nullable": true } } } From e79095520a37c5ba1261734f51aa6eba32a91046 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 1 Jan 2024 18:08:35 +0530 Subject: [PATCH 08/23] add mandate req field for stripe sofort --- crates/router/src/configs/defaults.rs | 21 ++++++++++++++++++- .../router/src/connector/aci/transformers.rs | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index 5b80610bd37..9509f9c72e6 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4648,7 +4648,26 @@ impl Default for super::settings::RequiredFields { ( enums::Connector::Stripe, RequiredFieldFinal { - mandate: HashMap::new(), + mandate: HashMap::from([ + ( + "payment_method_data.bank_redirect.sofort.billing_details.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.sofort.billing_details.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "payment_method_data.bank_redirect.sofort.billing_details.billing_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.sofort.billing_details.billing_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ) + ]), non_mandate: HashMap::new(), common: HashMap::from([ ( diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index cc1dc757716..28fbd4646af 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -190,7 +190,7 @@ impl api_models::payments::BankRedirectData::Sofort { country, .. } => { Self::BankRedirect(Box::new(BankRedirectionPMData { payment_brand: PaymentBrand::Sofortueberweisung, - bank_account_country: country.to_owned(), + bank_account_country: Some(country.clone().ok_or(errors::ConnectorError::MissingRequiredField{field_name: "country"})?), bank_account_bank_name: None, bank_account_bic: None, bank_account_iban: None, From 678eb53feb2326ead0b6c1b797184206743476f9 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 12:39:27 +0000 Subject: [PATCH 09/23] chore: run formatter --- crates/router/src/connector/aci/transformers.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index 28fbd4646af..aa79b3e037b 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -190,7 +190,11 @@ impl api_models::payments::BankRedirectData::Sofort { country, .. } => { Self::BankRedirect(Box::new(BankRedirectionPMData { payment_brand: PaymentBrand::Sofortueberweisung, - bank_account_country: Some(country.clone().ok_or(errors::ConnectorError::MissingRequiredField{field_name: "country"})?), + bank_account_country: Some(country.clone().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "country", + }, + )?), bank_account_bank_name: None, bank_account_bic: None, bank_account_iban: None, From bd59a2ea48e1102c19ecb89d0c47d194ccf0f5d2 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 9 Jan 2024 12:40:39 +0530 Subject: [PATCH 10/23] make fields manditory --- crates/router/src/configs/defaults.rs | 56 +++++-------------- .../src/connector/paypal/transformers.rs | 4 +- .../src/connector/stripe/transformers.rs | 17 ++---- 3 files changed, 19 insertions(+), 58 deletions(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index 4b98f49b81f..11e4f04b4ee 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4547,18 +4547,12 @@ impl Default for super::settings::RequiredFields { display_name: "country".to_string(), field_type: enums::FieldType::UserAddressCountry { options: vec![ - "ES".to_string(), - "GB".to_string(), - "SE".to_string(), "AT".to_string(), - "NL".to_string(), - "DE".to_string(), - "CH".to_string(), "BE".to_string(), - "FR".to_string(), - "FI".to_string(), + "DE".to_string(), + "ES".to_string(), "IT".to_string(), - "PL".to_string(), + "NL".to_string(), ] }, value: None, @@ -4622,7 +4616,16 @@ impl Default for super::settings::RequiredFields { display_name: "country".to_string(), field_type: enums::FieldType::UserAddressCountry{ options: vec![ + "ES".to_string(), + "GB".to_string(), + "IT".to_string(), + "DE".to_string(), + "FR".to_string(), "AT".to_string(), + "BE".to_string(), + "NL".to_string(), + "BE".to_string(), + "SK".to_string(), ] }, value: None, @@ -4645,16 +4648,10 @@ impl Default for super::settings::RequiredFields { options: vec![ "ES".to_string(), "GB".to_string(), - "SE".to_string(), "AT".to_string(), "NL".to_string(), "DE".to_string(), - "CH".to_string(), "BE".to_string(), - "FR".to_string(), - "FI".to_string(), - "IT".to_string(), - "PL".to_string(), ] }, value: None, @@ -4705,34 +4702,7 @@ impl Default for super::settings::RequiredFields { ) ]), non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.bank_redirect.sofort.preferred_language".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.sofort.preferred_language".to_string(), - display_name: "preferred_language".to_string(), - field_type: enums::FieldType::Text, - value: None, - } - ), - ("payment_method_data.bank_redirect.sofort.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.sofort.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "ES".to_string(), - "AT".to_string(), - "NL".to_string(), - "DE".to_string(), - "BE".to_string(), - "IT".to_string(), - ] - }, - value: None, - } - ), - ]) + common: HashMap::new(), } ), ( diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index 65333539bb0..12490573b2c 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -358,11 +358,11 @@ fn get_payment_source( name: billing_details .clone() .ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "sofort.billing_details", + field_name: "sofort.billing_details.name", })? .get_billing_name()?, country_code: country.ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "country", + field_name: "sofort.billing_details.name.country", })?, experience_context: ContextStruct { return_url: item.request.complete_authorize_url.clone(), diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index f63e2d82f5f..e92ec864c4f 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -290,9 +290,9 @@ pub struct StripeSofort { #[serde(rename = "payment_method_data[type]")] pub payment_method_data_type: StripePaymentMethodType, #[serde(rename = "payment_method_options[sofort][preferred_language]")] - preferred_language: String, + preferred_language: Option, #[serde(rename = "payment_method_data[sofort][country]")] - country: api_enums::CountryAlpha2, + country: Option, } #[derive(Debug, Eq, PartialEq, Serialize)] @@ -1644,17 +1644,8 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData { } => Ok(Self::BankRedirect(StripeBankRedirectData::StripeSofort( Box::new(StripeSofort { payment_method_data_type, - country: country - .ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "country", - })? - .to_owned(), - preferred_language: preferred_language - .clone() - .ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "sofort.preferred_language", - })? - .to_owned(), + country: *country, + preferred_language: preferred_language.clone(), }), ))), payments::BankRedirectData::OnlineBankingFpx { .. } => { From 51fc9a0b6267ccedc34540a56f07badda449c3d3 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 11 Jan 2024 13:47:48 +0530 Subject: [PATCH 11/23] add mandate config and refactor stripe sofort --- config/config.example.toml | 3 +- config/development.toml | 3 +- config/docker_compose.toml | 3 +- .../src/connector/stripe/transformers.rs | 80 ++++++++++--------- loadtest/config/development.toml | 3 +- 5 files changed, 49 insertions(+), 43 deletions(-) diff --git a/config/config.example.toml b/config/config.example.toml index 7e32b2f5d3b..1eda7fea254 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -380,7 +380,8 @@ pay_later.klarna = { connector_list = "adyen" } # Mandate supported payment bank_debit.ach = { connector_list = "gocardless" } # Mandate supported payment method type and connector for bank_debit bank_debit.becs = { connector_list = "gocardless" } # Mandate supported payment method type and connector for bank_debit bank_debit.sepa = { connector_list = "gocardless" } # Mandate supported payment method type and connector for bank_debit -bank_redirect.ideal = {connector_list = "stripe,adyen"} # Mandate supported payment method type and connector for bank_redirect +bank_redirect.ideal = {connector_list = "stripe,adyen,globalpay"} # Mandate supported payment method type and connector for bank_redirect +bank_redirect.sofort = {connector_list = "stripe,adyen,globalpay"} # Required fields info used while listing the payment_method_data diff --git a/config/development.toml b/config/development.toml index ebd4cb1c93e..8c97d33f14f 100644 --- a/config/development.toml +++ b/config/development.toml @@ -470,7 +470,8 @@ card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,global bank_debit.ach = { connector_list = "gocardless"} bank_debit.becs = { connector_list = "gocardless"} bank_debit.sepa = { connector_list = "gocardless"} -bank_redirect.ideal = {connector_list = "stripe,adyen"} +bank_redirect.ideal = {connector_list = "stripe,adyen,globalpay"} +bank_redirect.sofort = {connector_list = "stripe,adyen,globalpay"} [connector_request_reference_id_config] merchant_ids_send_payment_id_as_connector_request_id = [] diff --git a/config/docker_compose.toml b/config/docker_compose.toml index a8cf5bfb051..6f32553dbad 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -337,7 +337,8 @@ card.debit = {connector_list = "stripe,adyen,authorizedotnet,cybersource,globalp bank_debit.ach = { connector_list = "gocardless"} bank_debit.becs = { connector_list = "gocardless"} bank_debit.sepa = { connector_list = "gocardless"} -bank_redirect.ideal = {connector_list = "stripe,adyen"} +bank_redirect.ideal = {connector_list = "stripe,adyen,globalpay"} +bank_redirect.sofort = {connector_list = "stripe,adyen,globalpay"} [connector_customer] connector_list = "gocardless,stax,stripe" diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 50446d4c281..b8d9f4897c2 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1115,36 +1115,9 @@ impl TryFrom<(&payments::BankRedirectData, Option)> for StripeBillingAddre }), payments::BankRedirectData::Ideal { billing_details, .. - } => { - let billing_name = billing_details - .clone() - .and_then(|billing_data| billing_data.billing_name.clone()); - - let billing_email = billing_details - .clone() - .and_then(|billing_data| billing_data.email.clone()); - match is_customer_initiated_mandate_payment { - Some(true) => Ok(Self { - name: Some(billing_name.ok_or( - errors::ConnectorError::MissingRequiredField { - field_name: "billing_name", - }, - )?), - - email: Some(billing_email.ok_or( - errors::ConnectorError::MissingRequiredField { - field_name: "billing_email", - }, - )?), - ..Self::default() - }), - Some(false) | None => Ok(Self { - name: billing_name, - email: billing_email, - ..Self::default() - }), - } - } + } => Ok(get_stripe_sepaDD_mandate_billing_details( + billing_details, + is_customer_initiated_mandate_payment )), payments::BankRedirectData::Przelewy24 { billing_details, .. } => Ok(Self { @@ -1183,15 +1156,10 @@ impl TryFrom<(&payments::BankRedirectData, Option)> for StripeBillingAddre } payments::BankRedirectData::Sofort { billing_details, .. - } => Ok(Self { - name: billing_details - .clone() - .and_then(|billing_data| billing_data.billing_name.clone()), - email: billing_details - .clone() - .and_then(|billing_data| billing_data.email.clone()), - ..Self::default() - }), + } => Ok(get_stripe_sepaDD_mandate_billing_details( + billing_details, + is_customer_initiated_mandate_payment )), + payments::BankRedirectData::Bizum {} | payments::BankRedirectData::Blik { .. } | payments::BankRedirectData::Interac { .. } @@ -3833,3 +3801,37 @@ mod test_validate_shipping_address_against_payment_method { } } } + +fn get_stripe_sepaDD_mandate_billing_details( + billing_details : &Option, + is_customer_initiated_mandate_payment : Option) -> StripeBillingAddress { + let billing_name = billing_details + .clone() + .and_then(|billing_data| billing_data.billing_name.clone()); + + let billing_email = billing_details + .clone() + .and_then(|billing_data| billing_data.email.clone()); + match is_customer_initiated_mandate_payment { + Some(true) => Ok(StripeBillingAddress { + name: Some(billing_name.ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "billing_name", + }, + )?), + + email: Some(billing_email.ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "billing_email", + }, + )?), + ..StripeBillingAddress::default() + }), + Some(false) | None => Ok(StripeBillingAddress { + name: billing_name, + email: billing_email, + ..StripeBillingAddress::default() + }), + } + + } diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 066933317b0..f3d8611175c 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -245,7 +245,8 @@ card.debit = {connector_list = "stripe,adyen,authorizedotnet,cybersource,globalp bank_debit.ach = { connector_list = "gocardless"} bank_debit.becs = { connector_list = "gocardless"} bank_debit.sepa = { connector_list = "gocardless"} -bank_redirect.ideal = {connector_list = "stripe,adyen"} +bank_redirect.ideal = {connector_list = "stripe,adyen,globalpay"} +bank_redirect.sofort = {connector_list = "stripe,adyen,globalpay"} [analytics] source = "sqlx" From 4737bf597a3a74a14500b4b136c4b9c7ef69eff1 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 11 Jan 2024 14:38:10 +0530 Subject: [PATCH 12/23] refactor stripe transformer --- .../src/connector/stripe/transformers.rs | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index b8d9f4897c2..5954fe9afb3 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1115,9 +1115,10 @@ impl TryFrom<(&payments::BankRedirectData, Option)> for StripeBillingAddre }), payments::BankRedirectData::Ideal { billing_details, .. - } => Ok(get_stripe_sepaDD_mandate_billing_details( + } => Ok(get_stripe_sepa_dd_mandate_billing_details( billing_details, - is_customer_initiated_mandate_payment )), + is_customer_initiated_mandate_payment, + )?), payments::BankRedirectData::Przelewy24 { billing_details, .. } => Ok(Self { @@ -1156,9 +1157,10 @@ impl TryFrom<(&payments::BankRedirectData, Option)> for StripeBillingAddre } payments::BankRedirectData::Sofort { billing_details, .. - } => Ok(get_stripe_sepaDD_mandate_billing_details( + } => Ok(get_stripe_sepa_dd_mandate_billing_details( billing_details, - is_customer_initiated_mandate_payment )), + is_customer_initiated_mandate_payment, + )?), payments::BankRedirectData::Bizum {} | payments::BankRedirectData::Blik { .. } @@ -3802,10 +3804,11 @@ mod test_validate_shipping_address_against_payment_method { } } -fn get_stripe_sepaDD_mandate_billing_details( - billing_details : &Option, - is_customer_initiated_mandate_payment : Option) -> StripeBillingAddress { - let billing_name = billing_details +fn get_stripe_sepa_dd_mandate_billing_details( + billing_details: &Option, + is_customer_initiated_mandate_payment: Option, +) -> Result { + let billing_name = billing_details .clone() .and_then(|billing_data| billing_data.billing_name.clone()); @@ -3814,17 +3817,17 @@ fn get_stripe_sepaDD_mandate_billing_details( .and_then(|billing_data| billing_data.email.clone()); match is_customer_initiated_mandate_payment { Some(true) => Ok(StripeBillingAddress { - name: Some(billing_name.ok_or( - errors::ConnectorError::MissingRequiredField { + name: Some( + billing_name.ok_or(errors::ConnectorError::MissingRequiredField { field_name: "billing_name", - }, - )?), + })?, + ), - email: Some(billing_email.ok_or( - errors::ConnectorError::MissingRequiredField { + email: Some( + billing_email.ok_or(errors::ConnectorError::MissingRequiredField { field_name: "billing_email", - }, - )?), + })?, + ), ..StripeBillingAddress::default() }), Some(false) | None => Ok(StripeBillingAddress { @@ -3833,5 +3836,4 @@ fn get_stripe_sepaDD_mandate_billing_details( ..StripeBillingAddress::default() }), } - - } +} From 8749233f78adfa3d5fce7b31909b2d3e2c7c2896 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 11 Jan 2024 20:01:41 +0530 Subject: [PATCH 13/23] remove extra field --- crates/router/src/configs/defaults.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index a9ac6ad9cde..0c5824b3738 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4971,15 +4971,6 @@ impl Default for super::settings::RequiredFields { value: None, } ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), ( "billing.address.line1".to_string(), RequiredFieldInfo { From 28cb2cd2207aaa2e8315e82a4426b3e2722d644c Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 11 Jan 2024 20:22:01 +0530 Subject: [PATCH 14/23] correct field path --- crates/router/src/connector/paypal/transformers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index 1883f8b75bd..5b0e66536af 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -367,7 +367,7 @@ fn get_payment_source( })? .get_billing_name()?, country_code: country.ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "sofort.billing_details.name.country", + field_name: "sofort.billing_details.country", })?, experience_context: ContextStruct { return_url: item.request.complete_authorize_url.clone(), From 17ee23d7187e54d9524f955e88190e4fba5a751b Mon Sep 17 00:00:00 2001 From: AkshayaFoiger <131388445+AkshayaFoiger@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:41:47 +0530 Subject: [PATCH 15/23] Update crates/router/src/connector/paypal/transformers.rs Co-authored-by: Prasunna Soppa <70575890+prasunna09@users.noreply.github.com> --- crates/router/src/connector/paypal/transformers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index 5b0e66536af..bbe7c9a8325 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -363,7 +363,7 @@ fn get_payment_source( name: billing_details .clone() .ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "sofort.billing_details.name", + field_name: "sofort.billing_details", })? .get_billing_name()?, country_code: country.ok_or(errors::ConnectorError::MissingRequiredField { From 1b7c138e21c10cb080c63bf9eb7ba27979e4df34 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 12 Jan 2024 20:07:30 +0530 Subject: [PATCH 16/23] fix clippy error --- crates/router/src/connector/aci/transformers.rs | 2 +- crates/router/src/connector/adyen/transformers.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index d21154d678f..41007aeb270 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -202,7 +202,7 @@ impl api_models::payments::BankRedirectData::Sofort { country, .. } => { Self::BankRedirect(Box::new(BankRedirectionPMData { payment_brand: PaymentBrand::Sofortueberweisung, - bank_account_country: Some(country.clone().ok_or( + bank_account_country: Some(country.to_owned().ok_or( errors::ConnectorError::MissingRequiredField { field_name: "country", }, diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index e190def8f5e..d172bfe7fdb 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -2751,7 +2751,7 @@ fn get_redirect_extra_details( country, preferred_language, .. - } => Ok((preferred_language.clone(), country.clone())), + } => Ok((preferred_language.clone(), *country)), api_models::payments::BankRedirectData::OpenBankingUk { country, .. } => { let country = country.ok_or(errors::ConnectorError::MissingRequiredField { field_name: "country", From 2bc92a4c30d38513184af5993fede3ea7e82c700 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Wed, 17 Jan 2024 11:56:27 +0530 Subject: [PATCH 17/23] fix clippy error --- .../src/connector/stripe/transformers.rs | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 5954fe9afb3..d452c3ee9d5 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -3567,6 +3567,40 @@ pub struct Evidence { pub submit: bool, } +fn get_stripe_sepa_dd_mandate_billing_details( + billing_details: &Option, + is_customer_initiated_mandate_payment: Option, +) -> Result { + let billing_name = billing_details + .clone() + .and_then(|billing_data| billing_data.billing_name.clone()); + + let billing_email = billing_details + .clone() + .and_then(|billing_data| billing_data.email.clone()); + match is_customer_initiated_mandate_payment { + Some(true) => Ok(StripeBillingAddress { + name: Some( + billing_name.ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "billing_name", + })?, + ), + + email: Some( + billing_email.ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "billing_email", + })?, + ), + ..StripeBillingAddress::default() + }), + Some(false) | None => Ok(StripeBillingAddress { + name: billing_name, + email: billing_email, + ..StripeBillingAddress::default() + }), + } +} + impl TryFrom<&types::SubmitEvidenceRouterData> for Evidence { type Error = error_stack::Report; fn try_from(item: &types::SubmitEvidenceRouterData) -> Result { @@ -3804,36 +3838,3 @@ mod test_validate_shipping_address_against_payment_method { } } -fn get_stripe_sepa_dd_mandate_billing_details( - billing_details: &Option, - is_customer_initiated_mandate_payment: Option, -) -> Result { - let billing_name = billing_details - .clone() - .and_then(|billing_data| billing_data.billing_name.clone()); - - let billing_email = billing_details - .clone() - .and_then(|billing_data| billing_data.email.clone()); - match is_customer_initiated_mandate_payment { - Some(true) => Ok(StripeBillingAddress { - name: Some( - billing_name.ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "billing_name", - })?, - ), - - email: Some( - billing_email.ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "billing_email", - })?, - ), - ..StripeBillingAddress::default() - }), - Some(false) | None => Ok(StripeBillingAddress { - name: billing_name, - email: billing_email, - ..StripeBillingAddress::default() - }), - } -} From 17175240d7b005e077a2144c3fb8dc691c4a12ab Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 06:27:15 +0000 Subject: [PATCH 18/23] chore: run formatter --- crates/router/src/connector/stripe/transformers.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index d452c3ee9d5..26a7b7cc4a0 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -3837,4 +3837,3 @@ mod test_validate_shipping_address_against_payment_method { } } } - From 6d65743147ffde9fdc9947714d5233dabab73f59 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 18 Jan 2024 16:28:23 +0530 Subject: [PATCH 19/23] resolve comment: make stripe country req --- crates/router/src/connector/aci/transformers.rs | 2 +- crates/router/src/connector/paypal/transformers.rs | 2 +- crates/router/src/connector/stripe/transformers.rs | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index 41007aeb270..97cef72b02a 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -204,7 +204,7 @@ impl payment_brand: PaymentBrand::Sofortueberweisung, bank_account_country: Some(country.to_owned().ok_or( errors::ConnectorError::MissingRequiredField { - field_name: "country", + field_name: "sofort.country", }, )?), bank_account_bank_name: None, diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index bbe7c9a8325..baf8f48279d 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -367,7 +367,7 @@ fn get_payment_source( })? .get_billing_name()?, country_code: country.ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "sofort.billing_details.country", + field_name: "sofort.country", })?, experience_context: ContextStruct { return_url: item.request.complete_authorize_url.clone(), diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 26a7b7cc4a0..90d5bda84fe 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -292,7 +292,7 @@ pub struct StripeSofort { #[serde(rename = "payment_method_options[sofort][preferred_language]")] preferred_language: Option, #[serde(rename = "payment_method_data[sofort][country]")] - country: Option, + country: api_enums::CountryAlpha2, } #[derive(Debug, Eq, PartialEq, Serialize)] @@ -1648,7 +1648,9 @@ impl TryFrom<&payments::BankRedirectData> for StripePaymentMethodData { } => Ok(Self::BankRedirect(StripeBankRedirectData::StripeSofort( Box::new(StripeSofort { payment_method_data_type, - country: *country, + country: country.ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "sofort.country", + })?, preferred_language: preferred_language.clone(), }), ))), From cb87d754697a156af4f214393405ffcbb7865093 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger <131388445+AkshayaFoiger@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:32:25 +0530 Subject: [PATCH 20/23] Update crates/router/src/configs/defaults.rs Co-authored-by: Prasunna Soppa <70575890+prasunna09@users.noreply.github.com> --- crates/router/src/configs/defaults.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index 0c5824b3738..f2cf8cb997a 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4914,7 +4914,7 @@ impl Default for super::settings::RequiredFields { RequiredFieldInfo { required_field: "payment_method_data.bank_redirect.sofort.billing_details.billing_name".to_string(), display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, + field_type: enums::FieldType::UserBillingName, value: None, } ) From ea7eb3750e10356f424be2d4d95e85f29beabe1f Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 18 Jan 2024 16:46:41 +0530 Subject: [PATCH 21/23] add comment --- crates/router/src/connector/stripe/transformers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 90d5bda84fe..d694be96f4c 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -3569,6 +3569,7 @@ pub struct Evidence { pub submit: bool, } +// Mandates for bank redirects - ideal and sofort happens through sepa direct debit in stripe fn get_stripe_sepa_dd_mandate_billing_details( billing_details: &Option, is_customer_initiated_mandate_payment: Option, From 9c0af541f13711f3f13a20711fa6d4c5e149b318 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 18 Jan 2024 16:46:59 +0530 Subject: [PATCH 22/23] add re field for stripe --- crates/router/src/configs/defaults.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index f2cf8cb997a..3e0617ddf77 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -4953,8 +4953,26 @@ impl Default for super::settings::RequiredFields { } ) ]), - non_mandate: HashMap::new(), - common: HashMap::new(), + non_mandate : HashMap::from([ + ("payment_method_data.bank_redirect.sofort.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.sofort.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "ES".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "BE".to_string(), + ] + }, + value: None, + } + )]), + common: HashMap::new( + + ), } ), ( From 5821804bb82be4cb563734afbbb5172ca9258ffc Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:18:01 +0000 Subject: [PATCH 23/23] chore: run formatter --- crates/router/src/connector/stripe/transformers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index d694be96f4c..bc5c6b15570 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -3569,7 +3569,7 @@ pub struct Evidence { pub submit: bool, } -// Mandates for bank redirects - ideal and sofort happens through sepa direct debit in stripe +// Mandates for bank redirects - ideal and sofort happens through sepa direct debit in stripe fn get_stripe_sepa_dd_mandate_billing_details( billing_details: &Option, is_customer_initiated_mandate_payment: Option,