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
- The business owner creates one key per till in Likom Business, set to that till's branch, with
customers:identify,transactions:writeand, if you show rewards,redemptions:write. - Store the key in the POS's settings on the device or your server, not in your code.
- Your scanner must read QR codes from a phone screen. Most 2D barcode scanners and tablet cameras do.
The checkout flow
- Ring up the order as usual.
- "Do you have Likom?" The customer opens Likom and shows their QR. Scan it and call
POST /customers/identify. - If the answer is
kind: "person", showcardsand let the customer pick; callPOST /customers/card. - Optional: call
POST /transactions/previewwith the order total to show "You'll earn 24 points". - Optional: show
card.rewardswithavailable: true. If the customer uses one, apply itspriceor discount to the order and callPOST /redemptions. - Take payment. Only after it succeeds, call
POST /transactionswith the amount paid and your receipt number. - 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):
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:
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: retryPOST /transactionswith 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, waitretry_afterseconds. - Don't retry other
4xxerrors; show themessageto 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:
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:
- Create a separate test business in Likom Business (free), with a test branch and a card program.
- Make its API keys there. Nothing you do touches the real business.
- 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.
- 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 /transactionsandPOST /redemptionshas an Idempotency-Key tied to the order, reused on retry. - Errors show
messageto 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]