Flutter SDK
Official Flutter and Dart integration guide for the Malipo Payment Gateway.
Installation
Section titled “Installation”flutter pub add malipoQuickstart
Section titled “Quickstart”import 'package:malipo/malipo.dart';
void main() async { final malipo = Malipo(apiKey: 'sk_live_your_api_key');
try { final charge = await malipo.charges.create( ChargeCreateParams( amount: 10.0, currency: 'USD', phone: '+243810000000', network: MalipoNetwork.vodacomMpesa, description: 'Order #123', payer: MalipoPayer( firstName: 'John', lastName: 'Doe', email: 'john.doe@example.com', ), ), idempotencyKey: 'unique_order_id_123', );
print('Charge ID: ${charge.id}'); print('Status: ${charge.status.value}'); } catch (e) { print('Charge failed: $e'); } finally { malipo.close(); }}Check Balance
Section titled “Check Balance”try { final balance = await malipo.balance.retrieve(); print('Available: ${balance.available.first.amount} ${balance.available.first.currency}');} catch (e) { print('Failed to retrieve balance: $e');}Error Handling
Section titled “Error Handling”try { await malipo.charges.create( ChargeCreateParams( amount: -1.0, currency: 'USD', phone: '+243810000000', network: MalipoNetwork.vodacomMpesa, ), );} on MalipoException catch (e) { print('API Error: ${e.message}'); print('Status Code: ${e.statusCode}'); print('Error Code: ${e.errorCode}');} catch (e) { print('Unknown Error: $e');}