Added dialog window to confirm or reject processed payment #250
@@ -13,6 +13,7 @@ import 'package:pshared/provider/payment/wallets.dart';
|
|||||||
import 'package:pweb/pages/payment_methods/payment_page/body.dart';
|
import 'package:pweb/pages/payment_methods/payment_page/body.dart';
|
||||||
import 'package:pweb/widgets/sidebar/destinations.dart';
|
import 'package:pweb/widgets/sidebar/destinations.dart';
|
||||||
import 'package:pweb/services/posthog.dart';
|
import 'package:pweb/services/posthog.dart';
|
||||||
|
import 'package:pweb/widgets/dialogs/payment_status_dialog.dart';
|
||||||
|
|
||||||
|
|
||||||
class PaymentPage extends StatefulWidget {
|
class PaymentPage extends StatefulWidget {
|
||||||
@@ -83,13 +84,13 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
final paymentProvider = context.read<PaymentProvider>();
|
final paymentProvider = context.read<PaymentProvider>();
|
||||||
if (paymentProvider.isLoading) return;
|
if (paymentProvider.isLoading) return;
|
||||||
|
|
||||||
paymentProvider.pay().then((_) {
|
paymentProvider.pay().then((payment) {
|
||||||
PosthogService.paymentInitiated(method: flowProvider.selectedType);
|
|
||||||
}).catchError((error) {
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
final isSuccess = payment != null && paymentProvider.error == null;
|
||||||
SnackBar(content: Text(error.toString())),
|
showPaymentStatusDialog(context, isSuccess: isSuccess);
|
||||||
);
|
if (isSuccess) {
|
||||||
|
PosthogService.paymentInitiated(method: flowProvider.selectedType);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
frontend/pweb/lib/widgets/dialogs/payment_status_dialog.dart
Normal file
34
frontend/pweb/lib/widgets/dialogs/payment_status_dialog.dart
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||||
|
|
||||||
|
|
||||||
|
Future<void> showPaymentStatusDialog(BuildContext context, {required bool isSuccess}) {
|
||||||
|
return showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialogContext) {
|
||||||
|
final l10n = AppLocalizations.of(dialogContext)!;
|
||||||
|
return AlertDialog(
|
||||||
|
icon: isSuccess
|
||||||
|
? const Icon(Icons.check_circle, color: Colors.green, size: 48)
|
||||||
|
: const Icon(Icons.error, color: Colors.red, size: 48),
|
||||||
|
title: Text(
|
||||||
|
isSuccess
|
||||||
|
? l10n.paymentStatusSuccessTitle
|
||||||
|
: l10n.paymentStatusFailureTitle,
|
||||||
|
),
|
||||||
|
content: Text(
|
||||||
|
isSuccess
|
||||||
|
? l10n.paymentStatusSuccessMessage
|
||||||
|
: l10n.paymentStatusFailureMessage,
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||||
|
child: Text(l10n.ok),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user