Checkout Sessions

A Checkout Session is a hosted payment page. You create one with the amount, currency, and where to send the customer afterward, then redirect them to session.url. They pay on our page; you get a webhook when the payment lands.

Each session creates and owns a Payment Intent. Use the Payment Intent's status to check whether you got paid.

Related guide: How it works.

The Checkout Session object

idstring
Unique identifier, prefixed cs_.
objectstring
Always "checkout_session".
statusenum
open, complete, expired, or canceled.
modeenum
"payment" or "setup". Use "setup" to vault a card without charging.
amountinteger|null
Amount to charge, in the smallest currency unit. 5000 = $50.00 USD. Null in setup mode.
currencystring|null
ISO 4217 currency code, uppercase. Null in setup mode.
urlstring
The hosted checkout URL. Redirect your customer here.
payment_intentstring|null
ID of the Payment Intent created with this session. Null in setup mode. Use this to check payment status.
client_secretstring
Not needed by CxPay.embed(): pass the session id instead. Keep this secret out of logs and analytics. Hosted checkout uses the returned url.
customerstring|null
ID of the attached customer, if provided at create.
setup_intentstring|null
ID of the SetupIntent created when mode is "setup". Null for payment mode.
payment_methodsarray
Payment method types accepted for this session.
capture_methodenum|null
"automatic" or "manual". Null in setup mode.
setup_future_usageenum|null
"off_session", "on_session", or null. Set if the card will be vaulted on success.
return_urlnullable string
Where to redirect on success.
cancel_urlnullable string
Where to redirect on cancel.
descriptionnullable string
Free-form description used on receipts.
line_itemsarray|null
Itemized breakdown. null if none provided.
metadataobject
Up to 50 key-value pairs of your own data.
expires_atstring
ISO-8601 timestamp when the session expires.
livemodeboolean
true for live mode, false for test.
created_atstring
ISO-8601 timestamp when the session was created.
THE CHECKOUT SESSION OBJECT
JSON
1{
2 "id": "cs_01JQXYZ...",
3 "object": "checkout_session",
4 "status": "open",
5 "mode": "payment",
6 "amount": 5000,
7 "currency": "USD",
8 "url": "https://pay.cxpay.net/cs/cs_01JQXYZ...",
9 "client_secret": "pi_01JQ..._secret_abc123",
10 "payment_intent": "pi_01JQ...",
11 "return_url": "https://yoursite.com/success",
12 "cancel_url": "https://yoursite.com/cancel",
13 "description": null,
14 "line_items": null,
15 "metadata": { "order_id": "ORD-123" },
16 "expires_at": "2026-04-07T19:00:00.000Z",
17 "livemode": false,
18 "created_at": "2026-04-07T18:30:00.000Z"
19}

Was this section helpful?

Create a Checkout Session

POST/v1/checkout-sessions

Creates a checkout session and an underlying Payment Intent. Returns a hosted URL and the Payment Intent id you should persist.

Requires the Idempotency-Key header. Use a UUID v4. If your request fails mid-flight, retry with the same key — we'll return the original response rather than create a duplicate session. A 4xx or 5xx response isn't replayed: the request runs again.

Body parameters

modestringRequired
"payment" to collect a payment, or "setup" to vault a card without charging.
amountinteger
Amount in the smallest currency unit. 5000 = $50.00 USD. Required unless line_items is provided (in which case the total is derived from the items).
currencystring
ISO 4217 code, e.g. "USD", "EUR", "TTD". Required for payment mode; omit for setup mode.
return_urlstring
Public HTTPS URL the customer is sent to after completing checkout. Its origin must be registered in this MerchantOrg's return domains for the API key's test or live mode. Localhost and IP addresses are refused in both modes; use an HTTPS tunnel for local testing.
cancel_urlstring
Public HTTPS URL the customer is sent to on cancel. The same return-domain rule applies. An off-list URL returns 400 INVALID_RETURN_URL; an edge block may return 403 first.
descriptionstring
For receipts and your records. Max 500 chars.
metadataobject
Up to 50 key-value pairs.
line_itemsarray
Itemized breakdown. If passed alongside amount, totals must match.
expires_ininteger
Time-to-live in seconds. Default 1800 (30 min). Range 300–86400.
customer_emailstring
Looks up an existing Customer by email (dedup) and links it to the session, or mints a new Customer if none exists. Provide customer instead to attach a specific customer by id. When minting a new Customer, customer_name is required.
customerstring
cus_... — attach an existing customer. Saved cards and mandate references flow through this customer.
customer_namestring
Full name of the customer. Required when customer_email is provided without a customer id — a new Customer cannot be minted without a name.
setup_future_usageenum
"off_session" | "on_session" — vault the card on success for future charges.
capture_methodenum
"automatic" (default) or "manual" for auth-then-capture flow.

Line item shape

namestringRequired
Display name. Max 200 chars.
quantityintegerRequired
Number of units. Min 1.
unit_amountintegerRequired
Price per unit, smallest currency unit.
descriptionstring
Item description. Max 500 chars.

