approveRateRequest method

Future<void> approveRateRequest()

Implementation

Future <void> approveRateRequest() async {
  if (savedDonation.value == 0) {
      final res = await ClubImpactDialog.show();
      if (res == 1) {
        // if (goToDonation != null) {
        //   goToDonation();
        // }
        return;
      } else if (res != 2) {
        return;
      }
    }
    try{
        var data = {
      'donationAmount': savedDonation.value
      };
      var response = await Requests.getDio().patch(
          data: data,
          "booking/v4/${paymentDetails.value.bookingId}/approve-rate",
      );
      if(response.statusCode == 200){
        paymentDetails.value  =  paymentDetails.value.copyWith(
          approvedAt: FlightSearchUtils.getTimeinUnixTimeStampInSecond(),
        );
        await storePayment();
        redirect(Routes.CHOOSE_PAYMENT);
      }else{
        allowPayment.value = false;
        CustomFlashWidget.showFlashMessage(
          type: FlashType.error,
          title: "Failed",
          message: response.data['message']  ?? "Something unexcepted happened, please try again",
        );
      }
    }
    catch(e){
      allowPayment.value = false;
      debugPrint("### Approval Error $e");
      CustomFlashWidget.showFlashMessage(
          type: FlashType.error,
          title: "Failed",
          message: "Something unexcepted happened, please try again",
        );
    }
  }