6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 60a47a3b

AuthorEdmir Suljic<esu@dwarf.dk>
Date2025-06-17 10:47:56 +0200
Changed api endpoint and updated request structure

Changed files

comwell_key_app/lib/check_out/bloc/check_out_cubit.dart         | 2 +-
 comwell_key_app/lib/pregistration/pregistration_repository.dart | 8 +++++---
 comwell_key_app/lib/services/api.dart                           | 7 ++++---
 comwell_key_app/lib/services/utils/api_endpoints.dart           | 2 +-
 4 files changed, 11 insertions(+), 8 deletions(-)

Diff

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 8ef52242..d879a03a 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
@@ -130,7 +130,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
currency: "DKK",
);
final paymentConfigurations = await preregistrationRepository
- .sessionCheckout(amount, booking.hotelCode);
+ .sessionCheckout(amount, booking.confirmationId);
emit(state.processingStateUpdated(CheckoutProcessingStateSessionReceived(
paymentConfigurations: paymentConfigurations)));
} catch (e) {
diff --git a/comwell_key_app/lib/pregistration/pregistration_repository.dart b/comwell_key_app/lib/pregistration/pregistration_repository.dart
index ec5269df..c55a1367 100644
--- a/comwell_key_app/lib/pregistration/pregistration_repository.dart
+++ b/comwell_key_app/lib/pregistration/pregistration_repository.dart
@@ -14,17 +14,19 @@ class PreregistrationRepository {
Future<PaymentConfigurations> sessionCheckout(
Amount amount,
- String hotelCode,
+ String bookingId,
) async {
- final response = await _api.createAdyenSession(amount, hotelCode);
+ final response = await _api.createAdyenSession(bookingId);
final clientKey = response["clientKey"] as String;
final sessionResponse = response["sessionResponse"];
final id = sessionResponse["id"] as String;
final sessionData = sessionResponse["sessionData"] as String;
+
+ print("sessionResponse ${sessionResponse["amount"]["value"]}");
final session = await AdyenCheckout.session.create(
sessionId: id,
sessionData: sessionData,
- configuration: dropInConfiguration(amount, clientKey));
+ configuration: dropInConfiguration(Amount(value: sessionResponse["amount"]["value"] as int, currency: "DKK"), clientKey));
return PaymentConfigurations(
sessionCheckout: session,
googlePayConfiguration: _getGooglePayComponentConfig(clientKey),
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index 6349eeb3..b82833c1 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -43,15 +43,16 @@ class Api {
return StoredPaymentsResponse.fromJson(response.data!);
}
- Future<dynamic> createAdyenSession(Amount amount, String hotelCode) async {
+ Future<dynamic> createAdyenSession(String bookingId) async {
final body = {
- "hotelCode": hotelCode,
- "amount": amount.value,
+ "bookingConfirmationId": bookingId,
"returnUrl": "adyencheckout://com.comwell.phoenix.test/adyenPayment",
};
final json = jsonEncode(body);
final response =
await dio.post<dynamic>(ApiEndpoints.createAdyenSession, data: json);
+
+ print("response ${response.data}");
return response.data;
}
diff --git a/comwell_key_app/lib/services/utils/api_endpoints.dart b/comwell_key_app/lib/services/utils/api_endpoints.dart
index fde9bddd..b7d63c9a 100644
--- a/comwell_key_app/lib/services/utils/api_endpoints.dart
+++ b/comwell_key_app/lib/services/utils/api_endpoints.dart
@@ -13,7 +13,7 @@ class ApiEndpoints {
// Payment endpoints
static const String storedPaymentMethods = '/Payment/v1/stored-payment-methods';
- static const String createAdyenSession = '/Payment/v1/CreateAdyenSession';
+ static const String createAdyenSession = '/Payment/v1/CreateAdyenSessionForBooking';
static const String adyenPayments = 'https://checkout-test.adyen.com/v71/payments';
static const String adyenPaymentsDetails = 'https://checkout-test.adyen.com/v71/payments/details';