6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 848a3234
Changed files
.gitignore | 1 + common/pubspec.yaml | 2 +- concierge/example/pubspec.lock | 79 ++++++++--- concierge/example/pubspec.yaml | 66 +-------- .../lib/_generated/data/remote/models/order.g.dart | 12 +- concierge/lib/concierge_app.dart | 39 +----- concierge/lib/concierge_route.dart | 4 +- .../lib/data/remote/api/concierge_interceptor.dart | 2 +- concierge/lib/data/remote/models/order.dart | 12 +- .../domain/repositories/property_repository.dart | 2 +- .../screens/payment/bloc/payment_cubit.dart | 19 ++- .../screens/payment/payment_route.dart | 1 + .../lib/presentation/widgets/toggle_list_item.dart | 33 +++-- concierge/pubspec.yaml | 4 +- concierge/scripts/gen.sh | 3 +- payment_plugin/analysis_options.yaml | 2 + .../_generated/data/remote/api/api_client.g.dart | 24 ++++ payment_plugin/lib/data/remote/api/api_client.dart | 23 ++-- .../lib/domain/repositories/adyen_repository.dart | 152 ++++++++++----------- payment_plugin/pubspec.yaml | 47 +------ payment_plugin/scripts/gen.sh | 1 + 21 files changed, 231 insertions(+), 297 deletions(-)
Diff
diff --git a/.gitignore b/.gitignore
index be703737..c081b867 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ comwell_key_app/android/build/reports/problems/
comwell_key_app/macos/
comwell_key_app/linux/
comwell_key_app/windows/
+comwell_key_app/output/
.claude/
.idea/
mobilekeys_sdk_plugin/android/.gradle/
diff --git a/common/pubspec.yaml b/common/pubspec.yaml
index 37e464f7..a46d5b49 100644
--- a/common/pubspec.yaml
+++ b/common/pubspec.yaml
@@ -1,7 +1,7 @@
name: common
+publish_to: none
description: "A new Flutter package project."
version: 0.0.1
-homepage:
environment:
sdk: '>=3.8.0 <4.0.0'
diff --git a/concierge/example/pubspec.lock b/concierge/example/pubspec.lock
index 166f597c..7575931f 100644
--- a/concierge/example/pubspec.lock
+++ b/concierge/example/pubspec.lock
@@ -9,6 +9,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "88.0.0"
+ adyen_checkout:
+ dependency: transitive
+ description:
+ name: adyen_checkout
+ sha256: dbce3db3b95e8ea147279a5a49122c21d41a27f1a7295b8839bd3cab8130638c
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.8.1"
analyzer:
dependency: transitive
description:
@@ -77,10 +85,10 @@ packages:
dependency: transitive
description:
name: characters
- sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
+ sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
- version: "1.4.1"
+ version: "1.4.0"
checked_yaml:
dependency: transitive
description:
@@ -373,14 +381,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.1"
- get_it:
- dependency: transitive
- description:
- name: get_it
- sha256: ae78de7c3f2304b8d81f2bb6e320833e5e81de942188542328f074978cc0efa9
- url: "https://pub.dev"
- source: hosted
- version: "8.3.0"
glob:
dependency: transitive
description:
@@ -390,7 +390,7 @@ packages:
source: hosted
version: "2.1.3"
go_router:
- dependency: "direct main"
+ dependency: transitive
description:
name: go_router
sha256: "7974313e217a7771557add6ff2238acb63f635317c35fa590d348fb238f00896"
@@ -518,26 +518,26 @@ packages:
dependency: transitive
description:
name: matcher
- sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
+ sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev"
source: hosted
- version: "0.12.18"
+ version: "0.12.17"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
- sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
+ sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
- version: "0.13.0"
+ version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
- sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
+ sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
- version: "1.17.0"
+ version: "1.16.0"
mime:
dependency: transitive
description:
@@ -626,6 +626,45 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.0"
+ pay:
+ dependency: transitive
+ description:
+ name: pay
+ sha256: "83b15697797f8013bd7693193b9f657bacfe40c5d0a31d4e084caed5fe22d29c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.2.1"
+ pay_android:
+ dependency: transitive
+ description:
+ name: pay_android
+ sha256: d3e7d72e8be7f65dd8f0d3fd36a7c0357d94b504163b7dd6eed5e99f6f32405d
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.1.1"
+ pay_ios:
+ dependency: transitive
+ description:
+ name: pay_ios
+ sha256: ca4a7a12b4396b1205f314bebbc92e5268c627b65e5e6b3ab30efc2326da0a28
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.0"
+ pay_platform_interface:
+ dependency: transitive
+ description:
+ name: pay_platform_interface
+ sha256: "39a9f5fa4bafc59ce103bd5e84a6362113c6e58c361aed8dde9494b182fac400"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.0"
+ payment_plugin:
+ dependency: transitive
+ description:
+ path: "../../payment_plugin"
+ relative: true
+ source: path
+ version: "0.0.1"
petitparser:
dependency: transitive
description:
@@ -851,10 +890,10 @@ packages:
dependency: transitive
description:
name: test_api
- sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
+ sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
url: "https://pub.dev"
source: hosted
- version: "0.7.9"
+ version: "0.7.6"
typed_data:
dependency: transitive
description:
@@ -960,5 +999,5 @@ packages:
source: hosted
version: "3.1.3"
sdks:
- dart: ">=3.11.0 <4.0.0"
+ dart: ">=3.9.0 <4.0.0"
flutter: ">=3.35.0"
diff --git a/concierge/example/pubspec.yaml b/concierge/example/pubspec.yaml
index 89a8189f..e0d0e3a2 100644
--- a/concierge/example/pubspec.yaml
+++ b/concierge/example/pubspec.yaml
@@ -1,34 +1,15 @@
name: concierge_example
description: "Demonstrates how to use the concierge plugin."
-# The following line prevents the package from being accidentally published to
-# pub.dev using `flutter pub publish`. This is preferred for private packages.
-publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment:
sdk: ^3.8.1
+ flutter: '>=3.3.0'
-# Dependencies specify other packages that your package needs in order to work.
-# To automatically upgrade your package dependencies to the latest versions
-# consider running `flutter pub upgrade --major-versions`. Alternatively,
-# dependencies can be manually updated by changing the version numbers below to
-# the latest version available on pub.dev. To see which dependencies have newer
-# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
-
concierge:
- # When depending on this package from a real application you should use:
- # concierge: ^x.y.z
- # See https://dart.dev/tools/pub/dependencies#version-constraints
- # The example app is bundled with the plugin so we use a path dependency on
- # the parent directory to use the current plugin's version.
path: ../
-
- go_router: ^17.1.0
-
- # The following adds the Cupertino Icons font to your application.
- # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
dev_dependencies:
@@ -36,52 +17,7 @@ dev_dependencies:
sdk: flutter
flutter_test:
sdk: flutter
-
- # The "flutter_lints" package below contains a set of recommended lints to
- # encourage good coding practices. The lint set provided by the package is
- # activated in the `analysis_options.yaml` file located at the root of your
- # package. See that file for information about deactivating specific lint
- # rules and activating additional ones.
flutter_lints: ^5.0.0
-# For information on the generic Dart part of this file, see the
-# following page: https://dart.dev/tools/pub/pubspec
-
-# The following section is specific to Flutter packages.
flutter:
-
- # The following line ensures that the Material Icons font is
- # included with your application, so that you can use the icons in
- # the material Icons class.
uses-material-design: true
-
- # To add assets to your application, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
-
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/to/resolution-aware-images
-
- # For details regarding adding assets from package dependencies, see
- # https://flutter.dev/to/asset-from-package
-
- # To add custom fonts to your application, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts from package dependencies,
- # see https://flutter.dev/to/font-from-package
diff --git a/concierge/lib/_generated/data/remote/models/order.g.dart b/concierge/lib/_generated/data/remote/models/order.g.dart
index d418e906..0d4a8c2f 100644
--- a/concierge/lib/_generated/data/remote/models/order.g.dart
+++ b/concierge/lib/_generated/data/remote/models/order.g.dart
@@ -19,7 +19,7 @@ Order _$OrderFromJson(Map json) => Order(
estimatedDeliveryTime: json['estimated_delivery_time'],
pickupLocation: json['pickup_location'],
areaId: (json['area_id'] as num).toInt(),
- locationId: (json['location_id'] as num).toInt(),
+ locationId: (json['location_id'] as num?)?.toInt(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
customerComment: json['customer_comment'],
@@ -28,14 +28,14 @@ Order _$OrderFromJson(Map json) => Order(
deliveryMethodString: json['delivery_method_string'] as String,
statusString: json['status_string'] as String,
typeString: json['type_string'] as String,
- locationCode: json['location_code'] as String,
+ locationCode: json['location_code'] as String?,
orderItems: (json['order_items'] as List<dynamic>)
.map((e) => OrderItem.fromJson(Map<String, dynamic>.from(e as Map)))
.toList(),
payment: Payment.fromJson(Map<String, dynamic>.from(json['payment'] as Map)),
- customer: Customer.fromJson(
- Map<String, dynamic>.from(json['customer'] as Map),
- ),
+ customer: json['customer'] == null
+ ? null
+ : Customer.fromJson(Map<String, dynamic>.from(json['customer'] as Map)),
lastUpdateFrom: json['last_update_from'],
image: Image.fromJson(Map<String, dynamic>.from(json['image'] as Map)),
);
@@ -65,7 +65,7 @@ Map<String, dynamic> _$OrderToJson(Order instance) => <String, dynamic>{
'location_code': instance.locationCode,
'order_items': instance.orderItems.map((e) => e.toJson()).toList(),
'payment': instance.payment.toJson(),
- 'customer': instance.customer.toJson(),
+ 'customer': instance.customer?.toJson(),
'last_update_from': instance.lastUpdateFrom,
'image': instance.image.toJson(),
};
diff --git a/concierge/lib/concierge_app.dart b/concierge/lib/concierge_app.dart
index d19522d1..d8f207be 100644
--- a/concierge/lib/concierge_app.dart
+++ b/concierge/lib/concierge_app.dart
@@ -9,44 +9,11 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
+import 'package:payment_plugin/payment_plugin.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import 'flavors.dart';
-/// Host-app entry point: build the Hotel Overview UI for a given hotel + user token.
-///
-/// Typical usage from the host app:
-///
-/// Using `go_router`:
-/// ```dart
-/// // routes:
-/// // GoRoute(
-/// // path: '/concierge/:hotelCode',
-/// // builder: (context, state) => Concierge.hotelOverview(
-/// // flavor: Flavor.stage,
-/// // hotelCode: state.pathParameters['hotelCode']!,
-/// // userToken: '<token>',
-/// // ),
-/// // ),
-/// //
-/// // open from an image button:
-/// context.push('/concierge/ccp');
-/// ```
-///
-/// Using `Navigator`:
-/// ```dart
-/// Navigator.of(context).push(
-/// MaterialPageRoute(
-/// builder: (_) => Concierge.hotelOverview(
-/// flavor: Flavor.stage,
-/// hotelCode: "ccp",
-/// userToken: token,
-/// ),
-/// ),
-/// );
-/// ```
-///
-
class ConciergeApp extends StatelessWidget {
const ConciergeApp({
super.key,
@@ -69,6 +36,7 @@ class ConciergeApp extends StatelessWidget {
ConciergeInterceptor(storage),
if (kDebugMode) PrettyDioLogger(requestBody: true, requestHeader: true),
]);
+ await PaymentPlugin.initialize(config: PaymentConfig(dio: dio));
await storage.setUserToken(authToken);
return (ConciergeService(dio), storage);
}
@@ -82,8 +50,6 @@ class ConciergeApp extends StatelessWidget {
return Center(child: CircularProgressIndicator());
}
if (asyncSnapshot.hasError) {
- print("qqq err=${asyncSnapshot.error}");
- print("qqq st=${asyncSnapshot.stackTrace}");
return Center(child: Text(asyncSnapshot.error.toString()));
}
final (service, storage) = asyncSnapshot.data!;
@@ -91,6 +57,7 @@ class ConciergeApp extends StatelessWidget {
providers: [
RepositoryProvider(create: (context) => PropertyRepository(service)),
RepositoryProvider(create: (context) => storage),
+ RepositoryProvider(create: (context) => PaymentPlugin.instance),
],
child: MultiBlocProvider(
providers: [
diff --git a/concierge/lib/concierge_route.dart b/concierge/lib/concierge_route.dart
index 58a4f78c..0012ea7b 100644
--- a/concierge/lib/concierge_route.dart
+++ b/concierge/lib/concierge_route.dart
@@ -13,6 +13,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:go_router/go_router.dart';
+import 'package:payment_plugin/payment_plugin.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import 'data/local/secure_storage/concierge_secure_storage.dart';
import 'data/remote/api/concierge_interceptor.dart';
@@ -52,7 +53,7 @@ final conciergeShellRoute = StatefulShellRoute.indexedStack(
ConciergeInterceptor(storage),
if (kDebugMode) PrettyDioLogger(requestBody: true, requestHeader: true),
]);
- await storage.setUserToken("authToken");
+ await PaymentPlugin.initialize(config: PaymentConfig(dio: dio));
return (ConciergeService(dio), storage);
}
@@ -72,6 +73,7 @@ final conciergeShellRoute = StatefulShellRoute.indexedStack(
providers: [
RepositoryProvider(create: (context) => PropertyRepository(service)),
RepositoryProvider(create: (context) => storage),
+ RepositoryProvider(create: (context) => PaymentPlugin.instance),
],
child: MultiBlocProvider(
providers: [
diff --git a/concierge/lib/data/remote/api/concierge_interceptor.dart b/concierge/lib/data/remote/api/concierge_interceptor.dart
index 24501e4b..c41c84b8 100644
--- a/concierge/lib/data/remote/api/concierge_interceptor.dart
+++ b/concierge/lib/data/remote/api/concierge_interceptor.dart
@@ -10,7 +10,7 @@ class ConciergeInterceptor extends Interceptor {
void onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
final token = await _conciergeSecureStorage.getUserToken();
if (token != null) {
- options.headers["Authorization"] = token;
+ options.headers["Authorization"] = "Bearer $token";
}
super.onRequest(options, handler);
}
diff --git a/concierge/lib/data/remote/models/order.dart b/concierge/lib/data/remote/models/order.dart
index 8f985271..f7806701 100644
--- a/concierge/lib/data/remote/models/order.dart
+++ b/concierge/lib/data/remote/models/order.dart
@@ -3,15 +3,9 @@
// final order = orderFromJson(jsonString);
import 'package:json_annotation/json_annotation.dart';
-import 'dart:convert';
part '../../../_generated/data/remote/models/order.g.dart';
-
-Order orderFromJson(String str) => Order.fromJson(json.decode(str));
-
-String orderToJson(Order data) => json.encode(data.toJson());
-
@JsonSerializable(fieldRename: FieldRename.snake)
class Order {
final int id;
@@ -26,7 +20,7 @@ class Order {
final dynamic estimatedDeliveryTime;
final dynamic pickupLocation;
final int areaId;
- final int locationId;
+ final int? locationId;
final DateTime createdAt;
final DateTime updatedAt;
final dynamic customerComment;
@@ -35,10 +29,10 @@ class Order {
final String deliveryMethodString;
final String statusString;
final String typeString;
- final String locationCode;
+ final String? locationCode;
final List<OrderItem> orderItems;
final Payment payment;
- final Customer customer;
+ final Customer? customer;
final dynamic lastUpdateFrom;
final Image image;
diff --git a/concierge/lib/domain/repositories/property_repository.dart b/concierge/lib/domain/repositories/property_repository.dart
index 54b2569b..a3f3e780 100644
--- a/concierge/lib/domain/repositories/property_repository.dart
+++ b/concierge/lib/domain/repositories/property_repository.dart
@@ -47,7 +47,7 @@ class PropertyRepository {
"ga_client_id": "GA1.2.1247178081.1736166148",
};
if (deliveryLocation is Room) {
- body["room"] = "203";
+ body["room"] = "106";
} else if (deliveryLocation is Area) {
body["location_code"] = locationCode;
}
diff --git a/concierge/lib/presentation/screens/payment/bloc/payment_cubit.dart b/concierge/lib/presentation/screens/payment/bloc/payment_cubit.dart
index 3d53ed28..0214097e 100644
--- a/concierge/lib/presentation/screens/payment/bloc/payment_cubit.dart
+++ b/concierge/lib/presentation/screens/payment/bloc/payment_cubit.dart
@@ -3,12 +3,19 @@ import 'package:concierge/domain/repositories/property_repository.dart';
import 'package:concierge/presentation/app/cart_cubit.dart';
import 'package:concierge/presentation/base/base_cubit.dart';
import 'package:concierge/presentation/screens/payment/bloc/payment_state.dart';
+import 'package:payment_plugin/payment_plugin.dart';
+import 'package:payment_plugin/utils/json.dart';
class PaymentCubit extends BaseCubit<PaymentState> {
final CartCubit _cartCubit;
final PropertyRepository _propertyRepository;
+ final PaymentPlugin _paymentPlugin;
- PaymentCubit(this._cartCubit, this._propertyRepository) : super(const PaymentState()) {
+ PaymentCubit(
+ this._cartCubit,
+ this._propertyRepository,
+ this._paymentPlugin,
+ ) : super(const PaymentState()) {
init();
}
@@ -45,8 +52,14 @@ class PaymentCubit extends BaseCubit<PaymentState> {
comment: _cartCubit.state.comment,
chargeToRoom: _cartCubit.state.chargeToRoom,
);
- // TODO handling payment
- print("qqq response=$response");
+
+ final sessionResponse = await _paymentPlugin.repository.createAdyenSessionForConcierge(
+ response.id,
+ );
+ final data = Json.of(sessionResponse);
+ final clientKey = data["clientKey"];
+ final sessionData = Json.of(data["sessionResponse"]);
+ print(data);
} catch (e, st) {
handleError(e, st);
safeEmit(state.copyWith(error: AppError.unknown(e.toString())));
diff --git a/concierge/lib/presentation/screens/payment/payment_route.dart b/concierge/lib/presentation/screens/payment/payment_route.dart
index aade0924..a34e72e6 100644
--- a/concierge/lib/presentation/screens/payment/payment_route.dart
+++ b/concierge/lib/presentation/screens/payment/payment_route.dart
@@ -19,6 +19,7 @@ class PaymentRoute extends GoRouteData with $PaymentRoute {
create: (context) => PaymentCubit(
context.read(),
context.read(),
+ context.read(),
),
child: PaymentScreen(),
),
diff --git a/concierge/lib/presentation/widgets/toggle_list_item.dart b/concierge/lib/presentation/widgets/toggle_list_item.dart
index 63855a5d..7882e21a 100644
--- a/concierge/lib/presentation/widgets/toggle_list_item.dart
+++ b/concierge/lib/presentation/widgets/toggle_list_item.dart
@@ -64,21 +64,28 @@ class ToggleListItem extends StatelessWidget {
),
),
Gap(12),
- Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(title, style: TextStyle(color: Colors.black)),
- Text(
- subtitle,
- style: TextStyle(
- color: Colors.black.withAlpha((0.5 * 255).toInt()),
- fontSize: 12,
+ Expanded(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ title,
+ style: TextStyle(color: Colors.black),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
),
- ),
- ],
+ Text(
+ subtitle,
+ style: TextStyle(
+ color: Colors.black.withAlpha((0.5 * 255).toInt()),
+ fontSize: 12,
+ ),
+ ),
+ ],
+ ),
),
- Spacer(),
+ Gap(12),
ToggleCheckmark(
isSelected: isSelected,
size: 32,
diff --git a/concierge/pubspec.yaml b/concierge/pubspec.yaml
index 2053487f..46891ebf 100644
--- a/concierge/pubspec.yaml
+++ b/concierge/pubspec.yaml
@@ -1,4 +1,5 @@
name: concierge
+publish_to: none
description: "A new Flutter plugin project."
version: 0.0.1
@@ -11,6 +12,8 @@ dependencies:
sdk: flutter
common:
path: ../common
+ payment_plugin:
+ path: ../payment_plugin
plugin_platform_interface: ^2.0.2
equatable: ^2.0.5
json_annotation: ^4.9.0
@@ -24,7 +27,6 @@ dependencies:
lottie: ^3.1.2
flutter_dotenv: ^6.0.0
go_router: ^17.1.0
- get_it: ^8.0.3
pretty_dio_logger: any
gap: ^3.0.1
go_router_builder: ^4.1.0
diff --git a/concierge/scripts/gen.sh b/concierge/scripts/gen.sh
index 291e0047..6a76a2ac 100644
--- a/concierge/scripts/gen.sh
+++ b/concierge/scripts/gen.sh
@@ -1,2 +1 @@
-fvm dart run build_runner build --delete-conflicting-outputs
-#fvm flutter gen-l10n
\ No newline at end of file
+fvm dart run build_runner build --delete-conflicting-outputs
\ No newline at end of file
diff --git a/payment_plugin/analysis_options.yaml b/payment_plugin/analysis_options.yaml
index a5744c1c..366ecc80 100644
--- a/payment_plugin/analysis_options.yaml
+++ b/payment_plugin/analysis_options.yaml
@@ -2,3 +2,5 @@ include: package:flutter_lints/flutter.yaml
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
+formatter:
+ trailing_commas: preserve
\ No newline at end of file
diff --git a/payment_plugin/lib/_generated/data/remote/api/api_client.g.dart b/payment_plugin/lib/_generated/data/remote/api/api_client.g.dart
index c18c6685..367dcefb 100644
--- a/payment_plugin/lib/_generated/data/remote/api/api_client.g.dart
+++ b/payment_plugin/lib/_generated/data/remote/api/api_client.g.dart
@@ -67,6 +67,30 @@ class _ApiClient implements ApiClient {
return _value;
}
+ @override
+ Future<dynamic> createAdyenSessionForConcierge(
+ Map<String, dynamic> data,
+ ) async {
+ final _extra = <String, dynamic>{};
+ final queryParameters = <String, dynamic>{};
+ final _headers = <String, dynamic>{};
+ final _data = <String, dynamic>{};
+ _data.addAll(data);
+ final _options = _setStreamType<dynamic>(
+ Options(method: 'POST', headers: _headers, extra: _extra)
+ .compose(
+ _dio.options,
+ '/Payment/v1/CreateAdyenSessionForConcierge',
+ queryParameters: queryParameters,
+ data: _data,
+ )
+ .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
+ );
+ final _result = await _dio.fetch(_options);
+ final _value = _result.data;
+ return _value;
+ }
+
@override
Future<dynamic> createAdyenSessionForCards(String data) async {
final _extra = <String, dynamic>{};
diff --git a/payment_plugin/lib/data/remote/api/api_client.dart b/payment_plugin/lib/data/remote/api/api_client.dart
index fff19858..de48b633 100644
--- a/payment_plugin/lib/data/remote/api/api_client.dart
+++ b/payment_plugin/lib/data/remote/api/api_client.dart
@@ -1,10 +1,9 @@
import 'package:dio/dio.dart';
import 'package:payment_plugin/domain/models/payment_method.dart';
import 'package:payment_plugin/data/remote/models/stored_payment_methods_response.dart';
+import 'package:payment_plugin/utils/json.dart';
import 'package:retrofit/retrofit.dart';
-import '../models/api_response.dart';
-
part '../../../_generated/data/remote/api/api_client.g.dart';
@RestApi()
@@ -15,30 +14,26 @@ abstract class ApiClient {
Future<StoredPaymentsResponse> getPaymentMethods();
@POST("/Payment/v1/CreateAdyenSessionForBooking")
- Future<dynamic> createAdyenSession(
- @Body() String data,
- );
+ Future<dynamic> createAdyenSession(@Body() String data);
+
+ @POST("/Payment/v1/CreateAdyenSessionForConcierge")
+ Future<dynamic> createAdyenSessionForConcierge(@Body() Json data);
@POST("/Payment/v1/CreatePaymentSessionForAddingCards")
- Future<dynamic> createAdyenSessionForCards(
- @Body() String data);
+ Future<dynamic> createAdyenSessionForCards(@Body() String data);
@GET("/Payment/v1/list-available-payment-methods")
Future<dynamic> listAvailablePaymentMethods();
@POST("/Payment/v1/stored-payment-methods")
- Future<dynamic> storePaymentMethod(
- @Body() PaymentMethod storedPaymentMethod,
- );
+ Future<dynamic> storePaymentMethod(@Body() PaymentMethod storedPaymentMethod);
@DELETE("/Payment/v1/stored-payment-methods/{cardId}")
- Future<dynamic> removePaymentMethod(
- @Path("cardId") String cardId,
- );
+ Future<dynamic> removePaymentMethod(@Path("cardId") String cardId);
@POST("https://checkout-test.adyen.com/v71/payments")
Future<dynamic> submitPayment(
- @Query("data")Map<String, dynamic> data,
+ @Query("data") Map<String, dynamic> data,
@Header("X-API-KEY") String apiKey,
@Header("Content-Type") String contentType,
);
diff --git a/payment_plugin/lib/domain/repositories/adyen_repository.dart b/payment_plugin/lib/domain/repositories/adyen_repository.dart
index 4ed0da82..3930adaa 100644
--- a/payment_plugin/lib/domain/repositories/adyen_repository.dart
+++ b/payment_plugin/lib/domain/repositories/adyen_repository.dart
@@ -14,7 +14,7 @@ import 'package:payment_plugin/utils/json.dart';
class AdyenRepository {
final ApiClient _api;
-
+
/// Creates an AdyenRepository with a Dio instance from the main app
///
/// [dio] - The Dio instance from your main app (with all configured interceptors, baseUrl, etc.)
@@ -25,9 +25,7 @@ class AdyenRepository {
/// dio: yourConfiguredDioInstance,
/// );
/// ```
- AdyenRepository({
- required Dio dio,
- }) : _api = ApiClient(dio);
+ AdyenRepository({required Dio dio}) : _api = ApiClient(dio);
Future<Iterable<StoredPaymentMethod>> getCards() async {
final cards = await _api.getPaymentMethods();
@@ -47,6 +45,13 @@ class AdyenRepository {
return response;
}
+ Future<dynamic> createAdyenSessionForConcierge(int orderId) async {
+ final data = {
+ "OrderId": orderId,
+ "ReturnUrl": "comwell://"
+ };
+ return _api.createAdyenSessionForConcierge(data);
+ }
Future<Json?> postPaymentsDetails(Json body, String apiKey) async {
final contentType = "application/json";
@@ -65,8 +70,12 @@ class AdyenRepository {
return response;
}
- Future<Json> submitPayment(Json paymentResult, String shopperReference,
- String merchantAccount, String apiKey) async {
+ Future<Json> submitPayment(
+ Json paymentResult,
+ String shopperReference,
+ String merchantAccount,
+ String apiKey,
+ ) async {
final Map<String, dynamic> data = {
"shopperReference": shopperReference,
"amount": {"value:": 0, "currency": "DKK"},
@@ -104,41 +113,39 @@ class AdyenRepository {
}
final id = sessionResponse["id"] as String;
final sessionData = sessionResponse["sessionData"] as String;
- final availablePaymentMethods = await _api.listAvailablePaymentMethods() as Map<String, dynamic>;
+ final availablePaymentMethods =
+ await _api.listAvailablePaymentMethods() as Map<String, dynamic>;
final scheme = _findPaymentMethod(availablePaymentMethods, "scheme");
final googlePay = _findPaymentMethod(availablePaymentMethods, "googlePay");
final applePay = _findPaymentMethod(availablePaymentMethods, "applePay");
// Use the server response amount for consistency across all payment methods
- final serverAmount = Amount(
- value: sessionResponse["amount"]["value"] as int, currency: "DKK");
+ final serverAmount = Amount(value: sessionResponse["amount"]["value"] as int, currency: "DKK");
final session = await AdyenCheckout.session.create(
- sessionId: id,
- sessionData: sessionData,
- configuration: dropInConfiguration(serverAmount, clientKey, false));
+ sessionId: id,
+ sessionData: sessionData,
+ configuration: dropInConfiguration(serverAmount, clientKey, false),
+ );
return PaymentConfigurations(
- sessionCheckout: session,
- googlePayConfiguration: _getGooglePayComponentConfig(clientKey),
- dropInConfiguration:
- dropInConfiguration(serverAmount, clientKey, false),
- cardComponentConfiguration:
- cardComponentConfiguration(serverAmount, clientKey),
- applePayConfiguration:
- _applePayComponentConfiguration(clientKey, serverAmount, false),
- isFullyPaidWithPoints: payedWithPoints,
- availablePaymentMethods: [scheme!, googlePay!, applePay!]);
+ sessionCheckout: session,
+ googlePayConfiguration: _getGooglePayComponentConfig(clientKey),
+ dropInConfiguration: dropInConfiguration(serverAmount, clientKey, false),
+ cardComponentConfiguration: cardComponentConfiguration(serverAmount, clientKey),
+ applePayConfiguration: _applePayComponentConfiguration(clientKey, serverAmount, false),
+ isFullyPaidWithPoints: payedWithPoints,
+ availablePaymentMethods: [scheme!, googlePay!, applePay!],
+ );
}
-
+
Future<PaymentConfigurations?> fetchSessionForAddingCard() async {
- final body = {
- "returnUrl": returnUrl,
- };
+ final body = {"returnUrl": returnUrl};
final json = jsonEncode(body);
final response = await _api.createAdyenSessionForCards(json) as Map<String, dynamic>;
- final availablePaymentMethods = await _api.listAvailablePaymentMethods() as Map<String, dynamic>;
+ final availablePaymentMethods =
+ await _api.listAvailablePaymentMethods() as Map<String, dynamic>;
final clientKey = response["clientKey"] as String;
final sessionResponse = response["sessionResponse"];
@@ -152,28 +159,28 @@ class AdyenRepository {
final session = await AdyenCheckout.session.create(
sessionId: id,
sessionData: sessionData,
- configuration: cardComponentConfiguration(
- Amount(value: 0, currency: "DKK"), clientKey),
+ configuration: cardComponentConfiguration(Amount(value: 0, currency: "DKK"), clientKey),
);
return PaymentConfigurations(
- sessionCheckout: session,
- availablePaymentMethods: [scheme!, googlePay!, applePay!],
- googlePayConfiguration: _getGooglePayComponentConfig(clientKey),
- dropInConfiguration: dropInConfiguration(
- Amount(value: 0, currency: "DKK"), clientKey, true),
- cardComponentConfiguration: cardComponentConfiguration(
- Amount(value: 0, currency: "DKK"), clientKey),
- applePayConfiguration: _applePayComponentConfiguration(
- clientKey, Amount(value: 0, currency: "DKK"), true),
- isFullyPaidWithPoints: false);
+ sessionCheckout: session,
+ availablePaymentMethods: [scheme!, googlePay!, applePay!],
+ googlePayConfiguration: _getGooglePayComponentConfig(clientKey),
+ dropInConfiguration: dropInConfiguration(Amount(value: 0, currency: "DKK"), clientKey, true),
+ cardComponentConfiguration: cardComponentConfiguration(
+ Amount(value: 0, currency: "DKK"),
+ clientKey,
+ ),
+ applePayConfiguration: _applePayComponentConfiguration(
+ clientKey,
+ Amount(value: 0, currency: "DKK"),
+ true,
+ ),
+ isFullyPaidWithPoints: false,
+ );
}
-
-CardComponentConfiguration cardComponentConfiguration(
- Amount amount,
- String clientKey,
- ) {
+ CardComponentConfiguration cardComponentConfiguration(Amount amount, String clientKey) {
return CardComponentConfiguration(
environment: Environment.test,
amount: amount,
@@ -183,8 +190,7 @@ CardComponentConfiguration cardComponentConfiguration(
);
}
- DropInConfiguration dropInConfiguration(
- Amount amount, String clientKey, bool addCard) {
+ DropInConfiguration dropInConfiguration(Amount amount, String clientKey, bool addCard) {
return DropInConfiguration(
environment: Environment.test,
clientKey: clientKey,
@@ -193,20 +199,14 @@ CardComponentConfiguration cardComponentConfiguration(
googlePayConfiguration: _googlePayConfiguration,
applePayConfiguration: _getApplePlayConfig(amount, addCard),
cardConfiguration: const CardConfiguration(showStorePaymentField: false),
- paymentMethodNames: {
- "scheme": "Credit card",
- },
+ paymentMethodNames: {"scheme": "Credit card"},
);
}
GooglePayConfiguration get _googlePayConfiguration =>
- const GooglePayConfiguration(
- googlePayEnvironment: GooglePayEnvironment.test,
- );
+ const GooglePayConfiguration(googlePayEnvironment: GooglePayEnvironment.test);
- GooglePayComponentConfiguration _getGooglePayComponentConfig(
- String clientKey,
- ) {
+ GooglePayComponentConfiguration _getGooglePayComponentConfig(String clientKey) {
return GooglePayComponentConfiguration(
environment: Environment.test,
countryCode: "DK",
@@ -230,39 +230,36 @@ CardComponentConfiguration cardComponentConfiguration(
ApplePayConfiguration _getApplePlayConfig(Amount amount, bool addCard) {
return ApplePayConfiguration(
- merchantId: merchantId,
- merchantName: merchantName,
- allowOnboarding: true,
- allowShippingContactEditing: true,
- applePaySummaryItems: [
- ApplePaySummaryItem(
- label: addCard ? "add_card".tr() : "total".tr(),
- amount: Amount(value: amount.value, currency: amount.currency),
- type: ApplePaySummaryItemType.definite)
- ]);
+ merchantId: merchantId,
+ merchantName: merchantName,
+ allowOnboarding: true,
+ allowShippingContactEditing: true,
+ applePaySummaryItems: [
+ ApplePaySummaryItem(
+ label: addCard ? "add_card".tr() : "total".tr(),
+ amount: Amount(value: amount.value, currency: amount.currency),
+ type: ApplePaySummaryItemType.definite,
+ ),
+ ],
+ );
}
- static final Iterable<StoredPaymentMethod> mockStoredPaymentData = [
- 1,
- 2,
- 3,
- 4
- ].map((i) => StoredPaymentMethod(
+ static final Iterable<StoredPaymentMethod> mockStoredPaymentData = [1, 2, 3, 4].map(
+ (i) => StoredPaymentMethod(
expiryMonth: "12",
expiryYear: "2035",
holderName: "holder name",
id: "id $i",
lastFour: "$i$i$i$i",
- brand: "visa"));
+ brand: "visa",
+ ),
+ );
}
-Map<String, dynamic>? _findPaymentMethod(
- Map<String, dynamic> pmResponse,
- String type,
-) {
+Map<String, dynamic>? _findPaymentMethod(Map<String, dynamic> pmResponse, String type) {
final list =
(pmResponse['paymentMethods'] as List?)?.cast<Map<String, dynamic>>() ??
- const <Map<String, dynamic>>[];
+ const <Map<String, dynamic>>[];
for (final m in list) {
final t = (m['type'] as String?)?.toLowerCase();
@@ -272,4 +269,3 @@ Map<String, dynamic>? _findPaymentMethod(
}
return null;
}
-
diff --git a/payment_plugin/pubspec.yaml b/payment_plugin/pubspec.yaml
index 0cbbc024..fa6dc4c6 100644
--- a/payment_plugin/pubspec.yaml
+++ b/payment_plugin/pubspec.yaml
@@ -38,21 +38,7 @@ dev_dependencies:
retrofit_generator: ^10.0.5
freezed: ^3.0.6
-# For information on the generic Dart part of this file, see the
-# following page: https://dart.dev/tools/pub/pubspec
-
-# The following section is specific to Flutter packages.
flutter:
- # This section identifies this Flutter project as a plugin project.
- # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
- # which should be registered in the plugin registry. This is required for
- # using method channels.
- # The Android 'package' specifies package in which the registered class is.
- # This is required for using method channels on Android.
- # The 'ffiPlugin' specifies that native code should be built and bundled.
- # This is required for using `dart:ffi`.
- # All these are used by the tooling to maintain consistency when
- # adding or updating assets for this project.
plugin:
platforms:
android:
@@ -62,35 +48,4 @@ flutter:
pluginClass: PaymentPlugin
web:
pluginClass: PaymentPluginWeb
- fileName: payment_plugin_web.dart
-
- # To add assets to your plugin package, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
- #
- # For details regarding assets in packages, see
- # https://flutter.dev/to/asset-from-package
- #
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/to/resolution-aware-images
-
- # To add custom fonts to your plugin package, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts in packages, see
- # https://flutter.dev/to/font-from-package
+ fileName: payment_plugin_web.dart
\ No newline at end of file
diff --git a/payment_plugin/scripts/gen.sh b/payment_plugin/scripts/gen.sh
new file mode 100644
index 00000000..6a76a2ac
--- /dev/null
+++ b/payment_plugin/scripts/gen.sh
@@ -0,0 +1 @@
+fvm dart run build_runner build --delete-conflicting-outputs
\ No newline at end of file