Errors

400UNSUPPORTED_CURRENCY_PRECISION
The currency does not use 2 decimals. 0- and 3-decimal currencies, such as JPY, KWD, IQD and LYD, are refused when a Checkout Session or PaymentIntent is created, when a payment starts and when it is confirmed.
400CURRENCY_NOT_SUPPORTED
The currency is not enabled for this MerchantOrg in this mode.
400NO_PAYMENT_CAPABILITY
This MerchantOrg has no currency enabled in this mode.
400bad_request
Missing field, invalid currency, or line items don't sum to amount.
401unauthorized
Bad signature, expired timestamp, or unknown key.
409conflict
Idempotency-Key reused with a different body.
429rate_limited
Too many requests.
REQUEST
1curl https://api.cxpay.net/v1/checkout-sessions \
2 -H "X-Key-Id: ak_test_..." \
3 -H "X-Signature: <base64-hmac>" \
4 -H "X-Timestamp: 2026-04-07T18:30:00.000Z" \
5 -H "X-Nonce: 550e8400-e29b-41d4-a716-446655440000" \
6 -H "X-Body-Hash: <sha256-hex>" \
7 -H "Idempotency-Key: 550e8400-e29b-41d4-a716-446655440001" \
8 -H "Content-Type: application/json" \
9 -d '{
10 "mode": "payment",
11 "amount": 5000,
12 "currency": "USD",
13 "return_url": "https://yoursite.com/success",
14 "cancel_url": "https://yoursite.com/cancel",
15 "metadata": { "order_id": "ORD-123" }
16 }'
TestPOST /v1/checkout-sessions
RESPONSE
JSON
1{
2 "id": "cs_01JQXYZ...",
3 "object": "checkout_session",
4 "status": "open",
5 "mode": "payment",
6 "amount": 5000,
7 "currency": "USD",
8 "url": "https://pay.cxpay.net/cs/cs_01JQXYZ...",
9 "client_secret": "pi_01JQ..._secret_abc123",
10 "payment_intent": "pi_01JQ...",
11 "return_url": "https://yoursite.com/success",
12 "cancel_url": "https://yoursite.com/cancel",
13 "description": null,
14 "line_items": null,
15 "metadata": { "order_id": "ORD-123" },
16 "expires_at": "2026-04-07T19:00:00.000Z",
17 "livemode": false,
18 "created_at": "2026-04-07T18:30:00.000Z"
19}

Was this section helpful?

Retrieve a Checkout Session

GET/v1/checkout-sessions/:id

Returns a single Checkout Session by id. Useful when you want to check the session status server-side after a webhook delay.

Path parameters

idstringRequired
The Checkout Session id, prefixed cs_.

Errors

401unauthorized
Bad signature, expired timestamp, or unknown key.
404not_found
Session doesn't exist or belongs to a different account.
RESPONSE
JSON
1{
2 "id": "cs_01JQXYZ...",
3 "object": "checkout_session",
4 "status": "open",
5 "mode": "payment",
6 "amount": 5000,
7 "currency": "USD",
8 "url": "https://pay.cxpay.net/cs/cs_01JQXYZ...",
9 "client_secret": "pi_01JQ..._secret_abc123",
10 "payment_intent": "pi_01JQ...",
11 "return_url": "https://yoursite.com/success",
12 "cancel_url": "https://yoursite.com/cancel",
13 "description": null,
14 "line_items": null,
15 "metadata": { "order_id": "ORD-123" },
16 "expires_at": "2026-04-07T19:00:00.000Z",
17 "livemode": false,
18 "created_at": "2026-04-07T18:30:00.000Z"
19}

Was this section helpful?

List Checkout Sessions

GET/v1/checkout-sessions

Returns a paginated list of Checkout Sessions, newest first.

Query parameters

limitinteger
1–100, default 10.
statusenum
Filter by status: open, complete, expired, or canceled.
cursorstring
Pagination cursor from the previous response.

The response wraps the array in data, with has_more (boolean) and next_cursor (the cursor to pass on the next request, or null when there are no more results).

REQUEST
1curl "https://api.cxpay.net/v1/checkout-sessions?limit=20" \
2 -H "X-Key-Id: ak_test_..." \
3 -H "X-Signature: <base64-hmac>" \
4 -H "X-Timestamp: 2026-04-07T18:30:00.000Z" \
5 -H "X-Nonce: 550e8400-..." \
6 -H "X-Body-Hash: <sha256-of-empty>"
TestGET /v1/checkout-sessions?limit=20

Was this section helpful?

Update a Checkout Session

PATCH/v1/checkout-sessions/:id

Changes the metadata or payment_methods of an open Checkout Session.

Everything the session shares with its payment is fixed at creation: the amount, line items, return and cancel URLs and expiry. To change the total, cancel the session and create a new one; a new session always charges exactly what it was created with.

Body parameters

