ercaspay 0.0.2 ercaspay: ^0.0.2 copied to clipboard
A Flutter package for ercaspay.
import 'package:flutter/material.dart';
import 'package:ercaspay/ercaspay.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Ercaspay Example',
theme: ThemeData(
primarySwatch: Colors.red,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Ercaspay Example"),
),
body: Center(
child: SizedBox(
child: ElevatedButton(
onPressed: () => gotoPaymentGateway(),
child: const Text('Go to Ercaspay Checkout'),
),
)),
);
}
gotoPaymentGateway() async {
// final ercaspay = Ercaspay(
// context: context,
// amount: 100,
// reference: "{{randomly generated string}}",
// callbackUrl: "{{call back url}}",
// token: "{{Secret Key}}",
// business:
// Business(name: "{{business name}}", email: "{{business email}}"),
// );
//
// PaymentResponse? response = await Ercaspay.chargeTransaction();
//
// if (response != null) {
// if (response.success!) {
// //handle success response
// } else {
// //Handle not successful
// }
// } else {
// //User cancelled checkout
// }
}
}