From 4f068cf70afeb862de6fac384aeb1bc8cec90bcc Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 6 Feb 2025 16:59:52 +0100 Subject: [PATCH 1/7] Merged platform communication for Drop-in into one single stream. --- .../flutter/dropIn/DropInPlatformApi.kt | 18 +- .../checkout/flutter/generated/PlatformApi.kt | 21 +- ios/Classes/dropIn/DropInPlatformApi.swift | 16 +- .../DropInAdvancedFlowDelegate.swift | 10 +- ...ncedFlowStoredPaymentMethodsDelegate.swift | 2 +- .../DropInSessionsDelegate.swift | 6 +- ...SessionsStoredPaymentMethodsDelegate.swift | 2 +- ios/Classes/generated/PlatformApi.swift | 26 +- lib/src/drop_in/drop_in.dart | 62 +- lib/src/drop_in/drop_in_flutter_api.dart | 15 +- lib/src/generated/platform_api.g.dart | 648 ++++++++++-------- pigeons/platform_api.dart | 5 +- 12 files changed, 446 insertions(+), 385 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index f3688e50..155fd023 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt @@ -159,7 +159,7 @@ class DropInPlatformApi( PlatformCommunicationType.PAYMENT_COMPONENT, data = message.contentIfNotHandled.toString(), ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(model) {} + dropInFlutterApi.onDropInPlatformCommunication(model) {} } } @@ -179,12 +179,12 @@ class DropInPlatformApi( when (dropInStoredPaymentMethodDeletionModel?.dropInFlowType) { DropInType.SESSION -> - dropInFlutterApi.onDropInSessionPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel ) {} DropInType.ADVANCED_FLOW -> - dropInFlutterApi.onDropInAdvancedPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel ) {} @@ -206,7 +206,7 @@ class DropInPlatformApi( data = message.contentIfNotHandled.toString(), ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} } } @@ -222,7 +222,7 @@ class DropInPlatformApi( PlatformCommunicationType.BALANCE_CHECK, data = message.contentIfNotHandled.toString() ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} } } @@ -238,7 +238,7 @@ class DropInPlatformApi( PlatformCommunicationType.REQUEST_ORDER, data = message.contentIfNotHandled.toString() ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} } } @@ -254,7 +254,7 @@ class DropInPlatformApi( PlatformCommunicationType.CANCEL_ORDER, data = message.contentIfNotHandled.toString() ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} } } @@ -334,7 +334,7 @@ class DropInPlatformApi( paymentResult = mappedResult ) - dropInFlutterApi.onDropInSessionPlatformCommunication(platformCommunicationModel) {} + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} } val dropInAdvancedFlowCallback = @@ -372,6 +372,6 @@ class DropInPlatformApi( data = "", paymentResult = mappedResult ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt index 454ee634..b212df59 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt @@ -2018,27 +2018,10 @@ class DropInFlutterInterface(private val binaryMessenger: BinaryMessenger, priva PlatformApiPigeonCodec } } - fun onDropInSessionPlatformCommunication(platformCommunicationModelArg: PlatformCommunicationModel, callback: (Result) -> Unit) + fun onDropInPlatformCommunication(platformCommunicationModelArg: PlatformCommunicationModel, callback: (Result) -> Unit) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" - val channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication$separatedMessageChannelSuffix" - val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(platformCommunicationModelArg)) { - if (it is List<*>) { - if (it.size > 1) { - callback(Result.failure(AdyenPigeonError(it[0] as String, it[1] as String, it[2] as String?))) - } else { - callback(Result.success(Unit)) - } - } else { - callback(Result.failure(createConnectionError(channelName))) - } - } - } - fun onDropInAdvancedPlatformCommunication(platformCommunicationModelArg: PlatformCommunicationModel, callback: (Result) -> Unit) -{ - val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" - val channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication$separatedMessageChannelSuffix" + val channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication$separatedMessageChannelSuffix" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) channel.send(listOf(platformCommunicationModelArg)) { if (it is List<*>) { diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 54ae6ce9..75274158 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -116,7 +116,7 @@ class DropInPlatformApi: DropInPlatformInterface { type: PlatformCommunicationType.result, paymentResult: PaymentResultDTO(type: PaymentResultEnum.error, reason: error.localizedDescription) ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) @@ -198,7 +198,7 @@ class DropInPlatformApi: DropInPlatformInterface { result: PaymentResultModelDTO( resultCode: resultCode?.rawValue) ) - self?.dropInFlutterApi.onDropInAdvancedPlatformCommunication( + self?.dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: PlatformCommunicationModel( type: PlatformCommunicationType.result, paymentResult: paymentResult @@ -215,7 +215,7 @@ class DropInPlatformApi: DropInPlatformInterface { dropInViewController?.dropInComponent.handle(result) } catch { let paymentResult = PaymentResultDTO(type: PaymentResultEnum.error, reason: error.localizedDescription) - dropInFlutterApi.onDropInAdvancedPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: PlatformCommunicationModel( type: PlatformCommunicationType.result, paymentResult: paymentResult @@ -232,7 +232,7 @@ class DropInPlatformApi: DropInPlatformInterface { if paymentEventDTO.error?.dismissDropIn == true || dropInAdvancedFlowDelegate?.isApplePay == true { finalizeAndDismiss(success: false) { [weak self] in let paymentResult = PaymentResultDTO(type: PaymentResultEnum.error, reason: paymentEventDTO.error?.errorMessage) - self?.dropInFlutterApi.onDropInAdvancedPlatformCommunication( + self?.dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: PlatformCommunicationModel( type: PlatformCommunicationType.result, paymentResult: paymentResult @@ -295,7 +295,7 @@ class DropInPlatformApi: DropInPlatformInterface { reason: error.localizedDescription ) ) - dropInFlutterApi.onDropInSessionPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) @@ -351,7 +351,7 @@ extension DropInPlatformApi: PartialPaymentDelegate { type: PlatformCommunicationType.balanceCheck, data: data.jsonObject.toJsonStringRepresentation() ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) } catch { completion(.failure(error)) } @@ -360,7 +360,7 @@ extension DropInPlatformApi: PartialPaymentDelegate { func requestOrder(for component: any Adyen.Component, completion: @escaping (Result) -> Void) { requestOrderHandler = completion let platformCommunicationModel = PlatformCommunicationModel(type: PlatformCommunicationType.requestOrder) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) } func cancelOrder(_ order: Adyen.PartialPaymentOrder, component: any Adyen.Component) { @@ -372,7 +372,7 @@ extension DropInPlatformApi: PartialPaymentDelegate { let data = try JSONSerialization.data(withJSONObject: cancelOrderData, options: []) let cancelOrderDataString = String(data: data, encoding: .utf8) let platformCommunicationModel = PlatformCommunicationModel(type: PlatformCommunicationType.cancelOrder, data: cancelOrderDataString) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) } catch { adyenPrint(error.localizedDescription) } diff --git a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift index ef6764c8..e801200c 100644 --- a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift +++ b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift @@ -23,7 +23,7 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { type: PlatformCommunicationType.paymentComponent, data: submitDataEncoded ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) @@ -39,7 +39,7 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { let actionComponentData = ActionComponentDataModel(details: data.details.encodable, paymentData: data.paymentData) let actionComponentDataJson = try JSONEncoder().encode(actionComponentData) let actionComponentDataString = String(data: actionComponentDataJson, encoding: .utf8) - dropInFlutterApi.onDropInAdvancedPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: PlatformCommunicationModel( type: PlatformCommunicationType.additionalDetails, data: actionComponentDataString @@ -63,7 +63,7 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { type: PlatformCommunicationType.result, paymentResult: paymentResult ) - self?.dropInFlutterApi.onDropInAdvancedPlatformCommunication( + self?.dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) @@ -93,7 +93,7 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { reason: error.localizedDescription ) ) - self?.dropInFlutterApi.onDropInAdvancedPlatformCommunication( + self?.dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) @@ -111,6 +111,6 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { reason: error.localizedDescription ) ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) } } diff --git a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowStoredPaymentMethodsDelegate.swift b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowStoredPaymentMethodsDelegate.swift index 01cc61bf..1032e964 100644 --- a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowStoredPaymentMethodsDelegate.swift +++ b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowStoredPaymentMethodsDelegate.swift @@ -17,7 +17,7 @@ class DropInAdvancedFlowStoredPaymentMethodsDelegate: StoredPaymentMethodsDelega type: PlatformCommunicationType.deleteStoredPaymentMethod, data: storedPaymentMethod.identifier ) - dropInFlutterApi.onDropInAdvancedPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) diff --git a/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift b/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift index c1277119..1d82b7ce 100644 --- a/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift +++ b/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift @@ -25,7 +25,7 @@ class DropInSessionsDelegate: AdyenSessionDelegate { result: paymentResult ) ) - self.dropInFlutterApi.onDropInSessionPlatformCommunication( + self.dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) @@ -43,7 +43,7 @@ class DropInSessionsDelegate: AdyenSessionDelegate { reason: error.localizedDescription ) ) - self.dropInFlutterApi.onDropInSessionPlatformCommunication( + self.dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) @@ -55,7 +55,7 @@ class DropInSessionsDelegate: AdyenSessionDelegate { reason: error.localizedDescription ) ) - self.dropInFlutterApi.onDropInSessionPlatformCommunication( + self.dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) diff --git a/ios/Classes/dropIn/dropInSessions/DropInSessionsStoredPaymentMethodsDelegate.swift b/ios/Classes/dropIn/dropInSessions/DropInSessionsStoredPaymentMethodsDelegate.swift index 95e17011..eeafae53 100644 --- a/ios/Classes/dropIn/dropInSessions/DropInSessionsStoredPaymentMethodsDelegate.swift +++ b/ios/Classes/dropIn/dropInSessions/DropInSessionsStoredPaymentMethodsDelegate.swift @@ -17,7 +17,7 @@ class DropInSessionsStoredPaymentMethodsDelegate: StoredPaymentMethodsDelegate { type: PlatformCommunicationType.deleteStoredPaymentMethod, data: storedPaymentMethod.identifier ) - dropInFlutterApi.onDropInSessionPlatformCommunication( + dropInFlutterApi.onDropInPlatformCommunication( platformCommunicationModel: platformCommunicationModel, completion: { _ in } ) diff --git a/ios/Classes/generated/PlatformApi.swift b/ios/Classes/generated/PlatformApi.swift index db6fedb7..f27f3b89 100644 --- a/ios/Classes/generated/PlatformApi.swift +++ b/ios/Classes/generated/PlatformApi.swift @@ -1942,8 +1942,7 @@ class DropInPlatformInterfaceSetup { /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol DropInFlutterInterfaceProtocol { - func onDropInSessionPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) - func onDropInAdvancedPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) + func onDropInPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) } class DropInFlutterInterface: DropInFlutterInterfaceProtocol { @@ -1958,27 +1957,8 @@ class DropInFlutterInterface: DropInFlutterInterfaceProtocol { PlatformApiPigeonCodec.shared } - func onDropInSessionPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { - let channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([platformCommunicationModelArg] as [Any?]) { response in - guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName: channelName))) - return - } - if listResponse.count > 1 { - let code: String = listResponse[0] as! String - let message: String? = nilOrValue(listResponse[1]) - let details: String? = nilOrValue(listResponse[2]) - completion(.failure(AdyenPigeonError(code: code, message: message, details: details))) - } else { - completion(.success(())) - } - } - } - - func onDropInAdvancedPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { - let channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication\(messageChannelSuffix)" + func onDropInPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { + let channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication\(messageChannelSuffix)" let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([platformCommunicationModelArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index c404ad4e..eb97ef6a 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -39,10 +39,10 @@ class DropIn { dropInConfiguration.toDTO(sdkVersionNumber, true), ); - dropInFlutterApi.dropInSessionPlatformCommunicationStream = - StreamController.broadcast(); - dropInFlutterApi.dropInSessionPlatformCommunicationStream.stream - .asBroadcastStream() + dropInFlutterApi.dropInPlatformCommunicationStream = + StreamController(); + final platformCommunicationSubscription = dropInFlutterApi + .dropInPlatformCommunicationStream?.stream .listen((event) async { switch (event.type) { case PlatformCommunicationType.result: @@ -56,28 +56,28 @@ class DropIn { } }); - return dropInSessionCompleter.future.then((paymentResultDTO) { + return dropInSessionCompleter.future.then((paymentResultDTO) async { dropInPlatformApi.cleanUpDropIn(); - dropInFlutterApi.dropInSessionPlatformCommunicationStream.close(); + await platformCommunicationSubscription?.cancel(); + dropInFlutterApi.dropInPlatformCommunicationStream?.close(); + dropInFlutterApi.dropInPlatformCommunicationStream = null; adyenLogger .print("Drop-in session result type: ${paymentResultDTO.type.name}"); adyenLogger.print( "Drop-in session result code: ${paymentResultDTO.result?.resultCode}"); - switch (paymentResultDTO.type) { - case PaymentResultEnum.cancelledByUser: - return PaymentCancelledByUser(); - case PaymentResultEnum.error: - return PaymentError(reason: paymentResultDTO.reason); - case PaymentResultEnum.finished: - return PaymentSessionFinished( + return switch (paymentResultDTO.type) { + PaymentResultEnum.cancelledByUser => PaymentCancelledByUser(), + PaymentResultEnum.error => + PaymentError(reason: paymentResultDTO.reason), + PaymentResultEnum.finished => PaymentSessionFinished( sessionId: paymentResultDTO.result?.sessionId ?? "", sessionData: paymentResultDTO.result?.sessionData ?? "", sessionResult: paymentResultDTO.result?.sessionResult ?? "", resultCode: paymentResultDTO.result?.toResultCode() ?? ResultCode.unknown, order: paymentResultDTO.result?.order?.fromDTO(), - ); - } + ) + }; }); } @@ -104,10 +104,10 @@ class DropIn { encodedPaymentMethodsResponse, ); - dropInFlutterApi.dropInAdvancedFlowPlatformCommunicationStream = - StreamController.broadcast(); - dropInFlutterApi.dropInAdvancedFlowPlatformCommunicationStream.stream - .asBroadcastStream() + dropInFlutterApi.dropInPlatformCommunicationStream = + StreamController(); + final platformCommunicationSubscription = dropInFlutterApi + .dropInPlatformCommunicationStream?.stream .listen((event) async { switch (event.type) { case PlatformCommunicationType.paymentComponent: @@ -130,23 +130,23 @@ class DropIn { } }); - return dropInAdvancedFlowCompleter.future.then((paymentResultDTO) { + return dropInAdvancedFlowCompleter.future.then((paymentResultDTO) async { dropInPlatformApi.cleanUpDropIn(); - dropInFlutterApi.dropInAdvancedFlowPlatformCommunicationStream.close(); + await platformCommunicationSubscription?.cancel(); + await dropInFlutterApi.dropInPlatformCommunicationStream?.close(); + dropInFlutterApi.dropInPlatformCommunicationStream = null; adyenLogger.print( "Drop-in advanced flow result type: ${paymentResultDTO.type.name}"); adyenLogger.print( "Drop-in advanced flow result code: ${paymentResultDTO.result?.resultCode}"); - switch (paymentResultDTO.type) { - case PaymentResultEnum.cancelledByUser: - return PaymentCancelledByUser(); - case PaymentResultEnum.error: - return PaymentError(reason: paymentResultDTO.reason); - case PaymentResultEnum.finished: - return PaymentAdvancedFinished( - resultCode: paymentResultDTO.result?.toResultCode() ?? - ResultCode.unknown); - } + return switch (paymentResultDTO.type) { + PaymentResultEnum.cancelledByUser => PaymentCancelledByUser(), + PaymentResultEnum.error => + PaymentError(reason: paymentResultDTO.reason), + PaymentResultEnum.finished => PaymentAdvancedFinished( + resultCode: + paymentResultDTO.result?.toResultCode() ?? ResultCode.unknown) + }; }); } diff --git a/lib/src/drop_in/drop_in_flutter_api.dart b/lib/src/drop_in/drop_in_flutter_api.dart index c5caf85d..92c5215e 100644 --- a/lib/src/drop_in/drop_in_flutter_api.dart +++ b/lib/src/drop_in/drop_in_flutter_api.dart @@ -3,16 +3,11 @@ import 'dart:async'; import 'package:adyen_checkout/src/generated/platform_api.g.dart'; class DropInFlutterApi implements DropInFlutterInterface { - var dropInSessionPlatformCommunicationStream = - StreamController(); - var dropInAdvancedFlowPlatformCommunicationStream = - StreamController(); + StreamController? + dropInPlatformCommunicationStream; @override - void onDropInSessionPlatformCommunication(PlatformCommunicationModel data) => - dropInSessionPlatformCommunicationStream.sink.add(data); - - @override - void onDropInAdvancedPlatformCommunication(PlatformCommunicationModel data) => - dropInAdvancedFlowPlatformCommunicationStream.sink.add(data); + void onDropInPlatformCommunication( + PlatformCommunicationModel platformCommunicationModel) => + dropInPlatformCommunicationStream?.sink.add(platformCommunicationModel); } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index db4335b0..8601e43d 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -15,7 +15,8 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse( + {Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -315,7 +316,8 @@ class DropInConfigurationDTO { skipListWhenSinglePaymentMethod: result[11]! as bool, isRemoveStoredPaymentMethodEnabled: result[12]! as bool, preselectedPaymentMethodTitle: result[13] as String?, - paymentMethodNames: (result[14] as Map?)?.cast(), + paymentMethodNames: + (result[14] as Map?)?.cast(), isPartialPaymentSupported: result[15]! as bool, ); } @@ -448,14 +450,18 @@ class ApplePayConfigurationDTO { merchantId: result[0]! as String, merchantName: result[1]! as String, allowOnboarding: result[2] as bool?, - summaryItems: (result[3] as List?)?.cast(), - requiredBillingContactFields: (result[4] as List?)?.cast(), + summaryItems: + (result[3] as List?)?.cast(), + requiredBillingContactFields: + (result[4] as List?)?.cast(), billingContact: result[5] as ApplePayContactDTO?, - requiredShippingContactFields: (result[6] as List?)?.cast(), + requiredShippingContactFields: + (result[6] as List?)?.cast(), shippingContact: result[7] as ApplePayContactDTO?, applePayShippingType: result[8] as ApplePayShippingType?, allowShippingContactEditing: result[9] as bool?, - shippingMethods: (result[10] as List?)?.cast(), + shippingMethods: + (result[10] as List?)?.cast(), applicationData: result[11] as String?, supportedCountries: (result[12] as List?)?.cast(), merchantCapability: result[13] as ApplePayMerchantCapability?, @@ -1365,13 +1371,14 @@ class OrderCancelResultDTO { static OrderCancelResultDTO decode(Object result) { result as List; return OrderCancelResultDTO( - orderCancelResponseBody: (result[0] as Map?)!.cast(), - updatedPaymentMethodsResponseBody: (result[1] as Map?)?.cast(), + orderCancelResponseBody: + (result[0] as Map?)!.cast(), + updatedPaymentMethodsResponseBody: + (result[1] as Map?)?.cast(), ); } } - class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -1379,142 +1386,142 @@ class _PigeonCodec extends StandardMessageCodec { if (value is SessionDTO) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is AmountDTO) { + } else if (value is AmountDTO) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is AnalyticsOptionsDTO) { + } else if (value is AnalyticsOptionsDTO) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is DropInConfigurationDTO) { + } else if (value is DropInConfigurationDTO) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is CardConfigurationDTO) { + } else if (value is CardConfigurationDTO) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is ApplePayConfigurationDTO) { + } else if (value is ApplePayConfigurationDTO) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is ApplePayContactDTO) { + } else if (value is ApplePayContactDTO) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is ApplePayShippingMethodDTO) { + } else if (value is ApplePayShippingMethodDTO) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is ApplePaySummaryItemDTO) { + } else if (value is ApplePaySummaryItemDTO) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is GooglePayConfigurationDTO) { + } else if (value is GooglePayConfigurationDTO) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is MerchantInfoDTO) { + } else if (value is MerchantInfoDTO) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is ShippingAddressParametersDTO) { + } else if (value is ShippingAddressParametersDTO) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is BillingAddressParametersDTO) { + } else if (value is BillingAddressParametersDTO) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is CashAppPayConfigurationDTO) { + } else if (value is CashAppPayConfigurationDTO) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is PaymentResultDTO) { + } else if (value is PaymentResultDTO) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is PaymentResultModelDTO) { + } else if (value is PaymentResultModelDTO) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is OrderResponseDTO) { + } else if (value is OrderResponseDTO) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is PlatformCommunicationModel) { + } else if (value is PlatformCommunicationModel) { buffer.putUint8(146); writeValue(buffer, value.encode()); - } else if (value is ComponentCommunicationModel) { + } else if (value is ComponentCommunicationModel) { buffer.putUint8(147); writeValue(buffer, value.encode()); - } else if (value is PaymentEventDTO) { + } else if (value is PaymentEventDTO) { buffer.putUint8(148); writeValue(buffer, value.encode()); - } else if (value is ErrorDTO) { + } else if (value is ErrorDTO) { buffer.putUint8(149); writeValue(buffer, value.encode()); - } else if (value is DeletedStoredPaymentMethodResultDTO) { + } else if (value is DeletedStoredPaymentMethodResultDTO) { buffer.putUint8(150); writeValue(buffer, value.encode()); - } else if (value is CardComponentConfigurationDTO) { + } else if (value is CardComponentConfigurationDTO) { buffer.putUint8(151); writeValue(buffer, value.encode()); - } else if (value is InstantPaymentConfigurationDTO) { + } else if (value is InstantPaymentConfigurationDTO) { buffer.putUint8(152); writeValue(buffer, value.encode()); - } else if (value is InstantPaymentSetupResultDTO) { + } else if (value is InstantPaymentSetupResultDTO) { buffer.putUint8(153); writeValue(buffer, value.encode()); - } else if (value is UnencryptedCardDTO) { + } else if (value is UnencryptedCardDTO) { buffer.putUint8(154); writeValue(buffer, value.encode()); - } else if (value is EncryptedCardDTO) { + } else if (value is EncryptedCardDTO) { buffer.putUint8(155); writeValue(buffer, value.encode()); - } else if (value is ActionComponentConfigurationDTO) { + } else if (value is ActionComponentConfigurationDTO) { buffer.putUint8(156); writeValue(buffer, value.encode()); - } else if (value is OrderCancelResultDTO) { + } else if (value is OrderCancelResultDTO) { buffer.putUint8(157); writeValue(buffer, value.encode()); - } else if (value is Environment) { + } else if (value is Environment) { buffer.putUint8(158); writeValue(buffer, value.index); - } else if (value is AddressMode) { + } else if (value is AddressMode) { buffer.putUint8(159); writeValue(buffer, value.index); - } else if (value is CardAuthMethod) { + } else if (value is CardAuthMethod) { buffer.putUint8(160); writeValue(buffer, value.index); - } else if (value is TotalPriceStatus) { + } else if (value is TotalPriceStatus) { buffer.putUint8(161); writeValue(buffer, value.index); - } else if (value is GooglePayEnvironment) { + } else if (value is GooglePayEnvironment) { buffer.putUint8(162); writeValue(buffer, value.index); - } else if (value is CashAppPayEnvironment) { + } else if (value is CashAppPayEnvironment) { buffer.putUint8(163); writeValue(buffer, value.index); - } else if (value is PaymentResultEnum) { + } else if (value is PaymentResultEnum) { buffer.putUint8(164); writeValue(buffer, value.index); - } else if (value is PlatformCommunicationType) { + } else if (value is PlatformCommunicationType) { buffer.putUint8(165); writeValue(buffer, value.index); - } else if (value is ComponentCommunicationType) { + } else if (value is ComponentCommunicationType) { buffer.putUint8(166); writeValue(buffer, value.index); - } else if (value is PaymentEventType) { + } else if (value is PaymentEventType) { buffer.putUint8(167); writeValue(buffer, value.index); - } else if (value is FieldVisibility) { + } else if (value is FieldVisibility) { buffer.putUint8(168); writeValue(buffer, value.index); - } else if (value is InstantPaymentType) { + } else if (value is InstantPaymentType) { buffer.putUint8(169); writeValue(buffer, value.index); - } else if (value is ApplePayShippingType) { + } else if (value is ApplePayShippingType) { buffer.putUint8(170); writeValue(buffer, value.index); - } else if (value is ApplePayMerchantCapability) { + } else if (value is ApplePayMerchantCapability) { buffer.putUint8(171); writeValue(buffer, value.index); - } else if (value is ApplePaySummaryItemType) { + } else if (value is ApplePaySummaryItemType) { buffer.putUint8(172); writeValue(buffer, value.index); - } else if (value is CardNumberValidationResultDTO) { + } else if (value is CardNumberValidationResultDTO) { buffer.putUint8(173); writeValue(buffer, value.index); - } else if (value is CardExpiryDateValidationResultDTO) { + } else if (value is CardExpiryDateValidationResultDTO) { buffer.putUint8(174); writeValue(buffer, value.index); - } else if (value is CardSecurityCodeValidationResultDTO) { + } else if (value is CardSecurityCodeValidationResultDTO) { buffer.putUint8(175); writeValue(buffer, value.index); } else { @@ -1525,118 +1532,124 @@ class _PigeonCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 129: + case 129: return SessionDTO.decode(readValue(buffer)!); - case 130: + case 130: return AmountDTO.decode(readValue(buffer)!); - case 131: + case 131: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 132: + case 132: return DropInConfigurationDTO.decode(readValue(buffer)!); - case 133: + case 133: return CardConfigurationDTO.decode(readValue(buffer)!); - case 134: + case 134: return ApplePayConfigurationDTO.decode(readValue(buffer)!); - case 135: + case 135: return ApplePayContactDTO.decode(readValue(buffer)!); - case 136: + case 136: return ApplePayShippingMethodDTO.decode(readValue(buffer)!); - case 137: + case 137: return ApplePaySummaryItemDTO.decode(readValue(buffer)!); - case 138: + case 138: return GooglePayConfigurationDTO.decode(readValue(buffer)!); - case 139: + case 139: return MerchantInfoDTO.decode(readValue(buffer)!); - case 140: + case 140: return ShippingAddressParametersDTO.decode(readValue(buffer)!); - case 141: + case 141: return BillingAddressParametersDTO.decode(readValue(buffer)!); - case 142: + case 142: return CashAppPayConfigurationDTO.decode(readValue(buffer)!); - case 143: + case 143: return PaymentResultDTO.decode(readValue(buffer)!); - case 144: + case 144: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 145: + case 145: return OrderResponseDTO.decode(readValue(buffer)!); - case 146: + case 146: return PlatformCommunicationModel.decode(readValue(buffer)!); - case 147: + case 147: return ComponentCommunicationModel.decode(readValue(buffer)!); - case 148: + case 148: return PaymentEventDTO.decode(readValue(buffer)!); - case 149: + case 149: return ErrorDTO.decode(readValue(buffer)!); - case 150: + case 150: return DeletedStoredPaymentMethodResultDTO.decode(readValue(buffer)!); - case 151: + case 151: return CardComponentConfigurationDTO.decode(readValue(buffer)!); - case 152: + case 152: return InstantPaymentConfigurationDTO.decode(readValue(buffer)!); - case 153: + case 153: return InstantPaymentSetupResultDTO.decode(readValue(buffer)!); - case 154: + case 154: return UnencryptedCardDTO.decode(readValue(buffer)!); - case 155: + case 155: return EncryptedCardDTO.decode(readValue(buffer)!); - case 156: + case 156: return ActionComponentConfigurationDTO.decode(readValue(buffer)!); - case 157: + case 157: return OrderCancelResultDTO.decode(readValue(buffer)!); - case 158: + case 158: final int? value = readValue(buffer) as int?; return value == null ? null : Environment.values[value]; - case 159: + case 159: final int? value = readValue(buffer) as int?; return value == null ? null : AddressMode.values[value]; - case 160: + case 160: final int? value = readValue(buffer) as int?; return value == null ? null : CardAuthMethod.values[value]; - case 161: + case 161: final int? value = readValue(buffer) as int?; return value == null ? null : TotalPriceStatus.values[value]; - case 162: + case 162: final int? value = readValue(buffer) as int?; return value == null ? null : GooglePayEnvironment.values[value]; - case 163: + case 163: final int? value = readValue(buffer) as int?; return value == null ? null : CashAppPayEnvironment.values[value]; - case 164: + case 164: final int? value = readValue(buffer) as int?; return value == null ? null : PaymentResultEnum.values[value]; - case 165: + case 165: final int? value = readValue(buffer) as int?; return value == null ? null : PlatformCommunicationType.values[value]; - case 166: + case 166: final int? value = readValue(buffer) as int?; return value == null ? null : ComponentCommunicationType.values[value]; - case 167: + case 167: final int? value = readValue(buffer) as int?; return value == null ? null : PaymentEventType.values[value]; - case 168: + case 168: final int? value = readValue(buffer) as int?; return value == null ? null : FieldVisibility.values[value]; - case 169: + case 169: final int? value = readValue(buffer) as int?; return value == null ? null : InstantPaymentType.values[value]; - case 170: + case 170: final int? value = readValue(buffer) as int?; return value == null ? null : ApplePayShippingType.values[value]; - case 171: + case 171: final int? value = readValue(buffer) as int?; return value == null ? null : ApplePayMerchantCapability.values[value]; - case 172: + case 172: final int? value = readValue(buffer) as int?; return value == null ? null : ApplePaySummaryItemType.values[value]; - case 173: + case 173: final int? value = readValue(buffer) as int?; - return value == null ? null : CardNumberValidationResultDTO.values[value]; - case 174: + return value == null + ? null + : CardNumberValidationResultDTO.values[value]; + case 174: final int? value = readValue(buffer) as int?; - return value == null ? null : CardExpiryDateValidationResultDTO.values[value]; - case 175: + return value == null + ? null + : CardExpiryDateValidationResultDTO.values[value]; + case 175: final int? value = readValue(buffer) as int?; - return value == null ? null : CardSecurityCodeValidationResultDTO.values[value]; + return value == null + ? null + : CardSecurityCodeValidationResultDTO.values[value]; default: return super.readValueOfType(type, buffer); } @@ -1647,9 +1660,11 @@ class CheckoutPlatformInterface { /// Constructor for [CheckoutPlatformInterface]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - CheckoutPlatformInterface({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + CheckoutPlatformInterface( + {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) : __pigeon_binaryMessenger = binaryMessenger, - __pigeon_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + __pigeon_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? __pigeon_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -1657,8 +1672,10 @@ class CheckoutPlatformInterface { final String __pigeon_messageChannelSuffix; Future getReturnUrl() async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1683,15 +1700,19 @@ class CheckoutPlatformInterface { } } - Future createSession(String sessionId, String sessionData, Object? configuration) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future createSession( + String sessionId, String sessionData, Object? configuration) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([sessionId, sessionData, configuration]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([sessionId, sessionData, configuration]) + as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1711,8 +1732,10 @@ class CheckoutPlatformInterface { } Future clearSession() async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1732,15 +1755,18 @@ class CheckoutPlatformInterface { } } - Future encryptCard(UnencryptedCardDTO unencryptedCardDTO, String publicKey) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future encryptCard( + UnencryptedCardDTO unencryptedCardDTO, String publicKey) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([unencryptedCardDTO, publicKey]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([unencryptedCardDTO, publicKey]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1760,14 +1786,16 @@ class CheckoutPlatformInterface { } Future encryptBin(String bin, String publicKey) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([bin, publicKey]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([bin, publicKey]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1786,15 +1814,18 @@ class CheckoutPlatformInterface { } } - Future validateCardNumber(String cardNumber, bool enableLuhnCheck) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardNumber$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future validateCardNumber( + String cardNumber, bool enableLuhnCheck) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardNumber$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([cardNumber, enableLuhnCheck]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([cardNumber, enableLuhnCheck]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1813,15 +1844,18 @@ class CheckoutPlatformInterface { } } - Future validateCardExpiryDate(String expiryMonth, String expiryYear) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardExpiryDate$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future validateCardExpiryDate( + String expiryMonth, String expiryYear) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardExpiryDate$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([expiryMonth, expiryYear]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([expiryMonth, expiryYear]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1840,15 +1874,18 @@ class CheckoutPlatformInterface { } } - Future validateCardSecurityCode(String securityCode, String? cardBrand) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardSecurityCode$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future validateCardSecurityCode( + String securityCode, String? cardBrand) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardSecurityCode$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([securityCode, cardBrand]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([securityCode, cardBrand]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1868,14 +1905,16 @@ class CheckoutPlatformInterface { } Future enableConsoleLogging(bool loggingEnabled) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([loggingEnabled]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([loggingEnabled]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1894,24 +1933,29 @@ class DropInPlatformInterface { /// Constructor for [DropInPlatformInterface]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - DropInPlatformInterface({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + DropInPlatformInterface( + {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) : __pigeon_binaryMessenger = binaryMessenger, - __pigeon_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + __pigeon_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? __pigeon_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); final String __pigeon_messageChannelSuffix; - Future showDropInSession(DropInConfigurationDTO dropInConfigurationDTO) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future showDropInSession( + DropInConfigurationDTO dropInConfigurationDTO) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([dropInConfigurationDTO]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([dropInConfigurationDTO]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1925,15 +1969,19 @@ class DropInPlatformInterface { } } - Future showDropInAdvanced(DropInConfigurationDTO dropInConfigurationDTO, String paymentMethodsResponse) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future showDropInAdvanced(DropInConfigurationDTO dropInConfigurationDTO, + String paymentMethodsResponse) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([dropInConfigurationDTO, paymentMethodsResponse]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([dropInConfigurationDTO, paymentMethodsResponse]) + as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1948,14 +1996,16 @@ class DropInPlatformInterface { } Future onPaymentsResult(PaymentEventDTO paymentsResult) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([paymentsResult]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([paymentsResult]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1969,15 +2019,18 @@ class DropInPlatformInterface { } } - Future onPaymentsDetailsResult(PaymentEventDTO paymentsDetailsResult) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onPaymentsDetailsResult( + PaymentEventDTO paymentsDetailsResult) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([paymentsDetailsResult]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([paymentsDetailsResult]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1991,15 +2044,19 @@ class DropInPlatformInterface { } } - Future onDeleteStoredPaymentMethodResult(DeletedStoredPaymentMethodResultDTO deleteStoredPaymentMethodResultDTO) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onDeleteStoredPaymentMethodResult( + DeletedStoredPaymentMethodResultDTO + deleteStoredPaymentMethodResultDTO) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([deleteStoredPaymentMethodResultDTO]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([deleteStoredPaymentMethodResultDTO]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2014,14 +2071,16 @@ class DropInPlatformInterface { } Future onBalanceCheckResult(String balanceCheckResponse) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([balanceCheckResponse]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([balanceCheckResponse]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2036,14 +2095,16 @@ class DropInPlatformInterface { } Future onOrderRequestResult(String orderRequestResponse) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([orderRequestResponse]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([orderRequestResponse]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2057,15 +2118,18 @@ class DropInPlatformInterface { } } - Future onOrderCancelResult(OrderCancelResultDTO orderCancelResult) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onOrderCancelResult( + OrderCancelResultDTO orderCancelResult) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([orderCancelResult]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([orderCancelResult]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2080,8 +2144,10 @@ class DropInPlatformInterface { } Future cleanUpDropIn() async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2105,58 +2171,41 @@ class DropInPlatformInterface { abstract class DropInFlutterInterface { static const MessageCodec pigeonChannelCodec = _PigeonCodec(); - void onDropInSessionPlatformCommunication(PlatformCommunicationModel platformCommunicationModel); - - void onDropInAdvancedPlatformCommunication(PlatformCommunicationModel platformCommunicationModel); + void onDropInPlatformCommunication( + PlatformCommunicationModel platformCommunicationModel); - static void setUp(DropInFlutterInterface? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; - { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication$messageChannelSuffix', pigeonChannelCodec, - binaryMessenger: binaryMessenger); - if (api == null) { - __pigeon_channel.setMessageHandler(null); - } else { - __pigeon_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication was null.'); - final List args = (message as List?)!; - final PlatformCommunicationModel? arg_platformCommunicationModel = (args[0] as PlatformCommunicationModel?); - assert(arg_platformCommunicationModel != null, - 'Argument for dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication was null, expected non-null PlatformCommunicationModel.'); - try { - api.onDropInSessionPlatformCommunication(arg_platformCommunicationModel!); - return wrapResponse(empty: true); - } on PlatformException catch (e) { - return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); - } - }); - } - } + static void setUp( + DropInFlutterInterface? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication was null.'); + 'Argument for dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication was null.'); final List args = (message as List?)!; - final PlatformCommunicationModel? arg_platformCommunicationModel = (args[0] as PlatformCommunicationModel?); + final PlatformCommunicationModel? arg_platformCommunicationModel = + (args[0] as PlatformCommunicationModel?); assert(arg_platformCommunicationModel != null, - 'Argument for dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication was null, expected non-null PlatformCommunicationModel.'); + 'Argument for dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication was null, expected non-null PlatformCommunicationModel.'); try { - api.onDropInAdvancedPlatformCommunication(arg_platformCommunicationModel!); + api.onDropInPlatformCommunication(arg_platformCommunicationModel!); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } @@ -2168,9 +2217,11 @@ class ComponentPlatformInterface { /// Constructor for [ComponentPlatformInterface]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - ComponentPlatformInterface({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + ComponentPlatformInterface( + {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) : __pigeon_binaryMessenger = binaryMessenger, - __pigeon_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + __pigeon_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? __pigeon_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -2178,8 +2229,10 @@ class ComponentPlatformInterface { final String __pigeon_messageChannelSuffix; Future updateViewHeight(int viewId) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2199,15 +2252,18 @@ class ComponentPlatformInterface { } } - Future onPaymentsResult(String componentId, PaymentEventDTO paymentsResult) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onPaymentsResult( + String componentId, PaymentEventDTO paymentsResult) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([componentId, paymentsResult]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([componentId, paymentsResult]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2221,15 +2277,18 @@ class ComponentPlatformInterface { } } - Future onPaymentsDetailsResult(String componentId, PaymentEventDTO paymentsDetailsResult) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onPaymentsDetailsResult( + String componentId, PaymentEventDTO paymentsDetailsResult) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([componentId, paymentsDetailsResult]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([componentId, paymentsDetailsResult]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2243,15 +2302,24 @@ class ComponentPlatformInterface { } } - Future isInstantPaymentSupportedByPlatform(InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, String paymentMethodResponse, String componentId) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future isInstantPaymentSupportedByPlatform( + InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, + String paymentMethodResponse, + String componentId) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([instantPaymentConfigurationDTO, paymentMethodResponse, componentId]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([ + instantPaymentConfigurationDTO, + paymentMethodResponse, + componentId + ]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2270,15 +2338,24 @@ class ComponentPlatformInterface { } } - Future onInstantPaymentPressed(InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, String encodedPaymentMethod, String componentId) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onInstantPaymentPressed( + InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, + String encodedPaymentMethod, + String componentId) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([instantPaymentConfigurationDTO, encodedPaymentMethod, componentId]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([ + instantPaymentConfigurationDTO, + encodedPaymentMethod, + componentId + ]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2292,15 +2369,24 @@ class ComponentPlatformInterface { } } - Future handleAction(ActionComponentConfigurationDTO actionComponentConfiguration, String componentId, Map? actionResponse) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future handleAction( + ActionComponentConfigurationDTO actionComponentConfiguration, + String componentId, + Map? actionResponse) async { + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([actionComponentConfiguration, componentId, actionResponse]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([ + actionComponentConfiguration, + componentId, + actionResponse + ]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2315,8 +2401,10 @@ class ComponentPlatformInterface { } Future onDispose(String componentId) async { - final String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + final String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose$__pigeon_messageChannelSuffix'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2340,52 +2428,69 @@ class ComponentPlatformInterface { abstract class ComponentFlutterInterface { static const MessageCodec pigeonChannelCodec = _PigeonCodec(); - void _generateCodecForDTOs(CardComponentConfigurationDTO cardComponentConfigurationDTO, SessionDTO sessionDTO); + void _generateCodecForDTOs( + CardComponentConfigurationDTO cardComponentConfigurationDTO, + SessionDTO sessionDTO); - void onComponentCommunication(ComponentCommunicationModel componentCommunicationModel); + void onComponentCommunication( + ComponentCommunicationModel componentCommunicationModel); - static void setUp(ComponentFlutterInterface? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + static void setUp( + ComponentFlutterInterface? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs was null.'); + 'Argument for dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs was null.'); final List args = (message as List?)!; - final CardComponentConfigurationDTO? arg_cardComponentConfigurationDTO = (args[0] as CardComponentConfigurationDTO?); + final CardComponentConfigurationDTO? + arg_cardComponentConfigurationDTO = + (args[0] as CardComponentConfigurationDTO?); assert(arg_cardComponentConfigurationDTO != null, 'Argument for dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs was null, expected non-null CardComponentConfigurationDTO.'); final SessionDTO? arg_sessionDTO = (args[1] as SessionDTO?); assert(arg_sessionDTO != null, 'Argument for dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs was null, expected non-null SessionDTO.'); try { - api._generateCodecForDTOs(arg_cardComponentConfigurationDTO!, arg_sessionDTO!); + api._generateCodecForDTOs( + arg_cardComponentConfigurationDTO!, arg_sessionDTO!); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { __pigeon_channel.setMessageHandler(null); } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication was null.'); + 'Argument for dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication was null.'); final List args = (message as List?)!; - final ComponentCommunicationModel? arg_componentCommunicationModel = (args[0] as ComponentCommunicationModel?); + final ComponentCommunicationModel? arg_componentCommunicationModel = + (args[0] as ComponentCommunicationModel?); assert(arg_componentCommunicationModel != null, 'Argument for dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication was null, expected non-null ComponentCommunicationModel.'); try { @@ -2393,8 +2498,9 @@ abstract class ComponentFlutterInterface { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 175cd954..5efdb299 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -679,10 +679,7 @@ abstract class DropInPlatformInterface { @FlutterApi() abstract class DropInFlutterInterface { - void onDropInSessionPlatformCommunication( - PlatformCommunicationModel platformCommunicationModel); - - void onDropInAdvancedPlatformCommunication( + void onDropInPlatformCommunication( PlatformCommunicationModel platformCommunicationModel); } From ef5b2f4b3d7f06a0ee1a135284328f6ece8e7f1f Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Fri, 7 Feb 2025 13:14:40 +0100 Subject: [PATCH 2/7] removed redundant platform communication usage check --- .../checkout/flutter/dropIn/DropInPlatformApi.kt | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index 155fd023..7b8469c7 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt @@ -177,19 +177,7 @@ class DropInPlatformApi( data = dropInStoredPaymentMethodDeletionModel?.storedPaymentMethodId, ) - when (dropInStoredPaymentMethodDeletionModel?.dropInFlowType) { - DropInType.SESSION -> - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel - ) {} - - DropInType.ADVANCED_FLOW -> - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel - ) {} - - null -> return@observe - } + dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} } } From aca74272b6e43e2ef7d2a4fdd7134c0e5e1912c9 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Fri, 7 Feb 2025 13:37:11 +0100 Subject: [PATCH 3/7] Applied Kotlin code styling --- .../com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index 7b8469c7..66639baa 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt @@ -25,7 +25,6 @@ import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionPla import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionResultMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentResultMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInServiceResultMessenger -import com.adyen.checkout.flutter.dropIn.model.DropInType import com.adyen.checkout.flutter.dropIn.session.SessionDropInService import com.adyen.checkout.flutter.generated.DeletedStoredPaymentMethodResultDTO import com.adyen.checkout.flutter.generated.DropInConfigurationDTO From d321a5264d6228f16a01d57fb5d3f2867be12871 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Fri, 7 Feb 2025 16:12:53 +0100 Subject: [PATCH 4/7] Refactored platform communication into a generic form and decoupled it from drop-in --- .../checkout/flutter/AdyenCheckoutPlugin.kt | 10 +-- .../flutter/dropIn/DropInPlatformApi.kt | 74 +++++++++---------- .../checkout/flutter/generated/PlatformApi.kt | 32 ++++---- ios/Classes/AdyenCheckoutPlugin.swift | 6 +- ios/Classes/CheckoutPlatformApi.swift | 8 +- ios/Classes/dropIn/DropInPlatformApi.swift | 66 ++++++++--------- .../DropInAdvancedFlowDelegate.swift | 44 ++++++----- ...ncedFlowStoredPaymentMethodsDelegate.swift | 14 ++-- .../DropInSessionsDelegate.swift | 34 ++++----- ...SessionsStoredPaymentMethodsDelegate.swift | 14 ++-- ios/Classes/generated/PlatformApi.swift | 34 ++++----- lib/src/adyen_checkout.dart | 4 +- lib/src/common/checkout_flutter.dart | 10 +++ lib/src/drop_in/drop_in.dart | 72 +++++++++--------- lib/src/drop_in/drop_in_flutter_api.dart | 13 ---- lib/src/generated/platform_api.g.dart | 42 +++++------ pigeons/platform_api.dart | 13 ++-- 17 files changed, 236 insertions(+), 254 deletions(-) create mode 100644 lib/src/common/checkout_flutter.dart delete mode 100644 lib/src/drop_in/drop_in_flutter_api.dart diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/AdyenCheckoutPlugin.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/AdyenCheckoutPlugin.kt index 68e2c48b..5d09b0b1 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/AdyenCheckoutPlugin.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/AdyenCheckoutPlugin.kt @@ -7,10 +7,10 @@ import androidx.lifecycle.LifecycleEventObserver import com.adyen.checkout.dropin.DropIn import com.adyen.checkout.flutter.components.ComponentPlatformApi import com.adyen.checkout.flutter.dropIn.DropInPlatformApi +import com.adyen.checkout.flutter.generated.CheckoutFlutterInterface import com.adyen.checkout.flutter.generated.CheckoutPlatformInterface import com.adyen.checkout.flutter.generated.ComponentFlutterInterface import com.adyen.checkout.flutter.generated.ComponentPlatformInterface -import com.adyen.checkout.flutter.generated.DropInFlutterInterface import com.adyen.checkout.flutter.generated.DropInPlatformInterface import com.adyen.checkout.flutter.session.SessionHolder import com.adyen.checkout.flutter.utils.Constants.Companion.WRONG_FLUTTER_ACTIVITY_USAGE_ERROR_MESSAGE @@ -26,7 +26,7 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware, PluginRegistry.Activit private var flutterPluginBinding: FlutterPluginBinding? = null private var activityPluginBinding: ActivityPluginBinding? = null private var checkoutPlatformApi: CheckoutPlatformApi? = null - private var dropInFlutterApi: DropInFlutterInterface? = null + private var checkoutFlutter: CheckoutFlutterInterface? = null private var dropInPlatformApi: DropInPlatformApi? = null private var componentFlutterApi: ComponentFlutterInterface? = null private var componentPlatformApi: ComponentPlatformApi? = null @@ -79,8 +79,8 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware, PluginRegistry.Activit fragmentActivity: FragmentActivity, binaryMessenger: BinaryMessenger, ) { - dropInFlutterApi = - DropInFlutterInterface(binaryMessenger).apply { + checkoutFlutter = + CheckoutFlutterInterface(binaryMessenger).apply { dropInPlatformApi = DropInPlatformApi(this, fragmentActivity, sessionHolder) DropInPlatformInterface.setUp(binaryMessenger, dropInPlatformApi) } @@ -146,7 +146,7 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware, PluginRegistry.Activit lifecycleObserver = null dropInPlatformApi = null - dropInFlutterApi = null + checkoutFlutter = null DropInPlatformInterface.setUp(binaryMessenger, null) } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index 66639baa..98dc969c 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt @@ -26,9 +26,11 @@ import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionRes import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentResultMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInServiceResultMessenger import com.adyen.checkout.flutter.dropIn.session.SessionDropInService +import com.adyen.checkout.flutter.generated.CheckoutEvent +import com.adyen.checkout.flutter.generated.CheckoutEventType +import com.adyen.checkout.flutter.generated.CheckoutFlutterInterface import com.adyen.checkout.flutter.generated.DeletedStoredPaymentMethodResultDTO import com.adyen.checkout.flutter.generated.DropInConfigurationDTO -import com.adyen.checkout.flutter.generated.DropInFlutterInterface import com.adyen.checkout.flutter.generated.DropInPlatformInterface import com.adyen.checkout.flutter.generated.OrderCancelResultDTO import com.adyen.checkout.flutter.generated.PaymentEventDTO @@ -36,8 +38,6 @@ import com.adyen.checkout.flutter.generated.PaymentEventType import com.adyen.checkout.flutter.generated.PaymentResultDTO import com.adyen.checkout.flutter.generated.PaymentResultEnum import com.adyen.checkout.flutter.generated.PaymentResultModelDTO -import com.adyen.checkout.flutter.generated.PlatformCommunicationModel -import com.adyen.checkout.flutter.generated.PlatformCommunicationType import com.adyen.checkout.flutter.session.SessionHolder import com.adyen.checkout.flutter.utils.ConfigurationMapper.mapToDropInConfiguration import com.adyen.checkout.flutter.utils.ConfigurationMapper.mapToEnvironment @@ -50,7 +50,7 @@ import kotlinx.coroutines.withContext import org.json.JSONObject class DropInPlatformApi( - private val dropInFlutterApi: DropInFlutterInterface, + private val checkoutFlutter: CheckoutFlutterInterface, private val activity: FragmentActivity, private val sessionHolder: SessionHolder, ) : DropInPlatformInterface { @@ -153,12 +153,12 @@ class DropInPlatformApi( return@observe } - val model = - PlatformCommunicationModel( - PlatformCommunicationType.PAYMENT_COMPONENT, - data = message.contentIfNotHandled.toString(), + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.PAYMENT_COMPONENT, + data = message.contentIfNotHandled.toString() ) - dropInFlutterApi.onDropInPlatformCommunication(model) {} + checkoutFlutter.send(checkoutEvent) {} } } @@ -170,13 +170,13 @@ class DropInPlatformApi( } val dropInStoredPaymentMethodDeletionModel = message.contentIfNotHandled - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.DELETE_STORED_PAYMENT_METHOD, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.DELETE_STORED_PAYMENT_METHOD, data = dropInStoredPaymentMethodDeletionModel?.storedPaymentMethodId, ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(checkoutEvent) {} } } @@ -187,13 +187,13 @@ class DropInPlatformApi( return@observe } - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.ADDITIONAL_DETAILS, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.ADDITIONAL_DETAILS, data = message.contentIfNotHandled.toString(), ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(checkoutEvent) {} } } @@ -204,12 +204,12 @@ class DropInPlatformApi( return@observe } - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.BALANCE_CHECK, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.BALANCE_CHECK, data = message.contentIfNotHandled.toString() ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(checkoutEvent) {} } } @@ -220,12 +220,12 @@ class DropInPlatformApi( return@observe } - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.REQUEST_ORDER, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.REQUEST_ORDER, data = message.contentIfNotHandled.toString() ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(checkoutEvent) {} } } @@ -236,12 +236,12 @@ class DropInPlatformApi( return@observe } - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.CANCEL_ORDER, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.CANCEL_ORDER, data = message.contentIfNotHandled.toString() ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(checkoutEvent) {} } } @@ -314,14 +314,14 @@ class DropInPlatformApi( ) } - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.RESULT, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.RESULT, data = "", paymentResult = mappedResult ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(checkoutEvent) {} } val dropInAdvancedFlowCallback = @@ -353,12 +353,12 @@ class DropInPlatformApi( ) } - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.RESULT, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.RESULT, data = "", paymentResult = mappedResult ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(checkoutEvent) {} } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt index b212df59..9a1d819c 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt @@ -131,7 +131,7 @@ enum class PaymentResultEnum(val raw: Int) { } } -enum class PlatformCommunicationType(val raw: Int) { +enum class CheckoutEventType(val raw: Int) { PAYMENT_COMPONENT(0), ADDITIONAL_DETAILS(1), RESULT(2), @@ -141,7 +141,7 @@ enum class PlatformCommunicationType(val raw: Int) { CANCEL_ORDER(6); companion object { - fun ofRaw(raw: Int): PlatformCommunicationType? { + fun ofRaw(raw: Int): CheckoutEventType? { return values().firstOrNull { it.raw == raw } } } @@ -854,19 +854,19 @@ data class OrderResponseDTO ( } /** Generated class from Pigeon that represents data sent in messages. */ -data class PlatformCommunicationModel ( - val type: PlatformCommunicationType, +data class CheckoutEvent ( + val type: CheckoutEventType, val data: String? = null, val paymentResult: PaymentResultDTO? = null ) { companion object { @Suppress("LocalVariableName") - fun fromList(__pigeon_list: List): PlatformCommunicationModel { - val type = __pigeon_list[0] as PlatformCommunicationType + fun fromList(__pigeon_list: List): CheckoutEvent { + val type = __pigeon_list[0] as CheckoutEventType val data = __pigeon_list[1] as String? val paymentResult = __pigeon_list[2] as PaymentResultDTO? - return PlatformCommunicationModel(type, data, paymentResult) + return CheckoutEvent(type, data, paymentResult) } } fun toList(): List { @@ -1284,7 +1284,7 @@ private object PlatformApiPigeonCodec : StandardMessageCodec() { } 146.toByte() -> { return (readValue(buffer) as? List)?.let { - PlatformCommunicationModel.fromList(it) + CheckoutEvent.fromList(it) } } 147.toByte() -> { @@ -1379,7 +1379,7 @@ private object PlatformApiPigeonCodec : StandardMessageCodec() { } 165.toByte() -> { return (readValue(buffer) as Int?)?.let { - PlatformCommunicationType.ofRaw(it) + CheckoutEventType.ofRaw(it) } } 166.toByte() -> { @@ -1505,7 +1505,7 @@ private object PlatformApiPigeonCodec : StandardMessageCodec() { stream.write(145) writeValue(stream, value.toList()) } - is PlatformCommunicationModel -> { + is CheckoutEvent -> { stream.write(146) writeValue(stream, value.toList()) } @@ -1581,7 +1581,7 @@ private object PlatformApiPigeonCodec : StandardMessageCodec() { stream.write(164) writeValue(stream, value.raw) } - is PlatformCommunicationType -> { + is CheckoutEventType -> { stream.write(165) writeValue(stream, value.raw) } @@ -2011,19 +2011,19 @@ interface DropInPlatformInterface { } } /** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ -class DropInFlutterInterface(private val binaryMessenger: BinaryMessenger, private val messageChannelSuffix: String = "") { +class CheckoutFlutterInterface(private val binaryMessenger: BinaryMessenger, private val messageChannelSuffix: String = "") { companion object { - /** The codec used by DropInFlutterInterface. */ + /** The codec used by CheckoutFlutterInterface. */ val codec: MessageCodec by lazy { PlatformApiPigeonCodec } } - fun onDropInPlatformCommunication(platformCommunicationModelArg: PlatformCommunicationModel, callback: (Result) -> Unit) + fun send(eventArg: CheckoutEvent, callback: (Result) -> Unit) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" - val channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication$separatedMessageChannelSuffix" + val channelName = "dev.flutter.pigeon.adyen_checkout.CheckoutFlutterInterface.send$separatedMessageChannelSuffix" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(platformCommunicationModelArg)) { + channel.send(listOf(eventArg)) { if (it is List<*>) { if (it.size > 1) { callback(Result.failure(AdyenPigeonError(it[0] as String, it[1] as String, it[2] as String?))) diff --git a/ios/Classes/AdyenCheckoutPlugin.swift b/ios/Classes/AdyenCheckoutPlugin.swift index f88a87a4..25c5ad0d 100644 --- a/ios/Classes/AdyenCheckoutPlugin.swift +++ b/ios/Classes/AdyenCheckoutPlugin.swift @@ -6,10 +6,10 @@ public class AdyenCheckoutPlugin: NSObject, FlutterPlugin { public static func register(with registrar: FlutterPluginRegistrar) { let sessionHolder = SessionHolder() let messenger: FlutterBinaryMessenger = registrar.messenger() - let dropInFlutterApi = DropInFlutterInterface(binaryMessenger: messenger) + let checkoutFlutter = CheckoutFlutterInterface(binaryMessenger: messenger) let componentFlutterApi = ComponentFlutterInterface(binaryMessenger: messenger) let checkoutPlatformApi = CheckoutPlatformApi( - dropInFlutterApi: dropInFlutterApi, + checkoutFlutter: checkoutFlutter, componentFlutterApi: componentFlutterApi, sessionHolder: sessionHolder ) @@ -18,7 +18,7 @@ public class AdyenCheckoutPlugin: NSObject, FlutterPlugin { ComponentPlatformInterfaceSetup.setUp(binaryMessenger: messenger, api: componentPlatformApi) CheckoutPlatformInterfaceSetup.setUp(binaryMessenger: messenger, api: checkoutPlatformApi) - let dropInPlatformApi = DropInPlatformApi(dropInFlutterApi: dropInFlutterApi, sessionHolder: sessionHolder) + let dropInPlatformApi = DropInPlatformApi(checkoutFlutter: checkoutFlutter, sessionHolder: sessionHolder) DropInPlatformInterfaceSetup.setUp(binaryMessenger: messenger, api: dropInPlatformApi) let cardComponentAdvancedFactory = CardComponentFactory( diff --git a/ios/Classes/CheckoutPlatformApi.swift b/ios/Classes/CheckoutPlatformApi.swift index 96e51838..579e0938 100644 --- a/ios/Classes/CheckoutPlatformApi.swift +++ b/ios/Classes/CheckoutPlatformApi.swift @@ -8,17 +8,17 @@ import AdyenNetworking // 3) Add AppDelegate redirect class CheckoutPlatformApi: CheckoutPlatformInterface { - private let dropInFlutterApi: DropInFlutterInterface + private let checkoutFlutter: CheckoutFlutterInterface private let componentFlutterApi: ComponentFlutterInterface private let sessionHolder: SessionHolder private let adyenCse: AdyenCSE = .init() init( - dropInFlutterApi: DropInFlutterInterface, + checkoutFlutter: CheckoutFlutterInterface, componentFlutterApi: ComponentFlutterInterface, sessionHolder: SessionHolder ) { - self.dropInFlutterApi = dropInFlutterApi + self.checkoutFlutter = checkoutFlutter self.componentFlutterApi = componentFlutterApi self.sessionHolder = sessionHolder } @@ -103,7 +103,7 @@ class CheckoutPlatformApi: CheckoutPlatformInterface { sessionData: String, completion: @escaping (Result) -> Void ) throws { - let sessionDelegate = DropInSessionsDelegate(viewController: getViewController(), dropInFlutterApi: dropInFlutterApi) + let sessionDelegate = DropInSessionsDelegate(viewController: getViewController(), checkoutFlutter: checkoutFlutter) try requestAndSetSession( adyenContext: adyenContext, sessionId: sessionId, diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 75274158..b3c88add 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -4,7 +4,7 @@ import AdyenNetworking class DropInPlatformApi: DropInPlatformInterface { private let jsonDecoder = JSONDecoder() - private let dropInFlutterApi: DropInFlutterInterface + private let checkoutFlutter: CheckoutFlutterInterface private let sessionHolder: SessionHolder private var hostViewController: UIViewController? private var dropInViewController: DropInViewController? @@ -15,10 +15,10 @@ class DropInPlatformApi: DropInPlatformInterface { private var requestOrderHandler: ((Result) -> Void)? init( - dropInFlutterApi: DropInFlutterInterface, + checkoutFlutter: CheckoutFlutterInterface, sessionHolder: SessionHolder ) { - self.dropInFlutterApi = dropInFlutterApi + self.checkoutFlutter = checkoutFlutter self.sessionHolder = sessionHolder } @@ -37,7 +37,7 @@ class DropInPlatformApi: DropInPlatformInterface { let adyenContext = try dropInConfigurationDTO.createAdyenContext() dropInSessionStoredPaymentMethodsDelegate = DropInSessionsStoredPaymentMethodsDelegate( viewController: viewController, - dropInFlutterApi: dropInFlutterApi + checkoutFlutter: checkoutFlutter ) let payment = session.sessionContext.payment ?? adyenContext.payment let dropInConfiguration = try dropInConfigurationDTO.createDropInConfiguration(payment: payment) @@ -94,7 +94,7 @@ class DropInPlatformApi: DropInPlatformInterface { configuration: configuration, title: dropInConfigurationDTO.preselectedPaymentMethodTitle ) - dropInAdvancedFlowDelegate = DropInAdvancedFlowDelegate(dropInFlutterApi: dropInFlutterApi) + dropInAdvancedFlowDelegate = DropInAdvancedFlowDelegate(checkoutFlutter: checkoutFlutter) dropInAdvancedFlowDelegate?.dropInInteractorDelegate = self dropInComponent.delegate = dropInAdvancedFlowDelegate if dropInConfigurationDTO.isPartialPaymentSupported { @@ -103,7 +103,7 @@ class DropInPlatformApi: DropInPlatformInterface { if dropInConfigurationDTO.isRemoveStoredPaymentMethodEnabled == true { dropInAdvancedFlowStoredPaymentMethodsDelegate = DropInAdvancedFlowStoredPaymentMethodsDelegate( viewController: viewController, - dropInFlutterApi: dropInFlutterApi + checkoutFlutter: checkoutFlutter ) dropInComponent.storedPaymentMethodsDelegate = dropInAdvancedFlowStoredPaymentMethodsDelegate } @@ -112,12 +112,12 @@ class DropInPlatformApi: DropInPlatformInterface { self.dropInViewController = dropInViewController self.hostViewController?.present(dropInViewController, animated: false) } catch { - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.result, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.result, paymentResult: PaymentResultDTO(type: PaymentResultEnum.error, reason: error.localizedDescription) ) - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } @@ -198,11 +198,9 @@ class DropInPlatformApi: DropInPlatformInterface { result: PaymentResultModelDTO( resultCode: resultCode?.rawValue) ) - self?.dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: PlatformCommunicationModel( - type: PlatformCommunicationType.result, - paymentResult: paymentResult - ), + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, paymentResult: paymentResult) + self?.checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) }) @@ -215,11 +213,9 @@ class DropInPlatformApi: DropInPlatformInterface { dropInViewController?.dropInComponent.handle(result) } catch { let paymentResult = PaymentResultDTO(type: PaymentResultEnum.error, reason: error.localizedDescription) - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: PlatformCommunicationModel( - type: PlatformCommunicationType.result, - paymentResult: paymentResult - ), + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, paymentResult: paymentResult) + checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) finalizeAndDismiss(success: false) {} @@ -232,11 +228,9 @@ class DropInPlatformApi: DropInPlatformInterface { if paymentEventDTO.error?.dismissDropIn == true || dropInAdvancedFlowDelegate?.isApplePay == true { finalizeAndDismiss(success: false) { [weak self] in let paymentResult = PaymentResultDTO(type: PaymentResultEnum.error, reason: paymentEventDTO.error?.errorMessage) - self?.dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: PlatformCommunicationModel( - type: PlatformCommunicationType.result, - paymentResult: paymentResult - ), + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, paymentResult: paymentResult) + self?.checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } @@ -288,15 +282,15 @@ class DropInPlatformApi: DropInPlatformInterface { } private func sendSessionError(error: Error) { - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.result, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.result, paymentResult: PaymentResultDTO( type: PaymentResultEnum.error, reason: error.localizedDescription ) ) - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } @@ -347,11 +341,11 @@ extension DropInPlatformApi: PartialPaymentDelegate { func checkBalance(with data: Adyen.PaymentComponentData, component: any Adyen.Component, completion: @escaping (Result) -> Void) { do { checkBalanceHandler = completion - let platformCommunicationModel = try PlatformCommunicationModel( - type: PlatformCommunicationType.balanceCheck, + let checkoutEvent = try CheckoutEvent( + type: CheckoutEventType.balanceCheck, data: data.jsonObject.toJsonStringRepresentation() ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + checkoutFlutter.send(event: checkoutEvent, completion: { _ in }) } catch { completion(.failure(error)) } @@ -359,8 +353,8 @@ extension DropInPlatformApi: PartialPaymentDelegate { func requestOrder(for component: any Adyen.Component, completion: @escaping (Result) -> Void) { requestOrderHandler = completion - let platformCommunicationModel = PlatformCommunicationModel(type: PlatformCommunicationType.requestOrder) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.requestOrder) + checkoutFlutter.send(event: checkoutEvent, completion: { _ in }) } func cancelOrder(_ order: Adyen.PartialPaymentOrder, component: any Adyen.Component) { @@ -371,8 +365,8 @@ extension DropInPlatformApi: PartialPaymentDelegate { ] let data = try JSONSerialization.data(withJSONObject: cancelOrderData, options: []) let cancelOrderDataString = String(data: data, encoding: .utf8) - let platformCommunicationModel = PlatformCommunicationModel(type: PlatformCommunicationType.cancelOrder, data: cancelOrderDataString) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.cancelOrder, data: cancelOrderDataString) + checkoutFlutter.send(event: checkoutEvent, completion: { _ in }) } catch { adyenPrint(error.localizedDescription) } diff --git a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift index e801200c..7b5050a2 100644 --- a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift +++ b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift @@ -2,12 +2,12 @@ import Adyen import AdyenNetworking class DropInAdvancedFlowDelegate: DropInComponentDelegate { - private let dropInFlutterApi: DropInFlutterInterface + private let checkoutFlutter: CheckoutFlutterInterface public weak var dropInInteractorDelegate: DropInInteractorDelegate? var isApplePay: Bool = false - init(dropInFlutterApi: DropInFlutterInterface) { - self.dropInFlutterApi = dropInFlutterApi + init(checkoutFlutter: CheckoutFlutterInterface) { + self.checkoutFlutter = checkoutFlutter } func didSubmit(_ data: PaymentComponentData, from paymentComponent: PaymentComponent, in _: AnyDropInComponent) { @@ -19,12 +19,12 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { extra: applePayDetails?.getExtraData() ) let submitDataEncoded = try submitData.toJsonString() - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.paymentComponent, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.paymentComponent, data: submitDataEncoded ) - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } catch { @@ -39,11 +39,9 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { let actionComponentData = ActionComponentDataModel(details: data.details.encodable, paymentData: data.paymentData) let actionComponentDataJson = try JSONEncoder().encode(actionComponentData) let actionComponentDataString = String(data: actionComponentDataJson, encoding: .utf8) - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: PlatformCommunicationModel( - type: PlatformCommunicationType.additionalDetails, - data: actionComponentDataString - ), + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.additionalDetails, data: actionComponentDataString) + checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } catch { @@ -59,12 +57,12 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { type: PaymentResultEnum.finished, result: PaymentResultModelDTO(resultCode: ResultCode.received.rawValue) ) - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.result, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.result, paymentResult: paymentResult ) - self?.dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + self?.checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } @@ -86,15 +84,15 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { dropInInteractorDelegate?.finalizeAndDismiss(success: false) { [weak self] in switch error { case ComponentError.cancelled: - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.result, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.result, paymentResult: PaymentResultDTO( type: PaymentResultEnum.cancelledByUser, reason: error.localizedDescription ) ) - self?.dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + self?.checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) default: @@ -104,13 +102,13 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { } private func sendErrorToFlutterLayer(error: Error) { - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.result, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.result, paymentResult: PaymentResultDTO( type: PaymentResultEnum.error, reason: error.localizedDescription ) ) - dropInFlutterApi.onDropInPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + checkoutFlutter.send(event: checkoutEvent, completion: { _ in }) } } diff --git a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowStoredPaymentMethodsDelegate.swift b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowStoredPaymentMethodsDelegate.swift index 1032e964..12583df3 100644 --- a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowStoredPaymentMethodsDelegate.swift +++ b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowStoredPaymentMethodsDelegate.swift @@ -2,23 +2,23 @@ import Adyen class DropInAdvancedFlowStoredPaymentMethodsDelegate: StoredPaymentMethodsDelegate { - private let dropInFlutterApi: DropInFlutterInterface + private let checkoutFlutter: CheckoutFlutterInterface private let viewController: UIViewController private var completionHandler: ((Bool) -> Void)? - init(viewController: UIViewController, dropInFlutterApi: DropInFlutterInterface) { - self.dropInFlutterApi = dropInFlutterApi + init(viewController: UIViewController, checkoutFlutter: CheckoutFlutterInterface) { + self.checkoutFlutter = checkoutFlutter self.viewController = viewController } func disable(storedPaymentMethod: StoredPaymentMethod, completion: @escaping (Bool) -> Void) { completionHandler = completion - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.deleteStoredPaymentMethod, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.deleteStoredPaymentMethod, data: storedPaymentMethod.identifier ) - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } diff --git a/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift b/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift index 1d82b7ce..af653fd2 100644 --- a/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift +++ b/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift @@ -3,60 +3,60 @@ import AdyenNetworking class DropInSessionsDelegate: AdyenSessionDelegate { private let viewController: UIViewController? - private let dropInFlutterApi: DropInFlutterInterface + private let checkoutFlutter: CheckoutFlutterInterface - init(viewController: UIViewController?, dropInFlutterApi: DropInFlutterInterface) { + init(viewController: UIViewController?, checkoutFlutter: CheckoutFlutterInterface) { self.viewController = viewController - self.dropInFlutterApi = dropInFlutterApi + self.checkoutFlutter = checkoutFlutter } func didComplete(with result: Adyen.AdyenSessionResult, component _: Adyen.Component, session: Adyen.AdyenSession) { - viewController?.dismiss(animated: true, completion: { + viewController?.dismiss(animated: true, completion: { [weak self] in let paymentResult = PaymentResultModelDTO( sessionId: session.sessionContext.identifier, sessionData: session.sessionContext.data, sessionResult: result.encodedResult, resultCode: result.resultCode.rawValue ) - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.result, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.result, paymentResult: PaymentResultDTO( type: PaymentResultEnum.finished, result: paymentResult ) ) - self.dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + self?.checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) }) } func didFail(with error: Error, from _: Component, session _: AdyenSession) { - viewController?.dismiss(animated: true, completion: { + viewController?.dismiss(animated: true, completion: { [weak self] in switch error { case ComponentError.cancelled: - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.result, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.result, paymentResult: PaymentResultDTO( type: PaymentResultEnum.cancelledByUser, reason: error.localizedDescription ) ) - self.dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + self?.checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) default: - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.result, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.result, paymentResult: PaymentResultDTO( type: PaymentResultEnum.error, reason: error.localizedDescription ) ) - self.dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + self?.checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } diff --git a/ios/Classes/dropIn/dropInSessions/DropInSessionsStoredPaymentMethodsDelegate.swift b/ios/Classes/dropIn/dropInSessions/DropInSessionsStoredPaymentMethodsDelegate.swift index eeafae53..0ea5ce13 100644 --- a/ios/Classes/dropIn/dropInSessions/DropInSessionsStoredPaymentMethodsDelegate.swift +++ b/ios/Classes/dropIn/dropInSessions/DropInSessionsStoredPaymentMethodsDelegate.swift @@ -2,23 +2,23 @@ import Adyen class DropInSessionsStoredPaymentMethodsDelegate: StoredPaymentMethodsDelegate { - private let dropInFlutterApi: DropInFlutterInterface + private let checkoutFlutter: CheckoutFlutterInterface private let viewController: UIViewController private var completionHandler: ((Bool) -> Void)? - init(viewController: UIViewController, dropInFlutterApi: DropInFlutterInterface) { - self.dropInFlutterApi = dropInFlutterApi + init(viewController: UIViewController, checkoutFlutter: CheckoutFlutterInterface) { + self.checkoutFlutter = checkoutFlutter self.viewController = viewController } func disable(storedPaymentMethod: StoredPaymentMethod, completion: @escaping (Bool) -> Void) { completionHandler = completion - let platformCommunicationModel = PlatformCommunicationModel( - type: PlatformCommunicationType.deleteStoredPaymentMethod, + let checkoutEvent = CheckoutEvent( + type: CheckoutEventType.deleteStoredPaymentMethod, data: storedPaymentMethod.identifier ) - dropInFlutterApi.onDropInPlatformCommunication( - platformCommunicationModel: platformCommunicationModel, + checkoutFlutter.send( + event: checkoutEvent, completion: { _ in } ) } diff --git a/ios/Classes/generated/PlatformApi.swift b/ios/Classes/generated/PlatformApi.swift index f27f3b89..ed4dbad8 100644 --- a/ios/Classes/generated/PlatformApi.swift +++ b/ios/Classes/generated/PlatformApi.swift @@ -109,7 +109,7 @@ enum PaymentResultEnum: Int { case finished = 2 } -enum PlatformCommunicationType: Int { +enum CheckoutEventType: Int { case paymentComponent = 0 case additionalDetails = 1 case result = 2 @@ -869,18 +869,18 @@ struct OrderResponseDTO { } /// Generated class from Pigeon that represents data sent in messages. -struct PlatformCommunicationModel { - var type: PlatformCommunicationType +struct CheckoutEvent { + var type: CheckoutEventType var data: String? var paymentResult: PaymentResultDTO? // swift-format-ignore: AlwaysUseLowerCamelCase - static func fromList(_ __pigeon_list: [Any?]) -> PlatformCommunicationModel? { - let type = __pigeon_list[0] as! PlatformCommunicationType + static func fromList(_ __pigeon_list: [Any?]) -> CheckoutEvent? { + let type = __pigeon_list[0] as! CheckoutEventType let data: String? = nilOrValue(__pigeon_list[1]) let paymentResult: PaymentResultDTO? = nilOrValue(__pigeon_list[2]) - return PlatformCommunicationModel( + return CheckoutEvent( type: type, data: data, paymentResult: paymentResult @@ -1298,7 +1298,7 @@ private class PlatformApiPigeonCodecReader: FlutterStandardReader { case 145: return OrderResponseDTO.fromList(self.readValue() as! [Any?]) case 146: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + return CheckoutEvent.fromList(self.readValue() as! [Any?]) case 147: return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) case 148: @@ -1371,10 +1371,10 @@ private class PlatformApiPigeonCodecReader: FlutterStandardReader { } return enumResult case 165: - var enumResult: PlatformCommunicationType? = nil + var enumResult: CheckoutEventType? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { - enumResult = PlatformCommunicationType(rawValue: enumResultAsInt) + enumResult = CheckoutEventType(rawValue: enumResultAsInt) } return enumResult case 166: @@ -1506,7 +1506,7 @@ private class PlatformApiPigeonCodecWriter: FlutterStandardWriter { } else if let value = value as? OrderResponseDTO { super.writeByte(145) super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { + } else if let value = value as? CheckoutEvent { super.writeByte(146) super.writeValue(value.toList()) } else if let value = value as? ComponentCommunicationModel { @@ -1563,7 +1563,7 @@ private class PlatformApiPigeonCodecWriter: FlutterStandardWriter { } else if let value = value as? PaymentResultEnum { super.writeByte(164) super.writeValue(value.rawValue) - } else if let value = value as? PlatformCommunicationType { + } else if let value = value as? CheckoutEventType { super.writeByte(165) super.writeValue(value.rawValue) } else if let value = value as? ComponentCommunicationType { @@ -1941,11 +1941,11 @@ class DropInPlatformInterfaceSetup { } /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. -protocol DropInFlutterInterfaceProtocol { - func onDropInPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) +protocol CheckoutFlutterInterfaceProtocol { + func send(event eventArg: CheckoutEvent, completion: @escaping (Result) -> Void) } -class DropInFlutterInterface: DropInFlutterInterfaceProtocol { +class CheckoutFlutterInterface: CheckoutFlutterInterfaceProtocol { private let binaryMessenger: FlutterBinaryMessenger private let messageChannelSuffix: String init(binaryMessenger: FlutterBinaryMessenger, messageChannelSuffix: String = "") { @@ -1957,10 +1957,10 @@ class DropInFlutterInterface: DropInFlutterInterfaceProtocol { PlatformApiPigeonCodec.shared } - func onDropInPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { - let channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication\(messageChannelSuffix)" + func send(event eventArg: CheckoutEvent, completion: @escaping (Result) -> Void) { + let channelName = "dev.flutter.pigeon.adyen_checkout.CheckoutFlutterInterface.send\(messageChannelSuffix)" let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([platformCommunicationModelArg] as [Any?]) { response in + channel.sendMessage([eventArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return diff --git a/lib/src/adyen_checkout.dart b/lib/src/adyen_checkout.dart index bd51ed0e..fb3f0753 100644 --- a/lib/src/adyen_checkout.dart +++ b/lib/src/adyen_checkout.dart @@ -5,9 +5,9 @@ import 'package:adyen_checkout/src/adyen_checkout_interface.dart'; import 'package:adyen_checkout/src/common/adyen_checkout_advanced.dart'; import 'package:adyen_checkout/src/common/adyen_checkout_api.dart'; import 'package:adyen_checkout/src/common/adyen_checkout_session.dart'; +import 'package:adyen_checkout/src/common/checkout_flutter.dart'; import 'package:adyen_checkout/src/components/action_handling/action_component.dart'; import 'package:adyen_checkout/src/drop_in/drop_in.dart'; -import 'package:adyen_checkout/src/drop_in/drop_in_flutter_api.dart'; import 'package:adyen_checkout/src/drop_in/drop_in_platform_api.dart'; import 'package:adyen_checkout/src/generated/platform_api.g.dart'; import 'package:adyen_checkout/src/logging/adyen_logger.dart'; @@ -22,7 +22,7 @@ class AdyenCheckout implements AdyenCheckoutInterface { static final AdyenCheckoutApi _adyenCheckoutApi = AdyenCheckoutApi(); static final DropIn _dropIn = DropIn( SdkVersionNumberProvider.instance, - DropInFlutterApi(), + CheckoutFlutter(), DropInPlatformApi(), ); diff --git a/lib/src/common/checkout_flutter.dart b/lib/src/common/checkout_flutter.dart new file mode 100644 index 00000000..e66d7beb --- /dev/null +++ b/lib/src/common/checkout_flutter.dart @@ -0,0 +1,10 @@ +import 'dart:async'; + +import 'package:adyen_checkout/src/generated/platform_api.g.dart'; + +class CheckoutFlutter implements CheckoutFlutterInterface { + StreamController? platformEventStream; + + @override + void send(CheckoutEvent event) => platformEventStream?.sink.add(event); +} diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index eb97ef6a..4b410f5e 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:adyen_checkout/adyen_checkout.dart'; -import 'package:adyen_checkout/src/drop_in/drop_in_flutter_api.dart'; +import 'package:adyen_checkout/src/common/checkout_flutter.dart'; import 'package:adyen_checkout/src/drop_in/drop_in_platform_api.dart'; import 'package:adyen_checkout/src/generated/platform_api.g.dart'; import 'package:adyen_checkout/src/logging/adyen_logger.dart'; @@ -14,16 +14,16 @@ import 'package:adyen_checkout/src/util/sdk_version_number_provider.dart'; class DropIn { DropIn( this.sdkVersionNumberProvider, - this.dropInFlutterApi, + this.checkoutFlutter, this.dropInPlatformApi, ) { - DropInFlutterInterface.setUp(dropInFlutterApi); + CheckoutFlutterInterface.setUp(checkoutFlutter); } final PaymentEventHandler _paymentEventHandler = PaymentEventHandler(); final AdyenLogger adyenLogger = AdyenLogger.instance; final SdkVersionNumberProvider sdkVersionNumberProvider; - final DropInFlutterApi dropInFlutterApi; + final CheckoutFlutter checkoutFlutter; final DropInPlatformApi dropInPlatformApi; Future startDropInSessionsPayment( @@ -39,15 +39,13 @@ class DropIn { dropInConfiguration.toDTO(sdkVersionNumber, true), ); - dropInFlutterApi.dropInPlatformCommunicationStream = - StreamController(); - final platformCommunicationSubscription = dropInFlutterApi - .dropInPlatformCommunicationStream?.stream - .listen((event) async { + checkoutFlutter.platformEventStream = StreamController(); + final platformEventSubscription = + checkoutFlutter.platformEventStream?.stream.listen((event) async { switch (event.type) { - case PlatformCommunicationType.result: + case CheckoutEventType.result: dropInSessionCompleter.complete(event.paymentResult); - case PlatformCommunicationType.deleteStoredPaymentMethod: + case CheckoutEventType.deleteStoredPaymentMethod: _onDeleteStoredPaymentMethodCallback( event, dropInConfiguration.storedPaymentMethodConfiguration, @@ -58,9 +56,9 @@ class DropIn { return dropInSessionCompleter.future.then((paymentResultDTO) async { dropInPlatformApi.cleanUpDropIn(); - await platformCommunicationSubscription?.cancel(); - dropInFlutterApi.dropInPlatformCommunicationStream?.close(); - dropInFlutterApi.dropInPlatformCommunicationStream = null; + await platformEventSubscription?.cancel(); + checkoutFlutter.platformEventStream?.close(); + checkoutFlutter.platformEventStream = null; adyenLogger .print("Drop-in session result type: ${paymentResultDTO.type.name}"); adyenLogger.print( @@ -104,37 +102,35 @@ class DropIn { encodedPaymentMethodsResponse, ); - dropInFlutterApi.dropInPlatformCommunicationStream = - StreamController(); - final platformCommunicationSubscription = dropInFlutterApi - .dropInPlatformCommunicationStream?.stream - .listen((event) async { + checkoutFlutter.platformEventStream = StreamController(); + final platformEventSubscription = + checkoutFlutter.platformEventStream?.stream.listen((event) async { switch (event.type) { - case PlatformCommunicationType.paymentComponent: + case CheckoutEventType.paymentComponent: await _handlePaymentComponent(event, advancedCheckout); - case PlatformCommunicationType.additionalDetails: + case CheckoutEventType.additionalDetails: await _handleAdditionalDetails(event, advancedCheckout); - case PlatformCommunicationType.result: + case CheckoutEventType.result: _handleResult(dropInAdvancedFlowCompleter, event); - case PlatformCommunicationType.deleteStoredPaymentMethod: + case CheckoutEventType.deleteStoredPaymentMethod: _onDeleteStoredPaymentMethodCallback( event, dropInConfiguration.storedPaymentMethodConfiguration, ); - case PlatformCommunicationType.balanceCheck: + case CheckoutEventType.balanceCheck: _handleBalanceCheck(event, advancedCheckout.partialPayment); - case PlatformCommunicationType.requestOrder: + case CheckoutEventType.requestOrder: _handleOrderRequest(event, advancedCheckout.partialPayment); - case PlatformCommunicationType.cancelOrder: + case CheckoutEventType.cancelOrder: _handleOrderCancel(event, advancedCheckout.partialPayment); } }); return dropInAdvancedFlowCompleter.future.then((paymentResultDTO) async { dropInPlatformApi.cleanUpDropIn(); - await platformCommunicationSubscription?.cancel(); - await dropInFlutterApi.dropInPlatformCommunicationStream?.close(); - dropInFlutterApi.dropInPlatformCommunicationStream = null; + await platformEventSubscription?.cancel(); + await checkoutFlutter.platformEventStream?.close(); + checkoutFlutter.platformEventStream = null; adyenLogger.print( "Drop-in advanced flow result type: ${paymentResultDTO.type.name}"); adyenLogger.print( @@ -152,13 +148,13 @@ class DropIn { void _handleResult( Completer dropInAdvancedFlowCompleter, - PlatformCommunicationModel event, + CheckoutEvent event, ) { dropInAdvancedFlowCompleter.complete(event.paymentResult); } Future _handlePaymentComponent( - PlatformCommunicationModel event, + CheckoutEvent event, Checkout advancedCheckout, ) async { try { @@ -186,7 +182,7 @@ class DropIn { } Future _handleAdditionalDetails( - PlatformCommunicationModel event, + CheckoutEvent event, Checkout advancedCheckout, ) async { try { @@ -214,7 +210,7 @@ class DropIn { } Future _onDeleteStoredPaymentMethodCallback( - PlatformCommunicationModel event, + CheckoutEvent event, StoredPaymentMethodConfiguration? storedPaymentMethodConfiguration, ) async { final String? storedPaymentMethodId = event.data; @@ -241,7 +237,7 @@ class DropIn { } Future _getOnSubmitPaymentEvent( - PlatformCommunicationModel event, Checkout advancedCheckout) async { + CheckoutEvent event, Checkout advancedCheckout) async { final String submitData = (event.data as String); final Map submitDataDecoded = jsonDecode(submitData); switch (advancedCheckout) { @@ -272,7 +268,7 @@ class DropIn { } Future _getOnAdditionalDetailsPaymentEvent( - PlatformCommunicationModel event, Checkout advancedCheckout) async { + CheckoutEvent event, Checkout advancedCheckout) async { switch (advancedCheckout) { case AdvancedCheckout it: final additionalDetails = jsonDecode(event.data as String); @@ -283,7 +279,7 @@ class DropIn { } void _handleBalanceCheck( - PlatformCommunicationModel event, + CheckoutEvent event, PartialPayment? partialPayment, ) async { try { @@ -301,7 +297,7 @@ class DropIn { } void _handleOrderRequest( - PlatformCommunicationModel event, + CheckoutEvent event, PartialPayment? partialPayment, ) async { try { @@ -313,7 +309,7 @@ class DropIn { } void _handleOrderCancel( - PlatformCommunicationModel event, + CheckoutEvent event, PartialPayment? partialPayment, ) async { try { diff --git a/lib/src/drop_in/drop_in_flutter_api.dart b/lib/src/drop_in/drop_in_flutter_api.dart deleted file mode 100644 index 92c5215e..00000000 --- a/lib/src/drop_in/drop_in_flutter_api.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'dart:async'; - -import 'package:adyen_checkout/src/generated/platform_api.g.dart'; - -class DropInFlutterApi implements DropInFlutterInterface { - StreamController? - dropInPlatformCommunicationStream; - - @override - void onDropInPlatformCommunication( - PlatformCommunicationModel platformCommunicationModel) => - dropInPlatformCommunicationStream?.sink.add(platformCommunicationModel); -} diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index 8601e43d..71e2c7b4 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -68,7 +68,7 @@ enum PaymentResultEnum { finished, } -enum PlatformCommunicationType { +enum CheckoutEventType { paymentComponent, additionalDetails, result, @@ -935,14 +935,14 @@ class OrderResponseDTO { } } -class PlatformCommunicationModel { - PlatformCommunicationModel({ +class CheckoutEvent { + CheckoutEvent({ required this.type, this.data, this.paymentResult, }); - PlatformCommunicationType type; + CheckoutEventType type; String? data; @@ -956,10 +956,10 @@ class PlatformCommunicationModel { ]; } - static PlatformCommunicationModel decode(Object result) { + static CheckoutEvent decode(Object result) { result as List; - return PlatformCommunicationModel( - type: result[0]! as PlatformCommunicationType, + return CheckoutEvent( + type: result[0]! as CheckoutEventType, data: result[1] as String?, paymentResult: result[2] as PaymentResultDTO?, ); @@ -1434,7 +1434,7 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is OrderResponseDTO) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is PlatformCommunicationModel) { + } else if (value is CheckoutEvent) { buffer.putUint8(146); writeValue(buffer, value.encode()); } else if (value is ComponentCommunicationModel) { @@ -1491,7 +1491,7 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is PaymentResultEnum) { buffer.putUint8(164); writeValue(buffer, value.index); - } else if (value is PlatformCommunicationType) { + } else if (value is CheckoutEventType) { buffer.putUint8(165); writeValue(buffer, value.index); } else if (value is ComponentCommunicationType) { @@ -1567,7 +1567,7 @@ class _PigeonCodec extends StandardMessageCodec { case 145: return OrderResponseDTO.decode(readValue(buffer)!); case 146: - return PlatformCommunicationModel.decode(readValue(buffer)!); + return CheckoutEvent.decode(readValue(buffer)!); case 147: return ComponentCommunicationModel.decode(readValue(buffer)!); case 148: @@ -1613,7 +1613,7 @@ class _PigeonCodec extends StandardMessageCodec { return value == null ? null : PaymentResultEnum.values[value]; case 165: final int? value = readValue(buffer) as int?; - return value == null ? null : PlatformCommunicationType.values[value]; + return value == null ? null : CheckoutEventType.values[value]; case 166: final int? value = readValue(buffer) as int?; return value == null ? null : ComponentCommunicationType.values[value]; @@ -2168,14 +2168,13 @@ class DropInPlatformInterface { } } -abstract class DropInFlutterInterface { +abstract class CheckoutFlutterInterface { static const MessageCodec pigeonChannelCodec = _PigeonCodec(); - void onDropInPlatformCommunication( - PlatformCommunicationModel platformCommunicationModel); + void send(CheckoutEvent event); static void setUp( - DropInFlutterInterface? api, { + CheckoutFlutterInterface? api, { BinaryMessenger? binaryMessenger, String messageChannelSuffix = '', }) { @@ -2184,7 +2183,7 @@ abstract class DropInFlutterInterface { { final BasicMessageChannel __pigeon_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication$messageChannelSuffix', + 'dev.flutter.pigeon.adyen_checkout.CheckoutFlutterInterface.send$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { @@ -2192,14 +2191,13 @@ abstract class DropInFlutterInterface { } else { __pigeon_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication was null.'); + 'Argument for dev.flutter.pigeon.adyen_checkout.CheckoutFlutterInterface.send was null.'); final List args = (message as List?)!; - final PlatformCommunicationModel? arg_platformCommunicationModel = - (args[0] as PlatformCommunicationModel?); - assert(arg_platformCommunicationModel != null, - 'Argument for dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInPlatformCommunication was null, expected non-null PlatformCommunicationModel.'); + final CheckoutEvent? arg_event = (args[0] as CheckoutEvent?); + assert(arg_event != null, + 'Argument for dev.flutter.pigeon.adyen_checkout.CheckoutFlutterInterface.send was null, expected non-null CheckoutEvent.'); try { - api.onDropInPlatformCommunication(arg_platformCommunicationModel!); + api.send(arg_event!); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 5efdb299..9d57c560 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -56,7 +56,7 @@ enum PaymentResultEnum { finished, } -enum PlatformCommunicationType { +enum CheckoutEventType { paymentComponent, additionalDetails, result, @@ -436,12 +436,12 @@ class OrderResponseDTO { }); } -class PlatformCommunicationModel { - final PlatformCommunicationType type; +class CheckoutEvent { + final CheckoutEventType type; final String? data; final PaymentResultDTO? paymentResult; - PlatformCommunicationModel({ + CheckoutEvent({ required this.type, this.data, this.paymentResult, @@ -678,9 +678,8 @@ abstract class DropInPlatformInterface { } @FlutterApi() -abstract class DropInFlutterInterface { - void onDropInPlatformCommunication( - PlatformCommunicationModel platformCommunicationModel); +abstract class CheckoutFlutterInterface { + void send(CheckoutEvent event); } @HostApi() From 7441e5e1c496e69bfeb926516ccd561fadeb2b79 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Mon, 10 Feb 2025 09:41:13 +0100 Subject: [PATCH 5/7] Adjusted naming for complying with scope --- lib/src/adyen_checkout.dart | 4 ++-- lib/src/drop_in/drop_in.dart | 24 +++++++++---------- .../drop_in_flutter.dart} | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) rename lib/src/{common/checkout_flutter.dart => drop_in/drop_in_flutter.dart} (79%) diff --git a/lib/src/adyen_checkout.dart b/lib/src/adyen_checkout.dart index fb3f0753..9c4ac123 100644 --- a/lib/src/adyen_checkout.dart +++ b/lib/src/adyen_checkout.dart @@ -5,9 +5,9 @@ import 'package:adyen_checkout/src/adyen_checkout_interface.dart'; import 'package:adyen_checkout/src/common/adyen_checkout_advanced.dart'; import 'package:adyen_checkout/src/common/adyen_checkout_api.dart'; import 'package:adyen_checkout/src/common/adyen_checkout_session.dart'; -import 'package:adyen_checkout/src/common/checkout_flutter.dart'; import 'package:adyen_checkout/src/components/action_handling/action_component.dart'; import 'package:adyen_checkout/src/drop_in/drop_in.dart'; +import 'package:adyen_checkout/src/drop_in/drop_in_flutter.dart'; import 'package:adyen_checkout/src/drop_in/drop_in_platform_api.dart'; import 'package:adyen_checkout/src/generated/platform_api.g.dart'; import 'package:adyen_checkout/src/logging/adyen_logger.dart'; @@ -22,7 +22,7 @@ class AdyenCheckout implements AdyenCheckoutInterface { static final AdyenCheckoutApi _adyenCheckoutApi = AdyenCheckoutApi(); static final DropIn _dropIn = DropIn( SdkVersionNumberProvider.instance, - CheckoutFlutter(), + DropInFlutter(), DropInPlatformApi(), ); diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 4b410f5e..dd79c0ea 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:adyen_checkout/adyen_checkout.dart'; -import 'package:adyen_checkout/src/common/checkout_flutter.dart'; +import 'package:adyen_checkout/src/drop_in/drop_in_flutter.dart'; import 'package:adyen_checkout/src/drop_in/drop_in_platform_api.dart'; import 'package:adyen_checkout/src/generated/platform_api.g.dart'; import 'package:adyen_checkout/src/logging/adyen_logger.dart'; @@ -14,16 +14,16 @@ import 'package:adyen_checkout/src/util/sdk_version_number_provider.dart'; class DropIn { DropIn( this.sdkVersionNumberProvider, - this.checkoutFlutter, + this.dropInFlutter, this.dropInPlatformApi, ) { - CheckoutFlutterInterface.setUp(checkoutFlutter); + CheckoutFlutterInterface.setUp(dropInFlutter); } final PaymentEventHandler _paymentEventHandler = PaymentEventHandler(); final AdyenLogger adyenLogger = AdyenLogger.instance; final SdkVersionNumberProvider sdkVersionNumberProvider; - final CheckoutFlutter checkoutFlutter; + final DropInFlutter dropInFlutter; final DropInPlatformApi dropInPlatformApi; Future startDropInSessionsPayment( @@ -39,9 +39,9 @@ class DropIn { dropInConfiguration.toDTO(sdkVersionNumber, true), ); - checkoutFlutter.platformEventStream = StreamController(); + dropInFlutter.platformEventStream = StreamController(); final platformEventSubscription = - checkoutFlutter.platformEventStream?.stream.listen((event) async { + dropInFlutter.platformEventStream?.stream.listen((event) async { switch (event.type) { case CheckoutEventType.result: dropInSessionCompleter.complete(event.paymentResult); @@ -57,8 +57,8 @@ class DropIn { return dropInSessionCompleter.future.then((paymentResultDTO) async { dropInPlatformApi.cleanUpDropIn(); await platformEventSubscription?.cancel(); - checkoutFlutter.platformEventStream?.close(); - checkoutFlutter.platformEventStream = null; + dropInFlutter.platformEventStream?.close(); + dropInFlutter.platformEventStream = null; adyenLogger .print("Drop-in session result type: ${paymentResultDTO.type.name}"); adyenLogger.print( @@ -102,9 +102,9 @@ class DropIn { encodedPaymentMethodsResponse, ); - checkoutFlutter.platformEventStream = StreamController(); + dropInFlutter.platformEventStream = StreamController(); final platformEventSubscription = - checkoutFlutter.platformEventStream?.stream.listen((event) async { + dropInFlutter.platformEventStream?.stream.listen((event) async { switch (event.type) { case CheckoutEventType.paymentComponent: await _handlePaymentComponent(event, advancedCheckout); @@ -129,8 +129,8 @@ class DropIn { return dropInAdvancedFlowCompleter.future.then((paymentResultDTO) async { dropInPlatformApi.cleanUpDropIn(); await platformEventSubscription?.cancel(); - await checkoutFlutter.platformEventStream?.close(); - checkoutFlutter.platformEventStream = null; + await dropInFlutter.platformEventStream?.close(); + dropInFlutter.platformEventStream = null; adyenLogger.print( "Drop-in advanced flow result type: ${paymentResultDTO.type.name}"); adyenLogger.print( diff --git a/lib/src/common/checkout_flutter.dart b/lib/src/drop_in/drop_in_flutter.dart similarity index 79% rename from lib/src/common/checkout_flutter.dart rename to lib/src/drop_in/drop_in_flutter.dart index e66d7beb..54887f1b 100644 --- a/lib/src/common/checkout_flutter.dart +++ b/lib/src/drop_in/drop_in_flutter.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:adyen_checkout/src/generated/platform_api.g.dart'; -class CheckoutFlutter implements CheckoutFlutterInterface { +class DropInFlutter implements CheckoutFlutterInterface { StreamController? platformEventStream; @override From 9165928a780493debef8c7f8e25bd1660146a1cf Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Mon, 10 Feb 2025 11:33:22 +0100 Subject: [PATCH 6/7] Simplified checkout event class for platform communication --- .../checkout/flutter/dropIn/DropInPlatformApi.kt | 6 ++---- .../adyen/checkout/flutter/generated/PlatformApi.kt | 9 +++------ ios/Classes/dropIn/DropInPlatformApi.swift | 10 +++++----- .../DropInAdvancedFlowDelegate.swift | 6 +++--- .../dropInSessions/DropInSessionsDelegate.swift | 6 +++--- ios/Classes/generated/PlatformApi.swift | 12 ++++-------- lib/src/drop_in/drop_in.dart | 11 ++++++++--- lib/src/generated/platform_api.g.dart | 9 ++------- pigeons/platform_api.dart | 4 +--- 9 files changed, 31 insertions(+), 42 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index 98dc969c..092cb4bb 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt @@ -317,8 +317,7 @@ class DropInPlatformApi( val checkoutEvent = CheckoutEvent( CheckoutEventType.RESULT, - data = "", - paymentResult = mappedResult + data = mappedResult, ) checkoutFlutter.send(checkoutEvent) {} @@ -356,8 +355,7 @@ class DropInPlatformApi( val checkoutEvent = CheckoutEvent( CheckoutEventType.RESULT, - data = "", - paymentResult = mappedResult + data = mappedResult ) checkoutFlutter.send(checkoutEvent) {} } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt index 9a1d819c..22621377 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt @@ -856,24 +856,21 @@ data class OrderResponseDTO ( /** Generated class from Pigeon that represents data sent in messages. */ data class CheckoutEvent ( val type: CheckoutEventType, - val data: String? = null, - val paymentResult: PaymentResultDTO? = null + val data: Any? = null ) { companion object { @Suppress("LocalVariableName") fun fromList(__pigeon_list: List): CheckoutEvent { val type = __pigeon_list[0] as CheckoutEventType - val data = __pigeon_list[1] as String? - val paymentResult = __pigeon_list[2] as PaymentResultDTO? - return CheckoutEvent(type, data, paymentResult) + val data = __pigeon_list[1] + return CheckoutEvent(type, data) } } fun toList(): List { return listOf( type, data, - paymentResult, ) } } diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index b3c88add..b2e540ad 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -114,7 +114,7 @@ class DropInPlatformApi: DropInPlatformInterface { } catch { let checkoutEvent = CheckoutEvent( type: CheckoutEventType.result, - paymentResult: PaymentResultDTO(type: PaymentResultEnum.error, reason: error.localizedDescription) + data: PaymentResultDTO(type: PaymentResultEnum.error, reason: error.localizedDescription) ) checkoutFlutter.send( event: checkoutEvent, @@ -198,7 +198,7 @@ class DropInPlatformApi: DropInPlatformInterface { result: PaymentResultModelDTO( resultCode: resultCode?.rawValue) ) - let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, paymentResult: paymentResult) + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, data: paymentResult) self?.checkoutFlutter.send( event: checkoutEvent, completion: { _ in } @@ -213,7 +213,7 @@ class DropInPlatformApi: DropInPlatformInterface { dropInViewController?.dropInComponent.handle(result) } catch { let paymentResult = PaymentResultDTO(type: PaymentResultEnum.error, reason: error.localizedDescription) - let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, paymentResult: paymentResult) + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, data: paymentResult) checkoutFlutter.send( event: checkoutEvent, completion: { _ in } @@ -228,7 +228,7 @@ class DropInPlatformApi: DropInPlatformInterface { if paymentEventDTO.error?.dismissDropIn == true || dropInAdvancedFlowDelegate?.isApplePay == true { finalizeAndDismiss(success: false) { [weak self] in let paymentResult = PaymentResultDTO(type: PaymentResultEnum.error, reason: paymentEventDTO.error?.errorMessage) - let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, paymentResult: paymentResult) + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.result, data: paymentResult) self?.checkoutFlutter.send( event: checkoutEvent, completion: { _ in } @@ -284,7 +284,7 @@ class DropInPlatformApi: DropInPlatformInterface { private func sendSessionError(error: Error) { let checkoutEvent = CheckoutEvent( type: CheckoutEventType.result, - paymentResult: PaymentResultDTO( + data: PaymentResultDTO( type: PaymentResultEnum.error, reason: error.localizedDescription ) diff --git a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift index 7b5050a2..d74d18de 100644 --- a/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift +++ b/ios/Classes/dropIn/dropInAdvancedFlow/DropInAdvancedFlowDelegate.swift @@ -59,7 +59,7 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { ) let checkoutEvent = CheckoutEvent( type: CheckoutEventType.result, - paymentResult: paymentResult + data: paymentResult ) self?.checkoutFlutter.send( event: checkoutEvent, @@ -86,7 +86,7 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { case ComponentError.cancelled: let checkoutEvent = CheckoutEvent( type: CheckoutEventType.result, - paymentResult: PaymentResultDTO( + data: PaymentResultDTO( type: PaymentResultEnum.cancelledByUser, reason: error.localizedDescription ) @@ -104,7 +104,7 @@ class DropInAdvancedFlowDelegate: DropInComponentDelegate { private func sendErrorToFlutterLayer(error: Error) { let checkoutEvent = CheckoutEvent( type: CheckoutEventType.result, - paymentResult: PaymentResultDTO( + data: PaymentResultDTO( type: PaymentResultEnum.error, reason: error.localizedDescription ) diff --git a/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift b/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift index af653fd2..6c7bc947 100644 --- a/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift +++ b/ios/Classes/dropIn/dropInSessions/DropInSessionsDelegate.swift @@ -20,7 +20,7 @@ class DropInSessionsDelegate: AdyenSessionDelegate { ) let checkoutEvent = CheckoutEvent( type: CheckoutEventType.result, - paymentResult: PaymentResultDTO( + data: PaymentResultDTO( type: PaymentResultEnum.finished, result: paymentResult ) @@ -38,7 +38,7 @@ class DropInSessionsDelegate: AdyenSessionDelegate { case ComponentError.cancelled: let checkoutEvent = CheckoutEvent( type: CheckoutEventType.result, - paymentResult: PaymentResultDTO( + data: PaymentResultDTO( type: PaymentResultEnum.cancelledByUser, reason: error.localizedDescription ) @@ -50,7 +50,7 @@ class DropInSessionsDelegate: AdyenSessionDelegate { default: let checkoutEvent = CheckoutEvent( type: CheckoutEventType.result, - paymentResult: PaymentResultDTO( + data: PaymentResultDTO( type: PaymentResultEnum.error, reason: error.localizedDescription ) diff --git a/ios/Classes/generated/PlatformApi.swift b/ios/Classes/generated/PlatformApi.swift index ed4dbad8..3f97d88e 100644 --- a/ios/Classes/generated/PlatformApi.swift +++ b/ios/Classes/generated/PlatformApi.swift @@ -871,27 +871,23 @@ struct OrderResponseDTO { /// Generated class from Pigeon that represents data sent in messages. struct CheckoutEvent { var type: CheckoutEventType - var data: String? - var paymentResult: PaymentResultDTO? + var data: Any? // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ __pigeon_list: [Any?]) -> CheckoutEvent? { let type = __pigeon_list[0] as! CheckoutEventType - let data: String? = nilOrValue(__pigeon_list[1]) - let paymentResult: PaymentResultDTO? = nilOrValue(__pigeon_list[2]) + let data: Any? = __pigeon_list[1] return CheckoutEvent( type: type, - data: data, - paymentResult: paymentResult + data: data ) } func toList() -> [Any?] { [ type, - data, - paymentResult + data ] } } diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index dd79c0ea..f96ccafa 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -44,7 +44,7 @@ class DropIn { dropInFlutter.platformEventStream?.stream.listen((event) async { switch (event.type) { case CheckoutEventType.result: - dropInSessionCompleter.complete(event.paymentResult); + _handleResult(dropInSessionCompleter, event); case CheckoutEventType.deleteStoredPaymentMethod: _onDeleteStoredPaymentMethodCallback( event, @@ -147,10 +147,15 @@ class DropIn { } void _handleResult( - Completer dropInAdvancedFlowCompleter, + Completer completer, CheckoutEvent event, ) { - dropInAdvancedFlowCompleter.complete(event.paymentResult); + switch (event.data) { + case PaymentResultDTO paymentResultDTO: + completer.complete(paymentResultDTO); + default: + completer.complete(PaymentResultDTO(type: PaymentResultEnum.error)); + } } Future _handlePaymentComponent( diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index 71e2c7b4..d8cbbc51 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -939,20 +939,16 @@ class CheckoutEvent { CheckoutEvent({ required this.type, this.data, - this.paymentResult, }); CheckoutEventType type; - String? data; - - PaymentResultDTO? paymentResult; + Object? data; Object encode() { return [ type, data, - paymentResult, ]; } @@ -960,8 +956,7 @@ class CheckoutEvent { result as List; return CheckoutEvent( type: result[0]! as CheckoutEventType, - data: result[1] as String?, - paymentResult: result[2] as PaymentResultDTO?, + data: result[1], ); } } diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 9d57c560..b0e1e576 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -438,13 +438,11 @@ class OrderResponseDTO { class CheckoutEvent { final CheckoutEventType type; - final String? data; - final PaymentResultDTO? paymentResult; + final Object? data; CheckoutEvent({ required this.type, this.data, - this.paymentResult, }); } From faf87e16ccf5bab4480459053b1bcd1a36d2eaa0 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Mon, 10 Feb 2025 13:44:06 +0100 Subject: [PATCH 7/7] Simplified checkout event class for platform communication --- .../checkout/flutter/dropIn/DropInPlatformApi.kt | 4 ++-- lib/src/drop_in/drop_in.dart | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index 092cb4bb..6325af8c 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt @@ -317,7 +317,7 @@ class DropInPlatformApi( val checkoutEvent = CheckoutEvent( CheckoutEventType.RESULT, - data = mappedResult, + mappedResult, ) checkoutFlutter.send(checkoutEvent) {} @@ -355,7 +355,7 @@ class DropInPlatformApi( val checkoutEvent = CheckoutEvent( CheckoutEventType.RESULT, - data = mappedResult + mappedResult ) checkoutFlutter.send(checkoutEvent) {} } diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index f96ccafa..b03e1909 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -154,7 +154,10 @@ class DropIn { case PaymentResultDTO paymentResultDTO: completer.complete(paymentResultDTO); default: - completer.complete(PaymentResultDTO(type: PaymentResultEnum.error)); + completer.complete(PaymentResultDTO( + type: PaymentResultEnum.error, + reason: "Missing payment result data", + )); } } @@ -218,12 +221,12 @@ class DropIn { CheckoutEvent event, StoredPaymentMethodConfiguration? storedPaymentMethodConfiguration, ) async { - final String? storedPaymentMethodId = event.data; final deletionCallback = storedPaymentMethodConfiguration?.deleteStoredPaymentMethodCallback; - if (storedPaymentMethodId != null && deletionCallback != null) { + if (deletionCallback != null) { try { + final String storedPaymentMethodId = event.data as String; final bool result = await deletionCallback(storedPaymentMethodId); dropInPlatformApi.onDeleteStoredPaymentMethodResult( DeletedStoredPaymentMethodResultDTO( @@ -234,7 +237,7 @@ class DropIn { adyenLogger.print(error.toString()); dropInPlatformApi.onDeleteStoredPaymentMethodResult( DeletedStoredPaymentMethodResultDTO( - storedPaymentMethodId: storedPaymentMethodId, + storedPaymentMethodId: "", isSuccessfullyRemoved: false, )); }