PHP code example of bmatovu / laravel-mtn-momo

1. Go to this page and download the library: Download bmatovu/laravel-mtn-momo 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/ */

    

bmatovu / laravel-mtn-momo example snippets


use Bmatovu\MtnMomo\Products\Collection;

$collection = new Collection();

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

use Bmatovu\MtnMomo\Products\Collection;
use Bmatovu\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());
}

    $collection->requestToPay($yourTransactionId, $partyId, $amount)
    

    $collection->getTransactionStatus($referenceId)
    

    $collection->getAccountBalance()
    

    $collection->isActive($partyId)
    

    $collection->getToken()
    

    $collection->getAccountHolderBasicInfo($partyId)
    

    $disbursement->transfer($yourTransactionId, $partyId, $amount)
    

    $disbursement->getTransactionStatus($referenceId)
    

    $disbursement->getAccountBalance()
    

    $disbursement->isActive($partyId)
    

    $disbursement->getToken()
    

    $disbursement->getAccountHolderBasicInfo($partyId)
    

    $remittance->transfer($yourTransactionId, $partyId, $amount)
    

    $remittance->getTransactionStatus($referenceId)
    

    $remittance->getAccountBalance()
    

    $remittance->isActive($partyId)
    

    $remittance->getToken()
    

    $remittance->getAccountHolderBasicInfo($partyId)
    
bash
php artisan vendor:publish --provider="Bmatovu\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