This is a package that can be used to interact with the [not that] brand new MVola API from a Dart or Flutter client.
It is not recommended to manage payments in the client side due to some security reasons (most of dart packages are used for Flutter), so use it at your own risk. It was only after the first release of the package that I acknowledged that fact but I am not gonna delete it.
It allow you to make payments, see the status of a transaction and get the details of a previously made transaction.
This package depends on the uuid and the http packages.
Type in the terminal :
dart pub add mvola
or, if your adding it to a flutter project :
flutter pub add mvola
Add these lines to your pubspec.yaml :
dependencies:
mvola:
More info can be found on pub.dev, the official package repository for Dart and Flutter.
Start by importing the library.
import 'package:mvola/mvola.dart';
Then create an instance of the MVolaClient
class with the base url for the requests(https://devapi.mvola.mg in the sandbox and https://api.mvola.mg in production, as mentionned in the documentation) and a consumer key and a consumer secret. An optional callbackUrl can be provided, it's the url where the API send a notification whether a transaction has been successful or not.
var mvola = MVolaClient(baseUrl, consumerKey, consumerSecret);
[consumerKey] and [consumerSecret] can be found on the mvola devportal upon creating an application.
You then have to generate an access token in order to make transactions. You can store it in a variable for later use or just call the method to set it.
await mvola.generateAccessToken();
Now, you can make transactions, get the status of that transaction or get the details of a transaction.
// make a transaction
var transactionResponse = await mvola.initTransaction(
partnerName: 'name',
partnerNumber: '0343500004',
creditNumber: '0343500004',
amount: 5000,
debitNumber: '0343500003',
description: 'short description',
);
// get the status of a transaction
var transactionStatus = await mvola.getTransactionStatus(transactionResponse.serverCorrelationId, '0343500004', 'name');
// get the detail of a transaction
var transaction = await mvola.getTransactionDetail(serverCorrelationId, "name", "0343500004");
In the development environment, only 0343500004 and 0343500003 can be used as merchant or customer numbers.
The complete example code can be found here or here.
- Improve documentation
- Improve error/exception responses
- Add badges to README.md
- Add disclaimer to not use this package with client-side code (use with server-side stuff like serverpod)
If you encounter any issue or want more information about this package, don't hesitate to email me or message me on facebook or open an issue.
ℹ️ This package is still in early stage of developpment. So please, don't hesitate to point out any issue or suggest an improvment.
👤 Tsierenana Botramanagna Gracy