mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
fix(payment_methods): fix merchant payment method list to retain a mca based on connector_name and mca_id (#6408)
This commit is contained in:
@ -1217,12 +1217,14 @@ pub struct ResponsePaymentMethodIntermediate {
|
||||
pub card_networks: Option<Vec<api_enums::CardNetwork>>,
|
||||
pub payment_method: api_enums::PaymentMethod,
|
||||
pub connector: String,
|
||||
pub merchant_connector_id: String,
|
||||
}
|
||||
|
||||
impl ResponsePaymentMethodIntermediate {
|
||||
pub fn new(
|
||||
pm_type: RequestPaymentMethodTypes,
|
||||
connector: String,
|
||||
merchant_connector_id: String,
|
||||
pm: api_enums::PaymentMethod,
|
||||
) -> Self {
|
||||
Self {
|
||||
@ -1231,6 +1233,7 @@ impl ResponsePaymentMethodIntermediate {
|
||||
card_networks: pm_type.card_networks,
|
||||
payment_method: pm,
|
||||
connector,
|
||||
merchant_connector_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2980,6 +2980,7 @@ pub async fn list_payment_methods(
|
||||
api_enums::PaymentMethodType::ApplePay,
|
||||
api_enums::PaymentMethodType::Klarna,
|
||||
api_enums::PaymentMethodType::Paypal,
|
||||
api_enums::PaymentMethodType::SamsungPay,
|
||||
]);
|
||||
|
||||
let mut chosen = Vec::<api::SessionConnectorData>::new();
|
||||
@ -3031,6 +3032,15 @@ pub async fn list_payment_methods(
|
||||
.connector
|
||||
.connector_name
|
||||
.to_string()
|
||||
&& first_routable_connector
|
||||
.connector
|
||||
.merchant_connector_id
|
||||
.as_ref()
|
||||
.map(|merchant_connector_id| {
|
||||
*merchant_connector_id.get_string_repr()
|
||||
== intermediate.merchant_connector_id
|
||||
})
|
||||
.unwrap_or_default()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@ -4070,6 +4080,7 @@ pub async fn filter_payment_methods(
|
||||
let response_pm_type = ResponsePaymentMethodIntermediate::new(
|
||||
payment_method_object,
|
||||
connector.clone(),
|
||||
mca_id.get_string_repr().to_string(),
|
||||
payment_method,
|
||||
);
|
||||
resp.push(response_pm_type);
|
||||
|
||||
@ -5520,7 +5520,10 @@ where
|
||||
let routing_choice = choice
|
||||
.first()
|
||||
.ok_or(errors::ApiErrorResponse::InternalServerError)?;
|
||||
if connector_data.connector.connector_name == routing_choice.connector.connector_name {
|
||||
if connector_data.connector.connector_name == routing_choice.connector.connector_name
|
||||
&& connector_data.connector.merchant_connector_id
|
||||
== routing_choice.connector.merchant_connector_id
|
||||
{
|
||||
final_list.push(connector_data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user