Momo is a simple library in PHP for the MTN Mobile Money Open API.
- Collections
- Disbursements
- Remittances
- Signup For An Account
- Subscribe To Products
Follow this link to the developer portal and signup for an account.
On the Products page on developer portal you should see items you can subscribe to:
- Collections
- Disbursements
- Remittances
The recommended way to install Momo is through composer.
Just create a composer.json file for your project and require it:
composer require fannypack/momo
Now you can add the autoloader, and you will have access to the library:
<?php
require 'vendor/autoload.php';
<?php
use FannyPack\Momo\Products\Collection;
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
$options = [
// 'callbackHost' => '', //(optional) default is http://localhost:8000
// 'callbackUrl' => '', //(optional) default is http://localhost:8000/callback
// 'environment' => '', //(optional) default is sandbox
// 'accountHolderIdType' => '', //(optional) default is msisdn
'subscriptionKey' => '', //Product Subscription key
'xReferenceId' => '', //Api user reference id (in UUID format)
'apiKey' => '', // Api user key (Supply this after generating it at 'Create API Key')
//'preApproval' => '', //(optional) default is false
//'accessToken' => '' //Required for transactions
];
// Using collection
$collection = Collection::create($options);
// Using disbursement
$disbursement = Disbursement::create($options);
// Using remittance
$remittance = Remittance::create($options);
<?php
use FannyPack\Momo\Products\Collection;
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
// Using collection
$product = Collection::create($options);
// Using disbursement
$product = Disbursement::create($options);
// Using remittance
$product = Remittance::create($options);
$product->createApiUser(); //{"statusCode": 201}
<?php
use FannyPack\Momo\Products\Collection;
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
// Using collection
$product = Collection::create($options);
// Using disbursement
$product = Disbursement::create($options);
// Using remittance
$product = Remittance::create($options);
$apiUser = $product->getApiUser();
$apiUser->getProviderCallbackHost(); //http://localhost:8000
$apiUser->getTargetEnvironment(); //sandbox
<?php
use FannyPack\Momo\Products\Collection;
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
// Using collection
$product = Collection::create($options);
// Using disbursement
$product = Disbursement::create($options);
// Using remittance
$product = Remittance::create($options);
$apiKey = $product->createApiKey();
$apiKey->getApiKey(); //apiKey
<?php
use FannyPack\Momo\Products\Collection;
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
// Using collection
$product = Collection::create($options);
// Using disbursement
$product = Disbursement::create($options);
// Using remittance
$product = Remittance::create($options);
$token = $product->getToken();
$token->getAccessToken(); //accessToken
$token->getTokenType(); //tokenType
$token->getExpiresIn(); //expiry in seconds
<?php
use FannyPack\Momo\Products\Collection;
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
// Using collection
$product = Collection::create($options);
// Using disbursement
$product = Disbursement::create($options);
// Using remittance
$product = Remittance::create($options);
$balance = $product->getAccountBalance();
$balance->getAvailableBalance(); //accountBalance
$balance->getCurrency(); //currency
<?php
use FannyPack\Momo\Products\Collection;
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
// Using collection
$product = Collection::create($options);
// Using disbursement
$product = Disbursement::create($options);
// Using remittance
$product = Remittance::create($options);
$product->getAccountHolderInfo($accountHolderId); //{"statusCode": 201}
<?php
use FannyPack\Momo\Products\Collection;
// Using collection
$product = Collection::create($options);
$product->requestToPay($externalId, $partyId, $amount, $currency, $payerMessage = '', $payeeNote = ''); // {"statusCode": 200, "financialTransactionId": "8f3077a6-ce43-4584-a425-589c50cfcbe4"}
<?php
use FannyPack\Momo\Products\Collection;
// Using collection
$product = Collection::create($options);
$transactionStatus = $product->getRequestToPayStatus($financialTransactionId);
$transactionStatus->getAmount(); //amount
$transactionStatus->getCurrency(); //currency
$transactionStatus->getExternalId(); //externalId
$transactionStatus->getPayer(); //payer object
$transactionStatus->getStatus(); //status
<?php
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
// Using disbursement
$product = Disbursement::create($options);
// Using remittance
$product = Remittance::create($options);
$product->transfer($externalId, $partyId, $amount, $currency, $payerMessage = '', $payeeNote = '');// {"statusCode": 200, "financialTransactionId": "8f3077a6-ce43-4584-a425-589c50cfcbe4"}
<?php
use FannyPack\Momo\Products\Disbursement;
use FannyPack\Momo\Products\Remittance;
// Using disbursement
$product = Disbursement::create($options);
// Using remittance
$product = Remittance::create($options);
$transactionStatus = $product->transferStatus($financialTransactionId);
$transactionStatus->getAmount(); //amount
$transactionStatus->getCurrency(); //currency
$transactionStatus->getExternalId(); //externalId
$transactionStatus->getPayer(); //payer object
$transactionStatus->getStatus(); //status
For any bugs found, please email me at [email protected] or register an issue at issues