cancelPayments method

Future cancelPayments(
  1. dynamic paymentID
)

Implementation

Future cancelPayments(paymentID) async {
  try {
    dynamic response;
    response = await http.patch(
      Uri.parse('${Util.END_POINT}/payments/checkout/$paymentID/cancel'),
      headers: <String, String>{
        'Content-Type': 'application/json; charset=UTF-8',
        'Authorization':
            'Bearer ${GlobalizerController.paymentConfig!.publicKey}',
      },
    );
    if (response.statusCode == 201 || response.statusCode == 200) {
      return jsonDecode(response.body);
    } else if (response.statusCode == 401) {
      Get.snackbar('Unathorized', 'Check your Public Key and retry');
      return jsonDecode(response.body);
    } else if (response.statusCode == 404) {
      Get.snackbar('404 Error', 'Check the endpoint again');
      return jsonDecode(response.body);
    } else {
      Get.snackbar('Error', 'Something went wrong from the API Cancelling ');
      debugPrint(
          'Cant cancel payment from server : ${response.statusCode} ${response.body}');

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