diff --git a/crates/router/src/configs/defaults/payout_required_fields.rs b/crates/router/src/configs/defaults/payout_required_fields.rs index 1e4ca2107c..97e4be9662 100644 --- a/crates/router/src/configs/defaults/payout_required_fields.rs +++ b/crates/router/src/configs/defaults/payout_required_fields.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use api_models::{ enums::{ CountryAlpha2, FieldType, - PaymentMethod::{BankTransfer, Card, Wallet}, + PaymentMethod::{BankRedirect, BankTransfer, Card, Wallet}, PaymentMethodType, PayoutConnectors, }, payment_methods::RequiredFieldInfo, @@ -62,6 +62,25 @@ impl Default for PayoutRequiredFields { ), ])), ), + ( + // TODO: Refactor to support multiple connectors, each having its own set of required fields. + BankRedirect, + PaymentMethodTypeInfo(HashMap::from([{ + let (pmt, mut gidadat_fields) = get_connector_payment_method_type_fields( + PayoutConnectors::Gigadat, + PaymentMethodType::Interac, + ); + + let (_, loonio_fields) = get_connector_payment_method_type_fields( + PayoutConnectors::Loonio, + PaymentMethodType::Interac, + ); + + gidadat_fields.fields.extend(loonio_fields.fields); + + (pmt, gidadat_fields) + }])), + ), ])) } } @@ -246,7 +265,7 @@ fn get_connector_payment_method_type_fields( // Bank Redirect PaymentMethodType::Interac => { - common_fields.extend(get_interac_fields(connector)); + common_fields.extend(get_interac_fields()); ( payment_method_type, ConnectorFields { @@ -393,86 +412,16 @@ fn get_paypal_fields() -> HashMap { )]) } -fn get_interac_fields(connector: PayoutConnectors) -> HashMap { - match connector { - PayoutConnectors::Loonio => HashMap::from([ - ( - "payout_method_data.bank_redirect.interac.email".to_string(), - RequiredFieldInfo { - required_field: "payout_method_data.bank_redirect.interac.email".to_string(), - display_name: "email".to_string(), - field_type: FieldType::Text, - value: None, - }, - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "billing.address.first_name".to_string(), - display_name: "billing_address_first_name".to_string(), - field_type: FieldType::Text, - value: None, - }, - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "billing.address.last_name".to_string(), - display_name: "billing_address_last_name".to_string(), - field_type: FieldType::Text, - value: None, - }, - ), - ]), - PayoutConnectors::Gigadat => HashMap::from([ - ( - "payout_method_data.bank_redirect.interac.email".to_string(), - RequiredFieldInfo { - required_field: "payout_method_data.bank_redirect.interac.email".to_string(), - display_name: "email".to_string(), - field_type: FieldType::Text, - value: None, - }, - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "billing.address.first_name".to_string(), - display_name: "billing_address_first_name".to_string(), - field_type: FieldType::Text, - value: None, - }, - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "billing.address.last_name".to_string(), - display_name: "billing_address_last_name".to_string(), - field_type: FieldType::Text, - value: None, - }, - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: FieldType::UserPhoneNumber, - 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: FieldType::UserPhoneNumberCountryCode, - value: None, - }, - ), - ]), - _ => HashMap::from([]), - } +fn get_interac_fields() -> HashMap { + HashMap::from([( + "payout_method_data.bank_redirect.interac.email".to_string(), + RequiredFieldInfo { + required_field: "payout_method_data.bank_redirect.interac.email".to_string(), + display_name: "email".to_string(), + field_type: FieldType::Text, + value: None, + }, + )]) } fn get_countries_for_connector(connector: PayoutConnectors) -> Vec { @@ -639,6 +588,64 @@ fn get_billing_details(connector: PayoutConnectors) -> HashMap HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.first_name".to_string(), + display_name: "billing_address_first_name".to_string(), + field_type: FieldType::Text, + value: None, + }, + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.last_name".to_string(), + display_name: "billing_address_last_name".to_string(), + field_type: FieldType::Text, + value: None, + }, + ), + ]), + PayoutConnectors::Gigadat => HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.first_name".to_string(), + display_name: "billing_address_first_name".to_string(), + field_type: FieldType::Text, + value: None, + }, + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "billing.address.last_name".to_string(), + display_name: "billing_address_last_name".to_string(), + field_type: FieldType::Text, + value: None, + }, + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: FieldType::UserPhoneNumber, + 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: FieldType::UserPhoneNumberCountryCode, + value: None, + }, + ), + ]), _ => HashMap::from([]), } } diff --git a/crates/router/src/core/payout_link.rs b/crates/router/src/core/payout_link.rs index e96e1229e4..ba18f0111b 100644 --- a/crates/router/src/core/payout_link.rs +++ b/crates/router/src/core/payout_link.rs @@ -360,6 +360,7 @@ pub async fn filter_payout_methods( let mut bank_transfer_hash_set: HashSet = HashSet::new(); let mut card_hash_set: HashSet = HashSet::new(); let mut wallet_hash_set: HashSet = HashSet::new(); + let mut bank_redirect_hash_set: HashSet = HashSet::new(); let payout_filter_config = &state.conf.payout_method_filters.clone(); for mca in &filtered_mcas { let payout_methods = match &mca.payment_methods_enabled { @@ -408,9 +409,14 @@ pub async fn filter_payout_methods( payment_method_list_hm .insert(payment_method, bank_transfer_hash_set.clone()); } + common_enums::PaymentMethod::BankRedirect => { + bank_redirect_hash_set + .insert(request_payout_method_type.payment_method_type); + payment_method_list_hm + .insert(payment_method, bank_redirect_hash_set.clone()); + } common_enums::PaymentMethod::CardRedirect | common_enums::PaymentMethod::PayLater - | common_enums::PaymentMethod::BankRedirect | common_enums::PaymentMethod::Crypto | common_enums::PaymentMethod::BankDebit | common_enums::PaymentMethod::Reward diff --git a/docker-compose-development.yml b/docker-compose-development.yml index a26ba9ec21..5bfb2d230a 100644 --- a/docker-compose-development.yml +++ b/docker-compose-development.yml @@ -20,7 +20,7 @@ services: networks: - router_net volumes: - - pg_data:/VAR/LIB/POSTGRESQL/DATA + - pg_data:/var/lib/postgresql environment: - POSTGRES_USER=db_user - POSTGRES_PASSWORD=db_pass diff --git a/docker-compose.yml b/docker-compose.yml index c0bab9a82d..f8dfd7e0f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,7 +31,7 @@ services: networks: - router_net volumes: - - pg_data:/var/lib/postgresql/data + - pg_data:/var/lib/postgresql environment: - POSTGRES_USER=db_user - POSTGRES_PASSWORD=db_pass