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