alatpay_sdk 1.0.4
alatpay_sdk: ^1.0.4 copied to clipboard
A Flutter SDK for seamless Alat Pay integration, enabling secure, fast, and reliable in-app payments with simple APIs for payment initialization, confirmation, and tracking.
import 'package:alatpay_sdk/alatpay_sdk.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _incrementCounter() {
Customer demoCustomer = Customer(
email: "jane.doe@email.com",
phone: "09038818841",
firstName: "Jane",
lastName: "Doe",
);
final request = PaymentRequest(
businessId: "************************",
amount: 100,
currency: "NGN",
customer: demoCustomer,
);
AlatPaySdk.startPayment(
context,
request: request,
secretKey: "************************",
onPaymentComplete: (result) {
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.green,
content: Text("Successful payment ${result?.message}"),
),
);
},
onPaymentError: (panic) {
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.red,
content: Text(panic.toString()),
),
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: _incrementCounter,
child: const Text('Start AlatPay Payment'),
),
),
);
}
}