gmpay 1.0.27
gmpay: ^1.0.27 copied to clipboard
Fast and secure transactions for businesses and individuals.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:gmpay/flutter_gmpay.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// String _platformVersion = 'Unknown';
// final _gmpayPlugin = Gmpay();
@override
void initState() {
// Gmpay.instance.initialize(
// key: dotenv.env['APIKEY']!, secret: dotenv.env['APISECRET']!);
Gmpay.instance.initialize(packageName: "com.test.app", testMode: false);
super.initState();
}
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: WeNeedTheNavigator(),
themeMode: ThemeMode.dark,
);
}
}
class WeNeedTheNavigator extends StatelessWidget {
const WeNeedTheNavigator({
super.key,
});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('GMPAY PLUGIN TEST'),
centerTitle: true,
),
body: ListView(children: [
// GmpayCard(
// amount: 1000,
// ),
ElevatedButton(
onPressed: () {
Gmpay.instance.presentPaymentSheet(
context,
amount: 3000,
account: dotenv.env['PHONE']!,
metadata: {
"callback_url": "https://example.com/callback",
},
waitForConfirmation: true,
approvalUrlHandler: (p0) {
debugPrint(p0);
},
callback: (p1) {
if (p1 == null) {
debugPrint("Transaction cancelled");
} else {
debugPrint(p1.status?.name);
}
},
);
},
child: const Text("Show Bottomsheet")),
ElevatedButton(
onPressed: () {
Gmpay.instance.presentWithdrawSheet(
context,
amount: 1000,
account: dotenv.env['PHONE']!,
waitForConfirmation: true,
callback: (p1) {
if (p1 == null) {
debugPrint("Transaction cancelled");
} else {
if (kDebugMode) {
print(p1);
}
}
},
);
},
child: const Text("Show W Bottomsheet")),
ElevatedButton(
onPressed: () {
Gmpay.instance.presentVerificationSheet(
context,
reference: "1X4BJYKO6E8D",
callback: (p1) {
if (p1 == null) {
debugPrint("Transaction cancelled");
} else {
if (kDebugMode) {
print(p1);
}
}
},
);
},
child: const Text("Check transaction status")),
]),
);
}
}