mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 11:24:45 +08:00
refactor(router): Remove payment_methods_v2 and customer_v2 feature flag (#8236)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -4,7 +4,7 @@ use std::fmt::Debug;
|
||||
use api_models::payouts;
|
||||
use api_models::{enums as api_enums, payment_methods as api};
|
||||
use common_enums::enums as common_enums;
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
use common_utils::encryption;
|
||||
use common_utils::{crypto, ext_traits, id_type, type_name, types::keymanager};
|
||||
use error_stack::ResultExt;
|
||||
@ -32,11 +32,7 @@ pub enum DataDuplicationCheck {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait PaymentMethodsController {
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2"),
|
||||
not(feature = "customer_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn create_payment_method(
|
||||
&self,
|
||||
@ -58,10 +54,7 @@ pub trait PaymentMethodsController {
|
||||
network_token_payment_method_data: crypto::OptionalEncryptableValue,
|
||||
) -> errors::PmResult<payment_methods::PaymentMethod>;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn insert_payment_method(
|
||||
&self,
|
||||
@ -81,7 +74,7 @@ pub trait PaymentMethodsController {
|
||||
network_token_payment_method_data: crypto::OptionalEncryptableValue,
|
||||
) -> errors::PmResult<payment_methods::PaymentMethod>;
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn insert_payment_method(
|
||||
&self,
|
||||
@ -98,25 +91,19 @@ pub trait PaymentMethodsController {
|
||||
payment_method_billing_address: Option<encryption::Encryption>,
|
||||
) -> errors::PmResult<payment_methods::PaymentMethod>;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
async fn add_payment_method(
|
||||
&self,
|
||||
req: &api::PaymentMethodCreate,
|
||||
) -> errors::PmResponse<api::PaymentMethodResponse>;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v2", feature = "v1"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
async fn retrieve_payment_method(
|
||||
&self,
|
||||
pm: api::PaymentMethodId,
|
||||
) -> errors::PmResponse<api::PaymentMethodResponse>;
|
||||
|
||||
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
|
||||
#[cfg(feature = "v1")]
|
||||
async fn delete_payment_method(
|
||||
&self,
|
||||
pm_id: api::PaymentMethodId,
|
||||
@ -149,10 +136,7 @@ pub trait PaymentMethodsController {
|
||||
customer_id: &id_type::CustomerId,
|
||||
) -> errors::VaultResult<(api::PaymentMethodResponse, Option<DataDuplicationCheck>)>;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
async fn get_or_insert_payment_method(
|
||||
&self,
|
||||
req: api::PaymentMethodCreate,
|
||||
@ -161,7 +145,7 @@ pub trait PaymentMethodsController {
|
||||
key_store: &merchant_key_store::MerchantKeyStore,
|
||||
) -> errors::PmResult<payment_methods::PaymentMethod>;
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
async fn get_or_insert_payment_method(
|
||||
&self,
|
||||
req: api::PaymentMethodCreate,
|
||||
@ -172,19 +156,13 @@ pub trait PaymentMethodsController {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v2", feature = "v1"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
async fn get_card_details_with_locker_fallback(
|
||||
&self,
|
||||
pm: &payment_methods::PaymentMethod,
|
||||
) -> errors::PmResult<Option<api::CardDetailFromLocker>>;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v2", feature = "v1"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
async fn get_card_details_without_locker_fallback(
|
||||
&self,
|
||||
pm: &payment_methods::PaymentMethod,
|
||||
@ -197,10 +175,7 @@ pub trait PaymentMethodsController {
|
||||
card_reference: &str,
|
||||
) -> errors::PmResult<DeleteCardResp>;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
fn store_default_payment_method(
|
||||
&self,
|
||||
req: &api::PaymentMethodCreate,
|
||||
@ -208,7 +183,7 @@ pub trait PaymentMethodsController {
|
||||
merchant_id: &id_type::MerchantId,
|
||||
) -> (api::PaymentMethodResponse, Option<DataDuplicationCheck>);
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
fn store_default_payment_method(
|
||||
&self,
|
||||
req: &api::PaymentMethodCreate,
|
||||
@ -216,11 +191,7 @@ pub trait PaymentMethodsController {
|
||||
merchant_id: &id_type::MerchantId,
|
||||
) -> (api::PaymentMethodResponse, Option<DataDuplicationCheck>);
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2"),
|
||||
not(feature = "customer_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn save_network_token_and_update_payment_method(
|
||||
&self,
|
||||
@ -231,7 +202,7 @@ pub trait PaymentMethodsController {
|
||||
pm_id: String,
|
||||
) -> errors::PmResult<bool>;
|
||||
|
||||
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
|
||||
#[cfg(feature = "v1")]
|
||||
async fn set_default_payment_method(
|
||||
&self,
|
||||
merchant_id: &id_type::MerchantId,
|
||||
@ -239,10 +210,7 @@ pub trait PaymentMethodsController {
|
||||
payment_method_id: String,
|
||||
) -> errors::PmResponse<api_models::payment_methods::CustomerDefaultPaymentMethodResponse>;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
async fn add_payment_method_status_update_task(
|
||||
&self,
|
||||
payment_method: &payment_methods::PaymentMethod,
|
||||
|
||||
@ -14,10 +14,7 @@ pub use payment_methods::migrate_payment_method;
|
||||
type PmMigrationResult<T> =
|
||||
errors::CustomResult<api::ApplicationResponse<T>, errors::ApiErrorResponse>;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v2", feature = "v1"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
pub async fn migrate_payment_methods(
|
||||
state: &state::PaymentMethodsState,
|
||||
payment_methods: Vec<pm_api::PaymentMethodRecord>,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
use api_models::enums as api_enums;
|
||||
use api_models::{enums, payment_methods as pm_api};
|
||||
use common_utils::{
|
||||
@ -27,10 +27,7 @@ use crate::{
|
||||
state,
|
||||
};
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
pub async fn migrate_payment_method(
|
||||
state: &state::PaymentMethodsState,
|
||||
req: pm_api::PaymentMethodMigrate,
|
||||
@ -154,7 +151,7 @@ pub async fn migrate_payment_method(
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
pub async fn migrate_payment_method(
|
||||
_state: &state::PaymentMethodsState,
|
||||
_req: pm_api::PaymentMethodMigrate,
|
||||
@ -166,10 +163,7 @@ pub async fn migrate_payment_method(
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
pub async fn populate_bin_details_for_masked_card(
|
||||
card_details: &api_models::payment_methods::MigrateCardDetail,
|
||||
db: &dyn state::PaymentMethodsStorageInterface,
|
||||
@ -203,10 +197,7 @@ pub async fn populate_bin_details_for_masked_card(
|
||||
Ok(card_bin_details)
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
impl
|
||||
ForeignTryFrom<(
|
||||
&api_models::payment_methods::MigrateCardDetail,
|
||||
@ -281,7 +272,7 @@ impl
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
impl
|
||||
ForeignTryFrom<(
|
||||
&api_models::payment_methods::MigrateCardDetail,
|
||||
@ -361,10 +352,7 @@ impl
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn get_client_secret_or_add_payment_method_for_migration(
|
||||
state: &state::PaymentMethodsState,
|
||||
@ -467,11 +455,7 @@ pub async fn get_client_secret_or_add_payment_method_for_migration(
|
||||
))
|
||||
}
|
||||
}
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2"),
|
||||
not(feature = "customer_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn skip_locker_call_and_migrate_payment_method(
|
||||
state: &state::PaymentMethodsState,
|
||||
@ -640,11 +624,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(
|
||||
}
|
||||
|
||||
// need to discuss regarding the migration APIs for v2
|
||||
#[cfg(all(
|
||||
feature = "v2",
|
||||
feature = "payment_methods_v2",
|
||||
feature = "customer_v2"
|
||||
))]
|
||||
#[cfg(feature = "v2")]
|
||||
pub async fn skip_locker_call_and_migrate_payment_method(
|
||||
_state: state::PaymentMethodsState,
|
||||
_req: &pm_api::PaymentMethodMigrate,
|
||||
@ -673,10 +653,7 @@ pub fn get_card_bin_and_last4_digits_for_masked_card(
|
||||
|
||||
Ok((card_isin, last4_digits))
|
||||
}
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn save_migration_payment_method(
|
||||
req: pm_api::PaymentMethodCreate,
|
||||
|
||||
@ -4,10 +4,7 @@ pub use hyperswitch_domain_models::{errors::api_error_response, payment_methods
|
||||
use router_env::logger;
|
||||
|
||||
use crate::state;
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
pub async fn populate_bin_details_for_payment_method_create(
|
||||
card_details: api_models::payment_methods::CardDetail,
|
||||
db: Box<dyn state::PaymentMethodsStorageInterface>,
|
||||
@ -65,7 +62,7 @@ pub async fn populate_bin_details_for_payment_method_create(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
pub async fn populate_bin_details_for_payment_method_create(
|
||||
_card_details: api_models::payment_methods::CardDetail,
|
||||
_db: &dyn state::PaymentMethodsStorageInterface,
|
||||
@ -246,10 +243,7 @@ pub trait ForeignTryFrom<F>: Sized {
|
||||
fn foreign_try_from(from: F) -> Result<Self, Self::Error>;
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
impl ForeignFrom<(Option<api::CardDetailFromLocker>, domain::PaymentMethod)>
|
||||
for api::PaymentMethodResponse
|
||||
{
|
||||
@ -276,7 +270,7 @@ impl ForeignFrom<(Option<api::CardDetailFromLocker>, domain::PaymentMethod)>
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[cfg(feature = "v2")]
|
||||
impl ForeignFrom<(Option<api::CardDetailFromLocker>, domain::PaymentMethod)>
|
||||
for api::PaymentMethodResponse
|
||||
{
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
use common_utils::errors::CustomResult;
|
||||
use common_utils::types::keymanager;
|
||||
use hyperswitch_domain_models::{
|
||||
@ -42,10 +39,7 @@ impl From<&PaymentMethodsState> for keymanager::KeyManagerState {
|
||||
state.key_manager_state.clone()
|
||||
}
|
||||
}
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[cfg(feature = "v1")]
|
||||
impl PaymentMethodsState {
|
||||
pub async fn find_payment_method(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user