API Reference
Checkout Sessions
A checkout session is a single payment in progress. Your backend creates one, your customer pays at the returned url, and LuniPay emits a webhook when the session completes.
Checkout sessions are the highest-level primitive in the LuniPay API. If you just need to collect a one-time payment, this is the only resource you need — no customer object, no invoice, no payment intent. LuniPay hosts the payment page, handles 3DS and receipts, fires webhooks, and the session transitions from OPEN to COMPLETE or EXPIRED.
The checkout_session object
idstringUnique identifier, prefixed with `cs_`.
objectstringAlways `"checkout_session"`. Use this to type-discriminate when deserializing webhook payloads.
livemodebooleanTrue if the session was created with a live-mode secret key. Test and live sessions share the same schema but never mix in queries.
statusstringLifecycle state. `OPEN` is the default after creation; `COMPLETE` after a successful payment; `EXPIRED` after the expires_at timestamp or an explicit expire call.
Values: OPEN COMPLETE EXPIRED
payment_statusstringPayment state, independent of the session status. An OPEN session may already have `payment_status=paid` briefly before the status transitions to COMPLETE.
Values: unpaid paid no_payment_required
amount_centsintegerTotal amount the customer will be charged, in the smallest currency unit.
currencystringLowercase 3-letter ISO 4217 currency code.
success_urlstringURL the customer is redirected to after a successful payment. Supports `{CHECKOUT_SESSION_ID}` as a template variable — LuniPay replaces it with the session id before redirecting.
cancel_urlstringnullableURL the customer is redirected to if they abandon the session. If omitted, the cancel button is hidden.
customer_idstringnullableId of the customer attached to the session, if any.
customer_emailstringnullableEmail shown on the receipt when no customer object is attached.
line_itemsarraynullableOptional itemized breakdown shown on the checkout page. Each item has `name`, `quantity`, and `amount_cents`.
payment_intent_idstringnullableStripe PaymentIntent id created for this session. Populated once the customer starts payment.
payment_idstringnullableId of the resulting LuniPay `payment` object, set when the session completes successfully.
metadataobjectnullableUp to 20 arbitrary key/value pairs. Round-trips through webhook payloads for reconciliation.
expires_atintegerUnix timestamp after which the session can no longer be paid. Defaults to 24 hours from creation.
completed_atintegernullableUnix timestamp when the session moved to COMPLETE. Null until the payment succeeds.
urlstringThe hosted checkout URL. Redirect your customer here to complete payment.
createdintegerCreation timestamp (unix).
updatedintegerLast-updated timestamp (unix).
{
"id": "cs_01JRZK8WV3FYMPEQRXJ9HA5NTB",
"object": "checkout_session",
"livemode": false,
"status": "OPEN",
"payment_status": "unpaid",
"amount_cents": 5000,
"currency": "usd",
"success_url": "https://example.com/thanks?session_id={CHECKOUT_SESSION_ID}",
"cancel_url": "https://example.com/cart",
"customer_id": null,
"customer_email": null,
"line_items": null,
"payment_intent_id": null,
"payment_id": null,
"metadata": {
"order_id": "ORD-9821"
},
"expires_at": 1713187200,
"completed_at": null,
"url": "https://lunipay.io/checkout/cs_01JRZK8WV3FYMPEQRXJ9HA5NTB",
"created": 1713100800,
"updated": 1713100800
}Endpoints
- POST
/v1/checkout/sessionsCreate a checkout sessionCreates a new checkout session and returns a hosted payment URL.
- GET
/v1/checkout/sessions/:idRetrieve a checkout sessionFetches a checkout session by id.
- GET
/v1/checkout/sessionsList checkout sessionsReturns a cursor-paginated list of checkout sessions, newest first.
- POST
/v1/checkout/sessions/:id/expireExpire a checkout sessionTransitions an OPEN session to EXPIRED immediately.