6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit f7bee4cf
Changed files
.../booking_details/bloc/booking_details_bloc.dart | 2 +- .../lib/booking_details/booking_details_page.dart | 1 - .../lib/check_out/bloc/check_out_cubit.dart | 20 ++++++++++++++------ .../lib/check_out/check_out_repository.dart | 9 ++++++++- .../check_out/components/checkout_itemized_bill.dart | 2 +- .../lib/check_out/models/payment_configurations.dart | 5 +++++ 6 files changed, 29 insertions(+), 10 deletions(-)
Diff
diff --git a/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart b/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
index 4613f322..c205a9a9 100644
--- a/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
+++ b/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
@@ -40,7 +40,6 @@ class BookingDetailsBloc
on<InitialEvent>((event, emit) async {
try {
emit(state.loading());
- print("qqq booking=${booking}");
_startTimer();
add(CheckIfHouseKeepingOrdered());
add(CheckMobileKeys());
@@ -97,6 +96,7 @@ class BookingDetailsBloc
final bookingDetails =
await profileRepository.getBookingDetails(bookingId);
booking = bookingDetails;
+
emit(state.copyWith(status: BookingDetailsStatus.main, isLoading: false));
return bookingDetails;
} catch (e) {
diff --git a/comwell_key_app/lib/booking_details/booking_details_page.dart b/comwell_key_app/lib/booking_details/booking_details_page.dart
index 27a44b93..0d0b0b55 100644
--- a/comwell_key_app/lib/booking_details/booking_details_page.dart
+++ b/comwell_key_app/lib/booking_details/booking_details_page.dart
@@ -53,7 +53,6 @@ class BookingDetailsPage extends StatelessWidget {
Widget _buildBookingDetailsPage(BuildContext context,
BookingDetailsState state, BookingDetailsBloc cubit) {
final theme = Theme.of(context);
-
return Stack(
children: [
Container(
diff --git a/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart b/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
index d9a129e5..c5a0758d 100644
--- a/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
+++ b/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
@@ -36,7 +36,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
try {
final user = await profileRepository.fetchProfileSettings();
emit(state.clubPointsFetched(user.points));
- setItems([...state.items, CheckoutItem("Körv", 500)]);
+ //setItems([...state.items, CheckoutItem("Körv", 500)]);
} catch (e) {
// Todo handle error
@@ -71,11 +71,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
_tracking.trackBeginCheckout(analyticsEventItem);
emit(state.processingStateUpdated(CheckoutProcessingStateProcessing()));
createSession();
- try {
- await checkOutRepository.checkOut(booking.confirmationId);
- } catch (e) {
- emit(state.processingStateUpdated(CheckoutProcessingStateError()));
- }
+ checkOut();
}
void onContinueClicked() {
@@ -135,17 +131,29 @@ class CheckoutCubit extends Cubit<CheckoutState> {
}
}
+ Future<void> checkOut() async {
+ try {
+ emit(state.processingStateUpdated(CheckoutProcessingStateProcessing()));
+ await checkOutRepository.checkOut(booking.confirmationId);
+ } catch (e) {
+ emit(state.processingStateUpdated(CheckoutProcessingStateError()));
+ }
+ }
+
void createSession() async {
try {
final bookingPrice = booking.balance?.toInt();
+ print("bookingPrice: $bookingPrice");
+
final amount = Amount(
value: bookingPrice!,
currency: currency,
);
final paymentConfigurations = await preregistrationRepository
.sessionCheckout(amount, booking.confirmationId);
+ print("paymentConfigurations: ${paymentConfigurations}");
emit(state.processingStateUpdated(CheckoutProcessingStateSessionReceived(
paymentConfigurations: paymentConfigurations)));
} catch (e) {
diff --git a/comwell_key_app/lib/check_out/check_out_repository.dart b/comwell_key_app/lib/check_out/check_out_repository.dart
index edad6d0a..9c14183b 100644
--- a/comwell_key_app/lib/check_out/check_out_repository.dart
+++ b/comwell_key_app/lib/check_out/check_out_repository.dart
@@ -7,6 +7,13 @@ class CheckOutRepository {
CheckOutRepository();
Future<Json?> checkOut(String confirmationId) async {
- return await _api.checkOut(confirmationId);
+ final response = await _api.checkOut(confirmationId);
+
+ if (response?["status"] == "success") {
+ return response;
+ } else {
+ print("here in exception: ${response?["message"]}");
+ throw Exception(response?["message"]);
+ }
}
}
\ No newline at end of file
diff --git a/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart b/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
index 9eecbd81..71f4785a 100644
--- a/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
+++ b/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
@@ -34,7 +34,7 @@ class CheckoutItemizedBill extends StatelessWidget {
Row(
children: [
Text(
- cubit.state.totalPriceBeforeDiscount.toString(),
+ "${cubit.state.totalPriceBeforeDiscount.toInt()}",
style: const TextStyle(
decoration: TextDecoration.lineThrough,
decorationColor: colorDivider,
diff --git a/comwell_key_app/lib/check_out/models/payment_configurations.dart b/comwell_key_app/lib/check_out/models/payment_configurations.dart
index 6df9a6aa..27318571 100644
--- a/comwell_key_app/lib/check_out/models/payment_configurations.dart
+++ b/comwell_key_app/lib/check_out/models/payment_configurations.dart
@@ -14,4 +14,9 @@ class PaymentConfigurations {
required this.dropInConfiguration,
required this.applePayConfiguration,
});
+
+ @override
+ String toString() {
+ return 'PaymentConfigurations(sessionCheckout: $sessionCheckout, googlePayConfiguration: $googlePayConfiguration, dropInConfiguration: $dropInConfiguration, cardComponentConfiguration: $cardComponentConfiguration, applePayConfiguration: $applePayConfiguration)';
+ }
}