CartirraAPI
Get API keys

Getting started

Cartirra Popup and Redirect

Open the checkout over your own page with one script tag (Cartirra Popup), or send shoppers to Cartirra's checkout page (Cartirra Redirect). Then confirm the order on your server.

There are two ways to take a shopper through checkout:

  • Cartirra Popup opens the checkout over your page in a secure frame. You add one script tag. Steps 1 and 2 below.
  • Cartirra Redirect sends the shopper to Cartirra's checkout page, with no script on your side. Step 3 below.

Either way, the shopper signs in or checks out as a guest, chooses delivery or pickup, and pays by bank transfer or card. Card details are entered on your card provider's own page; they never touch your site or Cartirra.

You need two things from your server for each checkout: your public key (pk_test_… or pk_live_…, safe in the browser) and the session's client_secret from creating a checkout session.

The API is snake_case (client_secret); this script's options are JavaScript, so they're camelCase (clientSecret).

1. Add the script

Load it once, on any page that can start a checkout:

<script src="https://checkout.cartirra.com/v1/cartirra.js" async></script>

The script is small (about 2 KB) and defines window.Cartirra. It stays at /v1/ and only ever gets compatible fixes; a breaking change would ship as /v2/.

2. Open Cartirra Popup

When the shopper presses your pay button, create a session on your server, then open the checkout with its client_secret:

<button id="pay">Pay</button>
<script>
  document.getElementById('pay').addEventListener('click', async () => {
    // Your endpoint: it calls POST /v1/checkout-sessions with your secret key
    // and returns the session's client_secret to the browser as { clientSecret }.
    const { clientSecret } = await fetch('/api/checkout', { method: 'POST' }).then((r) => r.json());

    Cartirra.open({
      publicKey: 'pk_test_your_key',
      clientSecret,
      onSuccess: ({ orderId, reference, successUrl }) => {
        // The shopper has paid. Thank them, then confirm on your server (step 4).
        // Don't fulfil from here: anyone can call this from their own browser.
      },
      onClose: () => {
        // The shopper closed the checkout without paying. Their session stays open until it expires.
      },
      onError: ({ code, message }) => {
        // The checkout couldn't start, e.g. INVALID_PUBLIC_KEY.
      },
    });
  });
</script>
OptionRequiredWhat it does
publicKeyYesYour public key. Test keys open test sessions; live keys open live ones.
clientSecretYesFrom the session you just created. Use it for one checkout, then discard it.
onSuccessNoCalled once when the payment succeeds, with the order's orderId and reference, and the session's success_url (as successUrl). If the session has a success_url, the checkout goes there 5 seconds later by itself (see below). Use it to thank the shopper, never to fulfil: anyone can call it from their browser. Fulfil on the signed payment.succeeded webhook.
onCloseNoCalled when the checkout closes without a payment.
onErrorNoCalled when the checkout can't start, with the error code and message.

Cartirra.close() closes an open checkout from your code.

After payment: your success_url

If you created the session with a success_url, the "Order confirmed!" screen counts down 5 seconds ("Taking you back to …") and then takes the shopper there. The shopper can tap Stay here to stop it, or Continue shopping to go at once. Without a success_url, the checkout stays on "Order confirmed!" until the shopper closes it.

No JavaScript of your own

If you render the session on your server, a button with data attributes opens the checkout on click and goes to data-success-url 5 seconds after payment (the session's success_url wins when it has one):

<button
  data-cartirra-checkout
  data-public-key="pk_test_your_key"
  data-client-secret="cs_0193…_secret_…"
  data-success-url="https://shop.example.com/thanks"
>Pay ₦9,000.00</button>

Show Cartirra on your page

Shoppers trust a checkout they recognise. Let them see it's Cartirra on your page, before the checkout opens. The script draws these as soon as it loads, in Cartirra's colours and with the Cartirra mark, and your site's CSS can't change how they look. Where they sit (margins, and width unless you ask for full width) stays up to your layout.

A branded button. Add data-cartirra-style="branded" to a checkout button, and write "Checkout with Cartirra" in it so the words are there even before the script loads:

<button
  data-cartirra-checkout
  data-cartirra-style="branded"
  data-public-key="pk_test_your_key"
  data-client-secret="cs_0193…_secret_…"
>Checkout with Cartirra</button>

If your page opens the checkout itself with Cartirra.open, use data-cartirra-button instead: the same look, and the click stays yours.

<button id="pay" data-cartirra-button data-cartirra-width="full">Checkout with Cartirra</button>
AttributeValuesDefault
data-cartirra-labelcheckout (Checkout with Cartirra), pay (Pay with Cartirra), buy (Buy with Cartirra)checkout
data-cartirra-themedark (black button) or light (white with a border)dark
data-cartirra-widthfull to fill its containeras wide as its words

A badge under your own button. Keep your button as it is and add the badge under it. It reads "🔒 Secured by Cartirra", like the bottom of the checkout:

<button id="pay">Place order</button>
<div data-cartirra-badge></div>

On a dark background, add data-cartirra-theme="dark" to the badge.

From JavaScript. Pages that render later (React, Vue and similar) are branded as they appear. You can also brand an element yourself:

Cartirra.button(document.getElementById('pay'), { label: 'pay', theme: 'light', fullWidth: true });
Cartirra.badge(document.getElementById('secured'), { theme: 'dark' });

3. Or use Cartirra Redirect

If you can't add a script (a link in an email or a chat, a mobile app's web view), send the shopper to Cartirra's checkout page instead. The client secret goes in the URL fragment, which browsers don't send to servers, and the page removes it from the address bar as soon as it loads:

https://checkout.cartirra.com/#/pay/<client_secret>?pk=<public_key>

Cartirra Popup falls back to Cartirra Redirect by itself if the frame can't start (for example, a strict browser extension blocks it). After payment it takes the shopper to the session's success_url after the same 5-second countdown, or at once with Continue shopping.

4. Confirm the order on your server

onSuccess runs in the shopper's browser, so treat it as a signal to show a thank-you message, not as proof of payment. Fulfil the order when your server hears about it:

  • Webhooks: order.created and payment.succeeded arrive at your endpoint, signed. See Webhooks.
  • Or ask: GET /v1/checkout-sessions/{id} shows completed and the order_id once paid.

The shopper also gets a receipt by email, with a link to the receipt online.

Allow only your sites

Your checkout settings' allowed origins (allowed_origins) list the sites that may open your checkout, such as https://shop.example.com (no path; up to 20). When the list is empty, any site can open it with your public key. Once you add origins, the checkout refuses to start anywhere else and shows the shopper "This website can’t use this checkout" (EMBED_ORIGIN_NOT_ALLOWED).

Content Security Policy

If your site sends a Content-Security-Policy header, allow the script and the frame:

script-src 'self' https://checkout.cartirra.com;
frame-src https://checkout.cartirra.com;
img-src 'self' data:;

img-src data: is for the Cartirra mark on branded buttons and badges, which comes inside the script.

The checkout calls the Cartirra API from its own frame, so your connect-src doesn't need to change.

Your brand

The checkout uses your Checkout settings logo and brand colour: the colour on buttons, selections and highlights. If a colour is too light or too mid-toned for readable text, the checkout darkens it slightly where text sits on it, so it stays readable (WCAG AA).

Test it

With test keys, a Test mode · No real money moves strip runs across the top of the checkout, and payment screens show a Test mode panel: Simulate the transfer pays a bank transfer, and Simulate a card payment pays a card when no card provider is connected. If you've connected a provider's test keys (Paystack, Flutterwave, Monnify), card payments go to that provider's test page instead. See Test mode.