dadapas/mvola-php

A simple class wrapper for MVola mobile money for Madagascar.

1.3.1 2023-02-22 17:26 UTC

This package is auto-updated.

Last update: 2024-12-22 21:23:45 UTC


README

mvola api

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

PHP class wrap up Madagascar mobile money request as mvola.

This package facilitate these features for you:

  • Handle authentification token and expires token
  • Generate automaticly correlation ID and reference for payement
  • Request handler

Getting started

The suggested installation method is via composer:

composer require dadapas/mvola-php

To get started

require_once __DIR__ . "/vendor/autoload.php";
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());
}

Sending money to merchent like

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

For testing only msisdn 034 35 000 03 and 034 35 000 04 work Use real number for production

Support

This repository is support to all php project, Symfony, Laravel, Codeigniter, Wordpress, ..., and so on

Documentation

To read the documentation is in

Contributing

Please read the CONTRIBUTING.md contents if you wish to help out!

LICENCE

MIT Licence