mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix(payment_methods): List cards on the basis of profiles (#5584)
This commit is contained in:
@ -3892,6 +3892,7 @@ pub async fn list_customer_payment_method(
|
|||||||
let mca_enabled = get_mca_status(
|
let mca_enabled = get_mca_status(
|
||||||
state,
|
state,
|
||||||
&key_store,
|
&key_store,
|
||||||
|
profile_id.clone(),
|
||||||
merchant_account.get_id(),
|
merchant_account.get_id(),
|
||||||
is_connector_agnostic_mit_enabled,
|
is_connector_agnostic_mit_enabled,
|
||||||
connector_mandate_details,
|
connector_mandate_details,
|
||||||
@ -3932,7 +3933,9 @@ pub async fn list_customer_payment_method(
|
|||||||
&& customer.default_payment_method_id == Some(pm.payment_method_id),
|
&& customer.default_payment_method_id == Some(pm.payment_method_id),
|
||||||
billing: payment_method_billing,
|
billing: payment_method_billing,
|
||||||
};
|
};
|
||||||
customer_pms.push(pma.to_owned());
|
if requires_cvv || mca_enabled {
|
||||||
|
customer_pms.push(pma.to_owned());
|
||||||
|
}
|
||||||
|
|
||||||
let redis_conn = state
|
let redis_conn = state
|
||||||
.store
|
.store
|
||||||
@ -4410,19 +4413,22 @@ async fn generate_saved_pm_response(
|
|||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
.attach_printable("Failed to deserialize to Payment Mandate Reference ")?;
|
.attach_printable("Failed to deserialize to Payment Mandate Reference ")?;
|
||||||
|
|
||||||
let (is_connector_agnostic_mit_enabled, requires_cvv, off_session_payment_flag) = payment_info
|
let (is_connector_agnostic_mit_enabled, requires_cvv, off_session_payment_flag, profile_id) =
|
||||||
.map(|pi| {
|
payment_info
|
||||||
(
|
.map(|pi| {
|
||||||
pi.is_connector_agnostic_mit_enabled,
|
(
|
||||||
pi.requires_cvv,
|
pi.is_connector_agnostic_mit_enabled,
|
||||||
pi.off_session_payment_flag,
|
pi.requires_cvv,
|
||||||
)
|
pi.off_session_payment_flag,
|
||||||
})
|
pi.business_profile.map(|profile| profile.profile_id),
|
||||||
.unwrap_or((false, false, false));
|
)
|
||||||
|
})
|
||||||
|
.unwrap_or((false, false, false, Default::default()));
|
||||||
|
|
||||||
let mca_enabled = get_mca_status(
|
let mca_enabled = get_mca_status(
|
||||||
state,
|
state,
|
||||||
key_store,
|
key_store,
|
||||||
|
profile_id,
|
||||||
merchant_account.get_id(),
|
merchant_account.get_id(),
|
||||||
is_connector_agnostic_mit_enabled,
|
is_connector_agnostic_mit_enabled,
|
||||||
connector_mandate_details,
|
connector_mandate_details,
|
||||||
@ -4486,6 +4492,7 @@ async fn generate_saved_pm_response(
|
|||||||
pub async fn get_mca_status(
|
pub async fn get_mca_status(
|
||||||
state: &routes::SessionState,
|
state: &routes::SessionState,
|
||||||
key_store: &domain::MerchantKeyStore,
|
key_store: &domain::MerchantKeyStore,
|
||||||
|
profile_id: Option<String>,
|
||||||
merchant_id: &id_type::MerchantId,
|
merchant_id: &id_type::MerchantId,
|
||||||
is_connector_agnostic_mit_enabled: bool,
|
is_connector_agnostic_mit_enabled: bool,
|
||||||
connector_mandate_details: Option<storage::PaymentsMandateReference>,
|
connector_mandate_details: Option<storage::PaymentsMandateReference>,
|
||||||
@ -4507,19 +4514,17 @@ pub async fn get_mca_status(
|
|||||||
.change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
|
.change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
|
||||||
id: merchant_id.get_string_repr().to_owned(),
|
id: merchant_id.get_string_repr().to_owned(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let mut mca_ids = HashSet::new();
|
let mut mca_ids = HashSet::new();
|
||||||
let mcas = mcas
|
let mcas = mcas
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|mca| mca.disabled == Some(true))
|
.filter(|mca| mca.disabled == Some(false) && profile_id.clone() == mca.profile_id)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
for mca in mcas {
|
for mca in mcas {
|
||||||
mca_ids.insert(mca.get_id());
|
mca_ids.insert(mca.get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
for mca_id in connector_mandate_details.keys() {
|
for mca_id in connector_mandate_details.keys() {
|
||||||
if !mca_ids.contains(mca_id) {
|
if mca_ids.contains(mca_id) {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user