getPaymentStatus method
dynamic
getPaymentStatus({})
Implementation
getPaymentStatus({
required context,
required String transactionId,
required String merchandUserName,
required String merchandPassword,
required String providerShortTag,
required Function actionAfterProccess,
required String xApiKey,
required String mode,
}) async {
try {
const time = const Duration(seconds: 4);
Timer.periodic(time, (Timer timer) async {
var jsonResponse;
var url = Uri.parse("${constant.baseUrl}/gateway/paymentstatus/$transactionId");
log(url.toString());
var response =
await http.get(url, headers: getGlobalHeader(xApiKey, "$merchandUserName:$merchandPassword", mode));
print("This is response status/; ${response.statusCode}");
print("This is response Mode/; $mode");
jsonResponse = await jsonDecode(response.body);
print("This is response status/; $jsonResponse");
if (jsonResponse['status'] == "SUCCESS") {
print("Response SUCCESSFUL: $jsonResponse");
Navigator.pop(context);
actionAfterProccess(transactionId, "SUCCESS");
timer.cancel();
}
if (jsonResponse['status'] == "FAILED") {
Navigator.pop(context);
print("Response FAILED: $jsonResponse");
actionAfterProccess(transactionId, "FAILED");
timer.cancel();
}
});
} catch (e) {
// Navigator.pop(context);
actionAfterProccess(transactionId, "FAILED");
showInfoDialog(context, "Something went wrong , please try again or later");
}
}