A Flutter wrapper of the Flutterwave inline payment
A Flutter plugin for making payments via Flutterwave Payment Gateway. Supports web only
To use this plugin, add flutterwave_web_client
as
a dependency in your pubspec.yaml file.
Then initialize the plugin preferably in the initState
of your widget.
import 'package:flutterwave_web_client/flutterwave_web_client.dart';
class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
FlutterwaveWebClient.initialize(
'PUBLIC KEY GOES HERE');
super.initState();
}
}
Include the Flutterwave JS script in your index.html file
<script src="https://checkout.flutterwave.com/v3.js"></script>
void _makePayment() async {
final customer =
FlutterwaveCustomer('xxxxx@gmail.com', '0810xxxxxxx', 'John');
final charge = new Charge()
..amount = 100
..reference = 'test'
..currency = 'NGN'
..country = 'NG'
..customer = customer;
final response = await FlutterwaveWebClient.checkout(charge: charge);
if (response.status) {
print('Successful, Transaction ref ${response.tx_ref}');
} else {
print('Transaction failed');
}
}
It is recommended that when FlutterwaveWebClient.checkout()
returns, the
payment should be verified on your backend.