1. Go to this page and download the library: Download openpesa/laravel-pesa 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/ */
openpesa / laravel-pesa example snippets
use Openpesa\Pesa\Facades\Pesa;
// This route will be mapped to: `your-URL/api/charge`
Route::get('/charge', function () {
$response = Pesa::c2b([
'input_Amount' => 5000, // Amount to be charged
'input_Country' => 'TZN',
'input_Currency' => 'TZS',
'input_CustomerMSISDN' => '000000000001', // Replace with your phone number
'input_ServiceProviderCode' => '000001', // Replace with your service provider code given by M-Pesa
'input_ThirdPartyConversationID' => 'mpesatz', // Unique
'input_TransactionReference' => 'imethibitishwa', // Unique
'input_PurchasedItemsDesc' => 'Item description'
});
return $response;
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.