1. Go to this page and download the library: Download dadapas/mvola-php 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/ */
dadapas / mvola-php example snippets
use MVolaphp\Telma as MVola;
$credentials = array(
// Customer id
'client_id' => '<customer_id>',
// Customer secret
'client_secret' => '<customer_secret>',
// The merchant number
'merchant_number' => '0343500003',
// Set true to production
'production' => false,
// company_name
'partner_name' => "company_name",
// Set the lang
'lang' => 'MG'
);
// Path to cache that is enable to read and write
$cache = __DIR__.'/cache';
try {
$mvola = new MVola($credentials, $cache);
// ...
} catch (MVolaphp\Exception $e) {
echo $e->getMessage().PHP_EOL;
var_dump($e->getData());
}
use MVolaphp\Money;
use MVolaphp\Objects\{Phone, PayIn, KeyValue};
...
$payDetails = new PayIn();
// Amount of 1000 ar or arivo ariary
$money = new Money('MGA', 5000);
$payDetails->amount = $money;
// User to retreive the amount
$debit = new KeyValue();
$debit->addPairObject(new Phone("0343500004"));
$payDetails->debitParty = $debit;
// Credited party not obligatoire if has been set in options
// $merchant = new KeyValue();
// $merchant->addPairObject(new Phone("0343500004"));
// $payDetails->creditParty = $merchant;
// Set description text
$payDetails->descriptionText = "Test payement";
$meta = new KeyValue();
$meta->add('partnerName', "Company name");
// $meta->add('fc', 'USD');
// $meta->add('amountFc', 1);
// Add metadata information
$payDetails->metadata = $meta;
// Put callback url
$mvola->setCallbackUrl("https://example.com/mycallback");
// Make a payement
$response = $mvola->payIn($payDetails);
print_r($response);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.