Added dialog window to confirm or reject processed payment

This commit is contained in:
Arseni
2026-01-14 18:51:40 +03:00
parent 62bc2644d4
commit abb428e891
2 changed files with 41 additions and 6 deletions

View File

@@ -13,6 +13,7 @@ import 'package:pshared/provider/payment/wallets.dart';
import 'package:pweb/pages/payment_methods/payment_page/body.dart';
import 'package:pweb/widgets/sidebar/destinations.dart';
import 'package:pweb/services/posthog.dart';
import 'package:pweb/widgets/dialogs/payment_status_dialog.dart';
class PaymentPage extends StatefulWidget {
@@ -83,13 +84,13 @@ class _PaymentPageState extends State<PaymentPage> {
final paymentProvider = context.read<PaymentProvider>();
if (paymentProvider.isLoading) return;
paymentProvider.pay().then((_) {
PosthogService.paymentInitiated(method: flowProvider.selectedType);
}).catchError((error) {
paymentProvider.pay().then((payment) {
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(error.toString())),
);
final isSuccess = payment != null && paymentProvider.error == null;
showPaymentStatusDialog(context, isSuccess: isSuccess);
if (isSuccess) {
PosthogService.paymentInitiated(method: flowProvider.selectedType);
}
});
}

View 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),
),
],
);
},
);
}