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
fix(router): [Stripe/Itau/Paypal/Bambora/Cybersource] prevent partial submission of billing address and add required fields for all payment methods (#5752)
AkshayaFoigerad40cedf5cf7
diff --git a/crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs b/crates/hyperswitch_connectors/src/connectors/bambora/transformers.rsindex 8499aecaed..b8c75e3c4d 100644--- a/crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs@@ -1,6 +1,9 @@use base64::Engine;use common_enums::enums;-use common_utils::{ext_traits::ValueExt, pii::IpAddress};+use common_utils::{+ ext_traits::ValueExt,+ pii::{Email, IpAddress},+};use error_stack::ResultExt;use hyperswitch_domain_models::{payment_method_data::PaymentMethodData,@@ -86,6 +89,7 @@ pub struct BamboraPaymentsRequest {customer_ip: Option<Secret<String, IpAddress>>,term_url: Option<String>,card: BamboraCard,+ billing: AddressData,}#[derive(Default, Debug, Serialize)]@@ -173,6 +177,28 @@ impl TryFrom<BamboraRouterData<&types::PaymentsAuthorizeRouterData>> for Bamboracomplete: item.router_data.request.is_auto_capture()?,};+ let (country, province) = match (+ item.router_data.get_optional_billing_country(),+ item.router_data.get_optional_billing_state_2_digit(),+ ) {+ (Some(billing_country), Some(billing_state)) => {+ (Some(billing_country), Some(billing_state))+ }+ _ => (None, None),+ };++ let billing = AddressData {+ name: item.router_data.get_optional_billing_full_name(),+ address_line1: item.router_data.get_optional_billing_line1(),+ address_line2: item.router_data.get_optional_billing_line2(),+ city: item.router_data.get_optional_billing_city(),+ province,+ country,+ postal_code: item.router_data.get_optional_billing_zip(),+ phone_number: item.router_data.get_optional_billing_phone_number(),+ email_address: item.router_data.get_optional_billing_email(),+ };+Ok(Self {order_number: item.router_data.connector_request_reference_id.clone(),amount: item.amount,@@ -180,6 +206,7 @@ impl TryFrom<BamboraRouterData<&types::PaymentsAuthorizeRouterData>> for Bamboracard,customer_ip,term_url: item.router_data.request.complete_authorize_url.clone(),+ billing,})}PaymentMethodData::CardRedirect(_)@@ -342,15 +369,15 @@ pub struct AvsObject {#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]pub struct AddressData {- name: Secret<String>,- address_line1: Secret<String>,- address_line2: Secret<String>,- city: String,- province: String,- country: String,- postal_code: Secret<String>,- phone_number: Secret<String>,- email_address: Secret<String>,+ name: Option<Secret<String>>,+ address_line1: Option<Secret<String>>,+ address_line2: Option<Secret<String>>,+ city: Option<String>,+ province: Option<Secret<String>>,+ country: Option<enums::CountryAlpha2>,+ postal_code: Option<Secret<String>>,+ phone_number: Option<Secret<String>>,+ email_address: Option<Email>,}#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rsindex 808f2c956d..01e9dd14b6 100644--- a/crates/hyperswitch_connectors/src/utils.rs+++ b/crates/hyperswitch_connectors/src/utils.rs@@ -216,6 +216,7 @@ pub trait RouterData {fn get_optional_billing_country(&self) -> Option<enums::CountryAlpha2>;fn get_optional_billing_zip(&self) -> Option<Secret<String>>;fn get_optional_billing_state(&self) -> Option<Secret<String>>;+ fn get_optional_billing_state_2_digit(&self) -> Option<Secret<String>>;fn get_optional_billing_first_name(&self) -> Option<Secret<String>>;fn get_optional_billing_last_name(&self) -> Option<Secret<String>>;fn get_optional_billing_phone_number(&self) -> Option<Secret<String>>;@@ -554,6 +555,16 @@ impl<Flow, Request, Response> RouterData})}+ fn get_optional_billing_state_2_digit(&self) -> Option<Secret<String>> {+ self.get_optional_billing_state().and_then(|state| {+ if state.clone().expose().len() != 2 {+ None+ } else {+ Some(state)+ }+ })+ }+fn get_optional_billing_first_name(&self) -> Option<Secret<String>> {self.address.get_payment_method_billing()diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rsindex 8814e9156b..59016c71fe 100644--- a/crates/router/src/configs/defaults.rs+++ b/crates/router/src/configs/defaults.rs@@ -530,6 +530,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ )]),common: HashMap::new(),@@ -1002,9 +1011,9 @@ impl Default for super::settings::RequiredFields {}),(- "email".to_string(),+ "billing.email".to_string(),RequiredFieldInfo {- required_field: "email".to_string(),+ required_field: "payment_method_data.billing.email".to_string(),display_name: "email".to_string(),field_type: enums::FieldType::UserEmailAddress,value: None,@@ -3393,6 +3402,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ )]),common: HashMap::new(),@@ -3865,9 +3883,9 @@ impl Default for super::settings::RequiredFields {}),(- "email".to_string(),+ "billing.email".to_string(),RequiredFieldInfo {- required_field: "email".to_string(),+ required_field: "payment_method_data.billing.email".to_string(),display_name: "email".to_string(),field_type: enums::FieldType::UserEmailAddress,value: None,@@ -6224,7 +6242,17 @@ impl Default for super::settings::RequiredFields {enums::Connector::Stripe,RequiredFieldFinal {mandate: HashMap::new(),- non_mandate: HashMap::new(),+ non_mandate: HashMap::from([+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ )+ ]),common: HashMap::new(),})]),@@ -6245,9 +6273,7 @@ impl Default for super::settings::RequiredFields {(enums::Connector::Stripe,RequiredFieldFinal {- mandate: HashMap::new(),- non_mandate: HashMap::new(),- common: HashMap::from([+ mandate: HashMap::from([("billing.email".to_string(),RequiredFieldInfo {@@ -6256,7 +6282,10 @@ impl Default for super::settings::RequiredFields {field_type: enums::FieldType::UserEmailAddress,value: None,}- ),+ )+ ]),+ non_mandate: HashMap::new(),+ common: HashMap::from([("billing.address.first_name".to_string(),RequiredFieldInfo {@@ -7076,27 +7105,10 @@ impl Default for super::settings::RequiredFields {field_type: enums::FieldType::UserEmailAddress,value: None,}- ),- (- "billing.address.first_name".to_string(),- RequiredFieldInfo {- required_field: "payment_method_data.billing.address.first_name".to_string(),- display_name: "billing_name".to_string(),- field_type: enums::FieldType::UserBillingName,- value: None,- }- ),- (- "billing.address.last_name".to_string(),- RequiredFieldInfo {- required_field: "payment_method_data.billing.address.last_name".to_string(),- display_name: "billing_name".to_string(),- field_type: enums::FieldType::UserBillingName,- value: None,- })]),- non_mandate : HashMap::from([+ non_mandate : HashMap::new(),+ common: HashMap::from([("billing.address.country".to_string(),RequiredFieldInfo {required_field: "payment_method_data.billing.address.country".to_string(),@@ -7112,10 +7124,25 @@ impl Default for super::settings::RequiredFields {},value: None,}- )]),- common: HashMap::new(-),+ (+ "billing.address.first_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.first_name".to_string(),+ display_name: "account_holder_name".to_string(),+ field_type: enums::FieldType::UserBillingName,+ value: None,+ }+ ),+ (+ "billing.address.last_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.last_name".to_string(),+ display_name: "account_holder_name".to_string(),+ field_type: enums::FieldType::UserBillingName,+ value: None,+ }+ )]),}),(@@ -7687,9 +7714,9 @@ impl Default for super::settings::RequiredFields {non_mandate: HashMap::from([(- "email".to_string(),+ "billing.email".to_string(),RequiredFieldInfo {- required_field: "email".to_string(),+ required_field: "payment_method_data.billing.email".to_string(),display_name: "email".to_string(),field_type: enums::FieldType::UserEmailAddress,value: None,@@ -8171,9 +8198,9 @@ impl Default for super::settings::RequiredFields {non_mandate: HashMap::from([(- "email".to_string(),+ "billing.email".to_string(),RequiredFieldInfo {- required_field: "email".to_string(),+ required_field: "payment_method_data.billing.email".to_string(),display_name: "email".to_string(),field_type: enums::FieldType::UserEmailAddress,value: None,@@ -8501,6 +8528,21 @@ impl Default for super::settings::RequiredFields {]),},),+ (+ enums::PaymentMethodType::Cashapp,+ ConnectorFields {+ fields: HashMap::from([+ (+ enums::Connector::Stripe,+ RequiredFieldFinal {+ mandate: HashMap::new(),+ non_mandate: HashMap::new(),+ common: HashMap::new(),+ }+ )+ ]),+ },+ ),(enums::PaymentMethodType::MbWay,ConnectorFields {@@ -8529,6 +8571,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),]),}@@ -8692,8 +8743,7 @@ impl Default for super::settings::RequiredFields {enums::Connector::Paypal,RequiredFieldFinal {mandate: HashMap::new(),- non_mandate: HashMap::new(- ),+ non_mandate: HashMap::new(),common: HashMap::new(),}),@@ -9084,29 +9134,6 @@ impl Default for super::settings::RequiredFields {fields: HashMap::from([(enums::Connector::Stripe,- RequiredFieldFinal {- mandate : HashMap::new(),- non_mandate: HashMap::from([- ( "name".to_string(),- RequiredFieldInfo {- required_field: "name".to_string(),- display_name: "cust_name".to_string(),- field_type: enums::FieldType::UserFullName,- value: None,- }),- ("payment_method_data.pay_later.afterpay_clearpay_redirect.billing_email".to_string(),- RequiredFieldInfo {- required_field: "payment_method_data.pay_later.afterpay_clearpay_redirect.billing_email".to_string(),- display_name: "billing_email".to_string(),- field_type: enums::FieldType::UserEmailAddress,- value: None,- })- ]),- common : HashMap::new(),- }- ),- (- enums::Connector::Adyen,RequiredFieldFinal {mandate : HashMap::new(),non_mandate: HashMap::from([@@ -9146,15 +9173,6 @@ impl Default for super::settings::RequiredFields {value: None,}),- (- "billing.address.line2".to_string(),- RequiredFieldInfo {- required_field: "payment_method_data.billing.address.line2".to_string(),- display_name: "line2".to_string(),- field_type: enums::FieldType::UserAddressLine2,- value: None,- }- ),("billing.address.city".to_string(),RequiredFieldInfo {@@ -9199,6 +9217,24 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "shipping.address.first_name".to_string(),+ RequiredFieldInfo {+ required_field: "shipping.address.first_name".to_string(),+ display_name: "shipping_first_name".to_string(),+ field_type: enums::FieldType::UserShippingName,+ value: None,+ }+ ),+ (+ "shipping.address.last_name".to_string(),+ RequiredFieldInfo {+ required_field: "shipping.address.last_name".to_string(),+ display_name: "shipping_last_name".to_string(),+ field_type: enums::FieldType::UserShippingName,+ value: None,+ }+ ),("shipping.address.city".to_string(),RequiredFieldInfo {@@ -9208,6 +9244,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "shipping.address.state".to_string(),+ RequiredFieldInfo {+ required_field: "shipping.address.state".to_string(),+ display_name: "state".to_string(),+ field_type: enums::FieldType::UserShippingAddressState,+ value: None,+ }+ ),("shipping.address.zip".to_string(),RequiredFieldInfo {@@ -9224,11 +9269,7 @@ impl Default for super::settings::RequiredFields {display_name: "country".to_string(),field_type: enums::FieldType::UserShippingAddressCountry{options: vec![- "GB".to_string(),- "AU".to_string(),- "CA".to_string(),- "US".to_string(),- "NZ".to_string(),+ "ALL".to_string(),]},value: None,@@ -9243,49 +9284,6 @@ impl Default for super::settings::RequiredFields {value: None,}),- (- "shipping.address.line2".to_string(),- RequiredFieldInfo {- required_field: "shipping.address.line2".to_string(),- display_name: "line2".to_string(),- field_type: enums::FieldType::UserShippingAddressLine2,- value: None,- }- ),- ]),- common : HashMap::new(),- }- )- ]),- },- ),- (- enums::PaymentMethodType::Klarna,- ConnectorFields {- fields: HashMap::from([- (- enums::Connector::Stripe,- RequiredFieldFinal {- mandate : HashMap::new(),- non_mandate: HashMap::from([- ( "payment_method_data.pay_later.klarna.billing_country".to_string(),- RequiredFieldInfo {- required_field: "payment_method_data.pay_later.klarna.billing_country".to_string(),- display_name: "billing_country".to_string(),- field_type: enums::FieldType::UserAddressCountry{- options: vec![- "ALL".to_string(),- ]- },- value: None,- }),- ("email".to_string(),- RequiredFieldInfo {- required_field: "email".to_string(),- display_name: "email".to_string(),- field_type: enums::FieldType::UserEmailAddress,- value: None,- })]),common : HashMap::new(),}@@ -9294,19 +9292,7 @@ impl Default for super::settings::RequiredFields {enums::Connector::Adyen,RequiredFieldFinal {mandate : HashMap::new(),- non_mandate: HashMap::new(),- common : HashMap::from([- ( "payment_method_data.pay_later.klarna.billing_country".to_string(),- RequiredFieldInfo {- required_field: "payment_method_data.pay_later.klarna.billing_country".to_string(),- display_name: "billing_country".to_string(),- field_type: enums::FieldType::UserAddressCountry{- options: vec![- "ALL".to_string(),- ]- },- value: None,- }),+ non_mandate: HashMap::from([("billing.email".to_string(),RequiredFieldInfo {@@ -9316,40 +9302,259 @@ impl Default for super::settings::RequiredFields {value: None,}),- ]),- }- ),- (- enums::Connector::Klarna,- RequiredFieldFinal {- mandate: HashMap::new(),- non_mandate: HashMap::new(),- common: HashMap::from([(- "billing.address.country".to_string(),+ "billing.address.first_name".to_string(),RequiredFieldInfo {- required_field: "payment_method_data.billing.address.country".to_string(),- display_name: "country".to_string(),- field_type: enums::FieldType::UserAddressCountry{- options: vec![- "AU".to_string(),- "AT".to_string(),- "BE".to_string(),- "CA".to_string(),- "CZ".to_string(),- "DK".to_string(),- "FI".to_string(),- "FR".to_string(),- "DE".to_string(),- "GR".to_string(),- "IE".to_string(),- "IT".to_string(),- "NL".to_string(),- "NZ".to_string(),- "NO".to_string(),- "PL".to_string(),- "PT".to_string(),- "ES".to_string(),+ required_field: "payment_method_data.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: "payment_method_data.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: "payment_method_data.billing.address.line1".to_string(),+ display_name: "line1".to_string(),+ field_type: enums::FieldType::UserAddressLine1,+ value: None,+ }+ ),+ (+ "billing.address.line2".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.line2".to_string(),+ display_name: "line2".to_string(),+ field_type: enums::FieldType::UserAddressLine2,+ value: None,+ }+ ),+ (+ "billing.address.city".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.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: "payment_method_data.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: "payment_method_data.billing.address.country".to_string(),+ display_name: "country".to_string(),+ field_type: enums::FieldType::UserAddressCountry{+ options: vec![+ "GB".to_string(),+ "AU".to_string(),+ "CA".to_string(),+ "US".to_string(),+ "NZ".to_string(),+ ]+ },+ value: None,+ }+ ),+ (+ "billing.address.state".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.state".to_string(),+ display_name: "state".to_string(),+ field_type: enums::FieldType::UserAddressState,+ value: None,+ }+ ),+ (+ "shipping.address.city".to_string(),+ RequiredFieldInfo {+ required_field: "shipping.address.city".to_string(),+ display_name: "city".to_string(),+ field_type: enums::FieldType::UserShippingAddressCity,+ value: None,+ }+ ),+ (+ "shipping.address.zip".to_string(),+ RequiredFieldInfo {+ required_field: "shipping.address.zip".to_string(),+ display_name: "zip".to_string(),+ field_type: enums::FieldType::UserShippingAddressPincode,+ value: None,+ }+ ),+ (+ "shipping.address.country".to_string(),+ RequiredFieldInfo {+ required_field: "shipping.address.country".to_string(),+ display_name: "country".to_string(),+ field_type: enums::FieldType::UserShippingAddressCountry{+ options: vec![+ "GB".to_string(),+ "AU".to_string(),+ "CA".to_string(),+ "US".to_string(),+ "NZ".to_string(),+ ]+ },+ value: None,+ }+ ),+ (+ "shipping.address.line1".to_string(),+ RequiredFieldInfo {+ required_field: "shipping.address.line1".to_string(),+ display_name: "line1".to_string(),+ field_type: enums::FieldType::UserShippingAddressLine1,+ value: None,+ }+ ),+ (+ "shipping.address.line2".to_string(),+ RequiredFieldInfo {+ required_field: "shipping.address.line2".to_string(),+ display_name: "line2".to_string(),+ field_type: enums::FieldType::UserShippingAddressLine2,+ value: None,+ }+ ),+ ]),+ common : HashMap::new(),+ }+ )+ ]),+ },+ ),+ (+ enums::PaymentMethodType::Klarna,+ ConnectorFields {+ fields: HashMap::from([+ (+ enums::Connector::Stripe,+ RequiredFieldFinal {+ mandate : HashMap::new(),+ non_mandate: HashMap::from([+ ( "payment_method_data.pay_later.klarna.billing_country".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.pay_later.klarna.billing_country".to_string(),+ display_name: "billing_country".to_string(),+ field_type: enums::FieldType::UserAddressCountry{+ options: vec![+ "AU".to_string(),+ "AT".to_string(),+ "BE".to_string(),+ "CA".to_string(),+ "CZ".to_string(),+ "DK".to_string(),+ "FI".to_string(),+ "FR".to_string(),+ "GR".to_string(),+ "DE".to_string(),+ "IE".to_string(),+ "IT".to_string(),+ "NL".to_string(),+ "NZ".to_string(),+ "NO".to_string(),+ "PL".to_string(),+ "PT".to_string(),+ "RO".to_string(),+ "ES".to_string(),+ "SE".to_string(),+ "CH".to_string(),+ "GB".to_string(),+ "US".to_string(),+ ]+ },+ value: None,+ }),+ ("email".to_string(),+ RequiredFieldInfo {+ required_field: "email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ })+ ]),+ common : HashMap::new(),+ }+ ),+ (+ enums::Connector::Adyen,+ RequiredFieldFinal {+ mandate : HashMap::new(),+ non_mandate: HashMap::new(),+ common : HashMap::from([+ ( "payment_method_data.pay_later.klarna.billing_country".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.pay_later.klarna.billing_country".to_string(),+ display_name: "billing_country".to_string(),+ field_type: enums::FieldType::UserAddressCountry{+ options: vec![+ "ALL".to_string(),+ ]+ },+ value: None,+ }),+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ ),+ ]),+ }+ ),+ (+ enums::Connector::Klarna,+ RequiredFieldFinal {+ mandate: HashMap::new(),+ non_mandate: HashMap::new(),+ common: HashMap::from([+ (+ "billing.address.country".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.country".to_string(),+ display_name: "country".to_string(),+ field_type: enums::FieldType::UserAddressCountry{+ options: vec![+ "AU".to_string(),+ "AT".to_string(),+ "BE".to_string(),+ "CA".to_string(),+ "CZ".to_string(),+ "DK".to_string(),+ "FI".to_string(),+ "FR".to_string(),+ "DE".to_string(),+ "GR".to_string(),+ "IE".to_string(),+ "IT".to_string(),+ "NL".to_string(),+ "NZ".to_string(),+ "NO".to_string(),+ "PL".to_string(),+ "PT".to_string(),+ "ES".to_string(),"SE".to_string(),"CH".to_string(),"GB".to_string(),@@ -9450,6 +9655,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),("billing.email".to_string(),RequiredFieldInfo {@@ -9562,6 +9776,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),("billing.email".to_string(),RequiredFieldInfo {@@ -9665,6 +9888,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),("billing.email".to_string(),RequiredFieldInfo {@@ -9759,6 +9991,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),("billing.email".to_string(),RequiredFieldInfo {@@ -9872,6 +10113,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),("billing.email".to_string(),RequiredFieldInfo {@@ -10224,6 +10474,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ )]),common : HashMap::new(),@@ -10277,6 +10536,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),]),common : HashMap::new(),@@ -10330,6 +10598,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),]),common : HashMap::new(),@@ -10383,6 +10660,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),]),common : HashMap::new(),@@ -10436,6 +10722,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),]),common : HashMap::new(),@@ -10489,6 +10784,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),]),common : HashMap::new(),@@ -10540,7 +10844,7 @@ impl Default for super::settings::RequiredFields {RequiredFieldFinal {mandate: HashMap::new(),non_mandate: HashMap::new(),- common: HashMap::from([ (+ common: HashMap::from([("billing.address.first_name".to_string(),RequiredFieldInfo {required_field: "payment_method_data.billing.address.first_name".to_string(),@@ -10548,7 +10852,35 @@ impl Default for super::settings::RequiredFields {field_type: enums::FieldType::UserBillingName,value: None,}- )]),+ ),+ (+ "billing.address.last_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.last_name".to_string(),+ display_name: "owner_name".to_string(),+ field_type: enums::FieldType::UserBillingName,+ value: None,+ }+ ),+ (+ "payment_method_data.bank_debit.ach.account_number".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.ach.account_number".to_string(),+ display_name: "bank_account_number".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ ),+ (+ "payment_method_data.bank_debit.ach.routing_number".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.ach.routing_number".to_string(),+ display_name: "bank_routing_number".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ )+ ]),}),(enums::Connector::Adyen,@@ -10612,7 +10944,35 @@ impl Default for super::settings::RequiredFields {field_type: enums::FieldType::UserBillingName,value: None,}- )]),+ ),+ (+ "billing.address.last_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.last_name".to_string(),+ display_name: "owner_name".to_string(),+ field_type: enums::FieldType::UserBillingName,+ value: None,+ }+ ),+ (+ "payment_method_data.bank_debit.sepa.iban".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.bacs.iban".to_string(),+ display_name: "bank_account_number".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ ),+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ )+ ]),}),(@@ -10668,7 +11028,55 @@ impl Default for super::settings::RequiredFields {field_type: enums::FieldType::UserBillingName,value: None,}- )]),+ ),+ (+ "payment_method_data.bank_debit.bacs.account_number".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.bacs.account_number".to_string(),+ display_name: "bank_account_number".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ ),+ (+ "payment_method_data.bank_debit.bacs.sort_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.bacs.sort_code".to_string(),+ display_name: "bank_sort_code".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ ),+ (+ "billing.address.country".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.country".to_string(),+ display_name: "country".to_string(),+ field_type: enums::FieldType::UserAddressCountry {+ options: vec!["UK".to_string()],+ },+ value: None,+ },+ ),+ (+ "billing.address.zip".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.zip".to_string(),+ display_name: "zip".to_string(),+ field_type: enums::FieldType::UserAddressPincode,+ value: None,+ },+ ),+ (+ "billing.address.line1".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.line1".to_string(),+ display_name: "line1".to_string(),+ field_type: enums::FieldType::UserAddressLine1,+ value: None,+ },+ )+ ]),}),(@@ -10715,7 +11123,110 @@ impl Default for super::settings::RequiredFields {})]),},- )]))),+ ),+ (+ enums::PaymentMethodType::Becs,+ ConnectorFields {+ fields: HashMap::from([+ (+ enums::Connector::Stripe,+ RequiredFieldFinal {+ mandate: HashMap::new(),+ non_mandate: HashMap::new(),+ common: HashMap::from([ (+ "billing.address.first_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.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: "payment_method_data.billing.address.last_name".to_string(),+ display_name: "owner_name".to_string(),+ field_type: enums::FieldType::UserBillingName,+ value: None,+ }+ ),+ (+ "payment_method_data.bank_debit.becs.account_number".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.becs.account_number".to_string(),+ display_name: "bank_account_number".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ ),+ (+ "payment_method_data.bank_debit.becs.bsb_number".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.becs.bsb_number".to_string(),+ display_name: "bsb_number".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ ),+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ )+ ]),+ }+ ),+ (+ enums::Connector::Adyen,+ RequiredFieldFinal {+ mandate: HashMap::new(),+ non_mandate: HashMap::new(),+ common: HashMap::from([ (+ "billing.address.first_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.first_name".to_string(),+ display_name: "owner_name".to_string(),+ field_type: enums::FieldType::UserBillingName,+ value: None,+ }),+ (+ "billing.address.last_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.last_name".to_string(),+ display_name: "owner_name".to_string(),+ field_type: enums::FieldType::UserBillingName,+ value: None,+ }+ ),+ (+ "payment_method_data.bank_debit.bacs.account_number".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.bacs.account_number".to_string(),+ display_name: "bank_account_number".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ ),+ (+ "payment_method_data.bank_debit.bacs.sort_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.bank_debit.bacs.sort_code".to_string(),+ display_name: "bank_sort_code".to_string(),+ field_type: enums::FieldType::Text,+ value: None,+ }+ )+ ]),+ })+ ]),+ },+ ),+ ]))),(enums::PaymentMethod::BankTransfer,PaymentMethodType(HashMap::from([(@@ -10726,7 +11237,17 @@ impl Default for super::settings::RequiredFields {enums::Connector::Stripe,RequiredFieldFinal {mandate: HashMap::new(),- non_mandate: HashMap::new(),+ non_mandate: HashMap::from([+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ )+ ]),common: HashMap::new(),}),@@ -10750,7 +11271,17 @@ impl Default for super::settings::RequiredFields {},value: None,}- )]),+ ),+ (+ "billing.address.city".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.city".to_string(),+ display_name: "city".to_string(),+ field_type: enums::FieldType::UserAddressCity,+ value: None,+ },+ ),+ ]),common: HashMap::new(),}),@@ -10763,7 +11294,17 @@ impl Default for super::settings::RequiredFields {RequiredFieldFinal {mandate: HashMap::new(),non_mandate: HashMap::new(),- common: HashMap::new(),+ common: HashMap::from([+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ )+ ])}),])}),@@ -10804,6 +11345,24 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.address.first_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.first_name".to_string(),+ display_name: "card_holder_name".to_string(),+ field_type: enums::FieldType::UserFullName,+ value: None,+ }+ ),+ (+ "billing.address.last_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.last_name".to_string(),+ display_name: "card_holder_name".to_string(),+ field_type: enums::FieldType::UserFullName,+ value: None,+ }+ ),]),}@@ -11118,6 +11677,140 @@ impl Default for super::settings::RequiredFields {]),},),+ (+ enums::PaymentMethodType::Sepa,+ ConnectorFields {+ fields: HashMap::from([+ (+ enums::Connector::Stripe,+ RequiredFieldFinal {+ mandate : HashMap::new(),+ non_mandate : HashMap::new(),+ common : HashMap::from([+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ ),+ (+ "billing.address.first_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.first_name".to_string(),+ display_name: "card_holder_name".to_string(),+ field_type: enums::FieldType::UserFullName,+ value: None,+ }+ ),+ (+ "billing.address.last_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.last_name".to_string(),+ display_name: "card_holder_name".to_string(),+ field_type: enums::FieldType::UserFullName,+ value: None,+ }+ ),+ (+ "billing.address.country".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.country".to_string(),+ display_name: "country".to_string(),+ field_type: enums::FieldType::UserAddressCountry {+ options: vec![+ "AT".to_string(),+ "BE".to_string(),+ "BG".to_string(),+ "HR".to_string(),+ "CY".to_string(),+ "CZ".to_string(),+ "DK".to_string(),+ "EE".to_string(),+ "FI".to_string(),+ "FR".to_string(),+ "DE".to_string(),+ "GR".to_string(),+ "HU".to_string(),+ "IE".to_string(),+ "IT".to_string(),+ "LV".to_string(),+ "LT".to_string(),+ "LU".to_string(),+ "MT".to_string(),+ "NL".to_string(),+ "PL".to_string(),+ "PT".to_string(),+ "RO".to_string(),+ "SI".to_string(),+ "SK".to_string(),+ "ES".to_string(),+ "SE".to_string(),+ "AD".to_string(),+ "IS".to_string(),+ "LI".to_string(),+ "MC".to_string(),+ "NO".to_string(),+ "SM".to_string(),+ "CH".to_string(),+ "GB".to_string(),+ "VA".to_string(),+ ],+ },+ value: None,+ },+ ),+ ]),+ }+ )+ ]),+ },+ ),+ (+ enums::PaymentMethodType::Bacs,+ ConnectorFields {+ fields: HashMap::from([+ (+ enums::Connector::Stripe,+ RequiredFieldFinal {+ mandate : HashMap::new(),+ non_mandate : HashMap::new(),+ common : HashMap::from([+ (+ "billing.email".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.email".to_string(),+ display_name: "email".to_string(),+ field_type: enums::FieldType::UserEmailAddress,+ value: None,+ }+ ),+ (+ "billing.address.first_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.first_name".to_string(),+ display_name: "card_holder_name".to_string(),+ field_type: enums::FieldType::UserFullName,+ value: None,+ }+ ),+ (+ "billing.address.last_name".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.address.last_name".to_string(),+ display_name: "card_holder_name".to_string(),+ field_type: enums::FieldType::UserFullName,+ value: None,+ }+ )+ ]),+ }+ )+ ]),+ },+ ),]))),(enums::PaymentMethod::GiftCard,@@ -11165,7 +11858,7 @@ impl Default for super::settings::RequiredFields {value: None,}),- ]),+ ]),common: HashMap::new(),}),@@ -11213,6 +11906,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),("billing.email".to_string(),RequiredFieldInfo {@@ -11266,6 +11968,15 @@ impl Default for super::settings::RequiredFields {value: None,}),+ (+ "billing.phone.country_code".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.billing.phone.country_code".to_string(),+ display_name: "dialing_code".to_string(),+ field_type: enums::FieldType::UserPhoneNumberCountryCode,+ value: None,+ }+ ),("billing.email".to_string(),RequiredFieldInfo {diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rsindex d1f15082ee..6af3c60065 100644--- a/crates/router/src/connector/cybersource/transformers.rs+++ b/crates/router/src/connector/cybersource/transformers.rs@@ -83,7 +83,7 @@ pub struct CybersourceZeroMandateRequest {impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest {type Error = error_stack::Report<errors::ConnectorError>;fn try_from(item: &types::SetupMandateRouterData) -> Result<Self, Self::Error> {- let email = item.request.get_email()?;+ let email = item.get_billing_email().or(item.request.get_email())?;let bill_to = build_bill_to(item.get_optional_billing(), email)?;let order_information = OrderInformationWithBill {@@ -1033,7 +1033,10 @@ impldomain::Card,),) -> Result<Self, Self::Error> {- let email = item.router_data.request.get_email()?;+ let email = item+ .router_data+ .get_billing_email()+ .or(item.router_data.request.get_email())?;let bill_to = build_bill_to(item.router_data.get_optional_billing(), email)?;let order_information = OrderInformationWithBill::from((item, Some(bill_to)));@@ -1124,7 +1127,10 @@ impldomain::Card,),) -> Result<Self, Self::Error> {- let email = item.router_data.request.get_email()?;+ let email = item+ .router_data+ .get_billing_email()+ .or(item.router_data.request.get_email())?;let bill_to = build_bill_to(item.router_data.get_optional_billing(), email)?;let order_information = OrderInformationWithBill::from((item, bill_to));@@ -1207,7 +1213,10 @@ impldomain::ApplePayWalletData,),) -> Result<Self, Self::Error> {- let email = item.router_data.request.get_email()?;+ let email = item+ .router_data+ .get_billing_email()+ .or(item.router_data.request.get_email())?;let bill_to = build_bill_to(item.router_data.get_optional_billing(), email)?;let order_information = OrderInformationWithBill::from((item, Some(bill_to)));let processing_information = ProcessingInformation::try_from((@@ -1276,7 +1285,10 @@ impldomain::GooglePayWalletData,),) -> Result<Self, Self::Error> {- let email = item.router_data.request.get_email()?;+ let email = item+ .router_data+ .get_billing_email()+ .or(item.router_data.request.get_email())?;let bill_to = build_bill_to(item.router_data.get_optional_billing(), email)?;let order_information = OrderInformationWithBill::from((item, Some(bill_to)));@@ -1338,7 +1350,10 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>>}},None => {- let email = item.router_data.request.get_email()?;+ let email = item+ .router_data+ .get_billing_email()+ .or(item.router_data.request.get_email())?;let bill_to = build_bill_to(item.router_data.get_optional_billing(),email,@@ -1490,10 +1505,11 @@ impllet payment_instrument = CybersoucrePaymentInstrument {id: connector_mandate_id.into(),};- let bill_to =- item.router_data.request.get_email().ok().and_then(|email| {- build_bill_to(item.router_data.get_optional_billing(), email).ok()- });+ let bill_to = item+ .router_data+ .get_optional_billing_email()+ .or(item.router_data.request.get_optional_email())+ .and_then(|email| build_bill_to(item.router_data.get_optional_billing(), email).ok());let order_information = OrderInformationWithBill::from((item, bill_to));let payment_information =PaymentInformation::MandatePayment(Box::new(MandatePaymentInformation {@@ -2321,7 +2337,10 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsPreProcessingRouterData>>})?.1.to_string();- let email = item.router_data.request.get_email()?;+ let email = item+ .router_data+ .get_billing_email()+ .or(item.router_data.request.get_email())?;let bill_to = build_bill_to(item.router_data.get_optional_billing(), email)?;let order_information = OrderInformationWithBill {amount_details,diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rsindex 24b2f2b88e..fd2b262c7e 100644--- a/crates/router/src/connector/paypal/transformers.rs+++ b/crates/router/src/connector/paypal/transformers.rs@@ -150,14 +150,10 @@ pub struct ShippingAddress {name: Option<ShippingName>,}-impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for ShippingAddress {- type Error = error_stack::Report<errors::ConnectorError>;-- fn try_from(- item: &PaypalRouterData<&types::PaymentsAuthorizeRouterData>,- ) -> Result<Self, Self::Error> {- Ok(Self {- address: get_address_info(item.router_data.get_optional_shipping())?,+impl From<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for ShippingAddress {+ fn from(item: &PaypalRouterData<&types::PaymentsAuthorizeRouterData>) -> Self {+ Self {+ address: get_address_info(item.router_data.get_optional_shipping()),name: Some(ShippingName {full_name: item.router_data@@ -165,7 +161,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for Shippin.and_then(|inner_data| inner_data.address.as_ref()).and_then(|inner_data| inner_data.first_name.clone()),}),- })+ }}}@@ -252,20 +248,17 @@ pub struct PaypalPaymentsRequest {payment_source: Option<PaymentSourceItem>,}-fn get_address_info(- payment_address: Option<&api_models::payments::Address>,-) -> Result<Option<Address>, error_stack::Report<errors::ConnectorError>> {+fn get_address_info(payment_address: Option<&api_models::payments::Address>) -> Option<Address> {let address = payment_address.and_then(|payment_address| payment_address.address.as_ref());- let address = match address {- Some(address) => Some(Address {- country_code: address.get_country()?.to_owned(),+ match address {+ Some(address) => address.get_optional_country().map(|country| Address {+ country_code: country.to_owned(),address_line_1: address.line1.clone(),postal_code: address.zip.clone(),admin_area_2: address.city.clone(),}),None => None,- };- Ok(address)+ }}fn get_payment_source(item: &types::PaymentsAuthorizeRouterData,@@ -279,7 +272,7 @@ fn get_payment_source(experience_context: ContextStruct {return_url: item.request.complete_authorize_url.clone(),cancel_url: item.request.complete_authorize_url.clone(),- shipping_preference: if item.get_optional_shipping().is_some() {+ shipping_preference: if item.get_optional_shipping_country().is_some() {ShippingPreference::SetProvidedAddress} else {ShippingPreference::GetFromFile@@ -295,7 +288,7 @@ fn get_payment_source(experience_context: ContextStruct {return_url: item.request.complete_authorize_url.clone(),cancel_url: item.request.complete_authorize_url.clone(),- shipping_preference: if item.get_optional_shipping().is_some() {+ shipping_preference: if item.get_optional_shipping_country().is_some() {ShippingPreference::SetProvidedAddress} else {ShippingPreference::GetFromFile@@ -311,7 +304,7 @@ fn get_payment_source(experience_context: ContextStruct {return_url: item.request.complete_authorize_url.clone(),cancel_url: item.request.complete_authorize_url.clone(),- shipping_preference: if item.get_optional_shipping().is_some() {+ shipping_preference: if item.get_optional_shipping_country().is_some() {ShippingPreference::SetProvidedAddress} else {ShippingPreference::GetFromFile@@ -328,7 +321,7 @@ fn get_payment_source(experience_context: ContextStruct {return_url: item.request.complete_authorize_url.clone(),cancel_url: item.request.complete_authorize_url.clone(),- shipping_preference: if item.get_optional_shipping().is_some() {+ shipping_preference: if item.get_optional_shipping_country().is_some() {ShippingPreference::SetProvidedAddress} else {ShippingPreference::GetFromFile@@ -392,7 +385,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalPlet connector_request_reference_id =item.router_data.connector_request_reference_id.clone();- let shipping_address = ShippingAddress::try_from(item)?;+ let shipping_address = ShippingAddress::from(item);let item_details = vec![ItemDetails::from(item)];let purchase_units = vec![PurchaseUnitRequest {@@ -420,7 +413,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalP};let payment_source = Some(PaymentSourceItem::Card(CardRequest {- billing_address: get_address_info(item.router_data.get_optional_billing())?,+ billing_address: get_address_info(item.router_data.get_optional_billing()),expiry,name: item.router_data@@ -446,7 +439,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalPcancel_url: item.router_data.request.complete_authorize_url.clone(),shipping_preference: if item.router_data- .get_optional_shipping()+ .get_optional_shipping_country().is_some(){ShippingPreference::SetProvidedAddressdiff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rsindex 82ed9577a8..2af38249e9 100644--- a/crates/router/src/connector/stripe.rs+++ b/crates/router/src/connector/stripe.rs@@ -157,6 +157,8 @@ impl ConnectorValidation for Stripe {PaymentMethodDataType::ApplePay,PaymentMethodDataType::GooglePay,PaymentMethodDataType::AchBankDebit,+ PaymentMethodDataType::BacsBankDebit,+ PaymentMethodDataType::BecsBankDebit,PaymentMethodDataType::SepaBankDebit,PaymentMethodDataType::Sofort,PaymentMethodDataType::Ideal,diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rsindex 6b26818c29..1672199407 100644--- a/crates/router/src/connector/stripe/transformers.rs+++ b/crates/router/src/connector/stripe/transformers.rs@@ -1093,7 +1093,7 @@ fn get_bank_debit_data((StripePaymentMethodType::Ach, ach_data)}domain::BankDebitData::SepaBankDebit { iban, .. } => {- let sepa_data = BankDebitData::Sepa {+ let sepa_data: BankDebitData = BankDebitData::Sepa {iban: iban.to_owned(),};(StripePaymentMethodType::Sepa, sepa_data)@@ -1594,35 +1594,36 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentlet shipping_address = match item.get_optional_shipping() {Some(shipping_details) => {let shipping_address = shipping_details.address.as_ref();- Some(StripeShippingAddress {- city: shipping_address.and_then(|a| a.city.clone()),- country: shipping_address.and_then(|a| a.country),- line1: shipping_address.and_then(|a| a.line1.clone()),- line2: shipping_address.and_then(|a| a.line2.clone()),- zip: shipping_address.and_then(|a| a.zip.clone()),- state: shipping_address.and_then(|a| a.state.clone()),- name: shipping_address- .and_then(|a| {- a.first_name.as_ref().map(|first_name| {+ shipping_address.and_then(|shipping_detail| {+ shipping_detail+ .first_name+ .as_ref()+ .map(|first_name| StripeShippingAddress {+ city: shipping_address.and_then(|a| a.city.clone()),+ country: shipping_address.and_then(|a| a.country),+ line1: shipping_address.and_then(|a| a.line1.clone()),+ line2: shipping_address.and_then(|a| a.line2.clone()),+ zip: shipping_address.and_then(|a| a.zip.clone()),+ state: shipping_address.and_then(|a| a.state.clone()),+ name: format!(+ "{} {}",+ first_name.clone().expose(),+ shipping_detail+ .last_name+ .clone()+ .expose_option()+ .unwrap_or_default()+ )+ .into(),+ phone: shipping_details.phone.as_ref().map(|p| {format!(- "{} {}",- first_name.clone().expose(),- a.last_name.clone().expose_option().unwrap_or_default()+ "{}{}",+ p.country_code.clone().unwrap_or_default(),+ p.number.clone().expose_option().unwrap_or_default()).into()- })+ }),})- .ok_or(errors::ConnectorError::MissingRequiredField {- field_name: "shipping_address.first_name",- })?,- phone: shipping_details.phone.as_ref().map(|p| {- format!(- "{}{}",- p.country_code.clone().unwrap_or_default(),- p.number.clone().expose_option().unwrap_or_default()- )- .into()- }),})}None => None,@@ -1785,67 +1786,61 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntent_ => payment_data,};- let setup_mandate_details = item+ let customer_acceptance = item.request.setup_mandate_details.as_ref()- .and_then(|mandate_details| {- mandate_details- .customer_acceptance- .as_ref()- .map(|customer_acceptance| {- Ok::<_, error_stack::Report<errors::ConnectorError>>(- match customer_acceptance.acceptance_type {- AcceptanceType::Online => {- let online_mandate = customer_acceptance- .online- .clone()- .get_required_value("online")+ .and_then(|mandate_details| mandate_details.customer_acceptance.clone())+ .or(item.request.customer_acceptance.clone());++ let setup_mandate_details = customer_acceptance+ .as_ref()+ .map(|customer_acceptance| {+ Ok::<_, error_stack::Report<errors::ConnectorError>>(+ match customer_acceptance.acceptance_type {+ AcceptanceType::Online => {+ let online_mandate = customer_acceptance+ .online+ .clone()+ .get_required_value("online")+ .change_context(errors::ConnectorError::MissingRequiredField {+ field_name: "online",+ })?;+ StripeMandateRequest {+ mandate_type: StripeMandateType::Online {+ ip_address: online_mandate+ .ip_address+ .get_required_value("ip_address").change_context(errors::ConnectorError::MissingRequiredField {- field_name: "online",+ field_name: "ip_address",},- )?;- StripeMandateRequest {- mandate_type: StripeMandateType::Online {- ip_address: online_mandate- .ip_address- .get_required_value("ip_address")- .change_context(- errors::ConnectorError::MissingRequiredField {- field_name: "ip_address",- },- )?,- user_agent: online_mandate.user_agent,- },- }- }- AcceptanceType::Offline => StripeMandateRequest {- mandate_type: StripeMandateType::Offline,+ )?,+ user_agent: online_mandate.user_agent,},- },- )- })+ }+ }+ AcceptanceType::Offline => StripeMandateRequest {+ mandate_type: StripeMandateType::Offline,+ },+ },+ )}).transpose()?- .or_else(|| {+ .or({//stripe requires us to send mandate_data while making recurring payment through saved bank debit- if payment_method.is_some() {- //check if payment is done through saved payment method- match &payment_method_types {- //check if payment method is bank debit- Some(- StripePaymentMethodType::Ach- | StripePaymentMethodType::Sepa- | StripePaymentMethodType::Becs- | StripePaymentMethodType::Bacs,- ) => Some(StripeMandateRequest {- mandate_type: StripeMandateType::Offline,- }),- _ => None,- }- } else {- None+ //check if payment is done through saved payment method+ match &payment_method_types {+ //check if payment method is bank debit+ Some(+ StripePaymentMethodType::Ach+ | StripePaymentMethodType::Sepa+ | StripePaymentMethodType::Becs+ | StripePaymentMethodType::Bacs,+ ) => Some(StripeMandateRequest {+ mandate_type: StripeMandateType::Offline,+ }),+ _ => None,}});@@ -3252,7 +3247,7 @@ impltransfer_type: StripeCreditTransferTypes::Multibanco,currency,payment_method_data: MultibancoTransferData {- email: item.request.get_email()?,+ email: item.get_billing_email().or(item.request.get_email())?,},amount: Some(amount),return_url: Some(item.get_return_url()?),@@ -3262,7 +3257,7 @@ implOk(Self::AchBankTansfer(AchCreditTransferSourceRequest {transfer_type: StripeCreditTransferTypes::AchCreditTransfer,payment_method_data: AchTransferData {- email: item.request.get_email()?,+ email: item.get_billing_email().or(item.request.get_email())?,},currency,}))diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex f8eed11d16..9670e00ee9 100644--- a/crates/router/src/connector/utils.rs+++ b/crates/router/src/connector/utils.rs@@ -758,6 +758,7 @@ impl PaymentsSetupMandateRequestData for types::SetupMandateRequestData {pub trait PaymentsAuthorizeRequestData {fn is_auto_capture(&self) -> Result<bool, Error>;fn get_email(&self) -> Result<Email, Error>;+ fn get_optional_email(&self) -> Option<Email>;fn get_browser_info(&self) -> Result<BrowserInformation, Error>;fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error>;fn get_card(&self) -> Result<domain::Card, Error>;@@ -805,6 +806,9 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {fn get_email(&self) -> Result<Email, Error> {self.email.clone().ok_or_else(missing_field_err("email"))}+ fn get_optional_email(&self) -> Option<Email> {+ self.email.clone()+ }fn get_browser_info(&self) -> Result<BrowserInformation, Error> {self.browser_info.clone()@@ -1662,6 +1666,7 @@ pub trait AddressDetailsData {fn to_state_code(&self) -> Result<Secret<String>, Error>;fn to_state_code_as_optional(&self) -> Result<Option<Secret<String>>, Error>;fn get_optional_line2(&self) -> Option<Secret<String>>;+ fn get_optional_country(&self) -> Option<api_models::enums::CountryAlpha2>;}impl AddressDetailsData for api::AddressDetails {@@ -1761,6 +1766,9 @@ impl AddressDetailsData for api::AddressDetails {fn get_optional_line2(&self) -> Option<Secret<String>> {self.line2.clone()}+ fn get_optional_country(&self) -> Option<api_models::enums::CountryAlpha2> {+ self.country+ }}pub trait MandateData {