1. Go to this page and download the library: Download wanzoou/momoapicollection 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/ */
wanzoou / momoapicollection example snippets
use Wanzoou\Momoapicollection\MomoAPI;
$momo = new MomoAPI();
$momo->setMomoPayHost('sandbox.momodeveloper.mtn.com'); // Set MoMo API host
$momo->setPrimaryKey('your_primary_key'); // Set your primary key
$momo->setProviderCallbackHost('your_callback_host'); // Set your provider callback host
$momo->setTargetEnvironment('sandbox'); // Set the target environment (sandbox or live)
$phone = '237679465319'; // Payer's phone number
$amount = 100; // Amount to be paid
$currency = 'EUR'; // Currency
$responseCode = $momo->requestToPay($phone, $amount, $currency);
if ($responseCode == 202) {
echo "Payment request initiated successfully.";
} else {
echo "Failed to initiate payment request.";
}