Repository: juspay/hyperswitch
File: crates/router/src/core/payments.rs (Rust)

Code before:
        .network_transaction_id_supported_connectors
        .connector_list;

    is_connector_agnostic_mit_enabled == Some(true)
        && payment_method_info.get_payment_method_type() == Some(storage_enums::PaymentMethod::Card)
        && ntid_supported_connectors.contains(&connector)
        && payment_method_info.network_transaction_id.is_some()
}

#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
pub enum IsNtWithNtiFlow {
    NtWithNtiSupported(String), //Network token with Network transaction id supported flow
    NTWithNTINotSupported,      //Network token with Network transaction id not supported
}

pub fn is_network_token_with_network_transaction_id_flow(
    is_connector_agnostic_mit_enabled: Option<bool>,
    is_network_tokenization_enabled: bool,
    payment_method_info: &domain::PaymentMethod,
) -> IsNtWithNtiFlow {
    match (
        is_connector_agnostic_mit_enabled,
        is_network_tokenization_enabled,
        payment_method_info.get_payment_method_type(),
        payment_method_info.network_transaction_id.clone(),
        payment_method_info.network_token_locker_id.is_some(),
        payment_method_info
            .network_token_requestor_reference_id
            .is_some(),
    ) {
        (
            Some(true),
            true,
            Some(storage_enums::PaymentMethod::Card),
            Some(network_transaction_id),
            true,
            true,
        ) => IsNtWithNtiFlow::NtWithNtiSupported(network_transaction_id),
        _ => IsNtWithNtiFlow::NTWithNTINotSupported,
    }
}

pub fn should_add_task_to_process_tracker<F: Clone, D: OperationSessionGetters<F>>(
    payment_data: &D,
) -> bool {
    let connector = payment_data.get_payment_attempt().connector.as_deref();

    !matches!(
        (
            payment_data.get_payment_attempt().get_payment_method(),
            connector

Review comment (suggestion):
As we are taking some action only in case of `NtWithNtiSupported` and not returning anything from the match block, this can be made as `if let`

Ex:
`if let IsNtWithNtiFlow::NtWithNtiSupported(network_transaction_id) = is_network_token_with_ntid_flow`

Code after:
    }

    pub fn with_mandate_flow(
        mut self,
        is_mandate_flow: bool,
        connector_mandate_details: Option<
            hyperswitch_domain_models::mandates::PaymentsMandateReference,
        >,
    ) -> Self {
        if is_mandate_flow {
            self.action_types.extend(
                connector_mandate_details
                    .map(|details| ActionType::ConnectorMandate(details.to_owned())),
            );
        }
        self
    }

    pub async fn with_network_tokenization(
        mut self,
        state: &SessionState,
        is_network_token_with_ntid_flow: IsNtWithNtiFlow,
        is_nt_with_ntid_supported_connector: bool,
        payment_method_info: &domain::PaymentMethod,
    ) -> Self {
        match is_network_token_with_ntid_flow {
            IsNtWithNtiFlow::NtWithNtiSupported(network_transaction_id)
                if is_nt_with_ntid_supported_connector =>
            {
                self.action_types.extend(
                    network_tokenization::do_status_check_for_network_token(
                        state,
                        payment_method_info,
                    )
                    .await
                    .inspect_err(|e| {
                        logger::error!("Status check for network token failed: {:?}", e)
                    })
                    .ok()
                    .map(|(token_exp_month, token_exp_year)| {
                        ActionType::NetworkTokenWithNetworkTransactionId(NTWithNTIRef {
                            token_exp_month,
                            token_exp_year,
                            network_transaction_id,
                        })
                    }),
                );
            }
            _ => (),
        }
        self