Skip to content

Clean up and updates to dependencies and modification of the Flutterwave.charge() charge #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 37 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,52 @@
## [1.1.0] | 2025-04-10

### Version Changes

- Modified `Flutterwave.charge()` method to accept a BuildContext parameter.
- Added context.mounted checks to prevent setState calls after widget disposal.
- Enhanced success status check logic to handle different status values ("success" and "completed").
- Improved error handling and state management.
- Removed deprecated components: `flutterwave_style.dart` and `standard_webview.dart`.
- Updated SDK requirements to `>=2.17.0`.
- Upgraded dependencies to latest versions.
- Removed unused dependencies: webview_flutter, modal_bottom_sheet and uuid.

## [1.0.7] - February, 2023
* Fixed iOS bug where webview couldn't close when close buttons are clicked
* Removed required `name` and `phone number` fields in `Customer` object

- Fixed iOS bug where webview couldn't close when close buttons are clicked
- Removed required `name` and `phone number` fields in `Customer` object

## [1.0.6] - October, 2022
* Fixed bug where transaction gets stuck after redirecting on webview
* Fixed iOS build bug by removing inAppBrowser library

- Fixed bug where transaction gets stuck after redirecting on webview
- Fixed iOS build bug by removing inAppBrowser library

## [1.0.5] - October, 2022
* Fixed null when transaction is cancelled.
* Removed modal pop up before launching web view.
* Removed intermediate make payment screen before webview.
* Deprecated FlutterwaveStyle.
* Updated README file.

- Fixed null when transaction is cancelled.
- Removed modal pop up before launching web view.
- Removed intermediate make payment screen before webview.
- Deprecated FlutterwaveStyle.
- Updated README file.

## [1.0.4] - July 4, 2022
* Renamed property `isDebug` to `isTestMode`
* Made property `redirectUrl` required
* Updated README file

- Renamed property `isDebug` to `isTestMode`
- Made property `redirectUrl` required
- Updated README file

## [1.0.3] - October 4, 2021.
* Fixed issue with webview

- Fixed issue with webview

## [1.0.2] - September 23, 2021.
* Fixed bug where cancel payment buttons are not clickable on iOS devices.

- Fixed bug where cancel payment buttons are not clickable on iOS devices.

## [1.0.1] - September 14, 2021.
* Fixed bug where response is not returned to initiating screen when user cancels transaction.

- Fixed bug where response is not returned to initiating screen when user cancels transaction.

## [1.0.0] - September 9, 2021.
* Initial release

- Initial release
68 changes: 35 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@


<p align="center">
<img title="Flutterwave" height="200" src="https://flutterwave.com/images/logo/full.svg" width="50%"/>
</p>
</p>

# 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.
- Collections: Card, Account, Mobile money, Bank Transfers, USSD.
- Recurring payments: Tokenization and Subscriptions.
- Split payments


## Table of Contents

1. [Requirements](#requirements)
Expand All @@ -25,26 +21,24 @@ Available features include:
5. [Contribution guidelines](#contribution-guidelines)
6. [License](#license)


## Requirements

1. Flutterwave for business [API Keys](https://developer.flutterwave.com/docs/integration-guides/authentication)
2. Supported Flutter version >= 1.17.0

3. Dart SDK >= 2.17.0
4. For Android: Ensure NDK version >= 27.0.12077973 on your project's android/app/build.gradle.kts file with android { ndkVersion = "27.0.12077973" }

## Installation

1. Add the dependency to your project. In your `pubspec.yaml` file add: `flutterwave_standard: 1.0.7`
1. Add the dependency to your project. In your `pubspec.yaml` file add: `flutterwave_standard: 1.1.0`
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`
Expand All @@ -58,41 +52,48 @@ To create an instance, you should call the Flutterwave constructor. This constru

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

_
\_

handlePaymentInitialization() async {
handlePaymentInitialization() async {
final Customer customer = Customer(
name: "Flutterwave Developer",
phoneNumber: "1234566677777",
email: "[email protected]"
);
phoneNumber: "1234566677777",
email: "[email protected]"
);
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",
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, bank transfer",
customization: Customization(title: "My Payment"),
isTestMode: true );
}

### Handling the response
final ChargeResponse response = await flutterwave.charge(context);

Calling the `.charge()` method returns a `Future` of `ChargeResponse` which we await for the actual response as seen above.
// Handle the response
if (response.success == true) {
// Payment was successful
} else {
// Payment failed or was cancelled
}
}

### 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();
final ChargeResponse response = await flutterwave.charge(context);

Call the verify transaction [endpoint](https://developer.flutterwave.com/docs/verifications/transaction) with the `transactionID` returned in `response.transactionId` or the `txRef` you provided to verify transaction before offering value to customer
Call the verify transaction [endpoint](https://developer.flutterwave.com/docs/transaction-verification) 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](https://developer.flutterwave.com/docs/verifications/transaction) 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](https://developer.flutterwave.com/docs/integration-guides/webhooks) or call the transaction verification service using the [`transactionId`](https://developer.flutterwave.com/reference/endpoints/transactions#verify-a-transaction), or transaction reference you created(`txRef`)
- 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](https://developer.flutterwave.com/docs/transaction-verification) 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](https://developer.flutterwave.com/docs/webhooks) or call the transaction verification service using the [`transactionId`](https://developer.flutterwave.com/reference/verify-transaction), 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
Expand All @@ -119,8 +120,9 @@ Copyright (c) Flutterwave Inc.
- [fluttertoast](https://pub.dev/packages/fluttertoast)

<a id="references"></a>
## Flutterwave API References

- [Flutterwave API Doc](https://developer.flutterwave.com/docs)
- [Flutterwave Inline Payment Doc](https://developer.flutterwave.com/docs/flutterwave-inline)
## Flutterwave API References

- [Flutterwave API Doc](https://developer.flutterwave.com)
- [Flutterwave Inline Payment Doc](https://developer.flutterwave.com/docs/inline)
- [Flutterwave Dashboard](https://dashboard.flutterwave.com/login)
13 changes: 7 additions & 6 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
*.iml
Expand All @@ -26,19 +29,17 @@
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
29 changes: 22 additions & 7 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: 85684f9300908116a78138ea4c6036c35c9a1236
channel: stable
revision: "c23637390482d4cf9598c3ce3f2be31aa7332daf"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 85684f9300908116a78138ea4c6036c35c9a1236
base_revision: 85684f9300908116a78138ea4c6036c35c9a1236
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
- platform: android
create_revision: 85684f9300908116a78138ea4c6036c35c9a1236
base_revision: 85684f9300908116a78138ea4c6036c35c9a1236
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
- platform: ios
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
- platform: linux
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
- platform: macos
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
- platform: web
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
- platform: windows
create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf
base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf

# User provided section

Expand Down
10 changes: 5 additions & 5 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flutterwave_beta
# example

A new Flutter project.

Expand All @@ -8,9 +8,9 @@ This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
3 changes: 1 addition & 2 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
Expand Down
3 changes: 2 additions & 1 deletion example/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
Loading
Loading