Skip to content
iSmartPayDevelopers
Esc
↑↓navigate↵open⌘Jpreview
On this page

Hosted checkouts

Create a payment link your customer opens to pay you by mobile money or iSmartPay.

Before you start

  • The owner or a developer turns on hosted checkout on the Hosted checkout page of the console: the test console for test, the live console for live. Until then, creating a checkout is refused with 409 checkout_not_enabled.
  • Your business needs verification tier 2. Below that, creating is 403 tier_ineligible.
  • Your key needs collections.write.

Create

POST /v1/checkouts
Idempotency-Key: inv-2210
{
  "reference": "inv-2210",
  "amountType": "fixed",
  "amount": "250.00",
  "currency": "GHS",
  "usage": "single",
  "description": "Invoice 2210",
  "successUrl": "https://shop.example.com/paid",
  "cancelUrl": "https://shop.example.com/cart",
  "expiresInMinutes": 60,
  "lineItems": [
    { "label": "Monthly plan", "quantity": 2, "amount": "100.00" },
    { "label": "Setup fee", "quantity": 1, "amount": "50.00" }
  ],
  "metadata": { "orderId": "2210" },
  "appearance": { "accentColor": "#0a7d3b", "buttonText": "pay_amount" }
}
  • reference is yours, and unique for each checkout. A reference already taken is 409 checkout_reference_taken.
  • currency is GHS. Amounts have two decimal places.
  • description is at most 140 characters.
  • lineItems, metadata and appearance are optional. See below.
  • environment is optional. Leave it out. If you send one that is not this API’s, you get 422 environment_mismatch.

Amount

  • fixed (the default). Send amount. The customer pays exactly that.
  • open. The customer picks the amount. Leave amount out. You can set minAmount, maxAmount and up to four suggestedAmounts.

Usage and expiry

usage Behaviour expiresInMinutes
single (default) Closes after one payment. 5 to 10080. Defaults to 60. null is refused.
reusable Stays open and takes many payments. 5 to 525600, or leave it out for no expiry.

A 201 returns the checkout:

{
  "id": "6f0c2d4e-8a1b-4c3d-9e5f-1a2b3c4d5e6f",
  "reference": "inv-2210",
  "amountType": "fixed",
  "amount": "250.00",
  "minAmount": null,
  "maxAmount": null,
  "suggestedAmounts": [],
  "usage": "single",
  "currency": "GHS",
  "description": "Invoice 2210",
  "environment": "test",
  "status": "open",
  "url": "https://pay.example.com/d/...",
  "successUrl": "https://shop.example.com/paid",
  "cancelUrl": "https://shop.example.com/cart",
  "expiresAt": "2026-10-05T11:00:00Z",
  "paidAt": null,
  "collectionReference": null,
  "paymentsCount": 0,
  "totalCollected": "0.00",
  "createdAt": "2026-10-05T10:00:00Z",
  "appearance": { "accentColor": "#0a7d3b", "buttonText": "pay_amount" },
  "lineItems": [
    { "label": "Monthly plan", "quantity": 2, "amount": "100.00" },
    { "label": "Setup fee", "quantity": 1, "amount": "50.00" }
  ],
  "metadata": { "orderId": "2210" }
}

Share the url with the customer. It carries a secret, so send it only to the payer. appearance, lineItems and metadata are left out when the checkout has none.

Line items

lineItems lists what the customer is paying for. It is shown on the page and is display only.

  • Up to 1000 rows. Each row has a label (1 to 80 characters), a whole quantity from 1 to 9999, and amount, the price of one unit.
  • On a fixed checkout, quantity times amount over all rows must equal amount. If not, you get 422 invalid_input. In the example, 2 × 100.00 + 50.00 is 250.00.
  • On an open checkout they are display only, with no sum to match.

Metadata

metadata holds your own strings, such as an order ID. It is returned when you read the checkout and in its webhooks. The customer never sees it.

  • Up to 20 pairs. Keys are 1 to 40 characters and values at most 500.
  • Values must be strings.

Appearance

The page can carry your brand. The owner, an admin or a developer sets the defaults for the business on the Hosted checkout page of the console. Test and live are kept separately.

