feexpay_flutter 1.0.9 feexpay_flutter: ^1.0.9 copied to clipboard
A secure plugin to accept Mobile Money and Credit Card payments.
import 'package:example/end.dart';
import 'package:example/success.dart';
import 'package:feexpay_flutter/feexpay_flutter.dart';
import 'package:flutter/material.dart';
import 'package:random_string/random_string.dart';
void main() {
runApp(const MyApp(
));
}
class MyApp extends StatelessWidget {
const MyApp({key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'My Flutter Application'),
routes: <String, WidgetBuilder>{
'/endpayment': (BuildContext context) => const EndPage(),
'/successpayment': (BuildContext context) => const SuccessPage(),
},
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
bool popupIsActive = false;
late String editableText;
String randomString = randomAlphaNumeric(15);
String amount = '100';
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
MaterialButton(
child: Text('Payer $amount'),
color: Color(0xFF112C56),
textColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),),
onPressed: () => {
print(double.parse(amount)),
// print(randomString)
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ChoicePage(
token: 'fp_9jqqsIq8chG71drXD4SklEo6kHB6pjEkE0PYZuESPW49hoVBUyE87pSGH0AEsgkk',
// token: 'fp_expK2auYVTcKGLkg6yq3FfozEg7TdOkczJSMMZtJoOBR55gwwrDv7kGrssa0tZEj',
id: '64636ba955d2ed60e9eac0b9',
// id: '63e3c477589840e611232472',
amount: amount,
redirecturl: 'successpayment',
errorredirecturl: 'endpayment',
trans_key: randomString,
//callback_info: {"id": "fvjinduhghbuyfjhfdg"},
)),
)
}
),
],
),
),
);
}
}
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
void setState(Null Function() param0) {
}
@override
Widget build(BuildContext context) {
var widget;
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}