1. Go to this page and download the library: Download masterlink/mpesa-dependency 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/ */
masterlink / mpesa-dependency example snippets
Bluteki\MpesaGateway\Mpesa;
// configuring api access credentials
Mpesa::config(
'enter you api key',
'enter your public key',
'host',
'origin',
'port',
'service_provider_code'
);
$transactionReference = bin2hex(random_bytes(6));
$thirdPartyReference = bin2hex(random_bytes(6));
$response = Mpesa::c2b(1, '258844224168', $transactionReference, $thirdPartyReference);
echo '<pre>';
print_r($response->toArray());
Bluteki\MpesaGateway\Mpesa;
// configuring api access credentials
Mpesa::config(
'enter you api key',
'enter your public key',
'host',
'origin',
'port',
'service_provider_code'
);
$transactionReference = bin2hex(random_bytes(6));
$thirdPartyReference = bin2hex(random_bytes(6));
$response = Mpesa::b2c(1, '258844224168', $transactionReference, $thirdPartyReference);
echo '<pre>';
print_r($response->toArray());
use Bluteki\MpesaGateway\Mpesa;
public function boot(): void
{
Mpesa::config(
config('mpesa.api_key'),
config('mpesa.public_key'),
config('mpesa.host'),
config('mpesa.origin'),
config('mpesa.port'),
config('mpesa.service_provider_code')
);
}