Skip to Content
PaymentsOrders & Invoices

Orders & Invoices

When a customer pays into your Paybill or Till directly — not through a payment link — they’re the one typing the account number and amount, not you. VectaPay tries to match the incoming payment to an order or invoice on its own, but you get an exact, automatic match every time by telling VectaPay what to expect first: the reference the customer will type, and how much you’re expecting.

You can achieve this from the dashboard using the Orders & invoices button in the Payment In page or, use expectedPayments to create the same orders/invoices.

import { VectaPayClient, money } from "@vectapay/sdk"; const vectapay = new VectaPayClient({ apiKey: process.env.VECTAPAY_API_KEY! }); const order = await vectapay.expectedPayments.create({ providerAccountId: "acct_...", reference: "JOHN-DOE-001", // what the customer types as the account number amount: money(500000), // KES 5,000.00 description: "March school fees", customerName: "John Doe", customerPhone: "254712345678", });

Request fields

FieldRequiredNotes
providerAccountIdYesWhich Paybill or Till this reference applies to — an order is scoped to one provider account, not “any till you own”.
referenceYes1–100 characters. Must match the account number the customer types in exactly. Reusable once the prior order for it settles or is cancelled.
amountYesA Money value — see Money.
descriptionNoYour own note — “March school fees”, “Invoice #4471”.
customerName / customerPhoneNoYour own record only — not used for matching.

How matching works

The moment a payment lands in that Paybill or Till with a matching reference, VectaPay links it to the order automatically — no manual reconciliation, no webhook handling required on your side beyond what you already listen for. If the customer pays in instalments, every matching payment counts toward the same order; once the total paid reaches amount, the order is marked SETTLED on its own. A payment that overpays isn’t refunded automatically — it’s flagged for you to review in the dashboard.

Only C2B payments (a customer paying into your Paybill/Till directly without using your api) match against an order. Payments made through a payment link or collect() already carry their own reference and don’t need this.

This is very useful for people using kabambe phones, and have no access to web.

Reading orders back

const order = await vectapay.expectedPayments.get(orderId); console.log(order.status, order.paidAmount, order.remainingAmount); // List open orders const page = await vectapay.expectedPayments.list({ status: "OPEN", limit: 20 });

get() includes every contributing payment under contributions — each one’s amount, receipt number, and when it landed. list() returns summaries only, without the contribution breakdown.

Changing an order’s amount

const updated = await vectapay.expectedPayments.update(orderId, { amount: money(750000), // KES 7,500.00 });

An OPEN order’s amount can be changed until the first payment is matched to it. Once any payment has landed — even a partial instalment — the amount is locked: changing it after money has moved would rewrite what the customer already paid against. Settled and cancelled orders are final too. If a partial payment has already landed, cancel the order and create a new one with the correct amount.

Cancelling an order

await vectapay.expectedPayments.cancel(orderId);

Only an OPEN order can be cancelled — one that’s already SETTLED is done, and a CANCELLED order can’t be cancelled again.

Last updated on