Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(proxy): Add v1 proxy endpoint and update related documentation (#11180)

Gaurav Rawat0a513d73459e
diff --git a/api-reference/docs.json b/api-reference/docs.json
index aaf78d56df..856a164176 100644
--- a/api-reference/docs.json
+++ b/api-reference/docs.json
@@ -64,7 +64,8 @@
"v2/payment-methods/payment-method--retrieve-v1",
"v2/payment-methods/payment-method--update-v1",
"v2/payment-methods/payment-method--delete-v1",
- "v2/payment-methods/payment-method--list-customer-saved-payment-methods-v1"
+ "v2/payment-methods/payment-method--list-customer-saved-payment-methods-v1",
+ "v2/payment-methods/payment-method--payment-method-token-to-payment-method-id-v1"
]
},
{
@@ -77,6 +78,12 @@
"v2/customers/customers--list-v1"
]
},
+ {
+ "group": "Proxy",
+ "pages": [
+ "v2/proxy/proxy-v1"
+ ]
+ },
{
"group": "Payment Method Session",
"pages": [
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index b80773a4e8..e95e8180b9 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -3344,7 +3344,7 @@
"value": {
"card": {
"card_exp_month": "11",
- "card_exp_year": "25",
+ "card_exp_year": "30",
"card_holder_name": "John Doe",
"card_number": "4242424242424242"
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index ac2d4906fd..c721d7b56c 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -3696,6 +3696,57 @@
]
}
},
+ "/v1/payment-methods/token/{payment_method_temporary_token}/details": {
+ "get": {
+ "tags": [
+ "Payment Methods"
+ ],
+ "summary": "Payment Method - Get Payment Method Token Data",
+ "description": "Retrieve the Payment method id associated with a payment method token.",
+ "operationId": "Get Payment Method Token Data",
+ "parameters": [
+ {
+ "name": "payment_method_temporary_token",
+ "in": "path",
+ "description": "The unique identifier for the Payment Method Token",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "X-Profile-Id",
+ "in": "header",
+ "description": "Profile ID associated to the payment method",
+ "required": true,
+ "schema": {
+ "type": "string"
+ },
+ "example": "pro_abcdefghijklmnop"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Payment Method Token Data Retrieved",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PaymentMethodGetTokenDetailsResponse"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "Payment Method Not Found | Payment method token either expired or does not exist"
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ }
+ ]
+ }
+ },
"/v2/payment-method-sessions": {
"post": {
"tags": [
@@ -4340,7 +4391,7 @@
"card": {
"card_cvc": "123",
"card_exp_month": "10",
- "card_exp_year": "25",
+ "card_exp_year": "30",
"card_number": "4242424242424242"
}
},
@@ -4417,7 +4468,7 @@
"card": {
"card_cvc": "123",
"card_exp_month": "10",
- "card_exp_year": "25",
+ "card_exp_year": "30",
"card_number": "4242424242424242"
}
},
@@ -4718,7 +4769,89 @@
]
}
},
- "/proxy": {
+ "/v2/proxy": {
+ "post": {
+ "tags": [
+ "Proxy"
+ ],
+ "summary": "Proxy",
+ "description": "Create a proxy request",
+ "operationId": "Proxy Request",
+ "parameters": [
+ {
+ "name": "X-Profile-Id",
+ "in": "header",
+ "description": "Profile ID for authentication",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ProxyRequest"
+ },
+ "examples": {
+ "Create a proxy request": {
+ "value": {
+ "destination_url": "https://api.example.com/payments",
+ "headers": {
+ "Authorization": "Bearer sk_test_example",
+ "Content-Type": "application/json"
+ },
+ "method": "POST",
+ "request_body": {
+ "amount": 6540,
+ "capture": true,
+ "currency": "USD",
+ "reference": "ORD-5023-4E89",
+ "source": {
+ "billing_address": {
+ "address_line1": "123 High St.",
+ "city": "London",
+ "country": "GB"
+ },
+ "expiry_month": "{{$card_exp_month}}",
+ "expiry_year": "{{$card_exp_year}}",
+ "number": "{{$card_number}}",
+ "type": "card"
+ }
+ },
+ "token": "pm_0196ea5a42a67583863d5b1253d62931",
+ "token_type": "PaymentMethodId"
+ }
+ }
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "Proxy request",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ProxyResponse"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid data"
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ }
+ ]
+ }
+ },
+ "/v1/proxy": {
"post": {
"tags": [
"Proxy"
diff --git a/api-reference/v2/payment-methods/payment-method--payment-method-token-to-payment-method-id-v1.mdx b/api-reference/v2/payment-methods/payment-method--payment-method-token-to-payment-method-id-v1.mdx
new file mode 100644
index 0000000000..a14b0b863a
--- /dev/null
+++ b/api-reference/v2/payment-methods/payment-method--payment-method-token-to-payment-method-id-v1.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /v1/payment-methods/token/{payment_method_temporary_token}/details
+---
\ No newline at end of file
diff --git a/api-reference/v2/proxy/proxy-v1.mdx b/api-reference/v2/proxy/proxy-v1.mdx
new file mode 100644
index 0000000000..6209ad4a0a
--- /dev/null
+++ b/api-reference/v2/proxy/proxy-v1.mdx
@@ -0,0 +1,3 @@
+---
+openapi: post /v1/proxy
+---
\ No newline at end of file
diff --git a/api-reference/v2/proxy/proxy.mdx b/api-reference/v2/proxy/proxy.mdx
index efca3f7873..df2d1b73d1 100644
--- a/api-reference/v2/proxy/proxy.mdx
+++ b/api-reference/v2/proxy/proxy.mdx
@@ -1,3 +1,3 @@
---
-openapi: post /proxy
+openapi: post /v2/proxy
---
\ No newline at end of file
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 44c63c7cce..0ca091a894 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -152,6 +152,7 @@ Never share your secret api keys. Keep them guarded and secure.
routes::payment_method::list_customer_payment_method_api,
routes::payment_method::list_customer_payment_method_api_v1,
routes::payment_method::payment_method_get_token_details_api,
+ routes::payment_method::payment_method_get_token_details_api_v1,
//Routes for payment method session
routes::payment_method::payment_method_session_create,
@@ -178,6 +179,7 @@ Never share your secret api keys. Keep them guarded and secure.
// Routes for proxy
routes::proxy::proxy_core,
+ routes::proxy::proxy_core_v1,
// Route for tokenization
routes::tokenization::create_token_vault_api,
diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs
index 2bb0b64c56..9656e34ab1 100644
--- a/crates/openapi/src/routes/payment_method.rs
+++ b/crates/openapi/src/routes/payment_method.rs
@@ -15,7 +15,7 @@
"card": {
"card_number": "4242424242424242",
"card_exp_month": "11",
- "card_exp_year": "25",
+ "card_exp_year": "30",
"card_holder_name": "John Doe"
},
"customer_id": "{{customer_id}}"
@@ -508,6 +508,31 @@ pub async fn network_token_status_check_api() {}
)]
#[cfg(feature = "v2")]
pub async fn payment_method_get_token_details_api() {}
+
+/// Payment Method - Get Payment Method Token Data
+///
+/// Retrieve the Payment method id associated with a payment method token.
+#[utoipa::path(
+ get,
+ path = "/v1/payment-methods/token/{payment_method_temporary_token}/details",
+ params (
+ ("payment_method_temporary_token" = String, Path, description = "The unique identifier for the Payment Method Token"),
+ (
+ "X-Profile-Id" = String, Header,
+ description = "Profile ID associated to the payment method",
+ example = "pro_abcdefghijklmnop"
+ )
+ ),
+ responses(
+ (status = 200, description = "Payment Method Token Data Retrieved", body = PaymentMethodGetTokenDetailsResponse),
+ (status = 404, description = "Payment Method Not Found | Payment method token either expired or does not exist"),
+ ),
+ tag = "Payment Methods",
+ operation_id = "Get Payment Method Token Data",
+ security(("api_key" = []))
+)]
+#[cfg(feature = "v2")]
+pub async fn payment_method_get_token_details_api_v1() {}
/// Payment Method - List Customer Saved Payment Methods
///
/// List the payment methods saved for a customer
@@ -938,7 +963,7 @@ pub async fn tokenize_card_using_pm_api() {}
"card": {
"card_number": "4242424242424242",
"card_exp_month": "10",
- "card_exp_year": "25",
+ "card_exp_year": "30",
"card_cvc": "123"
}
},
@@ -983,7 +1008,7 @@ pub fn payment_method_session_confirm() {}
"card": {
"card_number": "4242424242424242",
"card_exp_month": "10",
- "card_exp_year": "25",
+ "card_exp_year": "30",
"card_cvc": "123"
}
},
diff --git a/crates/openapi/src/routes/proxy.rs b/crates/openapi/src/routes/proxy.rs
index f28b732f7b..ec8e9089e0 100644
--- a/crates/openapi/src/routes/proxy.rs
+++ b/crates/openapi/src/routes/proxy.rs
@@ -4,7 +4,7 @@
/// Create a proxy request
#[utoipa::path(
post,
- path = "/proxy",
+ path = "/v2/proxy",
request_body(
content = ProxyRequest,
examples((
@@ -52,3 +52,57 @@
)]
pub async fn proxy_core() {}
+#[cfg(feature = "v2")]
+///Proxy
+///
+/// Create a proxy request
+#[utoipa::path(
+ post,
+ path = "/v1/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_v1() {}
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 09639f5698..0e5835e32f 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -903,7 +903,11 @@ pub struct Proxy;
#[cfg(all(feature = "oltp", feature = "v2"))]
impl Proxy {
pub fn server(state: AppState) -> Scope {
- web::scope("/v2/proxy")
+ let base_path = format!(
+ "/{}/proxy",
+ state.conf.micro_services.payment_methods_prefix.0
+ );
+ web::scope(&base_path)
.app_data(web::Data::new(state))
.service(web::resource("").route(web::post().to(proxy::proxy)))
}