PHP code example of fannypack / momo

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

    

fannypack / momo example snippets





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);



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}



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



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



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



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



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}



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"}



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



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"}



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