Qosic Dart
A Very Good Project created by Very Good CLI.
About โ
This package is a simple way to handle Qosic's USSD payment. It allows you to integrate mobile money payment into your Dart and Flutter app.
๐จ WARNING ๐จ This client should only be used on the server side.
Installation ๐ป
โ In order to start using Qosic Dart you must have the Dart SDK installed on your machine.
Add qosic_dart
to your pubspec.yaml
:
dependencies:
qosic_dart:
Install it:
dart pub get qosic_dart
Usage ๐จ
Make a payment
A simple example of how to compute a USSD payment with QOSIC
final qosic = QosicDart(
moovKey: 'XXXXXXXXXx',
mtnKey: 'XXXXXXXXXX',
username: 'XXXXXXXXXX',
password: 'XXXXXXXXX',
);
final transactionRef = await qosic.pay(
network: QosicNetwork.mtn,
phoneNumber: 'XXXXXXXX', /// precedeed by the country code. ex: 229XXXXXXXX
amount: '1',
);
Timer.periodic(
const Duration(
seconds: 10, /// feel free to give your own second to wait
/// but I will advice you between 7 and 10 secs
),
(timer) async {
final status = await qosic.getPaymentStatus(
transactionReference: transactionRef!,
network: QosicNetwork.mtn,
country: QosicCountry.benin,
);
if (status == QosicStatus.successfull || status == QosicStatus.failed) {
timer.cancel();
if (status == QosicStatus.successfull) {
log("Success for payment");
} else {
log("Payment failed");
}
}
},
);
Continuous Integration ๐ค
Qosic Dart comes with a built-in GitHub Actions workflow powered by Very Good Workflows but you can also add your preferred CI/CD solution.
Out of the box, on each pull request and push, the CI formats
, lints
, and tests
the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses Very Good Analysis for a strict set of analysis options used by our team. Code coverage is enforced using the Very Good Workflows.
Running Tests ๐งช
To run all unit tests:
dart pub global activate coverage 1.2.0
dart test --coverage=coverage
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info
To view the generated coverage report you can use lcov.
# Generate Coverage Report
genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
open coverage/index.html
Libraries
- qosic_dart
- A Very Good Project created by Very Good CLI.