lenco_pay_with_transfer_widget 1.0.0+1-beta.4 lenco_pay_with_transfer_widget: ^1.0.0+1-beta.4 copied to clipboard
Lenco Pay With Tranafer Widget
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:lenco_pay_with_transfer_widget/src/datamodel.dart';
import 'package:lenco_pay_with_transfer_widget/src/lenco_pay_with_transfer.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Lenco Pay Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home:const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Lenco Pay With Transfer'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('Click Button to Initiate Lenco Pay'),
ElevatedButton(onPressed: (){
//LencoPayWithTransfer is just like any other widget
Navigator.push(
context,
MaterialPageRoute(builder: (context) => LencoPayWithTransfer(
publicKey: 'pub-f2d1b5e54986c6592a7f6f765c505f28137f592051aa8ca0',
reference: 'ref${Random().nextInt(1000000)}',//unique, (No space) Only ".", "_", and "-" are allowed
email: 'developers@test.com',
amount: 100,//minimum amount to accept
currency: 'NGN',// Optional
accountName: 'Eze Michael', // Optional
//On Successful Payment
onSuccessful: (Transaction transaction){
print(transaction.toJson());
},
//On Rejected Payment
onRejected: (RejectedTransaction transaction){
print(transaction.toJson());
},
//Error messages
onErrorMessage: (String message){
print(message);
},
)),
);
}, child:const Text('Pay with Transfer'))
],
),
),
);
}
}