Create a checkout session
Creates a hosted payment page for an order. Send your customer to its url; the page asks for their number, sends the prompt, waits, lets them retry and gives them a receipt. When they’ve paid, we send them to your success_url.
With reusable: true it becomes a payment page that takes any number of payments until you expire it.
checkout:writeHeaders#
Idempotency-Keystringheader8–80 letters, digits, - or _. Lets you retry safely: the same key and body return the first answer and never move money twice. See Idempotency.
Body#
JSON, with Content-Type: application/json.
line_itemsarrayWhat they’re paying for, like invoice lines. Give these or amount.
Show child attributes
descriptionstringrequiredWhat the line is for.
quantityintegerrequiredHow many.
unit_amountintegerrequiredThe price of one, in whole UGX.
amountintegerA single amount in UGX, instead of line_items. Needs title.
titlestringWhat’s being paid for. Required with amount; defaults to the first line.
descriptionstringText under the title.
success_urlstringWhere to send the customer after paying. {CHECKOUT_SESSION_ID} is replaced with the session id.
cancel_urlstringShown as a back arrow on the page.
referencestringYour order id. Returned on the session and in webhooks.
customerobjectFills in the page for them.
Show child attributes
namestringemailstringphonestringrequire_emailbooleanMake the email field required, so they always get a receipt.
require_namebooleanMake the name field required.
allow_custom_amountbooleanLet the customer type the amount, for donations, fees and top-ups.
min_amountintegerThe lowest amount they may type.
reusablebooleandefault: falsetrue: a link that takes any number of payments until you expire it. false: one payment, then complete.
expires_in_minutesintegerdefault: 1440One-time sessions only. 30 to 10,080.
wallet_idstringWhere payments land. Defaults to your main wallet.
fee_bearerstringwallet or customer.
metadataobjectUp to 20 keys of your own, with simple values. Returned on the object and in webhooks.
Returns#
The checkout session, with its url.
Errors#
| Status | Code | When |
|---|---|---|
| 422 | VALIDATION_ERROR | For example, neither line_items nor amount, or a total outside UGX 500–5,000,000. |
The common codes, such as UNAUTHENTICATED and RATE_LIMITED, can come from any endpoint. See Errors.
Don’t ship an order just because the customer arrived at your success_url: anyone can open that address. Confirm with the checkout.session.completed webhook, or by getting the session and checking that its status is complete.