Skip to content

Laravel Daraja

Every Safaricom M-Pesa API, as ordinary Laravel code. Typed responses, cached tokens, callbacks you can actually test.

Prompt a customer to pay

One call sends an STK push and returns a typed response.

$response = Daraja::stk()->push(
phone: '0712345678',
amount: 1500,
accountReference: 'INV-001',
);
$response->checkoutRequestId; // ws_CO_1912…

Handle the result

Callbacks arrive as typed events, not raw JSON.

Event::listen(function (StkCallbackReceived $e) {
if ($e->callback->successful()) {
Order::markPaid($e->callback->receipt());
}
});

Test without a network

Built on Laravel’s HTTP client, so Http::fake() drives the whole package.

Http::fake([
'*/mpesa/stkpush/*' => Http::response([
'ResponseCode' => '0',
]),
]);

Seventeen APIs

STK Push, C2B, B2C, B2B, Pochi, QR, Ratiba, Bill Manager, Pull Transactions, Lipa na Bonga, balances, reversals and status queries.

See the full list

PHP 8.3 or higher
Laravel 12 or 13

Laravel 10 and 11 are not supported. Both are past end of life and carry unpatched advisories, so Composer refuses to install them without disabling its security audit. Applications on those versions should stay on ^4.0.