Skip to main content
API documentation

4 endpoints

Checkout sessions

An e-commerce order becomes a session: you redirect the buyer to the hosted checkout and collect the result.

Endpoint names and descriptions come from the OpenAPI contract, in English — they cannot drift from the API.

In plain English

Payment inside your site: one order, one session.

When to use it

For a shop or an app where payment sits inside an order funnel, with return and cancel URLs that belong to you. A session expires 72 hours after creation by default — use `expiresAt` to shorten that.

How to integrate it

  1. 1Create the session with the amount and your order reference — your return URLs are optional: without them, your account's defaults apply.
  2. 2Redirect the buyer to the checkout URL you get back.
  3. 3On their return, show a pending state — the redirect says the buyer came back, not that the payment succeeded.
  4. 4Confirm the order when the webhook arrives, never on the redirect alone.

Sandbox test card

The sandbox runs on real rails against a test environment: the flows are genuine, the money is not. Only one card is accepted there.

Only this PAN is accepted. Any other number — including the 4242… cards from other platforms — is rejected upstream, usually with a 502 and the stable BAAS_CHARI_ERROR code. If you hit that error while testing, check the card number you entered first.

POST

Cancel a checkout session

Expires the session so it can no longer be paid. Returns the updated session status.

FieldTypeInRequiredDescription
sessionIdstringpathRequired
GET

List checkout sessions

Returns the caller's checkout sessions for the key's environment, most recent first. Optionally filter by creation origin with ?origin=API or ?origin=DASHBOARD.

FieldTypeInRequiredDescription
originenumqueryOptionalFilter by creation origin (API or DASHBOARD).Values APIDASHBOARD
pageablePageablequeryRequired
POST200

Create a checkout session

Creates a single-use checkout session for an order and returns its hosted checkoutUrl. Supply an optional client-owned externalId (unique per merchant) to make the create idempotent: a duplicate externalId returns the existing session with 200 OK. Pass an optional Idempotency-Key header to make retries safe.

Schema · CreateCheckoutSessionRequest

FieldTypeInRequiredDescription
Idempotency-KeystringheaderOptionalOptional idempotency key; replaying the same value returns the first result.
amountnumberbodyRequiredAmount to collect, in MAD major units.
orderIdstringbodyRequiredYour order/business reference for this checkout.
singleUsebooleanbodyOptionalSingle-use session (recommended). Defaults to true.
externalIdstringbodyOptionalOptional client-supplied id, unique per merchant; a duplicate value replays the existing session. Distinct from orderId/externalReference, which are not uniqueness-enforced.
configCheckoutSessionConfigbodyRequiredBuyer, redirect URLs and options for the checkout.
config.customerCheckoutSessionCustomerbodyRequiredThe buyer being charged.
config.urlsCheckoutSessionUrlsbodyOptionalOptional redirect / notification URLs. Any field left unset falls back to the merchant's configured default, then the platform default.
config.keepAlivebooleanbodyOptionalKeep the session alive after a failed attempt so the buyer can retry. Defaults to false.
config.frontendCheckoutSessionFrontendbodyOptionalOptional branding for the hosted checkout page.
config.settlementCheckoutSessionSettlementbodyOptionalOptional distribution — sub-merchant wallet to credit.
metadataobjectbodyOptionalFree-form metadata object (≤ 4 KB) echoed back in the payment webhook.
expiresAtstring (date-time)bodyOptionalSession expiry (ISO-8601 UTC). Must be in the future; defaults to 72h after creation.
notifyOnFailurebooleanbodyOptionalAlso send a payment.failed webhook when the payment fails. Defaults to false.
GET

Retrieve a checkout session

Fetches a session's current status, amount and expiration by its id.

FieldTypeInRequiredDescription
sessionIdstringpathRequiredSession id.

Talk to an integrator

A question about integration?

Our technical team supports integrators from the first sandbox call through to go-live.