Vending and self-service machines
This is how a machine takes Kaspi payment without a card terminal. The machine's software creates an invoice through the Qut Pay API. The buyer scans the QR on the screen with the Kaspi.kz app, or confirms in that app an invoice sent to their own number. The money goes straight to your Kaspi Pay account, while Qut Pay watches the payment and tells your server "paid": only then does the machine dispense.
The guide is written for the owner of the machines and for the developer of the machine's software. It applies equally to coffee and snack machines, water and milk dispensers, car-wash bays, vacuums, lockers, laundromats, massage chairs, power-bank stations and turnstiles. Qut Pay does not sell or install hardware: the controller and the software are yours or your integrator's.
Qut Pay is an independent service that works on top of your own Kaspi Pay account. We are not affiliated with Kaspi Bank JSC and make no promises on behalf of Kaspi. Kaspi and Kaspi Pay are trademarks of their owner.
1. The two ways to pay
| QR on the screen | Invoice to a number | |
|---|---|---|
| In the API | kind: "qr" (the default) | kind: "phone" and customer.phone |
| What the buyer does | Scans the QR with the Kaspi.kz app and confirms the payment. Types nothing | Types their number on the machine, opens the Kaspi.kz app and confirms the invoice that arrived |
| What the machine needs | A screen that fits a QR | A keypad for the number. The screen may be small |
| Amount | Up to two decimals | Whole tenge only |
| Invoice lifetime | About 3 minutes. The exact time is in the expiresAt field of the response | 24 hours unless cancelled. So you cancel the invoice yourself when the session ends |
| Cancelling | The QR cannot be withdrawn on Kaspi's side: it can be paid until expiresAt | The invoice is closed at Kaspi too |
| Common failure | The buyer is too slow and the QR expires | The number is mistyped or is not a Kaspi customer |
Which one to choose. Put a QR on a machine with a screen: the buyer types nothing and there are fewer mistakes. If there is no screen or it is too small, send an invoice to the number. You can offer both: the QR as the main way, "invoice to a number" as the alternative.
In both ways the invoice is paid in the Kaspi.kz app.
No screen and no keypad? Then there is a third way: a QR of a permanent payment link (qut.kz/p/<slug>) is stuck on every bay or door. It is described in the knowledge base. This guide is about the two ways where every sale gets a new invoice.
2. What is needed
| What | Details |
|---|---|
| The machine's software with internet access | The invoice is created in the cloud, so the machine needs a GSM modem or Wi-Fi. Without internet this setup does not work |
| A Kaspi Pay business account and a cashier | In Kaspi Pay you add an employee with the «Кассир» role on a separate number and connect it in the cabinet: Getting started. Test mode needs no cashier |
| An API key | Cabinet → Integrations → API keys. A test key is qp_test_…, a live key is qp_live_… |
| A webhook | Cabinet → Integrations → Webhook. The address must be https with a real domain: IP addresses and tunnel addresses are refused. At most 5 addresses per organization |
| A tariff | A flat monthly subscription. Its limits are in the table below |
| Fiscal receipts | Issuing a receipt is the seller's duty. How it is solved: Fiscal receipts |
Where the software lives
There are two setups.
- Machine → your server → Qut Pay. This is the one we recommend. The API key stays on the server only. The webhook comes to the server. The server sends the machine the "dispense" command over your own channel (for example MQTT or HTTP).
- The machine calls the Qut Pay API itself. Fits when there is no server. The machine has no public
httpsaddress, so it cannot receive a webhook: it polls the invoice status withGET /invoices/{id}. Create a separate key for every machine. A default key has only theinvoices:readandinvoices:writescopes, no refund scope. If a key leaks, you delete that one key only.
Tariff and limits
| Tariff | Per month | Monthly limit (paid payments) | Daily cap (invoices created) |
|---|---|---|---|
| Free | 0 ₸ | 20 | 50 |
| Trial (7 days) | 0 ₸ | — | 50 |
| Start | 4 990 ₸ | 800 | 200 |
| Business | 14 900 ₸ | 4 000 | 1 500 |
| Chain | 39 900 ₸ | 15 000 | 5 000 |
| Partner | 79 900 ₸ | 30 000 | 2 000 |
Only paid invoices count toward the monthly limit. The daily cap counts invoices created today, paid or not. This matters for a machine: every session a buyer started and abandoned is an invoice too. The trial starts with the first live invoice, and when it ends the organization moves to the Free tariff. The Partner tariff is enabled by the platform. Qut Pay takes no percentage of a payment, while Kaspi charges its own fee separately, on its own terms. More: Pricing and limits.
3. Step by step
Go through everything in test mode (sandbox) first. In test mode Kaspi is not called and no money moves, while webhooks are delivered for real. The API address is https://api.qut.kz/api/v1. Every request carries the X-API-Key header.
Step 1. Create an invoice
At the moment the buyer has picked a product:
POST https://api.qut.kz/api/v1/invoices
X-API-Key: qp_test_…
Content-Type: application/json
Idempotency-Key: vm-014-A2-s000123
{
"amount": 250,
"description": "Machine 14: water 5 l",
"externalOrderId": "vm-014-s000123",
"metadata": { "machine": "VM-014", "slot": "A2", "session": "s000123" }
}
Response 201 (main fields):
{
"id": "inv_01M1X22B2DSV3MNE1XP5S2YG41",
"status": "pending",
"mode": "sandbox",
"kind": "qr",
"amount": 250,
"qrUrl": "https://…",
"qrImageUrl": "https://qut.kz/pay/inv_01M1X22B2DSV3MNE1XP5S2YG41/qr.svg",
"qrPngUrl": "https://qut.kz/pay/inv_01M1X22B2DSV3MNE1XP5S2YG41/qr.png",
"expiresAt": "2026-11-27T10:03:00.000Z"
}
Show the qrImageUrl (SVG) or qrPngUrl (PNG) picture on the screen. qrUrl is the text inside the QR: the machine can draw the QR from it by itself. expiresAt is for the timer. metadata and externalOrderId come back unchanged both in the webhook and in the status response: that is how you know which machine and which slot it is.
For an invoice to a number the body gets kind and customer.phone, and the amount must be whole tenge:
{
"amount": 250,
"kind": "phone",
"customer": { "phone": "77011234567" },
"description": "Machine 14: water 5 l",
"externalOrderId": "vm-014-s000124",
"metadata": { "machine": "VM-014", "slot": "A2", "session": "s000124" }
}
The number is accepted as +7 701 123 45 67, 87011234567 or 77011234567. In this way description is up to 60 characters (100 for a QR) and is shown in the invoice as a comment.
Step 2. Simulate the payment
POST https://api.qut.kz/api/v1/invoices/inv_01M1X22B2DSV3MNE1XP5S2YG41/simulate
X-API-Key: qp_test_…
Content-Type: application/json
{ "status": "paid" }
The values "failed" and "expired" exist as well. This request works in test mode only.
Step 3. Receive "paid"
Your server receives a webhook:
POST https://server.example.kz/qutpay-webhook
X-Webhook-Event: invoice.paid
X-Webhook-Timestamp: 1764237780
X-Webhook-Signature: sha256=3f1a…
X-Webhook-Delivery: 17
{ "event": "invoice.paid", "invoice": { "id": "inv_01M1X22B2DSV3MNE1XP5S2YG41", "status": "paid", "amount": 250, "externalOrderId": "vm-014-s000123", "metadata": { "machine": "VM-014", "slot": "A2", "session": "s000123" }, "paidAt": "…" }, "sentAt": "…" }
You can learn the same result by asking for the status:
GET https://api.qut.kz/api/v1/invoices/inv_01M1X22B2DSV3MNE1XP5S2YG41
X-API-Key: qp_test_…
The response has "status": "paid".
Step 4. The "dispense" command
This is your software's job; the Qut Pay API has no such request. The server verifies the signature, takes the machine and the slot from metadata and sends the machine the command. Dispense only once per invoice.id.
Step 5. Test closing and refunding
- Create a new invoice and cancel it with
POST /invoices/{id}/cancel(section 5). - Send that invoice
paidthroughsimulate: aninvoice.paidwith"late": truearrives. - Refund it with
POST /invoices/{id}/refund. The key needs therefunds:writescope, a test key too. - Test an invoice to a number with
77000000404: it returns thekaspi_customer_not_founderror.
Step 6. Live mode
- Connect the Kaspi cashier.
- Switch the organization to live mode (
live) in the cabinet. - Create a live key (
qp_live_…) and put it in place of the test key. While the organization is in live mode a test key creates no invoice:409 key_mode_mismatch. - Make one small real payment and try refunding it.
The trial (7 days) starts with the first live invoice.
4. Dispense only on a confirmed payment
The only signal for the machine is the invoice status paid. There are two ways to learn it.
Webhook and signature
Every delivery carries the X-Webhook-Signature (sha256=<hex>) and X-Webhook-Timestamp (unix seconds) headers. Verify every delivery:
expected = hex( HMAC_SHA256( secret, timestamp + "." + rawBody ) )
valid = timingSafeEqual(expected, signatureWithout"sha256=") && |now - timestamp| <= 300
- Take the body as unchanged bytes, before parsing JSON.
- Answer
2xxwithin 8 seconds. Otherwise the delivery is repeated: 11 attempts in all, over about 2 hours. - So the handling must be idempotent: even if one
invoice.idarrives as "paid" twice, the machine dispenses once. - Do not accept a delivery with a wrong signature. An unverified "paid" would start the machine for free.
- The SDKs have ready-made functions: Node.js
verifyWebhook, Pythonverify_webhook, PHP\QutPay\Webhook::verify.
Polling the status from the server
You read the status field of the GET /invoices/{id} response. Ask once a second for the first 30 seconds. If there is no webhook, keep asking afterwards, every 2–3 seconds. At the end of the session add ?live=1 once: if the invoice is still open, we ask Kaspi at that very moment.
It is best to run the webhook and the polling together: you accept whichever arrives first.
How fast. We learn about a payment by asking Kaspi: an invoice younger than three minutes is checked about every 3 seconds. The webhook leaves the moment we learn. So the message arrives not instantly but a few seconds late. There is no guaranteed time.
The session timer
- QR. Take the timer from
expiresAtand do not wait longer. - Invoice to a number. The invoice lives 24 hours, so you set the timer yourself. Keep it within three minutes: an older invoice is checked less often, every 20 seconds.
What to show while waiting
| State | On the screen |
|---|---|
| The invoice is being created | "Please wait" |
pending, QR | The QR, the amount, a countdown, "Scan with the Kaspi.kz app", a "Cancel" button |
pending, invoice to a number | "The invoice was sent to the number …4567. Open the Kaspi.kz app and confirm", the amount, a countdown, a "Cancel" button |
paid | "Payment received", the product is dispensed |
failed | "Payment failed": the buyer declined the invoice or Kaspi rejected the payment. Offer a new session |
| The timer ran out | "Time is up". Cancel the invoice and return the screen to its start state |
5. Closing the session
When the timer runs out or the buyer presses "Cancel", close the invoice:
POST https://api.qut.kz/api/v1/invoices/inv_01M1X22B2DSV3MNE1XP5S2YG41/cancel
X-API-Key: qp_live_…
The response is the same invoice, status is cancelled, plus a stillPayableUntil field (abridged):
{ "id": "inv_01M1X22B2DSV3MNE1XP5S2YG41", "status": "cancelled", "kind": "qr", "stillPayableUntil": "2026-11-27T10:03:00.000Z" }
What cancelling really does:
- Invoice to a number. The invoice is closed at Kaspi too.
stillPayableUntilisnull. - QR. A QR cannot be withdrawn on Kaspi's side. With us the invoice becomes
cancelled, but the QR can be paid untilexpiresAt. That time is in thestillPayableUntilfield. - The invoice is not open.
409 invoice_not_open. Read the status: the invoice may have turnedpaidat that very moment. - Kaspi did not confirm the cancellation.
502 cancel_failed. The invoice stays open; repeat the request.
Do not wait for the invoice.expired message: it may come later than expiresAt. If Kaspi does not say so itself, we wait 90 more seconds before closing the invoice. Close the session on your own timer.
Late payment
Money can still arrive for a closed invoice (cancelled or expired): for example, the buyer scanned the QR at the last second and confirmed a little later. The invoice then turns paid, and the invoice.paid message carries "late": true. We keep checking a closed invoice for one more hour after expiresAt. An invoice closed without a check while the cashier connection was down is checked for longer, so a late-payment message may come later too.
There is one rule: a late payment is accepted and refunded. By then the machine may be serving another buyer, so nothing is dispensed and the money goes back:
POST https://api.qut.kz/api/v1/invoices/inv_01M1X22B2DSV3MNE1XP5S2YG41/refund
X-API-Key: qp_live_…
Content-Type: application/json
{ "reason": "Paid after the session was closed" }
Without amount the whole sum is refunded. The refund conditions are in section 8.
6. Idempotency
A dropped connection and a machine that sends the request again are normal. So that a retry never creates a second invoice, give every session one key: the machine, the slot and the session number.
Idempotency-Key: vm-014-A2-s000123
- When the same key comes again, the same invoice is returned: HTTP
200, with"idempotentReplay": truein the response. - When the same key comes with another amount, another
kindor another number:409 idempotency_conflict. The earlier invoice's id is in thedetails.invoiceIdfield. - The key is looked up within the organization and is shared by test and live modes. Only its first 120 characters count.
- Even if the earlier invoice has expired, was cancelled or was paid, the same key returns that same invoice. A new invoice is created under the same key only when the earlier one was not created (
failed). For a new session take a new session number. - The session counter must not start from zero when the machine restarts. Otherwise an old key repeats and an old invoice comes back.
- If
idempotentReplay: truearrives, look at the invoice'sstatusfield. Do not dispense a second time for an invoice that was already paid and dispensed.
The same holds on the webhook side: keep the "dispensed" mark by invoice.id and write it before the motor starts.
7. Several machines, several points, several legal entities
| Situation | How it maps in Qut Pay |
|---|---|
| One business, many machines | One organization, one tariff. You tell machines apart by metadata and externalOrderId |
| Separate reporting or separate access per point | A separate API key per point (or per machine) |
| Each point has its own cashier | Several cashiers are connected to one organization. You bind a key to one cashier (choose «Кассир» when creating the key, or connectionId) |
| Several legal entities (several sole proprietors or LLPs) | A separate organization for each: its own cashier, its own keys, its own webhooks, its own tariff |
| You serve other businesses' machines | Partner API: a separate organization per client. Referrals and Partner API |
What to know:
- The tariff belongs to the organization. The monthly limit and the daily cap are shared by all machines of the organization. Adding a cashier or a key does not raise the limit. Every organization has its own tariff; they do not add up.
- The money lands on the Kaspi Pay account the cashier belongs to. So open a separate organization for another legal entity.
- A key bound to a cashier creates live invoices only through that cashier and sees only its invoices. If that cashier's connection drops, the key does not switch to another cashier by itself.
- An unbound key works through the primary cashier. If the primary's connection drops, another active cashier of the same Kaspi business stands in.
- A webhook address can be bound to a key: that address then receives messages only about invoices created with that key.
- The request limit is counted per key: 200 write requests and 600 read requests a minute. If you poll the statuses of all machines often with one server key, the read limit runs out quickly. Let the webhook be the main channel.
A worked example: 10 machines with 50 sales a day each make 15 000 paid payments a month. That is the monthly limit of the Chain tariff.
8. Pitfalls
The buyer walked away without paying
The timer runs out, you cancel the invoice, the screen returns to its start state. An unpaid invoice does not count toward the monthly limit but does count toward the daily cap. Do not create invoices while the screen is idle: an invoice is created only after the buyer has picked a product.
The payment went through, the machine did not dispense
The money is on your Kaspi account, not with Qut Pay. So a refund is the seller's own action:
- Through the API:
POST /invoices/{id}/refund. Withoutamountthe whole sum is refunded; withamount, only that sum. - Or from the cabinet, on the invoice's page.
Conditions and limits:
- The key needs the
refunds:writescope. A default key does not have it:403 insufficient_scope. The scope is added by the cabinet owner. Do not put such a key into the machine; keep it on the server. - Only an invoice in the
paidorpartially_refundedstatus can be refunded. Otherwise409 invoice_not_refundable. - The refunds together never exceed the paid amount:
422 invalid_refund_amount. - The refund goes through the same cashier, and the money leaves your Kaspi account. If Kaspi does not carry it out:
502 refund_failed. 502 refund_unknownmeans Kaspi did not answer and the outcome is unknown. Do not repeat: read the invoice status. Until the outcome is settled, no new refund is accepted for this invoice (409 refund_pending_unknown); the organization's owner checks it in Kaspi and closes it in the cabinet.
Have the machine report the outcome of every command to the server: "dispensed" or "not dispensed". Then it is clear which invoice to refund.
The daily cap or the monthly limit is reached
| Error | What it means |
|---|---|
429 tariff_limit_reached | The payments received this month have reached the tariff's limit. Invoices created earlier can still be paid; new ones are not created |
429 tariff_daily_burst | The invoices created today have reached the daily cap |
429 request_rate_limited | The key's per-minute request limit was exceeded. The response has a Retry-After header |
On the machine: write "Kaspi payment is temporarily unavailable" and leave another way to pay. Do not retry these errors in a loop. When the monthly limit is 80 percent used, you get a warning in Telegram.
The number is wrong or is not a Kaspi customer
| Error | What it means | What to do |
|---|---|---|
422 invalid_phone | The number's format is wrong | Ask for the number again |
422 phone_required | kind: "phone" without a number | Send customer.phone |
422 amount_must_be_whole_tenge | An invoice to a number has tiyn in it | Make the amount whole tenge |
422 kaspi_customer_not_found | This number is not a Kaspi customer | Do not retry with the same number. Ask for another number or offer the QR |
502 kaspi_create_unconfirmed | Kaspi did not answer: the invoice may have reached the buyer | Close the session and write "if an invoice arrives, do not pay it". A retry with the same key returns the same answer |
We remember a kaspi_customer_not_found answer for that number for 10 minutes: a repeated request does not reach Kaspi.
On kaspi_create_unconfirmed you get a warning: check the «Счета» section of the Kaspi Pay app. If the buyer pays such an invoice, the money arrives but we do not see it: the machine dispenses nothing, and you refund the money yourself from Kaspi Pay.
The machine or the cashier is offline
- The machine has no internet. No invoice is created. Take Kaspi payment off the screen and leave another way to pay.
- The connection dropped after the QR was shown. The buyer may have paid in time. When the connection is back, read the invoice status first (
GET /invoices/{id}orGET /invoices?externalOrderId=…). If the invoice ispaid, dispense or refund, depending on whether the session is still open. - The Kaspi cashier's connection dropped. No new invoice is created:
kaspi_session_expired(HTTP 409 or 502). If no cashier is connected yet:400 kaspi_session_not_configured. You connect the cashier again in the cabinet. The cashiers' state is in theGET /accountresponse:connections[].statusmust beactive.
So keep a backup way to pay on the machine.
Never dispense on the buyer's word
Neither the words "I paid" nor a receipt or a screenshot on a phone proves a payment. There are only two proofs: an invoice.paid message with a verified signature, and the paid status in the GET /invoices/{id} response.
9. Frequently asked questions
Do cash and Kaspi work together? Yes. Qut Pay does not touch the machine's coin or bill acceptor: Kaspi payment is one more way added to your software. It is better to keep cash, because the cashier connection can drop.
How many cashier connections for N machines? One connection is enough for the machines of one business: Qut Pay does not limit the number of machines per connection. What limits you is the organization's tariff and the key's request limit. A second cashier is for counting points separately and for standing in when the primary drops. Try a large fleet on a few machines first.
What does the buyer see? With the QR: the Kaspi.kz app's scanner, then the payment confirmation screen. With an invoice to a number: an invoice arrives in the app with the amount and the description text; the invoice notice shows the cashier's number. After paying they see "Payment received" on the machine's screen.
How are receipts issued? Issuing a fiscal receipt is the seller's duty; Qut Pay does not issue it on your behalf. The simplest way is described on the Fiscal receipts page. The receiptUrl field of a paid invoice holds Qut Pay's receipt page: it is a payment confirmation, not a fiscal receipt.
How fast does the payment status arrive? Usually within a few seconds: we check a fresh invoice about every 3 seconds. There is no guaranteed time, so run the webhook and the status polling together.
Can one QR be printed and stuck on the machine? An invoice's QR cannot be used as a sticker: it is meant for one sale and is short-lived. A sticker needs the QR of a permanent payment link: self-service machines.
Does Qut Pay supply a controller or a module? No. We create the invoice, watch the payment and send the webhook. The hardware and the machine's software are yours or your integrator's.
Ready-made code and help
- SDK: Node.js, PHP, Python.
- The full API description: Website integration, OpenAPI: api.qut.kz/docs.
- If you hand it to an AI agent: api.qut.kz/llms.txt.
- Write your questions from the Support page of the cabinet. Name the machine, the invoice (
inv_…) and the error code. Do not send the API key.
Need help? WhatsApp +77788813333 · kazprose@gmail.com · 09:00–21:00 (Алматы)
You can also write from the dashboard: Support.
Qut Pay is an independent service, not affiliated with Kaspi Bank JSC. Kaspi and Kaspi Pay are trademarks of their owner.