Getting Started

Usage

Initialize feda_flutter and start processing payments.

Initialization

Initialize FedaFlutter once at app startup (e.g. in main.dart):

main.dart
import 'package:feda_flutter/feda_flutter.dart';

void main() {
  FedaFlutter.initialize(
    apiKey: 'your_api_key',
    environment: FedaEnvironment.sandbox, // or .live
  );
  runApp(MyApp());
}

Creating a transaction

final repo = FedaFlutter.instance.transactions;

final res = await repo.createTransaction(TransactionCreate(
  description: 'Order #42',
  amount: 5000,
  currency: CurrencyIso(iso: 'XOF'),
  customer: CustomerCreate(
    firstname: 'John',
    lastname: 'Doe',
    email: 'john@example.com',
    phoneNumber: PhoneNumber(number: '97000000', country: 'BJ'),
  ),
));

if (res.data != null) {
  print('Transaction created: ${res.data!.id}');
}

Using PayWidget

PayWidget handles the full payment flow in a WebView:

PayWidget(
  apiKey: 'your_api_key',
  transactionId: transactionId,
  environment: FedaEnvironment.sandbox,
  onPaymentSuccess: () => print('Payment successful!'),
  onPaymentFailed: () => print('Payment failed.'),
  onPaymentCanceled: () => print('Payment canceled.'),
)
Use FedaEnvironment.sandbox during development and switch to .live for production.