From 4d9d993d3282deced6b503cf45a31d3de8c9cf34 Mon Sep 17 00:00:00 2001 From: Cornelius Ashley-Osuzoka <59456456+Corvus97@users.noreply.github.com> Date: Sun, 17 Jul 2022 07:37:41 +0100 Subject: [PATCH 1/2] updated developer docs --- README.md | 108 +++++++++++++++++++++++++++--------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 33a2bf1..6b577b0 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,61 @@

- +

-# Flutterwave Flutter Standard SDK +# Flutterwave Flutter SDK (Standard) -## Table of Contents +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. -- [About](#about) -- [Getting Started](#getting-started) -- [Usage](#usage) -- [Deployment](#deployment) -- [Built Using](#build-tools) -- [References](#references) -- [Support](#support) - -## About -Flutterwave's Flutter SDK is Flutterwave's offical flutter sdk to integrate Flutterwave's [Standard](https://developer.flutterwave.com/docs/flutterwave-standard) payment into your flutter app. It comes with a ready made Drop In UI. +Available features include: +- Collections: Card, Account, Mobile money, Bank Transfers, USSD, Barter. +- Recurring payments: Tokenization and Subscriptions. +- Split payments - +## Table of Contents -## Getting Started +1. [Requirements](#requirements) +2. [Installation](#installation) +3. [Usage](#usage) +4. [Support](#support) +5. [Contribution guidelines](#contribution-guidelines) +6. [License](#license) -These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [deployment](#deployment) for notes on how to deploy the project on a live system. -See [references](#references) for links to dashboard and API documentation. ## Requirements -- Ensure you have your test (and live) [API keys](https://developer.flutterwave.com/docs/api-keys). - ``` Flutter version >= 1.17.0 Flutterwave version 3 API keys ``` -## Installation Add the dependency +1. Flutterwave for business [API Keys](https://developer.flutterwave.com/docs/integration-guides/authentication) +2. Supported Flutter version >= 1.17.0 + + +## Installation -In your `pubspec.yaml` file add: +1. Add the dependency to your project. In your `pubspec.yaml` file add: `flutterwave_standard: 1.0.2` +2. Run `flutter pub get` -1. `flutterwave_standard: ^1.0.4` -2. run `flutter pub get` - ## Usage -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. +### 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` +- `currency` +- `email` +- `fullName` +- `txRef` +- `isDebug` +- `paymentOptions` +- `Customization` + +It returns an instance of Flutterwave which we then call the async method `.charge()` on. _handlePaymentInitialization() async { final style = FlutterwaveStyle( @@ -86,10 +98,9 @@ the calling `Context` , `publicKey`, `Customer`, `amount`, `currency`, `email`, ); } -### 2. Handle the response +### Handling the response -Calling the `.charge()` method returns a `Future` -of `ChargeResponse` which we await for the actual response as seen above. +Calling the `.charge()` method returns a Future of `ChargeResponse` which we await for the actual response as seen above. @@ -105,45 +116,34 @@ of `ChargeResponse` which we await for the actual response as seen above. // 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 +#### Note -> **PLEASE NOTE** + 1. `ChargeResponse` can be null if a user cancels the transaction by pressing back. + 2. You need to confirm the transaction is succesful. 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. -> We advise you to do a further verification of transaction's details on your server to be sure everything checks out before providing service. - +## Support -##Testing -`pub run test` +For additional assistance using this library, contact the developer experience (DX) team via [email](mailto:developers@flutterwavego.com) or on [slack](https://bit.ly/34Vkzcg). -## Debugging Errors -We understand that you may run into some errors while integrating our library. You can read more about our error messages [here](https://developer.flutterwave.com/docs/integration-guides/errors). +You can also follow us [@FlutterwaveEng](https://twitter.com/FlutterwaveEng) and let us know what you think 😊. -For `authorization` and `validation` error responses, double-check your API keys and request. If you get a `server` error, kindly engage the team for support. - -## Support For additional assistance using this library, contact the developer experience (DX) team via [email](mailto:developers@flutterwavego.com) or on [slack](https://bit.ly/34Vkzcg). +## Contribution guidelines -You can also follow us [@FlutterwaveEng](https://twitter.com/FlutterwaveEng) and let us know what you think 😊 +Read more about our community contribution guidelines [here](/CONTRIBUTING). -## Contribution guidelines -Read more about our community contribution guidelines [here](https://www.notion.so/flutterwavego/Community-contribution-guide-ca1d8a876ba04d45ab4b663c758ae42a). ## License -By contributing to the Flutter library, you agree that your contributions will be licensed under its [MIT license](https://opensource.org/licenses/MIT). + +By contributing to the Flutter library, you agree that your contributions will be licensed under its [MIT license](/LICENSE). + +Copyright (c) Flutterwave Inc. + ## Built Using + - [flutter](https://flutter.dev/) - [http](https://pub.dev/packages/http) - [flutter_inappwebview](https://pub.dev/packages/flutter_inappwebview) - [fluttertoast](https://pub.dev/packages/fluttertoast) - - -## Flutterwave API References - -- [Flutterwave API Doc](https://developer.flutterwave.com/docs) -- [Flutterwave Inline Payment Doc](https://developer.flutterwave.com/docs/flutterwave-inline) -- [Flutterwave Dashboard](https://dashboard.flutterwave.com/login) \ No newline at end of file From 843da52c17363f892d0a3dfee19b52cb83f1354d Mon Sep 17 00:00:00 2001 From: huzaifansari54 Date: Tue, 11 Oct 2022 19:41:19 +0530 Subject: [PATCH 2/2] migrate to null safty in example --- example/lib/main.dart | 44 +++++++++++++++++++++++++-------------- example/pubspec.lock | 26 +++++++++++------------ example/pubspec.yaml | 5 ++--- lib/core/flutterwave.dart | 3 --- pubspec.lock | 26 +++++++++++------------ pubspec.yaml | 2 +- 6 files changed, 57 insertions(+), 49 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index e0d8256..68b4c26 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -65,7 +65,7 @@ class _MyHomePageState extends State { style: TextStyle(color: Colors.black), decoration: InputDecoration(hintText: "Amount"), validator: (value) => - value.isNotEmpty ? null : "Amount is required", + value!.isNotEmpty ? null : "Amount is required", ), ), Container( @@ -80,7 +80,7 @@ class _MyHomePageState extends State { hintText: "Currency", ), validator: (value) => - value.isNotEmpty ? null : "Currency is required", + value!.isNotEmpty ? null : "Currency is required", ), ), Container( @@ -151,7 +151,7 @@ class _MyHomePageState extends State { width: double.infinity, height: 50, margin: EdgeInsets.fromLTRB(0, 20, 0, 10), - child: RaisedButton( + child: MaterialButton( onPressed: this._onPressed, color: Colors.blue, child: Text( @@ -168,7 +168,7 @@ class _MyHomePageState extends State { } _onPressed() { - if (this.formKey.currentState.validate()) { + if (this.formKey.currentState!.validate()) { this._handlePaymentInitialization(); } } @@ -191,11 +191,8 @@ class _MyHomePageState extends State { fontSize: 18, ), mainBackgroundColor: Colors.indigo, - mainTextStyle: TextStyle( - color: Colors.indigo, - fontSize: 19, - letterSpacing: 2 - ), + mainTextStyle: + TextStyle(color: Colors.indigo, fontSize: 19, letterSpacing: 2), dialogBackgroundColor: Colors.greenAccent, appBarIcon: Icon(Icons.message, color: Colors.purple), buttonText: "Pay $selectedCurrency${amountController.text}", @@ -209,10 +206,16 @@ class _MyHomePageState extends State { name: "FLW Developer", phoneNumber: this.phoneNumberController.text ?? "12345678", email: "customer@customer.com"); - + final subAccounts = [ - SubAccount(id: "RS_1A3278129B808CB588B53A14608169AD", transactionChargeType: "flat", transactionPercentage: 25), - SubAccount(id: "RS_C7C265B8E4B16C2D472475D7F9F4426A", transactionChargeType: "flat", transactionPercentage: 50) + SubAccount( + id: "RS_1A3278129B808CB588B53A14608169AD", + transactionChargeType: "flat", + transactionPercentage: 25), + SubAccount( + id: "RS_C7C265B8E4B16C2D472475D7F9F4426A", + transactionChargeType: "flat", + transactionPercentage: 50) ]; final Flutterwave flutterwave = Flutterwave( @@ -230,9 +233,9 @@ class _MyHomePageState extends State { paymentOptions: "card, payattitude, barter", customization: Customization(title: "Test Payment"), isTestMode: false); - final ChargeResponse response = await flutterwave.charge(); + final ChargeResponse? response = await flutterwave.charge(); if (response != null) { - this.showLoading(response.status); + this.showLoading(response.status!); print("${response.toJson()}"); } else { this.showLoading("No Response!"); @@ -241,7 +244,7 @@ class _MyHomePageState extends State { String getPublicKey() { if (isTestMode) return "FLWPUBK_TEST-895362a74986153380262d89bfdc9b8a-X"; - // "FLWPUBK_TEST-02b9b5fc6406bd4a41c3ff141cc45e93-X"; + // "FLWPUBK_TEST-02b9b5fc6406bd4a41c3ff141cc45e93-X"; return "FLWPUBK-aa4cd0b443404147d2d8229a37694b00-X"; } @@ -298,7 +301,16 @@ class _MyHomePageState extends State { margin: EdgeInsets.fromLTRB(30, 20, 30, 20), width: double.infinity, height: 50, - child: Text(message), + child: Row( + children: [ + Text(message), + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: Text("Ok")) + ], + ), ), ); }, diff --git a/example/pubspec.lock b/example/pubspec.lock index 6a3f555..3482a63 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -127,28 +127,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" pedantic: dependency: transitive description: @@ -167,7 +167,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -188,21 +188,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" typed_data: dependency: transitive description: @@ -225,5 +225,5 @@ packages: source: hosted version: "2.1.2" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=2.18.0 <3.0.0" flutter: ">=1.22.2" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 34b30c9..f55a621 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,14 +4,14 @@ description: A flutterwave example project. version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.18.0 <3.0.0" dependencies: flutter: sdk: flutter flutterwave_standard: path: "../" -# flutterwave_standard: ^1.0.3 + # flutterwave_standard: ^1.0.3 cupertino_icons: ^0.1.3 uuid: 3.0.4 @@ -19,5 +19,4 @@ dev_dependencies: flutter_test: sdk: flutter flutter: - uses-material-design: true diff --git a/lib/core/flutterwave.dart b/lib/core/flutterwave.dart index 9366137..7387cc3 100644 --- a/lib/core/flutterwave.dart +++ b/lib/core/flutterwave.dart @@ -1,11 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutterwave_standard/models/requests/customer.dart'; import 'package:flutterwave_standard/models/requests/customizations.dart'; import 'package:flutterwave_standard/models/requests/standard_request.dart'; import 'package:flutterwave_standard/models/responses/charge_response.dart'; import 'package:flutterwave_standard/models/subaccount.dart'; -import 'package:flutterwave_standard/utils.dart'; import 'package:flutterwave_standard/view/flutterwave_style.dart'; import 'package:flutterwave_standard/view/payment_widget.dart'; @@ -41,7 +39,6 @@ class Flutterwave { this.meta, this.style}); - /// Starts Standard Transaction Future charge() async { final request = StandardRequest( diff --git a/pubspec.lock b/pubspec.lock index 629072a..d219c88 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -28,7 +28,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -84,7 +84,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" code_builder: dependency: transitive description: @@ -126,7 +126,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" file: dependency: transitive description: @@ -211,21 +211,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" mockito: dependency: "direct dev" description: @@ -246,7 +246,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" pedantic: dependency: transitive description: @@ -279,7 +279,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -300,21 +300,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" typed_data: dependency: transitive description: @@ -344,5 +344,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=2.18.0 <3.0.0" flutter: ">=1.22.2" diff --git a/pubspec.yaml b/pubspec.yaml index be0d7cc..e1e5a9e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutterwave's official library that wraps the standard implementati version: 1.0.4 homepage: https://github.com/Flutterwave/flutter_standard environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.18.0 <3.0.0" flutter: ">=1.17.0" dependencies: