mavunta/laravel-mavunta

Laravel integration for the Mavunta Pay API.

Maintainers

Package info

github.com/mavunta/laravel-mavunta

Homepage

Documentation

pkg:composer/mavunta/laravel-mavunta

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2026-07-03 09:08 UTC

This package is auto-updated.

Last update: 2026-07-03 10:27:41 UTC


README

Laravel integration for the Mavunta Pay API, on top of the mavunta/mavunta-php SDK. Auto-discovered service provider + facade, a publishable config, and a signed webhook receiver that dispatches a Laravel event.

composer require mavunta/laravel-mavunta
php artisan vendor:publish --tag=mavunta-config
MAVUNTA_SECRET_KEY=cwk_test_sk_...
MAVUNTA_WEBHOOK_SECRET=whsec_...

Create a payment

use Mavunta\Laravel\Facades\Mavunta;

$intent = Mavunta::paymentIntents()->create([
    'amount' => (string) $order->total,
    'currency' => 'KES',
    'settlement_currency' => 'USDT',
    'payment_methods' => ['mpesa', 'card', 'mavunta_balance'],
    'merchant_reference' => (string) $order->id,
]);

return redirect()->away($intent['checkout_url']);

Or inject the client: public function store(\Mavunta\Mavunta $mavunta).

Handle webhooks

The package registers POST /mavunta/webhook (configurable), verifies the signature, and dispatches an event. Add the URL in your Mavunta console and put its signing secret in MAVUNTA_WEBHOOK_SECRET. Then listen:

use Mavunta\Laravel\Events\MavuntaWebhookReceived;

Event::listen(function (MavuntaWebhookReceived $event) {
    if ($event->type() === 'payment_intent.paid') {
        $orderId = $event->data()['merchant_reference'] ?? null;
        // fulfil the order; dedupe on $event->id()
    }
});

License

MIT