Checking Status
From your own records
TypeScript
const status = await vectapay.payments.status(paymentId);
// { status, receiptNumber?, createdAt, updatedAt }This reads VectaPay’s own record. Use it for a status page a user is looking at right now while waiting for webhook to arrive assuming you have configured it.
Querying the provider live
For an M-Pesa STK push specifically, you can ask Safaricom directly by checkoutRequestId:
TypeScript
const live = await vectapay.payments.statusByCheckoutRequestId(checkoutRequestId);
console.log(live.status, live.source); // source: 'DATABASE' | 'DARAJA'While the payment is still pending, this asks Safaricom directly — source/Source comes back
'DARAJA'. Once a payment has already settled (or there’s nothing to check yet), it’s answered
straight from VectaPay’s own record instead, with source/Source as 'DATABASE', since asking
the provider again wouldn’t tell you anything new. Safe to call repeatedly while you wait — a
short-lived cache at the provider-client layer keeps repeated calls from hammering Safaricom. This
only applies to M-Pesa STK push payments.
Recent activity and summary
TypeScript
const recent = await vectapay.payments.recent();
const summary = await vectapay.payments.summary();
// { todayTotal, todayCount, successRate, pendingCount, pendingAmount }