6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit c6feb1e4
Changed files
comwell_key_app/assets/translations/da-DK.json | 2 +- comwell_key_app/assets/translations/en-US.json | 2 +- .../lib/check_out/bloc/check_out_cubit.dart | 47 ++++++++------------ .../lib/check_out/bloc/check_out_state.dart | 26 ++++++----- comwell_key_app/lib/check_out/check_out_flow.dart | 50 +++++++++++++--------- .../models/checkout_processing_state.dart | 23 ---------- .../check_out/pages/check_out_processing_page.dart | 15 +++---- comwell_key_app/lib/comwell_app.dart | 28 +++++++----- .../lib/my_booking/cubit/my_booking_cubit.dart | 6 ++- .../my_booking/pages/my_booking_payment_page.dart | 6 ++- comwell_key_app/lib/routing/app_router.dart | 31 ++++++++++++-- comwell_key_app/lib/routing/app_routes.dart | 3 ++ 12 files changed, 129 insertions(+), 110 deletions(-)
Diff
diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index 3303af4a..c25700f4 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -329,5 +329,5 @@
"remove": "Fjern",
"up_sales_processing_error_title": "Kunne ikke tilføje tilkøb",
"pay_bill": "Betal regning",
- "discount": "Rabat"
+ "discount": "Comwell Club Point Rabat"
}
\ No newline at end of file
diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index 743ae9fb..96de89d1 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -332,5 +332,5 @@
"remove": "Remove",
"up_sales_processing_error_title": "Failed to add addons",
"pay_bill": "Pay bill",
- "discount": "Discount"
+ "discount": "Comwell Club Points Discount"
}
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 51ab6d35..e0a68dcd 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
@@ -2,7 +2,7 @@ import 'package:adyen_checkout/adyen_checkout.dart';
import 'package:bloc/bloc.dart';
import 'package:comwell_key_app/check_out/bloc/check_out_state.dart';
import 'package:comwell_key_app/check_out/check_out_repository.dart';
-import 'package:comwell_key_app/check_out/models/checkout_processing_state.dart';
+import 'package:comwell_key_app/payment/cubit/payment_processing_state.dart';
import 'package:comwell_key_app/check_out/pages/check_out_page.dart';
import 'package:comwell_key_app/check_out/utils/constants.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
@@ -10,6 +10,7 @@ import 'package:comwell_key_app/pregistration/pregistration_repository.dart';
import 'package:comwell_key_app/profile/profile_repository.dart';
import 'package:comwell_key_app/profile/utils/urls.dart';
import 'package:comwell_key_app/services/models/booking_dto.dart';
+import 'package:comwell_key_app/payment/cubit/payment_cubit.dart';
import 'package:comwell_key_app/tracking/comwell_tracking.dart';
import 'package:comwell_key_app/tracking/models/analytics_event_item.dart';
import 'package:comwell_key_app/utils/locator.dart';
@@ -25,11 +26,13 @@ class CheckoutCubit extends Cubit<CheckoutState> {
final pageController = PageController();
bool _isAnimating = false;
late Booking booking;
+ final PaymentCubit paymentServicesCubit;
CheckoutPage get currentPage =>
CheckoutPage.fromIndex(pageController.page?.toInt() ?? 0);
- CheckoutCubit(this.booking, this.checkOutRepository)
+ CheckoutCubit(
+ this.booking, this.checkOutRepository, this.paymentServicesCubit)
: super(CheckoutState.initial(booking.balance ?? 0));
void init() async {
@@ -38,8 +41,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
//emit(state.clubPointsFetched(user.points));
setItems(booking.addOnItems ?? []);
} catch (e) {
- emit(state.processingStateUpdated(
- CheckoutProcessingStateError(message: "Error fetching club points")));
+ emit(state.checkoutError());
}
}
@@ -68,18 +70,17 @@ class CheckoutCubit extends Cubit<CheckoutState> {
price: booking.balance?.toInt() ?? 0,
quantity: 1);
_tracking.trackBeginCheckout(analyticsEventItem);
- emit(state.processingStateUpdated(CheckoutProcessingStateProcessing()));
- await createSession();
+ try {
+ await paymentServicesCubit.createSession();
+ } catch (e) {
+ emit(state.checkoutError());
+ }
}
Future<void> processCheckoutWithoutPaying() async {
- emit(state.processingStateUpdated(CheckoutProcessingStateProcessing()));
try {
await checkOutRepository.checkOut(booking.confirmationId);
- emit(state.processingStateUpdated(CheckoutProcessingStateConfirmed()));
} catch (e) {
- emit(state.processingStateUpdated(
- CheckoutProcessingStateError(message: e.toString())));
await Future<void>.delayed(const Duration(milliseconds: 1000));
}
}
@@ -150,21 +151,19 @@ class CheckoutCubit extends Cubit<CheckoutState> {
Future<void> checkOut() async {
try {
- if (state.processingState is CheckoutProcessingStateConfirmed) {
+ if (state.processingState is PaymentProcessingStateConfirmed) {
booking =
await profileRepository.getBookingDetails(booking.confirmationId);
}
emit(state.processingStateUpdated(CheckoutProcessingStateProcessing()));
if (booking.balance == 0) {
await checkOutRepository.checkOut(booking.confirmationId);
+ emit(state.checkoutSuccess());
} else {
- emit(state.processingStateUpdated(
- CheckoutProcessingStateError(message: "Balance is not 0")));
+ emit(state.checkoutError());
}
- emit(state.processingStateUpdated(CheckoutProcessingStateConfirmed()));
} catch (e) {
- emit(state.processingStateUpdated(
- CheckoutProcessingStateError(message: "Error checking out")));
+ emit(state.checkoutError());
await Future<void>.delayed(const Duration(milliseconds: 1000));
}
}
@@ -176,7 +175,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
value: booking.balance?.toInt() ?? 0,
currency: currency,
);
-
+
final paymentConfigurations =
await preregistrationRepository.sessionCheckout(
amount, booking.confirmationId, state.applyClubPoints);
@@ -190,8 +189,6 @@ class CheckoutCubit extends Cubit<CheckoutState> {
}
} catch (e) {
- emit(state.processingStateUpdated(
- CheckoutProcessingStateError(message: "Error creating session")));
await Future<void>.delayed(const Duration(milliseconds: 1000));
}
}
@@ -200,9 +197,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
switch (result) {
case PaymentAdvancedFinished():
case PaymentSessionFinished():
- emit(state
- .processingStateUpdated(CheckoutProcessingPaymentStateSuccess()));
- emit(state.processingStateUpdated(CheckoutProcessingStateConfirmed()));
+
//This is here to add time so that the payment is represented in the BookingDetails
await Future<void>.delayed(const Duration(milliseconds: 2000));
await checkOut();
@@ -210,21 +205,13 @@ class CheckoutCubit extends Cubit<CheckoutState> {
break;
case PaymentCancelledByUser():
case PaymentError():
- emit(state.processingStateUpdated(
- CheckoutProcessingStateError(message: "Error processing payment")));
}
}
- void onUserDismissPaymentPopup() {
- emit(state.processingStateUpdated(CheckoutProcessingStateNotStarted()));
- }
-
void showTermsAndConditions() {
launchUrl(Uri.parse(ComwellUrls.termsAndConditions));
}
-
-
//Removes the decimal point from the balance if it is .0
int get trimmedBalance {
final balance = booking.balance;
diff --git a/comwell_key_app/lib/check_out/bloc/check_out_state.dart b/comwell_key_app/lib/check_out/bloc/check_out_state.dart
index 91361b75..3fe7111b 100644
--- a/comwell_key_app/lib/check_out/bloc/check_out_state.dart
+++ b/comwell_key_app/lib/check_out/bloc/check_out_state.dart
@@ -1,5 +1,5 @@
-import 'package:comwell_key_app/check_out/models/checkout_processing_state.dart';
+import 'package:comwell_key_app/payment/cubit/payment_processing_state.dart';
import 'package:comwell_key_app/check_out/models/payment_method.dart';
import 'package:comwell_key_app/services/models/booking_dto.dart';
import 'package:comwell_key_app/check_out/pages/check_out_page.dart';
@@ -11,7 +11,8 @@ class CheckoutState extends Equatable {
final bool isTermsAccepted;
final bool applyClubPoints;
final int clubPoints;
- final CheckoutProcessingState processingState;
+ final PaymentProcessingState processingState;
+ final bool successfulCheckout;
final CheckoutPage page;
final CheckoutPaymentMethod? paymentMethod;
final bool showTermsError;
@@ -50,6 +51,7 @@ class CheckoutState extends Equatable {
required this.processingState,
this.paymentMethod,
required this.bookingBalance,
+ required this.successfulCheckout,
}) : _items = items;
CheckoutState.initial(num bookingBalance)
@@ -59,9 +61,10 @@ class CheckoutState extends Equatable {
showTermsError = false,
clubPoints = 500,
paymentMethod = CheckoutPaymentMethod.creditCard,
- processingState = CheckoutProcessingStateNotStarted(),
+ processingState = PaymentProcessingStateNotStarted(),
applyClubPoints = false,
- bookingBalance = bookingBalance;
+ bookingBalance = bookingBalance,
+ successfulCheckout = false;
CheckoutState itemsUpdated(Iterable<BookingAddonItem> items) {
@@ -83,10 +86,6 @@ class CheckoutState extends Equatable {
CheckoutState paymentMethodChanged(CheckoutPaymentMethod payment) =>
_copyWith(paymentMethod: payment);
- CheckoutState processingStateUpdated(
- CheckoutProcessingState processingState) =>
- _copyWith(updateProcessingState: processingState);
-
CheckoutState pageChanged(CheckoutPage page) => _copyWith(page: page);
CheckoutState clubPointsFetched(int clubPoints) =>
@@ -94,17 +93,22 @@ class CheckoutState extends Equatable {
CheckoutState showAcceptTermsError() => _copyWith(showTermsError: true);
+ CheckoutState checkoutSuccess() => _copyWith(successfulCheckout: true);
+
+ CheckoutState checkoutError() => _copyWith(successfulCheckout: false);
+
CheckoutState _copyWith({
Iterable<BookingAddonItem>? items,
bool? termsAccepted,
bool? applyClubPoints,
- CheckoutProcessingState? updateProcessingState,
+ PaymentProcessingState? updateProcessingState,
CheckoutPage? page,
CheckoutPaymentMethod? paymentMethod,
int? clubPoints,
bool? showTermsError,
num? bookingBalance,
+ bool? successfulCheckout,
}) {
return CheckoutState(
items: items ?? _items,
@@ -115,7 +119,8 @@ class CheckoutState extends Equatable {
isTermsAccepted: termsAccepted ?? isTermsAccepted,
applyClubPoints: applyClubPoints ?? this.applyClubPoints,
paymentMethod: paymentMethod ?? this.paymentMethod,
- bookingBalance: bookingBalance ?? this.bookingBalance);
+ bookingBalance: bookingBalance ?? this.bookingBalance,
+ successfulCheckout: successfulCheckout ?? this.successfulCheckout);
}
@override
@@ -131,5 +136,6 @@ class CheckoutState extends Equatable {
totalPriceBeforeDiscount,
totalPriceAfterDiscount,
totalPrice,
+ successfulCheckout,
];
}
diff --git a/comwell_key_app/lib/check_out/check_out_flow.dart b/comwell_key_app/lib/check_out/check_out_flow.dart
index 1eb13602..a1d2e780 100644
--- a/comwell_key_app/lib/check_out/check_out_flow.dart
+++ b/comwell_key_app/lib/check_out/check_out_flow.dart
@@ -1,9 +1,10 @@
import 'package:comwell_key_app/check_out/bloc/check_out_cubit.dart';
import 'package:comwell_key_app/check_out/components/check_out_bottom_sheet.dart';
-import 'package:comwell_key_app/check_out/models/checkout_processing_state.dart';
+import 'package:comwell_key_app/payment/cubit/payment_cubit.dart';
+import 'package:comwell_key_app/payment/cubit/payment_processing_state.dart';
import 'package:comwell_key_app/check_out/pages/check_out_page.dart';
-import 'package:comwell_key_app/check_out/pages/check_out_processing_page.dart';
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
@@ -14,24 +15,33 @@ class CheckOutFlow extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cubit = context.read<CheckoutCubit>();
- if (cubit.state.processingState is! CheckoutProcessingStateNotStarted) {
- return const CheckOutProcessingPage();
- }
- return Scaffold(
- appBar: ComwellAppBar(
- shouldShowProfileButton: false,
- onBackPressed: () {
- final didScroll = cubit.onBackPressed();
- if (!didScroll) context.pop();
- },
- ),
- bottomSheet: const CheckOutBottomSheet(),
- backgroundColor: Colors.white,
- body: PageView(
- controller: cubit.pageController,
- key: const PageStorageKey("check_out_flow"),
- physics: const NeverScrollableScrollPhysics(),
- children: CheckoutPage.getPages(ValueKey(cubit.state)).toList(),
+ return BlocListener<PaymentCubit, PaymentProcessingState>(
+ listener: (context, state) async {
+ if (state is PaymentProcessingStateSessionReceived) {
+ await cubit.checkOut();
+ if (cubit.state.successfulCheckout && context.mounted) {
+ context.pushNamed(AppRoutes.checkOutSuccess.name);
+ } else if (context.mounted) {
+ context.pushNamed(AppRoutes.checkOutError.name);
+ }
+ }
+ },
+ child: Scaffold(
+ appBar: ComwellAppBar(
+ shouldShowProfileButton: false,
+ onBackPressed: () {
+ final didScroll = cubit.onBackPressed();
+ if (!didScroll) context.pop();
+ },
+ ),
+ bottomSheet: const CheckOutBottomSheet(),
+ backgroundColor: Colors.white,
+ body: PageView(
+ controller: cubit.pageController,
+ key: const PageStorageKey("check_out_flow"),
+ physics: const NeverScrollableScrollPhysics(),
+ children: CheckoutPage.getPages(ValueKey(cubit.state)).toList(),
+ ),
),
);
}
diff --git a/comwell_key_app/lib/check_out/models/checkout_processing_state.dart b/comwell_key_app/lib/check_out/models/checkout_processing_state.dart
deleted file mode 100644
index 8f552073..00000000
--- a/comwell_key_app/lib/check_out/models/checkout_processing_state.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-import 'package:comwell_key_app/check_out/models/payment_configurations.dart';
-
-sealed class CheckoutProcessingState {}
-
-class CheckoutProcessingStateNotStarted extends CheckoutProcessingState {}
-
-class CheckoutProcessingStateProcessing extends CheckoutProcessingState {}
-
-class CheckoutProcessingStateSessionReceived extends CheckoutProcessingState {
- final PaymentConfigurations paymentConfigurations;
-
- CheckoutProcessingStateSessionReceived({required this.paymentConfigurations});
-}
-
-class CheckoutProcessingPaymentStateSuccess extends CheckoutProcessingState {}
-
-class CheckoutProcessingStateConfirmed extends CheckoutProcessingState {}
-
-class CheckoutProcessingStateError extends CheckoutProcessingState {
- final String message;
-
- CheckoutProcessingStateError({required this.message});
-}
diff --git a/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart b/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
index 7a5c7fe1..b8057d6f 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
@@ -1,6 +1,6 @@
import 'package:adyen_checkout/adyen_checkout.dart';
import 'package:comwell_key_app/check_out/bloc/check_out_cubit.dart';
-import 'package:comwell_key_app/check_out/models/checkout_processing_state.dart';
+import 'package:comwell_key_app/payment/cubit/payment_processing_state.dart';
import 'package:comwell_key_app/check_out/pages/check_out_error_page.dart';
import 'package:comwell_key_app/check_out/pages/check_out_success_page.dart';
import 'package:comwell_key_app/themes/dark_theme.dart';
@@ -70,7 +70,7 @@ class _CheckOutProcessingPageState extends State<CheckOutProcessingPage>
final cubit = context.read<CheckoutCubit>();
final processingState = cubit.state.processingState;
dynamic response;
- if (processingState is! CheckoutProcessingStateSessionReceived) return;
+ if (processingState is! PaymentProcessingStateSessionReceived) return;
final paymentConfig = processingState.paymentConfigurations;
if (!mounted) return;
@@ -84,7 +84,6 @@ class _CheckOutProcessingPageState extends State<CheckOutProcessingPage>
if (response is PaymentResult) {
cubit.onPaymentResult(response);
} else {
- cubit.onUserDismissPaymentPopup();
}
}
@@ -97,12 +96,12 @@ class _CheckOutProcessingPageState extends State<CheckOutProcessingPage>
color: sandColor[80],
child: Builder(builder: (context) {
final processingState = cubit.state.processingState;
- if (processingState is CheckoutProcessingStateConfirmed) {
+ if (processingState is PaymentProcessingStateConfirmed) {
return const CheckOutSuccessPage();
- } else if (processingState is CheckoutProcessingStateError) {
+ } else if (processingState is PaymentProcessingStateError) {
return const CheckOutErrorPage();
} else if (processingState
- is CheckoutProcessingStateSessionReceived) {
+ is PaymentProcessingStateSessionReceived) {
showAdyenModal(context);
}
return Lottie.asset(
@@ -113,9 +112,9 @@ class _CheckOutProcessingPageState extends State<CheckOutProcessingPage>
loadingComposition = composition;
animationController.duration = composition.duration;
switch (cubit.state.processingState) {
- case CheckoutProcessingStateConfirmed _:
+ case PaymentProcessingStateConfirmed _:
playSuccess();
- case CheckoutProcessingStateError _:
+ case PaymentProcessingStateError _:
playError();
default:
playLoading();
diff --git a/comwell_key_app/lib/comwell_app.dart b/comwell_key_app/lib/comwell_app.dart
index 914ceae8..8f7e09d8 100644
--- a/comwell_key_app/lib/comwell_app.dart
+++ b/comwell_key_app/lib/comwell_app.dart
@@ -4,11 +4,13 @@ import 'package:comwell_key_app/key/bloc/key_bloc.dart';
import 'package:comwell_key_app/key/repository/key_repository.dart';
import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
import 'package:comwell_key_app/overview/repository/overview_repository.dart';
+import 'package:comwell_key_app/pregistration/pregistration_repository.dart';
import 'package:comwell_key_app/profile/cubit/profile_cubit.dart';
import 'package:comwell_key_app/profile/profile_repository.dart';
import 'package:comwell_key_app/profile_settings/cubit/profile_settings_cubit.dart';
import 'package:comwell_key_app/profile_settings/repostiory/profile_settings_repository.dart';
import 'package:comwell_key_app/routing/app_router.dart';
+import 'package:comwell_key_app/payment/cubit/payment_cubit.dart';
import 'package:comwell_key_app/themes/dark_theme.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:comwell_key_app/utils/locator.dart';
@@ -19,21 +21,20 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class ComwellApp extends StatelessWidget {
-
const ComwellApp({super.key});
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: blocProviderList,
- child: MaterialApp.router(
- title: 'Comwell Key App',
- routerConfig: goRouter(),
- localizationsDelegates: context.localizationDelegates,
- supportedLocales: context.supportedLocales,
- locale: context.locale,
- theme: lightTheme,
- darkTheme: darkTheme,
+ child: MaterialApp.router(
+ title: 'Comwell Key App',
+ routerConfig: goRouter(),
+ localizationsDelegates: context.localizationDelegates,
+ supportedLocales: context.supportedLocales,
+ locale: context.locale,
+ theme: lightTheme,
+ darkTheme: darkTheme,
themeMode: ThemeMode.system,
),
);
@@ -55,8 +56,9 @@ final List<BlocProvider> blocProviderList = [
),
BlocProvider<ProfileCubit>(
lazy: false,
- create: (BuildContext context) =>
- ProfileCubit(profileRepository: locator<ProfileRepository>(), authenticationRepository: locator<AuthenticationRepository>()),
+ create: (BuildContext context) => ProfileCubit(
+ profileRepository: locator<ProfileRepository>(),
+ authenticationRepository: locator<AuthenticationRepository>()),
),
BlocProvider<ProfileSettingsCubit>(
lazy: false,
@@ -65,4 +67,8 @@ final List<BlocProvider> blocProviderList = [
profileSettingsRepository: locator<ProfileSettingsRepository>(),
authenticationRepository: locator<AuthenticationRepository>()),
),
+ BlocProvider<PaymentCubit>(
+ lazy: false,
+ create: (context) => PaymentCubit(
+ preregistrationRepository: locator<PreregistrationRepository>()))
];
diff --git a/comwell_key_app/lib/my_booking/cubit/my_booking_cubit.dart b/comwell_key_app/lib/my_booking/cubit/my_booking_cubit.dart
index adc1280d..48210a5a 100644
--- a/comwell_key_app/lib/my_booking/cubit/my_booking_cubit.dart
+++ b/comwell_key_app/lib/my_booking/cubit/my_booking_cubit.dart
@@ -1,3 +1,4 @@
+import 'package:adyen_checkout/adyen_checkout.dart';
import 'package:comwell_key_app/my_booking/cubit/my_booking_state.dart';
import 'package:comwell_key_app/my_booking/my_booking_repository.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
@@ -31,7 +32,7 @@ class MyBookingCubit extends Cubit<MyBookingState> {
// final user = await profileRepository.fetchProfileSettings();
// emit(state.clubPointsFetched(user.points));
} catch (e) {
- emit(state.copyWith(error: e as Error));
+ // emit(state.copyWith(error: e));
}
}
@@ -40,7 +41,7 @@ class MyBookingCubit extends Cubit<MyBookingState> {
0;
bool get canContinueToPayment =>
- booking.balance != 0 || (booking.addOnItems?.isNotEmpty ?? false);
+ booking.balance != 0 || (state.items.isNotEmpty);
void onAcceptTermsChanged(bool value) {
if (value) {
@@ -61,4 +62,5 @@ class MyBookingCubit extends Cubit<MyBookingState> {
void showTermsAndConditions() {
launchUrl(Uri.parse(ComwellUrls.termsAndConditions));
}
+
}
diff --git a/comwell_key_app/lib/my_booking/pages/my_booking_payment_page.dart b/comwell_key_app/lib/my_booking/pages/my_booking_payment_page.dart
index ad2def50..08e766b8 100644
--- a/comwell_key_app/lib/my_booking/pages/my_booking_payment_page.dart
+++ b/comwell_key_app/lib/my_booking/pages/my_booking_payment_page.dart
@@ -2,10 +2,12 @@ import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
import 'package:comwell_key_app/common/template_pages/payment_page_template.dart';
import 'package:comwell_key_app/my_booking/cubit/my_booking_cubit.dart';
import 'package:comwell_key_app/my_booking/cubit/my_booking_state.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
class MyBookingPaymentPage extends StatelessWidget {
const MyBookingPaymentPage({super.key});
@@ -49,7 +51,9 @@ class MyBookingPaymentPage extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 24.0, top: 16.0),
child: ElevatedButton(
- onPressed: () {},
+ onPressed: () {
+ context.pushNamed(AppRoutes.paymentProcessing.name);
+ },
child: Text("pay_bill".tr(),
style: theme.textTheme.bodyMedium
?.copyWith(color: Colors.white)),
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 37b4f89f..c4e10467 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -6,6 +6,8 @@ import 'package:comwell_key_app/check_out/bloc/check_out_cubit.dart';
import 'package:comwell_key_app/check_out/bloc/check_out_state.dart';
import 'package:comwell_key_app/check_out/check_out_flow.dart';
import 'package:comwell_key_app/check_out/check_out_repository.dart';
+import 'package:comwell_key_app/check_out/pages/check_out_error_page.dart';
+import 'package:comwell_key_app/check_out/pages/check_out_success_page.dart';
import 'package:comwell_key_app/choose_share_room/choose_share_room_page.dart';
import 'package:comwell_key_app/choose_share_room/choose_share_room_repository.dart';
import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_cubit.dart';
@@ -38,9 +40,11 @@ import 'package:comwell_key_app/overview/overview_page.dart';
import 'package:comwell_key_app/overview/past_cancelled_booking_detail_page.dart';
import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
import 'package:comwell_key_app/overview/repository/overview_repository.dart';
+import 'package:comwell_key_app/payment/payment_processing_page.dart';
import 'package:comwell_key_app/payment_cards/bloc/payment_cards_cubit.dart';
import 'package:comwell_key_app/payment_cards/payment_cards_page.dart';
import 'package:comwell_key_app/pregistration/cubit/preregistration_cubit.dart';
+import 'package:comwell_key_app/pregistration/pregistration_repository.dart';
import 'package:comwell_key_app/pregistration/preregistration_flow.dart';
import 'package:comwell_key_app/profile/cubit/profile_cubit.dart';
import 'package:comwell_key_app/profile/profile_page.dart';
@@ -52,6 +56,7 @@ import 'package:comwell_key_app/profile_settings/repostiory/profile_settings_rep
import 'package:comwell_key_app/redeem_debug/redeem_page.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/routing/go_router_observer.dart';
+import 'package:comwell_key_app/payment/cubit/payment_cubit.dart';
import 'package:comwell_key_app/share/cubit/share_booking_cubit.dart';
import 'package:comwell_key_app/share/share_booking_page.dart';
import 'package:comwell_key_app/up_sales/cubit/up_sales_cubit.dart';
@@ -368,15 +373,25 @@ GoRouter goRouter() {
builder: (context, state) {
final booking = state.extra as Booking;
return BlocProvider(
- create: (context) =>
- CheckoutCubit(booking, locator<CheckOutRepository>())
- ..init(),
+ create: (context) => CheckoutCubit(booking,
+ locator<CheckOutRepository>(), context.read<PaymentCubit>())
+ ..init(),
child: BlocBuilder<CheckoutCubit, CheckoutState>(
builder: (context, state) {
return CheckOutFlow(key: ValueKey(state));
}));
},
),
+ GoRoute(
+ path: "/${AppRoutes.paymentProcessing.name}",
+ name: AppRoutes.paymentProcessing.name,
+ builder: (context, state) => BlocProvider(
+ create: (context) => PaymentCubit(
+ preregistrationRepository:
+ locator<PreregistrationRepository>()),
+ child: const PaymentProcessingPage(),
+ ),
+ ),
GoRoute(
path: "/${AppRoutes.notifications.name}",
name: AppRoutes.notifications.name,
@@ -391,6 +406,16 @@ GoRouter goRouter() {
);
},
),
+ GoRoute(
+ path: "/${AppRoutes.checkOutSuccess.name}",
+ name: AppRoutes.checkOutSuccess.name,
+ builder: (context, state) => const CheckOutSuccessPage(),
+ ),
+ GoRoute(
+ path: "/${AppRoutes.checkOutError.name}",
+ name: AppRoutes.checkOutError.name,
+ builder: (context, state) => const CheckOutErrorPage(),
+ ),
ShellRoute(
pageBuilder: (context, state, child) {
return CustomTransitionPage<void>(
diff --git a/comwell_key_app/lib/routing/app_routes.dart b/comwell_key_app/lib/routing/app_routes.dart
index c708dc89..701126da 100644
--- a/comwell_key_app/lib/routing/app_routes.dart
+++ b/comwell_key_app/lib/routing/app_routes.dart
@@ -38,4 +38,7 @@ enum AppRoutes {
forceUpdate,
upSalesError,
payMyBooking,
+ paymentProcessing,
+ checkOutSuccess,
+ checkOutError,
}