onTapPay method

void onTapPay()

Implementation

void  onTapPay(){
  if(controller.paymentStatusData.value.purpose == 'SUBSCRIPTION'){
    goto(Routes.SUBSCRIPTION_PAYMENT);
  }else if(controller.paymentStatusData.value.purpose == 'SEARCH_CREDIT'){
    final searcCreditController = Get.put(SearchCreditController());
    searcCreditController.buyCreditPopup();
  }
  else{
    PaymentController paymentController = Get.put(PaymentController());
    paymentController.paymentType.value = PaymentType.flightBooking;
    // paymentController.bookingHistory.value=history;
    final history = controller.selectedBooking.value ?? BookingHistory();
    PaymentDetails paymentDetails = PaymentDetails(
        isNonDiscounted: history.isNonDiscounted,
        route: Routes.NEO_DASHBOARD,
        bookingId: history.id ?? '',
        tripType: history.tripType ?? '',
        bookingTrips: history.bookingTrips ?? [],
        totalOnlinePrice: double.tryParse(history.totalOnlinePrice ?? '0') ?? 0,
        totalDiscountedPrice: double.tryParse(history.totalDiscountedPrice ?? '0') ?? 0,
        discountPercentage: history.discountPercentage.toString(),
        totalDiscountedPriceBTC: history.totalDiscountedPriceBTC ?? 0,
        totalTax: double.tryParse(history.totalTax ?? '0') ?? 0,
        totalMilesEarned: history.milesEarned,
        totalPassengers: history.passengers?.length ?? 0,
        fromAirport: history.fromAirport,
        toAirport: history.toAirport,
        email: controller.authController.userProfileModel.value.data?.user?.email ?? 'your email address',
        adults: history.passengers?.where((e)=>e.type == 'ADULT').length ?? 0,
        children: history.passengers?.where((e)=>e.type == 'CHILD').length ?? 0,
        infantsInSeat: history.passengers?.where((e)=>e.type == 'INFANTWITHSEAT').length ?? 0,
        infantsInLap: history.passengers?.where((e)=>e.type == 'INFANT').length ?? 0,
        searchCreditEarned: history.isNonDiscounted == true ? 0 : 200,
        searchCreditUsed: history.searchCredit ?? 0,
        passengers: history.passengers,
        rateConfirmedAt: history.confirmedRateAt == null ? null : DateTime.tryParse(history.confirmedRateAt!),
        isStillAvailable: history.isStillAvailable,
        availabilityCheckedAt: history.availabilityCheckedAt,
        availabilityCheckCounter: history.availabilityCheckCounter,
        approvedAt: history.approvedAt,
        createdAt: history.createdAt,
        donationAmount: double.tryParse(history.donationAmount.toString()) ?? 0);


    paymentController.initPayment(paymentDetails);
  }
}