PaybytokenDocs
Checkout Sessions
API reference · Checkout Sessions

Checkout Sessions

Create, confirm and retrieve server-owned orders for every checkout presentation mode.

A Checkout Session represents one merchant-defined order and one customer payment attempt. It stores the authoritative line items, total, enabled token/network combinations and presentation mode. The merchant can create it directly, or a public Payment Link or Payment Request can create it from a versioned source snapshot.

Create a new session for each attempt. Do not reuse one between customers or orders.

Endpoints

MethodEndpointDescription
POST/api/v1/checkout_sessionsCreate a hosted, embedded or custom Checkout Session.
POST/api/v1/checkout_sessions/:id/confirmSelect a token and create exact payment instructions.
GET/api/v1/checkout_sessions/:idRetrieve the current state of a Checkout Session.

These endpoints require a server API key with the matching Checkout Session permission. See Authentication.

The Checkout Session object

Identity and mode

AttributeTypeDescription
idstringUnique chk_test_... or chk_live_... identifier.
account_idstringMerchant account that owns the session.
ui_modestringhosted, embedded or custom.
urlstring or nullHosted redirect URL, embedded checkout URL or null for custom UI.
allowed_originstring or nullExact origin allowed to mount an embedded session.
client_secretstringReturned only in the create response for an embedded session. Never returned by retrieval.
csrf_tokenstringSensitive server-only confirmation credential. Never expose it to the browser.

The embedded client_secret is short-lived and scoped to the session and allowed_origin. Keep it in browser memory and never log it, persist it, send it to analytics or place it in a URL. The CSRF token belongs on the merchant server and must remain bound to the matching session and customer.

Order

AttributeTypeDescription
amount_subtotalstringDecimal subtotal before discounts.
amount_totalstringDecimal amount the order requires.
currencystringOrder currency. Currently USD.
modestringCheckout mode. Currently payment.
line_itemsarrayServer-authored products, quantities and calculated totals.
supported_tokensarrayEnabled token/network combinations available to the customer.
payment_method_configurationobject or nullConfiguration ID and immutable version resolved when the Session was created.
payment_method_optionsarrayCustomer-safe capability snapshot, including wallet experiences and availability reasons.
descriptionstring or nullOptional merchant description.
metadataobject or nullMerchant-authored data used to associate the payment with an order.
customer_idstring or nullOptional merchant customer reference.
customer_emailstring or nullOptional receipt email.
client_reference_idstring or nullMerchant correlation value supplied by a public collection flow.

amount_subtotal and amount_total are calculated by Paybytoken from the line items. Do not send either value when creating a session.

Hosted, embedded and custom checkout must render from payment_method_options and supported_tokens, not from current merchant settings. This keeps an open Session stable after an administrator publishes a new Payment Method Configuration.

Source snapshot

AttributeTypeDescription
payment_link_idstring or nullReusable Payment Link that created this attempt.
payment_link_versioninteger or nullLink version snapshotted for this attempt.
payment_request_idstring or nullReceivable that created this attempt.
payment_request_versioninteger or nullFinalized request version snapshotted for this attempt.
originobject or nullCustomer-safe source attribution, when applicable.
after_completionobject or nullCompletion behavior copied from the source configuration.

A source change never mutates an existing Checkout Session. Use the source and version fields when investigating which terms the customer actually saw.

Payment and lifecycle

AttributeTypeDescription
payment_intent_idstring or nullPayment Intent created after the customer confirms a token and network.
selected_token_idstring or nullToken selected when payment instructions are confirmed.
statusstringopen, completed, expired or canceled.
success_urlstring or nullHosted return destination after successful checkout.
cancel_urlstring or nullMerchant destination after cancellation.
expired_attimestampTime after which the session can no longer be used.
used_attimestamp or nullTime the session was consumed or canceled.
created_attimestampCreation time.
updated_attimestampLast update time.

The related payment_intent returned by retrieval contains the selected network, token currency, destination and on-chain payment state.

Branding

The branding snapshot keeps a session visually stable if merchant settings change later:

AttributeTypeDescription
versionnumberBranding schema version.
display_namestringMerchant name shown in checkout.
logo_urlstring or nullMerchant logo URL.
brand_colorstringMerchant/order panel color.
brand_foreground_colorstringAutomatically selected text color for the brand surface.
accent_colorstringPrimary checkout action color.
accent_foreground_colorstringAutomatically selected text color for the accent surface.

On this page

API Workbench

Full Explorer

Open in new tab