1. Go to this page and download the library: Download kouyatekarim/momoapi 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/ */
kouyatekarim / momoapi example snippets
use Kouyatekarim\Momoapi\Products\Collection;
$options = [
// 'callbackHost' => '', //(optionel) http://localhost:8000 est par defaut
// 'callbackUrl' => '', //(optionel) http://localhost:8000/callback est par defaut
// 'environment' => '', //(optionel) sandbox est par defaut
// 'accountHolderIdType' => '', //(optionel) msisdn est par defaut
'subscriptionKey' => '', //la clée produit de souscription
'xReferenceId' => '', //Api user (en format UUID )
'apiKey' => '', // Api key (obtenu après l'avoir généré à 'Créer une clé API')
//'accessToken' => '' //obligatoire pour requestopay
];
// avec collection
$collection = Collection::create($options);
use Kouyatekarim\Momoapi\Products\Collection;
// avec collection
$product = Collection::create($options);
$response = $product->createApiUser(); //{"statusCode": 201}
echo $response
use Kouyatekarim\Momoapi\Products\Collection;
// Using collection
$product = Collection::create($options);
$apiUser = $product->getApiUser();
echo $apiUser->getProviderCallbackHost(); //http://localhost:8000
echo '</br>';
echo $apiUser->getTargetEnvironment(); //sandbox
use Kouyatekarim\Momoapi\Products\Collection;
// Avec collection
$product = Collection::create($options);
$apiKey = $product->createApiKey();
echo $apiKey->getApiKey(); //apiKey
use Kouyatekarim\Momoapi\Products\Collection;
// Avec collection
$product = Collection::create($options);
$token = $product->getToken();
echo $token->getAccessToken(); //accessToken
echo '</br>';
echo $token->getTokenType(); //tokenType
echo '</br>';
echo $token->getExpiresIn(); //expiry in seconds
use Kouyatekarim\Momoapi\Products\Collection;
// Avec collection
$product = Collection::create($options);
$product->requestToPay($externalId, $partyId, $amount, $currency, $payerMessage = '', $payeeNote = ''); // *