paystack_africa 2.0.0 copy "paystack_africa: ^2.0.0" to clipboard
paystack_africa: ^2.0.0 copied to clipboard

Flutter helper to create Paystack payment sessions, open an in-app WebView checkout, and return success/failure results with typed responses.

Paystack WebView (Flutter) #

A simple Flutter helper to accept Paystack payments via an in-app WebView.

  • ✅ Sandbox & Live support (public keys)
  • ✅ Typed success/failure result objects
  • ✅ Minimal API (PaystackGateway.pay(...))
  • ⚠️ Only use your public key (pk_...) in client apps. Never expose your secret key.

This package is not an official Paystack SDK.


Features #

  • Create a Paystack checkout session from your Flutter app
  • Open payment UI inside a WebView
  • Handle success or failure with clear callbacks
  • Example project included

Getting started #

Installation #

Add the dependency in pubspec.yaml:

dependencies:
  paystack_africa: ^2.0.0

Then run:

flutter pub get

Provide your public key #

Use --dart-define to avoid hardcoding:

flutter run --dart-define=PAYSTACK_PUBLIC_KEY=pk_test_xxx

Access it in code:

static const publicKey = String.fromEnvironment(
  'PAYSTACK_PUBLIC_KEY',
  defaultValue: 'pk_test_example_for_dev_only',
);

Usage #

final gateway = PaystackGateway(publicKey: publicKey);
final result = await gateway.pay(
  context: context,
  amountSmallestUnit: 150000, // ₦1,500.00
  email: 'customer@example.com',
);

if (result.isSuccess) {
  final data = (result as PaymentSuccess).data;
  // handle success
} else {
  final message = (result as PaymentFailure).message;
  // handle failure
}

Example #

See the example app.

ElevatedButton(
  onPressed: () async {
    final res = await gateway.pay(
      context: context,
      amountSmallestUnit: 150000, // ₦1,500
      email: 'customer@example.com',
    );
    final msg = res.isSuccess
        ? 'SUCCESS: ${(res as PaymentSuccess).data}'
        : 'FAIL: ${(res as PaymentFailure).message}';
    if (context.mounted) {
      ScaffoldMessenger.of(context)
          .showSnackBar(SnackBar(content: Text(msg)));
    }
  },
  child: const Text('Pay ₦1,500'),
)

License #

This project is licensed under the MIT License - see LICENSE.

1
likes
160
points
36
downloads

Publisher

verified publishergoutam.info

Weekly Downloads

Flutter helper to create Paystack payment sessions, open an in-app WebView checkout, and return success/failure results with typed responses.

Repository (GitHub)
View/report issues

Topics

#payments #checkout #paystack #nigeria

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, webview_flutter

More

Packages that depend on paystack_africa