flutterwave_standard 1.0.2 flutterwave_standard: ^1.0.2 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:
flutterwave_standard: 1.0.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()
, thestatus
,success
andtxRef
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 #
- Have issues integrating? Reach out via our Developer forum for support