Laravel with Horizon
A common choice for Kenyan developers. The callback route stores the payload and dispatches a job; Horizon manages Redis queue workers and retries. Needs PHP-FPM, Redis and Supervisor or systemd to keep workers running.
Host your shop, ticketing site, utility portal or subscription app on a VPS built for Daraja: a public HTTPS address for callbacks, queue workers that retry failed jobs and full root access to see exactly what Safaricom sent you, request by request.
Four cores for more PHP or app workers and separate queue workers, so callbacks stay fast during a sale or ticket release. Its 16 GB of RAM leaves room for WooCommerce and Redis caching too.
Order VPS V3When a customer taps "Pay" on your site, the Daraja STK Push request only starts the payment. The customer enters their PIN on the phone, and seconds later Safaricom posts the result to the callback URL you supplied. If that URL is slow, unreachable or returns an error, the money has left the customer but your system never marks the order as paid. Most M-Pesa support complaints trace back to that gap.
So the server matters as much as the code. The callback must be public, served over HTTPS with a valid certificate, and answered quickly. The heavy work, such as updating stock, issuing a ticket, sending an SMS receipt or creating an eTIMS invoice, should go to a background queue, not happen while Safaricom waits. Queues need long-running workers and usually Redis, which shared hosting rarely allows.
A VPS gives you that control. You choose the PHP, Python or Node.js version, run Laravel Horizon, Celery or BullMQ under a process manager, read the raw callback logs and add a scheduled job that checks the status of any payment still pending. HostingKE VPS plans include full root access, and our support team can help with DNS, certificates and firewall settings.
The customer has the M-Pesa SMS, your system shows nothing. Usually the callback timed out, hit a firewall or failed on a code error. Log every raw callback before processing it, and query the transaction status for anything left pending.
Callbacks can be retried, and impatient customers press Pay twice. Without an idempotency check on the M-Pesa receipt number or checkout request ID, one payment can issue two tickets or credit a wallet twice.
Consumer keys, passkeys and B2C initiator credentials end up in code repositories or shared hosting file managers. On a VPS they live in environment files readable only by the application user, and you can rotate them cleanly.
Ticket releases, flash sales and month-end utility payments bring hundreds of STK requests in minutes. Dedicated cores, enough PHP or app workers and a queue absorb the spike so callbacks are still answered promptly.
Any language that can make HTTPS requests can call Daraja. What matters on the server is a reliable web endpoint and a background worker.
A common choice for Kenyan developers. The callback route stores the payload and dispatches a job; Horizon manages Redis queue workers and retries. Needs PHP-FPM, Redis and Supervisor or systemd to keep workers running.
Django receives the callback and hands processing to Celery workers through Redis or RabbitMQ. Celery Beat can run the periodic status checks for stuck payments. Runs under Gunicorn behind Nginx.
An Express or Fastify app takes callbacks and pushes jobs to BullMQ, a Redis-backed queue with retries and delayed jobs. Keep the processes alive with PM2 or systemd.
The WordPress shop plugin, used with an M-Pesa payment gateway plugin. Large catalogues and busy checkouts need PHP workers and object caching that shared hosting limits, and the callback URL must stay reachable through any security plugins.
In-memory store that backs most of these queues and caches. It is small but must run continuously, with persistence enabled so queued payment jobs survive a restart.
Estimate the number of STK Push, C2B and B2C transactions on a busy day, not an average one.
This is a starting point: real load depends on how spiky your traffic is and on the work each payment triggers, such as SMS, PDFs or eTIMS invoices.
0 of 8 done. Tick them off as you go.
Safaricom posts STK, C2B and B2C results to URLs you provide, and they must be publicly reachable over HTTPS. Tunnels from a laptop work for testing, but production needs an always-on server with a fixed address and a valid certificate.
Payouts use an initiator name and a security credential encrypted with the M-Pesa public certificate. Keep the encrypted value and certificates on the server, out of your repository, and limit who has shell access to that VPS.
Many businesses now issue invoices through KRA eTIMS. If your app generates them after payment, do it in the background queue so a slow tax system never delays the response to the M-Pesa callback or the customer confirmation.
Plans from KES 2,000 a month, paid by M-Pesa or card.
Size your server