implemented hotrecharge changes

This commit is contained in:
2026-05-04 00:06:52 +02:00
parent 7566739665
commit 88c776507d
7 changed files with 170 additions and 121 deletions

View File

@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
@@ -22,6 +21,8 @@ class IntegrationController extends ChangeNotifier {
late GatewayController gatewayController;
late SharedPreferences prefs;
bool _disposed = false;
BuildContext context;
IntegrationController(this.context) {
@@ -45,15 +46,14 @@ class IntegrationController extends ChangeNotifier {
});
}
Future<void> doIntegration() async {
try {
model.isLoading = true;
notifyListeners();
dynamic workflowResponse = await http.get(
'/public/transaction/integration/'
'${transactionController.model.confirmationData['id']}'
'/public/transaction/integration/'
'${transactionController.model.confirmationData['id']}',
);
logger.i(workflowResponse.toString());
@@ -63,21 +63,28 @@ class IntegrationController extends ChangeNotifier {
model.status = response['status'];
transactionController.updateReceiptData(response);
await gatewayController.poll(transactionController.model.confirmationData['id']);
await gatewayController.poll(
transactionController.model.confirmationData['id'],
);
}
// regardless of poll result we proceed to receipt
WidgetsBinding.instance.addPostFrameCallback((_) {
context.go('/receipt');
});
model.isLoading = false;
notifyListeners();
if (!_disposed) notifyListeners();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!_disposed && context.mounted) context.go('/receipt');
});
} catch (e) {
model.isLoading = false;
model.errorMessage = e.toString();
notifyListeners();
if (!_disposed) notifyListeners();
}
}
}
@override
void dispose() {
_disposed = true;
super.dispose();
}
}