Flutter
Integrate the Wajub payment sheet into your Flutter app — installation, initialization, and payment presentation.
6 min read
The wajub_flutter package displays a native payment sheet (Material & Cupertino) to collect
payments in your app.
Install
flutter pub add wajub_flutterInitialize
Initialize the SDK with your public key at app startup.
import 'package:wajub_flutter/wajub_flutter.dart';
void main() {
Wajub.initialize(publicKey: 'pk_test.8f2b91c4d7e6a0f3');
runApp(const MyApp());
}Present the payment sheet
First create the payment on your backend, retrieve the reference, then present it.
// 1. Your backend has returned the reference
final reference = await api.createPayment(amount: 5000, currency: 'XAF');
// 2. Present the payment sheet
final result = await Wajub.present(
context: context,
reference: reference,
);
// 3. React to the result (the source of truth remains the server webhook)
switch (result.status) {
case WajubStatus.complete:
showSuccess();
break;
case WajubStatus.failed:
showError(result.reason);
break;
case WajubStatus.canceled:
// user closed the sheet
break;
}Confirm server-side
result.status is for updating the UI, not for delivering. Wait for the
payment.succeeded webhook server-side before any delivery.