Skip to main content
A checkout session is a PrimePay-hosted payment page for one order. Your server creates the session, you redirect the customer to its url, and the customer chooses how to pay and approves the payment on their phone. PrimePay then sends the customer back to your site and tells your server the result by webhook. Use it when you don’t want to build your own payment form.
Checkout sessions use snake_case field names (return_url, line_items) and their errors carry type and param. The other endpoints use camelCase.

How it works

1

Create a session from your server

POST /v1/checkout/sessions with the amount, your order reference, a return_url and a cancel_url. Send an Idempotency-Key so a retry returns the same session.
2

Redirect the customer to url

The response has a url on checkout.primepay.mw. The session can be paid for 30 minutes.
3

The customer pays

They choose a mobile money operator, enter their number and approve the payment on their phone.
4

The customer comes back

PrimePay sends them to your return_url with session_id, reference and status added to the address.
5

Confirm before you fulfil

Call GET /v1/checkout/sessions/{id} from your server, or wait for the checkout.session.completed webhook. Hand over the goods only when status is complete.
Don’t fulfil an order because the customer arrived at your return_url. Anyone can type that address. Always confirm with the API or the webhook.

Create a session

The key must be a secret key; a payments-only key also works. The Idempotency-Key header is required, 8 to 255 characters. On a retry with the same key, description and metadata may differ.

One session per order

A reference can have only one session that is open or paid.
  • Creating a new session for an order that still has an open session cancels the old one, so the customer can’t pay twice from an old tab.
  • If the order is already paid, you get 409 order_already_paid.
  • If the customer is approving a payment right now, you get 409 payment_in_progress. Wait for the webhook.

When the customer comes back

If the customer goes back without paying, they are sent to your cancel_url unchanged.

Session status

url is null once a session can no longer be paid.

Webhooks

See Webhooks for the body and how to check the signature.

Cancel a session

POST /v1/checkout/sessions/{id}/expire cancels an unpaid session, for example when the customer empties their cart. A paid session can’t be cancelled (409 session_complete).

Checkout errors