Command: git show 693f9019c:crates/router/src/core/paymentmethods/cards.rs grep -A 100…
- User
Command: git show 693f9019c:crates/router/src/core/payment_methods/cards.rs | grep -A 100 -B 5 "Filter out wallet payment method" Output: logger::info!( "The Payment Methods available after Constraint Graph filtering are {:?}", response );
// Filter out wallet payment method from mca if customer has already saved it customer .as_ref() .async_map(|customer| async { let wallet_pm_exists = response .iter() .any(|mca| mca.payment_method == enums::PaymentMethod::Wallet); if wallet_pm_exists { match db .find_payment_method_by_customer_id_merchant_id_status( &((&state).into()), merchant_context.get_merchant_key_store(), &customer.customer_id, merchant_context.get_merchant_account().get_id(), common_enums::PaymentMethodStatus::Active, None, merchant_context.get_merchant_account().storage_scheme, ) .await { Ok(customer_payment_methods) => { let customer_wallet_pm = customer_payment_methods .iter() .filter(|cust_pm| { cust_pm.get_payment_method_type() == Some(enums::PaymentMethod::Wallet) }) .collect::<Vec<_>>(); response.retain(|mca| { !(mca.payment_method == enums::PaymentMethod::Wallet && customer_wallet_pm.iter().any(|cust_pm| { cust_pm.get_payment_method_subtype() == Some(mca.payment_method_type) })) }); logger::debug!("Filtered out wallet payment method from mca since customer has already saved it"); Ok(()) } Err(error) => { if error.current_context().is_db_not_found() { Ok(()) } else { Err(error) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("failed to find payment methods for a customer") } } } } else { Ok(()) } }) .await .transpose()?; let mut pmt_to_auth_connector: HashMap< enums::PaymentMethod, HashMap<enums::PaymentMethodType, String>, > = HashMap::new(); if let Some((payment_attempt, payment_intent)) = payment_attempt.as_ref().zip(payment_intent.as_ref()) { let routing_enabled_pms = &router_consts::ROUTING_ENABLED_PAYMENT_METHODS; let routing_enabled_pm_types = &router_consts::ROUTING_ENABLED_PAYMENT_METHOD_TYPES; let mut chosen = api::SessionConnectorDatas::new(Vec::new()); for intermediate in &response { if routing_enabled_pm_types.contains(&intermediate.payment_method_type) || routing_enabled_pms.contains(&intermediate.payment_method) { let connector_data = api::ConnectorData::get_connector_by_name( &state.clone().conf.connectors, &intermediate.connector, api::GetToken::from(intermediate.payment_method_type), None, ) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("invalid connector name received")?; chosen.push(api::SessionConnectorData { payment_method_sub_type: intermediate.payment_method_type, payment_method_type: intermediate.payment_method, connector: connector_data, business_sub_label: None, }); } } let sfr = SessionFlowRoutingInput { state: &state, country: billing_address.clone().and_then(|ad| ad.country), key_store: merchant_context.get_merchant_key_store(), merchant_account: merchant_context.get_merchant_account(), payment_attempt, payment_intent, chosen, }; let result = routing::perform_session_flow_routing( sfr, &business_profile, Assistant
<is_displaying_contents> true </is_displaying_contents>