CX Pay API

Create Checkout Session

Create a hosted checkout session and redirect your customer to pay.

POST/checkout-sessions

Creates a new checkout session with an auto-created Payment Intent. Returns a hosted checkout URL for customer redirect.

Requires an Idempotency-Key header. Use a UUID — if your request fails mid-flight, you can safely retry.

Request Body

FieldTypeRequiredDescription
modestringYes"payment" to collect a payment
amountintegerYesAmount in smallest currency unit (e.g. 5000 = $50.00)
currencystringYesISO 4217 code: "USD", "EUR", "TTD", etc.
return_urlstringNoWhere to redirect after success. Must be HTTPS.
cancel_urlstringNoWhere to redirect on cancel. Must be HTTPS.
descriptionstringNoFor receipts and your reference. Max 500 chars.
metadataobjectNoYour key-value pairs. Max 50 keys.
line_itemsarrayNoItemized breakdown. If used with amount, totals must match.
expires_inintegerNoTTL in seconds. Default 1800 (30 min). Range: 300–86400.
customer_emailstringNoPre-fill email on checkout page.
capture_methodstringNo"automatic" (default) or "manual" for auth-then-capture.

Line Items

FieldTypeRequiredDescription
namestringYesDisplay name. Max 200 chars.
quantityintegerYesNumber of units. Min 1.
unit_amountintegerYesPrice per unit in smallest currency unit.
descriptionstringNoItem description. Max 500 chars.

Response 200

{
  "id": "cs_01JQXYZ...",
  "object": "checkout_session",
  "status": "open",
  "mode": "payment",
  "amount": 5000,
  "currency": "USD",
  "url": "https://pay.cxpay.net/cs/cs_01JQXYZ...",
  "client_secret": "pi_01JQ..._secret_abc123",
  "payment_intent": "pi_01JQ...",
  "return_url": "https://yoursite.com/success",
  "cancel_url": "https://yoursite.com/cancel",
  "metadata": { "order_id": "ORD-123" },
  "expires_at": "2026-04-07T19:00:00.000Z",
  "livemode": false,
  "created_at": "2026-04-07T18:30:00.000Z"
}
FieldDescription
idCheckout session ID (cs_...)
urlRedirect your customer here. This is the hosted payment page.
payment_intentPI ID — use this to check payment status later.
client_secretFor SDK/embedded use. Ignore if using hosted checkout.
statusopencomplete or expired or canceled
livemodetrue = real money. false = test mode.

Errors

StatusMeaning
400Bad request — missing fields, invalid currency, line items don't sum to amount
401Auth failed — bad signature, expired timestamp, invalid key
409Idempotency conflict — same key but different body
429Rate limited — slow down

Try It

POST/checkout-sessions
test

On this page