feat(router): Add support for Proxy api (#7901)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Prasunna Soppa
2025-05-22 18:31:36 +05:30
committed by GitHub
parent 8b0fd048ab
commit 8e9bad6457
22 changed files with 707 additions and 34 deletions

View File

@ -153,7 +153,10 @@ Never share your secret api keys. Keep them guarded and secure.
routes::refunds::refunds_list,
// Routes for Revenue Recovery flow under Process Tracker
routes::revenue_recovery::revenue_recovery_pt_retrieve_api
routes::revenue_recovery::revenue_recovery_pt_retrieve_api,
// Routes for proxy
routes::proxy::proxy_core,
),
components(schemas(
common_utils::types::MinorUnit,
@ -189,6 +192,7 @@ Never share your secret api keys. Keep them guarded and secure.
common_types::refunds::SplitRefund,
common_types::payments::ConnectorChargeResponseData,
common_types::payments::StripeChargeResponseData,
common_utils::request::Method,
api_models::refunds::RefundsCreateRequest,
api_models::refunds::RefundErrorDetails,
api_models::refunds::RefundType,
@ -728,6 +732,9 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payment_methods::AuthenticationDetails,
api_models::process_tracker::revenue_recovery::RevenueRecoveryResponse,
api_models::enums::ProcessTrackerStatus,
api_models::proxy::ProxyRequest,
api_models::proxy::ProxyResponse,
api_models::proxy::TokenType,
routes::payments::ForceSync,
)),
modifiers(&SecurityAddon)

View File

@ -15,6 +15,7 @@ pub mod payments;
pub mod payouts;
pub mod poll;
pub mod profile;
pub mod proxy;
pub mod refunds;
pub mod relay;
pub mod revenue_recovery;

View File

@ -0,0 +1,54 @@
#[cfg(feature = "v2")]
///Proxy
///
/// Create a proxy request
#[utoipa::path(
post,
path = "/proxy",
request_body(
content = ProxyRequest,
examples((
"Create a proxy request" = (
value = json!({
"request_body": {
"source": {
"type": "card",
"number": "{{$card_number}}",
"expiry_month": "{{$card_exp_month}}",
"expiry_year": "{{$card_exp_year}}",
"billing_address": {
"address_line1": "123 High St.",
"city": "London",
"country": "GB"
}
},
"amount": 6540,
"currency": "USD",
"reference": "ORD-5023-4E89",
"capture": true
},
"destination_url": "https://api.example.com/payments",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer sk_test_example"
},
"token": "pm_0196ea5a42a67583863d5b1253d62931",
"token_type": "PaymentMethodId",
"method": "POST"
})
)
))
),
responses(
(status = 200, description = "Proxy request", body = ProxyResponse),
(status = 400, description = "Invalid data")
),
params(
("X-Profile-Id" = String, Header, description = "Profile ID for authentication"),
),
tag = "Proxy",
operation_id = "Proxy Request",
security(("api_key" = []))
)]
pub async fn proxy_core() {}