Skip to main content
POST
Create a checkout session

Authorizations

Authorization
string
header
required

Your API key: sk_live_… / sk_test_… (secret), pk_live_… / pk_test_… (publishable, read-only reference data) or rk_live_… / rk_test_… (payments only).

Headers

Idempotency-Key
string
required

A new value for every new session (a UUID is ideal), 8 to 255 characters. If your request times out, send it again with the same key to get the first session back. description and metadata may differ on the retry.

Required string length: 8 - 255
Example:

"9b2f4c6e8a1d4f3b9c7e5a2d1f0b3c4e"

Body

application/json
amount
number
required

At most 2 decimal places.

Required range: 1 <= x <= 10000000
reference
string
required

Your order or invoice number. One open or paid session per order.

Maximum string length: 100
return_url
string
required

Where the customer goes after paying. A public https:// address (sandbox also allows http://localhost). session_id, reference and status are added to it.

Maximum string length: 2048
cancel_url
string
required

Where the customer goes if they go back without paying. Same rules as return_url.

Maximum string length: 2048
currency
string
default:MWK

MWK today. Other currencies are accepted once PrimePay takes payments in that country.

description
string | null

Shown to the customer.

Maximum string length: 255
customer
object
line_items
object[]

Shown on the page. They must add up to amount.

Maximum array length: 50
metadata
object | null

Your own values, up to 50 keys and 8 KB. Returned with the session and in webhooks.

sub_merchant_account_code
string | null

Aggregator accounts only. The 8-digit account code of a linked, active sub-merchant to collect for. The agreed fee always applies.

Response

The session. Redirect the customer to url.

id
string<uuid>
object
string
Example:

"checkout.session"

url
string | null

The payment page. null once the session can no longer be paid.

status
enum<string>
Available options:
open,
processing,
complete,
expired,
cancelled
livemode
boolean
amount
number
currency
string
Example:

"MWK"

reference
string
description
string | null
customer
object
line_items
object[]
metadata
object | null
sub_merchant_account_code
string | null
return_url
string
cancel_url
string
payment
object | null

The payment that completed the session. null until it is paid.

created_at
string<date-time>
expires_at
string<date-time>
completed_at
string<date-time> | null