Getting started
Quickstart
Create a checkout session from your server, let the shopper pay, and read the order. About ten minutes, all in test mode.
You'll need a test secret key (sk_test_…) from Developers → API keys in the dashboard. Keep it in an environment variable on your server:
export CARTIRRA_SECRET_KEY=sk_test_your_key_here
1. Create a checkout session
When the shopper is ready to pay, your server sends their cart to Cartirra. Prices come from your system, so send each line's unit price.
curl -X POST https://api.cartirra.com/v1/checkout-sessions \
-H "Authorization: Bearer $CARTIRRA_SECRET_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"lines": [
{ "name": "Jollof rice (large)", "quantity": 2, "unit_price": { "amount": "4500.00", "currency": "NGN" } }
],
"metadata": { "cartId": "c_123" },
"success_url": "https://shop.example.com/thanks"
}'
The response is the session. Keep its id and pass client_secret to your page:
{
"id": "cs_0193a1b2c3d47e5f8a9b0c1d2e3f4a5b",
"status": "open",
"currency": "NGN",
"client_secret": "cs_0193…_secret_…",
"expires_at": "2026-10-24T10:30:00.000Z"
}
client_secretlets the widget act on this one session. Send it only to the shopper's browser, never log it, and never send your secret key to a browser.
Add an image_url (a public https:// address) to a line to show the item's picture in the checkout, and description for a short line under its name.
Items with modifiers
When the shopper customised an item (a protein, extras, "no pepper"), send the choices as modifiers on its line instead of folding them into the name or price. Each modifier has a name, an optional group (shown as "Protein: Chicken"), a quantity per item (default 1) and a price per portion (omit it for a free choice):
{
"name": "Jollof rice (large)",
"quantity": 2,
"unit_price": { "amount": "4500.00", "currency": "NGN" },
"modifiers": [
{ "group": "Protein", "name": "Chicken", "quantity": 2, "price": { "amount": "1000.00", "currency": "NGN" } },
{ "name": "Plantain", "price": { "amount": "500.00", "currency": "NGN" } },
{ "name": "No pepper" }
]
}
One item costs unit_price plus each modifier's price × quantity (here ₦4,500 + ₦2,000 + ₦500 = ₦7,000), and the line costs that times its quantity (₦14,000). If the shopper changes the line's quantity in the checkout, every item keeps its modifiers. The checkout, the order, webhooks and the receipt list each modifier with what it adds. Up to 30 modifiers per line, each quantity 1–99.
If you set a cart check URL, Cartirra sends each line's modifiers with an index; answer a line with "modifiers": [{ "index": 0, "price": { "amount": "1200.00", "currency": "NGN" } }, { "index": 1, "available": false }] to reprice a modifier or take one that's run out off the item. The shopper sees what changed before paying.
What the shopper can change
The shopper can change each line's quantity (1–999) on the order summary, or remove a line, but never the last one. They always pay your unit price for what they keep, and the order lists exactly that.
- Lock the lines a deal depends on. Send
"locked": trueon a line, such as the phone a bundle price or gift comes with, and the shopper can't change its quantity or remove it. The session'slinesshowlocked: true. - Turn editing off for every line with Checkout → Checkout options → Edit cart in the dashboard, or
"options": { "edit_quantities": false }onPATCH /v1/checkout-settings. - Every item must cost something. A line whose item costs ₦0 (unit price plus modifiers) is refused with
validation_failed, because a free item on its own line could be kept while the shopper removes what it came with. Give free items and gifts with a promotion (Discounts in the dashboard) or a loyalty reward. Those are re-checked against the cart the shopper actually pays for. An item priced only by its modifiers (unit price ₦0, "Large" ₦3,000) is fine. - A cart check URL can refuse a cart you can't sell, such as a gift without the item it comes with. If your URL doesn't answer within 3 seconds, the checkout goes on without it.
2. Let the shopper pay
Your checkout page opens the Cartirra checkout widget with your public key (pk_test_…) and the session's client_secret. The shopper chooses delivery or pickup, then pays by bank transfer or card. Cartirra Popup and Redirect shows the script tag and options for Cartirra Popup, or how to send shoppers to Cartirra Redirect instead.
In test mode nothing is charged: the widget offers a simulated payment, so you can complete the flow end to end. See Test mode.
3. Get told about the order
When the payment succeeds, Cartirra creates the order and sends order.created and payment.succeeded to your webhook endpoint. Use the event to fulfil the order, and verify the signature first (Webhooks). Fulfil the lines on the order, not the cart you sent: the shopper may have changed quantities or removed lines.
You can also read the session again: once it is completed, its order_id is set.
curl https://api.cartirra.com/v1/checkout-sessions/cs_0193a1b2c3d47e5f8a9b0c1d2e3f4a5b \
-H "Authorization: Bearer $CARTIRRA_SECRET_KEY"
4. Read the order
curl https://api.cartirra.com/v1/orders/ord_0193a1b2c3d47e5f8a9b0c1d2e3f4a5b \
-H "Authorization: Bearer $CARTIRRA_SECRET_KEY"
The order carries its reference (what the shopper sees, such as ORD-1042), status, payment_status, the lines, the price breakdown and the fulfilment details.
5. Move it along
As you prepare and hand over the order, update its status so the shopper is kept informed:
curl -X POST https://api.cartirra.com/v1/orders/ord_0193a1b2c3d47e5f8a9b0c1d2e3f4a5b/status \
-H "Authorization: Bearer $CARTIRRA_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "status": "out_for_delivery" }'
Pay on delivery
If you turn on pay on delivery, some orders arrive as processing with payment_method: "pay_on_delivery" and payment_status: "pending". When you hand one over, record what happened:
curl -X POST https://api.cartirra.com/v1/orders/ord_0193a1b2c3d47e5f8a9b0c1d2e3f4a5b/pay-on-delivery/collected \
-H "Authorization: Bearer $CARTIRRA_SECRET_KEY"
Collected marks the order paid and sends the receipt. …/pay-on-delivery/not-paid cancels it instead. A shopper who leaves two such orders unpaid isn't offered pay on delivery again.
No code: payment links
To sell without building a checkout, create a payment link for a cart and share its url (WhatsApp, Instagram, SMS):
curl -X POST https://api.cartirra.com/v1/payment-links \
-H "Authorization: Bearer $CARTIRRA_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Party jollof for 10",
"lines": [{ "name": "Party jollof", "quantity": 1, "unit_price": { "amount": "25000.00", "currency": "NGN" } }],
"max_uses": 20
}'
Each shopper who opens the link gets their own checkout for that cart. uses counts the paid orders. Set status: "inactive" with PATCH /v1/payment-links/{id} to stop it. Orders from a link have metadata.paymentLink on their checkout session.
Going live
- Finish your business verification in the dashboard so live mode is switched on.
- Swap
sk_test_for yoursk_live_key andpk_test_forpk_live_. Test and live data never mix, so live starts empty. - Add a live webhook endpoint. Each mode has its own endpoint and signing secret.