flutterwave_standard 1.0.3 icon indicating copy to clipboard operation
flutterwave_standard: ^1.0.3 copied to clipboard

Flutterwave's official library that wraps the standard implementation.

Flutterwave Flutter Standard SDK #

Table of Contents #

About #

Flutterwave's Flutter SDK is Flutterwave's offical flutter sdk to integrate Flutterwave's Standard payment into your flutter app. It comes with a ready made Drop In UI.

Getting Started #

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. See references for links to dashboard and API documentation.

Prerequisite #

  • Ensure you have your test (and live) API keys.
Flutter version >= 1.17.0
Flutterwave version 3 API keys

Installing #

Step 1. Add the dependency

In your pubspec.yaml file add:

  1. flutterwave_standard: ^1.0.3
  2. run flutter pub get

Usage #

1. Create a Flutterwave instance #

Create a Flutterwave instance by calling the constructor Flutterwave The constructor accepts a mandatory instance of the following: the calling Context , publicKey, Customer, amount, currency, email, fullName, txRef, isDebug, paymentOptions, and Customization . It returns an instance of Flutterwave which we then call the async method .charge() on.

  _handlePaymentInitialization() async {
    final style = FlutterwaveStyle(
        appBarText: "My Standard Blue",
        buttonColor: Color(0xffd0ebff),
        appBarIcon: Icon(Icons.message, color: Color(0xffd0ebff)),
        buttonTextStyle: TextStyle(
          color: Colors.black,
          fontWeight: FontWeight.bold,
          fontSize: 18,
        ),
      appBarColor: Color(0xffd0ebff),
      dialogCancelTextStyle: TextStyle(
        color: Colors.redAccent,
        fontSize: 18,
      ),
      dialogContinueTextStyle: TextStyle(
        color: Colors.blue,
        fontSize: 18,
      )
    );
    final Customer customer = Customer(
            name: "FLW Developer",
            phoneNumber: "1234566677777",
            email: "customer@customer.com");

    final Flutterwave flutterwave = Flutterwave(
        context: context,
        style: style,
        publicKey: "Public Key,
        currency: "RWF",
        txRef: "unique_transaction_reference",
        amount: "3000",
        customer: customer,
        paymentOptions: "ussd, card, barter, payattitude",
        customization: Customization(title: "Test Payment"),
        isDebug: true);
  }

2. Handle the response #

Calling the .charge() method returns a Future of ChargeResponse which we await for the actual response as seen above.

 final ChargeResponse response = await flutterwave.charge();
 if (response != null) {
   print(response.toJson());
   if(response.success) {
     Call the verify transaction endpoint with the transactionID returned in `response.transactionId` to verify transaction before offering value to customer
   } else {
    // Transaction not successful
   }
 } else {
   // User cancelled
 }

Please note that:

  • ChargeResponse can be null, depending on if the user cancels the transaction by pressing back.
  • You need to check the status of the transaction from the instance of ChargeResponse returned from calling .charge(), the status, success and txRef are successful and correct before providing value to the customer

PLEASE NOTE

We advise you to do a further verification of transaction's details on your server to be sure everything checks out before providing service.

Deployment #

  • Switch to Live Mode on the Dashboard settings page
  • Use the Live Public API key from the API tab, see here for more details.

Built Using #

Flutterwave API References #

Support #

7
likes
110
pub points
81%
popularity

Flutterwave's official library that wraps the standard implementation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_inappwebview, fluttertoast, http

More

Packages that depend on flutterwave_standard