// ...
import 'package:payaza/payaza.dart';
// ...
void handleSuccess(PayazaSuccessResponse response) async {
await showAlert(
message: response.data.payazaReference ?? '',
title: 'Payment Successful');
if (context.mounted) {
Navigator.of(context).pop();
}
}
void handleError(PayazaErrorResponse response) async {
await showAlert(message: response.data.message, title: 'Error');
if (context.mounted) {
Navigator.of(context).pop();
}
}
void handleClose() {
print('Payaza widget was closed');
}
void onSubmit() {
Payaza.createTransaction(
context,
config: PayazaConfig(
amount: 110,
connectionMode: PayazaConnectionMode.LIVE_CONNECTION_MODE,
email: "example@example.com",
firstName: "<first name>",
lastName: "<last name>",
phoneNumber: "<+12345678900>",
transactionReference: "transaction_reference",
currencyCode: <NGN>,
),
onSuccess: handleSuccess,
onError: handleError,
onClose: handleClose,
);
}