fixes on tran flow
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
BASE_URL=https://peakapi.qantra.co.zw/api
|
; BASE_URL=https://peakapi.qantra.co.zw/api
|
||||||
; BASE_URL=http://192.168.100.26:6950/api
|
BASE_URL=http://192.168.100.138:6950/api
|
||||||
; BASE_URL=http://173.212.247.232:6950/api
|
; BASE_URL=http://173.212.247.232:6950/api
|
||||||
; BASE_URL=http://10.69.5.201:6950/api
|
; BASE_URL=http://10.69.5.201:6950/api
|
||||||
; BASE_URL=http://192.168.120.160:6950/api
|
; BASE_URL=http://192.168.120.160:6950/api
|
||||||
@@ -7,5 +7,5 @@ BASE_URL=https://peakapi.qantra.co.zw/api
|
|||||||
; BASE_URL=http://172.20.5.105:6950/api
|
; BASE_URL=http://172.20.5.105:6950/api
|
||||||
; BASE_URL=http://10.10.3.92:6950/api
|
; BASE_URL=http://10.10.3.92:6950/api
|
||||||
CLIENTID=77433712483-ng7pntvcpf6tnjccriuqm8dbna8vvp3b.apps.googleusercontent.com
|
CLIENTID=77433712483-ng7pntvcpf6tnjccriuqm8dbna8vvp3b.apps.googleusercontent.com
|
||||||
SIMULATE_PAYMENT_SUCCESS=false
|
; SIMULATE_PAYMENT_SUCCESS=false
|
||||||
; SIMULATE_PAYMENT_SUCCESS=true
|
SIMULATE_PAYMENT_SUCCESS=true
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ class Http {
|
|||||||
|
|
||||||
Http() {
|
Http() {
|
||||||
dio.options.baseUrl = baseUrl;
|
dio.options.baseUrl = baseUrl;
|
||||||
dio.options.connectTimeout = const Duration(seconds: 120);
|
// dio.options.connectTimeout = const Duration(seconds: 120);
|
||||||
dio.options.receiveTimeout = const Duration(seconds: 120);
|
// dio.options.receiveTimeout = const Duration(seconds: 120);
|
||||||
dio.options.sendTimeout = const Duration(seconds: 120);
|
// dio.options.sendTimeout = const Duration(seconds: 120);
|
||||||
dio.interceptors.add(
|
dio.interceptors.add(
|
||||||
LogInterceptor(
|
LogInterceptor(
|
||||||
request: true,
|
request: true,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class ConfirmController extends ChangeNotifier {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> doTransaction() async {
|
Future<Map<String, dynamic>?> doTransaction() async {
|
||||||
try {
|
try {
|
||||||
model.isLoading = true;
|
model.isLoading = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -82,20 +82,9 @@ class ConfirmController extends ChangeNotifier {
|
|||||||
|
|
||||||
transactionController.updateReceiptData(response);
|
transactionController.updateReceiptData(response);
|
||||||
|
|
||||||
if (transactionController.model.selectedPaymentProcessor.authType == "WEB") {
|
model.isLoading = false;
|
||||||
if (context.mounted) {
|
notifyListeners();
|
||||||
if(kIsWeb){
|
return response;
|
||||||
// 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');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
model.status = response['status'];
|
model.status = response['status'];
|
||||||
model.errorMessage = response['errorMessage'];
|
model.errorMessage = response['errorMessage'];
|
||||||
@@ -111,6 +100,7 @@ class ConfirmController extends ChangeNotifier {
|
|||||||
|
|
||||||
model.isLoading = false;
|
model.isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> pollTransaction(String uid) async {
|
Future<void> pollTransaction(String uid) async {
|
||||||
@@ -125,6 +115,7 @@ class ConfirmController extends ChangeNotifier {
|
|||||||
if (response['status'] == 'SUCCESS') {
|
if (response['status'] == 'SUCCESS') {
|
||||||
model.status = response['status'];
|
model.status = response['status'];
|
||||||
transactionController.updateReceiptData(response);
|
transactionController.updateReceiptData(response);
|
||||||
|
model.isCancelled = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -145,6 +136,5 @@ class ConfirmController extends ChangeNotifier {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
// TODO: implement dispose
|
||||||
super.dispose();
|
super.dispose();
|
||||||
model.isCancelled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:qpay/models/responsive_policy.dart';
|
import 'package:qpay/models/responsive_policy.dart';
|
||||||
@@ -59,6 +60,36 @@ class _ConfirmScreenState extends State<ConfirmScreen>
|
|||||||
super.dispose();
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -384,9 +415,7 @@ class _ConfirmScreenState extends State<ConfirmScreen>
|
|||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (controller.model.isLoading) return;
|
_handlePayment();
|
||||||
|
|
||||||
await controller.doTransaction();
|
|
||||||
},
|
},
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Container(
|
leading: Container(
|
||||||
|
|||||||
@@ -62,17 +62,18 @@ class GatewayController extends ChangeNotifier {
|
|||||||
model.status = response['status'];
|
model.status = response['status'];
|
||||||
transactionController.model.paymentStatus = response['paymentStatus'];
|
transactionController.model.paymentStatus = response['paymentStatus'];
|
||||||
|
|
||||||
|
finishLoading();
|
||||||
if(model.status == 'SUCCESS') {
|
if(model.status == 'SUCCESS') {
|
||||||
transactionController.updateReceiptData(response);
|
transactionController.updateReceiptData(response);
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
finishLoading();
|
||||||
logger.e(e);
|
logger.e(e);
|
||||||
_showErrorSnackBar(
|
_showErrorSnackBar(
|
||||||
"Network error. Please try again or contact support",
|
"Network error. Please try again or contact support",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
finishLoading();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> pollTransaction(String uid) async {
|
Future<void> pollTransaction(String uid) async {
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class _PollScreenState extends State<PollScreen> {
|
|||||||
child: OutlinedButton(
|
child: OutlinedButton(
|
||||||
child: Text('Retry'),
|
child: Text('Retry'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
controller.model.isCancelled = false;
|
||||||
controller.pollTransaction(transactionController.model.confirmationData['id']);
|
controller.pollTransaction(transactionController.model.confirmationData['id']);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -33,10 +33,10 @@
|
|||||||
|
|
||||||
<title>Velocity</title>
|
<title>Velocity</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
<script src="https://na.gateway.mastercard.com/static/checkout/checkout.min.js">
|
<!-- <script src="https://na.gateway.mastercard.com/static/checkout/checkout.min.js">-->
|
||||||
</script>
|
|
||||||
<!-- <script src="https://test-gateway.mastercard.com/static/checkout/checkout.min.js">-->
|
|
||||||
<!-- </script>-->
|
<!-- </script>-->
|
||||||
|
<script src="https://test-gateway.mastercard.com/static/checkout/checkout.min.js">
|
||||||
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function configure(sessionID) {
|
function configure(sessionID) {
|
||||||
|
|||||||
Reference in New Issue
Block a user