6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit bb77699d
Changed files
.../components/check_out_button.dart | 8 +- .../lib/check_out/bloc/check_out_cubit.dart | 36 +++---- comwell_key_app/lib/check_out/check_out_flow.dart | 6 +- .../components/check_out_bottom_sheet.dart | 12 ++- .../lib/check_out/pages/check_out_error_page.dart | 101 ++++++++++--------- .../check_out/pages/check_out_processing_page.dart | 2 +- .../check_out/pages/check_out_success_page.dart | 112 +++++++++++---------- .../lib/payment/cubit/payment_cubit.dart | 32 +++--- .../lib/payment/payment_processing_page.dart | 53 +++++----- .../payment_cards/bloc/payment_cards_cubit.dart | 7 +- .../lib/payment_cards/components/add_card.dart | 7 +- .../pregistration/pregistration_repository.dart | 9 +- comwell_key_app/lib/routing/app_router.dart | 12 +-- 13 files changed, 207 insertions(+), 190 deletions(-)
Diff
diff --git a/comwell_key_app/lib/booking_details/components/check_out_button.dart b/comwell_key_app/lib/booking_details/components/check_out_button.dart
index 8a2a199d..c8f362e2 100644
--- a/comwell_key_app/lib/booking_details/components/check_out_button.dart
+++ b/comwell_key_app/lib/booking_details/components/check_out_button.dart
@@ -24,11 +24,9 @@ class CheckOutButton extends StatelessWidget {
child: InkWell(
borderRadius: const BorderRadius.all(Radius.circular(15)),
onTap: () async {
-
- final result = await context.pushNamed(AppRoutes.checkOut.name, extra: cubit.booking);
- if (result == true) {
- cubit.add(InitialEvent());
- }
+ await context.pushNamed(AppRoutes.checkOut.name,
+ extra: cubit.booking);
+ cubit.add(InitialEvent());
},
child: Padding(
padding: const EdgeInsets.all(16.0),
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 e0a68dcd..4eb142ba 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
@@ -9,12 +9,14 @@ import 'package:comwell_key_app/overview/models/booking.dart';
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/routing/app_routes.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';
import 'package:flutter/material.dart';
+import 'package:go_router/go_router.dart';
import 'package:url_launcher/url_launcher.dart';
class CheckoutCubit extends Cubit<CheckoutState> {
@@ -57,7 +59,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
emit(state.itemsUpdated(items));
}
- Future<void> processCheckout() async {
+ Future<void> processPayment() async {
//TODO: Finish this when upsales are implemented
final analyticsEventItem = AnalyticsEventItem(
hotelName: booking.hotelName,
@@ -71,7 +73,9 @@ class CheckoutCubit extends Cubit<CheckoutState> {
quantity: 1);
_tracking.trackBeginCheckout(analyticsEventItem);
try {
- await paymentServicesCubit.createSession();
+ await paymentServicesCubit.createSession(booking.balance?.toInt() ?? 0,
+ booking.confirmationId, state.applyClubPoints);
+ await Future<void>.delayed(const Duration(milliseconds: 4000));
} catch (e) {
emit(state.checkoutError());
}
@@ -85,21 +89,21 @@ class CheckoutCubit extends Cubit<CheckoutState> {
}
}
- void onContinueClicked() {
+ void onContinueClicked(BuildContext context) {
if (_isAnimating) return;
_isAnimating = true;
switch (currentPage) {
case CheckoutPage.confirmation:
if (booking.balance == 0) {
- return _navigateToProcessing();
+ return _navigateToProcessing(context);
}
return _navigateTo(CheckoutPage.payment);
case CheckoutPage.payment:
- return _navigateToProcessing();
+ return _navigateToProcessing(context);
}
}
- void _navigateToProcessing() {
+ void _navigateToProcessing(BuildContext context) {
_isAnimating = false;
if (!state.isTermsAccepted && (booking.balance ?? 0.0) > 0.0) {
emit(state.showAcceptTermsError());
@@ -107,7 +111,8 @@ class CheckoutCubit extends Cubit<CheckoutState> {
if (booking.balance == 0) {
processCheckoutWithoutPaying();
} else {
- processCheckout();
+ context.pushNamed(AppRoutes.paymentProcessing.name);
+ processPayment();
}
}
}
@@ -151,14 +156,13 @@ class CheckoutCubit extends Cubit<CheckoutState> {
Future<void> checkOut() async {
try {
- if (state.processingState is PaymentProcessingStateConfirmed) {
- booking =
- await profileRepository.getBookingDetails(booking.confirmationId);
- }
- emit(state.processingStateUpdated(CheckoutProcessingStateProcessing()));
+ booking =
+ await profileRepository.getBookingDetails(booking.confirmationId);
+
if (booking.balance == 0) {
await checkOutRepository.checkOut(booking.confirmationId);
emit(state.checkoutSuccess());
+
} else {
emit(state.checkoutError());
}
@@ -179,15 +183,12 @@ class CheckoutCubit extends Cubit<CheckoutState> {
final paymentConfigurations =
await preregistrationRepository.sessionCheckout(
amount, booking.confirmationId, state.applyClubPoints);
- if (paymentConfigurations.isFullyPaidWithPoints) {
+ if (paymentConfigurations == null) {
checkOut();
-
} else {
await Future<void>.delayed(const Duration(milliseconds: 4000));
- emit(state.processingStateUpdated(CheckoutProcessingStateSessionReceived(
- paymentConfigurations: paymentConfigurations)));
+ emit(state.checkoutSuccess());
}
-
} catch (e) {
await Future<void>.delayed(const Duration(milliseconds: 1000));
}
@@ -200,7 +201,6 @@ class CheckoutCubit extends Cubit<CheckoutState> {
//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();
break;
case PaymentCancelledByUser():
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 a1d2e780..b2c01640 100644
--- a/comwell_key_app/lib/check_out/check_out_flow.dart
+++ b/comwell_key_app/lib/check_out/check_out_flow.dart
@@ -17,10 +17,12 @@ class CheckOutFlow extends StatelessWidget {
final cubit = context.read<CheckoutCubit>();
return BlocListener<PaymentCubit, PaymentProcessingState>(
listener: (context, state) async {
- if (state is PaymentProcessingStateSessionReceived) {
+ if (state is PaymentProcessingStateConfirmed) {
+ //This is here to add time so that the payment is represented in the BookingDetails
+ await Future<void>.delayed(const Duration(seconds: 5));
await cubit.checkOut();
if (cubit.state.successfulCheckout && context.mounted) {
- context.pushNamed(AppRoutes.checkOutSuccess.name);
+ context.pushNamed(AppRoutes.checkOutSuccess.name, extra: cubit.booking.digitalCard);
} else if (context.mounted) {
context.pushNamed(AppRoutes.checkOutError.name);
}
diff --git a/comwell_key_app/lib/check_out/components/check_out_bottom_sheet.dart b/comwell_key_app/lib/check_out/components/check_out_bottom_sheet.dart
index e63658d0..c0288d2a 100644
--- a/comwell_key_app/lib/check_out/components/check_out_bottom_sheet.dart
+++ b/comwell_key_app/lib/check_out/components/check_out_bottom_sheet.dart
@@ -2,10 +2,12 @@ import 'dart:io';
import 'package:comwell_key_app/check_out/bloc/check_out_cubit.dart';
import 'package:comwell_key_app/check_out/models/payment_method.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';
import '../pages/check_out_page.dart';
import 'confirm_check_out_dialog.dart';
@@ -40,12 +42,12 @@ class CheckOutBottomSheet extends StatelessWidget {
context: context,
builder: (context) =>
ConfirmCheckOutDialog(onConfirm: () {
- Navigator.of(context).pop();
- cubit.onContinueClicked();
+ context.pop();
+ cubit.onContinueClicked(context);
}),
);
}
- : cubit.onContinueClicked,
+ : () => cubit.onContinueClicked(context),
style: ButtonStyle(
backgroundColor:
WidgetStatePropertyAll(sandColor[100]),
@@ -54,7 +56,7 @@ class CheckOutBottomSheet extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 17.0),
child: Text(
- cubit.booking.balance == 0
+ cubit.booking.balance == 0 || cubit.booking.balance == null
? "checkout_page_confirmation".tr()
: "checkout_page_confirmation_continue".tr(),
style: theme.textTheme.bodyMedium
@@ -69,7 +71,7 @@ class CheckOutBottomSheet extends StatelessWidget {
builder: (context) =>
ConfirmCheckOutDialog(onConfirm: () {
Navigator.of(context).pop();
- cubit.onContinueClicked();
+ cubit.onContinueClicked(context);
}),
);
},
diff --git a/comwell_key_app/lib/check_out/pages/check_out_error_page.dart b/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
index 7a62001c..433cc49c 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
@@ -1,3 +1,4 @@
+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';
@@ -8,54 +9,58 @@ class CheckOutErrorPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 40.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- const SizedBox(),
- Column(
- children: [
- Text(
- "checkout_page_processing_error_title".tr(),
- style: Theme.of(context)
- .textTheme
- .headlineMedium
- ?.copyWith(color: Colors.white),
- ),
- Text(
- "checkout_page_processing_error_subtitle".tr(),
- textAlign: TextAlign.center,
- style: Theme.of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: colorDivider))
- ],
- ),
- Row(
- children: [
- Expanded(
- child: ElevatedButton(
- onPressed: () {
- context.pop();
- },
- style: const ButtonStyle(
- backgroundColor:
- WidgetStatePropertyAll(Colors.white)),
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: Text(
- "generic_ok".tr(),
- style: const TextStyle(color: Colors.black),
- ),
- )),
- ),
- ],
- )
- ],
+ return Scaffold(
+ backgroundColor: sandColor[80],
+ body: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 40.0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ const SizedBox(),
+ Column(
+ children: [
+ Text(
+ "checkout_page_processing_error_title".tr(),
+ style: Theme.of(context)
+ .textTheme
+ .headlineMedium
+ ?.copyWith(color: Colors.white),
+ ),
+ Text("checkout_page_processing_error_subtitle".tr(),
+ textAlign: TextAlign.center,
+ style: Theme.of(context)
+ .textTheme
+ .bodySmall
+ ?.copyWith(color: colorDivider))
+ ],
+ ),
+ Row(
+ children: [
+ Expanded(
+ child: ElevatedButton(
+ onPressed: () {
+ Navigator.of(context).popUntil((route) =>
+ route.settings.name ==
+ AppRoutes.bookingDetails.name);
+ },
+ style: const ButtonStyle(
+ backgroundColor:
+ WidgetStatePropertyAll(Colors.white)),
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Text(
+ "generic_ok".tr(),
+ style: const TextStyle(color: Colors.black),
+ ),
+ )),
+ ),
+ ],
+ )
+ ],
+ ),
),
),
);
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 b8057d6f..dc48cabe 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
@@ -97,7 +97,7 @@ class _CheckOutProcessingPageState extends State<CheckOutProcessingPage>
child: Builder(builder: (context) {
final processingState = cubit.state.processingState;
if (processingState is PaymentProcessingStateConfirmed) {
- return const CheckOutSuccessPage();
+ return CheckOutSuccessPage(digitalCard: cubit.booking.digitalCard);
} else if (processingState is PaymentProcessingStateError) {
return const CheckOutErrorPage();
} else if (processingState
diff --git a/comwell_key_app/lib/check_out/pages/check_out_success_page.dart b/comwell_key_app/lib/check_out/pages/check_out_success_page.dart
index efe3b7e8..20cebcd5 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_success_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_success_page.dart
@@ -1,5 +1,7 @@
import 'package:comwell_key_app/check_out/bloc/check_out_cubit.dart';
import 'package:comwell_key_app/check_out/components/check_out_countdown.dart';
+import 'package:comwell_key_app/overview/models/booking.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';
@@ -7,64 +9,68 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
class CheckOutSuccessPage extends StatelessWidget {
- const CheckOutSuccessPage({super.key});
+ final bool digitalCard;
+ const CheckOutSuccessPage({super.key, required this.digitalCard});
@override
Widget build(BuildContext context) {
- final booking = context.read<CheckoutCubit>().booking;
-
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 40.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- const SizedBox(),
- booking.digitalCard ? const CheckOutCountdown() : const SizedBox(),
- Column(
- children: [
- Text(
- "checkout_page_processing_success_title".tr(),
- style: Theme.of(context)
- .textTheme
- .headlineMedium
- ?.copyWith(color: Colors.white),
- ),
- Text(
- booking.digitalCard
- ? "checkout_page_processing_success_subtitle".tr()
- : "checkout_page_processing_success_subtitle_no_digital_card"
- .tr(),
- textAlign: TextAlign.center,
+ return Scaffold(
+ backgroundColor: sandColor[80],
+ body: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 40.0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ const SizedBox(),
+ digitalCard ? const CheckOutCountdown() : const SizedBox(),
+ Column(
+ children: [
+ Text(
+ "checkout_page_processing_success_title".tr(),
style: Theme.of(context)
.textTheme
- .bodySmall
- ?.copyWith(color: colorDivider))
- ],
- ),
- Row(
- children: [
- Expanded(
- child: ElevatedButton(
- onPressed: () {
- context.pop(true);
- },
- style: const ButtonStyle(
- backgroundColor:
- WidgetStatePropertyAll(Colors.white)),
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: Text(
- "generic_ok".tr(),
- style: const TextStyle(color: Colors.black),
- ),
- )),
- ),
- ],
- )
- ],
+ .headlineMedium
+ ?.copyWith(color: Colors.white),
+ ),
+ Text(
+ digitalCard
+ ? "checkout_page_processing_success_subtitle".tr()
+ : "checkout_page_processing_success_subtitle_no_digital_card"
+ .tr(),
+ textAlign: TextAlign.center,
+ style: Theme.of(context)
+ .textTheme
+ .bodySmall
+ ?.copyWith(color: colorDivider))
+ ],
+ ),
+ Row(
+ children: [
+ Expanded(
+ child: ElevatedButton(
+ onPressed: () {
+ Navigator.of(context).popUntil((route) =>
+ route.settings.name ==
+ AppRoutes.bookingDetails.name);
+ },
+ style: const ButtonStyle(
+ backgroundColor:
+ WidgetStatePropertyAll(Colors.white)),
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Text(
+ "generic_ok".tr(),
+ style: const TextStyle(color: Colors.black),
+ ),
+ )),
+ ),
+ ],
+ )
+ ],
+ ),
),
),
);
diff --git a/comwell_key_app/lib/payment/cubit/payment_cubit.dart b/comwell_key_app/lib/payment/cubit/payment_cubit.dart
index 6f1570a3..ede12133 100644
--- a/comwell_key_app/lib/payment/cubit/payment_cubit.dart
+++ b/comwell_key_app/lib/payment/cubit/payment_cubit.dart
@@ -1,35 +1,33 @@
import 'package:adyen_checkout/adyen_checkout.dart';
+import 'package:comwell_key_app/check_out/utils/constants.dart';
import 'package:comwell_key_app/pregistration/pregistration_repository.dart';
import 'package:comwell_key_app/payment/cubit/payment_processing_state.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class PaymentCubit extends Cubit<PaymentProcessingState> {
- late int totalPriceAfterDiscount;
- late String currency;
- late String confirmationId;
- late bool applyClubPoints;
final PreregistrationRepository preregistrationRepository;
PaymentCubit({required this.preregistrationRepository})
: super(PaymentProcessingStateNotStarted());
- Future<void> createSession() async {
-
- emit(PaymentProcessingStateProcessing());
-
+ Future<void> createSession(int price, String confirmationId,
+ bool applyClubPoints) async {
try {
- final bookingPrice = totalPriceAfterDiscount;
final amount = Amount(
- value: bookingPrice,
+ value: price,
currency: currency,
);
+ emit(PaymentProcessingStateProcessing());
+
final paymentConfigurations = await preregistrationRepository
.sessionCheckout(amount, confirmationId, applyClubPoints);
- emit(PaymentProcessingStateSessionReceived(
- paymentConfigurations: paymentConfigurations));
- await Future<void>.delayed(const Duration(milliseconds: 4000));
- emit(PaymentProcessingPaymentStateSuccess());
+ if (paymentConfigurations == null) {
+ emit(PaymentProcessingStateConfirmed());
+ } else {
+ emit(PaymentProcessingStateSessionReceived(
+ paymentConfigurations: paymentConfigurations));
+ }
} catch (e) {
emit(PaymentProcessingStateError(message: "Error creating session"));
await Future<void>.delayed(const Duration(milliseconds: 1000));
@@ -40,10 +38,7 @@ class PaymentCubit extends Cubit<PaymentProcessingState> {
switch (result) {
case PaymentAdvancedFinished():
case PaymentSessionFinished():
- emit(PaymentProcessingPaymentStateSuccess());
emit(PaymentProcessingStateConfirmed());
- //This is here to add time so that the payment is represented in the BookingDetails
-
break;
case PaymentCancelledByUser():
case PaymentError():
@@ -51,9 +46,6 @@ class PaymentCubit extends Cubit<PaymentProcessingState> {
}
}
-
-
-
void onUserDismissPaymentPopup() {
emit(PaymentProcessingStateNotStarted());
}
diff --git a/comwell_key_app/lib/payment/payment_processing_page.dart b/comwell_key_app/lib/payment/payment_processing_page.dart
index d1993eb5..ca5a0867 100644
--- a/comwell_key_app/lib/payment/payment_processing_page.dart
+++ b/comwell_key_app/lib/payment/payment_processing_page.dart
@@ -96,33 +96,36 @@ class _PaymentProcessingPageState extends State<PaymentProcessingPage>
body: Container(
alignment: Alignment.center,
color: sandColor[80],
- child: Builder(builder: (context) {
- final processingState = cubit.state;
- if (processingState is PaymentProcessingStateSessionReceived) {
- showAdyenModal(context);
- }
- return Lottie.asset(
- 'assets/animations/load_animation.json',
- controller: animationController,
- onLoaded: (composition) {
- if (loadingComposition == null) {
- loadingComposition = composition;
- animationController.duration = composition.duration;
- switch (cubit.state) {
- case PaymentProcessingStateConfirmed _:
- playSuccess();
- case PaymentProcessingStateError _:
- playError();
- default:
- playLoading();
- }
+ child: BlocListener<PaymentCubit, PaymentProcessingState>(
+ listener: (context, state) {
+ print("qqq state in listener: $state");
+ if (state is PaymentProcessingStateSessionReceived) {
+ showAdyenModal(context);
+ }
+ },
+ child: Lottie.asset(
+ 'assets/animations/load_animation.json',
+ controller: animationController,
+ onLoaded: (composition) {
+ if (loadingComposition == null) {
+ loadingComposition = composition;
+ animationController.duration = composition.duration;
+ switch (cubit.state) {
+ case PaymentProcessingStateConfirmed _:
+ playSuccess();
+ case PaymentProcessingStateError _:
+ print("qqq error in payment processing page");
+ playError();
+ default:
+ playLoading();
}
- },
- fit: BoxFit.cover,
- width: 64,
+ }
+ },
+ fit: BoxFit.cover,
+ width: 64,
height: 64,
- );
- }),
+ ),
+ ),
),
);
}
diff --git a/comwell_key_app/lib/payment_cards/bloc/payment_cards_cubit.dart b/comwell_key_app/lib/payment_cards/bloc/payment_cards_cubit.dart
index ca8b228c..1cedbf4a 100644
--- a/comwell_key_app/lib/payment_cards/bloc/payment_cards_cubit.dart
+++ b/comwell_key_app/lib/payment_cards/bloc/payment_cards_cubit.dart
@@ -16,15 +16,18 @@ class PaymentCardsCubit extends Cubit<PaymentCardsState> {
locator<PreregistrationRepository>();
final ProfileRepository profileRepository = locator<ProfileRepository>();
final Api _api = Api();
- late PaymentConfigurations paymentConfigurations;
+ late PaymentConfigurations? paymentConfigurations;
PaymentCardsCubit() : super(PaymentCardsState.initial()) {
init();
}
- Future<PaymentConfigurations> fetchPaymentConfiguration() async {
+ Future<PaymentConfigurations?> fetchPaymentConfiguration() async {
final session = await _preregistrationRepository.sessionCheckout(
Amount(currency: "DKK", value: 0), "CBO", false);
+ if (session == null) {
+ return null;
+ }
return session;
}
diff --git a/comwell_key_app/lib/payment_cards/components/add_card.dart b/comwell_key_app/lib/payment_cards/components/add_card.dart
index 2e5326df..96fe6abc 100644
--- a/comwell_key_app/lib/payment_cards/components/add_card.dart
+++ b/comwell_key_app/lib/payment_cards/components/add_card.dart
@@ -25,7 +25,12 @@ class AddCard extends StatelessWidget {
padding: MediaQuery.of(context).viewInsets,
child: AdyenCardComponent(
configuration:
- cubit.paymentConfigurations.cardComponentConfiguration,
+ cubit.paymentConfigurations?.cardComponentConfiguration ??
+ CardComponentConfiguration(
+ environment: Environment.test,
+ countryCode: "DK",
+ clientKey: "test",
+ ),
paymentMethod: paymentMethodConfig.toJson(),
checkout: cubit.advancedCheckout(),
onPaymentResult: cubit.onPaymentResult,
diff --git a/comwell_key_app/lib/pregistration/pregistration_repository.dart b/comwell_key_app/lib/pregistration/pregistration_repository.dart
index 8cfb5da6..dc70f8dc 100644
--- a/comwell_key_app/lib/pregistration/pregistration_repository.dart
+++ b/comwell_key_app/lib/pregistration/pregistration_repository.dart
@@ -13,7 +13,7 @@ class PreregistrationRepository {
PreregistrationRepository();
- Future<PaymentConfigurations> sessionCheckout(
+ Future<PaymentConfigurations?> sessionCheckout(
Amount amount,
String bookingId,
bool usePoints,
@@ -21,10 +21,13 @@ class PreregistrationRepository {
final response = await _api.createAdyenSession(bookingId, usePoints);
final clientKey = response["clientKey"] as String;
final sessionResponse = response["sessionResponse"];
+ final payedWithPoints = response["isFullyPaidWithPoints"] as bool;
+ if (payedWithPoints) {
+ return null;
+ }
final id = sessionResponse["id"] as String;
final sessionData = sessionResponse["sessionData"] as String;
- final payedWithPoints = response["isFullyPaidWithPoints"] as bool;
- print("qqq payedWithPoints $payedWithPoints");
+
// Use the server response amount for consistency across all payment methods
final serverAmount = Amount(
value: sessionResponse["amount"]["value"] as int, currency: "DKK");
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index c4e10467..ed77678d 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -385,12 +385,7 @@ GoRouter goRouter() {
GoRoute(
path: "/${AppRoutes.paymentProcessing.name}",
name: AppRoutes.paymentProcessing.name,
- builder: (context, state) => BlocProvider(
- create: (context) => PaymentCubit(
- preregistrationRepository:
- locator<PreregistrationRepository>()),
- child: const PaymentProcessingPage(),
- ),
+ builder: (context, state) => const PaymentProcessingPage(),
),
GoRoute(
path: "/${AppRoutes.notifications.name}",
@@ -409,7 +404,10 @@ GoRouter goRouter() {
GoRoute(
path: "/${AppRoutes.checkOutSuccess.name}",
name: AppRoutes.checkOutSuccess.name,
- builder: (context, state) => const CheckOutSuccessPage(),
+ builder: (context, state) {
+ final digitalCard = state.extra as bool;
+ return CheckOutSuccessPage(digitalCard: digitalCard);
+ },
),
GoRoute(
path: "/${AppRoutes.checkOutError.name}",