1. Go to this page and download the library: Download leefipay/mpesa library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
leefipay / mpesa example snippets
use LeefiPay\Mpesa\Facades\LeefiPay;
$response = LeefiPay::stkPush([
'phone' => '254700000000',
'amount' => 100,
'payment_channel_id' => 1,
'reference' => 'ORDER-1001', // sent as account_reference
'notes' => 'Payment for Order 1001',
'idempotency_key' => 'order-1001',
]);
if ($response->success()) {
$response->reference();
$response->waitingUrl();
$response->checkoutRequestId();
}
use LeefiPay\Mpesa\Contracts\LeefiPayClientInterface;
public function __construct(private LeefiPayClientInterface $leefiPay) {}