Skip to content

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

refactor(payouts): add bankredirect for payout links (#9943)

Swangi Kumari5b42bf8c9877
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<String, RequiredFieldInfo> {
)])
}
-fn get_interac_fields(connector: PayoutConnectors) -> HashMap<String, RequiredFieldInfo> {
- 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<String, RequiredFieldInfo> {
+ 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<CountryAlpha2> {
@@ -639,6 +588,64 @@ fn get_billing_details(connector: PayoutConnectors) -> HashMap<String, RequiredF
},
),
]),
+ PayoutConnectors::Loonio => 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<common_enums::PaymentMethodType> = HashSet::new();
let mut card_hash_set: HashSet<common_enums::PaymentMethodType> = HashSet::new();
let mut wallet_hash_set: HashSet<common_enums::PaymentMethodType> = HashSet::new();
+ let mut bank_redirect_hash_set: HashSet<common_enums::PaymentMethodType> = 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