metadataobject
Replace the metadata map. Up to 50 keys.
payment_methodsarray
Replace the accepted payment method types.

Errors

400CHECKOUT_SESSION_FIELD_NOT_UPDATABLE
The body has amount, line_items, return_url, cancel_url or expires_at. The error's details name the field.
404not_found
Session doesn't exist or belongs to a different account.
409conflict
The session's Payment Intent is mid-flight (processing or requires_action) and can't be changed yet.
410gone
Session is in a terminal status (complete, expired, or canceled).
REQUEST
1curl -X PATCH https://api.cxpay.net/v1/checkout-sessions/cs_01JQXYZ... \
2 -H "X-Key-Id: ak_test_..." \
3 -H "Content-Type: application/json" \
4 -H "X-Signature: <base64-hmac>" \
5 -H "X-Timestamp: 2026-04-07T18:30:00.000Z" \
6 -H "X-Nonce: 550e8400-..." \
7 -H "X-Body-Hash: <sha256-of-body>" \
8 -d '{ "metadata": { "order_id": "ORD-456" } }'
TestPATCH /v1/checkout-sessions/cs_01JQXYZ...

Was this section helpful?

Cancel a Checkout Session

POST/v1/checkout-sessions/:id/cancel

Cancels an open Checkout Session and its underlying Payment Intent. Returns the canceled session object.

Errors

404not_found
Session doesn't exist or belongs to a different account.
409CHECKOUT_SESSION_MID_FLIGHT
The session's Payment Intent is processing, requires_action, uncertain or requires_review, or its SetupIntent is processing or requires_action. The session is not canceled. Do not start a new payment for this order. For uncertain, keep retrieving the Payment Intent: it can move to requires_review, which sends no webhook. For requires_review, contact support.
410gone
Session is already complete or expired. (Canceling an already-canceled session is idempotent — returns 200 with the canceled session.)
REQUEST
1curl -X POST https://api.cxpay.net/v1/checkout-sessions/cs_01JQXYZ.../cancel \
2 -H "X-Key-Id: ak_test_..." \
3 -H "X-Signature: <base64-hmac>" \
4 -H "X-Timestamp: 2026-04-07T18:30:00.000Z" \
5 -H "X-Nonce: 550e8400-..." \
6 -H "X-Body-Hash: <sha256-of-empty>"
TestPOST /v1/checkout-sessions/cs_01JQXYZ.../cancel

Was this section helpful?

List payment method types

GET/v1/payment-method-types

Returns the payment methods a checkout would offer your account right now, in the order checkout lists them. Use it to show payment options on your own page before you create a Checkout Session. Methods you or CX Pay switched off are left out, and the list follows the key's mode. A method with requires_conversion is left out at checkout if no exchange rate is available at that moment.

Query parameters

currencystring
ISO 4217 code, uppercase. Leaves out methods that cannot take a payment in this currency.

Each item

typestring
Method identifier: card, apple_pay, ideal and so on. New values appear as CX Pay adds methods; skip ones you don't render yet rather than rejecting the response.
namestring
Display name, for example iDEAL.
categoryenum
card, wallet, bank_redirect or other.
currenciesarray | null
The only currencies the method accepts, or null when it has no fixed list.
requires_conversionboolean
true when the requested currency is converted before this method charges it.
iconobject
SVG URLs hosted by CX Pay: light for a light background, dark for a dark one.

Apple Pay and Google Pay are listed when enabled, but the payment form only shows them on a device and browser that support them. Requires the payments:read scope.

REQUEST
1curl "https://api.cxpay.net/v1/payment-method-types?currency=EUR" \
2 -H "X-Key-Id: ak_test_..." \
3 -H "X-Signature: <base64-hmac>" \
4 -H "X-Timestamp: 2026-10-14T18:30:00.000Z" \
5 -H "X-Nonce: 550e8400-..." \
6 -H "X-Body-Hash: <sha256-of-empty>"
TestGET /v1/payment-method-types?currency=EUR
RESPONSE
JSON
1{
2 "object": "list",
3 "data": [
4 {
5 "object": "payment_method_type",
6 "type": "card",
7 "name": "Cards",
8 "category": "card",
9 "currencies": null,
10 "requires_conversion": false,
11 "icon": {
12 "light": "https://pay.cxpay.net/icons/lpm/card-light.svg",
13 "dark": "https://pay.cxpay.net/icons/lpm/card-dark.svg"
14 }
15 },
16 {
17 "object": "payment_method_type",
18 "type": "ideal",
19 "name": "iDEAL",
20 "category": "bank_redirect",
21 "currencies": ["EUR"],
22 "requires_conversion": false,
23 "icon": {
24 "light": "https://pay.cxpay.net/icons/lpm/ideal-light.svg",
25 "dark": "https://pay.cxpay.net/icons/lpm/ideal-dark.svg"
26 }
27 }
28 ],
29 "livemode": false
30}

Was this section helpful?

Powered by CX Pay