PHP code example of nzokolab / mtnmomo

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

    

nzokolab / mtnmomo example snippets


use Nzokolab\MtnMomo\Products\Collection;

$collection = new Collection();

$referenceId = $collection->requestToPay('yourTransactionId', '46733123454', 100);

use Nzokolab\MtnMomo\Products\Collection;
use Nzokolab\MtnMomo\Exceptions\CollectionRequestException;

try {
    $collection = new Collection();
    
    $referenceId = $collection->requestToPay('yourTransactionId', '46733123453', 100);
} catch(CollectionRequestException $e) {
    do {
        printf("\n\r%s:%d %s (%d) [%s]\n\r", 
            $e->getFile(), $e->getLine(), $e->getMessage(), $e->getCode(), get_class($e));
    } while($e = $e->getPrevious());
}
bash
php artisan vendor:publish --provider="Nzokolab\MtnMomo\MtnMomoServiceProvider" --tag="config"
bash
php artisan migrate
bash
php artisan mtn-momo:init
bash
php artisan mtn-momo:register-id
bash
php artisan mtn-momo:validate-id
bash
php artisan mtn-momo:request-secret