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

docs(openapi): document X-Integration-Type and the server-integration response on payment create and update (#14180)

Prasunna Soppae56fd505b649
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 86c2bc6ccc..4b72660647 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -31,6 +31,19 @@
"summary": "Payments - Create",
"description": "Creates a payment resource, which represents a customer's intent to pay.\nThis endpoint is the starting point for various payment flows:\n",
"operationId": "Create a Payment",
+ "parameters": [
+ {
+ "name": "X-Integration-Type",
+ "in": "header",
+ "description": "Selects the response shape. `server` returns the payment together with `payment_method_list` and `session_tokens`, so a server-to-server integration can render its checkout from one call; it is honoured only with merchant API key authentication. `client`, or no header, returns the payment response unchanged.",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "nullable": true
+ },
+ "example": "server"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
@@ -627,6 +640,90 @@
"profile_id": "pro_pzzzzzzzzzzz",
"status": "succeeded"
}
+ },
+ "12. Server integration response": {
+ "value": {
+ "amount": 6540,
+ "attempt_count": 1,
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "currency": "USD",
+ "customer_id": "cus_abcdefgh",
+ "merchant_id": "merchant_1668273825",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "payment_method_list": {
+ "customer_payment_methods": [],
+ "intent_data": {
+ "amount": 6540,
+ "attempt_count": 1,
+ "currency": "USD",
+ "customer_id": "cus_abcdefgh",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "profile_id": "pro_abcdefghijklmnop",
+ "status": "requires_payment_method"
+ },
+ "payment_methods_enabled": [
+ {
+ "card_networks": [
+ "Visa",
+ "Mastercard"
+ ],
+ "customer_acceptance_support": "supported",
+ "payment_method": "card",
+ "payment_method_type": "credit"
+ }
+ ],
+ "sdk_next_action": {
+ "next_action": "confirm"
+ }
+ },
+ "profile_id": "pro_abcdefghijklmnop",
+ "sdk_authorization": "cHJvZmlsZV9pZD1wcm9mXzEyMyxwdWJsaXNoYWJsZV9rZXk9cGtfbGl2ZV8xMjM=",
+ "session_tokens": {
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "session_token": [],
+ "vault_details": {
+ "vault_data": {
+ "sdk_authorization": "cHJvZmlsZV9pZD1wcm9mXzEyMyxwdWJsaXNoYWJsZV9rZXk9cGtfbGl2ZV8xMjM="
+ },
+ "vault_type": "hyperswitch"
+ }
+ },
+ "status": "requires_payment_method"
+ }
+ },
+ "13. Server integration, one section failed": {
+ "value": {
+ "amount": 6540,
+ "attempt_count": 1,
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "currency": "USD",
+ "merchant_id": "merchant_1668273825",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "payment_method_list": {
+ "customer_payment_methods": [],
+ "intent_data": {
+ "amount": 6540,
+ "attempt_count": 1,
+ "currency": "USD",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "status": "requires_payment_method"
+ },
+ "payment_methods_enabled": [],
+ "sdk_next_action": {
+ "next_action": "confirm"
+ }
+ },
+ "profile_id": "pro_abcdefghijklmnop",
+ "session_tokens": {
+ "error": {
+ "code": "HE_00",
+ "message": "Something went wrong",
+ "type": "api"
+ }
+ },
+ "status": "requires_payment_method"
+ }
}
}
}
@@ -667,6 +764,17 @@
"schema": {
"type": "string"
}
+ },
+ {
+ "name": "X-Integration-Type",
+ "in": "header",
+ "description": "Selects the response shape. `server` returns the payment together with `payment_method_list` and `session_tokens`, so a server-to-server integration can render its checkout from one call; it is honoured only with merchant API key authentication. `client`, or no header, returns the payment response unchanged.",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "nullable": true
+ },
+ "example": "server"
}
],
"requestBody": {
@@ -714,6 +822,92 @@
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentsCreateResponseOpenApi"
+ },
+ "examples": {
+ "Server integration response": {
+ "value": {
+ "amount": 6540,
+ "attempt_count": 1,
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "currency": "USD",
+ "customer_id": "cus_abcdefgh",
+ "merchant_id": "merchant_1668273825",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "payment_method_list": {
+ "customer_payment_methods": [],
+ "intent_data": {
+ "amount": 6540,
+ "attempt_count": 1,
+ "currency": "USD",
+ "customer_id": "cus_abcdefgh",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "profile_id": "pro_abcdefghijklmnop",
+ "status": "requires_payment_method"
+ },
+ "payment_methods_enabled": [
+ {
+ "card_networks": [
+ "Visa",
+ "Mastercard"
+ ],
+ "customer_acceptance_support": "supported",
+ "payment_method": "card",
+ "payment_method_type": "credit"
+ }
+ ],
+ "sdk_next_action": {
+ "next_action": "confirm"
+ }
+ },
+ "profile_id": "pro_abcdefghijklmnop",
+ "sdk_authorization": "cHJvZmlsZV9pZD1wcm9mXzEyMyxwdWJsaXNoYWJsZV9rZXk9cGtfbGl2ZV8xMjM=",
+ "session_tokens": {
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "session_token": [],
+ "vault_details": {
+ "vault_data": {
+ "sdk_authorization": "cHJvZmlsZV9pZD1wcm9mXzEyMyxwdWJsaXNoYWJsZV9rZXk9cGtfbGl2ZV8xMjM="
+ },
+ "vault_type": "hyperswitch"
+ }
+ },
+ "status": "requires_payment_method"
+ }
+ },
+ "Server integration, one section failed": {
+ "value": {
+ "amount": 6540,
+ "attempt_count": 1,
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "currency": "USD",
+ "merchant_id": "merchant_1668273825",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "payment_method_list": {
+ "customer_payment_methods": [],
+ "intent_data": {
+ "amount": 6540,
+ "attempt_count": 1,
+ "currency": "USD",
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "status": "requires_payment_method"
+ },
+ "payment_methods_enabled": [],
+ "sdk_next_action": {
+ "next_action": "confirm"
+ }
+ },
+ "profile_id": "pro_abcdefghijklmnop",
+ "session_tokens": {
+ "error": {
+ "code": "HE_00",
+ "message": "Something went wrong",
+ "type": "api"
+ }
+ },
+ "status": "requires_payment_method"
+ }
+ }
}
}
}
diff --git a/crates/openapi/src/routes/payments.rs b/crates/openapi/src/routes/payments.rs
index 113b710251..00f81af29a 100644
--- a/crates/openapi/src/routes/payments.rs
+++ b/crates/openapi/src/routes/payments.rs
@@ -553,11 +553,94 @@
"attempt_count": 1,
"expires_on": "2023-10-26T10:45:00Z"
})
+ )),
+ ("12. Server integration response" = (
+ value = json!({
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "merchant_id": "merchant_1668273825",
+ "status": "requires_payment_method",
+ "amount": 6540,
+ "currency": "USD",
+ "customer_id": "cus_abcdefgh",
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "sdk_authorization": "cHJvZmlsZV9pZD1wcm9mXzEyMyxwdWJsaXNoYWJsZV9rZXk9cGtfbGl2ZV8xMjM=",
+ "profile_id": "pro_abcdefghijklmnop",
+ "attempt_count": 1,
+ "payment_method_list": {
+ "payment_methods_enabled": [
+ {
+ "payment_method": "card",
+ "payment_method_type": "credit",
+ "card_networks": ["Visa", "Mastercard"],
+ "customer_acceptance_support": "supported"
+ }
+ ],
+ "customer_payment_methods": [],
+ "sdk_next_action": { "next_action": "confirm" },
+ "intent_data": {
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "status": "requires_payment_method",
+ "amount": 6540,
+ "currency": "USD",
+ "customer_id": "cus_abcdefgh",
+ "profile_id": "pro_abcdefghijklmnop",
+ "attempt_count": 1
+ }
+ },
+ "session_tokens": {
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "session_token": [],
+ "vault_details": {
+ "vault_type": "hyperswitch",
+ "vault_data": {
+ "sdk_authorization": "cHJvZmlsZV9pZD1wcm9mXzEyMyxwdWJsaXNoYWJsZV9rZXk9cGtfbGl2ZV8xMjM="
+ }
+ }
+ }
+ })
+ )),
+ ("13. Server integration, one section failed" = (
+ value = json!({
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "merchant_id": "merchant_1668273825",
+ "status": "requires_payment_method",
+ "amount": 6540,
+ "currency": "USD",
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "profile_id": "pro_abcdefghijklmnop",
+ "attempt_count": 1,
+ "payment_method_list": {
+ "payment_methods_enabled": [],
+ "customer_payment_methods": [],
+ "sdk_next_action": { "next_action": "confirm" },
+ "intent_data": {
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "status": "requires_payment_method",
+ "amount": 6540,
+ "currency": "USD",
+ "attempt_count": 1
+ }
+ },
+ "session_tokens": {
+ "error": {
+ "type": "api",
+ "message": "Something went wrong",
+ "code": "HE_00"
+ }
+ }
+ })
))
)
),
(status = 400, description = "Missing Mandatory fields", body = GenericErrorResponseOpenApi),
),
+ params(
+ ("X-Integration-Type" = Option<String>, Header, description = "Selects the response shape. `server` returns the payment together with \
+ `payment_method_list` and `session_tokens`, so a server-to-server integration can render \
+ its checkout from one call; it is honoured only with merchant API key authentication. \
+ `client`, or no header, returns the payment response unchanged.", example = "server")
+ ),
tag = "Payments",
operation_id = "Create a Payment",
security(("api_key" = [])),
@@ -594,7 +677,11 @@ pub fn payments_retrieve() {}
post,
path = "/payments/{payment_id}",
params(
- ("payment_id" = String, Path, description = "The identifier for payment")
+ ("payment_id" = String, Path, description = "The identifier for payment"),
+ ("X-Integration-Type" = Option<String>, Header, description = "Selects the response shape. `server` returns the payment together with \
+ `payment_method_list` and `session_tokens`, so a server-to-server integration can render \
+ its checkout from one call; it is honoured only with merchant API key authentication. \
+ `client`, or no header, returns the payment response unchanged.", example = "server")
),
request_body(
content = PaymentsUpdateRequest,
@@ -635,7 +722,87 @@ pub fn payments_retrieve() {}
)
),
responses(
- (status = 200, description = "Payment updated", body = PaymentsCreateResponseOpenApi),
+ (status = 200, description = "Payment updated", body = PaymentsCreateResponseOpenApi,
+ examples(
+ ("Server integration response" = (
+ value = json!({
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "merchant_id": "merchant_1668273825",
+ "status": "requires_payment_method",
+ "amount": 6540,
+ "currency": "USD",
+ "customer_id": "cus_abcdefgh",
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "sdk_authorization": "cHJvZmlsZV9pZD1wcm9mXzEyMyxwdWJsaXNoYWJsZV9rZXk9cGtfbGl2ZV8xMjM=",
+ "profile_id": "pro_abcdefghijklmnop",
+ "attempt_count": 1,
+ "payment_method_list": {
+ "payment_methods_enabled": [
+ {
+ "payment_method": "card",
+ "payment_method_type": "credit",
+ "card_networks": ["Visa", "Mastercard"],
+ "customer_acceptance_support": "supported"
+ }
+ ],
+ "customer_payment_methods": [],
+ "sdk_next_action": { "next_action": "confirm" },
+ "intent_data": {
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "status": "requires_payment_method",
+ "amount": 6540,
+ "currency": "USD",
+ "customer_id": "cus_abcdefgh",
+ "profile_id": "pro_abcdefghijklmnop",
+ "attempt_count": 1
+ }
+ },
+ "session_tokens": {
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "session_token": [],
+ "vault_details": {
+ "vault_type": "hyperswitch",
+ "vault_data": {
+ "sdk_authorization": "cHJvZmlsZV9pZD1wcm9mXzEyMyxwdWJsaXNoYWJsZV9rZXk9cGtfbGl2ZV8xMjM="
+ }
+ }
+ }
+ })
+ )),
+ ("Server integration, one section failed" = (
+ value = json!({
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "merchant_id": "merchant_1668273825",
+ "status": "requires_payment_method",
+ "amount": 6540,
+ "currency": "USD",
+ "client_secret": "pay_mbabizu24mvu3mela5njyhpit4_secret_el9ksDkiB8hi6j9N78yo",
+ "profile_id": "pro_abcdefghijklmnop",
+ "attempt_count": 1,
+ "payment_method_list": {
+ "payment_methods_enabled": [],
+ "customer_payment_methods": [],
+ "sdk_next_action": { "next_action": "confirm" },
+ "intent_data": {
+ "payment_id": "pay_mbabizu24mvu3mela5njyhpit4",
+ "status": "requires_payment_method",
+ "amount": 6540,
+ "currency": "USD",
+ "attempt_count": 1
+ }
+ },
+ "session_tokens": {
+ "error": {
+ "type": "api",
+ "message": "Something went wrong",
+ "code": "HE_00"
+ }
+ }
+ })
+ ))
+ )
+ ),
(status = 400, description = "Missing mandatory fields", body = GenericErrorResponseOpenApi)
),
tag = "Payments",