Checkout sessions
Create a checkout session
Set up a payment for your customer, then send them to its `url`. Call this from your server with a secret key. The amount, currency, reference and redirect URLs are fixed here, and the hosted page can only pay exactly that. Test keys create test sessions (`cs_test_…`), which are resolved by the sandbox and never prompt a real phone. Sending the same request again, with a `reference` you have already used, returns that session as it now stands, with 201 like the original, so a retry after a timeout is safe. That includes a session the payer has since paid (`status: complete`). The same reference with any field changed is refused with 409 `REFERENCE_IN_USE`, and a reference whose session has expired or failed with 409 `REFERENCE_SESSION_CLOSED`: use a new reference for the next attempt. The browser being sent to `success_url` is not proof of payment. Fulfil on the `checkout.session.completed` webhook, or after reading the session and seeing `status: complete`. Send `account` to collect into one of your accounts other than the main one; the session's charge, its webhooks and its settlement all name it.
Before you call this endpoint
- An API key needs the
payments:writescope. - Call it from your server: a secret key never goes in a web page or an app.
- Once your business has an IP allowlist, every live key must call from an address on it.
- Guide: Checkout
Set up a payment for your customer, then send them to its url.
Call this from your server with a secret key. The amount, currency,
reference and redirect URLs are fixed here, and the hosted page can only
pay exactly that. Test keys create test sessions (cs_test_…), which are
resolved by the sandbox and never prompt a real phone.
Sending the same request again, with a reference you have already
used, returns that session as it now stands, with 201 like the original,
so a retry after a timeout is safe. That includes a session the payer has
since paid (status: complete). The same reference with any field changed
is refused with 409 REFERENCE_IN_USE, and a reference whose session has
expired or failed with 409 REFERENCE_SESSION_CLOSED: use a new
reference for the next attempt.
The browser being sent to success_url is not proof of payment. Fulfil on
the checkout.session.completed webhook, or after reading the session and
seeing status: complete.
Send account to collect into one of your accounts other than the main
one; the session's charge, its webhooks and its settlement all name it.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
A payment for your customer to complete on the hosted checkout page.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/b/v1/checkout/sessions" \ -H "Content-Type: application/json" \ -d '{ "amount_minor": 500000, "currency": "RWF", "reference": "ORDER-1042", "success_url": "https://shop.example.com/orders/1042/paid", "cancel_url": "https://shop.example.com/cart" }'{ "id": "string", "url": "string", "status": "string", "is_test": true, "amount_minor": 0, "currency": "string", "reference": "string", "customer": { "name": "Aline Uwase", "email": "aline@example.com", "phone": "250788123456" }, "methods": [ "string" ], "success_url": "string", "cancel_url": "string", "metadata": {}, "embed_origins": [ "string" ], "account": "acct_4f1c9a2b7d3e8f6a0b1c2d3e", "charge_id": "cf8b747b-a752-4d0a-9a4d-7d19fc1769f3", "failure_reason": "string", "expires_at": "2019-08-24T14:15:22Z", "created_at": "2019-08-24T14:15:22Z", "completed_at": "2019-08-24T14:15:22Z", "expired_at": "2019-08-24T14:15:22Z", "failed_at": "2019-08-24T14:15:22Z"}List checkout sessions
Newest first, scoped to your business and your key's mode. A test key never sees a live session and a live key never sees a test one. Paged with a cursor: pass the `id` of the last session on a page as `before` to get the next, older page. A page with fewer than `limit` sessions is the last one (a page of exactly `limit` may be followed by an empty one). Paging is exact: a session created while you page never shifts a page, so nothing is shown twice or skipped. The `status` filter applies to every session you have, however old, and an unclaimed session past its `expires_at` counts as `expired`. Keep `status` and `reference` the same on every page of one walk.
Fetch a checkout session
Verify a session from your server before you fulfil the order. `status: complete` with a `charge_id` is the confirmation. Another business's session, a session in the other mode and no session all give the same 404.