mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
refactor(compatibility): refactor stripe compatibility routes using web::resource (#1022)
This commit is contained in:
@ -7,14 +7,34 @@ pub struct PaymentIntents;
|
|||||||
|
|
||||||
impl PaymentIntents {
|
impl PaymentIntents {
|
||||||
pub fn server(state: routes::AppState) -> Scope {
|
pub fn server(state: routes::AppState) -> Scope {
|
||||||
web::scope("/payment_intents")
|
let mut route = web::scope("/payment_intents").app_data(web::Data::new(state));
|
||||||
.app_data(web::Data::new(state))
|
#[cfg(feature = "olap")]
|
||||||
.service(payment_intents_retrieve_with_gateway_creds)
|
{
|
||||||
.service(payment_intents_create)
|
route = route.service(web::resource("/list").route(web::get().to(payment_intent_list)))
|
||||||
.service(payment_intents_retrieve)
|
}
|
||||||
.service(payment_intents_update)
|
route = route
|
||||||
.service(payment_intents_confirm)
|
.service(web::resource("").route(web::post().to(payment_intents_create)))
|
||||||
.service(payment_intents_capture)
|
.service(
|
||||||
|
web::resource("/sync")
|
||||||
|
.route(web::post().to(payment_intents_retrieve_with_gateway_creds)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/{payment_id}")
|
||||||
|
.route(web::get().to(payment_intents_retrieve))
|
||||||
|
.route(web::post().to(payment_intents_update)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/{payment_id}/confirm")
|
||||||
|
.route(web::post().to(payment_intents_confirm)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/{payment_id}/capture")
|
||||||
|
.route(web::post().to(payment_intents_capture)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/{payment_id}/cancel").route(web::post().to(payment_intents_cancel)),
|
||||||
|
);
|
||||||
|
route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,10 +44,15 @@ impl SetupIntents {
|
|||||||
pub fn server(state: routes::AppState) -> Scope {
|
pub fn server(state: routes::AppState) -> Scope {
|
||||||
web::scope("/setup_intents")
|
web::scope("/setup_intents")
|
||||||
.app_data(web::Data::new(state))
|
.app_data(web::Data::new(state))
|
||||||
.service(setup_intents_create)
|
.service(web::resource("").route(web::post().to(setup_intents_create)))
|
||||||
.service(setup_intents_retrieve)
|
.service(
|
||||||
.service(setup_intents_update)
|
web::resource("/{setup_id}")
|
||||||
.service(setup_intents_confirm)
|
.route(web::get().to(setup_intents_retrieve))
|
||||||
|
.route(web::post().to(setup_intents_update)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/{setup_id}/confirm").route(web::post().to(setup_intents_confirm)),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,10 +62,15 @@ impl Refunds {
|
|||||||
pub fn server(config: routes::AppState) -> Scope {
|
pub fn server(config: routes::AppState) -> Scope {
|
||||||
web::scope("/refunds")
|
web::scope("/refunds")
|
||||||
.app_data(web::Data::new(config))
|
.app_data(web::Data::new(config))
|
||||||
.service(refund_create)
|
.service(web::resource("").route(web::post().to(refund_create)))
|
||||||
.service(refund_retrieve)
|
.service(
|
||||||
.service(refund_update)
|
web::resource("/sync").route(web::post().to(refund_retrieve_with_gateway_creds)),
|
||||||
.service(refund_retrieve_with_gateway_creds)
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/{refund_id}")
|
||||||
|
.route(web::get().to(refund_retrieve))
|
||||||
|
.route(web::post().to(refund_update)),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,11 +80,17 @@ impl Customers {
|
|||||||
pub fn server(config: routes::AppState) -> Scope {
|
pub fn server(config: routes::AppState) -> Scope {
|
||||||
web::scope("/customers")
|
web::scope("/customers")
|
||||||
.app_data(web::Data::new(config))
|
.app_data(web::Data::new(config))
|
||||||
.service(customer_create)
|
.service(web::resource("").route(web::post().to(customer_create)))
|
||||||
.service(customer_retrieve)
|
.service(
|
||||||
.service(customer_update)
|
web::resource("/{customer_id}")
|
||||||
.service(customer_delete)
|
.route(web::get().to(customer_retrieve))
|
||||||
.service(list_customer_payment_method_api)
|
.route(web::post().to(customer_update))
|
||||||
|
.route(web::delete().to(customer_delete)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/{customer_id}/payment_methods")
|
||||||
|
.route(web::get().to(list_customer_payment_method_api)),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
use actix_web::{delete, get, post, web, HttpRequest, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
use error_stack::report;
|
use error_stack::report;
|
||||||
use router_env::{instrument, tracing};
|
use router_env::{instrument, tracing};
|
||||||
|
|
||||||
@ -13,7 +13,6 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("")]
|
|
||||||
pub async fn customer_create(
|
pub async fn customer_create(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -51,7 +50,6 @@ pub async fn customer_create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[get("/{customer_id}")]
|
|
||||||
pub async fn customer_retrieve(
|
pub async fn customer_retrieve(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
@ -83,7 +81,6 @@ pub async fn customer_retrieve(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/{customer_id}")]
|
|
||||||
pub async fn customer_update(
|
pub async fn customer_update(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -124,7 +121,6 @@ pub async fn customer_update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[delete("/{customer_id}")]
|
|
||||||
pub async fn customer_delete(
|
pub async fn customer_delete(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
@ -154,7 +150,6 @@ pub async fn customer_delete(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[get("/{customer_id}/payment_methods")]
|
|
||||||
pub async fn list_customer_payment_method_api(
|
pub async fn list_customer_payment_method_api(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
use actix_web::{get, post, web, HttpRequest, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
use api_models::payments as payment_types;
|
use api_models::payments as payment_types;
|
||||||
use error_stack::report;
|
use error_stack::report;
|
||||||
use router_env::{instrument, tracing};
|
use router_env::{instrument, tracing};
|
||||||
@ -13,7 +13,6 @@ use crate::{
|
|||||||
types::api::{self as api_types},
|
types::api::{self as api_types},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[post("")]
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
pub async fn payment_intents_create(
|
pub async fn payment_intents_create(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
@ -63,7 +62,6 @@ pub async fn payment_intents_create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[get("/{payment_id}")]
|
|
||||||
pub async fn payment_intents_retrieve(
|
pub async fn payment_intents_retrieve(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
@ -112,7 +110,6 @@ pub async fn payment_intents_retrieve(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/sync")]
|
|
||||||
pub async fn payment_intents_retrieve_with_gateway_creds(
|
pub async fn payment_intents_retrieve_with_gateway_creds(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -170,7 +167,6 @@ pub async fn payment_intents_retrieve_with_gateway_creds(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/{payment_id}")]
|
|
||||||
pub async fn payment_intents_update(
|
pub async fn payment_intents_update(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -229,7 +225,6 @@ pub async fn payment_intents_update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/{payment_id}/confirm")]
|
|
||||||
pub async fn payment_intents_confirm(
|
pub async fn payment_intents_confirm(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -289,7 +284,6 @@ pub async fn payment_intents_confirm(
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/{payment_id}/capture")]
|
|
||||||
pub async fn payment_intents_capture(
|
pub async fn payment_intents_capture(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -340,7 +334,6 @@ pub async fn payment_intents_capture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/{payment_id}/cancel")]
|
|
||||||
pub async fn payment_intents_cancel(
|
pub async fn payment_intents_cancel(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -395,7 +388,6 @@ pub async fn payment_intents_cancel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[get("/list")]
|
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
pub async fn payment_intent_list(
|
pub async fn payment_intent_list(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
use actix_web::{get, post, web, HttpRequest, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
use error_stack::report;
|
use error_stack::report;
|
||||||
use router_env::{instrument, tracing};
|
use router_env::{instrument, tracing};
|
||||||
|
|
||||||
@ -13,7 +13,6 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("")]
|
|
||||||
pub async fn refund_create(
|
pub async fn refund_create(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -50,7 +49,6 @@ pub async fn refund_create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/sync")]
|
|
||||||
pub async fn refund_retrieve_with_gateway_creds(
|
pub async fn refund_retrieve_with_gateway_creds(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -91,7 +89,6 @@ pub async fn refund_retrieve_with_gateway_creds(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[get("/{refund_id}")]
|
|
||||||
pub async fn refund_retrieve(
|
pub async fn refund_retrieve(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
@ -129,7 +126,6 @@ pub async fn refund_retrieve(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/{refund_id}")]
|
|
||||||
pub async fn refund_update(
|
pub async fn refund_update(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
use actix_web::{get, post, web, HttpRequest, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
use api_models::payments as payment_types;
|
use api_models::payments as payment_types;
|
||||||
use error_stack::report;
|
use error_stack::report;
|
||||||
use router_env::{instrument, tracing};
|
use router_env::{instrument, tracing};
|
||||||
@ -13,7 +13,6 @@ use crate::{
|
|||||||
types::api as api_types,
|
types::api as api_types,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[post("")]
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
pub async fn setup_intents_create(
|
pub async fn setup_intents_create(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
@ -60,7 +59,6 @@ pub async fn setup_intents_create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[get("/{setup_id}")]
|
|
||||||
pub async fn setup_intents_retrieve(
|
pub async fn setup_intents_retrieve(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
@ -109,7 +107,6 @@ pub async fn setup_intents_retrieve(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/{setup_id}")]
|
|
||||||
pub async fn setup_intents_update(
|
pub async fn setup_intents_update(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
@ -165,7 +162,6 @@ pub async fn setup_intents_update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
#[post("/{setup_id}/confirm")]
|
|
||||||
pub async fn setup_intents_confirm(
|
pub async fn setup_intents_confirm(
|
||||||
state: web::Data<routes::AppState>,
|
state: web::Data<routes::AppState>,
|
||||||
qs_config: web::Data<serde_qs::Config>,
|
qs_config: web::Data<serde_qs::Config>,
|
||||||
|
|||||||
Reference in New Issue
Block a user