paystack_for_flutter 1.0.4 copy "paystack_for_flutter: ^1.0.4" to clipboard
paystack_for_flutter: ^1.0.4 copied to clipboard

The Flutter package that makes it super easy to integrate Paystack's payment gateway into your app with just few lines of code.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:paystack_for_flutter/paystack_for_flutter.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Paystack Flutter Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            TextButton(
              onPressed: () {
                PaystackFlutter().pay(
                  context: context,
                  secretKey:
                      'sk_test_4daeaa768f986a546516cd9a5d101f657ea4f1d3', // Your Paystack secret key.
                  amount:
                      60000, // The amount to be charged in the smallest currency unit. If amount is 600, multiply by 100(600*100)
                  firstName: 'Elite',
                  lastName: 'Developers',
                  email:
                      'theelitedevelopers1@gmail.com', // The customer's email address.
                  callbackUrl:
                      'https://callback.com', // The URL to which Paystack will redirect the user after the transaction.
                  showProgressBar:
                      false, // If true, it shows progress bar to inform user an action is in progress when getting checkout link from Paystack.
                  paymentOptions: [
                    PaymentOption.card,
                    PaymentOption.bankTransfer,
                    PaymentOption.mobileMoney
                  ],
                  currency: Currency.NGN,
                  metaData: {
                    "product_name": "Nike Sneakers",
                    "product_quantity": 3,
                    "product_price": 24000
                  }, // Additional metadata to be associated with the transaction
                  onSuccess: (paystackCallback) {
                    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                      content: Text(
                          'Transaction Successful::::${paystackCallback.reference}'),
                      backgroundColor: Colors.blue,
                    ));
                  }, // A callback function for when the payment is successful.
                  onCancelled: (paystackCallback) {
                    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                      content: Text(
                          'Transaction Failed/Not successful::::${paystackCallback.reference}'),
                      backgroundColor: Colors.red,
                    ));
                  }, // A callback function for when the payment is canceled.
                );
              },
              child: const Text(
                'Pay with Paystack',
                style: TextStyle(
                  color: Colors.blue,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
30
likes
160
points
196
downloads

Publisher

unverified uploader

Weekly Downloads

The Flutter package that makes it super easy to integrate Paystack's payment gateway into your app with just few lines of code.

Repository (GitHub)
View/report issues

Topics

#paystack #payment #payment-gateway #flutter

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

dio, flutter, webview_flutter

More

Packages that depend on paystack_for_flutter