paystack_gateway_payment 1.1.6 paystack_gateway_payment: ^1.1.6 copied to clipboard
Flutter integration for Paystack: easily initialize, verify payments, and use a customizable payment button.
import 'package:flutter/material.dart';
import 'package:paystack_gateway_payment/services/paystack_service.dart';
import 'package:paystack_gateway_payment/widgets/paystack_button.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Paystack Payment Example',
theme: ThemeData(primarySwatch: Colors.blue),
home: PaymentScreen(),
);
}
}
class PaymentScreen extends StatelessWidget {
// Replace with your actual Paystack secret key
final String paystackSecretKey = 'sk_test_xxxxxxxx';
@override
Widget build(BuildContext context) {
final paystackService = PaystackService(secretKey: paystackSecretKey);
return Scaffold(
appBar: AppBar(title: const Text('Paystack Payment Example')),
body: Center(
child: PaystackButton(
paystackService: paystackService,
email: 'testuser@example.com',
amount: 5000, // Amount in kobo (e.g., 5000 kobo = 50 NGN)
callbackUrl: 'https://example.com/callback',
buttonText: const Text('Pay Now'),
paymentScreenTitle: 'Complete Your Payment',
onTransactionComplete: (status, response) {
// Handle transaction completion
debugPrint('Transaction Status: $status');
if (response != null) {
debugPrint('Transaction Data: ${response.toString()}');
}
},
),
),
);
}
}