/Flutter

Flutter library for Flutterwave for Business (F4B) v3 APIs.

Primary LanguageDartMIT LicenseMIT

Flutterwave Flutter SDK (Standard)

The Flutter library helps you create seamless payment experiences in your dart mobile app. By connecting to our modal, you can start collecting payment in no time.

Available features include:

  • Collections: Card, Account, Mobile money, Bank Transfers, USSD, Barter.
  • Recurring payments: Tokenization and Subscriptions.
  • Split payments

Table of Contents

  1. Requirements
  2. Installation
  3. Usage
  4. Support
  5. Contribution guidelines
  6. License

Requirements

  1. Flutterwave for business API Keys
  2. Supported Flutter version >= 1.17.0

Installation

  1. Add the dependency to your project. In your pubspec.yaml file add: flutterwave_standard: 1.0.7
  2. Run flutter pub get

Usage

Initializing a Flutterwave instance

To create an instance, you should call the Flutterwave constructor. This constructor accepts a mandatory instance of the following:

  • The calling Context
  • publicKey
  • Customer
  • amount
  • email
  • fullName
  • txRef
  • isTestMode
  • paymentOptions
  • redirectUrl
  • Customization

It returns an instance of Flutterwave which we then call the async method .charge() on.

_

handlePaymentInitialization() async { 
	 final Customer customer = Customer(
	 name: "Flutterwave Developer",
	 phoneNumber: "1234566677777",   
     email: "customer@customer.com"  
 );            
    final Flutterwave flutterwave = Flutterwave(
        context: context, publicKey: "Public Key-here",
		currency: "currency-here",   
        redirectUrl: "add-your-redirect-url-here",  
        txRef: "add-your-unique-reference-here",   
        amount: "3000",   
        customer: customer,   
        paymentOptions: "ussd, card, barter, payattitude",   
        customization: Customization(title: "My Payment"),
        isTestMode: true );
 } 

Handling 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(); 

Call the verify transaction endpoint with the transactionID returned in response.transactionId or the txRef you provided to verify transaction before offering value to customer

Note

  • ChargeResponse can be null, depending on if the user cancels the transaction by pressing back.
  • You need to confirm the transaction is successful. Ensure that the txRef, amount, and status are correct and successful. Be sure to verify the transaction details before providing value.
  • Some payment methods are not instant, such a Pay with Bank Transfers, Pay with Bank, and so you would need to rely on webhooks or call the transaction verification service using the transactionId, or transaction reference you created(txRef)
  • For such long payments like the above, closing the payment page returns a cancelled status, so your final source of truth has to be calling the transaction verification service.

Support

For additional assistance using this library, contact the developer experience (DX) team via email or on slack.

You can also follow us @FlutterwaveEng and let us know what you think 😊.

Contribution guidelines

Read more about our community contribution guidelines here.

License

By contributing to the Flutter library, you agree that your contributions will be licensed under its MIT license.

Copyright (c) Flutterwave Inc.

Built Using

Flutterwave API References