Official Dart/Flutter SDK for the Malipopay payment platform. Accept payments via Mobile Money (M-Pesa, Airtel Money, Mixx/YAS, Halopesa, T-Pesa), Bank Transfer (CRDB, NMB), USSD, and Card (Visa, Mastercard) in Tanzania.
flutter pub add malipopayOr add to pubspec.yaml:
dependencies:
malipopay: ^1.0.0import 'package:malipopay/malipopay.dart';
Future<void> main() async {
final client = Malipopay('your-api-key');
final payment = await client.payments.collect({
'description': 'Order #1234',
'amount': 10000,
'phoneNumber': '255712345678',
});
print('Reference: ${payment['reference']}');
}final client = Malipopay(
'your-api-key',
environment: MalipopayEnvironment.uat, // .production or .uat
timeout: Duration(seconds: 30), // default: 30s
retries: 2, // default: 2
webhookSecret: 'whsec_...', // for webhook verification
);// Collect via mobile money
final payment = await client.payments.collect({
'description': 'Order #1234',
'amount': 10000,
'phoneNumber': '255712345678',
});
// Disburse funds
await client.payments.disburse({
'description': 'Salary payment',
'amount': 50000,
'phoneNumber': '255712345678',
});
// Verify payment
final status = await client.payments.verify('PAY-abc123');
// Create payment link
final link = await client.payments.createLink({
'amount': 25000,
'phoneNumber': '255712345678',
});final customer = await client.customers.create({
'phoneNumber': '255712345678',
'firstname': 'John',
'lastname': 'Doe',
'email': 'john@example.com',
});
final results = await client.customers.search({'query': 'John'});final invoice = await client.invoices.create({
'customer': 'customer-id',
'items': [
{'description': 'Web Development', 'quantity': 1, 'unitPrice': 500000},
],
'dueDate': '2026-05-01',
'currency': 'TZS',
'taxRate': 18,
});await client.sms.send({
'sender': 'MALIPOPAY',
'phoneNumber': '255712345678',
'message': 'Your payment was received!',
});
await client.sms.sendBulk({
'sender': 'MALIPOPAY',
'phoneNumber': ['255712345678', '255713456789'],
'message': 'Special offer!',
});final banks = await client.references.banks();
final currencies = await client.references.currencies();
final countries = await client.references.countries();final webhooks = Webhooks(secret: 'whsec_your_secret');
final event = webhooks.constructEvent(rawBody, signatureHeader);
switch (event.type) {
case WebhookEventType.paymentCompleted:
print('Payment completed: ${event.data['reference']}');
case WebhookEventType.paymentFailed:
print('Payment failed');
}try {
await client.payments.collect({...});
} on AuthenticationException catch (e) {
print('Invalid API key: ${e.message}');
} on ValidationException catch (e) {
print('Validation failed: ${e.fields}');
} on RateLimitException catch (e) {
print('Rate limited, retry after ${e.retryAfter}s');
} on MalipopayException catch (e) {
print('Error: ${e.message}');
}- Dart SDK ^3.0.0
- Flutter (if using in a Flutter app)
- Malipopay API key (get one here)
MIT
| SDK | Install |
|---|---|
| Node.js | npm install malipopay |
| Python | pip install malipopay |
| PHP | composer require malipopay/malipopay-php |
| Java | Maven / Gradle |
| .NET | dotnet add package Malipopay |
| Ruby | gem install malipopay |
| Flutter/Dart | flutter pub add malipopay |