Cashback used to mean one thing: a percentage back on a card or wallet payment. In India, a newer model is growing fast. Brands print a unique QR code on every pack, the buyer scans it after purchase, and money lands in their UPI account within minutes. It looks simple from the outside. Under the hood it is a small but interesting system that has to solve code generation, fraud, and payouts at scale.
This post walks through how a typical QR cashback platform is put together.
1. Generating codes that cannot be guessed
Every pack needs its own code, and those codes must be impossible to predict. If codes were sequential, anyone could script a loop and claim thousands of rewards.
A common approach:
- Generate a random token per unit (for example 12 to 16 characters from a URL safe alphabet), or sign a serial number with an HMAC so the server can verify it without storing every code in advance.
- Encode a short URL into the QR, such as
https://example.com/s/<token>, so the scan works with any phone camera and needs no app. - Store each token with its batch, SKU, campaign and reward amount, plus a status field:
unused,claimed,blocked.
Printing partners receive batches as CSV files, and the codes are usually hidden under a scratch panel so they cannot be read on the shelf before purchase.
2. The claim flow
When a buyer scans, the backend has to answer three questions in order:
- Is this code real? Look up or verify the token. An unknown token means a counterfeit or a typo.
- Has it been used? Claiming must be atomic. Use a conditional update such as
UPDATE codes SET status = 'claimed' WHERE token = ? AND status = 'unused'and check the affected row count, so two simultaneous scans cannot both win. - Who gets the reward? Attach the claim to a verified user, normally by mobile number with OTP.
A nice side effect of step 1 is product authentication. A scan that returns "unknown" or "already claimed" on a pack that was just opened is a strong signal of a fake or tampered product. Some platforms turn this into a visible feature, for example genuine product verification shown to the buyer right after the scan.
3. Fraud controls that actually matter
Money attracts abuse, so a few controls go a long way:
- Rate limits per device, per IP and per mobile number.
- Velocity checks: one user claiming 40 codes from the same batch in an hour is not a normal shopper.
- Geo sanity checks: a batch shipped to Kerala being scanned in bulk in one city elsewhere deserves a review.
- Hold and release: small rewards pay instantly, unusual patterns go to a short manual review queue.
- Blocking whole batches if a printer leak is discovered.
4. Wallets and UPI payouts
Paying out every few rupees as a separate bank transfer would be expensive and noisy, so most platforms credit an internal wallet first. The wallet is a ledger, not a single balance column: every credit and debit is an immutable row, and the balance is derived from it. That makes reconciliation and audits much easier.
When the user withdraws, the platform calls a bank's UPI payout (disbursement) API. Important details:
- Send an idempotency key with every payout request, so a retry after a timeout never pays twice.
- Treat payouts as asynchronous. Record the request as
pending, then confirm via callback or status polling. - Run a daily reconciliation between your ledger and the bank statement.
5. What brands get out of it
For the brand, each scan is a first party data point: which SKU, which city, what time, and whether this buyer has scanned before. That turns a product sold through thousands of small retail stores into something closer to a direct relationship, which is the real reason brands run these cashback and loyalty campaigns instead of plain price discounts.
Wrapping up
A QR cashback system is a good example of a product that looks like marketing but is really an exercise in idempotency, concurrency and ledger design. If you want to see the consumer side of this flow in production, Assured Rewards is one Indian platform built on this model, from scan to UPI withdrawal.
If you have built something similar, I would love to hear how you handled duplicate scans and payout retries in the comments.