All documentation

POS integration guide

This guide walks through a typical till integration: the customer pays at your POS and earns on their Likom card in the same checkout.

Before you start

  1. The business owner creates one key per till in Likom Business, set to that till's branch, with customers:identify, transactions:write and, if you show rewards, redemptions:write.
  2. Store the key in the POS's settings on the device or your server, not in your code.
  3. Your scanner must read QR codes from a phone screen. Most 2D barcode scanners and tablet cameras do.

The checkout flow

  1. Ring up the order as usual.
  2. "Do you have Likom?" The customer opens Likom and shows their QR. Scan it and call POST /customers/identify.
  3. If the answer is kind: "person", show cards and let the customer pick; call POST /customers/card.
  4. Optional: call POST /transactions/preview with the order total to show "You'll earn 24 points".
  5. Optional: show card.rewards with available: true. If the customer uses one, apply its price or discount to the order and call POST /redemptions.
  6. Take payment. Only after it succeeds, call POST /transactions with the amount paid and your receipt number.
  7. Print or show the message, such as "Maya earned 24 points".

Record the purchase after payment, with the amount actually paid. If payment fails, simply don't record it; the ticket expires on its own.

Sample code

Node.js 18+ (built-in fetch):

javascript
const API = "https://api.likom.co/v1/partner";
            const KEY = process.env.LIKOM_API_KEY; // from your POS settings, never in code
            
            async function call(method, path, body, idempotencyKey) {
              const headers = { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" };
              if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
              const res = await fetch(API + path, { method, headers, body: body && JSON.stringify(body) });
              const data = await res.json();
              if (!res.ok) throw Object.assign(new Error(data.detail.message), { status: res.status, code: data.detail.code });
              return data;
            }
            
            // 1. Scan
            const scan = await call("POST", "/customers/identify", { code: scannedText });
            if (scan.kind !== "card") { /* show scan.cards and call /customers/card */ }
            const ticket = scan.card.ticket;
            
            // 2. After payment
            const sale = await call("POST", "/transactions",
              { ticket, amount: order.total.toFixed(2), receipt_ref: order.number },
              `order-${order.id}`);
            console.log(sale.message); // "Recorded. Maya earned 24 points."

Python 3 with requests:

python
import os
            import requests
            
            API = "https://api.likom.co/v1/partner"
            session = requests.Session()
            session.headers["Authorization"] = f"Bearer {os.environ['LIKOM_API_KEY']}"
            
            def call(path, body, idempotency_key=None):
                headers = {"Idempotency-Key": idempotency_key} if idempotency_key else {}
                r = session.post(API + path, json=body, headers=headers, timeout=15)
                data = r.json()
                if not r.ok:
                    raise RuntimeError(f"{data['detail']['code']}: {data['detail']['message']}")
                return data
            
            scan = call("/customers/identify", {"code": scanned_text})
            ticket = scan["card"]["ticket"]
            sale = call("/transactions", {"ticket": ticket, "amount": "24.50", "receipt_ref": "OR-10482"},
                        idempotency_key="order-10482")
            print(sale["message"])

Timeouts and retries

  • Use a timeout of about 15 seconds.
  • On a timeout, a dropped connection, or a 5xx: retry POST /transactions with the same Idempotency-Key and the same body. You get the first result (replayed: true) if it went through, or it's recorded now if it didn't. It can't be recorded twice.
  • On 429, wait retry_after seconds.
  • Don't retry other 4xx errors; show the message to the cashier.
  • If Likom can't be reached during checkout, finish the sale anyway. Loyalty must never block a payment. Staff can record it later at the Counter in Likom Business with the receipt number.

Refunds and voids

  • Voided within 10 minutes at the same till: POST /transactions/{id}/undo.
  • Later refunds: a key with transactions:refund (for example your back office), or a manager in Likom Business.
  • If the points were already spent, the undo is refused (409 already_spent): show the message and let a manager decide in Likom Business.

Nightly reconciliation

With a key that has transactions:read (usually your back office, not a till), fetch yesterday's transactions and match them to your sales by receipt_ref:

bash
curl -G https://api.likom.co/v1/partner/transactions \
              -H "Authorization: Bearer $LIKOM_BACKOFFICE_KEY" \
              --data-urlencode "since=2026-11-15T00:00:00+08:00" \
              --data-urlencode "until=2026-11-16T00:00:00+08:00" \
              --data-urlencode "limit=200"

Follow next_cursor until it's null. Look for sales with no transaction (a missed recording), and transactions with no sale (worth asking about).

Testing

Test keys and a sandbox are coming. Until then:

  1. Create a separate test business in Likom Business (free), with a test branch and a card program.
  2. Make its API keys there. Nothing you do touches the real business.
  3. Sign up for a Likom account on your own phone at likom.co, and add the test business's card by scanning its card QR.
  4. Scan your own Likom QR with your POS and run the full flow, including retries with the same Idempotency-Key, undo, and an expired scan (wait 15 minutes).

Go-live checklist

  • One key per till, set to its branch, with only the permissions it needs.
  • Keys stored outside your code; logs show only the prefix.
  • Purchases recorded only after payment, with the amount paid and a unique receipt number.
  • Every POST /transactions and POST /redemptions has an Idempotency-Key tied to the order, reused on retry.
  • Errors show message to the cashier; checkout continues if Likom is unreachable.
  • Cashiers know how to ask "Do you have Likom?" and what to do when a QR has expired (ask the customer to show it again).

Questions? Write to [email protected] with your key's prefix (never the whole key).

Still need help? Troubleshooting · [email protected]