|
1 | 1 |
|
2 |
| -<p align="center"> |
3 |
| - <img title="Flutterwave" height="200" src="https://flutterwave.com/images/logo-colored.svg" width="50%"/> |
4 |
| -</p> |
5 | 2 |
|
6 |
| -# Flutterwave Flutter Standard SDK |
| 3 | +<p align="center"> |
| 4 | + <img title="Flutterwave" height="200" src="https://flutterwave.com/images/logo/full.svg" width="50%"/> |
| 5 | +</p> |
7 | 6 |
|
8 |
| -## Table of Contents |
| 7 | +# Flutterwave Flutter SDK (Standard) |
| 8 | + |
| 9 | +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. |
9 | 10 |
|
10 |
| -- [About](#about) |
11 |
| -- [Getting Started](#getting-started) |
12 |
| -- [Usage](#usage) |
13 |
| -- [Deployment](#deployment) |
14 |
| -- [Built Using](#build-tools) |
15 |
| -- [References](#references) |
16 |
| -- [Support](#support) |
17 | 11 |
|
18 |
| -<a id="about"></a> |
19 |
| -## About |
20 |
| -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. |
| 12 | +Available features include: |
21 | 13 |
|
| 14 | +- Collections: Card, Account, Mobile money, Bank Transfers, USSD, Barter. |
| 15 | +- Recurring payments: Tokenization and Subscriptions. |
| 16 | +- Split payments |
22 | 17 |
|
23 | 18 |
|
24 |
| -<a id="getting-started"></a> |
| 19 | +## Table of Contents |
25 | 20 |
|
26 |
| -## Getting Started |
| 21 | +1. [Requirements](#requirements) |
| 22 | +2. [Installation](#installation) |
| 23 | +3. [Usage](#usage) |
| 24 | +4. [Support](#support) |
| 25 | +5. [Contribution guidelines](#contribution-guidelines) |
| 26 | +6. [License](#license) |
27 | 27 |
|
28 |
| -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. |
29 |
| -See [references](#references) for links to dashboard and API documentation. |
30 | 28 |
|
31 | 29 | ## Requirements
|
32 |
| -- Ensure you have your test (and live) [API keys](https://developer.flutterwave.com/docs/api-keys). |
33 |
| - ``` Flutter version >= 1.17.0 Flutterwave version 3 API keys ``` |
34 | 30 |
|
35 |
| -## Installation Add the dependency |
| 31 | +1. Flutterwave for business [API Keys](https://developer.flutterwave.com/docs/integration-guides/authentication) |
| 32 | +2. Supported Flutter version >= 1.17.0 |
| 33 | + |
36 | 34 |
|
37 |
| -In your `pubspec.yaml` file add: |
| 35 | +## Installation |
| 36 | + |
| 37 | +1. Add the dependency to your project. In your `pubspec.yaml` file add: `flutterwave_standard: 1.0.5` |
| 38 | +2. Run `flutter pub get` |
38 | 39 |
|
39 |
| -1. `flutterwave_standard: ^1.0.4` |
40 |
| -2. run `flutter pub get` |
41 |
| - <a id="usage"></a> |
42 | 40 |
|
43 | 41 | ## Usage
|
44 | 42 |
|
45 |
| -Create a `Flutterwave` instance by calling the constructor `Flutterwave` The constructor accepts a mandatory instance of the following: |
46 |
| -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. |
47 |
| - |
48 |
| - _handlePaymentInitialization() async { |
49 |
| - final style = FlutterwaveStyle( |
50 |
| - appBarText: "My Standard Blue", |
51 |
| - buttonColor: Color(0xffd0ebff), |
52 |
| - appBarIcon: Icon(Icons.message, color: Color(0xffd0ebff)), |
53 |
| - buttonTextStyle: TextStyle( |
54 |
| - color: Colors.black, |
55 |
| - fontWeight: FontWeight.bold, |
56 |
| - fontSize: 18), |
57 |
| - appBarColor: Color(0xffd0ebff), |
58 |
| - dialogCancelTextStyle: TextStyle( |
59 |
| - color: Colors.redAccent, |
60 |
| - fontSize: 18 |
61 |
| - ), |
62 |
| - dialogContinueTextStyle: TextStyle( |
63 |
| - color: Colors.blue, |
64 |
| - fontSize: 18 |
65 |
| - ) |
66 |
| - ); |
67 |
| - |
68 |
| - final Customer customer = Customer( |
69 |
| - name: "FLW Developer", |
70 |
| - phoneNumber: "1234566677777", |
71 |
| - |
72 |
| - ); |
73 |
| - |
74 |
| - final Flutterwave flutterwave = Flutterwave( |
75 |
| - context: context, |
76 |
| - style: style, |
77 |
| - publicKey: "Public Key, |
78 |
| - currency: "RWF", |
79 |
| - redirectUrl: "my_redirect_url" |
80 |
| - txRef: "unique_transaction_reference", |
81 |
| - amount: "3000", |
82 |
| - customer: customer, |
83 |
| - paymentOptions: "ussd, card, barter, payattitude", |
84 |
| - customization: Customization(title: "Test Payment"), |
85 |
| - isDebug: true |
86 |
| - ); |
87 |
| - } |
88 |
| - |
89 |
| -### 2. Handle the response |
90 |
| - |
91 |
| -Calling the `.charge()` method returns a `Future` |
92 |
| -of `ChargeResponse` which we await for the actual response as seen above. |
93 |
| - |
94 |
| - |
95 |
| - |
96 |
| - final ChargeResponse response = await flutterwave.charge(); |
97 |
| - if (response != null) { |
98 |
| - print(response.toJson()); |
99 |
| - if(response.success) { |
100 |
| - Call the verify transaction endpoint with the transactionID returned in `response.transactionId` to verify transaction before offering value to customer |
101 |
| - } else { |
102 |
| - // Transaction not successful |
103 |
| - } |
104 |
| - } else { |
105 |
| - // User cancelled |
106 |
| - } |
107 |
| - |
108 |
| -#### Please note that: |
109 |
| -- `ChargeResponse` can be null, depending on if the user cancels |
110 |
| - the transaction by pressing back. |
111 |
| -- 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 |
112 |
| - |
113 |
| -> **PLEASE NOTE** |
114 |
| -
|
115 |
| -> We advise you to do a further verification of transaction's details on your server to be sure everything checks out before providing service. |
116 |
| -<a id="deployment"></a> |
117 |
| -
|
118 |
| - |
119 |
| -##Testing |
120 |
| -`pub run test` |
121 |
| - |
122 |
| -## Debugging Errors |
123 |
| -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). |
124 |
| - |
125 |
| -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. |
126 |
| - |
127 |
| -<a id="support"></a> |
128 |
| -## Support For additional assistance using this library, contact the developer experience (DX) team via [email](mailto:[email protected]) or on [slack](https://bit.ly/34Vkzcg). |
129 |
| - |
130 |
| -You can also follow us [@FlutterwaveEng](https://twitter.com/FlutterwaveEng) and let us know what you think 😊 |
| 43 | +### Initializing a Flutterwave instance |
| 44 | + |
| 45 | +To create an instance, you should call the Flutterwave constructor. This constructor accepts a mandatory instance of the following: |
| 46 | + |
| 47 | +- The calling `Context` |
| 48 | +- `publicKey` |
| 49 | +- `Customer` |
| 50 | +- `amount` |
| 51 | +- `email` |
| 52 | +- `fullName` |
| 53 | +- `txRef` |
| 54 | +- `isTestMode` |
| 55 | +- `paymentOptions` |
| 56 | +- `redirectUrl` |
| 57 | +- `Customization` |
| 58 | + |
| 59 | +It returns an instance of Flutterwave which we then call the async method `.charge()` on. |
| 60 | + |
| 61 | +_ |
| 62 | + |
| 63 | + handlePaymentInitialization() async { |
| 64 | + final Customer customer = Customer( |
| 65 | + name: "Flutterwave Developer", |
| 66 | + phoneNumber: "1234566677777", |
| 67 | + |
| 68 | + ); |
| 69 | + final Flutterwave flutterwave = Flutterwave( |
| 70 | + context: context, publicKey: "Public Key-here, |
| 71 | + currency: "currency-here", |
| 72 | + redirectUrl: "add-your-redirect-url-here" |
| 73 | + txRef: "add-your-unique-reference-here", |
| 74 | + amount: "3000", |
| 75 | + customer: customer, |
| 76 | + paymentOptions: "ussd, card, barter, payattitude", |
| 77 | + customization: Customization(title: "My Payment"), |
| 78 | + isTestMode: true ); |
| 79 | + } |
| 80 | + |
| 81 | +### Handling the response |
| 82 | + |
| 83 | +Calling the `.charge()` method returns a `Future` of `ChargeResponse` which we await for the actual response as seen above. |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + final ChargeResponse response = await flutterwave.charge(); |
| 88 | + |
| 89 | +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 |
| 90 | + |
| 91 | +#### Note |
| 92 | + |
| 93 | +- `ChargeResponse` can be null, depending on if the user cancels the transaction by pressing back. |
| 94 | +- 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. |
| 95 | +- 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`) |
| 96 | +- 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. |
| 97 | + |
| 98 | +## Support |
| 99 | + |
| 100 | +For additional assistance using this library, contact the developer experience (DX) team via [email ](mailto:[email protected]) or on [slack ](https://bit.ly/34Vkzcg). |
| 101 | + |
| 102 | +You can also follow us [@FlutterwaveEng](https://twitter.com/FlutterwaveEng) and let us know what you think 😊. |
131 | 103 |
|
132 | 104 | ## Contribution guidelines
|
| 105 | + |
133 | 106 | Read more about our community contribution guidelines [here](https://www.notion.so/flutterwavego/Community-contribution-guide-ca1d8a876ba04d45ab4b663c758ae42a).
|
134 | 107 |
|
135 | 108 | ## License
|
136 |
| -By contributing to the Flutter library, you agree that your contributions will be licensed under its [MIT license](https://opensource.org/licenses/MIT). |
| 109 | + |
| 110 | +By contributing to the Flutter library, you agree that your contributions will be licensed under its [MIT license](/LICENSE). |
| 111 | + |
| 112 | +Copyright (c) Flutterwave Inc. |
137 | 113 |
|
138 | 114 | ## Built Using
|
| 115 | + |
139 | 116 | - [flutter](https://flutter.dev/)
|
140 | 117 | - [http](https://pub.dev/packages/http)
|
141 | 118 | - [flutter_inappwebview](https://pub.dev/packages/flutter_inappwebview)
|
|
0 commit comments