PHP code example of nyanumba-codes / mpesa

1. Go to this page and download the library: Download nyanumba-codes/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/ */

    

nyanumba-codes / mpesa example snippets


use NyanumbaCodes\Mpesa\Mpesa;

$mpesa = new Mpesa();


$response = $mpesa->dynamicQr('MerchantName', 'Ref123');



$response = $mpesa->stkPush(100, '254700000000', 'AccountRef', 'TransactionDesc');


$response = $mpesa->transactionStatus('TransactionID', 'originatorConversationID');



$response = $mpesa->c2bSimulate(100, '254700000000', 'Ref123');



$response = $mpesa->reversal('TransactionID', 100);

bash
php artisan mpesa:install {environment}

bash
# For Sandbox 

php artisan mpesa:install

# or

php artisan mpesa:install sandbox