getExchangeEstimate method

Future<void> getExchangeEstimate()

Implementation

Future<void> getExchangeEstimate() async {
  try {
    var price = '';

    if (isFlightBooking) {
      final total =
          paymentDetails.value.totalSpendAmount + (paymentDetails.value.donationAmount ?? 0);
      if (selectedPaymentMethod.value == PaymentMethod.cardPayment) {
        price = (total * ((fee / 100)) + 1).text;
      } else {
        price = total.text;
      }
    }

    if (isSearchCredit) {
      price = creditPackage.value!.price.text;
    }

    if (isMembership) {
      price = subscriptionTotalPrice().toDouble().text;
    }

    var response = await Requests.getDio().get(
      "payments/crypto/exchange-estimate?currency=${selectedCryptoCurrency.value.ticker}&network=${selectedCryptoCurrency.value.network}&amount=$price",
    );
    print(response.toString());
    if (response.statusCode == 200) {
      await verifyPayment();
    } else {
      CustomFlashWidget.showFlashMessage(
        type: FlashType.error,
        title: "Error",
        message: response.data['message'],
      );
    }
  } catch (e) {
    print("exchang error ${e.toString()}");
    CustomFlashWidget.showFlashMessage(
      type: FlashType.error,
      title: "Error",
      message: 'Something unexpected happened. Please try again later!',
    );
  }
}