mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +08:00
fix(payment_methods): filter the apple pay retryable connectors for a specific business profile with default fallback configuration (#4794)
This commit is contained in:
@ -3210,11 +3210,11 @@ where
|
|||||||
routing_data.business_sub_label = choice.sub_label.clone();
|
routing_data.business_sub_label = choice.sub_label.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "retry")]
|
#[cfg(all(feature = "retry", feature = "connector_choice_mca_id"))]
|
||||||
let should_do_retry =
|
let should_do_retry =
|
||||||
retry::config_should_call_gsm(&*state.store, &merchant_account.merchant_id).await;
|
retry::config_should_call_gsm(&*state.store, &merchant_account.merchant_id).await;
|
||||||
|
|
||||||
#[cfg(feature = "retry")]
|
#[cfg(all(feature = "retry", feature = "connector_choice_mca_id"))]
|
||||||
if payment_data.payment_attempt.payment_method_type
|
if payment_data.payment_attempt.payment_method_type
|
||||||
== Some(storage_enums::PaymentMethodType::ApplePay)
|
== Some(storage_enums::PaymentMethodType::ApplePay)
|
||||||
&& should_do_retry
|
&& should_do_retry
|
||||||
@ -3225,15 +3225,15 @@ where
|
|||||||
payment_data,
|
payment_data,
|
||||||
key_store,
|
key_store,
|
||||||
connector_data.clone(),
|
connector_data.clone(),
|
||||||
#[cfg(feature = "connector_choice_mca_id")]
|
|
||||||
choice.merchant_connector_id.clone().as_ref(),
|
choice.merchant_connector_id.clone().as_ref(),
|
||||||
#[cfg(not(feature = "connector_choice_mca_id"))]
|
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if let Some(connector_data_list) = retryable_connector_data {
|
if let Some(connector_data_list) = retryable_connector_data {
|
||||||
return Ok(ConnectorCallType::Retryable(connector_data_list));
|
if connector_data_list.len() > 1 {
|
||||||
|
logger::info!("Constructed apple pay retryable connector list");
|
||||||
|
return Ok(ConnectorCallType::Retryable(connector_data_list));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4015,6 +4015,7 @@ pub fn get_applepay_metadata(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(feature = "retry", feature = "connector_choice_mca_id"))]
|
||||||
pub async fn get_apple_pay_retryable_connectors<F>(
|
pub async fn get_apple_pay_retryable_connectors<F>(
|
||||||
state: SessionState,
|
state: SessionState,
|
||||||
merchant_account: &domain::MerchantAccount,
|
merchant_account: &domain::MerchantAccount,
|
||||||
@ -4040,7 +4041,7 @@ where
|
|||||||
merchant_account.merchant_id.as_str(),
|
merchant_account.merchant_id.as_str(),
|
||||||
payment_data.creds_identifier.to_owned(),
|
payment_data.creds_identifier.to_owned(),
|
||||||
key_store,
|
key_store,
|
||||||
profile_id, // need to fix this
|
profile_id,
|
||||||
&decided_connector_data.connector_name.to_string(),
|
&decided_connector_data.connector_name.to_string(),
|
||||||
merchant_connector_id,
|
merchant_connector_id,
|
||||||
)
|
)
|
||||||
@ -4063,9 +4064,14 @@ where
|
|||||||
.await
|
.await
|
||||||
.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?;
|
.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?;
|
||||||
|
|
||||||
|
let profile_specific_merchant_connector_account_list = filter_mca_based_on_business_profile(
|
||||||
|
merchant_connector_account_list,
|
||||||
|
Some(profile_id.to_string()),
|
||||||
|
);
|
||||||
|
|
||||||
let mut connector_data_list = vec![decided_connector_data.clone()];
|
let mut connector_data_list = vec![decided_connector_data.clone()];
|
||||||
|
|
||||||
for merchant_connector_account in merchant_connector_account_list {
|
for merchant_connector_account in profile_specific_merchant_connector_account_list {
|
||||||
if is_apple_pay_simplified_flow(
|
if is_apple_pay_simplified_flow(
|
||||||
merchant_connector_account.metadata,
|
merchant_connector_account.metadata,
|
||||||
merchant_connector_account
|
merchant_connector_account
|
||||||
@ -4090,7 +4096,33 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(connector_data_list)
|
|
||||||
|
let fallback_connetors_list = crate::core::routing::helpers::get_merchant_default_config(
|
||||||
|
&*state.clone().store,
|
||||||
|
profile_id,
|
||||||
|
&api_enums::TransactionType::Payment,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
|
.attach_printable("Failed to get merchant default fallback connectors config")?;
|
||||||
|
|
||||||
|
// connector_data_list is the list of connectors for which Apple Pay simplified flow is configured.
|
||||||
|
// This list is arranged in the same order as the merchant's default fallback connectors configuration.
|
||||||
|
let mut ordered_connector_data_list = vec![decided_connector_data.clone()];
|
||||||
|
fallback_connetors_list
|
||||||
|
.iter()
|
||||||
|
.for_each(|fallback_connector| {
|
||||||
|
let connector_data = connector_data_list.iter().find(|connector_data| {
|
||||||
|
fallback_connector.merchant_connector_id == connector_data.merchant_connector_id
|
||||||
|
&& fallback_connector.merchant_connector_id
|
||||||
|
!= decided_connector_data.merchant_connector_id
|
||||||
|
});
|
||||||
|
if let Some(connector_data_details) = connector_data {
|
||||||
|
ordered_connector_data_list.push(connector_data_details.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Some(ordered_connector_data_list)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user