fixes on tran flow
This commit is contained in:
@@ -53,7 +53,7 @@ class ConfirmController extends ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> doTransaction() async {
|
||||
Future<Map<String, dynamic>?> doTransaction() async {
|
||||
try {
|
||||
model.isLoading = true;
|
||||
notifyListeners();
|
||||
@@ -82,20 +82,9 @@ class ConfirmController extends ChangeNotifier {
|
||||
|
||||
transactionController.updateReceiptData(response);
|
||||
|
||||
if (transactionController.model.selectedPaymentProcessor.authType == "WEB") {
|
||||
if (context.mounted) {
|
||||
if(kIsWeb){
|
||||
// the one we use here depends on when mpgs embedded bug will be fixed
|
||||
context.push('/gateway-web');
|
||||
// context.push('/gateway-redirect');
|
||||
}else {
|
||||
context.push('/gateway');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await pollTransaction(transactionController.model.receiptData?['id']);
|
||||
context.push('/poll');
|
||||
}
|
||||
model.isLoading = false;
|
||||
notifyListeners();
|
||||
return response;
|
||||
} else {
|
||||
model.status = response['status'];
|
||||
model.errorMessage = response['errorMessage'];
|
||||
@@ -111,6 +100,7 @@ class ConfirmController extends ChangeNotifier {
|
||||
|
||||
model.isLoading = false;
|
||||
notifyListeners();
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> pollTransaction(String uid) async {
|
||||
@@ -125,6 +115,7 @@ class ConfirmController extends ChangeNotifier {
|
||||
if (response['status'] == 'SUCCESS') {
|
||||
model.status = response['status'];
|
||||
transactionController.updateReceiptData(response);
|
||||
model.isCancelled = true;
|
||||
notifyListeners();
|
||||
break;
|
||||
}
|
||||
@@ -145,6 +136,5 @@ class ConfirmController extends ChangeNotifier {
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
model.isCancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:qpay/models/responsive_policy.dart';
|
||||
@@ -59,6 +60,36 @@ class _ConfirmScreenState extends State<ConfirmScreen>
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _handlePayment() async {
|
||||
try {
|
||||
if (controller.model.isLoading) return;
|
||||
|
||||
final response = await controller.doTransaction();
|
||||
if (response!['status'] == 'FAILED') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
if (controller.transactionController.model.selectedPaymentProcessor.authType == "WEB") {
|
||||
if(kIsWeb){
|
||||
// the one we use here depends on when mpgs embedded bug will be fixed
|
||||
context.push('/gateway-web');
|
||||
// context.push('/gateway-redirect');
|
||||
}else {
|
||||
context.push('/gateway');
|
||||
}
|
||||
} else {
|
||||
if (!mounted) return;
|
||||
context.push('/poll');
|
||||
}
|
||||
}catch (e,s) {
|
||||
print(e);
|
||||
print(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -384,9 +415,7 @@ class _ConfirmScreenState extends State<ConfirmScreen>
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
onTap: () async {
|
||||
if (controller.model.isLoading) return;
|
||||
|
||||
await controller.doTransaction();
|
||||
_handlePayment();
|
||||
},
|
||||
child: ListTile(
|
||||
leading: Container(
|
||||
|
||||
Reference in New Issue
Block a user