goToPayment method
Implementation
goToPayment(BookingHistory history) {
if (history.bookingStatus != BookingStatus.bookingConfirmed) {
PaymentController paymentController = Get.put(PaymentController());
paymentController.paymentType.value = PaymentType.flightBooking;
// paymentController.bookingHistory.value=history;
PaymentDetails paymentDetails = PaymentDetails(
isNonDiscounted: history.isNonDiscounted,
status: history.status ?? '',
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: userEmail,
createdAt: history.createdAt,
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,
donationAmount: double.tryParse(history.donationAmount.toString()) ?? 0,
rateConfirmedAt: history.confirmedRateAt == null ? null : DateTime.tryParse(history.confirmedRateAt!),
isStillAvailable: history.isStillAvailable,
availabilityCheckedAt: history.availabilityCheckedAt,
availabilityCheckCounter: history.availabilityCheckCounter,
approvedAt: history.approvedAt,
);
paymentController.initPayment(paymentDetails, isRateConfirmed: history.isRateConfirmed, isSaved: history.isSaved, isPaymentFailedForRateRequest: ((history.isDiscountedFlight?? false) && history.isRoundTrip && (history.bookingStatus == BookingStatus.paymentFailed)));
} else {
CustomFlashWidget.showFlashMessage(
type: FlashType.info,
title: "Warning",
message: "Booking is already Confirmed",
);
}
}