https://github.com/tbgracy/mvola-dart
A dart package for interacting with the MVola API.
https://github.com/tbgracy/mvola-dart
mvola mvola-sdk
Last synced: 4 months ago
JSON representation
A dart package for interacting with the MVola API.
- Host: GitHub
- URL: https://github.com/tbgracy/mvola-dart
- Owner: tbgracy
- License: mit
- Created: 2022-08-10T11:00:15.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-29T03:10:58.000Z (over 3 years ago)
- Last Synced: 2025-06-16T04:38:30.107Z (12 months ago)
- Topics: mvola, mvola-sdk
- Language: Dart
- Homepage: https://pub.dev/packages/mvola
- Size: 37.1 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# MVolaAPI dart package
This is a package that can be used to interact with the [not that] brand new [MVola API](https://www.mvola.mg/devportal/home) from a [Dart](https://dart.dev) or [Flutter](https://flutter.dev) client.
## â ī¸ DISCLAIMER
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.
## đĢ Features
It allow you to make payments, see the status of a transaction and get the details of a previously made transaction.
## đ ī¸ Getting started
This package depends on the [uuid](https://pub.dev/packages/uuid) and the [http](https://pub.dev/packages/http) packages.
### Installing from the command line
Type in the terminal :
```sh
dart pub add mvola
```
or, if your adding it to a flutter project :
```sh
flutter pub add mvola
```
### Pubspec installation
Add these lines to your pubspec.yaml :
```yaml
dependencies:
mvola:
```
More info can be found on [pub.dev](https://pub.dev/packages/mvola), the official package repository for [Dart](https://dart.dev/) and [Flutter](https://flutter.dev/).
## Usage
Start by importing the library.
```dart
import 'package:mvola/mvola.dart';
```
Then create an instance of the `MVolaClient` class with the base url for the requests([https://devapi.mvola.mg](https://devapi.mvola.mg) in the sandbox and [https://api.mvola.mg](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.
```dart
var mvola = MVolaClient(baseUrl, consumerKey, consumerSecret);
```
[consumerKey] and [consumerSecret] can be found on the [mvola devportal](https://www.mvola.mg/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.
```dart
await mvola.generateAccessToken();
```
Now, you can make transactions, get the status of that transaction or get the details of a transaction.
```dart
// 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](https://github.com/tbgracy/mvola-dart/blob/main/example/mvola_example.dart) or [here](https://pub.dev/packages/mvola/example).
## Todo
* [ ] Improve documentation
* [ ] Improve error/exception responses
* [ ] Add badges to [README.md](https://github.com/tbgracy/mvola-dart/blob/main/README.md)
* [ ] Add disclaimer to not use this package with client-side code (use with server-side stuff
like serverpod)
## Support
If you encounter any issue or want more information about this package, don't hesitate to [email me](mailto:gtsierenana@gmail.com) or message me on [facebook](https://facebook.com/gracy.botramanagna) or open an issue.
## Additional information
âšī¸ This package is still in early stage of developpment. So please, don't hesitate to point out any issue or suggest an improvment.
## License
[MIT](https://choosealicense.com/licenses/mit/)
## Author
đ¤ **Tsierenana Botramanagna Gracy**
âī¸ [gtsierenana@gmail.com](mailto:gtsierenana@gmail.com)