fetchPaymentStatus method
Implementation
Future<void> fetchPaymentStatus({required String token}) async {
try {
Map<String, String> headers = {
"mb-token": token,
};
String url =
"/check-payment/${_paymentProcessInfoController.value.paymentInfo.paymentInfo.id}";
_spinnerController.add(true);
final response = await getWithIntercept(url, headers: headers);
debugPrint("$response");
if (response.binStatus == EApiResponseStatusCode.bIN000) {
if (response.paymentStatus == "APPROVED") {
_paymentMessageController.add(
IResponseMessage(title: 'Yeah !', message: response.message));
_paymentScreenController.add(ELocalScreenNavigator.successScreen);
} else {
_paymentMessageController.add(
IResponseMessage(title: 'Oups !', message: response.message));
_paymentScreenController.add(ELocalScreenNavigator.errorScreen);
}
} else {
_paymentMessageController
.add(IResponseMessage(title: 'Oups !', message: response.message));
_paymentScreenController.add(ELocalScreenNavigator.errorScreen);
}
_spinnerController.add(false);
} catch (e, stack) {
_spinnerController.add(false);
debugPrint('Error during fetch operations: $e');
debugPrint('Stack trace: $stack');
_paymentMessageController.add(IResponseMessage(
title: 'Oups !',
message:
"Une erreur est survenue lors de cette opération, veuillez réessayer",
));
_paymentScreenController.add(ELocalScreenNavigator.errorScreen);
}
}