Setting Rule
Display name At most 60 characters. Leave it empty to use your business name.
Logo PNG or JPEG, at most 512 KB.
Accent colour A hex colour such as #0a7d3b. White text on it needs a contrast ratio of at least 4.5:1, or the API answers 422 accent_contrast_too_low.
Button text pay, pay_amount, donate or book.
Support An email, a phone number, or both. Shown in the page footer.
Payment methods Which of mtn, telecel and ismartpay to show, in order. One that is not listed is hidden. One that is down is left out for the moment.

Anything you leave unset falls back to the standard look.

A single checkout can override three of these in appearance: accentColor, buttonText and paymentMethods. Anything else in appearance is 422 invalid_input. What the checkout leaves out comes from the business defaults.

You can also manage the defaults with a key. GET /v1/checkout/appearance needs collections.read or collections.write. PUT /v1/checkout/appearance replaces the text settings, and anything you leave out is cleared. PUT and DELETE /v1/checkout/appearance/logo set and remove the logo, with the image as the request body. All three writes need collections.write.

Paying with iSmartPay

A customer with an iSmartPay account can pay your checkout with it. On the page they pick iSmartPay, enter their iSmartPay handle or phone number, and approve the request in the iSmartPay app. This is a payment request the page sends for them.

  • Your business needs a handle. The page offers iSmartPay only while you have one. An owner claims it in the console.
  • The request ends when the checkout does.
  • On the checkout, the attempt has provider ismartpay. payer is @handle if the customer entered a handle, or a masked phone number if they entered a number.

You send nothing extra to turn this on.

Statuses

Status Meaning
open Waiting for payment.
paid Paid. Single checkouts only.
expired Not paid in time.
cancelled You cancelled it, or checkout was turned off.

A checkout becomes paid only when the payment succeeds. A reusable checkout stays open after each payment and is never paid. Watch paymentsCount and totalCollected instead. totalCollected counts settled payments only.

Read and list

GET /v1/checkouts/{checkoutId} returns one checkout with its attempts: each payment attempt, with the payer’s number masked. An iSmartPay attempt shows the payer’s @handle instead. A checkoutId that is not a UUID is 400. Another business’s checkout is 404.

GET /v1/checkouts lists your checkouts in this environment, newest first.

  • status filters by status.
  • limit is 1 to 50. It defaults to 20.
  • Pass nextCursor back unchanged as cursor for the next page. Here nextCursor is an empty string on the last page.

Cancel

POST /v1/checkouts/{checkoutId}/cancel
Idempotency-Key: inv-2210-cancel

You can cancel an open checkout that has no payment in progress. Otherwise you get 409 checkout_not_open.

Knowing when it is paid

Subscribe a webhook endpoint to the checkout events:

Event Sent when
checkout.paid A payment succeeded. A reusable checkout sends it for every payment.
checkout.payment_failed A payment failed, or money arrived that did not pay the checkout.
checkout.expired The checkout ran out of time unpaid.
checkout.cancelled You cancelled it, or checkout was turned off.

data has the checkout’s id, reference, status, usage and metadata. On checkout.paid and checkout.payment_failed it also has a payment. See Webhooks for the shape.

If checkout.payment_failed has moneyReceived: true, the money reached your wallet but did not pay the checkout, for example because it came after the checkout closed. Refund it.

The collection.* events still fire for mobile money payments, and the events are in GET /v1/events. collectionReference on the checkout, and on each attempt, names the collection. You can also poll the checkout.

Permissions

To The key needs
Create or cancel collections.write
List or read collections.read

Errors

As well as the common errors, you may see:

Status Code What to do
403 tier_ineligible Your business is below verification tier 2.
409 checkout_not_enabled Hosted checkout is off. Turn it on in the console.
409 checkout_not_open The checkout is not open, or a payment is in progress. Read it to see its status.
409 checkout_reference_taken Use a new reference.
409 idempotency_key_reused That Idempotency-Key went with a different request. Use a new key.
422 environment_mismatch Leave environment out, or send this API’s.
422 accent_contrast_too_low Pick a darker accent colour.
422 invalid_input An appearance, line item or metadata value breaks its rule, or line items do not add up to amount. message says which.

Was this page helpful?