Skip to main content
PayHubDeveloper docs
简体中文

Get checkout session

API contract v1.0.0

getCheckoutSession
GET/v1/checkout/sessions/{session_id}
Required scopespayments:read

Retrieves a checkout session from the server side. completed appears only after the related Payment succeeds; expired only means new submissions are no longer allowed and doesn't mean the payment failed. Fulfill orders based on the Payment status or a webhook whose signature you've verified, never on the browser redirect.

Request headers

Request headersRequiredFormatDescription
AuthorizationYesBearer <API_KEY>

Server-side key, to be used only on the merchant's server. The merchant and environment are derived from the key. A missing, invalid, revoked or expired key returns 401.

Request example

curl
curl -X GET 'https://api.fluxan.co/v1/checkout/sessions/<SESSION_ID>' \
  -H 'Authorization: Bearer <TEST_SERVER_API_KEY>'

Placeholders to replace

  • <SESSION_ID>: Replace with your actual value
  • <TEST_SERVER_API_KEY>: Test-environment server API key, created on the "API Key" page of the merchant portal

Note

Server API keys must only be used on your own server, so the docs site doesn't offer interactive API testing. Get a test key: API Key page in the merchant portal (opens the merchant portal in a new tab) (Test environment; Requires Owner, Admin or Developer)

Responses

The checkout session.

JSON
{
  "id": "cs_demo_001",
  "payment_id": "pay_demo_008",
  "status": "open",
  "checkout_url": "https://pay.payhub.example/checkout/<SHORT_LIVED_TOKEN>",
  "expires_at": "2026-09-23T09:30:00Z",
  "return_url": "https://merchant.example/payment/return",
  "cancel_url": "https://merchant.example/payment/cancel",
  "locale": "zh-CN",
  "created_at": "2026-09-23T09:00:00Z",
  "request_id": "req_demo_020"
}

Placeholders to replace

  • <SHORT_LIVED_TOKEN>: Short-lived credential returned by the platform; use it as is and don't log it

Response fields

Returns an object. See the object section for field descriptions.

NameTypeRequiredDescription
id
stringRequired

Checkout session ID.

Example: cs_demo_002

payment_id
stringRequired

The related Payment.

Example: pay_demo_002

status
stringRequired

Checkout session status.

  • open: payment can be submitted
  • completed: appears only after the related Payment succeeds
  • expired: new submissions are no longer allowed; this doesn't mean the related payment failed
  • open: Payment can be submitted
  • completed: Appears only after the related Payment succeeds
  • expired: New submissions are no longer allowed; this doesn't mean the related payment failed
  • More values may be added in the future. Don't treat a status you don't recognize as success.

Example: open

checkout_url
string(uri)Required

The checkout page URL. It carries a short-lived credential bound to this session only, and contains no merchant server-side key. Use it only for a full-page redirect of the payer's browser: don't write it to logs, analytics tools or error reporting, and don't share it with anyone.

Example: https://pay.payhub.example/checkout/<SHORT_LIVED_TOKEN>

expires_at
string(date-time)Required

The time the session expires, fixed at creation. A session lasts at most 30 minutes (the platform can shorten this) and never longer than the time the order has left to be paid. During the read-only period after expiry (fixed at creation; 24 hours by default, which is also the maximum), the payer can still use the original link to view the session and the payment result (read-only, no submissions). After that, the link stops working.

Example: 2026-09-23T09:30:00Z

return_url
string(uri)Required

The merchant's return URL after the payment ends.

Example: https://merchant.example/payment/return

cancel_url
string(uri)NullableRequired

The URL the payer goes to when they click "Return to merchant". Clicking it doesn't cancel a charge that was already submitted. It's null if not provided.

Example: https://merchant.example/payment/cancel

locale
stringRequired

Checkout page language.

Example: zh-CN

created_at
string(date-time)Required

Creation time.

Example: 2026-09-23T09:00:00Z

request_id
stringRequired

Unique identifier of this request, used for troubleshooting and support.

Example: req_demo_001

Possible error codes

HTTPError codeWhen it occursHow to handle
404not_foundAn incorrect ID; using a test key to look up a live object; looking up a platform exception refund (not returned by the open API)Check the ID and the environment of the key you used; the platform doesn't reveal whether another merchant's object exists
401unauthenticatedCommonNo Authorization header was sent; the key was copied incompletely; the old key expired after a rotation; the key was revokedCheck your credentials: on the API Key page in the merchant portal, verify the key's status and environment
403forbiddenCommonCreating a refund with a read-only key; calling getEvent without the read scope for the event's business area; if the request's source IP isn't on the key's allowlist, the more specific ip_not_allowed is returnedUse a key that has the required scope; don't work around the restriction
429rate_limitedCommonA rate limit per merchant and per key; switching keys doesn't get around the merchant's overall limitWait for Retry-After seconds, then retry with the original idempotency key
500internal_errorCommon—Retry with the original idempotency key, or query by merchant order ID / refund ID; never charge again with a new key
502 / 503upstream_unavailableCommonA provider or platform dependency failed, and the platform can't confirm whether this request took effectSame as above

Notes

  • completed appears only after the linked payment succeeds.
  • expired only means the session no longer accepts new submissions. It doesn't mean the payment failed: a payment may still be processing when the session expires.
  • During the read-only period after expiry (24 hours by default, which is also the maximum), the payer can still open the original link to see the session and the payment result (read-only, no submissions). After that, the link stops working.
  • Fulfill based on the payment status or a webhook whose signature you've verified, never on the browser redirect. See Fulfillment rules.
Was this page helpful?