PHP code example of geekabel / mobile-money-payment
1. Go to this page and download the library: Download geekabel/mobile-money-payment 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/ */
geekabel / mobile-money-payment example snippets
use MobileMoneyPayment\PaymentManager;
use MobileMoneyPayment\Service\TmoneyService;
use MobileMoneyPayment\Service\FloozService;
use MobileMoneyPayment\Service\DefaultFloozCounterManager;
// Create service instances
$tmoneyService = new TmoneyService(
$httpClient,
$logger,
'tmoney_username',
'tmoney_password',
'tmoney_alias',
'https://tmoney-api-url.com'
);
$floozService = new FloozService(
$httpClient,
$logger,
new DefaultFloozCounterManager(),
'flooz_username',
'flooz_password',
'flooz_key',
'flooz_merchant_name',
'flooz_partner_msisdn',
'https://flooz-api-url.com'
);
// Create and set up the Payment Manager
$paymentManager = new PaymentManager();
$paymentManager->addService('tmoney', $tmoneyService);
$paymentManager->addService('flooz', $floozService);
use MobileMoneyPayment\Interface\PaymentServiceInterface;
use MobileMoneyPayment\Model\PaymentResponse;
class NewPaymentService implements PaymentServiceInterface
{
public function pay(string $phone, float $amount, string $reference, string $description = ''): PaymentResponse
{
// Implement payment logic
}
public function checkStatus(string $reference): PaymentResponse
{
// Implement status check logic
}
}
$newService = new NewPaymentService(/* ... */);
$paymentManager->addService('new_service', $newService);
use MobileMoneyPayment\Interface\FloozCounterManagerInterface;
class CustomFloozCounterManager implements FloozCounterManagerInterface
{
public function getAndIncrementCounter(): int
{
// Implement custom counter logic
}
}
$customCounterManager = new CustomFloozCounterManager();
$floozService = new FloozService(
$httpClient,
$logger,
$customCounterManager,
// ... other parameters
);
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$logger = new Logger('payment');
$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::DEBUG));
$tmoneyService = new TmoneyService(
$httpClient,
$logger,
// ... other parameters
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.