mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
refactor(pm_list): get profile_id from business_details in list pm (#2131)
This commit is contained in:
@ -854,9 +854,24 @@ pub async fn list_payment_methods(
|
|||||||
.await
|
.await
|
||||||
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
|
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
|
||||||
|
|
||||||
|
let profile_id = payment_intent
|
||||||
|
.as_ref()
|
||||||
|
.async_map(|payment_intent| async {
|
||||||
|
crate::core::utils::get_profile_id_from_business_details(
|
||||||
|
payment_intent.business_country,
|
||||||
|
payment_intent.business_label.as_ref(),
|
||||||
|
&merchant_account,
|
||||||
|
payment_intent.profile_id.as_ref(),
|
||||||
|
db,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.attach_printable("Could not find profile id from business details")
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.transpose()?;
|
||||||
|
|
||||||
// filter out connectors based on the business country
|
// filter out connectors based on the business country
|
||||||
let filtered_mcas =
|
let filtered_mcas = helpers::filter_mca_based_on_business_profile(all_mcas, profile_id);
|
||||||
helpers::filter_mca_based_on_business_profile(all_mcas, payment_intent.as_ref());
|
|
||||||
|
|
||||||
logger::debug!(mca_before_filtering=?filtered_mcas);
|
logger::debug!(mca_before_filtering=?filtered_mcas);
|
||||||
|
|
||||||
|
|||||||
@ -91,12 +91,12 @@ pub fn create_identity_from_certificate_and_key(
|
|||||||
|
|
||||||
pub fn filter_mca_based_on_business_profile(
|
pub fn filter_mca_based_on_business_profile(
|
||||||
merchant_connector_accounts: Vec<domain::MerchantConnectorAccount>,
|
merchant_connector_accounts: Vec<domain::MerchantConnectorAccount>,
|
||||||
payment_intent: Option<&PaymentIntent>,
|
profile_id: Option<String>,
|
||||||
) -> Vec<domain::MerchantConnectorAccount> {
|
) -> Vec<domain::MerchantConnectorAccount> {
|
||||||
if let Some(payment_intent) = payment_intent {
|
if let Some(profile_id) = profile_id {
|
||||||
merchant_connector_accounts
|
merchant_connector_accounts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|mca| mca.profile_id == payment_intent.profile_id)
|
.filter(|mca| mca.profile_id.as_ref() == Some(&profile_id))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
} else {
|
} else {
|
||||||
merchant_connector_accounts
|
merchant_connector_accounts
|
||||||
|
|||||||
@ -330,10 +330,18 @@ where
|
|||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
.attach_printable("Database error when querying for merchant connector accounts")?;
|
.attach_printable("Database error when querying for merchant connector accounts")?;
|
||||||
|
|
||||||
let filtered_connector_accounts = helpers::filter_mca_based_on_business_profile(
|
let profile_id = crate::core::utils::get_profile_id_from_business_details(
|
||||||
all_connector_accounts,
|
payment_intent.business_country,
|
||||||
Some(payment_intent),
|
payment_intent.business_label.as_ref(),
|
||||||
);
|
merchant_account,
|
||||||
|
payment_intent.profile_id.as_ref(),
|
||||||
|
&*state.store,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.attach_printable("Could not find profile id from business details")?;
|
||||||
|
|
||||||
|
let filtered_connector_accounts =
|
||||||
|
helpers::filter_mca_based_on_business_profile(all_connector_accounts, Some(profile_id));
|
||||||
|
|
||||||
let requested_payment_method_types = request.wallets.clone();
|
let requested_payment_method_types = request.wallets.clone();
|
||||||
let mut connector_and_supporting_payment_method_type = Vec::new();
|
let mut connector_and_supporting_payment_method_type = Vec::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user