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:
Prasunna Soppa
2025-06-12 00:07:24 +05:30
committed by GitHub
parent 6ea2e2a6f4
commit 000aa23c10
106 changed files with 896 additions and 1856 deletions

View File

@ -4,16 +4,16 @@ pub mod payment_intents;
pub mod refunds;
pub mod setup_intents;
pub mod webhooks;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use actix_web::{web, Scope};
pub mod errors;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use crate::routes;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
pub struct StripeApis;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
impl StripeApis {
pub fn server(state: routes::AppState) -> Scope {
let max_depth = 10;

View File

@ -1,15 +1,13 @@
use actix_web::{web, Scope};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use super::customers::*;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use super::{payment_intents::*, setup_intents::*};
#[cfg(feature = "v1")]
use super::{customers::*, payment_intents::*, setup_intents::*};
use super::{refunds::*, webhooks::*};
use crate::routes::{self, mandates, webhooks};
pub struct PaymentIntents;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
impl PaymentIntents {
pub fn server(state: routes::AppState) -> Scope {
let mut route = web::scope("/payment_intents").app_data(web::Data::new(state));
@ -45,7 +43,7 @@ impl PaymentIntents {
pub struct SetupIntents;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
impl SetupIntents {
pub fn server(state: routes::AppState) -> Scope {
web::scope("/setup_intents")
@ -82,7 +80,7 @@ impl Refunds {
pub struct Customers;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
impl Customers {
pub fn server(config: routes::AppState) -> Scope {
web::scope("/customers")

View File

@ -1,14 +1,14 @@
pub mod types;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use actix_web::{web, HttpRequest, HttpResponse};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use common_utils::id_type;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use error_stack::report;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use router_env::{instrument, tracing, Flow};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use crate::{
compatibility::{stripe::errors, wrap},
core::{api_locking, customers, payment_methods::cards},
@ -20,11 +20,7 @@ use crate::{
},
};
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "customer_v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::CustomersCreate))]
pub async fn customer_create(
state: web::Data<routes::AppState>,
@ -72,11 +68,7 @@ pub async fn customer_create(
.await
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "customer_v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::CustomersRetrieve))]
pub async fn customer_retrieve(
state: web::Data<routes::AppState>,
@ -116,11 +108,7 @@ pub async fn customer_retrieve(
.await
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "customer_v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::CustomersUpdate))]
pub async fn customer_update(
state: web::Data<routes::AppState>,
@ -174,11 +162,7 @@ pub async fn customer_update(
.await
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "customer_v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::CustomersDelete))]
pub async fn customer_delete(
state: web::Data<routes::AppState>,
@ -218,11 +202,7 @@ pub async fn customer_delete(
.await
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "customer_v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::CustomerPaymentMethodsList))]
pub async fn list_customer_payment_method_api(
state: web::Data<routes::AppState>,

View File

@ -1,12 +1,9 @@
use std::{convert::From, default::Default};
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
use api_models::payment_methods as api_types;
use api_models::payments;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use common_utils::{crypto::Encryptable, date_time};
use common_utils::{
id_type,
@ -15,7 +12,7 @@ use common_utils::{
};
use serde::{Deserialize, Serialize};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use crate::logger;
use crate::types::{api, api::enums as api_enums};
@ -123,7 +120,7 @@ impl From<StripeAddressDetails> for payments::AddressDetails {
}
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
impl From<CreateCustomerRequest> for api::CustomerRequest {
fn from(req: CreateCustomerRequest) -> Self {
Self {
@ -139,7 +136,7 @@ impl From<CreateCustomerRequest> for api::CustomerRequest {
}
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
impl From<CustomerUpdateRequest> for api::CustomerUpdateRequest {
fn from(req: CustomerUpdateRequest) -> Self {
Self {
@ -154,7 +151,7 @@ impl From<CustomerUpdateRequest> for api::CustomerUpdateRequest {
}
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
impl From<api::CustomerResponse> for CreateCustomerResponse {
fn from(cust: api::CustomerResponse) -> Self {
let cust = cust.into_inner();
@ -182,7 +179,7 @@ impl From<api::CustomerResponse> for CreateCustomerResponse {
}
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
impl From<api::CustomerDeleteResponse> for CustomerDeleteResponse {
fn from(cust: api::CustomerDeleteResponse) -> Self {
Self {
@ -215,10 +212,7 @@ pub struct CardDetails {
pub fingerprint: Option<masking::Secret<String>>,
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
impl From<api::CustomerPaymentMethodsListResponse> for CustomerPaymentMethodListResponse {
fn from(item: api::CustomerPaymentMethodsListResponse) -> Self {
let customer_payment_methods = item.customer_payment_methods;
@ -233,10 +227,7 @@ impl From<api::CustomerPaymentMethodsListResponse> for CustomerPaymentMethodList
}
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
impl From<api_types::CustomerPaymentMethod> for PaymentMethodData {
fn from(item: api_types::CustomerPaymentMethod) -> Self {
let card = item.card.map(From::from);
@ -249,10 +240,7 @@ impl From<api_types::CustomerPaymentMethod> for PaymentMethodData {
}
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
#[cfg(feature = "v1")]
impl From<api_types::CardDetailFromLocker> for CardDetails {
fn from(item: api_types::CardDetailFromLocker) -> Self {
Self {

View File

@ -2,9 +2,9 @@ pub mod types;
use actix_web::{web, HttpRequest, HttpResponse};
use api_models::payments as payment_types;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use error_stack::report;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use router_env::Tag;
use router_env::{instrument, tracing, Flow};
@ -14,7 +14,7 @@ use crate::{
routes::{self},
services::{api, authentication as auth},
};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use crate::{
core::api_locking::GetLockingInput,
logger,
@ -22,7 +22,7 @@ use crate::{
types::{api as api_types, domain},
};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCreate, payment_id))]
pub async fn payment_intents_create(
state: web::Data<routes::AppState>,
@ -185,7 +185,7 @@ pub async fn payment_intents_retrieve(
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow))]
pub async fn payment_intents_retrieve_with_gateway_creds(
state: web::Data<routes::AppState>,
@ -271,7 +271,7 @@ pub async fn payment_intents_retrieve_with_gateway_creds(
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsUpdate))]
pub async fn payment_intents_update(
state: web::Data<routes::AppState>,
@ -354,7 +354,7 @@ pub async fn payment_intents_update(
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsConfirm, payment_id))]
pub async fn payment_intents_confirm(
state: web::Data<routes::AppState>,
@ -446,7 +446,7 @@ pub async fn payment_intents_confirm(
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCapture, payment_id))]
pub async fn payment_intents_capture(
state: web::Data<routes::AppState>,
@ -522,7 +522,7 @@ pub async fn payment_intents_capture(
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCancel, payment_id))]
pub async fn payment_intents_cancel(
state: web::Data<routes::AppState>,

View File

@ -1,14 +1,14 @@
pub mod types;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use actix_web::{web, HttpRequest, HttpResponse};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use api_models::payments as payment_types;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use error_stack::report;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use router_env::{instrument, tracing, Flow};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
use crate::{
compatibility::{
stripe::{errors, payment_intents::types as stripe_payment_types},
@ -20,7 +20,7 @@ use crate::{
types::{api as api_types, domain},
};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsCreate))]
pub async fn setup_intents_create(
state: web::Data<routes::AppState>,
@ -169,7 +169,7 @@ pub async fn setup_intents_retrieve(
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsUpdate))]
pub async fn setup_intents_update(
state: web::Data<routes::AppState>,
@ -252,7 +252,7 @@ pub async fn setup_intents_update(
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::PaymentsConfirm))]
pub async fn setup_intents_confirm(
state: web::Data<routes::AppState>,