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.
- Create a Checkout SessionPOST
/v1/checkout-sessions - Retrieve a Checkout SessionGET
/v1/checkout-sessions/:id - List Checkout SessionsGET
/v1/checkout-sessions - Update a Checkout SessionPATCH
/v1/checkout-sessions/:id - Cancel a Checkout SessionPOST
/v1/checkout-sessions/:id/cancel - List payment method typesGET
/v1/payment-method-types
The Checkout Session object
idstring- Unique identifier, prefixed
cs_. objectstring- Always
"checkout_session". statusenumopen,complete,expired, orcanceled.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
modeis"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.
nullif none provided. metadataobject- Up to 50 key-value pairs of your own data.
expires_atstring- ISO-8601 timestamp when the session expires.
livemodebooleantruefor live mode,falsefor test.created_atstring- ISO-8601 timestamp when the session was created.
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
/v1/checkout-sessionsCreates 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 unlessline_itemsis provided (in which case the total is derived from the items). currencystring- ISO 4217 code, e.g.
"USD","EUR","TTD". Required forpaymentmode; omit forsetupmode. 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 return403first. 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
customerinstead to attach a specific customer by id. When minting a new Customer,customer_nameis required. customerstringcus_...— attach an existing customer. Saved cards and mandate references flow through this customer.customer_namestring- Full name of the customer. Required when
customer_emailis provided without acustomerid — 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.
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 }'
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
/v1/checkout-sessions/:idReturns 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.
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
/v1/checkout-sessionsReturns a paginated list of Checkout Sessions, newest first.
Query parameters
limitinteger- 1–100, default 10.
statusenum- Filter by status:
open,complete,expired, orcanceled. 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).
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>"
Was this section helpful?
Update a Checkout Session
/v1/checkout-sessions/:idChanges 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_urlorexpires_at. The error'sdetailsname the field. 404not_found- Session doesn't exist or belongs to a different account.
409conflict- The session's Payment Intent is mid-flight (
processingorrequires_action) and can't be changed yet. 410gone- Session is in a terminal status (
complete,expired, orcanceled).
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" } }'
Was this section helpful?
Cancel a Checkout Session
/v1/checkout-sessions/:id/cancelCancels 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,uncertainorrequires_review, or its SetupIntent isprocessingorrequires_action. The session is not canceled. Do not start a new payment for this order. Foruncertain, keep retrieving the Payment Intent: it can move torequires_review, which sends no webhook. Forrequires_review, contact support. 410gone- Session is already
completeorexpired. (Canceling an already-canceled session is idempotent — returns 200 with the canceled session.)
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>"
Was this section helpful?
List payment method types
/v1/payment-method-typesReturns 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,idealand 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. categoryenumcard,wallet,bank_redirectorother.currenciesarray | null- The only currencies the method accepts, or
nullwhen it has no fixed list. requires_conversionbooleantruewhen the requestedcurrencyis converted before this method charges it.iconobject- SVG URLs hosted by CX Pay:
lightfor a light background,darkfor 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.
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>"
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": false30}
Was this section helpful?
- Need help? Contact Support.
- Check out our changelog.
- Questions? Contact Sales.
- LLM? Read llms.txt.
Powered by CX Pay