refactor(session_token): add support for business filtering in payments session (#1128)

This commit is contained in:
Narayan Bhat
2023-05-11 20:34:45 +05:30
committed by GitHub
parent e779ee78a4
commit 2b0ed12530
13 changed files with 127 additions and 104 deletions

View File

@ -43,6 +43,25 @@ use crate::{
},
};
pub fn filter_mca_based_on_business_details(
merchant_connector_accounts: Vec<
storage_models::merchant_connector_account::MerchantConnectorAccount,
>,
payment_intent: Option<&storage_models::payment_intent::PaymentIntent>,
) -> Vec<storage_models::merchant_connector_account::MerchantConnectorAccount> {
if let Some(payment_intent) = payment_intent {
merchant_connector_accounts
.into_iter()
.filter(|mca| {
mca.business_country == payment_intent.business_country
&& mca.business_label == payment_intent.business_label
})
.collect::<Vec<_>>()
} else {
merchant_connector_accounts
}
}
pub async fn get_address_for_payment_request(
db: &dyn StorageInterface,
req_address: Option<&api::Address>,