chore: resolve warnings in v2 (#8373)

Co-authored-by: Aishwariyaa Anand <aishwariyaa.anand@Aishwariyaa-Anand-C3PGW02T6Y.local>
This commit is contained in:
Aishwariyaa Anand
2025-06-22 16:58:23 +05:30
committed by GitHub
parent 0851c6ece5
commit d2d4f3d1d8
50 changed files with 218 additions and 320 deletions

View File

@ -6,10 +6,11 @@ use api_models::{
};
use crate::configs::settings::{
ConnectorFields, Mandates, PaymentMethodType, RequiredFieldFinal, RequiredFields,
SupportedConnectorsForMandate, SupportedPaymentMethodTypesForMandate,
SupportedPaymentMethodsForMandate, ZeroMandates,
ConnectorFields, Mandates, RequiredFieldFinal, SupportedConnectorsForMandate,
SupportedPaymentMethodTypesForMandate, SupportedPaymentMethodsForMandate, ZeroMandates,
};
#[cfg(feature = "v1")]
use crate::configs::settings::{PaymentMethodType, RequiredFields};
impl Default for ZeroMandates {
fn default() -> Self {
@ -125,6 +126,7 @@ impl Default for Mandates {
}
#[derive(Clone, serde::Serialize)]
#[cfg_attr(feature = "v2", allow(dead_code))] // multiple variants are never constructed for v2
enum RequiredField {
CardNumber,
CardExpMonth,
@ -859,6 +861,7 @@ impl RequiredField {
}
// Define helper functions for common field groups
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn card_basic() -> Vec<RequiredField> {
vec![
RequiredField::CardNumber,
@ -868,6 +871,7 @@ fn card_basic() -> Vec<RequiredField> {
]
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn full_name() -> Vec<RequiredField> {
vec![
RequiredField::BillingUserFirstName,
@ -875,6 +879,7 @@ fn full_name() -> Vec<RequiredField> {
]
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn billing_name() -> Vec<RequiredField> {
vec![
RequiredField::BillingFirstName("billing_first_name", FieldType::UserBillingName),
@ -882,18 +887,22 @@ fn billing_name() -> Vec<RequiredField> {
]
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn email() -> Vec<RequiredField> {
[RequiredField::Email].to_vec()
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn billing_email() -> Vec<RequiredField> {
[RequiredField::BillingEmail].to_vec()
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn card_with_name() -> Vec<RequiredField> {
[card_basic(), full_name()].concat()
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn billing_email_name() -> Vec<RequiredField> {
vec![
RequiredField::BillingEmail,
@ -902,6 +911,7 @@ fn billing_email_name() -> Vec<RequiredField> {
]
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn billing_email_name_phone() -> Vec<RequiredField> {
vec![
RequiredField::BillingUserFirstName,
@ -912,6 +922,7 @@ fn billing_email_name_phone() -> Vec<RequiredField> {
]
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn billing_address() -> Vec<RequiredField> {
vec![
RequiredField::BillingAddressCity,
@ -940,6 +951,7 @@ fn fields(
}
}
#[cfg_attr(feature = "v2", allow(dead_code))] // This function is not used in v2
fn connectors(connectors: Vec<(Connector, RequiredFieldFinal)>) -> ConnectorFields {
ConnectorFields {
fields: connectors.into_iter().collect(),

View File

@ -3,6 +3,7 @@ use std::fmt::Debug;
#[cfg(feature = "payouts")]
use api_models::payouts;
use api_models::{enums as api_enums, payment_methods as api};
#[cfg(feature = "v1")]
use common_enums::enums as common_enums;
#[cfg(feature = "v2")]
use common_utils::encryption;
@ -10,6 +11,7 @@ use common_utils::{crypto, ext_traits, id_type, type_name, types::keymanager};
use error_stack::ResultExt;
use hyperswitch_domain_models::{merchant_key_store, payment_methods, type_encryption};
use masking::{PeekInterface, Secret};
#[cfg(feature = "v1")]
use scheduler::errors as sch_errors;
use serde::{Deserialize, Serialize};
use storage_impl::{errors as storage_errors, payment_method};
@ -148,10 +150,10 @@ pub trait PaymentMethodsController {
#[cfg(feature = "v2")]
async fn get_or_insert_payment_method(
&self,
req: api::PaymentMethodCreate,
resp: &mut api::PaymentMethodResponse,
customer_id: &id_type::CustomerId,
key_store: &merchant_key_store::MerchantKeyStore,
_req: api::PaymentMethodCreate,
_resp: &mut api::PaymentMethodResponse,
_customer_id: &id_type::CustomerId,
_key_store: &merchant_key_store::MerchantKeyStore,
) -> errors::PmResult<payment_methods::PaymentMethod> {
todo!()
}

View File

@ -2,15 +2,19 @@ use actix_multipart::form::{self, bytes, text};
use api_models::payment_methods as pm_api;
use csv::Reader;
use error_stack::ResultExt;
#[cfg(feature = "v1")]
use hyperswitch_domain_models::{api, merchant_context};
use masking::PeekInterface;
use rdkafka::message::ToBytes;
use router_env::{instrument, tracing};
use crate::{controller as pm, core::errors, state};
use crate::core::errors;
#[cfg(feature = "v1")]
use crate::{controller as pm, state};
pub mod payment_methods;
pub use payment_methods::migrate_payment_method;
#[cfg(feature = "v1")]
type PmMigrationResult<T> =
errors::CustomResult<api::ApplicationResponse<T>, errors::ApiErrorResponse>;

View File

@ -2,30 +2,39 @@ use std::str::FromStr;
#[cfg(feature = "v2")]
use api_models::enums as api_enums;
use api_models::{enums, payment_methods as pm_api};
#[cfg(feature = "v1")]
use api_models::enums;
use api_models::payment_methods as pm_api;
#[cfg(feature = "v1")]
use common_utils::{
consts,
crypto::Encryptable,
errors::CustomResult,
ext_traits::{AsyncExt, ConfigExt},
generate_id, id_type,
generate_id,
};
use common_utils::{errors::CustomResult, id_type};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
api::ApplicationResponse, errors::api_error_response as errors, ext_traits::OptionExt,
merchant_context, payment_methods as domain_pm,
api::ApplicationResponse, errors::api_error_response as errors, merchant_context,
};
use masking::{PeekInterface, Secret};
#[cfg(feature = "v1")]
use hyperswitch_domain_models::{ext_traits::OptionExt, payment_methods as domain_pm};
use masking::PeekInterface;
#[cfg(feature = "v1")]
use masking::Secret;
#[cfg(feature = "v1")]
use router_env::{instrument, logger, tracing};
#[cfg(feature = "v1")]
use serde_json::json;
use storage_impl::cards_info;
#[cfg(feature = "v1")]
use crate::{
controller::{create_encrypted_data, PaymentMethodsController},
controller::create_encrypted_data,
core::migration,
helpers::{ForeignFrom, ForeignTryFrom, StorageErrorExt},
state,
helpers::{ForeignFrom, StorageErrorExt},
};
use crate::{controller::PaymentMethodsController, helpers::ForeignTryFrom, state};
#[cfg(feature = "v1")]
pub async fn migrate_payment_method(
@ -156,8 +165,8 @@ pub async fn migrate_payment_method(
_state: &state::PaymentMethodsState,
_req: pm_api::PaymentMethodMigrate,
_merchant_id: &id_type::MerchantId,
merchant_context: &merchant_context::MerchantContext,
controller: &dyn PaymentMethodsController,
_merchant_context: &merchant_context::MerchantContext,
_controller: &dyn PaymentMethodsController,
) -> CustomResult<ApplicationResponse<pm_api::PaymentMethodMigrateResponse>, errors::ApiErrorResponse>
{
todo!()

View File

@ -1,6 +1,8 @@
use api_models::{enums as api_enums, payment_methods as api};
#[cfg(feature = "v1")]
use common_utils::ext_traits::AsyncExt;
pub use hyperswitch_domain_models::{errors::api_error_response, payment_methods as domain};
#[cfg(feature = "v1")]
use router_env::logger;
use crate::state;
@ -277,7 +279,7 @@ impl ForeignFrom<(Option<api::CardDetailFromLocker>, domain::PaymentMethod)>
for api::PaymentMethodResponse
{
fn foreign_from(
(card_details, item): (Option<api::CardDetailFromLocker>, domain::PaymentMethod),
(_card_details, _item): (Option<api::CardDetailFromLocker>, domain::PaymentMethod),
) -> Self {
todo!()
}

View File

@ -1,8 +1,10 @@
#[cfg(feature = "v1")]
use common_utils::errors::CustomResult;
use common_utils::types::keymanager;
#[cfg(feature = "v1")]
use hyperswitch_domain_models::merchant_account;
use hyperswitch_domain_models::{
cards_info, customer, merchant_account, merchant_key_store, payment_methods as pm_domain,
cards_info, customer, merchant_key_store, payment_methods as pm_domain,
};
use storage_impl::{errors, kv_router_store::KVRouterStore, DatabaseStore, MockDb, RouterStore};