Qut Pay (Kaspi QR payments)
v0.1.5Kaspi QR payments (Kazakhstan) via Qut Pay: invoices, refunds, subscriptions, payment links.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
qutpay_account Qut Pay account and mode
Returns the organization behind the API key: mode (sandbox or live), tariff and limits, connected Kaspi cashiers, provider status. Call this first.
qutpay_create_invoice Create a Kaspi invoice
Creates an invoice (QR by default, or pushed to the customer's Kaspi.kz app with kind="phone"). Returns payUrl (hosted pay page), qrImageUrl, deepLink, expiresAt (~3 min). Always pass idempotencyKey (e.g. "order-1001") so a retry never creates a second invoice. Amount in KZT, ≤ 2 decimals; whole tenge for kind="phone".
| Parameter | Type | Description |
|---|---|---|
amount * | number | Amount in KZT, e.g. 2500 or 1500.5 |
customer | object | |
description | string | Shown to the customer, e.g. "Order #1001" |
externalOrderId | string | Your order id; later GET /invoices?externalOrderId finds it |
failUrl | string | |
idempotencyKey | string | Unique per order; same key → same invoice |
kind | string | "qr" (default) or "phone" (invoice pushed into the customer's Kaspi.kz app; needs customer.phone) |
metadata | object | Returned unchanged in webhooks |
successUrl | string |
qutpay_create_topup Create a balance top-up invoice
Balance top-up for a user of the merchant's own service (AI service, SaaS, website): a QR invoice whose metadata is { ref: userRef, pack, qutpay_kind: "topup" }. The merchant keeps the balance in their own system and credits it on the invoice.paid webhook (idempotent by invoice id; subtract on invoice.refunded). Qut Pay holds no balance. Not for digital goods inside Telegram bots (Telegram requires Stars there). Returns payUrl like qutpay_create_invoice.
| Parameter | Type | Description |
|---|---|---|
amount * | number | Amount in KZT; packs from 1 000 KZT make sense because of the Kaspi fee |
userRef * | string | Your user id to credit: 1–64 chars, A–Z a–z 0–9 _ . : - |
description | string | Shown to the customer; default "Баланс толтыру" |
idempotencyKey | string | Unique per top-up attempt |
pack | Pack id or label, e.g. "pro-600" — returned in metadata.pack | |
successUrl | string |
qutpay_get_invoice Get invoice status
Reads one invoice by id (inv_…). live=true asks Kaspi right now instead of the cached status. Status flow: new → pending → paid | failed | expired | cancelled; paid → partially_refunded → refunded.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
live | boolean |
qutpay_list_invoices List invoices
Lists invoices of the organization, newest first. Filter by status, externalOrderId, date range (ISO), limit ≤ 50, offset for paging.
| Parameter | Type | Description |
|---|---|---|
externalOrderId | string | |
from | string | ISO date/time, inclusive |
limit | integer | |
offset | integer | |
status | string | |
to | string | ISO date/time, exclusive |
qutpay_cancel_invoice Cancel an open invoice
Closes a pending invoice. A QR may still be paid until expiresAt — then invoice.paid arrives anyway; handle it.
| Parameter | Type | Description |
|---|---|---|
id * | string |
qutpay_refund_invoice Refund a paid invoice
Full refund (omit amount) or partial refund of a paid invoice. Needs the refunds:write scope. With a LIVE key real money is returned to the customer, so confirm=true is required and the merchant must have asked for this refund explicitly.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
amount | number | Omit for a full refund |
confirm | boolean | Required (true) with a live key |
reason | string |
qutpay_simulate_payment Simulate a payment (sandbox only)
Completes a sandbox invoice as paid / failed / expired without Kaspi, so the whole flow including the merchant's webhook can be tested. Refuses to run with a live key.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
status | string | Default "paid" |
qutpay_list_subscriptions List scheduled invoices (subscriptions)
Lists recurring invoice schedules (subscriptions), newest first. Needs the invoices:read scope.
| Parameter | Type | Description |
|---|---|---|
limit | integer | |
offset | integer | |
status | string |
qutpay_get_subscription Get one subscription
Reads a recurring invoice schedule by id (sub_…): status, amount, interval, nextRunAt, last run and its error, customerUrl. Needs the invoices:read scope.
| Parameter | Type | Description |
|---|---|---|
id * | string |
qutpay_create_subscription Create a subscription (recurring invoices)
Creates a schedule that issues an invoice every N days/weeks/months (gym pass, tutoring, rent, SaaS plan). Each run is an invoice the customer confirms — in the Kaspi.kz app (kind="phone") or through a pay link; Kaspi has no card-on-file auto-debit. The customer's own page (customerUrl) shows the schedule. startAt sets the first run (default now). Needs subscriptions:manage or invoices:write.
| Parameter | Type | Description |
|---|---|---|
amount * | number | Amount in KZT per run; whole tenge for kind="phone" |
customer | object | |
dayOfMonth | integer | Monthly schedules: day 1–28 |
description | string | Shown to the customer, e.g. "Gym pass — October" |
every | integer | Every N intervals, default 1 |
interval | string | Default "month" |
kind | string | "qr" (default: pay link, emailed if customer.email) or "phone" (invoice pushed into the customer's Kaspi.kz app) |
maxRuns | integer | Stop after N invoices; omit for no end |
metadata | object | Copied into every invoice and webhook |
reminders | object | Customer reminders: N days before each invoice, and after an unpaid one |
startAt | string | ISO date/time of the first invoice; default now |
qutpay_update_subscription Update a subscription
Changes an active or paused subscription: amount, description, schedule (interval, every, dayOfMonth, nextRunAt), customer, maxRuns, reminders, metadata. Only the fields passed change. Cancelled or finished subscriptions cannot be changed.
| Parameter | Type | Description |
|---|---|---|
id * | string | sub_… |
amount | number | Amount in KZT per run; whole tenge for kind="phone" |
customer | object | |
dayOfMonth | integer | Monthly schedules: day 1–28 |
description | string | Shown to the customer, e.g. "Gym pass — October" |
every | integer | Every N intervals, default 1 |
interval | string | Default "month" |
kind | string | "qr" (default: pay link, emailed if customer.email) or "phone" (invoice pushed into the customer's Kaspi.kz app) |
maxRuns | integer | Stop after N invoices; omit for no end |
metadata | object | Copied into every invoice and webhook |
nextRunAt | string | ISO date/time of the next invoice |
reminders | object | Customer reminders: N days before each invoice, and after an unpaid one |
qutpay_pause_subscription Pause a subscription
Stops issuing invoices until resumed. Reversible with qutpay_resume_subscription.
| Parameter | Type | Description |
|---|---|---|
id * | string |
qutpay_resume_subscription Resume a paused subscription
Re-activates a paused subscription in the organization's current mode. If the next run time has already passed it is rescheduled from now; catchUp=true issues the missed invoice right away instead.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
catchUp | boolean | Issue the missed invoice now (default false) |
qutpay_cancel_subscription Cancel a subscription (irreversible)
DESTRUCTIVE: ends the subscription for good — it cannot be resumed or edited afterwards (create a new one instead). Invoices already issued are not affected. To stop it for a while use qutpay_pause_subscription. With a LIVE key confirm=true is required, only after the merchant explicitly asked to cancel.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
confirm | boolean | Required (true) with a live key |
qutpay_run_subscription_now Issue the next subscription invoice now
Issues the next invoice of a subscription immediately instead of waiting for nextRunAt and moves the schedule on, so the same period is never billed twice. Returns { invoice (with payUrl), run, subscription }.
| Parameter | Type | Description |
|---|---|---|
id * | string |
qutpay_create_payment_link Create a payment link (permanent pay page + QR)
Creates a permanent page /p/<slug> with a printable QR: a fixed price, a customer-entered amount (optionally with min/max), or 2–6 top-up packs shown as buttons (e.g. 1 000 / 5 000 / 10 000 KZT). Every payment becomes an ordinary invoice (webhooks fire as usual; metadata.paymentLinkId). For balance top-ups give packs and send each user to url + "?ref=<userId>" — the ref lands in the invoice metadata. Packs and a fixed amount are mutually exclusive. Needs links:manage or invoices:write; the tariff caps how many links exist.
| Parameter | Type | Description |
|---|---|---|
title * | string | Shown on the page, e.g. "Coffee" or "Balance top-up" |
amount | number | Fixed price in KZT; omit to let the customer type the amount |
collect | object | Fields the customer must fill in before paying |
description | string | |
maxAmount | number | Upper limit for a customer-entered amount |
minAmount | number | Lower limit for a customer-entered amount |
packs | array | |
slug | string | URL part, 3–40 chars a-z 0-9 and -; random if omitted; cannot be changed later |
successUrl | string | Where the customer returns after paying |
qutpay_list_payment_links List payment links
Lists the organization's payment links, newest first, with url, qrImageUrl, status, hits (page views) and invoicesCount. Filter by status; limit ≤ 100, offset for paging.
| Parameter | Type | Description |
|---|---|---|
limit | integer | |
offset | integer | |
status | string |
qutpay_get_payment_link Get one payment link
Reads a payment link by id (pl_…): settings, packs, url, qrImageUrl, status, hits (page views) and invoicesCount (live invoices created from it).
| Parameter | Type | Description |
|---|---|---|
id * | string |
qutpay_update_payment_link Update a payment link
Changes title, description, price or limits, packs (null removes them), required fields or successUrl. Only the fields passed change; the slug — and so the printed QR — stays the same. Invoices already created are not affected.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
amount | Fixed price in KZT; null lets the customer type the amount | |
collect | object | Fields the customer must fill in before paying |
description | string | |
maxAmount | number | Upper limit for a customer-entered amount |
minAmount | number | Lower limit for a customer-entered amount |
packs | 2–6 packs; null removes them | |
successUrl | string | Where the customer returns after paying |
title | string | Shown on the page, e.g. "Coffee" or "Balance top-up" |
qutpay_pause_payment_link Pause a payment link
The page stays reachable but takes no payments until resumed (customers see that it is paused). Reversible with qutpay_resume_payment_link.
| Parameter | Type | Description |
|---|---|---|
id * | string |
qutpay_resume_payment_link Resume a paused payment link
Lets a paused payment link take payments again.
| Parameter | Type | Description |
|---|---|---|
id * | string |
qutpay_delete_payment_link Delete a payment link (irreversible)
DESTRUCTIVE: removes the link for good — its page and every printed QR stop working and the slug is freed. Invoices already paid through it are kept. To stop it for a while use qutpay_pause_payment_link. With a LIVE key confirm=true is required, only after the merchant explicitly asked to delete.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
confirm | boolean | Required (true) with a live key |