From aabed61451481dc1259fc3c4127151d4d2cebab8 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Wed, 20 Dec 2023 17:08:21 +0100 Subject: [PATCH 1/7] Small adjustments that were found during testing --- .../com/adyen/checkout/flutter/example/MainActivity.kt | 2 +- example/lib/repositories/adyen_drop_in_repository.dart | 7 +++++-- example/lib/screens/drop_in/drop_in_screen.dart | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/example/android/app/src/main/kotlin/com/adyen/checkout/flutter/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/adyen/checkout/flutter/example/MainActivity.kt index 7513a748..a792e31e 100644 --- a/example/android/app/src/main/kotlin/com/adyen/checkout/flutter/example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/adyen/checkout/flutter/example/MainActivity.kt @@ -2,6 +2,6 @@ package com.adyen.checkout.flutter.example import io.flutter.embedding.android.FlutterFragmentActivity -//We need to explain to merchants that we require a FlutterFragmentActivity instead the default FlutterActivity in order to support AndroidX. It is required from the checkout SDK. +//Requires a FlutterFragmentActivity instead the default FlutterActivity. class MainActivity : FlutterFragmentActivity() { } diff --git a/example/lib/repositories/adyen_drop_in_repository.dart b/example/lib/repositories/adyen_drop_in_repository.dart index e667accb..e9a98d43 100644 --- a/example/lib/repositories/adyen_drop_in_repository.dart +++ b/example/lib/repositories/adyen_drop_in_repository.dart @@ -78,6 +78,10 @@ class AdyenDropInRepository extends AdyenBaseRepository { Future fetchPaymentMethods() async { return await service.fetchPaymentMethods(PaymentMethodsRequestNetworkModel( + amount: AmountNetworkModel( + currency: Config.amount.currency, + value: Config.amount.value, + ), merchantAccount: Config.merchantAccount, countryCode: Config.countryCode, channel: determineChannel(), @@ -126,8 +130,7 @@ class AdyenDropInRepository extends AdyenBaseRepository { return paymentEventHandler.handleResponse(response); } - Future postPaymentsDetails( - String additionalDetails) async { + Future postPaymentsDetails(String additionalDetails) async { final response = await service.postPaymentsDetails(jsonDecode(additionalDetails)); return paymentEventHandler.handleResponse(response); diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index cb38809f..bfb737d3 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -92,7 +92,7 @@ class _DropInScreenState extends State { const CardConfiguration cardsConfiguration = CardConfiguration(); const ApplePayConfiguration applePayConfiguration = ApplePayConfiguration( - merchantId: Config.merchantAccount, + merchantId: "merchant.com.adyen.checkoutsandbox.test", merchantName: Config.merchantName, ); From 0b11b9a5f36a178487f4a36bfc85c616e6af7fd0 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Dec 2023 10:43:10 +0100 Subject: [PATCH 2/7] Added Runner.entitlements for apple pay --- example/ios/Runner.xcodeproj/project.pbxproj | 5 +++++ example/ios/Runner/Runner.entitlements | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 example/ios/Runner/Runner.entitlements diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 21d2b408..4d5c3b77 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -53,6 +53,7 @@ 500E5112FE84E8FF424A2FAF /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7581FD482B332CF700AEC65C /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; 759D7A922B0380EB00C5F718 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Main.strings; sourceTree = ""; }; 759D7A932B0380EB00C5F718 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/LaunchScreen.strings; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -154,6 +155,7 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( + 7581FD482B332CF700AEC65C /* Runner.entitlements */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -472,6 +474,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -652,6 +655,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -674,6 +678,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; diff --git a/example/ios/Runner/Runner.entitlements b/example/ios/Runner/Runner.entitlements new file mode 100644 index 00000000..8051c352 --- /dev/null +++ b/example/ios/Runner/Runner.entitlements @@ -0,0 +1,9 @@ + + + + + com.apple.developer.in-app-payments + + + + From 7101169651b38762b059a798eebce40fc7664567 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Dec 2023 10:46:15 +0100 Subject: [PATCH 3/7] Added config constants for merchant id --- example/lib/config.dart | 1 + example/lib/screens/drop_in/drop_in_screen.dart | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/example/lib/config.dart b/example/lib/config.dart index 38371530..d447f388 100644 --- a/example/lib/config.dart +++ b/example/lib/config.dart @@ -18,6 +18,7 @@ class Config { //Environment constants static const String merchantAccount = "TestMerchantCheckout"; static const String merchantName = "Test Merchant"; + static const String merchantId = "merchant.com.adyen.checkoutsandbox.test"; static const String countryCode = "NL"; static const String shopperLocale = "nl_NL"; static const String shopperReference = "Test reference"; diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index bfb737d3..56aa302a 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -92,7 +92,7 @@ class _DropInScreenState extends State { const CardConfiguration cardsConfiguration = CardConfiguration(); const ApplePayConfiguration applePayConfiguration = ApplePayConfiguration( - merchantId: "merchant.com.adyen.checkoutsandbox.test", + merchantId: Config.merchantId, merchantName: Config.merchantName, ); From a7f56cc63aac0029bbc97d4552d7ca41a96fd891 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Dec 2023 15:02:31 +0100 Subject: [PATCH 4/7] Added trim to version number --- lib/src/util/sdk_version_number_provider.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/util/sdk_version_number_provider.dart b/lib/src/util/sdk_version_number_provider.dart index e56752d6..34cc01b0 100644 --- a/lib/src/util/sdk_version_number_provider.dart +++ b/lib/src/util/sdk_version_number_provider.dart @@ -9,7 +9,7 @@ class SdkVersionNumberProvider { final RegExp regex = RegExp('version:s*(.*?)s*\\n'); final match = regex.firstMatch(pubspecContent); final versionNumber = match?.group(1) ?? ""; - return versionNumber; + return versionNumber.trim(); } catch (exception) { AdyenLogger.instance.print( "Could not find adyen checkout pubspec file for reading the SDK version number"); From 577ea14ada6c494912d666e5c9409e673f975c9e Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Dec 2023 15:25:55 +0100 Subject: [PATCH 5/7] Added additional information to session console log for example app --- example/lib/network/service.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lib/network/service.dart b/example/lib/network/service.dart index d0a36367..40e8d734 100644 --- a/example/lib/network/service.dart +++ b/example/lib/network/service.dart @@ -18,7 +18,7 @@ class Service { headers: _createHeaders(), body: sessionRequestNetworkModel.toRawJson(), ); - print("PspReference: ${response.headers["pspreference"]}"); + print("Session pspReference: ${response.headers["pspreference"]}"); return SessionResponseNetworkModel.fromRawJson(response.body); } From ebed3fceb0f40ead18fc80dad560395ad01e2365 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Dec 2023 16:49:29 +0100 Subject: [PATCH 6/7] Used environment from config --- example/lib/screens/drop_in/drop_in_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index 56aa302a..38cad52f 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -115,7 +115,7 @@ class _DropInScreenState extends State { ); final DropInConfiguration dropInConfiguration = DropInConfiguration( - environment: Environment.test, + environment: Config.environment, clientKey: Config.clientKey, countryCode: Config.countryCode, shopperLocale: Config.shopperLocale, From 841d887cbcec63566af58f7e63135b4061bd8fce Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Fri, 22 Dec 2023 11:48:47 +0100 Subject: [PATCH 7/7] Applied changes from code review --- example/lib/config.dart | 6 +++++- example/lib/screens/drop_in/drop_in_screen.dart | 2 +- pubspec.yaml | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/example/lib/config.dart b/example/lib/config.dart index 3871ce35..540cee38 100644 --- a/example/lib/config.dart +++ b/example/lib/config.dart @@ -10,15 +10,17 @@ class Config { { "CLIENT_KEY" : "YOUR_CLIENT_KEY", "X_API_KEY" : "YOUR X_API_KEY" + "APPLE_PAY_MERCHANT_ID_KEY": "YOUR_APPLE_PAY_MERCHANT_ID_KEY" } */ static const String clientKey = String.fromEnvironment('CLIENT_KEY'); static const String xApiKey = String.fromEnvironment('X_API_KEY'); + static const String merchantId = + String.fromEnvironment('APPLE_PAY_MERCHANT_ID_KEY'); //Environment constants static const String merchantAccount = "TestMerchantCheckout"; static const String merchantName = "Test Merchant"; - static const String merchantId = "merchant.com.adyen.checkoutsandbox.test"; static const String countryCode = "NL"; static const String shopperLocale = "nl-NL"; static const String shopperReference = "Test reference"; @@ -26,6 +28,8 @@ class Config { static const String baseUrl = "checkout-test.adyen.com"; static const String apiVersion = "v71"; static const String iOSReturnUrl = "flutter-ui-host://payments"; + static const GooglePayEnvironment googlePayEnvironment = + GooglePayEnvironment.test; //Example data static Amount amount = Amount(currency: "EUR", value: 1200); diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index ab52e0ba..bc63709f 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -98,7 +98,7 @@ class _DropInScreenState extends State { const GooglePayConfiguration googlePayConfiguration = GooglePayConfiguration( - googlePayEnvironment: GooglePayEnvironment.test, + googlePayEnvironment: Config.googlePayEnvironment, shippingAddressRequired: true, billingAddressRequired: true, ); diff --git a/pubspec.yaml b/pubspec.yaml index 1c4b48ed..ef315c40 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,8 +10,8 @@ environment: dependencies: flutter: sdk: flutter - plugin_platform_interface: 2.1.7 - stream_transform: 2.1.0 + plugin_platform_interface: ^2.1.7 + stream_transform: ^2.1.0 dev_dependencies: flutter_test: