1. Go to this page and download the library: Download james-kabz/mpesapkg 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/ */
james-kabz / mpesapkg example snippets
use JamesKabz\MpesaPkg\Services\MpesaConfig;
class Example
{
public function __construct(private MpesaConfig $config) {}
public function handle(): void
{
$prefix = $this->config->routePrefix();
$stkShortCode = $this->config->stkShortCode();
}
}
use JamesKabz\MpesaPkg\MpesaClient;
class PaymentsController
{
public function __construct(private MpesaClient $mpesa) {}
}