M-Pesa
VectaPay integrates directly with Safaricom’s Daraja API — you connect your own Paybill or Till credentials, and VectaPay handles OAuth token refresh, callback verification, and retries.
What’s different about this rail
- Amount range: KES 10–150,000 per transaction — a Safaricom-wide limit, not a VectaPay one.
- Confirmation is asynchronous and can be slow. The prompt typically reaches the customer’s
phone within 5–10 seconds; they then have about 60 seconds to enter their PIN. Expect the final
result anywhere from a few seconds to just over a minute after
collect()returns — this is exactly why webhooks, not polling, are the right way to wait. - Paybill vs. Till is a property of the provider account you connected, not something you choose per request.
receiptNumber— Safaricom’s confirmation code (the one the customer also sees by SMS) — is only present once a payment reachesSUCCESS.
Recurring billing (standing orders)
For a subscription, VectaPay can register an M-Pesa Ratiba standing order instead of pushing a
fresh STK prompt every billing cycle. This is enabled per-subscription from the dashboard (there’s
no collect()-style call for it — it’s a merchant action, not a per-payment API call):
- The customer gets one PIN prompt to authorize the standing order. Every renewal after that is collected automatically — no repeated STK push, no repeated PIN entry.
- The amount is fixed at whatever the subscription’s price is the moment the standing order is enabled. Safaricom guarantees the amount collected each cycle matches exactly, so a subscription can never be under- or over-charged through this path.
- Only available on an M-Pesa provider account, and only for a whole-shilling price (no cents) on one of the billing frequencies Safaricom’s standing-order product supports (daily, weekly, monthly, bi-monthly, quarterly, half-yearly, or yearly — not an arbitrary custom interval).
- Known limits: the mandate has a fixed expiry Safaricom requires at registration — renewing it before that date isn’t automated yet. There’s also no API to cancel or modify an active standing order; the customer can only do that from their own M-Pesa app.
- The subscription’s
chargeMode(visible on the subscription record, not yet on the webhook payload) isstanding_orderfor one running this way,customer_approvalfor the ordinary STK-per-cycle path.
Payouts (B2C)
Use commandId to tell Safaricom what kind of payout it is (SalaryPayment, BusinessPayment,
PromotionPayment) — see Sending a Payout. Safaricom applies
different tax treatment per command.
Testing (smoke test)
You don’t create an M-Pesa test payment method. Test mode uses our own M-Pesa test line: a platform-owned Daraja sandbox app whose credentials are never shown to you and which cannot be selected, targeted, or attached to a payment link.
Before it will prompt a number, you must verify that number from Developer → Testing by
completing one KES 10 payment on it; Safaricom credits that amount back a few minutes later. After
that, a pk_test_ collect() to that same number runs the full path — your app, VectaPay,
Daraja’s sandbox, your PIN, and your webhook. See Testing for limits and the exact
errors.
Every M-Pesa payment method you connect is a production account. See Environments for why.