getPaymentDetails method

Future getPaymentDetails(
  1. dynamic paymentID
)

Implementation

Future getPaymentDetails(paymentID) async {
  try {
    final ServiceController _serviceController = Get.find();

    dynamic response;

    response = await http.get(
      Uri.parse('${Util.END_POINT}/payments/checkout/$paymentID'),
      headers: <String, String>{
        'Content-Type': 'application/json; charset=UTF-8',
        'Authorization':
            'Bearer ${GlobalizerController.paymentConfig!.publicKey}',
      },
    );
    //set the statusCode inside of the controller.
    _serviceController.getPaymentDetailsStatusCode = response.statusCode;

    //Handling Status codes Error Via Snackbar
    if (response.statusCode == 201 || response.statusCode == 200) {
      return jsonDecode(response.body);
    } else if (response.statusCode == 401) {
      //Bad Public key
      debugPrint("Your public key is not authorized");
      return jsonDecode(response.body);
    } else if (response.statusCode == 404) {
      debugPrint("getPaymentDetails() service status: 404");

      return jsonDecode(response.body);
    } else if (response.body == "null") {
      debugPrint("getPaymentDetails() returning null from API");

      return jsonDecode(response.body);
    } else {
      return jsonDecode(response.body);
    }
  } on Exception catch (e) {
    rethrow;
  }
}