Payment Intent Reference
Endpoint
POST /payment-intent
What this endpoint does
Creates a payment intent for an e-commerce checkout transaction and returns a PaymentUrl that can be used to direct the member to the Capricorn hosted checkout experience. The payment intent contains the transaction context required to complete the payment journey using Capricorn's hosted payment pages.
Request Headers
In the tables below, Required indicates that Capricorn cannot process the request without that value.
| Header | Type | Required | Description | Constraints | Example |
|---|---|---|---|---|---|
client_id | string | Yes | Client application identifier for the calling system. | 32-character alphanumeric, pattern ^([A-Za-z0-9]){32}$ | 0123456789ABCDEF0123456789ABCDEF |
client_secret | string | Yes | Client application secret for the calling system. | 32-character alphanumeric, pattern ^([A-Za-z0-9]){32}$ | ABCDEF0123456789ABCDEF0123456789 |
x-captoken | string | Yes | Mandatory Capricorn authorization token for the approved request context. | 64-character SHA-256 hash, pattern ^[a-fA-F0-9]64$ | opaque-token |
X-Correlation-ID | string | No | Optional correlation value used for tracing and support. | Pattern ^[0-9a-zA-Z(\-){}]+$, min length 1 | a0235ed0-d884-11ef-957a-005056afc7ce |
URI / Query Parameters
| Parameter | Type | Required | Description | Constraints | Example |
|---|---|---|---|---|---|
| None | n/a | No | This endpoint does not define URI or query parameters. | n/a | n/a |
Request Body
Requests to this endpoint must use Content-Type: application/json.
Creates a payment intent for an e-commerce checkout transaction and returns a hosted checkout URL. The request body contains the transaction, member, supplier, and callback information required to establish the checkout session. authContextToken is an optional value obtained through the Member Identity Handover flow and can be provided when an authenticated member context is available.
Callback URL domains should be registered during supplier onboarding. Callback URLs should use approved HTTPS domains.
Retain the state value supplied when creating the Payment Intent. When the member returns through the configured callback URL, validate that the returned state value matches the value originally associated with the checkout session.
The cartId used when creating the Payment Intent should remain consistent throughout the hosted checkout and final transaction submission flow.
memberId: Six-digit numeric Capricorn member identifier. supplierId: Six-digit numeric Capricorn supplier identifier.
If a Member ID contains fewer than six digits, include leading zeros when constructing the request. Examples: 001234, 000321, 088776, 000077
{
"transactionAmount": 99.99,
"transactionDate": "2024-03-13T08:49:53.542555Z",
"memberId": "111555",
"supplierId": "000000",
"authContextToken": "TEST-AUTH-CONTEXT-TOKEN-ABC123",
"checkoutReference": "CHK-20250908-00001",
"cartId": "123456XY",
"state": "checkout-state-token-20250908-00001",
"callbackUrls": {
"success": "https://callbacks.acmeparts.example.com/payments/success",
"failure": "https://callbacks.acmeparts.example.com/payments/failure",
"cancel": "https://callbacks.acmeparts.example.com/payments/cancel"
}
}
| Field | Type | Required | Description | Constraints / Example |
|---|---|---|---|---|
transactionAmount | number | Yes | Dollar value of the transaction. | Minimum 0.01, multipleOf: 0.01; 99.99 |
transactionDate | string (date-time) | Yes | Transaction timestamp in Zulu/UTC. | 2024-03-13T08:49:53.542555Z |
memberId | string | Yes | Six-digit numeric Capricorn member identifier. | Min length 2, max length 6; 111555 |
supplierId | string | Yes | Six-digit numeric Capricorn supplier identifier. | Min length 2, max length 6; 000000 |
checkoutReference | string | Yes | Caller-defined checkout reference. | CHK-20250908-00001 |
cartId | string | Yes | Cart identifier. | Pattern ^[a-zA-Z0-9_-]+$; maximum length 40; 123456XY |
state | string | Yes | Opaque state-management value returned through the checkout journey. | Max length 50; checkout-state-token-20250908-00001 |
callbackUrls | object | Yes | Browser callback URLs. | See nested fields below. |
callbackUrls.success | string | Yes | Valid HTTPS URL. | Pattern ^https://.+$; https://callbacks.acmeparts.example.com/payments/success |
callbackUrls.failure | string | Yes | Valid HTTPS URL. | URL string; HTTPS example https://callbacks.acmeparts.example.com/payments/failure |
callbackUrls.cancel | string | Yes | Valid HTTPS URL. | URL string; HTTPS example https://callbacks.acmeparts.example.com/payments/cancel |
authContextToken | string | No | Optional token supplied from the Member Identity Handover flow. When provided, it links the Payment Intent to an authenticated Capricorn member context. | TEST-AUTH-CONTEXT-TOKEN-ABC123 |
Code Examples
Replace the example credentials with the values provided during onboarding. If the example includes a supplierId, use your own supplier ID associated with your x-captoken.
- cURL
- HTTP
- JavaScript
- Python
- C
- Java
curl -X POST 'https://api.capricorn.example.com/payment-intent' \
-H 'Content-Type: application/json' \
-H 'client_id: 0123456789ABCDEF0123456789ABCDEF' \
-H 'client_secret: ABCDEF0123456789ABCDEF0123456789' \
-H 'x-captoken: opaque-token' \
-H 'username: api.user' \
-H 'X-Correlation-ID: a0235ed0-d884-11ef-957a-005056afc7ce' \
-d '{
"transactionAmount": 99.99,
"transactionDate": "2024-03-13T08:49:53.542555Z",
"memberId": "111555",
"supplierId": "000000",
"authContextToken": "TEST-AUTH-CONTEXT-TOKEN-ABC123",
"checkoutReference": "CHK-20250908-00001",
"cartId": "123456XY",
"state": "checkout-state-token-20250908-00001",
"callbackUrls": {
"success": "https://callbacks.acmeparts.example.com/payments/success",
"failure": "https://callbacks.acmeparts.example.com/payments/failure",
"cancel": "https://callbacks.acmeparts.example.com/payments/cancel"
}
}'
POST /payment-intent HTTP/1.1
Host: api.capricorn.example.com
Content-Type: application/json
client_id: 0123456789ABCDEF0123456789ABCDEF
client_secret: ABCDEF0123456789ABCDEF0123456789
x-captoken: opaque-token
username: api.user
X-Correlation-ID: a0235ed0-d884-11ef-957a-005056afc7ce
{
"transactionAmount": 99.99,
"transactionDate": "2024-03-13T08:49:53.542555Z",
"memberId": "111555",
"supplierId": "000000",
"authContextToken": "TEST-AUTH-CONTEXT-TOKEN-ABC123",
"checkoutReference": "CHK-20250908-00001",
"cartId": "123456XY",
"state": "checkout-state-token-20250908-00001",
"callbackUrls": {
"success": "https://callbacks.acmeparts.example.com/payments/success",
"failure": "https://callbacks.acmeparts.example.com/payments/failure",
"cancel": "https://callbacks.acmeparts.example.com/payments/cancel"
}
}
const payload = {
"transactionAmount": 99.99,
"transactionDate": "2024-03-13T08:49:53.542555Z",
"memberId": "111555",
"supplierId": "000000",
"authContextToken": "TEST-AUTH-CONTEXT-TOKEN-ABC123",
"checkoutReference": "CHK-20250908-00001",
"cartId": "123456XY",
"state": "checkout-state-token-20250908-00001",
"callbackUrls": {
"success": "https://callbacks.acmeparts.example.com/payments/success",
"failure": "https://callbacks.acmeparts.example.com/payments/failure",
"cancel": "https://callbacks.acmeparts.example.com/payments/cancel"
}
};
const response = await fetch('https://api.capricorn.example.com/payment-intent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'client_id': '0123456789ABCDEF0123456789ABCDEF',
'client_secret': 'ABCDEF0123456789ABCDEF0123456789',
'x-captoken': 'opaque-token',
'username': 'api.user',
'X-Correlation-ID': 'a0235ed0-d884-11ef-957a-005056afc7ce',
},
body: JSON.stringify(payload),
});
const data = await response.json();
console.log(data);
import requests
payload = {
"transactionAmount": 99.99,
"transactionDate": "2024-03-13T08:49:53.542555Z",
"memberId": "111555",
"supplierId": "000000",
"authContextToken": "TEST-AUTH-CONTEXT-TOKEN-ABC123",
"checkoutReference": "CHK-20250908-00001",
"cartId": "123456XY",
"state": "checkout-state-token-20250908-00001",
"callbackUrls": {
"success": "https://callbacks.acmeparts.example.com/payments/success",
"failure": "https://callbacks.acmeparts.example.com/payments/failure",
"cancel": "https://callbacks.acmeparts.example.com/payments/cancel"
}
}
response = requests.request(
'POST',
'https://api.capricorn.example.com/payment-intent',
headers={
'Content-Type': 'application/json',
'client_id': '0123456789ABCDEF0123456789ABCDEF',
'client_secret': 'ABCDEF0123456789ABCDEF0123456789',
'x-captoken': 'opaque-token',
'username': 'api.user',
'X-Correlation-ID': 'a0235ed0-d884-11ef-957a-005056afc7ce',
},
json=payload,
)
print(response.status_code)
print(response.json())
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
if (!curl) return 1;
curl_easy_setopt(curl, CURLOPT_URL, "https://api.capricorn.example.com/payment-intent");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "client_id: 0123456789ABCDEF0123456789ABCDEF");
headers = curl_slist_append(headers, "client_secret: ABCDEF0123456789ABCDEF0123456789");
headers = curl_slist_append(headers, "x-captoken: opaque-token");
headers = curl_slist_append(headers, "username: api.user");
headers = curl_slist_append(headers, "X-Correlation-ID: a0235ed0-d884-11ef-957a-005056afc7ce");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *payload = "{\"transactionAmount\":99.99,\"transactionDate\":\"2024-03-13T08:49:53.542555Z\",\"memberId\":\"111555\",\"supplierId\":\"000000\",\"authContextToken\":\"TEST-AUTH-CONTEXT-TOKEN-ABC123\",\"checkoutReference\":\"CHK-20250908-00001\",\"cartId\":\"123456XY\",\"state\":\"checkout-state-token-20250908-00001\",\"callbackUrls\":{\"success\":\"https://callbacks.acmeparts.example.com/payments/success\",\"failure\":\"https://callbacks.acmeparts.example.com/payments/failure\",\"cancel\":\"https://callbacks.acmeparts.example.com/payments/cancel\"}}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String payload = "{\"transactionAmount\":99.99,\"transactionDate\":\"2024-03-13T08:49:53.542555Z\",\"memberId\":\"111555\",\"supplierId\":\"000000\",\"authContextToken\":\"TEST-AUTH-CONTEXT-TOKEN-ABC123\",\"checkoutReference\":\"CHK-20250908-00001\",\"cartId\":\"123456XY\",\"state\":\"checkout-state-token-20250908-00001\",\"callbackUrls\":{\"success\":\"https://callbacks.acmeparts.example.com/payments/success\",\"failure\":\"https://callbacks.acmeparts.example.com/payments/failure\",\"cancel\":\"https://callbacks.acmeparts.example.com/payments/cancel\"}}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create("https://api.capricorn.example.com/payment-intent"))
.header("Content-Type", "application/json")
.header("client_id", "0123456789ABCDEF0123456789ABCDEF")
.header("client_secret", "ABCDEF0123456789ABCDEF0123456789")
.header("x-captoken", "opaque-token")
.header("username", "api.user")
.header("X-Correlation-ID", "a0235ed0-d884-11ef-957a-005056afc7ce")
.method("POST", HttpRequest.BodyPublishers.ofString(payload));
HttpResponse<String> response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
Responses
X-Correlation-ID is generated automatically if omitted and may appear as correlationId in the response body.
201 Created
Returned when Capricorn successfully creates the payment intent and allocates a hosted checkout URL.
| Field | Type | Description | Example |
|---|---|---|---|
PaymentUrl | string | Capricorn-hosted checkout URL that the client should redirect the user to. | https://checkout.capricorn.example/XXXXXX |
{
"PaymentUrl": "https://checkout.capricorn.example/XXXXXX"
}
400 Bad Request
Returned when required headers or request-body fields are missing, malformed, or outside the documented constraints.
| Field | Type | Description | Example |
|---|---|---|---|
error.type | string | Error category for request-shape or validation problems. | CAP:BAD_REQUEST |
error.description | string | Short summary of the failure category. | Bad request |
error.message | string | Message describing what to correct before retrying. | Invalid Request, Please validate the request message. |
{
"error": {
"type": "CAP:BAD_REQUEST",
"description": "Bad request",
"message": "Invalid Request, Please validate the request message."
}
}
401 Unauthorized
Returned when client_id or client_secret is missing or invalid.
| Field | Type | Description | Example |
|---|---|---|---|
error.type | string | Error category returned when authentication fails. | CAP:UNAUTHORIZED |
error.description | string | Short summary of the authentication failure. | Unauthorized |
error.message | string | Explains that the supplied client credentials were rejected. | Client id or secret is invalid. |
{
"error": {
"type": "CAP:UNAUTHORIZED",
"description": "Unauthorized",
"message": "Client id or secret is invalid."
}
}
422 Unprocessable Entity
Returned when the payment intent request is understood but cannot be processed.
| Field | Type | Description | Example |
|---|---|---|---|
error.type | string | Error category for semantically invalid requests. | CAP:UNPROCESSABLE_ENTITY |
error.description | string | Short summary of the semantic failure. | Unable to process the contained instructions(422) |
error.message | string | Explains why the API could not continue processing the request. | Unable to process the request due to Business Rules failure |
{
"error": {
"type": "CAP:UNPROCESSABLE_ENTITY",
"description": "Unable to process the contained instructions(422)",
"message": "Unable to process the request due to Business Rules failure"
}
}
429 Too Many Requests
Returned when the caller exceeds the API rate limit.
| Field | Type | Description | Example |
|---|---|---|---|
message | string | Rate-limit message returned when too many requests are sent in a short period. | Too Many Requests |
{
"message": "Too Many Requests"
}
500 Internal Server Error
Returned when the API encounters an unexpected server-side failure while creating the payment intent.
| Field | Type | Description | Example |
|---|---|---|---|
error.type | string | Error category for unexpected server-side failures. | CAP:INTERNAL_SERVER_ERROR |
error.description | string | Short summary of the server-side error. | Internal server error |
error.message | string | Advises the client to retry later. | API encountered an unexpected error. Please retry later. |
{
"error": {
"type": "CAP:INTERNAL_SERVER_ERROR",
"description": "Internal server error",
"message": "API encountered an unexpected error. Please retry later."
}
}
503 Service Unavailable
Returned when a backend dependency is unavailable or times out while creating the payment intent.
Response headers
| Header | Type | Description |
|---|---|---|
Retry-After | string | Optional delay, in seconds, that the client should wait before retrying the request. |
Response Body
| Field | Type | Description | Example |
|---|---|---|---|
error.type | string | Error category for temporary downstream or platform outages. | CAP:SERVICE_UNAVAILABLE |
error.description | string | Short summary of the availability issue. | Service unavailable |
error.message | string | Indicates the API timed out or could not reach a backend service. | A timeout occurred while processing the request. |
{
"error": {
"type": "CAP:SERVICE_UNAVAILABLE",
"description": "Service unavailable",
"message": "A timeout occurred while processing the request."
}
}