From d3935df95d4979647c5a40cede0dfb48b4b30d1d Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Fri, 20 Sep 2024 10:47:18 +0200 Subject: [PATCH 01/21] Started with implementation of partial payment --- .../com/adyen/checkout/flutter/PlatformApi.kt | 59 +- .../flutter/dropIn/DropInPlatformApi.kt | 68 +- .../dropIn/advanced/AdvancedDropInService.kt | 91 +- .../advanced/DropInServiceResultMessenger.kt | 53 + example/lib/network/service.dart | 30 + .../adyen_drop_in_repository.dart | 23 + .../lib/screens/drop_in/drop_in_screen.dart | 5 + ios/Classes/PlatformApi.swift | 3968 ++++++++--------- ios/Classes/dropIn/DropInPlatformApi.swift | 5 + lib/adyen_checkout.dart | 1 + lib/src/common/model/checkout.dart | 4 + lib/src/common/model/partial_payment.dart | 13 + lib/src/drop_in/drop_in.dart | 46 +- lib/src/drop_in/drop_in_platform_api.dart | 8 + lib/src/generated/platform_api.g.dart | 49 +- pigeons/platform_api.dart | 8 +- pubspec.yaml | 2 +- 17 files changed, 2413 insertions(+), 2020 deletions(-) create mode 100644 lib/src/common/model/partial_payment.dart diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt index 6e6e3796..3a2daba5 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v15.0.3), do not edit directly. +// Autogenerated from Pigeon (v16.0.5), do not edit directly. // See also: https://pub.dev/packages/pigeon @@ -133,7 +133,10 @@ enum class PlatformCommunicationType(val raw: Int) { PAYMENTCOMPONENT(0), ADDITIONALDETAILS(1), RESULT(2), - DELETESTOREDPAYMENTMETHOD(3); + DELETESTOREDPAYMENTMETHOD(3), + BALANCECHECK(4), + REQUESTORDER(5), + CANCELORDER(6); companion object { fun ofRaw(raw: Int): PlatformCommunicationType? { @@ -1752,6 +1755,8 @@ interface DropInPlatformInterface { fun onPaymentsResult(paymentsResult: PaymentEventDTO) fun onPaymentsDetailsResult(paymentsDetailsResult: PaymentEventDTO) fun onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) + fun onBalanceCheckResult(balanceCheckResponse: String) + fun onOrderRequestResult(orderRequestResponse: String) fun cleanUpDropIn() companion object { @@ -1858,6 +1863,44 @@ interface DropInPlatformInterface { channel.setMessageHandler(null) } } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val balanceCheckResponseArg = args[0] as String + var wrapped: List + try { + api.onBalanceCheckResult(balanceCheckResponseArg) + wrapped = listOf(null) + } catch (exception: Throwable) { + wrapped = wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val orderRequestResponseArg = args[0] as String + var wrapped: List + try { + api.onOrderRequestResult(orderRequestResponseArg) + wrapped = listOf(null) + } catch (exception: Throwable) { + wrapped = wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } run { val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn", codec) if (api != null) { @@ -1946,7 +1989,8 @@ class DropInFlutterInterface(private val binaryMessenger: BinaryMessenger) { DropInFlutterInterfaceCodec } } - fun onDropInSessionPlatformCommunication(platformCommunicationModelArg: PlatformCommunicationModel, callback: (Result) -> Unit) { + fun onDropInSessionPlatformCommunication(platformCommunicationModelArg: PlatformCommunicationModel, callback: (Result) -> Unit) +{ val channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) channel.send(listOf(platformCommunicationModelArg)) { @@ -1961,7 +2005,8 @@ class DropInFlutterInterface(private val binaryMessenger: BinaryMessenger) { } } } - fun onDropInAdvancedPlatformCommunication(platformCommunicationModelArg: PlatformCommunicationModel, callback: (Result) -> Unit) { + fun onDropInAdvancedPlatformCommunication(platformCommunicationModelArg: PlatformCommunicationModel, callback: (Result) -> Unit) +{ val channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) channel.send(listOf(platformCommunicationModelArg)) { @@ -2510,7 +2555,8 @@ class ComponentFlutterInterface(private val binaryMessenger: BinaryMessenger) { ComponentFlutterInterfaceCodec } } - fun _generateCodecForDTOs(cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTOArg: SessionDTO, callback: (Result) -> Unit) { + fun _generateCodecForDTOs(cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTOArg: SessionDTO, callback: (Result) -> Unit) +{ val channelName = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) channel.send(listOf(cardComponentConfigurationDTOArg, sessionDTOArg)) { @@ -2525,7 +2571,8 @@ class ComponentFlutterInterface(private val binaryMessenger: BinaryMessenger) { } } } - fun onComponentCommunication(componentCommunicationModelArg: ComponentCommunicationModel, callback: (Result) -> Unit) { + fun onComponentCommunication(componentCommunicationModelArg: ComponentCommunicationModel, callback: (Result) -> Unit) +{ val channelName = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) channel.send(listOf(componentCommunicationModelArg)) { 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 28b5423c..bd1e3677 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,6 +26,10 @@ import com.adyen.checkout.dropin.internal.ui.model.SessionDropInResultContractPa import com.adyen.checkout.flutter.dropIn.advanced.AdvancedDropInService import com.adyen.checkout.flutter.dropIn.advanced.DropInAdditionalDetailsPlatformMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInAdditionalDetailsResultMessenger +import com.adyen.checkout.flutter.dropIn.advanced.DropInBalanceCheckPlatformMessenger +import com.adyen.checkout.flutter.dropIn.advanced.DropInBalanceCheckResultMessenger +import com.adyen.checkout.flutter.dropIn.advanced.DropInOrderRequestPlatformMessenger +import com.adyen.checkout.flutter.dropIn.advanced.DropInOrderRequestResultMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionPlatformMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionResultMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentResultMessenger @@ -75,6 +79,8 @@ class DropInPlatformApi( ) { setAdvancedFlowDropInServiceObserver() setStoredPaymentMethodDeletionObserver() + setBalanceCheckPlatformMessengerObserver() + setOrderRequestPlatformMessengerObserver() activity.lifecycleScope.launch(Dispatchers.IO) { val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize( @@ -112,6 +118,14 @@ class DropInPlatformApi( DropInPaymentMethodDeletionResultMessenger.sendResult(deleteStoredPaymentMethodResultDTO) } + override fun onBalanceCheckResult(balanceCheckResponse: String) { + DropInBalanceCheckResultMessenger.sendResult(balanceCheckResponse) + } + + override fun onOrderRequestResult(orderRequestResponse: String) { + DropInOrderRequestResultMessenger.sendResult(orderRequestResponse) + } + override fun cleanUpDropIn() { DropInServiceResultMessenger.instance().removeObservers(activity) DropInPaymentMethodDeletionPlatformMessenger.instance().removeObservers(activity) @@ -181,6 +195,36 @@ class DropInPlatformApi( } } + private fun setBalanceCheckPlatformMessengerObserver() { + DropInBalanceCheckPlatformMessenger.instance().removeObservers(activity) + DropInBalanceCheckPlatformMessenger.instance().observe(activity) { message -> + if (message.hasBeenHandled()) { + return@observe + } + + val platformCommunicationModel = PlatformCommunicationModel( + PlatformCommunicationType.BALANCECHECK, + data = message.contentIfNotHandled.toString() + ) + dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + } + } + + private fun setOrderRequestPlatformMessengerObserver() { + DropInOrderRequestPlatformMessenger.instance().removeObservers(activity) + DropInOrderRequestPlatformMessenger.instance().observe(activity) { message -> + if (message.hasBeenHandled()) { + return@observe + } + + val platformCommunicationModel = PlatformCommunicationModel( + PlatformCommunicationType.REQUESTORDER, + data = message.contentIfNotHandled.toString() + ) + dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + } + } + private fun createCheckoutSession( sessionHolder: SessionHolder, environment: com.adyen.checkout.core.Environment, @@ -234,15 +278,15 @@ class DropInPlatformApi( PaymentResultDTO( PaymentResultEnum.FINISHED, result = - with(sessionDropInResult.result) { - PaymentResultModelDTO( - sessionId, - sessionData, - sessionResult, - resultCode, - order?.mapToOrderResponseModel() - ) - } + with(sessionDropInResult.result) { + PaymentResultModelDTO( + sessionId, + sessionData, + sessionResult, + resultCode, + order?.mapToOrderResponseModel() + ) + } ) } @@ -279,9 +323,9 @@ class DropInPlatformApi( PaymentResultDTO( PaymentResultEnum.FINISHED, result = - PaymentResultModelDTO( - resultCode = dropInAdvancedFlowResult.result - ) + PaymentResultModelDTO( + resultCode = dropInAdvancedFlowResult.result + ) ) } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index 643fb9c3..ecdf51f6 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -6,22 +6,30 @@ import PaymentEventDTO import PaymentEventType import android.content.Intent import android.os.IBinder +import android.util.Log import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ServiceLifecycleDispatcher import com.adyen.checkout.components.core.ActionComponentData +import com.adyen.checkout.components.core.BalanceResult +import com.adyen.checkout.components.core.OrderResponse import com.adyen.checkout.components.core.PaymentComponentData import com.adyen.checkout.components.core.PaymentComponentState import com.adyen.checkout.components.core.StoredPaymentMethod import com.adyen.checkout.components.core.action.Action +import com.adyen.checkout.core.exception.ModelSerializationException +import com.adyen.checkout.dropin.BalanceDropInServiceResult import com.adyen.checkout.dropin.DropInService import com.adyen.checkout.dropin.DropInServiceResult import com.adyen.checkout.dropin.ErrorDialog +import com.adyen.checkout.dropin.OrderDropInServiceResult import com.adyen.checkout.dropin.RecurringDropInServiceResult import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletionModel import com.adyen.checkout.flutter.dropIn.model.DropInType import com.adyen.checkout.flutter.utils.Constants import com.adyen.checkout.googlepay.GooglePayComponentState +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch import org.json.JSONObject class AdvancedDropInService : DropInService(), LifecycleOwner { @@ -45,8 +53,26 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } } - override fun onBalanceCheck(paymentComponentState: PaymentComponentState<*>) = - onPaymentComponentState(paymentComponentState) + override fun onBalanceCheck(paymentComponentState: PaymentComponentState<*>) { + try { + setBalanceCheckObserver() + val data = PaymentComponentData.SERIALIZER.serialize(paymentComponentState.data) + DropInBalanceCheckPlatformMessenger.sendResult(data) + } catch (exception: Exception) { + sendResult( + DropInServiceResult.Error( + errorDialog = null, + reason = exception.message, + dismissDropIn = true + ) + ) + } + } + + override fun onOrderRequest() { + setOrderRequestObserver() + DropInOrderRequestPlatformMessenger.sendResult("onOrderRequest") + } override fun onRemoveStoredPaymentMethod(storedPaymentMethod: StoredPaymentMethod) { storedPaymentMethod.id?.let { storedPaymentMethodId -> @@ -122,6 +148,30 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } } + private fun setBalanceCheckObserver() { + DropInBalanceCheckResultMessenger.instance().removeObservers(this) + DropInBalanceCheckResultMessenger.instance().observe(this) { message -> + if (message.hasBeenHandled()) { + return@observe + } + + val balanceResult = mapToBalanceDropInServiceResult(message.contentIfNotHandled as String) + sendBalanceResult(balanceResult) + } + } + + private fun setOrderRequestObserver() { + DropInOrderRequestPlatformMessenger.instance().removeObservers(this) + DropInOrderRequestPlatformMessenger.instance().observe(this) { message -> + if (message.hasBeenHandled()) { + return@observe + } + + val orderResult = mapToOrderDropInServiceResult(message.contentIfNotHandled as String) + sendOrderResult(orderResult) + } + } + private fun mapToDeletionDropInResult( deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO? ): RecurringDropInServiceResult { @@ -131,9 +181,9 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { // TODO - the error message should be provided by the native SDK RecurringDropInServiceResult.Error( errorDialog = - ErrorDialog( - message = "Removal of the stored payment method failed. Please try again later." - ) + ErrorDialog( + message = "Removal of the stored payment method failed. Please try again later." + ) ) } } @@ -182,6 +232,37 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } } + private fun mapToBalanceDropInServiceResult(response: String): BalanceDropInServiceResult { + if (response.isEmpty()) { + return BalanceDropInServiceResult.Error(errorDialog = null, reason = "Balance check failed") + } + + val jsonResponse = JSONObject(response) + return when (val resultCode = jsonResponse.optString("resultCode")) { + "Success" -> BalanceDropInServiceResult.Balance(BalanceResult.SERIALIZER.deserialize(jsonResponse)) + "NotEnoughBalance" -> BalanceDropInServiceResult.Balance(BalanceResult.SERIALIZER.deserialize(jsonResponse)) + else -> BalanceDropInServiceResult.Error( + errorDialog = ErrorDialog(message = resultCode), + dismissDropIn = false, + ) + } + } + + private fun mapToOrderDropInServiceResult(response: String): OrderDropInServiceResult { + if (response.isEmpty()) { + return OrderDropInServiceResult.Error(errorDialog = null, reason = "Order request failed") + } + + val jsonResponse = JSONObject(response) + return when (val resultCode = jsonResponse.optString("resultCode")) { + "Success" -> OrderDropInServiceResult.OrderCreated(OrderResponse.SERIALIZER.deserialize(jsonResponse)) + else -> OrderDropInServiceResult.Error( + errorDialog = ErrorDialog(message = resultCode), + dismissDropIn = false, + ) + } + } + override fun onBind(intent: Intent?): IBinder { dispatcher.onServicePreSuperOnBind() return super.onBind(intent) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt index cde358b4..f69dc8a7 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt @@ -82,3 +82,56 @@ class DropInPaymentMethodDeletionResultMessenger : LiveData>() { + companion object { + private val dropInBalanceCheckPlatformMessenger = + DropInBalanceCheckPlatformMessenger() + + fun instance() = dropInBalanceCheckPlatformMessenger + + fun sendResult(value: JSONObject) { + dropInBalanceCheckPlatformMessenger.postValue(Event(value)) + } + } +} + +class DropInBalanceCheckResultMessenger : LiveData>() { + companion object { + private val dropInBalanceCheckResultMessenger = + DropInBalanceCheckResultMessenger() + + fun instance() = dropInBalanceCheckResultMessenger + + fun sendResult(value: String) { + dropInBalanceCheckResultMessenger.postValue(Event(value)) + } + } +} + +class DropInOrderRequestPlatformMessenger: LiveData>() { + companion object { + private val dropInOrderRequestPlatformMessenger = + DropInOrderRequestPlatformMessenger() + + fun instance() = dropInOrderRequestPlatformMessenger + + fun sendResult(value: String) { + dropInOrderRequestPlatformMessenger.postValue(Event(value)) + } + } +} + +class DropInOrderRequestResultMessenger: LiveData>() { + companion object { + private val dropInOrderRequestResultMessenger = + DropInOrderRequestResultMessenger() + + fun instance() = dropInOrderRequestResultMessenger + + fun sendResult(value: String) { + dropInOrderRequestResultMessenger.postValue(Event(value)) + } + } +} + diff --git a/example/lib/network/service.dart b/example/lib/network/service.dart index a5052d4e..d8464fca 100644 --- a/example/lib/network/service.dart +++ b/example/lib/network/service.dart @@ -81,6 +81,36 @@ class Service { } } + Future> postPaymentMethodsBalance( + Map body) async { + final response = await http.post( + Uri.https(Config.baseUrl, "/${Config.apiVersion}/paymentMethods/balance"), + headers: _createHeaders(), + body: jsonEncode(body), + ); + print(response.body); + return jsonDecode(response.body); + } + + Future> postOrders(Map body) async { + final response = await http.post( + Uri.https(Config.baseUrl, "/${Config.apiVersion}/orders"), + headers: _createHeaders(), + body: jsonEncode(body), + ); + return jsonDecode(response.body); + } + + Future> postOrdersCancel(Map body) async { + final response = await http.post( + Uri.https(Config.baseUrl, "/${Config.apiVersion}/orders/cancel"), + headers: _createHeaders(), + body: jsonEncode(body), + ); + return jsonDecode(response.body); + } + + Map _createHeaders() => { "content-type": "application/json", "x-API-key": Config.xApiKey, diff --git a/example/lib/repositories/adyen_drop_in_repository.dart b/example/lib/repositories/adyen_drop_in_repository.dart index faf5f000..b1d53fda 100644 --- a/example/lib/repositories/adyen_drop_in_repository.dart +++ b/example/lib/repositories/adyen_drop_in_repository.dart @@ -134,4 +134,27 @@ class AdyenDropInRepository extends AdyenBaseRepository { shopperReference: Config.shopperReference, ); } + + Future> onCheckBalance( + Map balanceRequestBody) async { + balanceRequestBody.addAll({"merchantAccount": Config.merchantAccount}); + return service.postPaymentMethodsBalance(balanceRequestBody); + } + + Future> onRequestOrder() async { + final orderRequestBody = { + "reference": "flutter-test_${DateTime.now().millisecondsSinceEpoch}", + "amount": { + "value": Config.amount.value, + "currency": Config.amount.currency + }, + "merchantAccount": Config.merchantAccount, + }; + return service.postOrders(orderRequestBody); + } + + Future> onCancelOrder( + Map orderCancelRequestBody) async { + return service.postOrders(orderCancelRequestBody); + } } diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index 0efc3732..22974b4c 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -75,6 +75,11 @@ class DropInScreen extends StatelessWidget { final advancedCheckout = AdvancedCheckout( onSubmit: repository.onSubmit, onAdditionalDetails: repository.onAdditionalDetails, + partialPayment: PartialPayment( + onCheckBalance: repository.onCheckBalance, + onRequestOrder: repository.onRequestOrder, + onCancelOrder: repository.onCancelOrder, + ), ); final paymentResult = await AdyenCheckout.advanced.startDropIn( diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index 5a6fcc71..bd67f3c6 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -1,2292 +1,2274 @@ -// Autogenerated from Pigeon (v15.0.3), do not edit directly. +// Autogenerated from Pigeon (v16.0.5), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation + #if os(iOS) - import Flutter + import Flutter #elseif os(macOS) - import FlutterMacOS + import FlutterMacOS #else - #error("Unsupported platform.") + #error("Unsupported platform.") #endif private func wrapResult(_ result: Any?) -> [Any?] { - [result] + return [result] } private func wrapError(_ error: Any) -> [Any?] { - if let flutterError = error as? FlutterError { - return [ - flutterError.code, - flutterError.message, - flutterError.details - ] - } + if let flutterError = error as? FlutterError { return [ - "\(error)", - "\(type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)" + flutterError.code, + flutterError.message, + flutterError.details, ] + } + return [ + "\(error)", + "\(type(of: error))", + "Stacktrace: \(Thread.callStackSymbols)", + ] } private func createConnectionError(withChannelName channelName: String) -> FlutterError { - FlutterError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") + return FlutterError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") } private func isNullish(_ value: Any?) -> Bool { - value is NSNull || value == nil + return value is NSNull || value == nil } private func nilOrValue(_ value: Any?) -> T? { - if value is NSNull { return nil } - return value as! T? + if value is NSNull { return nil } + return value as! T? } enum Environment: Int { - case test = 0 - case europe = 1 - case unitedStates = 2 - case australia = 3 - case india = 4 - case apse = 5 + case test = 0 + case europe = 1 + case unitedStates = 2 + case australia = 3 + case india = 4 + case apse = 5 } enum AddressMode: Int { - case full = 0 - case postalCode = 1 - case none = 2 + case full = 0 + case postalCode = 1 + case none = 2 } enum CardAuthMethod: Int { - case panOnly = 0 - case cryptogram3DS = 1 + case panOnly = 0 + case cryptogram3DS = 1 } enum TotalPriceStatus: Int { - case notCurrentlyKnown = 0 - case estimated = 1 - case finalPrice = 2 + case notCurrentlyKnown = 0 + case estimated = 1 + case finalPrice = 2 } enum GooglePayEnvironment: Int { - case test = 0 - case production = 1 + case test = 0 + case production = 1 } enum CashAppPayEnvironment: Int { - case sandbox = 0 - case production = 1 + case sandbox = 0 + case production = 1 } enum PaymentResultEnum: Int { - case cancelledByUser = 0 - case error = 1 - case finished = 2 + case cancelledByUser = 0 + case error = 1 + case finished = 2 } enum PlatformCommunicationType: Int { - case paymentComponent = 0 - case additionalDetails = 1 - case result = 2 - case deleteStoredPaymentMethod = 3 + case paymentComponent = 0 + case additionalDetails = 1 + case result = 2 + case deleteStoredPaymentMethod = 3 + case balanceCheck = 4 + case requestOrder = 5 + case cancelOrder = 6 } enum ComponentCommunicationType: Int { - case onSubmit = 0 - case additionalDetails = 1 - case loading = 2 - case result = 3 - case resize = 4 + case onSubmit = 0 + case additionalDetails = 1 + case loading = 2 + case result = 3 + case resize = 4 } enum PaymentEventType: Int { - case finished = 0 - case action = 1 - case error = 2 + case finished = 0 + case action = 1 + case error = 2 } enum FieldVisibility: Int { - case show = 0 - case hide = 1 + case show = 0 + case hide = 1 } enum InstantPaymentType: Int { - case googlePay = 0 - case applePay = 1 - case instant = 2 + case googlePay = 0 + case applePay = 1 + case instant = 2 } enum ApplePayShippingType: Int { - case shipping = 0 - case delivery = 1 - case storePickup = 2 - case servicePickup = 3 + case shipping = 0 + case delivery = 1 + case storePickup = 2 + case servicePickup = 3 } enum ApplePayMerchantCapability: Int { - case debit = 0 - case credit = 1 + case debit = 0 + case credit = 1 } enum ApplePaySummaryItemType: Int { - case pending = 0 - case definite = 1 + case pending = 0 + case definite = 1 } /// Generated class from Pigeon that represents data sent in messages. struct SessionDTO { - var id: String - var sessionData: String - var paymentMethodsJson: String - - static func fromList(_ list: [Any?]) -> SessionDTO? { - let id = list[0] as! String - let sessionData = list[1] as! String - let paymentMethodsJson = list[2] as! String - - return SessionDTO( - id: id, - sessionData: sessionData, - paymentMethodsJson: paymentMethodsJson - ) - } - - func toList() -> [Any?] { - [ - id, - sessionData, - paymentMethodsJson - ] - } + var id: String + var sessionData: String + var paymentMethodsJson: String + + static func fromList(_ list: [Any?]) -> SessionDTO? { + let id = list[0] as! String + let sessionData = list[1] as! String + let paymentMethodsJson = list[2] as! String + + return SessionDTO( + id: id, + sessionData: sessionData, + paymentMethodsJson: paymentMethodsJson + ) + } + func toList() -> [Any?] { + return [ + id, + sessionData, + paymentMethodsJson, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct AmountDTO { - var currency: String - var value: Int64 - - static func fromList(_ list: [Any?]) -> AmountDTO? { - let currency = list[0] as! String - let value = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) - - return AmountDTO( - currency: currency, - value: value - ) - } - - func toList() -> [Any?] { - [ - currency, - value - ] - } + var currency: String + var value: Int64 + + static func fromList(_ list: [Any?]) -> AmountDTO? { + let currency = list[0] as! String + let value = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) + + return AmountDTO( + currency: currency, + value: value + ) + } + func toList() -> [Any?] { + return [ + currency, + value, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct AnalyticsOptionsDTO { - var enabled: Bool - var version: String - - static func fromList(_ list: [Any?]) -> AnalyticsOptionsDTO? { - let enabled = list[0] as! Bool - let version = list[1] as! String - - return AnalyticsOptionsDTO( - enabled: enabled, - version: version - ) - } - - func toList() -> [Any?] { - [ - enabled, - version - ] - } + var enabled: Bool + var version: String + + static func fromList(_ list: [Any?]) -> AnalyticsOptionsDTO? { + let enabled = list[0] as! Bool + let version = list[1] as! String + + return AnalyticsOptionsDTO( + enabled: enabled, + version: version + ) + } + func toList() -> [Any?] { + return [ + enabled, + version, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct DropInConfigurationDTO { - var environment: Environment - var clientKey: String - var countryCode: String - var amount: AmountDTO? - var shopperLocale: String? - var cardConfigurationDTO: CardConfigurationDTO? - var applePayConfigurationDTO: ApplePayConfigurationDTO? - var googlePayConfigurationDTO: GooglePayConfigurationDTO? - var cashAppPayConfigurationDTO: CashAppPayConfigurationDTO? - var analyticsOptionsDTO: AnalyticsOptionsDTO - var showPreselectedStoredPaymentMethod: Bool - var skipListWhenSinglePaymentMethod: Bool - var isRemoveStoredPaymentMethodEnabled: Bool - var preselectedPaymentMethodTitle: String? - var paymentMethodNames: [String?: String?]? - - static func fromList(_ list: [Any?]) -> DropInConfigurationDTO? { - let environment = Environment(rawValue: list[0] as! Int)! - let clientKey = list[1] as! String - let countryCode = list[2] as! String - var amount: AmountDTO? - if let amountList: [Any?] = nilOrValue(list[3]) { - amount = AmountDTO.fromList(amountList) - } - let shopperLocale: String? = nilOrValue(list[4]) - var cardConfigurationDTO: CardConfigurationDTO? - if let cardConfigurationDTOList: [Any?] = nilOrValue(list[5]) { - cardConfigurationDTO = CardConfigurationDTO.fromList(cardConfigurationDTOList) - } - var applePayConfigurationDTO: ApplePayConfigurationDTO? - if let applePayConfigurationDTOList: [Any?] = nilOrValue(list[6]) { - applePayConfigurationDTO = ApplePayConfigurationDTO.fromList(applePayConfigurationDTOList) - } - var googlePayConfigurationDTO: GooglePayConfigurationDTO? - if let googlePayConfigurationDTOList: [Any?] = nilOrValue(list[7]) { - googlePayConfigurationDTO = GooglePayConfigurationDTO.fromList(googlePayConfigurationDTOList) - } - var cashAppPayConfigurationDTO: CashAppPayConfigurationDTO? - if let cashAppPayConfigurationDTOList: [Any?] = nilOrValue(list[8]) { - cashAppPayConfigurationDTO = CashAppPayConfigurationDTO.fromList(cashAppPayConfigurationDTOList) - } - let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[9] as! [Any?])! - let showPreselectedStoredPaymentMethod = list[10] as! Bool - let skipListWhenSinglePaymentMethod = list[11] as! Bool - let isRemoveStoredPaymentMethodEnabled = list[12] as! Bool - let preselectedPaymentMethodTitle: String? = nilOrValue(list[13]) - let paymentMethodNames: [String?: String?]? = nilOrValue(list[14]) - - return DropInConfigurationDTO( - environment: environment, - clientKey: clientKey, - countryCode: countryCode, - amount: amount, - shopperLocale: shopperLocale, - cardConfigurationDTO: cardConfigurationDTO, - applePayConfigurationDTO: applePayConfigurationDTO, - googlePayConfigurationDTO: googlePayConfigurationDTO, - cashAppPayConfigurationDTO: cashAppPayConfigurationDTO, - analyticsOptionsDTO: analyticsOptionsDTO, - showPreselectedStoredPaymentMethod: showPreselectedStoredPaymentMethod, - skipListWhenSinglePaymentMethod: skipListWhenSinglePaymentMethod, - isRemoveStoredPaymentMethodEnabled: isRemoveStoredPaymentMethodEnabled, - preselectedPaymentMethodTitle: preselectedPaymentMethodTitle, - paymentMethodNames: paymentMethodNames - ) - } - - func toList() -> [Any?] { - [ - environment.rawValue, - clientKey, - countryCode, - amount?.toList(), - shopperLocale, - cardConfigurationDTO?.toList(), - applePayConfigurationDTO?.toList(), - googlePayConfigurationDTO?.toList(), - cashAppPayConfigurationDTO?.toList(), - analyticsOptionsDTO.toList(), - showPreselectedStoredPaymentMethod, - skipListWhenSinglePaymentMethod, - isRemoveStoredPaymentMethodEnabled, - preselectedPaymentMethodTitle, - paymentMethodNames - ] - } + var environment: Environment + var clientKey: String + var countryCode: String + var amount: AmountDTO? = nil + var shopperLocale: String? = nil + var cardConfigurationDTO: CardConfigurationDTO? = nil + var applePayConfigurationDTO: ApplePayConfigurationDTO? = nil + var googlePayConfigurationDTO: GooglePayConfigurationDTO? = nil + var cashAppPayConfigurationDTO: CashAppPayConfigurationDTO? = nil + var analyticsOptionsDTO: AnalyticsOptionsDTO + var showPreselectedStoredPaymentMethod: Bool + var skipListWhenSinglePaymentMethod: Bool + var isRemoveStoredPaymentMethodEnabled: Bool + var preselectedPaymentMethodTitle: String? = nil + var paymentMethodNames: [String?: String?]? = nil + + static func fromList(_ list: [Any?]) -> DropInConfigurationDTO? { + let environment = Environment(rawValue: list[0] as! Int)! + let clientKey = list[1] as! String + let countryCode = list[2] as! String + var amount: AmountDTO? = nil + if let amountList: [Any?] = nilOrValue(list[3]) { + amount = AmountDTO.fromList(amountList) + } + let shopperLocale: String? = nilOrValue(list[4]) + var cardConfigurationDTO: CardConfigurationDTO? = nil + if let cardConfigurationDTOList: [Any?] = nilOrValue(list[5]) { + cardConfigurationDTO = CardConfigurationDTO.fromList(cardConfigurationDTOList) + } + var applePayConfigurationDTO: ApplePayConfigurationDTO? = nil + if let applePayConfigurationDTOList: [Any?] = nilOrValue(list[6]) { + applePayConfigurationDTO = ApplePayConfigurationDTO.fromList(applePayConfigurationDTOList) + } + var googlePayConfigurationDTO: GooglePayConfigurationDTO? = nil + if let googlePayConfigurationDTOList: [Any?] = nilOrValue(list[7]) { + googlePayConfigurationDTO = GooglePayConfigurationDTO.fromList(googlePayConfigurationDTOList) + } + var cashAppPayConfigurationDTO: CashAppPayConfigurationDTO? = nil + if let cashAppPayConfigurationDTOList: [Any?] = nilOrValue(list[8]) { + cashAppPayConfigurationDTO = CashAppPayConfigurationDTO.fromList(cashAppPayConfigurationDTOList) + } + let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[9] as! [Any?])! + let showPreselectedStoredPaymentMethod = list[10] as! Bool + let skipListWhenSinglePaymentMethod = list[11] as! Bool + let isRemoveStoredPaymentMethodEnabled = list[12] as! Bool + let preselectedPaymentMethodTitle: String? = nilOrValue(list[13]) + let paymentMethodNames: [String?: String?]? = nilOrValue(list[14]) + + return DropInConfigurationDTO( + environment: environment, + clientKey: clientKey, + countryCode: countryCode, + amount: amount, + shopperLocale: shopperLocale, + cardConfigurationDTO: cardConfigurationDTO, + applePayConfigurationDTO: applePayConfigurationDTO, + googlePayConfigurationDTO: googlePayConfigurationDTO, + cashAppPayConfigurationDTO: cashAppPayConfigurationDTO, + analyticsOptionsDTO: analyticsOptionsDTO, + showPreselectedStoredPaymentMethod: showPreselectedStoredPaymentMethod, + skipListWhenSinglePaymentMethod: skipListWhenSinglePaymentMethod, + isRemoveStoredPaymentMethodEnabled: isRemoveStoredPaymentMethodEnabled, + preselectedPaymentMethodTitle: preselectedPaymentMethodTitle, + paymentMethodNames: paymentMethodNames + ) + } + func toList() -> [Any?] { + return [ + environment.rawValue, + clientKey, + countryCode, + amount?.toList(), + shopperLocale, + cardConfigurationDTO?.toList(), + applePayConfigurationDTO?.toList(), + googlePayConfigurationDTO?.toList(), + cashAppPayConfigurationDTO?.toList(), + analyticsOptionsDTO.toList(), + showPreselectedStoredPaymentMethod, + skipListWhenSinglePaymentMethod, + isRemoveStoredPaymentMethodEnabled, + preselectedPaymentMethodTitle, + paymentMethodNames, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct CardConfigurationDTO { - var holderNameRequired: Bool - var addressMode: AddressMode - var showStorePaymentField: Bool - var showCvcForStoredCard: Bool - var showCvc: Bool - var kcpFieldVisibility: FieldVisibility - var socialSecurityNumberFieldVisibility: FieldVisibility - var supportedCardTypes: [String?] - - static func fromList(_ list: [Any?]) -> CardConfigurationDTO? { - let holderNameRequired = list[0] as! Bool - let addressMode = AddressMode(rawValue: list[1] as! Int)! - let showStorePaymentField = list[2] as! Bool - let showCvcForStoredCard = list[3] as! Bool - let showCvc = list[4] as! Bool - let kcpFieldVisibility = FieldVisibility(rawValue: list[5] as! Int)! - let socialSecurityNumberFieldVisibility = FieldVisibility(rawValue: list[6] as! Int)! - let supportedCardTypes = list[7] as! [String?] - - return CardConfigurationDTO( - holderNameRequired: holderNameRequired, - addressMode: addressMode, - showStorePaymentField: showStorePaymentField, - showCvcForStoredCard: showCvcForStoredCard, - showCvc: showCvc, - kcpFieldVisibility: kcpFieldVisibility, - socialSecurityNumberFieldVisibility: socialSecurityNumberFieldVisibility, - supportedCardTypes: supportedCardTypes - ) - } - - func toList() -> [Any?] { - [ - holderNameRequired, - addressMode.rawValue, - showStorePaymentField, - showCvcForStoredCard, - showCvc, - kcpFieldVisibility.rawValue, - socialSecurityNumberFieldVisibility.rawValue, - supportedCardTypes - ] - } + var holderNameRequired: Bool + var addressMode: AddressMode + var showStorePaymentField: Bool + var showCvcForStoredCard: Bool + var showCvc: Bool + var kcpFieldVisibility: FieldVisibility + var socialSecurityNumberFieldVisibility: FieldVisibility + var supportedCardTypes: [String?] + + static func fromList(_ list: [Any?]) -> CardConfigurationDTO? { + let holderNameRequired = list[0] as! Bool + let addressMode = AddressMode(rawValue: list[1] as! Int)! + let showStorePaymentField = list[2] as! Bool + let showCvcForStoredCard = list[3] as! Bool + let showCvc = list[4] as! Bool + let kcpFieldVisibility = FieldVisibility(rawValue: list[5] as! Int)! + let socialSecurityNumberFieldVisibility = FieldVisibility(rawValue: list[6] as! Int)! + let supportedCardTypes = list[7] as! [String?] + + return CardConfigurationDTO( + holderNameRequired: holderNameRequired, + addressMode: addressMode, + showStorePaymentField: showStorePaymentField, + showCvcForStoredCard: showCvcForStoredCard, + showCvc: showCvc, + kcpFieldVisibility: kcpFieldVisibility, + socialSecurityNumberFieldVisibility: socialSecurityNumberFieldVisibility, + supportedCardTypes: supportedCardTypes + ) + } + func toList() -> [Any?] { + return [ + holderNameRequired, + addressMode.rawValue, + showStorePaymentField, + showCvcForStoredCard, + showCvc, + kcpFieldVisibility.rawValue, + socialSecurityNumberFieldVisibility.rawValue, + supportedCardTypes, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ApplePayConfigurationDTO { - var merchantId: String - var merchantName: String - var allowOnboarding: Bool? - var summaryItems: [ApplePaySummaryItemDTO?]? - var requiredBillingContactFields: [String?]? - var billingContact: ApplePayContactDTO? - var requiredShippingContactFields: [String?]? - var shippingContact: ApplePayContactDTO? - var applePayShippingType: ApplePayShippingType? - var allowShippingContactEditing: Bool? - var shippingMethods: [ApplePayShippingMethodDTO?]? - var applicationData: String? - var supportedCountries: [String?]? - var merchantCapability: ApplePayMerchantCapability? - - static func fromList(_ list: [Any?]) -> ApplePayConfigurationDTO? { - let merchantId = list[0] as! String - let merchantName = list[1] as! String - let allowOnboarding: Bool? = nilOrValue(list[2]) - let summaryItems: [ApplePaySummaryItemDTO?]? = nilOrValue(list[3]) - let requiredBillingContactFields: [String?]? = nilOrValue(list[4]) - var billingContact: ApplePayContactDTO? - if let billingContactList: [Any?] = nilOrValue(list[5]) { - billingContact = ApplePayContactDTO.fromList(billingContactList) - } - let requiredShippingContactFields: [String?]? = nilOrValue(list[6]) - var shippingContact: ApplePayContactDTO? - if let shippingContactList: [Any?] = nilOrValue(list[7]) { - shippingContact = ApplePayContactDTO.fromList(shippingContactList) - } - var applePayShippingType: ApplePayShippingType? - let applePayShippingTypeEnumVal: Int? = nilOrValue(list[8]) - if let applePayShippingTypeRawValue = applePayShippingTypeEnumVal { - applePayShippingType = ApplePayShippingType(rawValue: applePayShippingTypeRawValue)! - } - let allowShippingContactEditing: Bool? = nilOrValue(list[9]) - let shippingMethods: [ApplePayShippingMethodDTO?]? = nilOrValue(list[10]) - let applicationData: String? = nilOrValue(list[11]) - let supportedCountries: [String?]? = nilOrValue(list[12]) - var merchantCapability: ApplePayMerchantCapability? - let merchantCapabilityEnumVal: Int? = nilOrValue(list[13]) - if let merchantCapabilityRawValue = merchantCapabilityEnumVal { - merchantCapability = ApplePayMerchantCapability(rawValue: merchantCapabilityRawValue)! - } - - return ApplePayConfigurationDTO( - merchantId: merchantId, - merchantName: merchantName, - allowOnboarding: allowOnboarding, - summaryItems: summaryItems, - requiredBillingContactFields: requiredBillingContactFields, - billingContact: billingContact, - requiredShippingContactFields: requiredShippingContactFields, - shippingContact: shippingContact, - applePayShippingType: applePayShippingType, - allowShippingContactEditing: allowShippingContactEditing, - shippingMethods: shippingMethods, - applicationData: applicationData, - supportedCountries: supportedCountries, - merchantCapability: merchantCapability - ) - } - - func toList() -> [Any?] { - [ - merchantId, - merchantName, - allowOnboarding, - summaryItems, - requiredBillingContactFields, - billingContact?.toList(), - requiredShippingContactFields, - shippingContact?.toList(), - applePayShippingType?.rawValue, - allowShippingContactEditing, - shippingMethods, - applicationData, - supportedCountries, - merchantCapability?.rawValue - ] - } + var merchantId: String + var merchantName: String + var allowOnboarding: Bool? = nil + var summaryItems: [ApplePaySummaryItemDTO?]? = nil + var requiredBillingContactFields: [String?]? = nil + var billingContact: ApplePayContactDTO? = nil + var requiredShippingContactFields: [String?]? = nil + var shippingContact: ApplePayContactDTO? = nil + var applePayShippingType: ApplePayShippingType? = nil + var allowShippingContactEditing: Bool? = nil + var shippingMethods: [ApplePayShippingMethodDTO?]? = nil + var applicationData: String? = nil + var supportedCountries: [String?]? = nil + var merchantCapability: ApplePayMerchantCapability? = nil + + static func fromList(_ list: [Any?]) -> ApplePayConfigurationDTO? { + let merchantId = list[0] as! String + let merchantName = list[1] as! String + let allowOnboarding: Bool? = nilOrValue(list[2]) + let summaryItems: [ApplePaySummaryItemDTO?]? = nilOrValue(list[3]) + let requiredBillingContactFields: [String?]? = nilOrValue(list[4]) + var billingContact: ApplePayContactDTO? = nil + if let billingContactList: [Any?] = nilOrValue(list[5]) { + billingContact = ApplePayContactDTO.fromList(billingContactList) + } + let requiredShippingContactFields: [String?]? = nilOrValue(list[6]) + var shippingContact: ApplePayContactDTO? = nil + if let shippingContactList: [Any?] = nilOrValue(list[7]) { + shippingContact = ApplePayContactDTO.fromList(shippingContactList) + } + var applePayShippingType: ApplePayShippingType? = nil + let applePayShippingTypeEnumVal: Int? = nilOrValue(list[8]) + if let applePayShippingTypeRawValue = applePayShippingTypeEnumVal { + applePayShippingType = ApplePayShippingType(rawValue: applePayShippingTypeRawValue)! + } + let allowShippingContactEditing: Bool? = nilOrValue(list[9]) + let shippingMethods: [ApplePayShippingMethodDTO?]? = nilOrValue(list[10]) + let applicationData: String? = nilOrValue(list[11]) + let supportedCountries: [String?]? = nilOrValue(list[12]) + var merchantCapability: ApplePayMerchantCapability? = nil + let merchantCapabilityEnumVal: Int? = nilOrValue(list[13]) + if let merchantCapabilityRawValue = merchantCapabilityEnumVal { + merchantCapability = ApplePayMerchantCapability(rawValue: merchantCapabilityRawValue)! + } + + return ApplePayConfigurationDTO( + merchantId: merchantId, + merchantName: merchantName, + allowOnboarding: allowOnboarding, + summaryItems: summaryItems, + requiredBillingContactFields: requiredBillingContactFields, + billingContact: billingContact, + requiredShippingContactFields: requiredShippingContactFields, + shippingContact: shippingContact, + applePayShippingType: applePayShippingType, + allowShippingContactEditing: allowShippingContactEditing, + shippingMethods: shippingMethods, + applicationData: applicationData, + supportedCountries: supportedCountries, + merchantCapability: merchantCapability + ) + } + func toList() -> [Any?] { + return [ + merchantId, + merchantName, + allowOnboarding, + summaryItems, + requiredBillingContactFields, + billingContact?.toList(), + requiredShippingContactFields, + shippingContact?.toList(), + applePayShippingType?.rawValue, + allowShippingContactEditing, + shippingMethods, + applicationData, + supportedCountries, + merchantCapability?.rawValue, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ApplePayContactDTO { - var phoneNumber: String? - var emailAddress: String? - var givenName: String? - var familyName: String? - var phoneticGivenName: String? - var phoneticFamilyName: String? - var addressLines: [String?]? - var subLocality: String? - var city: String? - var postalCode: String? - var subAdministrativeArea: String? - var administrativeArea: String? - var country: String? - var countryCode: String? - - static func fromList(_ list: [Any?]) -> ApplePayContactDTO? { - let phoneNumber: String? = nilOrValue(list[0]) - let emailAddress: String? = nilOrValue(list[1]) - let givenName: String? = nilOrValue(list[2]) - let familyName: String? = nilOrValue(list[3]) - let phoneticGivenName: String? = nilOrValue(list[4]) - let phoneticFamilyName: String? = nilOrValue(list[5]) - let addressLines: [String?]? = nilOrValue(list[6]) - let subLocality: String? = nilOrValue(list[7]) - let city: String? = nilOrValue(list[8]) - let postalCode: String? = nilOrValue(list[9]) - let subAdministrativeArea: String? = nilOrValue(list[10]) - let administrativeArea: String? = nilOrValue(list[11]) - let country: String? = nilOrValue(list[12]) - let countryCode: String? = nilOrValue(list[13]) - - return ApplePayContactDTO( - phoneNumber: phoneNumber, - emailAddress: emailAddress, - givenName: givenName, - familyName: familyName, - phoneticGivenName: phoneticGivenName, - phoneticFamilyName: phoneticFamilyName, - addressLines: addressLines, - subLocality: subLocality, - city: city, - postalCode: postalCode, - subAdministrativeArea: subAdministrativeArea, - administrativeArea: administrativeArea, - country: country, - countryCode: countryCode - ) - } - - func toList() -> [Any?] { - [ - phoneNumber, - emailAddress, - givenName, - familyName, - phoneticGivenName, - phoneticFamilyName, - addressLines, - subLocality, - city, - postalCode, - subAdministrativeArea, - administrativeArea, - country, - countryCode - ] - } + var phoneNumber: String? = nil + var emailAddress: String? = nil + var givenName: String? = nil + var familyName: String? = nil + var phoneticGivenName: String? = nil + var phoneticFamilyName: String? = nil + var addressLines: [String?]? = nil + var subLocality: String? = nil + var city: String? = nil + var postalCode: String? = nil + var subAdministrativeArea: String? = nil + var administrativeArea: String? = nil + var country: String? = nil + var countryCode: String? = nil + + static func fromList(_ list: [Any?]) -> ApplePayContactDTO? { + let phoneNumber: String? = nilOrValue(list[0]) + let emailAddress: String? = nilOrValue(list[1]) + let givenName: String? = nilOrValue(list[2]) + let familyName: String? = nilOrValue(list[3]) + let phoneticGivenName: String? = nilOrValue(list[4]) + let phoneticFamilyName: String? = nilOrValue(list[5]) + let addressLines: [String?]? = nilOrValue(list[6]) + let subLocality: String? = nilOrValue(list[7]) + let city: String? = nilOrValue(list[8]) + let postalCode: String? = nilOrValue(list[9]) + let subAdministrativeArea: String? = nilOrValue(list[10]) + let administrativeArea: String? = nilOrValue(list[11]) + let country: String? = nilOrValue(list[12]) + let countryCode: String? = nilOrValue(list[13]) + + return ApplePayContactDTO( + phoneNumber: phoneNumber, + emailAddress: emailAddress, + givenName: givenName, + familyName: familyName, + phoneticGivenName: phoneticGivenName, + phoneticFamilyName: phoneticFamilyName, + addressLines: addressLines, + subLocality: subLocality, + city: city, + postalCode: postalCode, + subAdministrativeArea: subAdministrativeArea, + administrativeArea: administrativeArea, + country: country, + countryCode: countryCode + ) + } + func toList() -> [Any?] { + return [ + phoneNumber, + emailAddress, + givenName, + familyName, + phoneticGivenName, + phoneticFamilyName, + addressLines, + subLocality, + city, + postalCode, + subAdministrativeArea, + administrativeArea, + country, + countryCode, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ApplePayShippingMethodDTO { - var label: String - var detail: String - var amount: AmountDTO - var identifier: String - var startDate: String? - var endDate: String? - - static func fromList(_ list: [Any?]) -> ApplePayShippingMethodDTO? { - let label = list[0] as! String - let detail = list[1] as! String - let amount = AmountDTO.fromList(list[2] as! [Any?])! - let identifier = list[3] as! String - let startDate: String? = nilOrValue(list[4]) - let endDate: String? = nilOrValue(list[5]) - - return ApplePayShippingMethodDTO( - label: label, - detail: detail, - amount: amount, - identifier: identifier, - startDate: startDate, - endDate: endDate - ) - } - - func toList() -> [Any?] { - [ - label, - detail, - amount.toList(), - identifier, - startDate, - endDate - ] - } + var label: String + var detail: String + var amount: AmountDTO + var identifier: String + var startDate: String? = nil + var endDate: String? = nil + + static func fromList(_ list: [Any?]) -> ApplePayShippingMethodDTO? { + let label = list[0] as! String + let detail = list[1] as! String + let amount = AmountDTO.fromList(list[2] as! [Any?])! + let identifier = list[3] as! String + let startDate: String? = nilOrValue(list[4]) + let endDate: String? = nilOrValue(list[5]) + + return ApplePayShippingMethodDTO( + label: label, + detail: detail, + amount: amount, + identifier: identifier, + startDate: startDate, + endDate: endDate + ) + } + func toList() -> [Any?] { + return [ + label, + detail, + amount.toList(), + identifier, + startDate, + endDate, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ApplePaySummaryItemDTO { - var label: String - var amount: AmountDTO - var type: ApplePaySummaryItemType - - static func fromList(_ list: [Any?]) -> ApplePaySummaryItemDTO? { - let label = list[0] as! String - let amount = AmountDTO.fromList(list[1] as! [Any?])! - let type = ApplePaySummaryItemType(rawValue: list[2] as! Int)! - - return ApplePaySummaryItemDTO( - label: label, - amount: amount, - type: type - ) - } - - func toList() -> [Any?] { - [ - label, - amount.toList(), - type.rawValue - ] - } + var label: String + var amount: AmountDTO + var type: ApplePaySummaryItemType + + static func fromList(_ list: [Any?]) -> ApplePaySummaryItemDTO? { + let label = list[0] as! String + let amount = AmountDTO.fromList(list[1] as! [Any?])! + let type = ApplePaySummaryItemType(rawValue: list[2] as! Int)! + + return ApplePaySummaryItemDTO( + label: label, + amount: amount, + type: type + ) + } + func toList() -> [Any?] { + return [ + label, + amount.toList(), + type.rawValue, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct GooglePayConfigurationDTO { - var googlePayEnvironment: GooglePayEnvironment - var merchantAccount: String? - var merchantInfoDTO: MerchantInfoDTO? - var totalPriceStatus: TotalPriceStatus? - var allowedCardNetworks: [String?]? - var allowedAuthMethods: [String?]? - var allowPrepaidCards: Bool? - var allowCreditCards: Bool? - var assuranceDetailsRequired: Bool? - var emailRequired: Bool? - var existingPaymentMethodRequired: Bool? - var shippingAddressRequired: Bool? - var shippingAddressParametersDTO: ShippingAddressParametersDTO? - var billingAddressRequired: Bool? - var billingAddressParametersDTO: BillingAddressParametersDTO? - - static func fromList(_ list: [Any?]) -> GooglePayConfigurationDTO? { - let googlePayEnvironment = GooglePayEnvironment(rawValue: list[0] as! Int)! - let merchantAccount: String? = nilOrValue(list[1]) - var merchantInfoDTO: MerchantInfoDTO? - if let merchantInfoDTOList: [Any?] = nilOrValue(list[2]) { - merchantInfoDTO = MerchantInfoDTO.fromList(merchantInfoDTOList) - } - var totalPriceStatus: TotalPriceStatus? - let totalPriceStatusEnumVal: Int? = nilOrValue(list[3]) - if let totalPriceStatusRawValue = totalPriceStatusEnumVal { - totalPriceStatus = TotalPriceStatus(rawValue: totalPriceStatusRawValue)! - } - let allowedCardNetworks: [String?]? = nilOrValue(list[4]) - let allowedAuthMethods: [String?]? = nilOrValue(list[5]) - let allowPrepaidCards: Bool? = nilOrValue(list[6]) - let allowCreditCards: Bool? = nilOrValue(list[7]) - let assuranceDetailsRequired: Bool? = nilOrValue(list[8]) - let emailRequired: Bool? = nilOrValue(list[9]) - let existingPaymentMethodRequired: Bool? = nilOrValue(list[10]) - let shippingAddressRequired: Bool? = nilOrValue(list[11]) - var shippingAddressParametersDTO: ShippingAddressParametersDTO? - if let shippingAddressParametersDTOList: [Any?] = nilOrValue(list[12]) { - shippingAddressParametersDTO = ShippingAddressParametersDTO.fromList(shippingAddressParametersDTOList) - } - let billingAddressRequired: Bool? = nilOrValue(list[13]) - var billingAddressParametersDTO: BillingAddressParametersDTO? - if let billingAddressParametersDTOList: [Any?] = nilOrValue(list[14]) { - billingAddressParametersDTO = BillingAddressParametersDTO.fromList(billingAddressParametersDTOList) - } - - return GooglePayConfigurationDTO( - googlePayEnvironment: googlePayEnvironment, - merchantAccount: merchantAccount, - merchantInfoDTO: merchantInfoDTO, - totalPriceStatus: totalPriceStatus, - allowedCardNetworks: allowedCardNetworks, - allowedAuthMethods: allowedAuthMethods, - allowPrepaidCards: allowPrepaidCards, - allowCreditCards: allowCreditCards, - assuranceDetailsRequired: assuranceDetailsRequired, - emailRequired: emailRequired, - existingPaymentMethodRequired: existingPaymentMethodRequired, - shippingAddressRequired: shippingAddressRequired, - shippingAddressParametersDTO: shippingAddressParametersDTO, - billingAddressRequired: billingAddressRequired, - billingAddressParametersDTO: billingAddressParametersDTO - ) - } - - func toList() -> [Any?] { - [ - googlePayEnvironment.rawValue, - merchantAccount, - merchantInfoDTO?.toList(), - totalPriceStatus?.rawValue, - allowedCardNetworks, - allowedAuthMethods, - allowPrepaidCards, - allowCreditCards, - assuranceDetailsRequired, - emailRequired, - existingPaymentMethodRequired, - shippingAddressRequired, - shippingAddressParametersDTO?.toList(), - billingAddressRequired, - billingAddressParametersDTO?.toList() - ] - } + var googlePayEnvironment: GooglePayEnvironment + var merchantAccount: String? = nil + var merchantInfoDTO: MerchantInfoDTO? = nil + var totalPriceStatus: TotalPriceStatus? = nil + var allowedCardNetworks: [String?]? = nil + var allowedAuthMethods: [String?]? = nil + var allowPrepaidCards: Bool? = nil + var allowCreditCards: Bool? = nil + var assuranceDetailsRequired: Bool? = nil + var emailRequired: Bool? = nil + var existingPaymentMethodRequired: Bool? = nil + var shippingAddressRequired: Bool? = nil + var shippingAddressParametersDTO: ShippingAddressParametersDTO? = nil + var billingAddressRequired: Bool? = nil + var billingAddressParametersDTO: BillingAddressParametersDTO? = nil + + static func fromList(_ list: [Any?]) -> GooglePayConfigurationDTO? { + let googlePayEnvironment = GooglePayEnvironment(rawValue: list[0] as! Int)! + let merchantAccount: String? = nilOrValue(list[1]) + var merchantInfoDTO: MerchantInfoDTO? = nil + if let merchantInfoDTOList: [Any?] = nilOrValue(list[2]) { + merchantInfoDTO = MerchantInfoDTO.fromList(merchantInfoDTOList) + } + var totalPriceStatus: TotalPriceStatus? = nil + let totalPriceStatusEnumVal: Int? = nilOrValue(list[3]) + if let totalPriceStatusRawValue = totalPriceStatusEnumVal { + totalPriceStatus = TotalPriceStatus(rawValue: totalPriceStatusRawValue)! + } + let allowedCardNetworks: [String?]? = nilOrValue(list[4]) + let allowedAuthMethods: [String?]? = nilOrValue(list[5]) + let allowPrepaidCards: Bool? = nilOrValue(list[6]) + let allowCreditCards: Bool? = nilOrValue(list[7]) + let assuranceDetailsRequired: Bool? = nilOrValue(list[8]) + let emailRequired: Bool? = nilOrValue(list[9]) + let existingPaymentMethodRequired: Bool? = nilOrValue(list[10]) + let shippingAddressRequired: Bool? = nilOrValue(list[11]) + var shippingAddressParametersDTO: ShippingAddressParametersDTO? = nil + if let shippingAddressParametersDTOList: [Any?] = nilOrValue(list[12]) { + shippingAddressParametersDTO = ShippingAddressParametersDTO.fromList(shippingAddressParametersDTOList) + } + let billingAddressRequired: Bool? = nilOrValue(list[13]) + var billingAddressParametersDTO: BillingAddressParametersDTO? = nil + if let billingAddressParametersDTOList: [Any?] = nilOrValue(list[14]) { + billingAddressParametersDTO = BillingAddressParametersDTO.fromList(billingAddressParametersDTOList) + } + + return GooglePayConfigurationDTO( + googlePayEnvironment: googlePayEnvironment, + merchantAccount: merchantAccount, + merchantInfoDTO: merchantInfoDTO, + totalPriceStatus: totalPriceStatus, + allowedCardNetworks: allowedCardNetworks, + allowedAuthMethods: allowedAuthMethods, + allowPrepaidCards: allowPrepaidCards, + allowCreditCards: allowCreditCards, + assuranceDetailsRequired: assuranceDetailsRequired, + emailRequired: emailRequired, + existingPaymentMethodRequired: existingPaymentMethodRequired, + shippingAddressRequired: shippingAddressRequired, + shippingAddressParametersDTO: shippingAddressParametersDTO, + billingAddressRequired: billingAddressRequired, + billingAddressParametersDTO: billingAddressParametersDTO + ) + } + func toList() -> [Any?] { + return [ + googlePayEnvironment.rawValue, + merchantAccount, + merchantInfoDTO?.toList(), + totalPriceStatus?.rawValue, + allowedCardNetworks, + allowedAuthMethods, + allowPrepaidCards, + allowCreditCards, + assuranceDetailsRequired, + emailRequired, + existingPaymentMethodRequired, + shippingAddressRequired, + shippingAddressParametersDTO?.toList(), + billingAddressRequired, + billingAddressParametersDTO?.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct MerchantInfoDTO { - var merchantName: String? - var merchantId: String? - - static func fromList(_ list: [Any?]) -> MerchantInfoDTO? { - let merchantName: String? = nilOrValue(list[0]) - let merchantId: String? = nilOrValue(list[1]) - - return MerchantInfoDTO( - merchantName: merchantName, - merchantId: merchantId - ) - } - - func toList() -> [Any?] { - [ - merchantName, - merchantId - ] - } + var merchantName: String? = nil + var merchantId: String? = nil + + static func fromList(_ list: [Any?]) -> MerchantInfoDTO? { + let merchantName: String? = nilOrValue(list[0]) + let merchantId: String? = nilOrValue(list[1]) + + return MerchantInfoDTO( + merchantName: merchantName, + merchantId: merchantId + ) + } + func toList() -> [Any?] { + return [ + merchantName, + merchantId, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ShippingAddressParametersDTO { - var allowedCountryCodes: [String?]? - var isPhoneNumberRequired: Bool? - - static func fromList(_ list: [Any?]) -> ShippingAddressParametersDTO? { - let allowedCountryCodes: [String?]? = nilOrValue(list[0]) - let isPhoneNumberRequired: Bool? = nilOrValue(list[1]) - - return ShippingAddressParametersDTO( - allowedCountryCodes: allowedCountryCodes, - isPhoneNumberRequired: isPhoneNumberRequired - ) - } - - func toList() -> [Any?] { - [ - allowedCountryCodes, - isPhoneNumberRequired - ] - } + var allowedCountryCodes: [String?]? = nil + var isPhoneNumberRequired: Bool? = nil + + static func fromList(_ list: [Any?]) -> ShippingAddressParametersDTO? { + let allowedCountryCodes: [String?]? = nilOrValue(list[0]) + let isPhoneNumberRequired: Bool? = nilOrValue(list[1]) + + return ShippingAddressParametersDTO( + allowedCountryCodes: allowedCountryCodes, + isPhoneNumberRequired: isPhoneNumberRequired + ) + } + func toList() -> [Any?] { + return [ + allowedCountryCodes, + isPhoneNumberRequired, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct BillingAddressParametersDTO { - var format: String? - var isPhoneNumberRequired: Bool? - - static func fromList(_ list: [Any?]) -> BillingAddressParametersDTO? { - let format: String? = nilOrValue(list[0]) - let isPhoneNumberRequired: Bool? = nilOrValue(list[1]) - - return BillingAddressParametersDTO( - format: format, - isPhoneNumberRequired: isPhoneNumberRequired - ) - } - - func toList() -> [Any?] { - [ - format, - isPhoneNumberRequired - ] - } + var format: String? = nil + var isPhoneNumberRequired: Bool? = nil + + static func fromList(_ list: [Any?]) -> BillingAddressParametersDTO? { + let format: String? = nilOrValue(list[0]) + let isPhoneNumberRequired: Bool? = nilOrValue(list[1]) + + return BillingAddressParametersDTO( + format: format, + isPhoneNumberRequired: isPhoneNumberRequired + ) + } + func toList() -> [Any?] { + return [ + format, + isPhoneNumberRequired, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct CashAppPayConfigurationDTO { - var cashAppPayEnvironment: CashAppPayEnvironment - var returnUrl: String - - static func fromList(_ list: [Any?]) -> CashAppPayConfigurationDTO? { - let cashAppPayEnvironment = CashAppPayEnvironment(rawValue: list[0] as! Int)! - let returnUrl = list[1] as! String - - return CashAppPayConfigurationDTO( - cashAppPayEnvironment: cashAppPayEnvironment, - returnUrl: returnUrl - ) - } - - func toList() -> [Any?] { - [ - cashAppPayEnvironment.rawValue, - returnUrl - ] - } + var cashAppPayEnvironment: CashAppPayEnvironment + var returnUrl: String + + static func fromList(_ list: [Any?]) -> CashAppPayConfigurationDTO? { + let cashAppPayEnvironment = CashAppPayEnvironment(rawValue: list[0] as! Int)! + let returnUrl = list[1] as! String + + return CashAppPayConfigurationDTO( + cashAppPayEnvironment: cashAppPayEnvironment, + returnUrl: returnUrl + ) + } + func toList() -> [Any?] { + return [ + cashAppPayEnvironment.rawValue, + returnUrl, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct PaymentResultDTO { - var type: PaymentResultEnum - var reason: String? - var result: PaymentResultModelDTO? - - static func fromList(_ list: [Any?]) -> PaymentResultDTO? { - let type = PaymentResultEnum(rawValue: list[0] as! Int)! - let reason: String? = nilOrValue(list[1]) - var result: PaymentResultModelDTO? - if let resultList: [Any?] = nilOrValue(list[2]) { - result = PaymentResultModelDTO.fromList(resultList) - } - - return PaymentResultDTO( - type: type, - reason: reason, - result: result - ) - } - - func toList() -> [Any?] { - [ - type.rawValue, - reason, - result?.toList() - ] - } + var type: PaymentResultEnum + var reason: String? = nil + var result: PaymentResultModelDTO? = nil + + static func fromList(_ list: [Any?]) -> PaymentResultDTO? { + let type = PaymentResultEnum(rawValue: list[0] as! Int)! + let reason: String? = nilOrValue(list[1]) + var result: PaymentResultModelDTO? = nil + if let resultList: [Any?] = nilOrValue(list[2]) { + result = PaymentResultModelDTO.fromList(resultList) + } + + return PaymentResultDTO( + type: type, + reason: reason, + result: result + ) + } + func toList() -> [Any?] { + return [ + type.rawValue, + reason, + result?.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct PaymentResultModelDTO { - var sessionId: String? - var sessionData: String? - var sessionResult: String? - var resultCode: String? - var order: OrderResponseDTO? - - static func fromList(_ list: [Any?]) -> PaymentResultModelDTO? { - let sessionId: String? = nilOrValue(list[0]) - let sessionData: String? = nilOrValue(list[1]) - let sessionResult: String? = nilOrValue(list[2]) - let resultCode: String? = nilOrValue(list[3]) - var order: OrderResponseDTO? - if let orderList: [Any?] = nilOrValue(list[4]) { - order = OrderResponseDTO.fromList(orderList) - } - - return PaymentResultModelDTO( - sessionId: sessionId, - sessionData: sessionData, - sessionResult: sessionResult, - resultCode: resultCode, - order: order - ) - } - - func toList() -> [Any?] { - [ - sessionId, - sessionData, - sessionResult, - resultCode, - order?.toList() - ] - } + var sessionId: String? = nil + var sessionData: String? = nil + var sessionResult: String? = nil + var resultCode: String? = nil + var order: OrderResponseDTO? = nil + + static func fromList(_ list: [Any?]) -> PaymentResultModelDTO? { + let sessionId: String? = nilOrValue(list[0]) + let sessionData: String? = nilOrValue(list[1]) + let sessionResult: String? = nilOrValue(list[2]) + let resultCode: String? = nilOrValue(list[3]) + var order: OrderResponseDTO? = nil + if let orderList: [Any?] = nilOrValue(list[4]) { + order = OrderResponseDTO.fromList(orderList) + } + + return PaymentResultModelDTO( + sessionId: sessionId, + sessionData: sessionData, + sessionResult: sessionResult, + resultCode: resultCode, + order: order + ) + } + func toList() -> [Any?] { + return [ + sessionId, + sessionData, + sessionResult, + resultCode, + order?.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct OrderResponseDTO { - var pspReference: String - var orderData: String - var amount: AmountDTO? - var remainingAmount: AmountDTO? - - static func fromList(_ list: [Any?]) -> OrderResponseDTO? { - let pspReference = list[0] as! String - let orderData = list[1] as! String - var amount: AmountDTO? - if let amountList: [Any?] = nilOrValue(list[2]) { - amount = AmountDTO.fromList(amountList) - } - var remainingAmount: AmountDTO? - if let remainingAmountList: [Any?] = nilOrValue(list[3]) { - remainingAmount = AmountDTO.fromList(remainingAmountList) - } - - return OrderResponseDTO( - pspReference: pspReference, - orderData: orderData, - amount: amount, - remainingAmount: remainingAmount - ) - } - - func toList() -> [Any?] { - [ - pspReference, - orderData, - amount?.toList(), - remainingAmount?.toList() - ] - } + var pspReference: String + var orderData: String + var amount: AmountDTO? = nil + var remainingAmount: AmountDTO? = nil + + static func fromList(_ list: [Any?]) -> OrderResponseDTO? { + let pspReference = list[0] as! String + let orderData = list[1] as! String + var amount: AmountDTO? = nil + if let amountList: [Any?] = nilOrValue(list[2]) { + amount = AmountDTO.fromList(amountList) + } + var remainingAmount: AmountDTO? = nil + if let remainingAmountList: [Any?] = nilOrValue(list[3]) { + remainingAmount = AmountDTO.fromList(remainingAmountList) + } + + return OrderResponseDTO( + pspReference: pspReference, + orderData: orderData, + amount: amount, + remainingAmount: remainingAmount + ) + } + func toList() -> [Any?] { + return [ + pspReference, + orderData, + amount?.toList(), + remainingAmount?.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct PlatformCommunicationModel { - var type: PlatformCommunicationType - var data: String? - var paymentResult: PaymentResultDTO? - - static func fromList(_ list: [Any?]) -> PlatformCommunicationModel? { - let type = PlatformCommunicationType(rawValue: list[0] as! Int)! - let data: String? = nilOrValue(list[1]) - var paymentResult: PaymentResultDTO? - if let paymentResultList: [Any?] = nilOrValue(list[2]) { - paymentResult = PaymentResultDTO.fromList(paymentResultList) - } - - return PlatformCommunicationModel( - type: type, - data: data, - paymentResult: paymentResult - ) - } - - func toList() -> [Any?] { - [ - type.rawValue, - data, - paymentResult?.toList() - ] - } + var type: PlatformCommunicationType + var data: String? = nil + var paymentResult: PaymentResultDTO? = nil + + static func fromList(_ list: [Any?]) -> PlatformCommunicationModel? { + let type = PlatformCommunicationType(rawValue: list[0] as! Int)! + let data: String? = nilOrValue(list[1]) + var paymentResult: PaymentResultDTO? = nil + if let paymentResultList: [Any?] = nilOrValue(list[2]) { + paymentResult = PaymentResultDTO.fromList(paymentResultList) + } + + return PlatformCommunicationModel( + type: type, + data: data, + paymentResult: paymentResult + ) + } + func toList() -> [Any?] { + return [ + type.rawValue, + data, + paymentResult?.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ComponentCommunicationModel { - var type: ComponentCommunicationType - var componentId: String - var data: Any? - var paymentResult: PaymentResultDTO? - - static func fromList(_ list: [Any?]) -> ComponentCommunicationModel? { - let type = ComponentCommunicationType(rawValue: list[0] as! Int)! - let componentId = list[1] as! String - let data: Any? = list[2] - var paymentResult: PaymentResultDTO? - if let paymentResultList: [Any?] = nilOrValue(list[3]) { - paymentResult = PaymentResultDTO.fromList(paymentResultList) - } - - return ComponentCommunicationModel( - type: type, - componentId: componentId, - data: data, - paymentResult: paymentResult - ) - } - - func toList() -> [Any?] { - [ - type.rawValue, - componentId, - data, - paymentResult?.toList() - ] - } + var type: ComponentCommunicationType + var componentId: String + var data: Any? = nil + var paymentResult: PaymentResultDTO? = nil + + static func fromList(_ list: [Any?]) -> ComponentCommunicationModel? { + let type = ComponentCommunicationType(rawValue: list[0] as! Int)! + let componentId = list[1] as! String + let data: Any? = list[2] + var paymentResult: PaymentResultDTO? = nil + if let paymentResultList: [Any?] = nilOrValue(list[3]) { + paymentResult = PaymentResultDTO.fromList(paymentResultList) + } + + return ComponentCommunicationModel( + type: type, + componentId: componentId, + data: data, + paymentResult: paymentResult + ) + } + func toList() -> [Any?] { + return [ + type.rawValue, + componentId, + data, + paymentResult?.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct PaymentEventDTO { - var paymentEventType: PaymentEventType - var result: String? - var actionResponse: [String?: Any?]? - var error: ErrorDTO? - - static func fromList(_ list: [Any?]) -> PaymentEventDTO? { - let paymentEventType = PaymentEventType(rawValue: list[0] as! Int)! - let result: String? = nilOrValue(list[1]) - let actionResponse: [String?: Any?]? = nilOrValue(list[2]) - var error: ErrorDTO? - if let errorList: [Any?] = nilOrValue(list[3]) { - error = ErrorDTO.fromList(errorList) - } - - return PaymentEventDTO( - paymentEventType: paymentEventType, - result: result, - actionResponse: actionResponse, - error: error - ) - } - - func toList() -> [Any?] { - [ - paymentEventType.rawValue, - result, - actionResponse, - error?.toList() - ] - } + var paymentEventType: PaymentEventType + var result: String? = nil + var actionResponse: [String?: Any?]? = nil + var error: ErrorDTO? = nil + + static func fromList(_ list: [Any?]) -> PaymentEventDTO? { + let paymentEventType = PaymentEventType(rawValue: list[0] as! Int)! + let result: String? = nilOrValue(list[1]) + let actionResponse: [String?: Any?]? = nilOrValue(list[2]) + var error: ErrorDTO? = nil + if let errorList: [Any?] = nilOrValue(list[3]) { + error = ErrorDTO.fromList(errorList) + } + + return PaymentEventDTO( + paymentEventType: paymentEventType, + result: result, + actionResponse: actionResponse, + error: error + ) + } + func toList() -> [Any?] { + return [ + paymentEventType.rawValue, + result, + actionResponse, + error?.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ErrorDTO { - var errorMessage: String? - var reason: String? - var dismissDropIn: Bool? - - static func fromList(_ list: [Any?]) -> ErrorDTO? { - let errorMessage: String? = nilOrValue(list[0]) - let reason: String? = nilOrValue(list[1]) - let dismissDropIn: Bool? = nilOrValue(list[2]) - - return ErrorDTO( - errorMessage: errorMessage, - reason: reason, - dismissDropIn: dismissDropIn - ) - } - - func toList() -> [Any?] { - [ - errorMessage, - reason, - dismissDropIn - ] - } + var errorMessage: String? = nil + var reason: String? = nil + var dismissDropIn: Bool? = nil + + static func fromList(_ list: [Any?]) -> ErrorDTO? { + let errorMessage: String? = nilOrValue(list[0]) + let reason: String? = nilOrValue(list[1]) + let dismissDropIn: Bool? = nilOrValue(list[2]) + + return ErrorDTO( + errorMessage: errorMessage, + reason: reason, + dismissDropIn: dismissDropIn + ) + } + func toList() -> [Any?] { + return [ + errorMessage, + reason, + dismissDropIn, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct DeletedStoredPaymentMethodResultDTO { - var storedPaymentMethodId: String - var isSuccessfullyRemoved: Bool - - static func fromList(_ list: [Any?]) -> DeletedStoredPaymentMethodResultDTO? { - let storedPaymentMethodId = list[0] as! String - let isSuccessfullyRemoved = list[1] as! Bool - - return DeletedStoredPaymentMethodResultDTO( - storedPaymentMethodId: storedPaymentMethodId, - isSuccessfullyRemoved: isSuccessfullyRemoved - ) - } - - func toList() -> [Any?] { - [ - storedPaymentMethodId, - isSuccessfullyRemoved - ] - } + var storedPaymentMethodId: String + var isSuccessfullyRemoved: Bool + + static func fromList(_ list: [Any?]) -> DeletedStoredPaymentMethodResultDTO? { + let storedPaymentMethodId = list[0] as! String + let isSuccessfullyRemoved = list[1] as! Bool + + return DeletedStoredPaymentMethodResultDTO( + storedPaymentMethodId: storedPaymentMethodId, + isSuccessfullyRemoved: isSuccessfullyRemoved + ) + } + func toList() -> [Any?] { + return [ + storedPaymentMethodId, + isSuccessfullyRemoved, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct CardComponentConfigurationDTO { - var environment: Environment - var clientKey: String - var countryCode: String - var amount: AmountDTO? - var shopperLocale: String? - var cardConfiguration: CardConfigurationDTO - var analyticsOptionsDTO: AnalyticsOptionsDTO - - static func fromList(_ list: [Any?]) -> CardComponentConfigurationDTO? { - let environment = Environment(rawValue: list[0] as! Int)! - let clientKey = list[1] as! String - let countryCode = list[2] as! String - var amount: AmountDTO? - if let amountList: [Any?] = nilOrValue(list[3]) { - amount = AmountDTO.fromList(amountList) - } - let shopperLocale: String? = nilOrValue(list[4]) - let cardConfiguration = CardConfigurationDTO.fromList(list[5] as! [Any?])! - let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[6] as! [Any?])! - - return CardComponentConfigurationDTO( - environment: environment, - clientKey: clientKey, - countryCode: countryCode, - amount: amount, - shopperLocale: shopperLocale, - cardConfiguration: cardConfiguration, - analyticsOptionsDTO: analyticsOptionsDTO - ) - } - - func toList() -> [Any?] { - [ - environment.rawValue, - clientKey, - countryCode, - amount?.toList(), - shopperLocale, - cardConfiguration.toList(), - analyticsOptionsDTO.toList() - ] - } + var environment: Environment + var clientKey: String + var countryCode: String + var amount: AmountDTO? = nil + var shopperLocale: String? = nil + var cardConfiguration: CardConfigurationDTO + var analyticsOptionsDTO: AnalyticsOptionsDTO + + static func fromList(_ list: [Any?]) -> CardComponentConfigurationDTO? { + let environment = Environment(rawValue: list[0] as! Int)! + let clientKey = list[1] as! String + let countryCode = list[2] as! String + var amount: AmountDTO? = nil + if let amountList: [Any?] = nilOrValue(list[3]) { + amount = AmountDTO.fromList(amountList) + } + let shopperLocale: String? = nilOrValue(list[4]) + let cardConfiguration = CardConfigurationDTO.fromList(list[5] as! [Any?])! + let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[6] as! [Any?])! + + return CardComponentConfigurationDTO( + environment: environment, + clientKey: clientKey, + countryCode: countryCode, + amount: amount, + shopperLocale: shopperLocale, + cardConfiguration: cardConfiguration, + analyticsOptionsDTO: analyticsOptionsDTO + ) + } + func toList() -> [Any?] { + return [ + environment.rawValue, + clientKey, + countryCode, + amount?.toList(), + shopperLocale, + cardConfiguration.toList(), + analyticsOptionsDTO.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct InstantPaymentConfigurationDTO { - var instantPaymentType: InstantPaymentType - var environment: Environment - var clientKey: String - var countryCode: String - var amount: AmountDTO? - var shopperLocale: String? - var analyticsOptionsDTO: AnalyticsOptionsDTO - var googlePayConfigurationDTO: GooglePayConfigurationDTO? - var applePayConfigurationDTO: ApplePayConfigurationDTO? - - static func fromList(_ list: [Any?]) -> InstantPaymentConfigurationDTO? { - let instantPaymentType = InstantPaymentType(rawValue: list[0] as! Int)! - let environment = Environment(rawValue: list[1] as! Int)! - let clientKey = list[2] as! String - let countryCode = list[3] as! String - var amount: AmountDTO? - if let amountList: [Any?] = nilOrValue(list[4]) { - amount = AmountDTO.fromList(amountList) - } - let shopperLocale: String? = nilOrValue(list[5]) - let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[6] as! [Any?])! - var googlePayConfigurationDTO: GooglePayConfigurationDTO? - if let googlePayConfigurationDTOList: [Any?] = nilOrValue(list[7]) { - googlePayConfigurationDTO = GooglePayConfigurationDTO.fromList(googlePayConfigurationDTOList) - } - var applePayConfigurationDTO: ApplePayConfigurationDTO? - if let applePayConfigurationDTOList: [Any?] = nilOrValue(list[8]) { - applePayConfigurationDTO = ApplePayConfigurationDTO.fromList(applePayConfigurationDTOList) - } - - return InstantPaymentConfigurationDTO( - instantPaymentType: instantPaymentType, - environment: environment, - clientKey: clientKey, - countryCode: countryCode, - amount: amount, - shopperLocale: shopperLocale, - analyticsOptionsDTO: analyticsOptionsDTO, - googlePayConfigurationDTO: googlePayConfigurationDTO, - applePayConfigurationDTO: applePayConfigurationDTO - ) - } - - func toList() -> [Any?] { - [ - instantPaymentType.rawValue, - environment.rawValue, - clientKey, - countryCode, - amount?.toList(), - shopperLocale, - analyticsOptionsDTO.toList(), - googlePayConfigurationDTO?.toList(), - applePayConfigurationDTO?.toList() - ] - } + var instantPaymentType: InstantPaymentType + var environment: Environment + var clientKey: String + var countryCode: String + var amount: AmountDTO? = nil + var shopperLocale: String? = nil + var analyticsOptionsDTO: AnalyticsOptionsDTO + var googlePayConfigurationDTO: GooglePayConfigurationDTO? = nil + var applePayConfigurationDTO: ApplePayConfigurationDTO? = nil + + static func fromList(_ list: [Any?]) -> InstantPaymentConfigurationDTO? { + let instantPaymentType = InstantPaymentType(rawValue: list[0] as! Int)! + let environment = Environment(rawValue: list[1] as! Int)! + let clientKey = list[2] as! String + let countryCode = list[3] as! String + var amount: AmountDTO? = nil + if let amountList: [Any?] = nilOrValue(list[4]) { + amount = AmountDTO.fromList(amountList) + } + let shopperLocale: String? = nilOrValue(list[5]) + let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[6] as! [Any?])! + var googlePayConfigurationDTO: GooglePayConfigurationDTO? = nil + if let googlePayConfigurationDTOList: [Any?] = nilOrValue(list[7]) { + googlePayConfigurationDTO = GooglePayConfigurationDTO.fromList(googlePayConfigurationDTOList) + } + var applePayConfigurationDTO: ApplePayConfigurationDTO? = nil + if let applePayConfigurationDTOList: [Any?] = nilOrValue(list[8]) { + applePayConfigurationDTO = ApplePayConfigurationDTO.fromList(applePayConfigurationDTOList) + } + + return InstantPaymentConfigurationDTO( + instantPaymentType: instantPaymentType, + environment: environment, + clientKey: clientKey, + countryCode: countryCode, + amount: amount, + shopperLocale: shopperLocale, + analyticsOptionsDTO: analyticsOptionsDTO, + googlePayConfigurationDTO: googlePayConfigurationDTO, + applePayConfigurationDTO: applePayConfigurationDTO + ) + } + func toList() -> [Any?] { + return [ + instantPaymentType.rawValue, + environment.rawValue, + clientKey, + countryCode, + amount?.toList(), + shopperLocale, + analyticsOptionsDTO.toList(), + googlePayConfigurationDTO?.toList(), + applePayConfigurationDTO?.toList(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct InstantPaymentSetupResultDTO { - var instantPaymentType: InstantPaymentType - var isSupported: Bool - var resultData: Any? - - static func fromList(_ list: [Any?]) -> InstantPaymentSetupResultDTO? { - let instantPaymentType = InstantPaymentType(rawValue: list[0] as! Int)! - let isSupported = list[1] as! Bool - let resultData: Any? = list[2] - - return InstantPaymentSetupResultDTO( - instantPaymentType: instantPaymentType, - isSupported: isSupported, - resultData: resultData - ) - } - - func toList() -> [Any?] { - [ - instantPaymentType.rawValue, - isSupported, - resultData - ] - } + var instantPaymentType: InstantPaymentType + var isSupported: Bool + var resultData: Any? = nil + + static func fromList(_ list: [Any?]) -> InstantPaymentSetupResultDTO? { + let instantPaymentType = InstantPaymentType(rawValue: list[0] as! Int)! + let isSupported = list[1] as! Bool + let resultData: Any? = list[2] + + return InstantPaymentSetupResultDTO( + instantPaymentType: instantPaymentType, + isSupported: isSupported, + resultData: resultData + ) + } + func toList() -> [Any?] { + return [ + instantPaymentType.rawValue, + isSupported, + resultData, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct UnencryptedCardDTO { - var cardNumber: String? - var expiryMonth: String? - var expiryYear: String? - var cvc: String? - - static func fromList(_ list: [Any?]) -> UnencryptedCardDTO? { - let cardNumber: String? = nilOrValue(list[0]) - let expiryMonth: String? = nilOrValue(list[1]) - let expiryYear: String? = nilOrValue(list[2]) - let cvc: String? = nilOrValue(list[3]) - - return UnencryptedCardDTO( - cardNumber: cardNumber, - expiryMonth: expiryMonth, - expiryYear: expiryYear, - cvc: cvc - ) - } - - func toList() -> [Any?] { - [ - cardNumber, - expiryMonth, - expiryYear, - cvc - ] - } + var cardNumber: String? = nil + var expiryMonth: String? = nil + var expiryYear: String? = nil + var cvc: String? = nil + + static func fromList(_ list: [Any?]) -> UnencryptedCardDTO? { + let cardNumber: String? = nilOrValue(list[0]) + let expiryMonth: String? = nilOrValue(list[1]) + let expiryYear: String? = nilOrValue(list[2]) + let cvc: String? = nilOrValue(list[3]) + + return UnencryptedCardDTO( + cardNumber: cardNumber, + expiryMonth: expiryMonth, + expiryYear: expiryYear, + cvc: cvc + ) + } + func toList() -> [Any?] { + return [ + cardNumber, + expiryMonth, + expiryYear, + cvc, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct EncryptedCardDTO { - var encryptedCardNumber: String? - var encryptedExpiryMonth: String? - var encryptedExpiryYear: String? - var encryptedSecurityCode: String? - - static func fromList(_ list: [Any?]) -> EncryptedCardDTO? { - let encryptedCardNumber: String? = nilOrValue(list[0]) - let encryptedExpiryMonth: String? = nilOrValue(list[1]) - let encryptedExpiryYear: String? = nilOrValue(list[2]) - let encryptedSecurityCode: String? = nilOrValue(list[3]) - - return EncryptedCardDTO( - encryptedCardNumber: encryptedCardNumber, - encryptedExpiryMonth: encryptedExpiryMonth, - encryptedExpiryYear: encryptedExpiryYear, - encryptedSecurityCode: encryptedSecurityCode - ) - } - - func toList() -> [Any?] { - [ - encryptedCardNumber, - encryptedExpiryMonth, - encryptedExpiryYear, - encryptedSecurityCode - ] - } + var encryptedCardNumber: String? = nil + var encryptedExpiryMonth: String? = nil + var encryptedExpiryYear: String? = nil + var encryptedSecurityCode: String? = nil + + static func fromList(_ list: [Any?]) -> EncryptedCardDTO? { + let encryptedCardNumber: String? = nilOrValue(list[0]) + let encryptedExpiryMonth: String? = nilOrValue(list[1]) + let encryptedExpiryYear: String? = nilOrValue(list[2]) + let encryptedSecurityCode: String? = nilOrValue(list[3]) + + return EncryptedCardDTO( + encryptedCardNumber: encryptedCardNumber, + encryptedExpiryMonth: encryptedExpiryMonth, + encryptedExpiryYear: encryptedExpiryYear, + encryptedSecurityCode: encryptedSecurityCode + ) + } + func toList() -> [Any?] { + return [ + encryptedCardNumber, + encryptedExpiryMonth, + encryptedExpiryYear, + encryptedSecurityCode, + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ActionComponentConfigurationDTO { - var environment: Environment - var clientKey: String - var shopperLocale: String? - var amount: AmountDTO? - var analyticsOptionsDTO: AnalyticsOptionsDTO - - static func fromList(_ list: [Any?]) -> ActionComponentConfigurationDTO? { - let environment = Environment(rawValue: list[0] as! Int)! - let clientKey = list[1] as! String - let shopperLocale: String? = nilOrValue(list[2]) - var amount: AmountDTO? - if let amountList: [Any?] = nilOrValue(list[3]) { - amount = AmountDTO.fromList(amountList) - } - let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[4] as! [Any?])! - - return ActionComponentConfigurationDTO( - environment: environment, - clientKey: clientKey, - shopperLocale: shopperLocale, - amount: amount, - analyticsOptionsDTO: analyticsOptionsDTO - ) - } - - func toList() -> [Any?] { - [ - environment.rawValue, - clientKey, - shopperLocale, - amount?.toList(), - analyticsOptionsDTO.toList() - ] - } + var environment: Environment + var clientKey: String + var shopperLocale: String? = nil + var amount: AmountDTO? = nil + var analyticsOptionsDTO: AnalyticsOptionsDTO + + static func fromList(_ list: [Any?]) -> ActionComponentConfigurationDTO? { + let environment = Environment(rawValue: list[0] as! Int)! + let clientKey = list[1] as! String + let shopperLocale: String? = nilOrValue(list[2]) + var amount: AmountDTO? = nil + if let amountList: [Any?] = nilOrValue(list[3]) { + amount = AmountDTO.fromList(amountList) + } + let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[4] as! [Any?])! + + return ActionComponentConfigurationDTO( + environment: environment, + clientKey: clientKey, + shopperLocale: shopperLocale, + amount: amount, + analyticsOptionsDTO: analyticsOptionsDTO + ) + } + func toList() -> [Any?] { + return [ + environment.rawValue, + clientKey, + shopperLocale, + amount?.toList(), + analyticsOptionsDTO.toList(), + ] + } } private class CheckoutPlatformInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return ActionComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 129: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 130: - return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) - case 131: - return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 132: - return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) - case 133: - return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) - case 134: - return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) - case 135: - return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 136: - return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 137: - return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 138: - return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 139: - return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) - case 140: - return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) - case 141: - return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 142: - return EncryptedCardDTO.fromList(self.readValue() as! [Any?]) - case 143: - return ErrorDTO.fromList(self.readValue() as! [Any?]) - case 144: - return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 145: - return InstantPaymentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 146: - return InstantPaymentSetupResultDTO.fromList(self.readValue() as! [Any?]) - case 147: - return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) - case 148: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) - case 149: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) - case 150: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) - case 151: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) - case 152: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) - case 153: - return SessionDTO.fromList(self.readValue() as! [Any?]) - case 154: - return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 155: - return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return ActionComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 129: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 130: + return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) + case 131: + return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 132: + return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) + case 133: + return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) + case 134: + return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) + case 135: + return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 136: + return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 137: + return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 138: + return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 139: + return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) + case 140: + return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) + case 141: + return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 142: + return EncryptedCardDTO.fromList(self.readValue() as! [Any?]) + case 143: + return ErrorDTO.fromList(self.readValue() as! [Any?]) + case 144: + return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 145: + return InstantPaymentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 146: + return InstantPaymentSetupResultDTO.fromList(self.readValue() as! [Any?]) + case 147: + return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) + case 148: + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + case 149: + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + case 150: + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + case 151: + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + case 152: + return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + case 153: + return SessionDTO.fromList(self.readValue() as! [Any?]) + case 154: + return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 155: + return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class CheckoutPlatformInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? ActionComponentConfigurationDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? AmountDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? AnalyticsOptionsDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayConfigurationDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayContactDTO { - super.writeByte(132) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayShippingMethodDTO { - super.writeByte(133) - super.writeValue(value.toList()) - } else if let value = value as? ApplePaySummaryItemDTO { - super.writeByte(134) - super.writeValue(value.toList()) - } else if let value = value as? BillingAddressParametersDTO { - super.writeByte(135) - super.writeValue(value.toList()) - } else if let value = value as? CardComponentConfigurationDTO { - super.writeByte(136) - super.writeValue(value.toList()) - } else if let value = value as? CardConfigurationDTO { - super.writeByte(137) - super.writeValue(value.toList()) - } else if let value = value as? CashAppPayConfigurationDTO { - super.writeByte(138) - super.writeValue(value.toList()) - } else if let value = value as? ComponentCommunicationModel { - super.writeByte(139) - super.writeValue(value.toList()) - } else if let value = value as? DeletedStoredPaymentMethodResultDTO { - super.writeByte(140) - super.writeValue(value.toList()) - } else if let value = value as? DropInConfigurationDTO { - super.writeByte(141) - super.writeValue(value.toList()) - } else if let value = value as? EncryptedCardDTO { - super.writeByte(142) - super.writeValue(value.toList()) - } else if let value = value as? ErrorDTO { - super.writeByte(143) - super.writeValue(value.toList()) - } else if let value = value as? GooglePayConfigurationDTO { - super.writeByte(144) - super.writeValue(value.toList()) - } else if let value = value as? InstantPaymentConfigurationDTO { - super.writeByte(145) - super.writeValue(value.toList()) - } else if let value = value as? InstantPaymentSetupResultDTO { - super.writeByte(146) - super.writeValue(value.toList()) - } else if let value = value as? MerchantInfoDTO { - super.writeByte(147) - super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { - super.writeByte(148) - super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { - super.writeByte(149) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { - super.writeByte(150) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { - super.writeByte(151) - super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { - super.writeByte(152) - super.writeValue(value.toList()) - } else if let value = value as? SessionDTO { - super.writeByte(153) - super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { - super.writeByte(154) - super.writeValue(value.toList()) - } else if let value = value as? UnencryptedCardDTO { - super.writeByte(155) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? ActionComponentConfigurationDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? AmountDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? AnalyticsOptionsDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayConfigurationDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayContactDTO { + super.writeByte(132) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayShippingMethodDTO { + super.writeByte(133) + super.writeValue(value.toList()) + } else if let value = value as? ApplePaySummaryItemDTO { + super.writeByte(134) + super.writeValue(value.toList()) + } else if let value = value as? BillingAddressParametersDTO { + super.writeByte(135) + super.writeValue(value.toList()) + } else if let value = value as? CardComponentConfigurationDTO { + super.writeByte(136) + super.writeValue(value.toList()) + } else if let value = value as? CardConfigurationDTO { + super.writeByte(137) + super.writeValue(value.toList()) + } else if let value = value as? CashAppPayConfigurationDTO { + super.writeByte(138) + super.writeValue(value.toList()) + } else if let value = value as? ComponentCommunicationModel { + super.writeByte(139) + super.writeValue(value.toList()) + } else if let value = value as? DeletedStoredPaymentMethodResultDTO { + super.writeByte(140) + super.writeValue(value.toList()) + } else if let value = value as? DropInConfigurationDTO { + super.writeByte(141) + super.writeValue(value.toList()) + } else if let value = value as? EncryptedCardDTO { + super.writeByte(142) + super.writeValue(value.toList()) + } else if let value = value as? ErrorDTO { + super.writeByte(143) + super.writeValue(value.toList()) + } else if let value = value as? GooglePayConfigurationDTO { + super.writeByte(144) + super.writeValue(value.toList()) + } else if let value = value as? InstantPaymentConfigurationDTO { + super.writeByte(145) + super.writeValue(value.toList()) + } else if let value = value as? InstantPaymentSetupResultDTO { + super.writeByte(146) + super.writeValue(value.toList()) + } else if let value = value as? MerchantInfoDTO { + super.writeByte(147) + super.writeValue(value.toList()) + } else if let value = value as? OrderResponseDTO { + super.writeByte(148) + super.writeValue(value.toList()) + } else if let value = value as? PaymentEventDTO { + super.writeByte(149) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultDTO { + super.writeByte(150) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultModelDTO { + super.writeByte(151) + super.writeValue(value.toList()) + } else if let value = value as? PlatformCommunicationModel { + super.writeByte(152) + super.writeValue(value.toList()) + } else if let value = value as? SessionDTO { + super.writeByte(153) + super.writeValue(value.toList()) + } else if let value = value as? ShippingAddressParametersDTO { + super.writeByte(154) + super.writeValue(value.toList()) + } else if let value = value as? UnencryptedCardDTO { + super.writeByte(155) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class CheckoutPlatformInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - CheckoutPlatformInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + return CheckoutPlatformInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - CheckoutPlatformInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + return CheckoutPlatformInterfaceCodecWriter(data: data) + } } class CheckoutPlatformInterfaceCodec: FlutterStandardMessageCodec { - static let shared = CheckoutPlatformInterfaceCodec(readerWriter: CheckoutPlatformInterfaceCodecReaderWriter()) + static let shared = CheckoutPlatformInterfaceCodec(readerWriter: CheckoutPlatformInterfaceCodecReaderWriter()) } /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol CheckoutPlatformInterface { - func getReturnUrl(completion: @escaping (Result) -> Void) - func createSession(sessionId: String, sessionData: String, configuration: Any?, completion: @escaping (Result) -> Void) - func clearSession() throws - func encryptCard(unencryptedCardDTO: UnencryptedCardDTO, publicKey: String, completion: @escaping (Result) -> Void) - func encryptBin(bin: String, publicKey: String, completion: @escaping (Result) -> Void) - func enableConsoleLogging(loggingEnabled: Bool) throws + func getReturnUrl(completion: @escaping (Result) -> Void) + func createSession(sessionId: String, sessionData: String, configuration: Any?, completion: @escaping (Result) -> Void) + func encryptCard(unencryptedCardDTO: UnencryptedCardDTO, publicKey: String, completion: @escaping (Result) -> Void) + func encryptBin(bin: String, publicKey: String, completion: @escaping (Result) -> Void) + func enableConsoleLogging(loggingEnabled: Bool) throws } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class CheckoutPlatformInterfaceSetup { - /// The codec used by CheckoutPlatformInterface. - static var codec: FlutterStandardMessageCodec { CheckoutPlatformInterfaceCodec.shared } - /// Sets up an instance of `CheckoutPlatformInterface` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: CheckoutPlatformInterface?) { - let getReturnUrlChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl", binaryMessenger: binaryMessenger, codec: codec) - if let api { - getReturnUrlChannel.setMessageHandler { _, reply in - api.getReturnUrl { result in - switch result { - case let .success(res): - reply(wrapResult(res)) - case let .failure(error): - reply(wrapError(error)) - } - } - } - } else { - getReturnUrlChannel.setMessageHandler(nil) + /// The codec used by CheckoutPlatformInterface. + static var codec: FlutterStandardMessageCodec { CheckoutPlatformInterfaceCodec.shared } + /// Sets up an instance of `CheckoutPlatformInterface` to handle messages through the `binaryMessenger`. + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: CheckoutPlatformInterface?) { + let getReturnUrlChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + getReturnUrlChannel.setMessageHandler { _, reply in + api.getReturnUrl { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } } - let createSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession", binaryMessenger: binaryMessenger, codec: codec) - if let api { - createSessionChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let sessionIdArg = args[0] as! String - let sessionDataArg = args[1] as! String - let configurationArg: Any? = args[2] - api.createSession(sessionId: sessionIdArg, sessionData: sessionDataArg, configuration: configurationArg) { result in - switch result { - case let .success(res): - reply(wrapResult(res)) - case let .failure(error): - reply(wrapError(error)) - } - } - } - } else { - createSessionChannel.setMessageHandler(nil) + } + } else { + getReturnUrlChannel.setMessageHandler(nil) + } + let createSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + createSessionChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let sessionIdArg = args[0] as! String + let sessionDataArg = args[1] as! String + let configurationArg: Any? = args[2] + api.createSession(sessionId: sessionIdArg, sessionData: sessionDataArg, configuration: configurationArg) { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } } - let clearSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession", binaryMessenger: binaryMessenger, codec: codec) - if let api { - clearSessionChannel.setMessageHandler { _, reply in - do { - try api.clearSession() - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - clearSessionChannel.setMessageHandler(nil) + } + } else { + createSessionChannel.setMessageHandler(nil) + } + let encryptCardChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + encryptCardChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let unencryptedCardDTOArg = args[0] as! UnencryptedCardDTO + let publicKeyArg = args[1] as! String + api.encryptCard(unencryptedCardDTO: unencryptedCardDTOArg, publicKey: publicKeyArg) { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } } - let encryptCardChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard", binaryMessenger: binaryMessenger, codec: codec) - if let api { - encryptCardChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let unencryptedCardDTOArg = args[0] as! UnencryptedCardDTO - let publicKeyArg = args[1] as! String - api.encryptCard(unencryptedCardDTO: unencryptedCardDTOArg, publicKey: publicKeyArg) { result in - switch result { - case let .success(res): - reply(wrapResult(res)) - case let .failure(error): - reply(wrapError(error)) - } - } - } - } else { - encryptCardChannel.setMessageHandler(nil) + } + } else { + encryptCardChannel.setMessageHandler(nil) + } + let encryptBinChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + encryptBinChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let binArg = args[0] as! String + let publicKeyArg = args[1] as! String + api.encryptBin(bin: binArg, publicKey: publicKeyArg) { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } } - let encryptBinChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin", binaryMessenger: binaryMessenger, codec: codec) - if let api { - encryptBinChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let binArg = args[0] as! String - let publicKeyArg = args[1] as! String - api.encryptBin(bin: binArg, publicKey: publicKeyArg) { result in - switch result { - case let .success(res): - reply(wrapResult(res)) - case let .failure(error): - reply(wrapError(error)) - } - } - } - } else { - encryptBinChannel.setMessageHandler(nil) - } - let enableConsoleLoggingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging", binaryMessenger: binaryMessenger, codec: codec) - if let api { - enableConsoleLoggingChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let loggingEnabledArg = args[0] as! Bool - do { - try api.enableConsoleLogging(loggingEnabled: loggingEnabledArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - enableConsoleLoggingChannel.setMessageHandler(nil) + } + } else { + encryptBinChannel.setMessageHandler(nil) + } + let enableConsoleLoggingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + enableConsoleLoggingChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let loggingEnabledArg = args[0] as! Bool + do { + try api.enableConsoleLogging(loggingEnabled: loggingEnabledArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } + } + } else { + enableConsoleLoggingChannel.setMessageHandler(nil) } + } } - private class DropInPlatformInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 129: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 130: - return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) - case 131: - return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 132: - return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) - case 133: - return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) - case 134: - return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) - case 135: - return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 136: - return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 137: - return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 138: - return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) - case 139: - return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 140: - return ErrorDTO.fromList(self.readValue() as! [Any?]) - case 141: - return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 142: - return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) - case 143: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) - case 144: - return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 129: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 130: + return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) + case 131: + return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 132: + return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) + case 133: + return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) + case 134: + return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) + case 135: + return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 136: + return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 137: + return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 138: + return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) + case 139: + return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 140: + return ErrorDTO.fromList(self.readValue() as! [Any?]) + case 141: + return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 142: + return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) + case 143: + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + case 144: + return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class DropInPlatformInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? AmountDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? AmountDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? AnalyticsOptionsDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayConfigurationDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayContactDTO { - super.writeByte(132) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayShippingMethodDTO { - super.writeByte(133) - super.writeValue(value.toList()) - } else if let value = value as? ApplePaySummaryItemDTO { - super.writeByte(134) - super.writeValue(value.toList()) - } else if let value = value as? BillingAddressParametersDTO { - super.writeByte(135) - super.writeValue(value.toList()) - } else if let value = value as? CardConfigurationDTO { - super.writeByte(136) - super.writeValue(value.toList()) - } else if let value = value as? CashAppPayConfigurationDTO { - super.writeByte(137) - super.writeValue(value.toList()) - } else if let value = value as? DeletedStoredPaymentMethodResultDTO { - super.writeByte(138) - super.writeValue(value.toList()) - } else if let value = value as? DropInConfigurationDTO { - super.writeByte(139) - super.writeValue(value.toList()) - } else if let value = value as? ErrorDTO { - super.writeByte(140) - super.writeValue(value.toList()) - } else if let value = value as? GooglePayConfigurationDTO { - super.writeByte(141) - super.writeValue(value.toList()) - } else if let value = value as? MerchantInfoDTO { - super.writeByte(142) - super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { - super.writeByte(143) - super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { - super.writeByte(144) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? AmountDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? AmountDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? AnalyticsOptionsDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayConfigurationDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayContactDTO { + super.writeByte(132) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayShippingMethodDTO { + super.writeByte(133) + super.writeValue(value.toList()) + } else if let value = value as? ApplePaySummaryItemDTO { + super.writeByte(134) + super.writeValue(value.toList()) + } else if let value = value as? BillingAddressParametersDTO { + super.writeByte(135) + super.writeValue(value.toList()) + } else if let value = value as? CardConfigurationDTO { + super.writeByte(136) + super.writeValue(value.toList()) + } else if let value = value as? CashAppPayConfigurationDTO { + super.writeByte(137) + super.writeValue(value.toList()) + } else if let value = value as? DeletedStoredPaymentMethodResultDTO { + super.writeByte(138) + super.writeValue(value.toList()) + } else if let value = value as? DropInConfigurationDTO { + super.writeByte(139) + super.writeValue(value.toList()) + } else if let value = value as? ErrorDTO { + super.writeByte(140) + super.writeValue(value.toList()) + } else if let value = value as? GooglePayConfigurationDTO { + super.writeByte(141) + super.writeValue(value.toList()) + } else if let value = value as? MerchantInfoDTO { + super.writeByte(142) + super.writeValue(value.toList()) + } else if let value = value as? PaymentEventDTO { + super.writeByte(143) + super.writeValue(value.toList()) + } else if let value = value as? ShippingAddressParametersDTO { + super.writeByte(144) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class DropInPlatformInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - DropInPlatformInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + return DropInPlatformInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - DropInPlatformInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + return DropInPlatformInterfaceCodecWriter(data: data) + } } class DropInPlatformInterfaceCodec: FlutterStandardMessageCodec { - static let shared = DropInPlatformInterfaceCodec(readerWriter: DropInPlatformInterfaceCodecReaderWriter()) + static let shared = DropInPlatformInterfaceCodec(readerWriter: DropInPlatformInterfaceCodecReaderWriter()) } /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol DropInPlatformInterface { - func showDropInSession(dropInConfigurationDTO: DropInConfigurationDTO) throws - func showDropInAdvanced(dropInConfigurationDTO: DropInConfigurationDTO, paymentMethodsResponse: String) throws - func onPaymentsResult(paymentsResult: PaymentEventDTO) throws - func onPaymentsDetailsResult(paymentsDetailsResult: PaymentEventDTO) throws - func onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) throws - func cleanUpDropIn() throws + func showDropInSession(dropInConfigurationDTO: DropInConfigurationDTO) throws + func showDropInAdvanced(dropInConfigurationDTO: DropInConfigurationDTO, paymentMethodsResponse: String) throws + func onPaymentsResult(paymentsResult: PaymentEventDTO) throws + func onPaymentsDetailsResult(paymentsDetailsResult: PaymentEventDTO) throws + func onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) throws + func onBalanceCheckResult(balanceCheckResponse: String) throws + func onOrderRequestResult(orderRequestResponse: String) throws + func cleanUpDropIn() throws } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class DropInPlatformInterfaceSetup { - /// The codec used by DropInPlatformInterface. - static var codec: FlutterStandardMessageCodec { DropInPlatformInterfaceCodec.shared } - /// Sets up an instance of `DropInPlatformInterface` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: DropInPlatformInterface?) { - let showDropInSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession", binaryMessenger: binaryMessenger, codec: codec) - if let api { - showDropInSessionChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let dropInConfigurationDTOArg = args[0] as! DropInConfigurationDTO - do { - try api.showDropInSession(dropInConfigurationDTO: dropInConfigurationDTOArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - showDropInSessionChannel.setMessageHandler(nil) + /// The codec used by DropInPlatformInterface. + static var codec: FlutterStandardMessageCodec { DropInPlatformInterfaceCodec.shared } + /// Sets up an instance of `DropInPlatformInterface` to handle messages through the `binaryMessenger`. + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: DropInPlatformInterface?) { + let showDropInSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + showDropInSessionChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let dropInConfigurationDTOArg = args[0] as! DropInConfigurationDTO + do { + try api.showDropInSession(dropInConfigurationDTO: dropInConfigurationDTOArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + showDropInSessionChannel.setMessageHandler(nil) + } + let showDropInAdvancedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + showDropInAdvancedChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let dropInConfigurationDTOArg = args[0] as! DropInConfigurationDTO + let paymentMethodsResponseArg = args[1] as! String + do { + try api.showDropInAdvanced(dropInConfigurationDTO: dropInConfigurationDTOArg, paymentMethodsResponse: paymentMethodsResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + showDropInAdvancedChannel.setMessageHandler(nil) + } + let onPaymentsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onPaymentsResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let paymentsResultArg = args[0] as! PaymentEventDTO + do { + try api.onPaymentsResult(paymentsResult: paymentsResultArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let showDropInAdvancedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced", binaryMessenger: binaryMessenger, codec: codec) - if let api { - showDropInAdvancedChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let dropInConfigurationDTOArg = args[0] as! DropInConfigurationDTO - let paymentMethodsResponseArg = args[1] as! String - do { - try api.showDropInAdvanced(dropInConfigurationDTO: dropInConfigurationDTOArg, paymentMethodsResponse: paymentMethodsResponseArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - showDropInAdvancedChannel.setMessageHandler(nil) + } + } else { + onPaymentsResultChannel.setMessageHandler(nil) + } + let onPaymentsDetailsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onPaymentsDetailsResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let paymentsDetailsResultArg = args[0] as! PaymentEventDTO + do { + try api.onPaymentsDetailsResult(paymentsDetailsResult: paymentsDetailsResultArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let onPaymentsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult", binaryMessenger: binaryMessenger, codec: codec) - if let api { - onPaymentsResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let paymentsResultArg = args[0] as! PaymentEventDTO - do { - try api.onPaymentsResult(paymentsResult: paymentsResultArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - onPaymentsResultChannel.setMessageHandler(nil) + } + } else { + onPaymentsDetailsResultChannel.setMessageHandler(nil) + } + let onDeleteStoredPaymentMethodResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onDeleteStoredPaymentMethodResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let deleteStoredPaymentMethodResultDTOArg = args[0] as! DeletedStoredPaymentMethodResultDTO + do { + try api.onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: deleteStoredPaymentMethodResultDTOArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let onPaymentsDetailsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult", binaryMessenger: binaryMessenger, codec: codec) - if let api { - onPaymentsDetailsResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let paymentsDetailsResultArg = args[0] as! PaymentEventDTO - do { - try api.onPaymentsDetailsResult(paymentsDetailsResult: paymentsDetailsResultArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - onPaymentsDetailsResultChannel.setMessageHandler(nil) + } + } else { + onDeleteStoredPaymentMethodResultChannel.setMessageHandler(nil) + } + let onBalanceCheckResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onBalanceCheckResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let balanceCheckResponseArg = args[0] as! String + do { + try api.onBalanceCheckResult(balanceCheckResponse: balanceCheckResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let onDeleteStoredPaymentMethodResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult", binaryMessenger: binaryMessenger, codec: codec) - if let api { - onDeleteStoredPaymentMethodResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let deleteStoredPaymentMethodResultDTOArg = args[0] as! DeletedStoredPaymentMethodResultDTO - do { - try api.onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: deleteStoredPaymentMethodResultDTOArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - onDeleteStoredPaymentMethodResultChannel.setMessageHandler(nil) + } + } else { + onBalanceCheckResultChannel.setMessageHandler(nil) + } + let onOrderRequestResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onOrderRequestResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let orderRequestResponseArg = args[0] as! String + do { + try api.onOrderRequestResult(orderRequestResponse: orderRequestResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let cleanUpDropInChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn", binaryMessenger: binaryMessenger, codec: codec) - if let api { - cleanUpDropInChannel.setMessageHandler { _, reply in - do { - try api.cleanUpDropIn() - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - cleanUpDropInChannel.setMessageHandler(nil) + } + } else { + onOrderRequestResultChannel.setMessageHandler(nil) + } + let cleanUpDropInChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + cleanUpDropInChannel.setMessageHandler { _, reply in + do { + try api.cleanUpDropIn() + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } + } + } else { + cleanUpDropInChannel.setMessageHandler(nil) } + } } - private class DropInFlutterInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 129: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) - case 130: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) - case 131: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) - case 132: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 129: + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + case 130: + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + case 131: + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + case 132: + return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class DropInFlutterInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? AmountDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { - super.writeByte(132) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? AmountDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? OrderResponseDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultModelDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? PlatformCommunicationModel { + super.writeByte(132) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class DropInFlutterInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - DropInFlutterInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + return DropInFlutterInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - DropInFlutterInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + return DropInFlutterInterfaceCodecWriter(data: data) + } } class DropInFlutterInterfaceCodec: FlutterStandardMessageCodec { - static let shared = DropInFlutterInterfaceCodec(readerWriter: DropInFlutterInterfaceCodecReaderWriter()) + static let shared = DropInFlutterInterfaceCodec(readerWriter: DropInFlutterInterfaceCodecReaderWriter()) } /// 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 onDropInSessionPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) + func onDropInAdvancedPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) } - class DropInFlutterInterface: DropInFlutterInterfaceProtocol { - private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger) { - self.binaryMessenger = binaryMessenger - } - - var codec: FlutterStandardMessageCodec { - DropInFlutterInterfaceCodec.shared - } - - func onDropInSessionPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { - let channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication" - 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(FlutterError(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" - 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(FlutterError(code: code, message: message, details: details))) - } else { - completion(.success(())) - } - } - } + private let binaryMessenger: FlutterBinaryMessenger + init(binaryMessenger: FlutterBinaryMessenger) { + self.binaryMessenger = binaryMessenger + } + var codec: FlutterStandardMessageCodec { + return DropInFlutterInterfaceCodec.shared + } + func onDropInSessionPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication" + 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(FlutterError(code: code, message: message, details: details))) + } else { + completion(.success(Void())) + } + } + } + func onDropInAdvancedPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication" + 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(FlutterError(code: code, message: message, details: details))) + } else { + completion(.success(Void())) + } + } + } } - private class ComponentPlatformInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return ActionComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 129: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 130: - return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) - case 131: - return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 132: - return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) - case 133: - return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) - case 134: - return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) - case 135: - return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 136: - return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 137: - return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 138: - return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 139: - return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) - case 140: - return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) - case 141: - return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 142: - return EncryptedCardDTO.fromList(self.readValue() as! [Any?]) - case 143: - return ErrorDTO.fromList(self.readValue() as! [Any?]) - case 144: - return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 145: - return InstantPaymentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 146: - return InstantPaymentSetupResultDTO.fromList(self.readValue() as! [Any?]) - case 147: - return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) - case 148: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) - case 149: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) - case 150: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) - case 151: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) - case 152: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) - case 153: - return SessionDTO.fromList(self.readValue() as! [Any?]) - case 154: - return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 155: - return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return ActionComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 129: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 130: + return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) + case 131: + return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 132: + return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) + case 133: + return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) + case 134: + return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) + case 135: + return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 136: + return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 137: + return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 138: + return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 139: + return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) + case 140: + return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) + case 141: + return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 142: + return EncryptedCardDTO.fromList(self.readValue() as! [Any?]) + case 143: + return ErrorDTO.fromList(self.readValue() as! [Any?]) + case 144: + return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 145: + return InstantPaymentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 146: + return InstantPaymentSetupResultDTO.fromList(self.readValue() as! [Any?]) + case 147: + return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) + case 148: + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + case 149: + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + case 150: + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + case 151: + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + case 152: + return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + case 153: + return SessionDTO.fromList(self.readValue() as! [Any?]) + case 154: + return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 155: + return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class ComponentPlatformInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? ActionComponentConfigurationDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? AmountDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? AnalyticsOptionsDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayConfigurationDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayContactDTO { - super.writeByte(132) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayShippingMethodDTO { - super.writeByte(133) - super.writeValue(value.toList()) - } else if let value = value as? ApplePaySummaryItemDTO { - super.writeByte(134) - super.writeValue(value.toList()) - } else if let value = value as? BillingAddressParametersDTO { - super.writeByte(135) - super.writeValue(value.toList()) - } else if let value = value as? CardComponentConfigurationDTO { - super.writeByte(136) - super.writeValue(value.toList()) - } else if let value = value as? CardConfigurationDTO { - super.writeByte(137) - super.writeValue(value.toList()) - } else if let value = value as? CashAppPayConfigurationDTO { - super.writeByte(138) - super.writeValue(value.toList()) - } else if let value = value as? ComponentCommunicationModel { - super.writeByte(139) - super.writeValue(value.toList()) - } else if let value = value as? DeletedStoredPaymentMethodResultDTO { - super.writeByte(140) - super.writeValue(value.toList()) - } else if let value = value as? DropInConfigurationDTO { - super.writeByte(141) - super.writeValue(value.toList()) - } else if let value = value as? EncryptedCardDTO { - super.writeByte(142) - super.writeValue(value.toList()) - } else if let value = value as? ErrorDTO { - super.writeByte(143) - super.writeValue(value.toList()) - } else if let value = value as? GooglePayConfigurationDTO { - super.writeByte(144) - super.writeValue(value.toList()) - } else if let value = value as? InstantPaymentConfigurationDTO { - super.writeByte(145) - super.writeValue(value.toList()) - } else if let value = value as? InstantPaymentSetupResultDTO { - super.writeByte(146) - super.writeValue(value.toList()) - } else if let value = value as? MerchantInfoDTO { - super.writeByte(147) - super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { - super.writeByte(148) - super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { - super.writeByte(149) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { - super.writeByte(150) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { - super.writeByte(151) - super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { - super.writeByte(152) - super.writeValue(value.toList()) - } else if let value = value as? SessionDTO { - super.writeByte(153) - super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { - super.writeByte(154) - super.writeValue(value.toList()) - } else if let value = value as? UnencryptedCardDTO { - super.writeByte(155) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? ActionComponentConfigurationDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? AmountDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? AnalyticsOptionsDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayConfigurationDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayContactDTO { + super.writeByte(132) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayShippingMethodDTO { + super.writeByte(133) + super.writeValue(value.toList()) + } else if let value = value as? ApplePaySummaryItemDTO { + super.writeByte(134) + super.writeValue(value.toList()) + } else if let value = value as? BillingAddressParametersDTO { + super.writeByte(135) + super.writeValue(value.toList()) + } else if let value = value as? CardComponentConfigurationDTO { + super.writeByte(136) + super.writeValue(value.toList()) + } else if let value = value as? CardConfigurationDTO { + super.writeByte(137) + super.writeValue(value.toList()) + } else if let value = value as? CashAppPayConfigurationDTO { + super.writeByte(138) + super.writeValue(value.toList()) + } else if let value = value as? ComponentCommunicationModel { + super.writeByte(139) + super.writeValue(value.toList()) + } else if let value = value as? DeletedStoredPaymentMethodResultDTO { + super.writeByte(140) + super.writeValue(value.toList()) + } else if let value = value as? DropInConfigurationDTO { + super.writeByte(141) + super.writeValue(value.toList()) + } else if let value = value as? EncryptedCardDTO { + super.writeByte(142) + super.writeValue(value.toList()) + } else if let value = value as? ErrorDTO { + super.writeByte(143) + super.writeValue(value.toList()) + } else if let value = value as? GooglePayConfigurationDTO { + super.writeByte(144) + super.writeValue(value.toList()) + } else if let value = value as? InstantPaymentConfigurationDTO { + super.writeByte(145) + super.writeValue(value.toList()) + } else if let value = value as? InstantPaymentSetupResultDTO { + super.writeByte(146) + super.writeValue(value.toList()) + } else if let value = value as? MerchantInfoDTO { + super.writeByte(147) + super.writeValue(value.toList()) + } else if let value = value as? OrderResponseDTO { + super.writeByte(148) + super.writeValue(value.toList()) + } else if let value = value as? PaymentEventDTO { + super.writeByte(149) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultDTO { + super.writeByte(150) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultModelDTO { + super.writeByte(151) + super.writeValue(value.toList()) + } else if let value = value as? PlatformCommunicationModel { + super.writeByte(152) + super.writeValue(value.toList()) + } else if let value = value as? SessionDTO { + super.writeByte(153) + super.writeValue(value.toList()) + } else if let value = value as? ShippingAddressParametersDTO { + super.writeByte(154) + super.writeValue(value.toList()) + } else if let value = value as? UnencryptedCardDTO { + super.writeByte(155) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class ComponentPlatformInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - ComponentPlatformInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + return ComponentPlatformInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - ComponentPlatformInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + return ComponentPlatformInterfaceCodecWriter(data: data) + } } class ComponentPlatformInterfaceCodec: FlutterStandardMessageCodec { - static let shared = ComponentPlatformInterfaceCodec(readerWriter: ComponentPlatformInterfaceCodecReaderWriter()) + static let shared = ComponentPlatformInterfaceCodec(readerWriter: ComponentPlatformInterfaceCodecReaderWriter()) } /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol ComponentPlatformInterface { - func updateViewHeight(viewId: Int64) throws - func onPaymentsResult(componentId: String, paymentsResult: PaymentEventDTO) throws - func onPaymentsDetailsResult(componentId: String, paymentsDetailsResult: PaymentEventDTO) throws - func isInstantPaymentSupportedByPlatform(instantPaymentConfigurationDTO: InstantPaymentConfigurationDTO, paymentMethodResponse: String, componentId: String, completion: @escaping (Result) -> Void) - func onInstantPaymentPressed(instantPaymentConfigurationDTO: InstantPaymentConfigurationDTO, encodedPaymentMethod: String, componentId: String) throws - func handleAction(actionComponentConfiguration: ActionComponentConfigurationDTO, componentId: String, actionResponse: [String?: Any?]?) throws - func onDispose(componentId: String) throws + func updateViewHeight(viewId: Int64) throws + func onPaymentsResult(componentId: String, paymentsResult: PaymentEventDTO) throws + func onPaymentsDetailsResult(componentId: String, paymentsDetailsResult: PaymentEventDTO) throws + func isInstantPaymentSupportedByPlatform(instantPaymentConfigurationDTO: InstantPaymentConfigurationDTO, paymentMethodResponse: String, componentId: String, completion: @escaping (Result) -> Void) + func onInstantPaymentPressed(instantPaymentConfigurationDTO: InstantPaymentConfigurationDTO, encodedPaymentMethod: String, componentId: String) throws + func handleAction(actionComponentConfiguration: ActionComponentConfigurationDTO, componentId: String, actionResponse: [String?: Any?]?) throws + func onDispose(componentId: String) throws } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class ComponentPlatformInterfaceSetup { - /// The codec used by ComponentPlatformInterface. - static var codec: FlutterStandardMessageCodec { ComponentPlatformInterfaceCodec.shared } - /// Sets up an instance of `ComponentPlatformInterface` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: ComponentPlatformInterface?) { - let updateViewHeightChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight", binaryMessenger: binaryMessenger, codec: codec) - if let api { - updateViewHeightChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let viewIdArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) - do { - try api.updateViewHeight(viewId: viewIdArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - updateViewHeightChannel.setMessageHandler(nil) + /// The codec used by ComponentPlatformInterface. + static var codec: FlutterStandardMessageCodec { ComponentPlatformInterfaceCodec.shared } + /// Sets up an instance of `ComponentPlatformInterface` to handle messages through the `binaryMessenger`. + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: ComponentPlatformInterface?) { + let updateViewHeightChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + updateViewHeightChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let viewIdArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) + do { + try api.updateViewHeight(viewId: viewIdArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let onPaymentsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult", binaryMessenger: binaryMessenger, codec: codec) - if let api { - onPaymentsResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let componentIdArg = args[0] as! String - let paymentsResultArg = args[1] as! PaymentEventDTO - do { - try api.onPaymentsResult(componentId: componentIdArg, paymentsResult: paymentsResultArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - onPaymentsResultChannel.setMessageHandler(nil) + } + } else { + updateViewHeightChannel.setMessageHandler(nil) + } + let onPaymentsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onPaymentsResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let componentIdArg = args[0] as! String + let paymentsResultArg = args[1] as! PaymentEventDTO + do { + try api.onPaymentsResult(componentId: componentIdArg, paymentsResult: paymentsResultArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let onPaymentsDetailsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult", binaryMessenger: binaryMessenger, codec: codec) - if let api { - onPaymentsDetailsResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let componentIdArg = args[0] as! String - let paymentsDetailsResultArg = args[1] as! PaymentEventDTO - do { - try api.onPaymentsDetailsResult(componentId: componentIdArg, paymentsDetailsResult: paymentsDetailsResultArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - onPaymentsDetailsResultChannel.setMessageHandler(nil) + } + } else { + onPaymentsResultChannel.setMessageHandler(nil) + } + let onPaymentsDetailsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onPaymentsDetailsResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let componentIdArg = args[0] as! String + let paymentsDetailsResultArg = args[1] as! PaymentEventDTO + do { + try api.onPaymentsDetailsResult(componentId: componentIdArg, paymentsDetailsResult: paymentsDetailsResultArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let isInstantPaymentSupportedByPlatformChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform", binaryMessenger: binaryMessenger, codec: codec) - if let api { - isInstantPaymentSupportedByPlatformChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let instantPaymentConfigurationDTOArg = args[0] as! InstantPaymentConfigurationDTO - let paymentMethodResponseArg = args[1] as! String - let componentIdArg = args[2] as! String - api.isInstantPaymentSupportedByPlatform(instantPaymentConfigurationDTO: instantPaymentConfigurationDTOArg, paymentMethodResponse: paymentMethodResponseArg, componentId: componentIdArg) { result in - switch result { - case let .success(res): - reply(wrapResult(res)) - case let .failure(error): - reply(wrapError(error)) - } - } - } - } else { - isInstantPaymentSupportedByPlatformChannel.setMessageHandler(nil) + } + } else { + onPaymentsDetailsResultChannel.setMessageHandler(nil) + } + let isInstantPaymentSupportedByPlatformChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + isInstantPaymentSupportedByPlatformChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let instantPaymentConfigurationDTOArg = args[0] as! InstantPaymentConfigurationDTO + let paymentMethodResponseArg = args[1] as! String + let componentIdArg = args[2] as! String + api.isInstantPaymentSupportedByPlatform(instantPaymentConfigurationDTO: instantPaymentConfigurationDTOArg, paymentMethodResponse: paymentMethodResponseArg, componentId: componentIdArg) { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } } - let onInstantPaymentPressedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed", binaryMessenger: binaryMessenger, codec: codec) - if let api { - onInstantPaymentPressedChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let instantPaymentConfigurationDTOArg = args[0] as! InstantPaymentConfigurationDTO - let encodedPaymentMethodArg = args[1] as! String - let componentIdArg = args[2] as! String - do { - try api.onInstantPaymentPressed(instantPaymentConfigurationDTO: instantPaymentConfigurationDTOArg, encodedPaymentMethod: encodedPaymentMethodArg, componentId: componentIdArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - onInstantPaymentPressedChannel.setMessageHandler(nil) + } + } else { + isInstantPaymentSupportedByPlatformChannel.setMessageHandler(nil) + } + let onInstantPaymentPressedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onInstantPaymentPressedChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let instantPaymentConfigurationDTOArg = args[0] as! InstantPaymentConfigurationDTO + let encodedPaymentMethodArg = args[1] as! String + let componentIdArg = args[2] as! String + do { + try api.onInstantPaymentPressed(instantPaymentConfigurationDTO: instantPaymentConfigurationDTOArg, encodedPaymentMethod: encodedPaymentMethodArg, componentId: componentIdArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let handleActionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction", binaryMessenger: binaryMessenger, codec: codec) - if let api { - handleActionChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let actionComponentConfigurationArg = args[0] as! ActionComponentConfigurationDTO - let componentIdArg = args[1] as! String - let actionResponseArg: [String?: Any?]? = nilOrValue(args[2]) - do { - try api.handleAction(actionComponentConfiguration: actionComponentConfigurationArg, componentId: componentIdArg, actionResponse: actionResponseArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - handleActionChannel.setMessageHandler(nil) + } + } else { + onInstantPaymentPressedChannel.setMessageHandler(nil) + } + let handleActionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + handleActionChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let actionComponentConfigurationArg = args[0] as! ActionComponentConfigurationDTO + let componentIdArg = args[1] as! String + let actionResponseArg: [String?: Any?]? = nilOrValue(args[2]) + do { + try api.handleAction(actionComponentConfiguration: actionComponentConfigurationArg, componentId: componentIdArg, actionResponse: actionResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } - let onDisposeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose", binaryMessenger: binaryMessenger, codec: codec) - if let api { - onDisposeChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let componentIdArg = args[0] as! String - do { - try api.onDispose(componentId: componentIdArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - onDisposeChannel.setMessageHandler(nil) + } + } else { + handleActionChannel.setMessageHandler(nil) + } + let onDisposeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onDisposeChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let componentIdArg = args[0] as! String + do { + try api.onDispose(componentId: componentIdArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) } + } + } else { + onDisposeChannel.setMessageHandler(nil) } + } } - private class ComponentFlutterInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 129: - return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) - case 130: - return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 131: - return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 132: - return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) - case 133: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) - case 134: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) - case 135: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) - case 136: - return SessionDTO.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 129: + return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) + case 130: + return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 131: + return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 132: + return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) + case 133: + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + case 134: + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + case 135: + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + case 136: + return SessionDTO.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class ComponentFlutterInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? AmountDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? AnalyticsOptionsDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? CardComponentConfigurationDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? CardConfigurationDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? ComponentCommunicationModel { - super.writeByte(132) - super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { - super.writeByte(133) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { - super.writeByte(134) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { - super.writeByte(135) - super.writeValue(value.toList()) - } else if let value = value as? SessionDTO { - super.writeByte(136) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? AmountDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? AnalyticsOptionsDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? CardComponentConfigurationDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? CardConfigurationDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? ComponentCommunicationModel { + super.writeByte(132) + super.writeValue(value.toList()) + } else if let value = value as? OrderResponseDTO { + super.writeByte(133) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultDTO { + super.writeByte(134) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultModelDTO { + super.writeByte(135) + super.writeValue(value.toList()) + } else if let value = value as? SessionDTO { + super.writeByte(136) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class ComponentFlutterInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - ComponentFlutterInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + return ComponentFlutterInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - ComponentFlutterInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + return ComponentFlutterInterfaceCodecWriter(data: data) + } } class ComponentFlutterInterfaceCodec: FlutterStandardMessageCodec { - static let shared = ComponentFlutterInterfaceCodec(readerWriter: ComponentFlutterInterfaceCodecReaderWriter()) + static let shared = ComponentFlutterInterfaceCodec(readerWriter: ComponentFlutterInterfaceCodecReaderWriter()) } /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol ComponentFlutterInterfaceProtocol { - func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) - func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) + func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) + func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) } - class ComponentFlutterInterface: ComponentFlutterInterfaceProtocol { - private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger) { - self.binaryMessenger = binaryMessenger - } - - var codec: FlutterStandardMessageCodec { - ComponentFlutterInterfaceCodec.shared - } - - func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) { - let channelName = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([cardComponentConfigurationDTOArg, sessionDTOArg] 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(FlutterError(code: code, message: message, details: details))) - } else { - completion(.success(())) - } - } - } - - func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) { - let channelName = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([componentCommunicationModelArg] 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(FlutterError(code: code, message: message, details: details))) - } else { - completion(.success(())) - } - } - } + private let binaryMessenger: FlutterBinaryMessenger + init(binaryMessenger: FlutterBinaryMessenger) { + self.binaryMessenger = binaryMessenger + } + var codec: FlutterStandardMessageCodec { + return ComponentFlutterInterfaceCodec.shared + } + func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([cardComponentConfigurationDTOArg, sessionDTOArg] 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(FlutterError(code: code, message: message, details: details))) + } else { + completion(.success(Void())) + } + } + } + func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([componentCommunicationModelArg] 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(FlutterError(code: code, message: message, details: details))) + } else { + completion(.success(Void())) + } + } + } } diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index f720f848..5cebe4b7 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -132,6 +132,11 @@ class DropInPlatformApi: DropInPlatformInterface { dropInAdvancedFlowStoredPaymentMethodsDelegate?.handleDisableResult( isSuccessfullyRemoved: deleteStoredPaymentMethodResultDTO.isSuccessfullyRemoved) } + + func onBalanceCheckResult(balanceCheckResponse: String) throws { + + } + func cleanUpDropIn() { sessionHolder.reset() diff --git a/lib/adyen_checkout.dart b/lib/adyen_checkout.dart index dadc8610..afe73b18 100644 --- a/lib/adyen_checkout.dart +++ b/lib/adyen_checkout.dart @@ -5,6 +5,7 @@ export 'src/common/model/checkout.dart'; export 'src/common/model/cse/encrypted_card.dart'; export 'src/common/model/cse/unencrypted_card.dart'; export 'src/common/model/order_response.dart'; +export 'src/common/model/partial_payment.dart'; export 'src/common/model/payment_event.dart'; export 'src/common/model/payment_method_configurations/apple_pay/apple_pay_configuration.dart'; export 'src/common/model/payment_method_configurations/apple_pay/apple_pay_contact.dart'; diff --git a/lib/src/common/model/checkout.dart b/lib/src/common/model/checkout.dart index 67e71cf6..42f34c7c 100644 --- a/lib/src/common/model/checkout.dart +++ b/lib/src/common/model/checkout.dart @@ -1,3 +1,4 @@ +import 'package:adyen_checkout/src/common/model/partial_payment.dart'; import 'package:adyen_checkout/src/common/model/payment_event.dart'; sealed class Checkout {} @@ -23,8 +24,11 @@ class AdvancedCheckout extends Checkout { Future Function(Map additionalDetails) onAdditionalDetails; + PartialPayment? partialPayment; + AdvancedCheckout({ required this.onSubmit, required this.onAdditionalDetails, + this.partialPayment, }); } diff --git a/lib/src/common/model/partial_payment.dart b/lib/src/common/model/partial_payment.dart new file mode 100644 index 00000000..ab00db08 --- /dev/null +++ b/lib/src/common/model/partial_payment.dart @@ -0,0 +1,13 @@ +class PartialPayment { + Future> Function(Map balanceResponse) + onCheckBalance; + Future> Function() onRequestOrder; + Future> Function(Map orderResponse) + onCancelOrder; + + PartialPayment({ + required this.onCheckBalance, + required this.onRequestOrder, + required this.onCancelOrder, + }); +} diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index b1760a28..e47aa015 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -83,7 +83,7 @@ class DropIn { Future startDropInAdvancedFlowPayment( DropInConfiguration dropInConfiguration, Map paymentMethodsResponse, - Checkout advancedCheckout, + AdvancedCheckout advancedCheckout, ) async { adyenLogger.print("Start Drop-in advanced flow"); final dropInAdvancedFlowCompleter = Completer(); @@ -116,6 +116,12 @@ class DropIn { event, dropInConfiguration.storedPaymentMethodConfiguration, ); + case PlatformCommunicationType.balanceCheck: + _handleBalanceCheck(event, advancedCheckout.partialPayment); + case PlatformCommunicationType.requestOrder: + _handleOrderRequest(event, advancedCheckout.partialPayment); + case PlatformCommunicationType.cancelOrder: + // TODO: Handle this case. } }); @@ -255,4 +261,42 @@ class DropIn { throw Exception("Please use the session card component."); } } + + void _handleBalanceCheck( + PlatformCommunicationModel event, + PartialPayment? partialPayment, + ) async { + if (partialPayment == null) { + //TODO Check with Android to investigate the race condition + await Future.delayed(const Duration(milliseconds: 300)); + dropInPlatformApi.onBalanceCheckResult(""); + throw Exception("Partial payment implementation is not provided."); + } + + final Map data = jsonDecode(event.data as String); + final Map requestBody = {}; + requestBody.addAll({ + "paymentMethod": data["paymentMethod"], + "amount": data["amount"], + }); + + final balanceCheckResponse = + await partialPayment.onCheckBalance(requestBody); + dropInPlatformApi.onBalanceCheckResult(jsonEncode(balanceCheckResponse)); + } + + void _handleOrderRequest( + PlatformCommunicationModel event, + PartialPayment? partialPayment, + ) async { + if (partialPayment == null) { + //TODO Check with Android to investigate the race condition + await Future.delayed(const Duration(milliseconds: 300)); + dropInPlatformApi.onOrderRequestResult(""); + throw Exception("Partial payment implementation is not provided."); + } + + final balanceCheckResponse = await partialPayment.onRequestOrder(); + dropInPlatformApi.onOrderRequestResult(jsonEncode(balanceCheckResponse)); + } } diff --git a/lib/src/drop_in/drop_in_platform_api.dart b/lib/src/drop_in/drop_in_platform_api.dart index 643b8ed7..ad90a1e9 100644 --- a/lib/src/drop_in/drop_in_platform_api.dart +++ b/lib/src/drop_in/drop_in_platform_api.dart @@ -37,4 +37,12 @@ class DropInPlatformApi implements DropInPlatformInterface { @override Future cleanUpDropIn() => _dropInPlatformInterface.cleanUpDropIn(); + + @override + Future onBalanceCheckResult(String balanceCheckResponse) => + _dropInPlatformInterface.onBalanceCheckResult(balanceCheckResponse); + + @override + Future onOrderRequestResult(String orderRequestResponse) => + _dropInPlatformInterface.onOrderRequestResult(orderRequestResponse); } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index cc380a38..7087fa8e 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v15.0.3), do not edit directly. +// Autogenerated from Pigeon (v16.0.5), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -73,6 +73,9 @@ enum PlatformCommunicationType { additionalDetails, result, deleteStoredPaymentMethod, + balanceCheck, + requestOrder, + cancelOrder, } enum ComponentCommunicationType { @@ -1953,6 +1956,50 @@ class DropInPlatformInterface { } } + Future onBalanceCheckResult(String balanceCheckResponse) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + 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) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + Future onOrderRequestResult(String orderRequestResponse) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + 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) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + Future cleanUpDropIn() async { const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn'; diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index f71d180c..4bce19a2 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -58,6 +58,9 @@ enum PlatformCommunicationType { additionalDetails, result, deleteStoredPaymentMethod, + balanceCheck, + requestOrder, + cancelOrder, } enum ComponentCommunicationType { @@ -601,7 +604,6 @@ abstract class CheckoutPlatformInterface { @HostApi() abstract class DropInPlatformInterface { - // TODO: Merge show dropIn methods into one. void showDropInSession(DropInConfigurationDTO dropInConfigurationDTO); void showDropInAdvanced( @@ -616,6 +618,10 @@ abstract class DropInPlatformInterface { void onDeleteStoredPaymentMethodResult( DeletedStoredPaymentMethodResultDTO deleteStoredPaymentMethodResultDTO); + void onBalanceCheckResult(String balanceCheckResponse); + + void onOrderRequestResult(String orderRequestResponse); + void cleanUpDropIn(); } diff --git a/pubspec.yaml b/pubspec.yaml index baa47dad..f0fdbdd6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,7 +27,7 @@ dev_dependencies: flutter_test: sdk: flutter flutter_lints: 3.0.1 - pigeon: 15.0.3 + pigeon: 16.0.5 flutter: assets: From 67fad317cbe3aa566d8291685e7cb64852a18e49 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Wed, 25 Sep 2024 18:01:46 +0200 Subject: [PATCH 02/21] Added android partial payments flow --- .../com/adyen/checkout/flutter/PlatformApi.kt | 146 +++- .../components/ComponentPlatformApi.kt | 8 +- .../flutter/dropIn/DropInPlatformApi.kt | 73 +- .../dropIn/advanced/AdvancedDropInService.kt | 107 ++- .../advanced/DropInServiceResultMessenger.kt | 30 +- ...payment_methods_request_network_model.dart | 42 -- example/lib/network/service.dart | 24 +- .../adyen_apple_pay_component_repository.dart | 15 +- .../adyen_card_component_repository.dart | 17 +- .../adyen_drop_in_repository.dart | 106 ++- ...adyen_google_pay_component_repository.dart | 17 +- .../adyen_instant_component_repository.dart | 17 +- example/lib/utils/payment_event_handler.dart | 29 +- ios/Classes/PlatformApi.swift | 128 +++- .../components/ComponentPlatformApi.swift | 4 +- .../applePay/ApplePayAdvancedComponent.swift | 3 + .../instant/InstantAdvancedComponent.swift | 4 +- ios/Classes/dropIn/DropInPlatformApi.swift | 8 +- lib/adyen_checkout.dart | 3 +- lib/src/common/model/checkout.dart | 2 +- lib/src/common/model/partial_payment.dart | 13 - .../order_cancel_response.dart | 9 + .../partial_payment/partial_payment.dart | 17 + lib/src/common/model/payment_event.dart | 10 + lib/src/drop_in/drop_in.dart | 32 +- lib/src/drop_in/drop_in_platform_api.dart | 5 + lib/src/generated/platform_api.g.dart | 672 ++++++++---------- lib/src/util/dto_mapper.dart | 46 +- lib/src/util/payment_event_handler.dart | 9 +- pigeons/platform_api.dart | 17 +- 30 files changed, 949 insertions(+), 664 deletions(-) delete mode 100644 example/lib/network/models/payment_methods_request_network_model.dart delete mode 100644 lib/src/common/model/partial_payment.dart create mode 100644 lib/src/common/model/partial_payment/order_cancel_response.dart create mode 100644 lib/src/common/model/partial_payment/partial_payment.dart diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt index 3a2daba5..a4624e3f 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt @@ -162,7 +162,8 @@ enum class ComponentCommunicationType(val raw: Int) { enum class PaymentEventType(val raw: Int) { FINISHED(0), ACTION(1), - ERROR(2); + ERROR(2), + UPDATE(3); companion object { fun ofRaw(raw: Int): PaymentEventType? { @@ -902,7 +903,7 @@ data class ComponentCommunicationModel ( data class PaymentEventDTO ( val paymentEventType: PaymentEventType, val result: String? = null, - val actionResponse: Map? = null, + val data: Map? = null, val error: ErrorDTO? = null ) { @@ -911,18 +912,18 @@ data class PaymentEventDTO ( fun fromList(list: List): PaymentEventDTO { val paymentEventType = PaymentEventType.ofRaw(list[0] as Int)!! val result = list[1] as String? - val actionResponse = list[2] as Map? + val data = list[2] as Map? val error: ErrorDTO? = (list[3] as List?)?.let { ErrorDTO.fromList(it) } - return PaymentEventDTO(paymentEventType, result, actionResponse, error) + return PaymentEventDTO(paymentEventType, result, data, error) } } fun toList(): List { return listOf( paymentEventType.raw, result, - actionResponse, + data, error?.toList(), ) } @@ -1177,6 +1178,28 @@ data class ActionComponentConfigurationDTO ( } } +/** Generated class from Pigeon that represents data sent in messages. */ +data class OrderCancelResponseDTO ( + val orderCancelResponseBody: Map, + val updatedPaymentMethods: Map? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(list: List): OrderCancelResponseDTO { + val orderCancelResponseBody = list[0] as Map + val updatedPaymentMethods = list[1] as Map? + return OrderCancelResponseDTO(orderCancelResponseBody, updatedPaymentMethods) + } + } + fun toList(): List { + return listOf( + orderCancelResponseBody, + updatedPaymentMethods, + ) + } +} + @Suppress("UNCHECKED_CAST") private object CheckoutPlatformInterfaceCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { @@ -1283,40 +1306,45 @@ private object CheckoutPlatformInterfaceCodec : StandardMessageCodec() { } 148.toByte() -> { return (readValue(buffer) as? List)?.let { - OrderResponseDTO.fromList(it) + OrderCancelResponseDTO.fromList(it) } } 149.toByte() -> { return (readValue(buffer) as? List)?.let { - PaymentEventDTO.fromList(it) + OrderResponseDTO.fromList(it) } } 150.toByte() -> { return (readValue(buffer) as? List)?.let { - PaymentResultDTO.fromList(it) + PaymentEventDTO.fromList(it) } } 151.toByte() -> { return (readValue(buffer) as? List)?.let { - PaymentResultModelDTO.fromList(it) + PaymentResultDTO.fromList(it) } } 152.toByte() -> { return (readValue(buffer) as? List)?.let { - PlatformCommunicationModel.fromList(it) + PaymentResultModelDTO.fromList(it) } } 153.toByte() -> { return (readValue(buffer) as? List)?.let { - SessionDTO.fromList(it) + PlatformCommunicationModel.fromList(it) } } 154.toByte() -> { return (readValue(buffer) as? List)?.let { - ShippingAddressParametersDTO.fromList(it) + SessionDTO.fromList(it) } } 155.toByte() -> { + return (readValue(buffer) as? List)?.let { + ShippingAddressParametersDTO.fromList(it) + } + } + 156.toByte() -> { return (readValue(buffer) as? List)?.let { UnencryptedCardDTO.fromList(it) } @@ -1406,38 +1434,42 @@ private object CheckoutPlatformInterfaceCodec : StandardMessageCodec() { stream.write(147) writeValue(stream, value.toList()) } - is OrderResponseDTO -> { + is OrderCancelResponseDTO -> { stream.write(148) writeValue(stream, value.toList()) } - is PaymentEventDTO -> { + is OrderResponseDTO -> { stream.write(149) writeValue(stream, value.toList()) } - is PaymentResultDTO -> { + is PaymentEventDTO -> { stream.write(150) writeValue(stream, value.toList()) } - is PaymentResultModelDTO -> { + is PaymentResultDTO -> { stream.write(151) writeValue(stream, value.toList()) } - is PlatformCommunicationModel -> { + is PaymentResultModelDTO -> { stream.write(152) writeValue(stream, value.toList()) } - is SessionDTO -> { + is PlatformCommunicationModel -> { stream.write(153) writeValue(stream, value.toList()) } - is ShippingAddressParametersDTO -> { + is SessionDTO -> { stream.write(154) writeValue(stream, value.toList()) } - is UnencryptedCardDTO -> { + is ShippingAddressParametersDTO -> { stream.write(155) writeValue(stream, value.toList()) } + is UnencryptedCardDTO -> { + stream.write(156) + writeValue(stream, value.toList()) + } else -> super.writeValue(stream, value) } } @@ -1662,10 +1694,15 @@ private object DropInPlatformInterfaceCodec : StandardMessageCodec() { } 143.toByte() -> { return (readValue(buffer) as? List)?.let { - PaymentEventDTO.fromList(it) + OrderCancelResponseDTO.fromList(it) } } 144.toByte() -> { + return (readValue(buffer) as? List)?.let { + PaymentEventDTO.fromList(it) + } + } + 145.toByte() -> { return (readValue(buffer) as? List)?.let { ShippingAddressParametersDTO.fromList(it) } @@ -1735,14 +1772,18 @@ private object DropInPlatformInterfaceCodec : StandardMessageCodec() { stream.write(142) writeValue(stream, value.toList()) } - is PaymentEventDTO -> { + is OrderCancelResponseDTO -> { stream.write(143) writeValue(stream, value.toList()) } - is ShippingAddressParametersDTO -> { + is PaymentEventDTO -> { stream.write(144) writeValue(stream, value.toList()) } + is ShippingAddressParametersDTO -> { + stream.write(145) + writeValue(stream, value.toList()) + } else -> super.writeValue(stream, value) } } @@ -1757,6 +1798,7 @@ interface DropInPlatformInterface { fun onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) fun onBalanceCheckResult(balanceCheckResponse: String) fun onOrderRequestResult(orderRequestResponse: String) + fun onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) fun cleanUpDropIn() companion object { @@ -1901,6 +1943,25 @@ interface DropInPlatformInterface { channel.setMessageHandler(null) } } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val orderCancelResponseArg = args[0] as OrderCancelResponseDTO + var wrapped: List + try { + api.onOrderCancelResult(orderCancelResponseArg) + wrapped = listOf(null) + } catch (exception: Throwable) { + wrapped = wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } run { val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn", codec) if (api != null) { @@ -2128,40 +2189,45 @@ private object ComponentPlatformInterfaceCodec : StandardMessageCodec() { } 148.toByte() -> { return (readValue(buffer) as? List)?.let { - OrderResponseDTO.fromList(it) + OrderCancelResponseDTO.fromList(it) } } 149.toByte() -> { return (readValue(buffer) as? List)?.let { - PaymentEventDTO.fromList(it) + OrderResponseDTO.fromList(it) } } 150.toByte() -> { return (readValue(buffer) as? List)?.let { - PaymentResultDTO.fromList(it) + PaymentEventDTO.fromList(it) } } 151.toByte() -> { return (readValue(buffer) as? List)?.let { - PaymentResultModelDTO.fromList(it) + PaymentResultDTO.fromList(it) } } 152.toByte() -> { return (readValue(buffer) as? List)?.let { - PlatformCommunicationModel.fromList(it) + PaymentResultModelDTO.fromList(it) } } 153.toByte() -> { return (readValue(buffer) as? List)?.let { - SessionDTO.fromList(it) + PlatformCommunicationModel.fromList(it) } } 154.toByte() -> { return (readValue(buffer) as? List)?.let { - ShippingAddressParametersDTO.fromList(it) + SessionDTO.fromList(it) } } 155.toByte() -> { + return (readValue(buffer) as? List)?.let { + ShippingAddressParametersDTO.fromList(it) + } + } + 156.toByte() -> { return (readValue(buffer) as? List)?.let { UnencryptedCardDTO.fromList(it) } @@ -2251,38 +2317,42 @@ private object ComponentPlatformInterfaceCodec : StandardMessageCodec() { stream.write(147) writeValue(stream, value.toList()) } - is OrderResponseDTO -> { + is OrderCancelResponseDTO -> { stream.write(148) writeValue(stream, value.toList()) } - is PaymentEventDTO -> { + is OrderResponseDTO -> { stream.write(149) writeValue(stream, value.toList()) } - is PaymentResultDTO -> { + is PaymentEventDTO -> { stream.write(150) writeValue(stream, value.toList()) } - is PaymentResultModelDTO -> { + is PaymentResultDTO -> { stream.write(151) writeValue(stream, value.toList()) } - is PlatformCommunicationModel -> { + is PaymentResultModelDTO -> { stream.write(152) writeValue(stream, value.toList()) } - is SessionDTO -> { + is PlatformCommunicationModel -> { stream.write(153) writeValue(stream, value.toList()) } - is ShippingAddressParametersDTO -> { + is SessionDTO -> { stream.write(154) writeValue(stream, value.toList()) } - is UnencryptedCardDTO -> { + is ShippingAddressParametersDTO -> { stream.write(155) writeValue(stream, value.toList()) } + is UnencryptedCardDTO -> { + stream.write(156) + writeValue(stream, value.toList()) + } else -> super.writeValue(stream, value) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/components/ComponentPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/components/ComponentPlatformApi.kt index 6de1e5e8..5cfc5395 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/components/ComponentPlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/components/ComponentPlatformApi.kt @@ -144,8 +144,9 @@ class ComponentPlatformApi( ) { when (paymentEventDTO.paymentEventType) { PaymentEventType.FINISHED -> onFinished(paymentEventDTO.result, componentId) - PaymentEventType.ACTION -> onAction(paymentEventDTO.actionResponse) + PaymentEventType.ACTION -> onAction(paymentEventDTO.data) PaymentEventType.ERROR -> onError(paymentEventDTO.error, componentId) + PaymentEventType.UPDATE -> onUpdate(paymentEventDTO.data, componentId) } } @@ -215,4 +216,9 @@ class ComponentPlatformApi( currentComponent?.handleIntent(intent) } } + + private fun onUpdate( + data: Map?, + componentId: String + ) = Unit } 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 bd1e3677..5da19880 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 @@ -4,6 +4,7 @@ import DeletedStoredPaymentMethodResultDTO import DropInConfigurationDTO import DropInFlutterInterface import DropInPlatformInterface +import OrderCancelResponseDTO import PaymentEventDTO import PaymentEventType import PaymentResultDTO @@ -28,6 +29,8 @@ import com.adyen.checkout.flutter.dropIn.advanced.DropInAdditionalDetailsPlatfor import com.adyen.checkout.flutter.dropIn.advanced.DropInAdditionalDetailsResultMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInBalanceCheckPlatformMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInBalanceCheckResultMessenger +import com.adyen.checkout.flutter.dropIn.advanced.DropInOrderCancelPlatformMessenger +import com.adyen.checkout.flutter.dropIn.advanced.DropInOrderCancelResultMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInOrderRequestPlatformMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInOrderRequestResultMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionPlatformMessenger @@ -81,6 +84,7 @@ class DropInPlatformApi( setStoredPaymentMethodDeletionObserver() setBalanceCheckPlatformMessengerObserver() setOrderRequestPlatformMessengerObserver() + setOrderCancelPlatformMessengerObserver() activity.lifecycleScope.launch(Dispatchers.IO) { val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize( @@ -92,7 +96,7 @@ class DropInPlatformApi( DropIn.startPayment( activity.applicationContext, dropInAdvancedFlowLauncher, - paymentMethodsWithoutGiftCards, + paymentMethodsApiResponse, dropInConfiguration, AdvancedDropInService::class.java, ) @@ -126,10 +130,17 @@ class DropInPlatformApi( DropInOrderRequestResultMessenger.sendResult(orderRequestResponse) } + override fun onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) { + DropInOrderCancelResultMessenger.sendResult(orderCancelResponse) + } + override fun cleanUpDropIn() { DropInServiceResultMessenger.instance().removeObservers(activity) - DropInPaymentMethodDeletionPlatformMessenger.instance().removeObservers(activity) DropInAdditionalDetailsPlatformMessenger.instance().removeObservers(activity) + DropInPaymentMethodDeletionPlatformMessenger.instance().removeObservers(activity) + DropInBalanceCheckResultMessenger.instance().removeObservers(activity) + DropInOrderRequestResultMessenger.instance().removeObservers(activity) + DropInOrderCancelPlatformMessenger.instance().removeObservers(activity) } private fun setAdvancedFlowDropInServiceObserver() { @@ -202,10 +213,11 @@ class DropInPlatformApi( return@observe } - val platformCommunicationModel = PlatformCommunicationModel( - PlatformCommunicationType.BALANCECHECK, - data = message.contentIfNotHandled.toString() - ) + val platformCommunicationModel = + PlatformCommunicationModel( + PlatformCommunicationType.BALANCECHECK, + data = message.contentIfNotHandled.toString() + ) dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} } } @@ -217,10 +229,27 @@ class DropInPlatformApi( return@observe } - val platformCommunicationModel = PlatformCommunicationModel( - PlatformCommunicationType.REQUESTORDER, - data = message.contentIfNotHandled.toString() - ) + val platformCommunicationModel = + PlatformCommunicationModel( + PlatformCommunicationType.REQUESTORDER, + data = message.contentIfNotHandled.toString() + ) + dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + } + } + + private fun setOrderCancelPlatformMessengerObserver() { + DropInOrderCancelPlatformMessenger.instance().removeObservers(activity) + DropInOrderCancelPlatformMessenger.instance().observe(activity) { message -> + if (message.hasBeenHandled()) { + return@observe + } + + val platformCommunicationModel = + PlatformCommunicationModel( + PlatformCommunicationType.CANCELORDER, + data = message.contentIfNotHandled.toString() + ) dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} } } @@ -278,15 +307,15 @@ class DropInPlatformApi( PaymentResultDTO( PaymentResultEnum.FINISHED, result = - with(sessionDropInResult.result) { - PaymentResultModelDTO( - sessionId, - sessionData, - sessionResult, - resultCode, - order?.mapToOrderResponseModel() - ) - } + with(sessionDropInResult.result) { + PaymentResultModelDTO( + sessionId, + sessionData, + sessionResult, + resultCode, + order?.mapToOrderResponseModel() + ) + } ) } @@ -323,9 +352,9 @@ class DropInPlatformApi( PaymentResultDTO( PaymentResultEnum.FINISHED, result = - PaymentResultModelDTO( - resultCode = dropInAdvancedFlowResult.result - ) + PaymentResultModelDTO( + resultCode = dropInAdvancedFlowResult.result + ) ) } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index ecdf51f6..174ad61c 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -2,22 +2,23 @@ package com.adyen.checkout.flutter.dropIn.advanced import DeletedStoredPaymentMethodResultDTO import ErrorDTO +import OrderCancelResponseDTO import PaymentEventDTO import PaymentEventType import android.content.Intent import android.os.IBinder -import android.util.Log import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ServiceLifecycleDispatcher import com.adyen.checkout.components.core.ActionComponentData import com.adyen.checkout.components.core.BalanceResult +import com.adyen.checkout.components.core.Order import com.adyen.checkout.components.core.OrderResponse import com.adyen.checkout.components.core.PaymentComponentData import com.adyen.checkout.components.core.PaymentComponentState +import com.adyen.checkout.components.core.PaymentMethodsApiResponse import com.adyen.checkout.components.core.StoredPaymentMethod import com.adyen.checkout.components.core.action.Action -import com.adyen.checkout.core.exception.ModelSerializationException import com.adyen.checkout.dropin.BalanceDropInServiceResult import com.adyen.checkout.dropin.DropInService import com.adyen.checkout.dropin.DropInServiceResult @@ -28,8 +29,6 @@ import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletion import com.adyen.checkout.flutter.dropIn.model.DropInType import com.adyen.checkout.flutter.utils.Constants import com.adyen.checkout.googlepay.GooglePayComponentState -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import org.json.JSONObject class AdvancedDropInService : DropInService(), LifecycleOwner { @@ -74,6 +73,17 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { DropInOrderRequestPlatformMessenger.sendResult("onOrderRequest") } + override fun onOrderCancel( + order: Order, + shouldUpdatePaymentMethods: Boolean + ) { + setOrderCancelObserver() + val event = JSONObject() + event.put("order", Order.SERIALIZER.serialize(order)) + event.put("shouldUpdatePaymentMethods", shouldUpdatePaymentMethods) + DropInOrderCancelPlatformMessenger.sendResult(event) + } + override fun onRemoveStoredPaymentMethod(storedPaymentMethod: StoredPaymentMethod) { storedPaymentMethod.id?.let { storedPaymentMethodId -> setStoredPaymentMethodDeletionObserver() @@ -161,8 +171,8 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } private fun setOrderRequestObserver() { - DropInOrderRequestPlatformMessenger.instance().removeObservers(this) - DropInOrderRequestPlatformMessenger.instance().observe(this) { message -> + DropInOrderRequestResultMessenger.instance().removeObservers(this) + DropInOrderRequestResultMessenger.instance().observe(this) { message -> if (message.hasBeenHandled()) { return@observe } @@ -172,6 +182,18 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } } + private fun setOrderCancelObserver() { + DropInOrderCancelResultMessenger.instance().removeObservers(this) + DropInOrderCancelResultMessenger.instance().observe(this) { message -> + if (message.hasBeenHandled()) { + return@observe + } + + val orderResult = mapToOrderCancelDropInServiceResult(message.contentIfNotHandled) ?: return@observe + sendResult(orderResult) + } + } + private fun mapToDeletionDropInResult( deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO? ): RecurringDropInServiceResult { @@ -181,9 +203,9 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { // TODO - the error message should be provided by the native SDK RecurringDropInServiceResult.Error( errorDialog = - ErrorDialog( - message = "Removal of the stored payment method failed. Please try again later." - ) + ErrorDialog( + message = "Removal of the stored payment method failed. Please try again later." + ) ) } } @@ -203,18 +225,35 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { ) PaymentEventType.ACTION -> { - if (paymentEventDTO.actionResponse == null) { + if (paymentEventDTO.data == null) { DropInServiceResult.Error( errorDialog = null, reason = "Action response not provided", dismissDropIn = true ) } else { - val actionJson = JSONObject(paymentEventDTO.actionResponse) + val actionJson = JSONObject(paymentEventDTO.data) DropInServiceResult.Action(action = Action.SERIALIZER.deserialize(actionJson)) } } + PaymentEventType.UPDATE -> { + if (paymentEventDTO.data == null) { + DropInServiceResult.Error( + errorDialog = null, + reason = "Updated payment methods and order not provided", + dismissDropIn = true + ) + } else { + val updatedPaymentMethodsJSON = + JSONObject(paymentEventDTO.data["updatedPaymentMethods"] as HashMap<*, *>) + val orderResponseJSON = JSONObject(paymentEventDTO.data["orderResponse"] as HashMap<*, *>) + val paymentMethods = PaymentMethodsApiResponse.SERIALIZER.deserialize(updatedPaymentMethodsJSON) + val orderResponse = OrderResponse.SERIALIZER.deserialize(orderResponseJSON) + DropInServiceResult.Update(paymentMethods, orderResponse) + } + } + null -> DropInServiceResult.Error( errorDialog = null, @@ -241,10 +280,11 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { return when (val resultCode = jsonResponse.optString("resultCode")) { "Success" -> BalanceDropInServiceResult.Balance(BalanceResult.SERIALIZER.deserialize(jsonResponse)) "NotEnoughBalance" -> BalanceDropInServiceResult.Balance(BalanceResult.SERIALIZER.deserialize(jsonResponse)) - else -> BalanceDropInServiceResult.Error( - errorDialog = ErrorDialog(message = resultCode), - dismissDropIn = false, - ) + else -> + BalanceDropInServiceResult.Error( + errorDialog = ErrorDialog(message = resultCode), + dismissDropIn = false, + ) } } @@ -256,10 +296,39 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { val jsonResponse = JSONObject(response) return when (val resultCode = jsonResponse.optString("resultCode")) { "Success" -> OrderDropInServiceResult.OrderCreated(OrderResponse.SERIALIZER.deserialize(jsonResponse)) - else -> OrderDropInServiceResult.Error( - errorDialog = ErrorDialog(message = resultCode), - dismissDropIn = false, - ) + else -> + OrderDropInServiceResult.Error( + errorDialog = ErrorDialog(message = resultCode), + dismissDropIn = false, + ) + } + } + + private fun mapToOrderCancelDropInServiceResult( + orderCancelResponseDTO: OrderCancelResponseDTO? + ): DropInServiceResult? { + if (orderCancelResponseDTO == null || orderCancelResponseDTO.orderCancelResponseBody.isEmpty()) { + return DropInServiceResult.Error(errorDialog = null, reason = "Order cancellation failed") + } + + val orderCancelResponseBody = JSONObject(orderCancelResponseDTO.orderCancelResponseBody) + return when (val resultCode = orderCancelResponseBody.optString("resultCode")) { + "Received" -> { + if (orderCancelResponseDTO.updatedPaymentMethods?.isNotEmpty() == true) { + val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethods + val paymentMethods = + PaymentMethodsApiResponse.SERIALIZER.deserialize(JSONObject(updatedPaymentMethods)) + val orderResponse = OrderResponse.SERIALIZER.deserialize(orderCancelResponseBody) + sendResult(DropInServiceResult.Update(paymentMethods, orderResponse)) + } + null + } + + else -> + DropInServiceResult.Error( + errorDialog = ErrorDialog(message = resultCode), + dismissDropIn = false, + ) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt index f69dc8a7..ffec1900 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt @@ -1,6 +1,7 @@ package com.adyen.checkout.flutter.dropIn.advanced import DeletedStoredPaymentMethodResultDTO +import OrderCancelResponseDTO import PaymentEventDTO import androidx.lifecycle.LiveData import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletionModel @@ -109,7 +110,7 @@ class DropInBalanceCheckResultMessenger : LiveData>() { } } -class DropInOrderRequestPlatformMessenger: LiveData>() { +class DropInOrderRequestPlatformMessenger : LiveData>() { companion object { private val dropInOrderRequestPlatformMessenger = DropInOrderRequestPlatformMessenger() @@ -122,7 +123,7 @@ class DropInOrderRequestPlatformMessenger: LiveData>() { } } -class DropInOrderRequestResultMessenger: LiveData>() { +class DropInOrderRequestResultMessenger : LiveData>() { companion object { private val dropInOrderRequestResultMessenger = DropInOrderRequestResultMessenger() @@ -135,3 +136,28 @@ class DropInOrderRequestResultMessenger: LiveData>() { } } +class DropInOrderCancelPlatformMessenger : LiveData>() { + companion object { + private val dropInOrderCancelPlatformMessenger = + DropInOrderCancelPlatformMessenger() + + fun instance() = dropInOrderCancelPlatformMessenger + + fun sendResult(value: JSONObject) { + dropInOrderCancelPlatformMessenger.postValue(Event(value)) + } + } +} + +class DropInOrderCancelResultMessenger : LiveData>() { + companion object { + private val dropInOrderCancelResultMessenger = + DropInOrderCancelResultMessenger() + + fun instance() = dropInOrderCancelResultMessenger + + fun sendResult(value: OrderCancelResponseDTO) { + dropInOrderCancelResultMessenger.postValue(Event(value)) + } + } +} diff --git a/example/lib/network/models/payment_methods_request_network_model.dart b/example/lib/network/models/payment_methods_request_network_model.dart deleted file mode 100644 index ebffee2c..00000000 --- a/example/lib/network/models/payment_methods_request_network_model.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'dart:convert'; - -import 'package:adyen_checkout_example/network/models/amount_network_model.dart'; - -class PaymentMethodsRequestNetworkModel { - final String merchantAccount; - final AmountNetworkModel? amount; - final String? channel; - final String? countryCode; - final String? shopperReference; - - PaymentMethodsRequestNetworkModel({ - required this.merchantAccount, - this.amount, - this.channel, - this.countryCode, - this.shopperReference, - }); - - String toRawJson() { - return json.encode(toJson()); - } - - Map toJson() { - Map json = {}; - json.addAll({"merchantAccount": merchantAccount}); - - if (amount != null) { - json.addAll({"amount": amount?.toJson()}); - } - if (channel != null) { - json.addAll({"channel": channel}); - } - if (countryCode != null) { - json.addAll({"countryCode": countryCode}); - } - if (shopperReference != null) { - json.addAll({"shopperReference": shopperReference}); - } - return json; - } -} diff --git a/example/lib/network/service.dart b/example/lib/network/service.dart index d8464fca..0396ca11 100644 --- a/example/lib/network/service.dart +++ b/example/lib/network/service.dart @@ -1,10 +1,10 @@ // ignore_for_file: avoid_print import 'dart:convert'; +import 'dart:developer'; import 'package:adyen_checkout/adyen_checkout.dart'; import 'package:adyen_checkout_example/config.dart'; -import 'package:adyen_checkout_example/network/models/payment_methods_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_response_network_model.dart'; import 'package:http/http.dart' as http; @@ -25,12 +25,11 @@ class Service { } Future> fetchPaymentMethods( - PaymentMethodsRequestNetworkModel - paymentMethodsRequestNetworkModel) async { + Map body) async { final response = await http.post( Uri.https(Config.baseUrl, "/${Config.apiVersion}/paymentMethods"), headers: _createHeaders(), - body: paymentMethodsRequestNetworkModel.toRawJson(), + body: jsonEncode(body), ); return jsonDecode(response.body); } @@ -42,6 +41,7 @@ class Service { body: jsonEncode(body), ); print("PspReference: ${response.headers["pspreference"]}"); + log(response.body); return jsonDecode(response.body); } @@ -55,16 +55,10 @@ class Service { return jsonDecode(response.body); } - Future deleteStoredPaymentMethod({ - required String storedPaymentMethodId, - required String merchantAccount, - required String shopperReference, - }) async { - final queryParameters = { - 'merchantAccount': merchantAccount, - 'shopperReference': shopperReference, - }; - + Future deleteStoredPaymentMethod( + String storedPaymentMethodId, + Map queryParameters, + ) async { final response = await http.delete( Uri.https( Config.baseUrl, @@ -88,7 +82,6 @@ class Service { headers: _createHeaders(), body: jsonEncode(body), ); - print(response.body); return jsonDecode(response.body); } @@ -110,7 +103,6 @@ class Service { return jsonDecode(response.body); } - Map _createHeaders() => { "content-type": "application/json", "x-API-key": Config.xApiKey, diff --git a/example/lib/repositories/adyen_apple_pay_component_repository.dart b/example/lib/repositories/adyen_apple_pay_component_repository.dart index bc08f929..15223b34 100644 --- a/example/lib/repositories/adyen_apple_pay_component_repository.dart +++ b/example/lib/repositories/adyen_apple_pay_component_repository.dart @@ -1,7 +1,6 @@ import 'package:adyen_checkout/adyen_checkout.dart'; import 'package:adyen_checkout_example/config.dart'; import 'package:adyen_checkout_example/network/models/amount_network_model.dart'; -import 'package:adyen_checkout_example/network/models/payment_methods_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/payment_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_response_network_model.dart'; @@ -54,12 +53,12 @@ class AdyenApplePayComponentRepository extends AdyenBaseRepository { } Future> fetchPaymentMethods() async { - return await service.fetchPaymentMethods(PaymentMethodsRequestNetworkModel( - merchantAccount: Config.merchantAccount, - countryCode: Config.countryCode, - channel: determineChannel(), - shopperReference: Config.shopperReference, - )); + return await service.fetchPaymentMethods({ + "merchantAccount": Config.merchantAccount, + "countryCode": Config.countryCode, + "channel": determineChannel(), + "shopperReference": Config.shopperReference, + }); } Future onSubmit( @@ -94,7 +93,7 @@ class AdyenApplePayComponentRepository extends AdyenBaseRepository { mergedJson.addAll(data); mergedJson.addAll(paymentsRequestData.toJson()); final response = await service.postPayments(mergedJson); - return paymentEventHandler.handleResponse(response); + return paymentEventHandler.handleResponse(jsonResponse: response); } Future onAdditionalDetailsMock( diff --git a/example/lib/repositories/adyen_card_component_repository.dart b/example/lib/repositories/adyen_card_component_repository.dart index 9aa62510..caa33653 100644 --- a/example/lib/repositories/adyen_card_component_repository.dart +++ b/example/lib/repositories/adyen_card_component_repository.dart @@ -1,7 +1,6 @@ import 'package:adyen_checkout/adyen_checkout.dart'; import 'package:adyen_checkout_example/config.dart'; import 'package:adyen_checkout_example/network/models/amount_network_model.dart'; -import 'package:adyen_checkout_example/network/models/payment_methods_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/payment_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_response_network_model.dart'; @@ -44,12 +43,12 @@ class AdyenCardComponentRepository extends AdyenBaseRepository { } Future> fetchPaymentMethods() async { - return await service.fetchPaymentMethods(PaymentMethodsRequestNetworkModel( - merchantAccount: Config.merchantAccount, - countryCode: Config.countryCode, - channel: determineChannel(), - shopperReference: Config.shopperReference, - )); + return await service.fetchPaymentMethods({ + "merchantAccount": Config.merchantAccount, + "countryCode": Config.countryCode, + "channel": determineChannel(), + "shopperReference": Config.shopperReference, + }); } Future onSubmit( @@ -83,12 +82,12 @@ class AdyenCardComponentRepository extends AdyenBaseRepository { mergedJson.addAll(data); mergedJson.addAll(paymentsRequestData.toJson()); final response = await service.postPayments(mergedJson); - return paymentEventHandler.handleResponse(response); + return paymentEventHandler.handleResponse(jsonResponse: response); } Future onAdditionalDetails( Map additionalDetails) async { final response = await service.postPaymentsDetails(additionalDetails); - return paymentEventHandler.handleResponse(response); + return paymentEventHandler.handleResponse(jsonResponse: response); } } diff --git a/example/lib/repositories/adyen_drop_in_repository.dart b/example/lib/repositories/adyen_drop_in_repository.dart index b1d53fda..cfeb3b75 100644 --- a/example/lib/repositories/adyen_drop_in_repository.dart +++ b/example/lib/repositories/adyen_drop_in_repository.dart @@ -4,7 +4,6 @@ import 'package:adyen_checkout_example/network/models/amount_network_model.dart' import 'package:adyen_checkout_example/network/models/billing_address.dart'; import 'package:adyen_checkout_example/network/models/delivery_address.dart'; import 'package:adyen_checkout_example/network/models/line_item.dart'; -import 'package:adyen_checkout_example/network/models/payment_methods_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/payment_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_response_network_model.dart'; @@ -74,17 +73,26 @@ class AdyenDropInRepository extends AdyenBaseRepository { ); } - Future> fetchPaymentMethods() async { - return await service.fetchPaymentMethods(PaymentMethodsRequestNetworkModel( - amount: AmountNetworkModel( - currency: Config.amount.currency, - value: Config.amount.value, - ), - merchantAccount: Config.merchantAccount, - countryCode: Config.countryCode, - channel: determineChannel(), - shopperReference: Config.shopperReference, - )); + Future> fetchPaymentMethods({ + Map? orderResponse, + }) async { + final requestBody = { + "amount": { + "value": Config.amount.value, + "currency": Config.amount.currency + }, + "merchantAccount": Config.merchantAccount, + "countryCode": Config.countryCode, + "channel": determineChannel(), + "shopperReference": Config.shopperReference, + }; + + //Add order for partial payments support + if (orderResponse != null) { + requestBody.addAll({"order": orderResponse}); + } + + return await service.fetchPaymentMethods(requestBody); } Future onSubmit( @@ -102,9 +110,6 @@ class AdyenDropInRepository extends AdyenBaseRepository { currency: Config.amount.currency, ), countryCode: Config.countryCode, - recurringProcessingModel: RecurringProcessingModel.cardOnFile, - shopperInteraction: - ShopperInteractionModel.ecommerce.shopperInteractionModelString, channel: determineChannel(), authenticationData: { "attemptAuthentication": "always", @@ -115,23 +120,49 @@ class AdyenDropInRepository extends AdyenBaseRepository { ); Map mergedJson = {}; - mergedJson.addAll(data); mergedJson.addAll(paymentsRequestData.toJson()); + // This will override any already existing fields in paymentsRequestData + mergedJson.addAll(data); final response = await service.postPayments(mergedJson); - return paymentEventHandler.handleResponse(response); + final paymentEvent = await _evaluatePaymentsResponse(response); + return paymentEvent; + } + + Future _evaluatePaymentsResponse( + Map response) async { + if (_hasOrderWithRemainingAmount(response)) { + final Map updatedPaymentMethods = + await fetchPaymentMethods( + orderResponse: { + "pspReference": response["order"]["pspReference"], + "orderData": response["order"]["orderData"], + }, + ); + return paymentEventHandler.handleResponse( + jsonResponse: response, + updatedPaymentMethods: updatedPaymentMethods, + ); + } else { + return paymentEventHandler.handleResponse(jsonResponse: response); + } } Future onAdditionalDetails( Map additionalDetails) async { - final response = await service.postPaymentsDetails(additionalDetails); - return paymentEventHandler.handleResponse(response); + final Map response = + await service.postPaymentsDetails(additionalDetails); + return paymentEventHandler.handleResponse(jsonResponse: response); } Future deleteStoredPaymentMethod(String storedPaymentMethodId) async { + final Map queryParameters = { + 'merchantAccount': Config.merchantAccount, + 'shopperReference': Config.shopperReference, + }; + return await service.deleteStoredPaymentMethod( - storedPaymentMethodId: storedPaymentMethodId, - merchantAccount: Config.merchantAccount, - shopperReference: Config.shopperReference, + storedPaymentMethodId, + queryParameters, ); } @@ -142,7 +173,7 @@ class AdyenDropInRepository extends AdyenBaseRepository { } Future> onRequestOrder() async { - final orderRequestBody = { + final Map orderRequestBody = { "reference": "flutter-test_${DateTime.now().millisecondsSinceEpoch}", "amount": { "value": Config.amount.value, @@ -153,8 +184,31 @@ class AdyenDropInRepository extends AdyenBaseRepository { return service.postOrders(orderRequestBody); } - Future> onCancelOrder( - Map orderCancelRequestBody) async { - return service.postOrders(orderCancelRequestBody); + Future onCancelOrder( + bool shouldUpdatePaymentMethods, + Map order, + ) async { + final orderCancelRequestBody = { + "merchantAccount": Config.merchantAccount, + "order": order, + }; + final Map orderCancelResponseBody = + await service.postOrdersCancel(orderCancelRequestBody); + final OrderCancelResponse orderCancelResponse = + OrderCancelResponse(orderCancelResponseBody: orderCancelResponseBody); + if (shouldUpdatePaymentMethods == true) { + final paymentMethods = await fetchPaymentMethods(); + orderCancelResponse.updatedPaymentMethods = paymentMethods; + } + + return orderCancelResponse; + } + + bool _hasOrderWithRemainingAmount(jsonResponse) { + if (jsonResponse.containsKey("order")) { + final remainingAmount = jsonResponse["order"]["remainingAmount"]["value"]; + return remainingAmount > 0; + } + return false; } } diff --git a/example/lib/repositories/adyen_google_pay_component_repository.dart b/example/lib/repositories/adyen_google_pay_component_repository.dart index ec8459c8..d9c41248 100644 --- a/example/lib/repositories/adyen_google_pay_component_repository.dart +++ b/example/lib/repositories/adyen_google_pay_component_repository.dart @@ -1,7 +1,6 @@ import 'package:adyen_checkout/adyen_checkout.dart'; import 'package:adyen_checkout_example/config.dart'; import 'package:adyen_checkout_example/network/models/amount_network_model.dart'; -import 'package:adyen_checkout_example/network/models/payment_methods_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/payment_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_response_network_model.dart'; @@ -54,12 +53,12 @@ class AdyenGooglePayComponentRepository extends AdyenBaseRepository { } Future> fetchPaymentMethods() async { - return await service.fetchPaymentMethods(PaymentMethodsRequestNetworkModel( - merchantAccount: Config.merchantAccount, - countryCode: Config.countryCode, - channel: determineChannel(), - shopperReference: Config.shopperReference, - )); + return await service.fetchPaymentMethods({ + "merchantAccount": Config.merchantAccount, + "countryCode": Config.countryCode, + "channel": determineChannel(), + "shopperReference": Config.shopperReference, + }); } Future onSubmit( @@ -94,12 +93,12 @@ class AdyenGooglePayComponentRepository extends AdyenBaseRepository { mergedJson.addAll(data); mergedJson.addAll(paymentsRequestData.toJson()); final response = await service.postPayments(mergedJson); - return paymentEventHandler.handleResponse(response); + return paymentEventHandler.handleResponse(jsonResponse: response); } Future onAdditionalDetails( Map additionalDetails) async { final response = await service.postPaymentsDetails(additionalDetails); - return paymentEventHandler.handleResponse(response); + return paymentEventHandler.handleResponse(jsonResponse: response); } } diff --git a/example/lib/repositories/adyen_instant_component_repository.dart b/example/lib/repositories/adyen_instant_component_repository.dart index d1e4cfa6..7fcc1dc4 100644 --- a/example/lib/repositories/adyen_instant_component_repository.dart +++ b/example/lib/repositories/adyen_instant_component_repository.dart @@ -2,7 +2,6 @@ import 'package:adyen_checkout/adyen_checkout.dart'; import 'package:adyen_checkout_example/config.dart'; import 'package:adyen_checkout_example/network/models/amount_network_model.dart'; import 'package:adyen_checkout_example/network/models/line_item.dart'; -import 'package:adyen_checkout_example/network/models/payment_methods_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/payment_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_request_network_model.dart'; import 'package:adyen_checkout_example/network/models/session_response_network_model.dart'; @@ -68,12 +67,12 @@ class AdyenInstantComponentRepository extends AdyenBaseRepository { } Future> fetchPaymentMethods() async { - return await service.fetchPaymentMethods(PaymentMethodsRequestNetworkModel( - merchantAccount: Config.merchantAccount, - countryCode: Config.countryCode, - channel: determineChannel(), - shopperReference: Config.shopperReference, - )); + return await service.fetchPaymentMethods({ + "merchantAccount": Config.merchantAccount, + "countryCode": Config.countryCode, + "channel": determineChannel(), + "shopperReference": Config.shopperReference, + }); } Future onSubmit( @@ -120,12 +119,12 @@ class AdyenInstantComponentRepository extends AdyenBaseRepository { mergedJson.addAll(data); mergedJson.addAll(paymentsRequestData.toJson()); final response = await service.postPayments(mergedJson); - return paymentEventHandler.handleResponse(response); + return paymentEventHandler.handleResponse(jsonResponse: response); } Future onAdditionalDetails( Map additionalDetails) async { final response = await service.postPaymentsDetails(additionalDetails); - return paymentEventHandler.handleResponse(response); + return paymentEventHandler.handleResponse(jsonResponse: response); } } diff --git a/example/lib/utils/payment_event_handler.dart b/example/lib/utils/payment_event_handler.dart index 94c2c1d3..bf0c71bc 100644 --- a/example/lib/utils/payment_event_handler.dart +++ b/example/lib/utils/payment_event_handler.dart @@ -5,11 +5,13 @@ class PaymentEventHandler { static const errorCodeKey = "errorCode"; static const resultCodeKey = "resultCode"; static const actionKey = "action"; - static const orderKey = "order"; static const messageKey = "message"; static const refusalReasonKey = "refusalReason"; - PaymentEvent handleResponse(Map jsonResponse) { + PaymentEvent handleResponse({ + required Map jsonResponse, + Map updatedPaymentMethods = const {}, + }) { if (_isError(jsonResponse)) { return Error( errorMessage: jsonResponse[messageKey], @@ -30,6 +32,14 @@ class PaymentEventHandler { return Action(actionResponse: jsonResponse[actionKey]); } + if (_isNonFullyPaidOrder(jsonResponse) && + updatedPaymentMethods.isNotEmpty) { + return Update( + orderResponse: jsonResponse["order"], + paymentMethods: updatedPaymentMethods, + ); + } + if (jsonResponse.containsKey(resultCodeKey)) { return Finished(resultCode: jsonResponse[resultCodeKey]); } @@ -56,10 +66,13 @@ class PaymentEventHandler { bool _isAction(jsonResponse) => jsonResponse.containsKey(actionKey); - bool _isNonFullyPaidOrder(jsonResponse) => - jsonResponse.containsKey(orderKey) && - (getOrderFromResponse(jsonResponse).remainingAmount?.value ?? 0) > 0; - - OrderResponse getOrderFromResponse(jsonResponse) => - OrderResponse.fromJson(jsonResponse); + bool _isNonFullyPaidOrder(jsonResponse) { + if (jsonResponse.containsKey("order")) { + final remainingAmount = + jsonResponse["order"]["remainingAmount"]["value"]; + return remainingAmount > 0; + } else { + return false; + } + } } diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index bd67f3c6..a2a99cd8 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -107,6 +107,7 @@ enum PaymentEventType: Int { case finished = 0 case action = 1 case error = 2 + case update = 3 } enum FieldVisibility: Int { @@ -903,13 +904,13 @@ struct ComponentCommunicationModel { struct PaymentEventDTO { var paymentEventType: PaymentEventType var result: String? = nil - var actionResponse: [String?: Any?]? = nil + var data: [String?: Any?]? = nil var error: ErrorDTO? = nil static func fromList(_ list: [Any?]) -> PaymentEventDTO? { let paymentEventType = PaymentEventType(rawValue: list[0] as! Int)! let result: String? = nilOrValue(list[1]) - let actionResponse: [String?: Any?]? = nilOrValue(list[2]) + let data: [String?: Any?]? = nilOrValue(list[2]) var error: ErrorDTO? = nil if let errorList: [Any?] = nilOrValue(list[3]) { error = ErrorDTO.fromList(errorList) @@ -918,7 +919,7 @@ struct PaymentEventDTO { return PaymentEventDTO( paymentEventType: paymentEventType, result: result, - actionResponse: actionResponse, + data: data, error: error ) } @@ -926,7 +927,7 @@ struct PaymentEventDTO { return [ paymentEventType.rawValue, result, - actionResponse, + data, error?.toList(), ] } @@ -1207,6 +1208,28 @@ struct ActionComponentConfigurationDTO { } } +/// Generated class from Pigeon that represents data sent in messages. +struct OrderCancelResponseDTO { + var orderCancelResponseBody: [String?: Any?] + var updatedPaymentMethods: [String?: Any?]? = nil + + static func fromList(_ list: [Any?]) -> OrderCancelResponseDTO? { + let orderCancelResponseBody = list[0] as! [String?: Any?] + let updatedPaymentMethods: [String?: Any?]? = nilOrValue(list[1]) + + return OrderCancelResponseDTO( + orderCancelResponseBody: orderCancelResponseBody, + updatedPaymentMethods: updatedPaymentMethods + ) + } + func toList() -> [Any?] { + return [ + orderCancelResponseBody, + updatedPaymentMethods, + ] + } +} + private class CheckoutPlatformInterfaceCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { @@ -1251,20 +1274,22 @@ private class CheckoutPlatformInterfaceCodecReader: FlutterStandardReader { case 147: return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) case 148: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) case 149: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) case 150: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) case 151: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) case 152: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) case 153: - return SessionDTO.fromList(self.readValue() as! [Any?]) + return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) case 154: - return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + return SessionDTO.fromList(self.readValue() as! [Any?]) case 155: + return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 156: return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -1334,30 +1359,33 @@ private class CheckoutPlatformInterfaceCodecWriter: FlutterStandardWriter { } else if let value = value as? MerchantInfoDTO { super.writeByte(147) super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { + } else if let value = value as? OrderCancelResponseDTO { super.writeByte(148) super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { + } else if let value = value as? OrderResponseDTO { super.writeByte(149) super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { + } else if let value = value as? PaymentEventDTO { super.writeByte(150) super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { + } else if let value = value as? PaymentResultDTO { super.writeByte(151) super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { + } else if let value = value as? PaymentResultModelDTO { super.writeByte(152) super.writeValue(value.toList()) - } else if let value = value as? SessionDTO { + } else if let value = value as? PlatformCommunicationModel { super.writeByte(153) super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { + } else if let value = value as? SessionDTO { super.writeByte(154) super.writeValue(value.toList()) - } else if let value = value as? UnencryptedCardDTO { + } else if let value = value as? ShippingAddressParametersDTO { super.writeByte(155) super.writeValue(value.toList()) + } else if let value = value as? UnencryptedCardDTO { + super.writeByte(156) + super.writeValue(value.toList()) } else { super.writeValue(value) } @@ -1514,8 +1542,10 @@ private class DropInPlatformInterfaceCodecReader: FlutterStandardReader { case 142: return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) case 143: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) case 144: + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + case 145: return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -1570,12 +1600,15 @@ private class DropInPlatformInterfaceCodecWriter: FlutterStandardWriter { } else if let value = value as? MerchantInfoDTO { super.writeByte(142) super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { + } else if let value = value as? OrderCancelResponseDTO { super.writeByte(143) super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { + } else if let value = value as? PaymentEventDTO { super.writeByte(144) super.writeValue(value.toList()) + } else if let value = value as? ShippingAddressParametersDTO { + super.writeByte(145) + super.writeValue(value.toList()) } else { super.writeValue(value) } @@ -1605,6 +1638,7 @@ protocol DropInPlatformInterface { func onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) throws func onBalanceCheckResult(balanceCheckResponse: String) throws func onOrderRequestResult(orderRequestResponse: String) throws + func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws func cleanUpDropIn() throws } @@ -1720,6 +1754,21 @@ class DropInPlatformInterfaceSetup { } else { onOrderRequestResultChannel.setMessageHandler(nil) } + let onOrderCancelResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onOrderCancelResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let orderCancelResponseArg = args[0] as! OrderCancelResponseDTO + do { + try api.onOrderCancelResult(orderCancelResponse: orderCancelResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onOrderCancelResultChannel.setMessageHandler(nil) + } let cleanUpDropInChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn", binaryMessenger: binaryMessenger, codec: codec) if let api = api { cleanUpDropInChannel.setMessageHandler { _, reply in @@ -1885,20 +1934,22 @@ private class ComponentPlatformInterfaceCodecReader: FlutterStandardReader { case 147: return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) case 148: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) case 149: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) case 150: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) case 151: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) case 152: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) case 153: - return SessionDTO.fromList(self.readValue() as! [Any?]) + return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) case 154: - return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + return SessionDTO.fromList(self.readValue() as! [Any?]) case 155: + return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 156: return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -1968,30 +2019,33 @@ private class ComponentPlatformInterfaceCodecWriter: FlutterStandardWriter { } else if let value = value as? MerchantInfoDTO { super.writeByte(147) super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { + } else if let value = value as? OrderCancelResponseDTO { super.writeByte(148) super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { + } else if let value = value as? OrderResponseDTO { super.writeByte(149) super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { + } else if let value = value as? PaymentEventDTO { super.writeByte(150) super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { + } else if let value = value as? PaymentResultDTO { super.writeByte(151) super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { + } else if let value = value as? PaymentResultModelDTO { super.writeByte(152) super.writeValue(value.toList()) - } else if let value = value as? SessionDTO { + } else if let value = value as? PlatformCommunicationModel { super.writeByte(153) super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { + } else if let value = value as? SessionDTO { super.writeByte(154) super.writeValue(value.toList()) - } else if let value = value as? UnencryptedCardDTO { + } else if let value = value as? ShippingAddressParametersDTO { super.writeByte(155) super.writeValue(value.toList()) + } else if let value = value as? UnencryptedCardDTO { + super.writeByte(156) + super.writeValue(value.toList()) } else { super.writeValue(value) } diff --git a/ios/Classes/components/ComponentPlatformApi.swift b/ios/Classes/components/ComponentPlatformApi.swift index 4b9ddccf..b6804c32 100644 --- a/ios/Classes/components/ComponentPlatformApi.swift +++ b/ios/Classes/components/ComponentPlatformApi.swift @@ -96,10 +96,12 @@ class ComponentPlatformApi: ComponentPlatformInterface { case .finished: onFinishCallback(paymentEventDTO) case .action: - guard let jsonActionResponse = paymentEventDTO.actionResponse else { return } + guard let jsonActionResponse = paymentEventDTO.data else { return } onActionCallback(jsonActionResponse) case .error: onErrorCallback(paymentEventDTO.error) + case .update: + return } } } diff --git a/ios/Classes/components/applePay/ApplePayAdvancedComponent.swift b/ios/Classes/components/applePay/ApplePayAdvancedComponent.swift index 50910d88..505bd10e 100644 --- a/ios/Classes/components/applePay/ApplePayAdvancedComponent.swift +++ b/ios/Classes/components/applePay/ApplePayAdvancedComponent.swift @@ -42,6 +42,9 @@ class ApplePayAdvancedComponent: BaseApplePayComponent { case .action: // Apple pay does not require action handling return + case .update: + // Apple pay does not support updating the payment flow + return } } diff --git a/ios/Classes/components/instant/InstantAdvancedComponent.swift b/ios/Classes/components/instant/InstantAdvancedComponent.swift index 8e1a6db6..b70da073 100644 --- a/ios/Classes/components/instant/InstantAdvancedComponent.swift +++ b/ios/Classes/components/instant/InstantAdvancedComponent.swift @@ -51,12 +51,14 @@ class InstantAdvancedComponent: BaseInstantComponent, InstantComponentProtocol { onError(paymentEventDTO: paymentEventDTO) case .action: onAction(paymentEventDTO: paymentEventDTO) + case .update: + return } } private func onAction(paymentEventDTO: PaymentEventDTO) { do { - guard let jsonActionResponse = paymentEventDTO.actionResponse else { return } + guard let jsonActionResponse = paymentEventDTO.data else { return } let jsonData = try JSONSerialization.data(withJSONObject: jsonActionResponse, options: []) let action = try JSONDecoder().decode(Action.self, from: jsonData) actionComponent?.handle(action) diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 5cebe4b7..fa377152 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -137,6 +137,10 @@ class DropInPlatformApi: DropInPlatformInterface { } + func onOrderRequestResult(orderRequestResponse: String) throws { + + } + func cleanUpDropIn() { sessionHolder.reset() @@ -156,6 +160,8 @@ class DropInPlatformApi: DropInPlatformInterface { onDropInResultAction(paymentEventDTO: paymentEventDTO) case .error: onDropInResultError(paymentEventDTO: paymentEventDTO) + case .update: + return } } @@ -180,7 +186,7 @@ class DropInPlatformApi: DropInPlatformInterface { private func onDropInResultAction(paymentEventDTO: PaymentEventDTO) { do { - let jsonData = try JSONSerialization.data(withJSONObject: paymentEventDTO.actionResponse as Any, options: []) + let jsonData = try JSONSerialization.data(withJSONObject: paymentEventDTO.data as Any, options: []) let result = try JSONDecoder().decode(Action.self, from: jsonData) dropInViewController?.dropInComponent.handle(result) } catch { diff --git a/lib/adyen_checkout.dart b/lib/adyen_checkout.dart index afe73b18..5335de90 100644 --- a/lib/adyen_checkout.dart +++ b/lib/adyen_checkout.dart @@ -5,7 +5,8 @@ export 'src/common/model/checkout.dart'; export 'src/common/model/cse/encrypted_card.dart'; export 'src/common/model/cse/unencrypted_card.dart'; export 'src/common/model/order_response.dart'; -export 'src/common/model/partial_payment.dart'; +export 'src/common/model/partial_payment/order_cancel_response.dart'; +export 'src/common/model/partial_payment/partial_payment.dart'; export 'src/common/model/payment_event.dart'; export 'src/common/model/payment_method_configurations/apple_pay/apple_pay_configuration.dart'; export 'src/common/model/payment_method_configurations/apple_pay/apple_pay_contact.dart'; diff --git a/lib/src/common/model/checkout.dart b/lib/src/common/model/checkout.dart index 42f34c7c..ff2055ae 100644 --- a/lib/src/common/model/checkout.dart +++ b/lib/src/common/model/checkout.dart @@ -1,4 +1,4 @@ -import 'package:adyen_checkout/src/common/model/partial_payment.dart'; +import 'package:adyen_checkout/src/common/model/partial_payment/partial_payment.dart'; import 'package:adyen_checkout/src/common/model/payment_event.dart'; sealed class Checkout {} diff --git a/lib/src/common/model/partial_payment.dart b/lib/src/common/model/partial_payment.dart deleted file mode 100644 index ab00db08..00000000 --- a/lib/src/common/model/partial_payment.dart +++ /dev/null @@ -1,13 +0,0 @@ -class PartialPayment { - Future> Function(Map balanceResponse) - onCheckBalance; - Future> Function() onRequestOrder; - Future> Function(Map orderResponse) - onCancelOrder; - - PartialPayment({ - required this.onCheckBalance, - required this.onRequestOrder, - required this.onCancelOrder, - }); -} diff --git a/lib/src/common/model/partial_payment/order_cancel_response.dart b/lib/src/common/model/partial_payment/order_cancel_response.dart new file mode 100644 index 00000000..ba477625 --- /dev/null +++ b/lib/src/common/model/partial_payment/order_cancel_response.dart @@ -0,0 +1,9 @@ +class OrderCancelResponse { + final Map orderCancelResponseBody; + Map? updatedPaymentMethods; + + OrderCancelResponse({ + required this.orderCancelResponseBody, + this.updatedPaymentMethods, + }); +} diff --git a/lib/src/common/model/partial_payment/partial_payment.dart b/lib/src/common/model/partial_payment/partial_payment.dart new file mode 100644 index 00000000..4fb248cd --- /dev/null +++ b/lib/src/common/model/partial_payment/partial_payment.dart @@ -0,0 +1,17 @@ +import 'package:adyen_checkout/src/common/model/partial_payment/order_cancel_response.dart'; + +class PartialPayment { + Future> Function(Map requestBody) + onCheckBalance; + Future> Function() onRequestOrder; + Future Function( + bool shouldUpdatePaymentMethods, + Map order, + ) onCancelOrder; + + PartialPayment({ + required this.onCheckBalance, + required this.onRequestOrder, + required this.onCancelOrder, + }); +} diff --git a/lib/src/common/model/payment_event.dart b/lib/src/common/model/payment_event.dart index fbb5a686..5585a1f0 100644 --- a/lib/src/common/model/payment_event.dart +++ b/lib/src/common/model/payment_event.dart @@ -12,6 +12,16 @@ class Action extends PaymentEvent { Action({required this.actionResponse}); } +class Update extends PaymentEvent { + final Map paymentMethods; + final Map orderResponse; + + Update({ + required this.paymentMethods, + required this.orderResponse, + }); +} + class Error extends PaymentEvent { final String? errorMessage; final String? reason; diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index e47aa015..f889b823 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -121,7 +121,7 @@ class DropIn { case PlatformCommunicationType.requestOrder: _handleOrderRequest(event, advancedCheckout.partialPayment); case PlatformCommunicationType.cancelOrder: - // TODO: Handle this case. + _handleOrderCancel(event, advancedCheckout.partialPayment); } }); @@ -273,12 +273,11 @@ class DropIn { throw Exception("Partial payment implementation is not provided."); } - final Map data = jsonDecode(event.data as String); - final Map requestBody = {}; - requestBody.addAll({ + final data = jsonDecode(event.data as String); + final Map requestBody = { "paymentMethod": data["paymentMethod"], "amount": data["amount"], - }); + }; final balanceCheckResponse = await partialPayment.onCheckBalance(requestBody); @@ -296,7 +295,26 @@ class DropIn { throw Exception("Partial payment implementation is not provided."); } - final balanceCheckResponse = await partialPayment.onRequestOrder(); - dropInPlatformApi.onOrderRequestResult(jsonEncode(balanceCheckResponse)); + final orderRequestResponse = await partialPayment.onRequestOrder(); + dropInPlatformApi.onOrderRequestResult(jsonEncode(orderRequestResponse)); + } + + void _handleOrderCancel( + PlatformCommunicationModel event, + PartialPayment? partialPayment, + ) async { + if (partialPayment == null) { + dropInPlatformApi.onOrderCancelResult( + OrderCancelResponseDTO(orderCancelResponseBody: {})); + throw Exception("Partial payment implementation is not provided."); + } + + final orderResponse = jsonDecode(event.data as String); + final orderCancelResponse = await partialPayment.onCancelOrder( + orderResponse["shouldUpdatePaymentMethods"] as bool? ?? false, + orderResponse["order"], + ); + + dropInPlatformApi.onOrderCancelResult(orderCancelResponse.toDTO()); } } diff --git a/lib/src/drop_in/drop_in_platform_api.dart b/lib/src/drop_in/drop_in_platform_api.dart index ad90a1e9..8618ef56 100644 --- a/lib/src/drop_in/drop_in_platform_api.dart +++ b/lib/src/drop_in/drop_in_platform_api.dart @@ -45,4 +45,9 @@ class DropInPlatformApi implements DropInPlatformInterface { @override Future onOrderRequestResult(String orderRequestResponse) => _dropInPlatformInterface.onOrderRequestResult(orderRequestResponse); + + @override + Future onOrderCancelResult( + OrderCancelResponseDTO orderCancelResponse) => + _dropInPlatformInterface.onOrderCancelResult(orderCancelResponse); } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index 7087fa8e..f253a5ea 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -15,8 +15,7 @@ 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 []; } @@ -90,6 +89,7 @@ enum PaymentEventType { finished, action, error, + update, } enum FieldVisibility { @@ -294,14 +294,12 @@ class DropInConfigurationDTO { cashAppPayConfigurationDTO: result[8] != null ? CashAppPayConfigurationDTO.decode(result[8]! as List) : null, - analyticsOptionsDTO: - AnalyticsOptionsDTO.decode(result[9]! as List), + analyticsOptionsDTO: AnalyticsOptionsDTO.decode(result[9]! as List), showPreselectedStoredPaymentMethod: result[10]! as bool, 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(), ); } } @@ -356,8 +354,7 @@ class CardConfigurationDTO { showCvcForStoredCard: result[3]! as bool, showCvc: result[4]! as bool, kcpFieldVisibility: FieldVisibility.values[result[5]! as int], - socialSecurityNumberFieldVisibility: - FieldVisibility.values[result[6]! as int], + socialSecurityNumberFieldVisibility: FieldVisibility.values[result[6]! as int], supportedCardTypes: (result[7] as List?)!.cast(), ); } @@ -434,15 +431,12 @@ 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] != null ? ApplePayContactDTO.decode(result[5]! as List) : null, - requiredShippingContactFields: - (result[6] as List?)?.cast(), + requiredShippingContactFields: (result[6] as List?)?.cast(), shippingContact: result[7] != null ? ApplePayContactDTO.decode(result[7]! as List) : null, @@ -450,8 +444,7 @@ class ApplePayConfigurationDTO { ? ApplePayShippingType.values[result[8]! as int] : null, 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] != null @@ -701,8 +694,9 @@ class GooglePayConfigurationDTO { merchantInfoDTO: result[2] != null ? MerchantInfoDTO.decode(result[2]! as List) : null, - totalPriceStatus: - result[3] != null ? TotalPriceStatus.values[result[3]! as int] : null, + totalPriceStatus: result[3] != null + ? TotalPriceStatus.values[result[3]! as int] + : null, allowedCardNetworks: (result[4] as List?)?.cast(), allowedAuthMethods: (result[5] as List?)?.cast(), allowPrepaidCards: result[6] as bool?, @@ -1017,7 +1011,7 @@ class PaymentEventDTO { PaymentEventDTO({ required this.paymentEventType, this.result, - this.actionResponse, + this.data, this.error, }); @@ -1025,7 +1019,7 @@ class PaymentEventDTO { String? result; - Map? actionResponse; + Map? data; ErrorDTO? error; @@ -1033,7 +1027,7 @@ class PaymentEventDTO { return [ paymentEventType.index, result, - actionResponse, + data, error?.encode(), ]; } @@ -1043,8 +1037,7 @@ class PaymentEventDTO { return PaymentEventDTO( paymentEventType: PaymentEventType.values[result[0]! as int], result: result[1] as String?, - actionResponse: - (result[2] as Map?)?.cast(), + data: (result[2] as Map?)?.cast(), error: result[3] != null ? ErrorDTO.decode(result[3]! as List) : null, @@ -1156,10 +1149,8 @@ class CardComponentConfigurationDTO { ? AmountDTO.decode(result[3]! as List) : null, shopperLocale: result[4] as String?, - cardConfiguration: - CardConfigurationDTO.decode(result[5]! as List), - analyticsOptionsDTO: - AnalyticsOptionsDTO.decode(result[6]! as List), + cardConfiguration: CardConfigurationDTO.decode(result[5]! as List), + analyticsOptionsDTO: AnalyticsOptionsDTO.decode(result[6]! as List), ); } } @@ -1220,8 +1211,7 @@ class InstantPaymentConfigurationDTO { ? AmountDTO.decode(result[4]! as List) : null, shopperLocale: result[5] as String?, - analyticsOptionsDTO: - AnalyticsOptionsDTO.decode(result[6]! as List), + analyticsOptionsDTO: AnalyticsOptionsDTO.decode(result[6]! as List), googlePayConfigurationDTO: result[7] != null ? GooglePayConfigurationDTO.decode(result[7]! as List) : null, @@ -1373,8 +1363,33 @@ class ActionComponentConfigurationDTO { amount: result[3] != null ? AmountDTO.decode(result[3]! as List) : null, - analyticsOptionsDTO: - AnalyticsOptionsDTO.decode(result[4]! as List), + analyticsOptionsDTO: AnalyticsOptionsDTO.decode(result[4]! as List), + ); + } +} + +class OrderCancelResponseDTO { + OrderCancelResponseDTO({ + required this.orderCancelResponseBody, + this.updatedPaymentMethods, + }); + + Map orderCancelResponseBody; + + Map? updatedPaymentMethods; + + Object encode() { + return [ + orderCancelResponseBody, + updatedPaymentMethods, + ]; + } + + static OrderCancelResponseDTO decode(Object result) { + result as List; + return OrderCancelResponseDTO( + orderCancelResponseBody: (result[0] as Map?)!.cast(), + updatedPaymentMethods: (result[1] as Map?)?.cast(), ); } } @@ -1443,30 +1458,33 @@ class _CheckoutPlatformInterfaceCodec extends StandardMessageCodec { } else if (value is MerchantInfoDTO) { buffer.putUint8(147); writeValue(buffer, value.encode()); - } else if (value is OrderResponseDTO) { + } else if (value is OrderCancelResponseDTO) { buffer.putUint8(148); writeValue(buffer, value.encode()); - } else if (value is PaymentEventDTO) { + } else if (value is OrderResponseDTO) { buffer.putUint8(149); writeValue(buffer, value.encode()); - } else if (value is PaymentResultDTO) { + } else if (value is PaymentEventDTO) { buffer.putUint8(150); writeValue(buffer, value.encode()); - } else if (value is PaymentResultModelDTO) { + } else if (value is PaymentResultDTO) { buffer.putUint8(151); writeValue(buffer, value.encode()); - } else if (value is PlatformCommunicationModel) { + } else if (value is PaymentResultModelDTO) { buffer.putUint8(152); writeValue(buffer, value.encode()); - } else if (value is SessionDTO) { + } else if (value is PlatformCommunicationModel) { buffer.putUint8(153); writeValue(buffer, value.encode()); - } else if (value is ShippingAddressParametersDTO) { + } else if (value is SessionDTO) { buffer.putUint8(154); writeValue(buffer, value.encode()); - } else if (value is UnencryptedCardDTO) { + } else if (value is ShippingAddressParametersDTO) { buffer.putUint8(155); writeValue(buffer, value.encode()); + } else if (value is UnencryptedCardDTO) { + buffer.putUint8(156); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -1475,61 +1493,63 @@ class _CheckoutPlatformInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ActionComponentConfigurationDTO.decode(readValue(buffer)!); - case 129: + case 129: return AmountDTO.decode(readValue(buffer)!); - case 130: + case 130: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 131: + case 131: return ApplePayConfigurationDTO.decode(readValue(buffer)!); - case 132: + case 132: return ApplePayContactDTO.decode(readValue(buffer)!); - case 133: + case 133: return ApplePayShippingMethodDTO.decode(readValue(buffer)!); - case 134: + case 134: return ApplePaySummaryItemDTO.decode(readValue(buffer)!); - case 135: + case 135: return BillingAddressParametersDTO.decode(readValue(buffer)!); - case 136: + case 136: return CardComponentConfigurationDTO.decode(readValue(buffer)!); - case 137: + case 137: return CardConfigurationDTO.decode(readValue(buffer)!); - case 138: + case 138: return CashAppPayConfigurationDTO.decode(readValue(buffer)!); - case 139: + case 139: return ComponentCommunicationModel.decode(readValue(buffer)!); - case 140: + case 140: return DeletedStoredPaymentMethodResultDTO.decode(readValue(buffer)!); - case 141: + case 141: return DropInConfigurationDTO.decode(readValue(buffer)!); - case 142: + case 142: return EncryptedCardDTO.decode(readValue(buffer)!); - case 143: + case 143: return ErrorDTO.decode(readValue(buffer)!); - case 144: + case 144: return GooglePayConfigurationDTO.decode(readValue(buffer)!); - case 145: + case 145: return InstantPaymentConfigurationDTO.decode(readValue(buffer)!); - case 146: + case 146: return InstantPaymentSetupResultDTO.decode(readValue(buffer)!); - case 147: + case 147: return MerchantInfoDTO.decode(readValue(buffer)!); - case 148: + case 148: + return OrderCancelResponseDTO.decode(readValue(buffer)!); + case 149: return OrderResponseDTO.decode(readValue(buffer)!); - case 149: + case 150: return PaymentEventDTO.decode(readValue(buffer)!); - case 150: + case 151: return PaymentResultDTO.decode(readValue(buffer)!); - case 151: + case 152: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 152: + case 153: return PlatformCommunicationModel.decode(readValue(buffer)!); - case 153: + case 154: return SessionDTO.decode(readValue(buffer)!); - case 154: + case 155: return ShippingAddressParametersDTO.decode(readValue(buffer)!); - case 155: + case 156: return UnencryptedCardDTO.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1545,14 +1565,11 @@ class CheckoutPlatformInterface { : __pigeon_binaryMessenger = binaryMessenger; final BinaryMessenger? __pigeon_binaryMessenger; - static const MessageCodec pigeonChannelCodec = - _CheckoutPlatformInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = _CheckoutPlatformInterfaceCodec(); Future getReturnUrl() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1577,19 +1594,15 @@ class CheckoutPlatformInterface { } } - Future createSession( - String sessionId, String sessionData, Object? configuration) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future createSession(String sessionId, String sessionData, Object? configuration) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession'; + 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) { @@ -1608,42 +1621,15 @@ class CheckoutPlatformInterface { } } - Future clearSession() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future encryptCard(UnencryptedCardDTO unencryptedCardDTO, String publicKey) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - } - - Future encryptCard( - UnencryptedCardDTO unencryptedCardDTO, String publicKey) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = await __pigeon_channel - .send([unencryptedCardDTO, publicKey]) as List?; + await __pigeon_channel.send([unencryptedCardDTO, publicKey]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1663,16 +1649,14 @@ class CheckoutPlatformInterface { } Future encryptBin(String bin, String publicKey) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin'; + 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) { @@ -1692,16 +1676,14 @@ class CheckoutPlatformInterface { } Future enableConsoleLogging(bool loggingEnabled) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging'; + 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) { @@ -1765,12 +1747,15 @@ class _DropInPlatformInterfaceCodec extends StandardMessageCodec { } else if (value is MerchantInfoDTO) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is PaymentEventDTO) { + } else if (value is OrderCancelResponseDTO) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is ShippingAddressParametersDTO) { + } else if (value is PaymentEventDTO) { buffer.putUint8(144); writeValue(buffer, value.encode()); + } else if (value is ShippingAddressParametersDTO) { + buffer.putUint8(145); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -1779,39 +1764,41 @@ class _DropInPlatformInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return AmountDTO.decode(readValue(buffer)!); - case 129: + case 129: return AmountDTO.decode(readValue(buffer)!); - case 130: + case 130: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 131: + case 131: return ApplePayConfigurationDTO.decode(readValue(buffer)!); - case 132: + case 132: return ApplePayContactDTO.decode(readValue(buffer)!); - case 133: + case 133: return ApplePayShippingMethodDTO.decode(readValue(buffer)!); - case 134: + case 134: return ApplePaySummaryItemDTO.decode(readValue(buffer)!); - case 135: + case 135: return BillingAddressParametersDTO.decode(readValue(buffer)!); - case 136: + case 136: return CardConfigurationDTO.decode(readValue(buffer)!); - case 137: + case 137: return CashAppPayConfigurationDTO.decode(readValue(buffer)!); - case 138: + case 138: return DeletedStoredPaymentMethodResultDTO.decode(readValue(buffer)!); - case 139: + case 139: return DropInConfigurationDTO.decode(readValue(buffer)!); - case 140: + case 140: return ErrorDTO.decode(readValue(buffer)!); - case 141: + case 141: return GooglePayConfigurationDTO.decode(readValue(buffer)!); - case 142: + case 142: return MerchantInfoDTO.decode(readValue(buffer)!); - case 143: + case 143: + return OrderCancelResponseDTO.decode(readValue(buffer)!); + case 144: return PaymentEventDTO.decode(readValue(buffer)!); - case 144: + case 145: return ShippingAddressParametersDTO.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1827,21 +1814,17 @@ class DropInPlatformInterface { : __pigeon_binaryMessenger = binaryMessenger; final BinaryMessenger? __pigeon_binaryMessenger; - static const MessageCodec pigeonChannelCodec = - _DropInPlatformInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = _DropInPlatformInterfaceCodec(); - Future showDropInSession( - DropInConfigurationDTO dropInConfigurationDTO) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future showDropInSession(DropInConfigurationDTO dropInConfigurationDTO) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession'; + 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) { @@ -1855,19 +1838,15 @@ class DropInPlatformInterface { } } - Future showDropInAdvanced(DropInConfigurationDTO dropInConfigurationDTO, - String paymentMethodsResponse) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future showDropInAdvanced(DropInConfigurationDTO dropInConfigurationDTO, String paymentMethodsResponse) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced'; + 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) { @@ -1882,16 +1861,14 @@ class DropInPlatformInterface { } Future onPaymentsResult(PaymentEventDTO paymentsResult) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult'; + 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) { @@ -1905,18 +1882,15 @@ class DropInPlatformInterface { } } - Future onPaymentsDetailsResult( - PaymentEventDTO paymentsDetailsResult) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future onPaymentsDetailsResult(PaymentEventDTO paymentsDetailsResult) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult'; + 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) { @@ -1930,19 +1904,15 @@ class DropInPlatformInterface { } } - Future onDeleteStoredPaymentMethodResult( - DeletedStoredPaymentMethodResultDTO - deleteStoredPaymentMethodResultDTO) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future onDeleteStoredPaymentMethodResult(DeletedStoredPaymentMethodResultDTO deleteStoredPaymentMethodResultDTO) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult'; + 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) { @@ -2000,11 +1970,31 @@ class DropInPlatformInterface { } } + Future onOrderCancelResult(OrderCancelResponseDTO orderCancelResponse) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([orderCancelResponse]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + Future cleanUpDropIn() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2052,15 +2042,15 @@ class _DropInFlutterInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return AmountDTO.decode(readValue(buffer)!); - case 129: + case 129: return OrderResponseDTO.decode(readValue(buffer)!); - case 130: + case 130: return PaymentResultDTO.decode(readValue(buffer)!); - case 131: + case 131: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 132: + case 132: return PlatformCommunicationModel.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -2069,73 +2059,59 @@ class _DropInFlutterInterfaceCodec extends StandardMessageCodec { } abstract class DropInFlutterInterface { - static const MessageCodec pigeonChannelCodec = - _DropInFlutterInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = _DropInFlutterInterfaceCodec(); - void onDropInSessionPlatformCommunication( - PlatformCommunicationModel platformCommunicationModel); + void onDropInSessionPlatformCommunication(PlatformCommunicationModel platformCommunicationModel); - void onDropInAdvancedPlatformCommunication( - PlatformCommunicationModel platformCommunicationModel); + void onDropInAdvancedPlatformCommunication(PlatformCommunicationModel platformCommunicationModel); - static void setup(DropInFlutterInterface? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(DropInFlutterInterface? api, {BinaryMessenger? binaryMessenger}) { { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication', - pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication', 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.'); + '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?); + 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!); + 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())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication', - pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication', 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.onDropInAdvancedPlatformCommunication 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.'); try { - api.onDropInAdvancedPlatformCommunication( - arg_platformCommunicationModel!); + api.onDropInAdvancedPlatformCommunication(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())); } }); } @@ -2207,30 +2183,33 @@ class _ComponentPlatformInterfaceCodec extends StandardMessageCodec { } else if (value is MerchantInfoDTO) { buffer.putUint8(147); writeValue(buffer, value.encode()); - } else if (value is OrderResponseDTO) { + } else if (value is OrderCancelResponseDTO) { buffer.putUint8(148); writeValue(buffer, value.encode()); - } else if (value is PaymentEventDTO) { + } else if (value is OrderResponseDTO) { buffer.putUint8(149); writeValue(buffer, value.encode()); - } else if (value is PaymentResultDTO) { + } else if (value is PaymentEventDTO) { buffer.putUint8(150); writeValue(buffer, value.encode()); - } else if (value is PaymentResultModelDTO) { + } else if (value is PaymentResultDTO) { buffer.putUint8(151); writeValue(buffer, value.encode()); - } else if (value is PlatformCommunicationModel) { + } else if (value is PaymentResultModelDTO) { buffer.putUint8(152); writeValue(buffer, value.encode()); - } else if (value is SessionDTO) { + } else if (value is PlatformCommunicationModel) { buffer.putUint8(153); writeValue(buffer, value.encode()); - } else if (value is ShippingAddressParametersDTO) { + } else if (value is SessionDTO) { buffer.putUint8(154); writeValue(buffer, value.encode()); - } else if (value is UnencryptedCardDTO) { + } else if (value is ShippingAddressParametersDTO) { buffer.putUint8(155); writeValue(buffer, value.encode()); + } else if (value is UnencryptedCardDTO) { + buffer.putUint8(156); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -2239,61 +2218,63 @@ class _ComponentPlatformInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ActionComponentConfigurationDTO.decode(readValue(buffer)!); - case 129: + case 129: return AmountDTO.decode(readValue(buffer)!); - case 130: + case 130: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 131: + case 131: return ApplePayConfigurationDTO.decode(readValue(buffer)!); - case 132: + case 132: return ApplePayContactDTO.decode(readValue(buffer)!); - case 133: + case 133: return ApplePayShippingMethodDTO.decode(readValue(buffer)!); - case 134: + case 134: return ApplePaySummaryItemDTO.decode(readValue(buffer)!); - case 135: + case 135: return BillingAddressParametersDTO.decode(readValue(buffer)!); - case 136: + case 136: return CardComponentConfigurationDTO.decode(readValue(buffer)!); - case 137: + case 137: return CardConfigurationDTO.decode(readValue(buffer)!); - case 138: + case 138: return CashAppPayConfigurationDTO.decode(readValue(buffer)!); - case 139: + case 139: return ComponentCommunicationModel.decode(readValue(buffer)!); - case 140: + case 140: return DeletedStoredPaymentMethodResultDTO.decode(readValue(buffer)!); - case 141: + case 141: return DropInConfigurationDTO.decode(readValue(buffer)!); - case 142: + case 142: return EncryptedCardDTO.decode(readValue(buffer)!); - case 143: + case 143: return ErrorDTO.decode(readValue(buffer)!); - case 144: + case 144: return GooglePayConfigurationDTO.decode(readValue(buffer)!); - case 145: + case 145: return InstantPaymentConfigurationDTO.decode(readValue(buffer)!); - case 146: + case 146: return InstantPaymentSetupResultDTO.decode(readValue(buffer)!); - case 147: + case 147: return MerchantInfoDTO.decode(readValue(buffer)!); - case 148: + case 148: + return OrderCancelResponseDTO.decode(readValue(buffer)!); + case 149: return OrderResponseDTO.decode(readValue(buffer)!); - case 149: + case 150: return PaymentEventDTO.decode(readValue(buffer)!); - case 150: + case 151: return PaymentResultDTO.decode(readValue(buffer)!); - case 151: + case 152: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 152: + case 153: return PlatformCommunicationModel.decode(readValue(buffer)!); - case 153: + case 154: return SessionDTO.decode(readValue(buffer)!); - case 154: + case 155: return ShippingAddressParametersDTO.decode(readValue(buffer)!); - case 155: + case 156: return UnencryptedCardDTO.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -2309,14 +2290,11 @@ class ComponentPlatformInterface { : __pigeon_binaryMessenger = binaryMessenger; final BinaryMessenger? __pigeon_binaryMessenger; - static const MessageCodec pigeonChannelCodec = - _ComponentPlatformInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = _ComponentPlatformInterfaceCodec(); Future updateViewHeight(int viewId) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2336,18 +2314,15 @@ class ComponentPlatformInterface { } } - Future onPaymentsResult( - String componentId, PaymentEventDTO paymentsResult) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future onPaymentsResult(String componentId, PaymentEventDTO paymentsResult) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult'; + 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) { @@ -2361,18 +2336,15 @@ class ComponentPlatformInterface { } } - Future onPaymentsDetailsResult( - String componentId, PaymentEventDTO paymentsDetailsResult) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future onPaymentsDetailsResult(String componentId, PaymentEventDTO paymentsDetailsResult) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult'; + 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) { @@ -2386,24 +2358,15 @@ class ComponentPlatformInterface { } } - Future isInstantPaymentSupportedByPlatform( - InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, - String paymentMethodResponse, - String componentId) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future isInstantPaymentSupportedByPlatform(InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, String paymentMethodResponse, String componentId) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform'; + 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) { @@ -2422,24 +2385,15 @@ class ComponentPlatformInterface { } } - Future onInstantPaymentPressed( - InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, - String encodedPaymentMethod, - String componentId) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future onInstantPaymentPressed(InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, String encodedPaymentMethod, String componentId) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed'; + 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) { @@ -2453,24 +2407,15 @@ class ComponentPlatformInterface { } } - Future handleAction( - ActionComponentConfigurationDTO actionComponentConfiguration, - String componentId, - Map? actionResponse) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future handleAction(ActionComponentConfigurationDTO actionComponentConfiguration, String componentId, Map? actionResponse) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction'; + 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) { @@ -2485,10 +2430,8 @@ class ComponentPlatformInterface { } Future onDispose(String componentId) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2548,23 +2491,23 @@ class _ComponentFlutterInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return AmountDTO.decode(readValue(buffer)!); - case 129: + case 129: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 130: + case 130: return CardComponentConfigurationDTO.decode(readValue(buffer)!); - case 131: + case 131: return CardConfigurationDTO.decode(readValue(buffer)!); - case 132: + case 132: return ComponentCommunicationModel.decode(readValue(buffer)!); - case 133: + case 133: return OrderResponseDTO.decode(readValue(buffer)!); - case 134: + case 134: return PaymentResultDTO.decode(readValue(buffer)!); - case 135: + case 135: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 136: + case 136: return SessionDTO.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -2573,67 +2516,53 @@ class _ComponentFlutterInterfaceCodec extends StandardMessageCodec { } abstract class ComponentFlutterInterface { - static const MessageCodec pigeonChannelCodec = - _ComponentFlutterInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = _ComponentFlutterInterfaceCodec(); - 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}) { + static void setup(ComponentFlutterInterface? api, {BinaryMessenger? binaryMessenger}) { { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs', - pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs', 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< - Object?>( - 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication', - pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication', 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 { @@ -2641,9 +2570,8 @@ 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/lib/src/util/dto_mapper.dart b/lib/src/util/dto_mapper.dart index 2e20310a..c7687451 100644 --- a/lib/src/util/dto_mapper.dart +++ b/lib/src/util/dto_mapper.dart @@ -13,24 +13,25 @@ extension AnalyticsOptionsMapper on AnalyticsOptions { extension DropInConfigurationMapper on DropInConfiguration { DropInConfigurationDTO toDTO(String sdkVersionNumber) => DropInConfigurationDTO( - environment: environment, - clientKey: clientKey, - countryCode: countryCode.toUpperCase(), - amount: amount?.toDTO(), - shopperLocale: shopperLocale, - cardConfigurationDTO: cardConfiguration?.toDTO(), - applePayConfigurationDTO: applePayConfiguration?.toDTO(), - googlePayConfigurationDTO: googlePayConfiguration?.toDTO(), - cashAppPayConfigurationDTO: cashAppPayConfiguration?.toDTO(), - analyticsOptionsDTO: analyticsOptions.toDTO(sdkVersionNumber), - isRemoveStoredPaymentMethodEnabled: _isRemoveStoredPaymentMethodEnabled( - storedPaymentMethodConfiguration), - showPreselectedStoredPaymentMethod: storedPaymentMethodConfiguration - ?.showPreselectedStoredPaymentMethod ?? - true, - skipListWhenSinglePaymentMethod: skipListWhenSinglePaymentMethod, - preselectedPaymentMethodTitle: preselectedPaymentMethodTitle, - paymentMethodNames: paymentMethodNames, + environment: environment, + clientKey: clientKey, + countryCode: countryCode.toUpperCase(), + amount: amount?.toDTO(), + shopperLocale: shopperLocale, + cardConfigurationDTO: cardConfiguration?.toDTO(), + applePayConfigurationDTO: applePayConfiguration?.toDTO(), + googlePayConfigurationDTO: googlePayConfiguration?.toDTO(), + cashAppPayConfigurationDTO: cashAppPayConfiguration?.toDTO(), + analyticsOptionsDTO: analyticsOptions.toDTO(sdkVersionNumber), + isRemoveStoredPaymentMethodEnabled: + _isRemoveStoredPaymentMethodEnabled( + storedPaymentMethodConfiguration), + showPreselectedStoredPaymentMethod: storedPaymentMethodConfiguration + ?.showPreselectedStoredPaymentMethod ?? + true, + skipListWhenSinglePaymentMethod: skipListWhenSinglePaymentMethod, + preselectedPaymentMethodTitle: preselectedPaymentMethodTitle, + paymentMethodNames: paymentMethodNames, ); bool _isRemoveStoredPaymentMethodEnabled( @@ -302,3 +303,12 @@ extension ActionComponentConfigurationMapper on ActionComponentConfiguration { analyticsOptionsDTO: analyticsOptions.toDTO(sdkVersionNumber), ); } + +extension OrderCancelResponseMapper on OrderCancelResponse { + OrderCancelResponseDTO toDTO() { + return OrderCancelResponseDTO( + orderCancelResponseBody: orderCancelResponseBody, + updatedPaymentMethods: updatedPaymentMethods, + ); + } +} diff --git a/lib/src/util/payment_event_handler.dart b/lib/src/util/payment_event_handler.dart index e38f5c67..098f41be 100644 --- a/lib/src/util/payment_event_handler.dart +++ b/lib/src/util/payment_event_handler.dart @@ -10,7 +10,7 @@ class PaymentEventHandler { ), Action() => PaymentEventDTO( paymentEventType: PaymentEventType.action, - actionResponse: paymentEvent.actionResponse, + data: paymentEvent.actionResponse, ), Error() => PaymentEventDTO( paymentEventType: PaymentEventType.error, @@ -20,6 +20,13 @@ class PaymentEventHandler { dismissDropIn: paymentEvent.dismissDropIn, ), ), + Update() => PaymentEventDTO( + paymentEventType: PaymentEventType.update, + data: { + "updatedPaymentMethods": paymentEvent.paymentMethods, + "orderResponse": paymentEvent.orderResponse, + }, + ), }; } } diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 4bce19a2..60928b7f 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -75,6 +75,7 @@ enum PaymentEventType { finished, action, error, + update, } enum FieldVisibility { @@ -440,13 +441,13 @@ class ComponentCommunicationModel { class PaymentEventDTO { final PaymentEventType paymentEventType; final String? result; - final Map? actionResponse; + final Map? data; final ErrorDTO? error; PaymentEventDTO({ required this.paymentEventType, this.result, - this.actionResponse, + this.data, this.error, }); } @@ -573,6 +574,16 @@ class ActionComponentConfigurationDTO { ); } +class OrderCancelResponseDTO { + final Map orderCancelResponseBody; + final Map? updatedPaymentMethods; + + OrderCancelResponseDTO( + this.orderCancelResponseBody, + this.updatedPaymentMethods, + ); +} + @HostApi() abstract class CheckoutPlatformInterface { @async @@ -622,6 +633,8 @@ abstract class DropInPlatformInterface { void onOrderRequestResult(String orderRequestResponse); + void onOrderCancelResult(OrderCancelResponseDTO orderCancelResponse); + void cleanUpDropIn(); } From e18088f7a9bb57ceaef9ff05e65fa88551b23d53 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Mon, 28 Oct 2024 18:42:00 +0100 Subject: [PATCH 03/21] Rebase with main --- ios/Classes/PlatformApi.swift | 14 ++++++++++++++ ios/Classes/dropIn/DropInPlatformApi.swift | 3 +++ lib/src/generated/platform_api.g.dart | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index a2a99cd8..c3a389fb 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -1410,6 +1410,7 @@ class CheckoutPlatformInterfaceCodec: FlutterStandardMessageCodec { protocol CheckoutPlatformInterface { func getReturnUrl(completion: @escaping (Result) -> Void) func createSession(sessionId: String, sessionData: String, configuration: Any?, completion: @escaping (Result) -> Void) + func clearSession() throws func encryptCard(unencryptedCardDTO: UnencryptedCardDTO, publicKey: String, completion: @escaping (Result) -> Void) func encryptBin(bin: String, publicKey: String, completion: @escaping (Result) -> Void) func enableConsoleLogging(loggingEnabled: Bool) throws @@ -1455,6 +1456,19 @@ class CheckoutPlatformInterfaceSetup { } else { createSessionChannel.setMessageHandler(nil) } + let clearSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + clearSessionChannel.setMessageHandler { _, reply in + do { + try api.clearSession() + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + clearSessionChannel.setMessageHandler(nil) + } let encryptCardChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard", binaryMessenger: binaryMessenger, codec: codec) if let api = api { encryptCardChannel.setMessageHandler { message, reply in diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index fa377152..d76651a4 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -141,6 +141,9 @@ class DropInPlatformApi: DropInPlatformInterface { } + func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws { + + } func cleanUpDropIn() { sessionHolder.reset() diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index f253a5ea..b5fa400e 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -1621,6 +1621,28 @@ class CheckoutPlatformInterface { } } + Future clearSession() async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send(null) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + Future encryptCard(UnencryptedCardDTO unencryptedCardDTO, String publicKey) async { const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard'; final BasicMessageChannel __pigeon_channel = BasicMessageChannel( From 4714ba53f5907c7da78d02658c89682719510472 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Mon, 18 Nov 2024 18:06:58 +0100 Subject: [PATCH 04/21] Started with integration of partial payments for iOS --- .../models/EncodableBalance.swift | 17 +++++++++++++++++ lib/src/drop_in/drop_in.dart | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 ios/Classes/dropIn/dropInAdvancedFlow/models/EncodableBalance.swift diff --git a/ios/Classes/dropIn/dropInAdvancedFlow/models/EncodableBalance.swift b/ios/Classes/dropIn/dropInAdvancedFlow/models/EncodableBalance.swift new file mode 100644 index 00000000..2b42b834 --- /dev/null +++ b/ios/Classes/dropIn/dropInAdvancedFlow/models/EncodableBalance.swift @@ -0,0 +1,17 @@ +import Adyen +import Foundation + +extension Balance: Decodable { + + public init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let availableAmount = try container.decode(Amount.self, forKey: .availableAmount) + let transactionLimit = try container.decodeIfPresent(Amount.self, forKey: .transactionLimit) + self = .init(availableAmount: availableAmount, transactionLimit: transactionLimit) + } + + private enum CodingKeys: String, CodingKey { + case availableAmount = "balance" + case transactionLimit + } +} diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index f889b823..8ccdcb7f 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -241,6 +241,10 @@ class DropIn { final Map submitDataDecoded = jsonDecode(submitData); switch (advancedCheckout) { case AdvancedCheckout it: + if (submitDataDecoded[Constants.submitDataKey].containsKey("order")) { + _mapOrderToCompactOrder(submitDataDecoded); + } + final PaymentEvent paymentEvent = await it.onSubmit( submitDataDecoded[Constants.submitDataKey], submitDataDecoded[Constants.submitExtraKey], @@ -251,6 +255,14 @@ class DropIn { } } + void _mapOrderToCompactOrder(Map submitDataDecoded) { + final order = submitDataDecoded[Constants.submitDataKey]["order"]; + submitDataDecoded[Constants.submitDataKey]["order"] = { + "pspReference": order["pspReference"], + "orderData": order["orderData"], + }; + } + Future _getOnAdditionalDetailsPaymentEvent( PlatformCommunicationModel event, Checkout advancedCheckout) async { switch (advancedCheckout) { From 298146610779e85850b508bd1c62eb9c3a1ea31c Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 19 Nov 2024 15:09:13 +0100 Subject: [PATCH 05/21] Completed partial payments for iOS and improved error handling for API callbacks --- .../com/adyen/checkout/flutter/PlatformApi.kt | 8 +- .../flutter/dropIn/DropInPlatformApi.kt | 16 +- .../dropIn/advanced/AdvancedDropInService.kt | 128 +- .../adyen/checkout/flutter/utils/Constants.kt | 6 + example/lib/network/service.dart | 3 +- example/lib/utils/payment_event_handler.dart | 3 +- ios/Classes/PlatformApi.swift | 4111 +++++++++-------- ios/Classes/dropIn/DropInPlatformApi.swift | 96 +- ios/Classes/utils/Constants.swift | 7 + lib/src/common/adyen_checkout_session.dart | 2 +- lib/src/drop_in/drop_in.dart | 79 +- lib/src/generated/platform_api.g.dart | 597 ++- lib/src/util/constants.dart | 8 + lib/src/util/dto_mapper.dart | 43 +- lib/src/util/payment_event_handler.dart | 5 +- pigeons/platform_api.dart | 2 + test/dto_mapping_test.dart | 3 +- 17 files changed, 2722 insertions(+), 2395 deletions(-) create mode 100644 ios/Classes/utils/Constants.swift diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt index a4624e3f..340a2b85 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt @@ -315,8 +315,8 @@ data class DropInConfigurationDTO ( val skipListWhenSinglePaymentMethod: Boolean, val isRemoveStoredPaymentMethodEnabled: Boolean, val preselectedPaymentMethodTitle: String? = null, - val paymentMethodNames: Map? = null - + val paymentMethodNames: Map? = null, + val isPartialPaymentSupported: Boolean ) { companion object { @Suppress("UNCHECKED_CAST") @@ -346,7 +346,8 @@ data class DropInConfigurationDTO ( val isRemoveStoredPaymentMethodEnabled = list[12] as Boolean val preselectedPaymentMethodTitle = list[13] as String? val paymentMethodNames = list[14] as Map? - return DropInConfigurationDTO(environment, clientKey, countryCode, amount, shopperLocale, cardConfigurationDTO, applePayConfigurationDTO, googlePayConfigurationDTO, cashAppPayConfigurationDTO, analyticsOptionsDTO, showPreselectedStoredPaymentMethod, skipListWhenSinglePaymentMethod, isRemoveStoredPaymentMethodEnabled, preselectedPaymentMethodTitle, paymentMethodNames) + val isPartialPaymentSupported = list[15] as Boolean + return DropInConfigurationDTO(environment, clientKey, countryCode, amount, shopperLocale, cardConfigurationDTO, applePayConfigurationDTO, googlePayConfigurationDTO, cashAppPayConfigurationDTO, analyticsOptionsDTO, showPreselectedStoredPaymentMethod, skipListWhenSinglePaymentMethod, isRemoveStoredPaymentMethodEnabled, preselectedPaymentMethodTitle, paymentMethodNames, isPartialPaymentSupported) } } fun toList(): List { @@ -366,6 +367,7 @@ data class DropInConfigurationDTO ( isRemoveStoredPaymentMethodEnabled, preselectedPaymentMethodTitle, paymentMethodNames, + isPartialPaymentSupported, ) } } 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 5da19880..e6fb1c50 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 @@ -90,13 +90,17 @@ class DropInPlatformApi( PaymentMethodsApiResponse.SERIALIZER.deserialize( JSONObject(paymentMethodsResponse), ) - val paymentMethodsWithoutGiftCards = removeGiftCardPaymentMethods(paymentMethodsApiResponse) + val paymentMethodsWithoutGiftCards = + removeGiftCardPaymentMethods( + paymentMethodsApiResponse, + dropInConfigurationDTO.isPartialPaymentSupported + ) val dropInConfiguration = dropInConfigurationDTO.mapToDropInConfiguration(activity.applicationContext) withContext(Dispatchers.Main) { DropIn.startPayment( activity.applicationContext, dropInAdvancedFlowLauncher, - paymentMethodsApiResponse, + paymentMethodsWithoutGiftCards, dropInConfiguration, AdvancedDropInService::class.java, ) @@ -269,10 +273,14 @@ class DropInPlatformApi( ) } - // Gift cards will be supported in a later version private fun removeGiftCardPaymentMethods( - paymentMethodsResponse: PaymentMethodsApiResponse + paymentMethodsResponse: PaymentMethodsApiResponse, + isPartialPaymentSupported: Boolean ): PaymentMethodsApiResponse { + if (isPartialPaymentSupported) { + return paymentMethodsResponse + } + val giftCardTypeIdentifier = "giftcard" val storedPaymentMethods = paymentMethodsResponse.storedPaymentMethods?.filterNot { it.type == giftCardTypeIdentifier } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index 174ad61c..3ee54a3f 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -78,10 +78,10 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { shouldUpdatePaymentMethods: Boolean ) { setOrderCancelObserver() - val event = JSONObject() - event.put("order", Order.SERIALIZER.serialize(order)) - event.put("shouldUpdatePaymentMethods", shouldUpdatePaymentMethods) - DropInOrderCancelPlatformMessenger.sendResult(event) + val cancelOrderData = JSONObject() + cancelOrderData.put(Constants.ORDER_KEY, Order.SERIALIZER.serialize(order)) + cancelOrderData.put(Constants.SHOULD_UPDATE_PAYMENT_METHODS_KEY, shouldUpdatePaymentMethods) + DropInOrderCancelPlatformMessenger.sendResult(cancelOrderData) } override fun onRemoveStoredPaymentMethod(storedPaymentMethod: StoredPaymentMethod) { @@ -246,8 +246,9 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { ) } else { val updatedPaymentMethodsJSON = - JSONObject(paymentEventDTO.data["updatedPaymentMethods"] as HashMap<*, *>) - val orderResponseJSON = JSONObject(paymentEventDTO.data["orderResponse"] as HashMap<*, *>) + JSONObject(paymentEventDTO.data[Constants.UPDATED_PAYMENT_METHODS_KEY] as HashMap<*, *>) + val orderResponseJSON = + JSONObject(paymentEventDTO.data[Constants.ORDER_RESPONSE_KEY] as HashMap<*, *>) val paymentMethods = PaymentMethodsApiResponse.SERIALIZER.deserialize(updatedPaymentMethodsJSON) val orderResponse = OrderResponse.SERIALIZER.deserialize(orderResponseJSON) DropInServiceResult.Update(paymentMethods, orderResponse) @@ -272,63 +273,90 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } private fun mapToBalanceDropInServiceResult(response: String): BalanceDropInServiceResult { - if (response.isEmpty()) { - return BalanceDropInServiceResult.Error(errorDialog = null, reason = "Balance check failed") - } + try { + val jsonResponse = JSONObject(response) + return when (val resultCode = jsonResponse.optString(Constants.RESULT_CODE_KEY)) { + "Success" -> BalanceDropInServiceResult.Balance(BalanceResult.SERIALIZER.deserialize(jsonResponse)) + "NotEnoughBalance" -> + BalanceDropInServiceResult.Balance( + BalanceResult.SERIALIZER.deserialize( + jsonResponse + ) + ) - val jsonResponse = JSONObject(response) - return when (val resultCode = jsonResponse.optString("resultCode")) { - "Success" -> BalanceDropInServiceResult.Balance(BalanceResult.SERIALIZER.deserialize(jsonResponse)) - "NotEnoughBalance" -> BalanceDropInServiceResult.Balance(BalanceResult.SERIALIZER.deserialize(jsonResponse)) - else -> - BalanceDropInServiceResult.Error( - errorDialog = ErrorDialog(message = resultCode), - dismissDropIn = false, - ) + else -> + BalanceDropInServiceResult.Error( + errorDialog = + ErrorDialog( + title = resultCode, + message = jsonResponse.optString(Constants.MESSAGE_KEY) ?: "Unknown" + ), + dismissDropIn = false + ) + } + } catch (exception: Exception) { + return BalanceDropInServiceResult.Error( + errorDialog = null, + reason = "Failure parsing balance check response." + ) } } private fun mapToOrderDropInServiceResult(response: String): OrderDropInServiceResult { - if (response.isEmpty()) { - return OrderDropInServiceResult.Error(errorDialog = null, reason = "Order request failed") - } - - val jsonResponse = JSONObject(response) - return when (val resultCode = jsonResponse.optString("resultCode")) { - "Success" -> OrderDropInServiceResult.OrderCreated(OrderResponse.SERIALIZER.deserialize(jsonResponse)) - else -> - OrderDropInServiceResult.Error( - errorDialog = ErrorDialog(message = resultCode), - dismissDropIn = false, - ) + try { + val jsonResponse = JSONObject(response) + return when (val resultCode = jsonResponse.optString(Constants.RESULT_CODE_KEY)) { + "Success" -> OrderDropInServiceResult.OrderCreated(OrderResponse.SERIALIZER.deserialize(jsonResponse)) + else -> + OrderDropInServiceResult.Error( + errorDialog = + ErrorDialog( + title = resultCode, + message = jsonResponse.optString(Constants.MESSAGE_KEY) ?: "Unknown" + ), + dismissDropIn = false + ) + } + } catch (exception: Exception) { + return OrderDropInServiceResult.Error( + errorDialog = null, + reason = "Failure parsing order response." + ) } } private fun mapToOrderCancelDropInServiceResult( orderCancelResponseDTO: OrderCancelResponseDTO? ): DropInServiceResult? { - if (orderCancelResponseDTO == null || orderCancelResponseDTO.orderCancelResponseBody.isEmpty()) { - return DropInServiceResult.Error(errorDialog = null, reason = "Order cancellation failed") - } - - val orderCancelResponseBody = JSONObject(orderCancelResponseDTO.orderCancelResponseBody) - return when (val resultCode = orderCancelResponseBody.optString("resultCode")) { - "Received" -> { - if (orderCancelResponseDTO.updatedPaymentMethods?.isNotEmpty() == true) { - val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethods - val paymentMethods = - PaymentMethodsApiResponse.SERIALIZER.deserialize(JSONObject(updatedPaymentMethods)) - val orderResponse = OrderResponse.SERIALIZER.deserialize(orderCancelResponseBody) - sendResult(DropInServiceResult.Update(paymentMethods, orderResponse)) + try { + val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelResponseBody?.let { JSONObject(it) } + return when (val resultCode = orderCancelResponseBody?.optString(Constants.RESULT_CODE_KEY)) { + "Received" -> { + if (orderCancelResponseDTO.updatedPaymentMethods?.isNotEmpty() == true) { + val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethods + val paymentMethods = + PaymentMethodsApiResponse.SERIALIZER.deserialize(JSONObject(updatedPaymentMethods)) + val orderResponse = OrderResponse.SERIALIZER.deserialize(orderCancelResponseBody) + sendResult(DropInServiceResult.Update(paymentMethods, orderResponse)) + } + null } - null - } - else -> - DropInServiceResult.Error( - errorDialog = ErrorDialog(message = resultCode), - dismissDropIn = false, - ) + else -> + DropInServiceResult.Error( + errorDialog = + ErrorDialog( + title = resultCode, + message = orderCancelResponseBody?.optString(Constants.MESSAGE_KEY) ?: "Unknown" + ), + dismissDropIn = false, + ) + } + } catch (exception: Exception) { + return DropInServiceResult.Error( + errorDialog = null, + reason = "Failure parsing order cancellation response." + ) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/utils/Constants.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/utils/Constants.kt index 7f201ab8..11465b84 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/utils/Constants.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/utils/Constants.kt @@ -15,5 +15,11 @@ class Constants { const val SDK_PAYMENT_CANCELED_IDENTIFIER = "Payment canceled" const val ADVANCED_PAYMENT_DATA_KEY = "data" const val ADVANCED_EXTRA_DATA_KEY = "extra" + const val ORDER_KEY = "order" + const val ORDER_RESPONSE_KEY = "orderResponse" + const val SHOULD_UPDATE_PAYMENT_METHODS_KEY = "shouldUpdatePaymentMethods" + const val UPDATED_PAYMENT_METHODS_KEY = "updatedPaymentMethods" + const val RESULT_CODE_KEY = "resultCode" + const val MESSAGE_KEY = "message" } } diff --git a/example/lib/network/service.dart b/example/lib/network/service.dart index 0396ca11..6b71c7ed 100644 --- a/example/lib/network/service.dart +++ b/example/lib/network/service.dart @@ -94,7 +94,8 @@ class Service { return jsonDecode(response.body); } - Future> postOrdersCancel(Map body) async { + Future> postOrdersCancel( + Map body) async { final response = await http.post( Uri.https(Config.baseUrl, "/${Config.apiVersion}/orders/cancel"), headers: _createHeaders(), diff --git a/example/lib/utils/payment_event_handler.dart b/example/lib/utils/payment_event_handler.dart index bf0c71bc..d8ab70cb 100644 --- a/example/lib/utils/payment_event_handler.dart +++ b/example/lib/utils/payment_event_handler.dart @@ -68,8 +68,7 @@ class PaymentEventHandler { bool _isNonFullyPaidOrder(jsonResponse) { if (jsonResponse.containsKey("order")) { - final remainingAmount = - jsonResponse["order"]["remainingAmount"]["value"]; + final remainingAmount = jsonResponse["order"]["remainingAmount"]["value"]; return remainingAmount > 0; } else { return false; diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index c3a389fb..75950c6b 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -4,2339 +4,2384 @@ import Foundation #if os(iOS) - import Flutter + import Flutter #elseif os(macOS) - import FlutterMacOS + import FlutterMacOS #else - #error("Unsupported platform.") + #error("Unsupported platform.") #endif private func wrapResult(_ result: Any?) -> [Any?] { - return [result] + [result] } private func wrapError(_ error: Any) -> [Any?] { - if let flutterError = error as? FlutterError { + if let flutterError = error as? FlutterError { + return [ + flutterError.code, + flutterError.message, + flutterError.details + ] + } return [ - flutterError.code, - flutterError.message, - flutterError.details, + "\(error)", + "\(type(of: error))", + "Stacktrace: \(Thread.callStackSymbols)" ] - } - return [ - "\(error)", - "\(type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)", - ] } private func createConnectionError(withChannelName channelName: String) -> FlutterError { - return FlutterError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") + FlutterError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") } private func isNullish(_ value: Any?) -> Bool { - return value is NSNull || value == nil + value is NSNull || value == nil } private func nilOrValue(_ value: Any?) -> T? { - if value is NSNull { return nil } - return value as! T? + if value is NSNull { return nil } + return value as! T? } enum Environment: Int { - case test = 0 - case europe = 1 - case unitedStates = 2 - case australia = 3 - case india = 4 - case apse = 5 + case test = 0 + case europe = 1 + case unitedStates = 2 + case australia = 3 + case india = 4 + case apse = 5 } enum AddressMode: Int { - case full = 0 - case postalCode = 1 - case none = 2 + case full = 0 + case postalCode = 1 + case none = 2 } enum CardAuthMethod: Int { - case panOnly = 0 - case cryptogram3DS = 1 + case panOnly = 0 + case cryptogram3DS = 1 } enum TotalPriceStatus: Int { - case notCurrentlyKnown = 0 - case estimated = 1 - case finalPrice = 2 + case notCurrentlyKnown = 0 + case estimated = 1 + case finalPrice = 2 } enum GooglePayEnvironment: Int { - case test = 0 - case production = 1 + case test = 0 + case production = 1 } enum CashAppPayEnvironment: Int { - case sandbox = 0 - case production = 1 + case sandbox = 0 + case production = 1 } enum PaymentResultEnum: Int { - case cancelledByUser = 0 - case error = 1 - case finished = 2 + case cancelledByUser = 0 + case error = 1 + case finished = 2 } enum PlatformCommunicationType: Int { - case paymentComponent = 0 - case additionalDetails = 1 - case result = 2 - case deleteStoredPaymentMethod = 3 - case balanceCheck = 4 - case requestOrder = 5 - case cancelOrder = 6 + case paymentComponent = 0 + case additionalDetails = 1 + case result = 2 + case deleteStoredPaymentMethod = 3 + case balanceCheck = 4 + case requestOrder = 5 + case cancelOrder = 6 } enum ComponentCommunicationType: Int { - case onSubmit = 0 - case additionalDetails = 1 - case loading = 2 - case result = 3 - case resize = 4 + case onSubmit = 0 + case additionalDetails = 1 + case loading = 2 + case result = 3 + case resize = 4 } enum PaymentEventType: Int { - case finished = 0 - case action = 1 - case error = 2 - case update = 3 + case finished = 0 + case action = 1 + case error = 2 + case update = 3 } enum FieldVisibility: Int { - case show = 0 - case hide = 1 + case show = 0 + case hide = 1 } enum InstantPaymentType: Int { - case googlePay = 0 - case applePay = 1 - case instant = 2 + case googlePay = 0 + case applePay = 1 + case instant = 2 } enum ApplePayShippingType: Int { - case shipping = 0 - case delivery = 1 - case storePickup = 2 - case servicePickup = 3 + case shipping = 0 + case delivery = 1 + case storePickup = 2 + case servicePickup = 3 } enum ApplePayMerchantCapability: Int { - case debit = 0 - case credit = 1 + case debit = 0 + case credit = 1 } enum ApplePaySummaryItemType: Int { - case pending = 0 - case definite = 1 + case pending = 0 + case definite = 1 } /// Generated class from Pigeon that represents data sent in messages. struct SessionDTO { - var id: String - var sessionData: String - var paymentMethodsJson: String - - static func fromList(_ list: [Any?]) -> SessionDTO? { - let id = list[0] as! String - let sessionData = list[1] as! String - let paymentMethodsJson = list[2] as! String - - return SessionDTO( - id: id, - sessionData: sessionData, - paymentMethodsJson: paymentMethodsJson - ) - } - func toList() -> [Any?] { - return [ - id, - sessionData, - paymentMethodsJson, - ] - } + var id: String + var sessionData: String + var paymentMethodsJson: String + + static func fromList(_ list: [Any?]) -> SessionDTO? { + let id = list[0] as! String + let sessionData = list[1] as! String + let paymentMethodsJson = list[2] as! String + + return SessionDTO( + id: id, + sessionData: sessionData, + paymentMethodsJson: paymentMethodsJson + ) + } + + func toList() -> [Any?] { + [ + id, + sessionData, + paymentMethodsJson + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct AmountDTO { - var currency: String - var value: Int64 - - static func fromList(_ list: [Any?]) -> AmountDTO? { - let currency = list[0] as! String - let value = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) - - return AmountDTO( - currency: currency, - value: value - ) - } - func toList() -> [Any?] { - return [ - currency, - value, - ] - } + var currency: String + var value: Int64 + + static func fromList(_ list: [Any?]) -> AmountDTO? { + let currency = list[0] as! String + let value = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) + + return AmountDTO( + currency: currency, + value: value + ) + } + + func toList() -> [Any?] { + [ + currency, + value + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct AnalyticsOptionsDTO { - var enabled: Bool - var version: String - - static func fromList(_ list: [Any?]) -> AnalyticsOptionsDTO? { - let enabled = list[0] as! Bool - let version = list[1] as! String - - return AnalyticsOptionsDTO( - enabled: enabled, - version: version - ) - } - func toList() -> [Any?] { - return [ - enabled, - version, - ] - } + var enabled: Bool + var version: String + + static func fromList(_ list: [Any?]) -> AnalyticsOptionsDTO? { + let enabled = list[0] as! Bool + let version = list[1] as! String + + return AnalyticsOptionsDTO( + enabled: enabled, + version: version + ) + } + + func toList() -> [Any?] { + [ + enabled, + version + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct DropInConfigurationDTO { - var environment: Environment - var clientKey: String - var countryCode: String - var amount: AmountDTO? = nil - var shopperLocale: String? = nil - var cardConfigurationDTO: CardConfigurationDTO? = nil - var applePayConfigurationDTO: ApplePayConfigurationDTO? = nil - var googlePayConfigurationDTO: GooglePayConfigurationDTO? = nil - var cashAppPayConfigurationDTO: CashAppPayConfigurationDTO? = nil - var analyticsOptionsDTO: AnalyticsOptionsDTO - var showPreselectedStoredPaymentMethod: Bool - var skipListWhenSinglePaymentMethod: Bool - var isRemoveStoredPaymentMethodEnabled: Bool - var preselectedPaymentMethodTitle: String? = nil - var paymentMethodNames: [String?: String?]? = nil - - static func fromList(_ list: [Any?]) -> DropInConfigurationDTO? { - let environment = Environment(rawValue: list[0] as! Int)! - let clientKey = list[1] as! String - let countryCode = list[2] as! String - var amount: AmountDTO? = nil - if let amountList: [Any?] = nilOrValue(list[3]) { - amount = AmountDTO.fromList(amountList) - } - let shopperLocale: String? = nilOrValue(list[4]) - var cardConfigurationDTO: CardConfigurationDTO? = nil - if let cardConfigurationDTOList: [Any?] = nilOrValue(list[5]) { - cardConfigurationDTO = CardConfigurationDTO.fromList(cardConfigurationDTOList) - } - var applePayConfigurationDTO: ApplePayConfigurationDTO? = nil - if let applePayConfigurationDTOList: [Any?] = nilOrValue(list[6]) { - applePayConfigurationDTO = ApplePayConfigurationDTO.fromList(applePayConfigurationDTOList) - } - var googlePayConfigurationDTO: GooglePayConfigurationDTO? = nil - if let googlePayConfigurationDTOList: [Any?] = nilOrValue(list[7]) { - googlePayConfigurationDTO = GooglePayConfigurationDTO.fromList(googlePayConfigurationDTOList) - } - var cashAppPayConfigurationDTO: CashAppPayConfigurationDTO? = nil - if let cashAppPayConfigurationDTOList: [Any?] = nilOrValue(list[8]) { - cashAppPayConfigurationDTO = CashAppPayConfigurationDTO.fromList(cashAppPayConfigurationDTOList) - } - let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[9] as! [Any?])! - let showPreselectedStoredPaymentMethod = list[10] as! Bool - let skipListWhenSinglePaymentMethod = list[11] as! Bool - let isRemoveStoredPaymentMethodEnabled = list[12] as! Bool - let preselectedPaymentMethodTitle: String? = nilOrValue(list[13]) - let paymentMethodNames: [String?: String?]? = nilOrValue(list[14]) - - return DropInConfigurationDTO( - environment: environment, - clientKey: clientKey, - countryCode: countryCode, - amount: amount, - shopperLocale: shopperLocale, - cardConfigurationDTO: cardConfigurationDTO, - applePayConfigurationDTO: applePayConfigurationDTO, - googlePayConfigurationDTO: googlePayConfigurationDTO, - cashAppPayConfigurationDTO: cashAppPayConfigurationDTO, - analyticsOptionsDTO: analyticsOptionsDTO, - showPreselectedStoredPaymentMethod: showPreselectedStoredPaymentMethod, - skipListWhenSinglePaymentMethod: skipListWhenSinglePaymentMethod, - isRemoveStoredPaymentMethodEnabled: isRemoveStoredPaymentMethodEnabled, - preselectedPaymentMethodTitle: preselectedPaymentMethodTitle, - paymentMethodNames: paymentMethodNames - ) - } - func toList() -> [Any?] { - return [ - environment.rawValue, - clientKey, - countryCode, - amount?.toList(), - shopperLocale, - cardConfigurationDTO?.toList(), - applePayConfigurationDTO?.toList(), - googlePayConfigurationDTO?.toList(), - cashAppPayConfigurationDTO?.toList(), - analyticsOptionsDTO.toList(), - showPreselectedStoredPaymentMethod, - skipListWhenSinglePaymentMethod, - isRemoveStoredPaymentMethodEnabled, - preselectedPaymentMethodTitle, - paymentMethodNames, - ] - } + var environment: Environment + var clientKey: String + var countryCode: String + var amount: AmountDTO? + var shopperLocale: String? + var cardConfigurationDTO: CardConfigurationDTO? + var applePayConfigurationDTO: ApplePayConfigurationDTO? + var googlePayConfigurationDTO: GooglePayConfigurationDTO? + var cashAppPayConfigurationDTO: CashAppPayConfigurationDTO? + var analyticsOptionsDTO: AnalyticsOptionsDTO + var showPreselectedStoredPaymentMethod: Bool + var skipListWhenSinglePaymentMethod: Bool + var isRemoveStoredPaymentMethodEnabled: Bool + var preselectedPaymentMethodTitle: String? + var paymentMethodNames: [String?: String?]? + var isPartialPaymentSupported: Bool + + static func fromList(_ list: [Any?]) -> DropInConfigurationDTO? { + let environment = Environment(rawValue: list[0] as! Int)! + let clientKey = list[1] as! String + let countryCode = list[2] as! String + var amount: AmountDTO? + if let amountList: [Any?] = nilOrValue(list[3]) { + amount = AmountDTO.fromList(amountList) + } + let shopperLocale: String? = nilOrValue(list[4]) + var cardConfigurationDTO: CardConfigurationDTO? + if let cardConfigurationDTOList: [Any?] = nilOrValue(list[5]) { + cardConfigurationDTO = CardConfigurationDTO.fromList(cardConfigurationDTOList) + } + var applePayConfigurationDTO: ApplePayConfigurationDTO? + if let applePayConfigurationDTOList: [Any?] = nilOrValue(list[6]) { + applePayConfigurationDTO = ApplePayConfigurationDTO.fromList(applePayConfigurationDTOList) + } + var googlePayConfigurationDTO: GooglePayConfigurationDTO? + if let googlePayConfigurationDTOList: [Any?] = nilOrValue(list[7]) { + googlePayConfigurationDTO = GooglePayConfigurationDTO.fromList(googlePayConfigurationDTOList) + } + var cashAppPayConfigurationDTO: CashAppPayConfigurationDTO? + if let cashAppPayConfigurationDTOList: [Any?] = nilOrValue(list[8]) { + cashAppPayConfigurationDTO = CashAppPayConfigurationDTO.fromList(cashAppPayConfigurationDTOList) + } + let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[9] as! [Any?])! + let showPreselectedStoredPaymentMethod = list[10] as! Bool + let skipListWhenSinglePaymentMethod = list[11] as! Bool + let isRemoveStoredPaymentMethodEnabled = list[12] as! Bool + let preselectedPaymentMethodTitle: String? = nilOrValue(list[13]) + let paymentMethodNames: [String?: String?]? = nilOrValue(list[14]) + let isPartialPaymentSupported = list[15] as! Bool + + return DropInConfigurationDTO( + environment: environment, + clientKey: clientKey, + countryCode: countryCode, + amount: amount, + shopperLocale: shopperLocale, + cardConfigurationDTO: cardConfigurationDTO, + applePayConfigurationDTO: applePayConfigurationDTO, + googlePayConfigurationDTO: googlePayConfigurationDTO, + cashAppPayConfigurationDTO: cashAppPayConfigurationDTO, + analyticsOptionsDTO: analyticsOptionsDTO, + showPreselectedStoredPaymentMethod: showPreselectedStoredPaymentMethod, + skipListWhenSinglePaymentMethod: skipListWhenSinglePaymentMethod, + isRemoveStoredPaymentMethodEnabled: isRemoveStoredPaymentMethodEnabled, + preselectedPaymentMethodTitle: preselectedPaymentMethodTitle, + paymentMethodNames: paymentMethodNames, + isPartialPaymentSupported: isPartialPaymentSupported + ) + } + + func toList() -> [Any?] { + [ + environment.rawValue, + clientKey, + countryCode, + amount?.toList(), + shopperLocale, + cardConfigurationDTO?.toList(), + applePayConfigurationDTO?.toList(), + googlePayConfigurationDTO?.toList(), + cashAppPayConfigurationDTO?.toList(), + analyticsOptionsDTO.toList(), + showPreselectedStoredPaymentMethod, + skipListWhenSinglePaymentMethod, + isRemoveStoredPaymentMethodEnabled, + preselectedPaymentMethodTitle, + paymentMethodNames, + isPartialPaymentSupported + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct CardConfigurationDTO { - var holderNameRequired: Bool - var addressMode: AddressMode - var showStorePaymentField: Bool - var showCvcForStoredCard: Bool - var showCvc: Bool - var kcpFieldVisibility: FieldVisibility - var socialSecurityNumberFieldVisibility: FieldVisibility - var supportedCardTypes: [String?] - - static func fromList(_ list: [Any?]) -> CardConfigurationDTO? { - let holderNameRequired = list[0] as! Bool - let addressMode = AddressMode(rawValue: list[1] as! Int)! - let showStorePaymentField = list[2] as! Bool - let showCvcForStoredCard = list[3] as! Bool - let showCvc = list[4] as! Bool - let kcpFieldVisibility = FieldVisibility(rawValue: list[5] as! Int)! - let socialSecurityNumberFieldVisibility = FieldVisibility(rawValue: list[6] as! Int)! - let supportedCardTypes = list[7] as! [String?] - - return CardConfigurationDTO( - holderNameRequired: holderNameRequired, - addressMode: addressMode, - showStorePaymentField: showStorePaymentField, - showCvcForStoredCard: showCvcForStoredCard, - showCvc: showCvc, - kcpFieldVisibility: kcpFieldVisibility, - socialSecurityNumberFieldVisibility: socialSecurityNumberFieldVisibility, - supportedCardTypes: supportedCardTypes - ) - } - func toList() -> [Any?] { - return [ - holderNameRequired, - addressMode.rawValue, - showStorePaymentField, - showCvcForStoredCard, - showCvc, - kcpFieldVisibility.rawValue, - socialSecurityNumberFieldVisibility.rawValue, - supportedCardTypes, - ] - } + var holderNameRequired: Bool + var addressMode: AddressMode + var showStorePaymentField: Bool + var showCvcForStoredCard: Bool + var showCvc: Bool + var kcpFieldVisibility: FieldVisibility + var socialSecurityNumberFieldVisibility: FieldVisibility + var supportedCardTypes: [String?] + + static func fromList(_ list: [Any?]) -> CardConfigurationDTO? { + let holderNameRequired = list[0] as! Bool + let addressMode = AddressMode(rawValue: list[1] as! Int)! + let showStorePaymentField = list[2] as! Bool + let showCvcForStoredCard = list[3] as! Bool + let showCvc = list[4] as! Bool + let kcpFieldVisibility = FieldVisibility(rawValue: list[5] as! Int)! + let socialSecurityNumberFieldVisibility = FieldVisibility(rawValue: list[6] as! Int)! + let supportedCardTypes = list[7] as! [String?] + + return CardConfigurationDTO( + holderNameRequired: holderNameRequired, + addressMode: addressMode, + showStorePaymentField: showStorePaymentField, + showCvcForStoredCard: showCvcForStoredCard, + showCvc: showCvc, + kcpFieldVisibility: kcpFieldVisibility, + socialSecurityNumberFieldVisibility: socialSecurityNumberFieldVisibility, + supportedCardTypes: supportedCardTypes + ) + } + + func toList() -> [Any?] { + [ + holderNameRequired, + addressMode.rawValue, + showStorePaymentField, + showCvcForStoredCard, + showCvc, + kcpFieldVisibility.rawValue, + socialSecurityNumberFieldVisibility.rawValue, + supportedCardTypes + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ApplePayConfigurationDTO { - var merchantId: String - var merchantName: String - var allowOnboarding: Bool? = nil - var summaryItems: [ApplePaySummaryItemDTO?]? = nil - var requiredBillingContactFields: [String?]? = nil - var billingContact: ApplePayContactDTO? = nil - var requiredShippingContactFields: [String?]? = nil - var shippingContact: ApplePayContactDTO? = nil - var applePayShippingType: ApplePayShippingType? = nil - var allowShippingContactEditing: Bool? = nil - var shippingMethods: [ApplePayShippingMethodDTO?]? = nil - var applicationData: String? = nil - var supportedCountries: [String?]? = nil - var merchantCapability: ApplePayMerchantCapability? = nil - - static func fromList(_ list: [Any?]) -> ApplePayConfigurationDTO? { - let merchantId = list[0] as! String - let merchantName = list[1] as! String - let allowOnboarding: Bool? = nilOrValue(list[2]) - let summaryItems: [ApplePaySummaryItemDTO?]? = nilOrValue(list[3]) - let requiredBillingContactFields: [String?]? = nilOrValue(list[4]) - var billingContact: ApplePayContactDTO? = nil - if let billingContactList: [Any?] = nilOrValue(list[5]) { - billingContact = ApplePayContactDTO.fromList(billingContactList) - } - let requiredShippingContactFields: [String?]? = nilOrValue(list[6]) - var shippingContact: ApplePayContactDTO? = nil - if let shippingContactList: [Any?] = nilOrValue(list[7]) { - shippingContact = ApplePayContactDTO.fromList(shippingContactList) - } - var applePayShippingType: ApplePayShippingType? = nil - let applePayShippingTypeEnumVal: Int? = nilOrValue(list[8]) - if let applePayShippingTypeRawValue = applePayShippingTypeEnumVal { - applePayShippingType = ApplePayShippingType(rawValue: applePayShippingTypeRawValue)! - } - let allowShippingContactEditing: Bool? = nilOrValue(list[9]) - let shippingMethods: [ApplePayShippingMethodDTO?]? = nilOrValue(list[10]) - let applicationData: String? = nilOrValue(list[11]) - let supportedCountries: [String?]? = nilOrValue(list[12]) - var merchantCapability: ApplePayMerchantCapability? = nil - let merchantCapabilityEnumVal: Int? = nilOrValue(list[13]) - if let merchantCapabilityRawValue = merchantCapabilityEnumVal { - merchantCapability = ApplePayMerchantCapability(rawValue: merchantCapabilityRawValue)! - } - - return ApplePayConfigurationDTO( - merchantId: merchantId, - merchantName: merchantName, - allowOnboarding: allowOnboarding, - summaryItems: summaryItems, - requiredBillingContactFields: requiredBillingContactFields, - billingContact: billingContact, - requiredShippingContactFields: requiredShippingContactFields, - shippingContact: shippingContact, - applePayShippingType: applePayShippingType, - allowShippingContactEditing: allowShippingContactEditing, - shippingMethods: shippingMethods, - applicationData: applicationData, - supportedCountries: supportedCountries, - merchantCapability: merchantCapability - ) - } - func toList() -> [Any?] { - return [ - merchantId, - merchantName, - allowOnboarding, - summaryItems, - requiredBillingContactFields, - billingContact?.toList(), - requiredShippingContactFields, - shippingContact?.toList(), - applePayShippingType?.rawValue, - allowShippingContactEditing, - shippingMethods, - applicationData, - supportedCountries, - merchantCapability?.rawValue, - ] - } + var merchantId: String + var merchantName: String + var allowOnboarding: Bool? + var summaryItems: [ApplePaySummaryItemDTO?]? + var requiredBillingContactFields: [String?]? + var billingContact: ApplePayContactDTO? + var requiredShippingContactFields: [String?]? + var shippingContact: ApplePayContactDTO? + var applePayShippingType: ApplePayShippingType? + var allowShippingContactEditing: Bool? + var shippingMethods: [ApplePayShippingMethodDTO?]? + var applicationData: String? + var supportedCountries: [String?]? + var merchantCapability: ApplePayMerchantCapability? + + static func fromList(_ list: [Any?]) -> ApplePayConfigurationDTO? { + let merchantId = list[0] as! String + let merchantName = list[1] as! String + let allowOnboarding: Bool? = nilOrValue(list[2]) + let summaryItems: [ApplePaySummaryItemDTO?]? = nilOrValue(list[3]) + let requiredBillingContactFields: [String?]? = nilOrValue(list[4]) + var billingContact: ApplePayContactDTO? + if let billingContactList: [Any?] = nilOrValue(list[5]) { + billingContact = ApplePayContactDTO.fromList(billingContactList) + } + let requiredShippingContactFields: [String?]? = nilOrValue(list[6]) + var shippingContact: ApplePayContactDTO? + if let shippingContactList: [Any?] = nilOrValue(list[7]) { + shippingContact = ApplePayContactDTO.fromList(shippingContactList) + } + var applePayShippingType: ApplePayShippingType? + let applePayShippingTypeEnumVal: Int? = nilOrValue(list[8]) + if let applePayShippingTypeRawValue = applePayShippingTypeEnumVal { + applePayShippingType = ApplePayShippingType(rawValue: applePayShippingTypeRawValue)! + } + let allowShippingContactEditing: Bool? = nilOrValue(list[9]) + let shippingMethods: [ApplePayShippingMethodDTO?]? = nilOrValue(list[10]) + let applicationData: String? = nilOrValue(list[11]) + let supportedCountries: [String?]? = nilOrValue(list[12]) + var merchantCapability: ApplePayMerchantCapability? + let merchantCapabilityEnumVal: Int? = nilOrValue(list[13]) + if let merchantCapabilityRawValue = merchantCapabilityEnumVal { + merchantCapability = ApplePayMerchantCapability(rawValue: merchantCapabilityRawValue)! + } + + return ApplePayConfigurationDTO( + merchantId: merchantId, + merchantName: merchantName, + allowOnboarding: allowOnboarding, + summaryItems: summaryItems, + requiredBillingContactFields: requiredBillingContactFields, + billingContact: billingContact, + requiredShippingContactFields: requiredShippingContactFields, + shippingContact: shippingContact, + applePayShippingType: applePayShippingType, + allowShippingContactEditing: allowShippingContactEditing, + shippingMethods: shippingMethods, + applicationData: applicationData, + supportedCountries: supportedCountries, + merchantCapability: merchantCapability + ) + } + + func toList() -> [Any?] { + [ + merchantId, + merchantName, + allowOnboarding, + summaryItems, + requiredBillingContactFields, + billingContact?.toList(), + requiredShippingContactFields, + shippingContact?.toList(), + applePayShippingType?.rawValue, + allowShippingContactEditing, + shippingMethods, + applicationData, + supportedCountries, + merchantCapability?.rawValue + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ApplePayContactDTO { - var phoneNumber: String? = nil - var emailAddress: String? = nil - var givenName: String? = nil - var familyName: String? = nil - var phoneticGivenName: String? = nil - var phoneticFamilyName: String? = nil - var addressLines: [String?]? = nil - var subLocality: String? = nil - var city: String? = nil - var postalCode: String? = nil - var subAdministrativeArea: String? = nil - var administrativeArea: String? = nil - var country: String? = nil - var countryCode: String? = nil - - static func fromList(_ list: [Any?]) -> ApplePayContactDTO? { - let phoneNumber: String? = nilOrValue(list[0]) - let emailAddress: String? = nilOrValue(list[1]) - let givenName: String? = nilOrValue(list[2]) - let familyName: String? = nilOrValue(list[3]) - let phoneticGivenName: String? = nilOrValue(list[4]) - let phoneticFamilyName: String? = nilOrValue(list[5]) - let addressLines: [String?]? = nilOrValue(list[6]) - let subLocality: String? = nilOrValue(list[7]) - let city: String? = nilOrValue(list[8]) - let postalCode: String? = nilOrValue(list[9]) - let subAdministrativeArea: String? = nilOrValue(list[10]) - let administrativeArea: String? = nilOrValue(list[11]) - let country: String? = nilOrValue(list[12]) - let countryCode: String? = nilOrValue(list[13]) - - return ApplePayContactDTO( - phoneNumber: phoneNumber, - emailAddress: emailAddress, - givenName: givenName, - familyName: familyName, - phoneticGivenName: phoneticGivenName, - phoneticFamilyName: phoneticFamilyName, - addressLines: addressLines, - subLocality: subLocality, - city: city, - postalCode: postalCode, - subAdministrativeArea: subAdministrativeArea, - administrativeArea: administrativeArea, - country: country, - countryCode: countryCode - ) - } - func toList() -> [Any?] { - return [ - phoneNumber, - emailAddress, - givenName, - familyName, - phoneticGivenName, - phoneticFamilyName, - addressLines, - subLocality, - city, - postalCode, - subAdministrativeArea, - administrativeArea, - country, - countryCode, - ] - } + var phoneNumber: String? + var emailAddress: String? + var givenName: String? + var familyName: String? + var phoneticGivenName: String? + var phoneticFamilyName: String? + var addressLines: [String?]? + var subLocality: String? + var city: String? + var postalCode: String? + var subAdministrativeArea: String? + var administrativeArea: String? + var country: String? + var countryCode: String? + + static func fromList(_ list: [Any?]) -> ApplePayContactDTO? { + let phoneNumber: String? = nilOrValue(list[0]) + let emailAddress: String? = nilOrValue(list[1]) + let givenName: String? = nilOrValue(list[2]) + let familyName: String? = nilOrValue(list[3]) + let phoneticGivenName: String? = nilOrValue(list[4]) + let phoneticFamilyName: String? = nilOrValue(list[5]) + let addressLines: [String?]? = nilOrValue(list[6]) + let subLocality: String? = nilOrValue(list[7]) + let city: String? = nilOrValue(list[8]) + let postalCode: String? = nilOrValue(list[9]) + let subAdministrativeArea: String? = nilOrValue(list[10]) + let administrativeArea: String? = nilOrValue(list[11]) + let country: String? = nilOrValue(list[12]) + let countryCode: String? = nilOrValue(list[13]) + + return ApplePayContactDTO( + phoneNumber: phoneNumber, + emailAddress: emailAddress, + givenName: givenName, + familyName: familyName, + phoneticGivenName: phoneticGivenName, + phoneticFamilyName: phoneticFamilyName, + addressLines: addressLines, + subLocality: subLocality, + city: city, + postalCode: postalCode, + subAdministrativeArea: subAdministrativeArea, + administrativeArea: administrativeArea, + country: country, + countryCode: countryCode + ) + } + + func toList() -> [Any?] { + [ + phoneNumber, + emailAddress, + givenName, + familyName, + phoneticGivenName, + phoneticFamilyName, + addressLines, + subLocality, + city, + postalCode, + subAdministrativeArea, + administrativeArea, + country, + countryCode + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ApplePayShippingMethodDTO { - var label: String - var detail: String - var amount: AmountDTO - var identifier: String - var startDate: String? = nil - var endDate: String? = nil - - static func fromList(_ list: [Any?]) -> ApplePayShippingMethodDTO? { - let label = list[0] as! String - let detail = list[1] as! String - let amount = AmountDTO.fromList(list[2] as! [Any?])! - let identifier = list[3] as! String - let startDate: String? = nilOrValue(list[4]) - let endDate: String? = nilOrValue(list[5]) - - return ApplePayShippingMethodDTO( - label: label, - detail: detail, - amount: amount, - identifier: identifier, - startDate: startDate, - endDate: endDate - ) - } - func toList() -> [Any?] { - return [ - label, - detail, - amount.toList(), - identifier, - startDate, - endDate, - ] - } + var label: String + var detail: String + var amount: AmountDTO + var identifier: String + var startDate: String? + var endDate: String? + + static func fromList(_ list: [Any?]) -> ApplePayShippingMethodDTO? { + let label = list[0] as! String + let detail = list[1] as! String + let amount = AmountDTO.fromList(list[2] as! [Any?])! + let identifier = list[3] as! String + let startDate: String? = nilOrValue(list[4]) + let endDate: String? = nilOrValue(list[5]) + + return ApplePayShippingMethodDTO( + label: label, + detail: detail, + amount: amount, + identifier: identifier, + startDate: startDate, + endDate: endDate + ) + } + + func toList() -> [Any?] { + [ + label, + detail, + amount.toList(), + identifier, + startDate, + endDate + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ApplePaySummaryItemDTO { - var label: String - var amount: AmountDTO - var type: ApplePaySummaryItemType - - static func fromList(_ list: [Any?]) -> ApplePaySummaryItemDTO? { - let label = list[0] as! String - let amount = AmountDTO.fromList(list[1] as! [Any?])! - let type = ApplePaySummaryItemType(rawValue: list[2] as! Int)! - - return ApplePaySummaryItemDTO( - label: label, - amount: amount, - type: type - ) - } - func toList() -> [Any?] { - return [ - label, - amount.toList(), - type.rawValue, - ] - } + var label: String + var amount: AmountDTO + var type: ApplePaySummaryItemType + + static func fromList(_ list: [Any?]) -> ApplePaySummaryItemDTO? { + let label = list[0] as! String + let amount = AmountDTO.fromList(list[1] as! [Any?])! + let type = ApplePaySummaryItemType(rawValue: list[2] as! Int)! + + return ApplePaySummaryItemDTO( + label: label, + amount: amount, + type: type + ) + } + + func toList() -> [Any?] { + [ + label, + amount.toList(), + type.rawValue + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct GooglePayConfigurationDTO { - var googlePayEnvironment: GooglePayEnvironment - var merchantAccount: String? = nil - var merchantInfoDTO: MerchantInfoDTO? = nil - var totalPriceStatus: TotalPriceStatus? = nil - var allowedCardNetworks: [String?]? = nil - var allowedAuthMethods: [String?]? = nil - var allowPrepaidCards: Bool? = nil - var allowCreditCards: Bool? = nil - var assuranceDetailsRequired: Bool? = nil - var emailRequired: Bool? = nil - var existingPaymentMethodRequired: Bool? = nil - var shippingAddressRequired: Bool? = nil - var shippingAddressParametersDTO: ShippingAddressParametersDTO? = nil - var billingAddressRequired: Bool? = nil - var billingAddressParametersDTO: BillingAddressParametersDTO? = nil - - static func fromList(_ list: [Any?]) -> GooglePayConfigurationDTO? { - let googlePayEnvironment = GooglePayEnvironment(rawValue: list[0] as! Int)! - let merchantAccount: String? = nilOrValue(list[1]) - var merchantInfoDTO: MerchantInfoDTO? = nil - if let merchantInfoDTOList: [Any?] = nilOrValue(list[2]) { - merchantInfoDTO = MerchantInfoDTO.fromList(merchantInfoDTOList) - } - var totalPriceStatus: TotalPriceStatus? = nil - let totalPriceStatusEnumVal: Int? = nilOrValue(list[3]) - if let totalPriceStatusRawValue = totalPriceStatusEnumVal { - totalPriceStatus = TotalPriceStatus(rawValue: totalPriceStatusRawValue)! - } - let allowedCardNetworks: [String?]? = nilOrValue(list[4]) - let allowedAuthMethods: [String?]? = nilOrValue(list[5]) - let allowPrepaidCards: Bool? = nilOrValue(list[6]) - let allowCreditCards: Bool? = nilOrValue(list[7]) - let assuranceDetailsRequired: Bool? = nilOrValue(list[8]) - let emailRequired: Bool? = nilOrValue(list[9]) - let existingPaymentMethodRequired: Bool? = nilOrValue(list[10]) - let shippingAddressRequired: Bool? = nilOrValue(list[11]) - var shippingAddressParametersDTO: ShippingAddressParametersDTO? = nil - if let shippingAddressParametersDTOList: [Any?] = nilOrValue(list[12]) { - shippingAddressParametersDTO = ShippingAddressParametersDTO.fromList(shippingAddressParametersDTOList) - } - let billingAddressRequired: Bool? = nilOrValue(list[13]) - var billingAddressParametersDTO: BillingAddressParametersDTO? = nil - if let billingAddressParametersDTOList: [Any?] = nilOrValue(list[14]) { - billingAddressParametersDTO = BillingAddressParametersDTO.fromList(billingAddressParametersDTOList) - } - - return GooglePayConfigurationDTO( - googlePayEnvironment: googlePayEnvironment, - merchantAccount: merchantAccount, - merchantInfoDTO: merchantInfoDTO, - totalPriceStatus: totalPriceStatus, - allowedCardNetworks: allowedCardNetworks, - allowedAuthMethods: allowedAuthMethods, - allowPrepaidCards: allowPrepaidCards, - allowCreditCards: allowCreditCards, - assuranceDetailsRequired: assuranceDetailsRequired, - emailRequired: emailRequired, - existingPaymentMethodRequired: existingPaymentMethodRequired, - shippingAddressRequired: shippingAddressRequired, - shippingAddressParametersDTO: shippingAddressParametersDTO, - billingAddressRequired: billingAddressRequired, - billingAddressParametersDTO: billingAddressParametersDTO - ) - } - func toList() -> [Any?] { - return [ - googlePayEnvironment.rawValue, - merchantAccount, - merchantInfoDTO?.toList(), - totalPriceStatus?.rawValue, - allowedCardNetworks, - allowedAuthMethods, - allowPrepaidCards, - allowCreditCards, - assuranceDetailsRequired, - emailRequired, - existingPaymentMethodRequired, - shippingAddressRequired, - shippingAddressParametersDTO?.toList(), - billingAddressRequired, - billingAddressParametersDTO?.toList(), - ] - } + var googlePayEnvironment: GooglePayEnvironment + var merchantAccount: String? + var merchantInfoDTO: MerchantInfoDTO? + var totalPriceStatus: TotalPriceStatus? + var allowedCardNetworks: [String?]? + var allowedAuthMethods: [String?]? + var allowPrepaidCards: Bool? + var allowCreditCards: Bool? + var assuranceDetailsRequired: Bool? + var emailRequired: Bool? + var existingPaymentMethodRequired: Bool? + var shippingAddressRequired: Bool? + var shippingAddressParametersDTO: ShippingAddressParametersDTO? + var billingAddressRequired: Bool? + var billingAddressParametersDTO: BillingAddressParametersDTO? + + static func fromList(_ list: [Any?]) -> GooglePayConfigurationDTO? { + let googlePayEnvironment = GooglePayEnvironment(rawValue: list[0] as! Int)! + let merchantAccount: String? = nilOrValue(list[1]) + var merchantInfoDTO: MerchantInfoDTO? + if let merchantInfoDTOList: [Any?] = nilOrValue(list[2]) { + merchantInfoDTO = MerchantInfoDTO.fromList(merchantInfoDTOList) + } + var totalPriceStatus: TotalPriceStatus? + let totalPriceStatusEnumVal: Int? = nilOrValue(list[3]) + if let totalPriceStatusRawValue = totalPriceStatusEnumVal { + totalPriceStatus = TotalPriceStatus(rawValue: totalPriceStatusRawValue)! + } + let allowedCardNetworks: [String?]? = nilOrValue(list[4]) + let allowedAuthMethods: [String?]? = nilOrValue(list[5]) + let allowPrepaidCards: Bool? = nilOrValue(list[6]) + let allowCreditCards: Bool? = nilOrValue(list[7]) + let assuranceDetailsRequired: Bool? = nilOrValue(list[8]) + let emailRequired: Bool? = nilOrValue(list[9]) + let existingPaymentMethodRequired: Bool? = nilOrValue(list[10]) + let shippingAddressRequired: Bool? = nilOrValue(list[11]) + var shippingAddressParametersDTO: ShippingAddressParametersDTO? + if let shippingAddressParametersDTOList: [Any?] = nilOrValue(list[12]) { + shippingAddressParametersDTO = ShippingAddressParametersDTO.fromList(shippingAddressParametersDTOList) + } + let billingAddressRequired: Bool? = nilOrValue(list[13]) + var billingAddressParametersDTO: BillingAddressParametersDTO? + if let billingAddressParametersDTOList: [Any?] = nilOrValue(list[14]) { + billingAddressParametersDTO = BillingAddressParametersDTO.fromList(billingAddressParametersDTOList) + } + + return GooglePayConfigurationDTO( + googlePayEnvironment: googlePayEnvironment, + merchantAccount: merchantAccount, + merchantInfoDTO: merchantInfoDTO, + totalPriceStatus: totalPriceStatus, + allowedCardNetworks: allowedCardNetworks, + allowedAuthMethods: allowedAuthMethods, + allowPrepaidCards: allowPrepaidCards, + allowCreditCards: allowCreditCards, + assuranceDetailsRequired: assuranceDetailsRequired, + emailRequired: emailRequired, + existingPaymentMethodRequired: existingPaymentMethodRequired, + shippingAddressRequired: shippingAddressRequired, + shippingAddressParametersDTO: shippingAddressParametersDTO, + billingAddressRequired: billingAddressRequired, + billingAddressParametersDTO: billingAddressParametersDTO + ) + } + + func toList() -> [Any?] { + [ + googlePayEnvironment.rawValue, + merchantAccount, + merchantInfoDTO?.toList(), + totalPriceStatus?.rawValue, + allowedCardNetworks, + allowedAuthMethods, + allowPrepaidCards, + allowCreditCards, + assuranceDetailsRequired, + emailRequired, + existingPaymentMethodRequired, + shippingAddressRequired, + shippingAddressParametersDTO?.toList(), + billingAddressRequired, + billingAddressParametersDTO?.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct MerchantInfoDTO { - var merchantName: String? = nil - var merchantId: String? = nil - - static func fromList(_ list: [Any?]) -> MerchantInfoDTO? { - let merchantName: String? = nilOrValue(list[0]) - let merchantId: String? = nilOrValue(list[1]) - - return MerchantInfoDTO( - merchantName: merchantName, - merchantId: merchantId - ) - } - func toList() -> [Any?] { - return [ - merchantName, - merchantId, - ] - } + var merchantName: String? + var merchantId: String? + + static func fromList(_ list: [Any?]) -> MerchantInfoDTO? { + let merchantName: String? = nilOrValue(list[0]) + let merchantId: String? = nilOrValue(list[1]) + + return MerchantInfoDTO( + merchantName: merchantName, + merchantId: merchantId + ) + } + + func toList() -> [Any?] { + [ + merchantName, + merchantId + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ShippingAddressParametersDTO { - var allowedCountryCodes: [String?]? = nil - var isPhoneNumberRequired: Bool? = nil - - static func fromList(_ list: [Any?]) -> ShippingAddressParametersDTO? { - let allowedCountryCodes: [String?]? = nilOrValue(list[0]) - let isPhoneNumberRequired: Bool? = nilOrValue(list[1]) - - return ShippingAddressParametersDTO( - allowedCountryCodes: allowedCountryCodes, - isPhoneNumberRequired: isPhoneNumberRequired - ) - } - func toList() -> [Any?] { - return [ - allowedCountryCodes, - isPhoneNumberRequired, - ] - } + var allowedCountryCodes: [String?]? + var isPhoneNumberRequired: Bool? + + static func fromList(_ list: [Any?]) -> ShippingAddressParametersDTO? { + let allowedCountryCodes: [String?]? = nilOrValue(list[0]) + let isPhoneNumberRequired: Bool? = nilOrValue(list[1]) + + return ShippingAddressParametersDTO( + allowedCountryCodes: allowedCountryCodes, + isPhoneNumberRequired: isPhoneNumberRequired + ) + } + + func toList() -> [Any?] { + [ + allowedCountryCodes, + isPhoneNumberRequired + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct BillingAddressParametersDTO { - var format: String? = nil - var isPhoneNumberRequired: Bool? = nil - - static func fromList(_ list: [Any?]) -> BillingAddressParametersDTO? { - let format: String? = nilOrValue(list[0]) - let isPhoneNumberRequired: Bool? = nilOrValue(list[1]) - - return BillingAddressParametersDTO( - format: format, - isPhoneNumberRequired: isPhoneNumberRequired - ) - } - func toList() -> [Any?] { - return [ - format, - isPhoneNumberRequired, - ] - } + var format: String? + var isPhoneNumberRequired: Bool? + + static func fromList(_ list: [Any?]) -> BillingAddressParametersDTO? { + let format: String? = nilOrValue(list[0]) + let isPhoneNumberRequired: Bool? = nilOrValue(list[1]) + + return BillingAddressParametersDTO( + format: format, + isPhoneNumberRequired: isPhoneNumberRequired + ) + } + + func toList() -> [Any?] { + [ + format, + isPhoneNumberRequired + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct CashAppPayConfigurationDTO { - var cashAppPayEnvironment: CashAppPayEnvironment - var returnUrl: String - - static func fromList(_ list: [Any?]) -> CashAppPayConfigurationDTO? { - let cashAppPayEnvironment = CashAppPayEnvironment(rawValue: list[0] as! Int)! - let returnUrl = list[1] as! String - - return CashAppPayConfigurationDTO( - cashAppPayEnvironment: cashAppPayEnvironment, - returnUrl: returnUrl - ) - } - func toList() -> [Any?] { - return [ - cashAppPayEnvironment.rawValue, - returnUrl, - ] - } + var cashAppPayEnvironment: CashAppPayEnvironment + var returnUrl: String + + static func fromList(_ list: [Any?]) -> CashAppPayConfigurationDTO? { + let cashAppPayEnvironment = CashAppPayEnvironment(rawValue: list[0] as! Int)! + let returnUrl = list[1] as! String + + return CashAppPayConfigurationDTO( + cashAppPayEnvironment: cashAppPayEnvironment, + returnUrl: returnUrl + ) + } + + func toList() -> [Any?] { + [ + cashAppPayEnvironment.rawValue, + returnUrl + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct PaymentResultDTO { - var type: PaymentResultEnum - var reason: String? = nil - var result: PaymentResultModelDTO? = nil - - static func fromList(_ list: [Any?]) -> PaymentResultDTO? { - let type = PaymentResultEnum(rawValue: list[0] as! Int)! - let reason: String? = nilOrValue(list[1]) - var result: PaymentResultModelDTO? = nil - if let resultList: [Any?] = nilOrValue(list[2]) { - result = PaymentResultModelDTO.fromList(resultList) - } - - return PaymentResultDTO( - type: type, - reason: reason, - result: result - ) - } - func toList() -> [Any?] { - return [ - type.rawValue, - reason, - result?.toList(), - ] - } + var type: PaymentResultEnum + var reason: String? + var result: PaymentResultModelDTO? + + static func fromList(_ list: [Any?]) -> PaymentResultDTO? { + let type = PaymentResultEnum(rawValue: list[0] as! Int)! + let reason: String? = nilOrValue(list[1]) + var result: PaymentResultModelDTO? + if let resultList: [Any?] = nilOrValue(list[2]) { + result = PaymentResultModelDTO.fromList(resultList) + } + + return PaymentResultDTO( + type: type, + reason: reason, + result: result + ) + } + + func toList() -> [Any?] { + [ + type.rawValue, + reason, + result?.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct PaymentResultModelDTO { - var sessionId: String? = nil - var sessionData: String? = nil - var sessionResult: String? = nil - var resultCode: String? = nil - var order: OrderResponseDTO? = nil - - static func fromList(_ list: [Any?]) -> PaymentResultModelDTO? { - let sessionId: String? = nilOrValue(list[0]) - let sessionData: String? = nilOrValue(list[1]) - let sessionResult: String? = nilOrValue(list[2]) - let resultCode: String? = nilOrValue(list[3]) - var order: OrderResponseDTO? = nil - if let orderList: [Any?] = nilOrValue(list[4]) { - order = OrderResponseDTO.fromList(orderList) - } - - return PaymentResultModelDTO( - sessionId: sessionId, - sessionData: sessionData, - sessionResult: sessionResult, - resultCode: resultCode, - order: order - ) - } - func toList() -> [Any?] { - return [ - sessionId, - sessionData, - sessionResult, - resultCode, - order?.toList(), - ] - } + var sessionId: String? + var sessionData: String? + var sessionResult: String? + var resultCode: String? + var order: OrderResponseDTO? + + static func fromList(_ list: [Any?]) -> PaymentResultModelDTO? { + let sessionId: String? = nilOrValue(list[0]) + let sessionData: String? = nilOrValue(list[1]) + let sessionResult: String? = nilOrValue(list[2]) + let resultCode: String? = nilOrValue(list[3]) + var order: OrderResponseDTO? + if let orderList: [Any?] = nilOrValue(list[4]) { + order = OrderResponseDTO.fromList(orderList) + } + + return PaymentResultModelDTO( + sessionId: sessionId, + sessionData: sessionData, + sessionResult: sessionResult, + resultCode: resultCode, + order: order + ) + } + + func toList() -> [Any?] { + [ + sessionId, + sessionData, + sessionResult, + resultCode, + order?.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct OrderResponseDTO { - var pspReference: String - var orderData: String - var amount: AmountDTO? = nil - var remainingAmount: AmountDTO? = nil - - static func fromList(_ list: [Any?]) -> OrderResponseDTO? { - let pspReference = list[0] as! String - let orderData = list[1] as! String - var amount: AmountDTO? = nil - if let amountList: [Any?] = nilOrValue(list[2]) { - amount = AmountDTO.fromList(amountList) - } - var remainingAmount: AmountDTO? = nil - if let remainingAmountList: [Any?] = nilOrValue(list[3]) { - remainingAmount = AmountDTO.fromList(remainingAmountList) - } - - return OrderResponseDTO( - pspReference: pspReference, - orderData: orderData, - amount: amount, - remainingAmount: remainingAmount - ) - } - func toList() -> [Any?] { - return [ - pspReference, - orderData, - amount?.toList(), - remainingAmount?.toList(), - ] - } + var pspReference: String + var orderData: String + var amount: AmountDTO? + var remainingAmount: AmountDTO? + + static func fromList(_ list: [Any?]) -> OrderResponseDTO? { + let pspReference = list[0] as! String + let orderData = list[1] as! String + var amount: AmountDTO? + if let amountList: [Any?] = nilOrValue(list[2]) { + amount = AmountDTO.fromList(amountList) + } + var remainingAmount: AmountDTO? + if let remainingAmountList: [Any?] = nilOrValue(list[3]) { + remainingAmount = AmountDTO.fromList(remainingAmountList) + } + + return OrderResponseDTO( + pspReference: pspReference, + orderData: orderData, + amount: amount, + remainingAmount: remainingAmount + ) + } + + func toList() -> [Any?] { + [ + pspReference, + orderData, + amount?.toList(), + remainingAmount?.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct PlatformCommunicationModel { - var type: PlatformCommunicationType - var data: String? = nil - var paymentResult: PaymentResultDTO? = nil - - static func fromList(_ list: [Any?]) -> PlatformCommunicationModel? { - let type = PlatformCommunicationType(rawValue: list[0] as! Int)! - let data: String? = nilOrValue(list[1]) - var paymentResult: PaymentResultDTO? = nil - if let paymentResultList: [Any?] = nilOrValue(list[2]) { - paymentResult = PaymentResultDTO.fromList(paymentResultList) - } - - return PlatformCommunicationModel( - type: type, - data: data, - paymentResult: paymentResult - ) - } - func toList() -> [Any?] { - return [ - type.rawValue, - data, - paymentResult?.toList(), - ] - } + var type: PlatformCommunicationType + var data: String? + var paymentResult: PaymentResultDTO? + + static func fromList(_ list: [Any?]) -> PlatformCommunicationModel? { + let type = PlatformCommunicationType(rawValue: list[0] as! Int)! + let data: String? = nilOrValue(list[1]) + var paymentResult: PaymentResultDTO? + if let paymentResultList: [Any?] = nilOrValue(list[2]) { + paymentResult = PaymentResultDTO.fromList(paymentResultList) + } + + return PlatformCommunicationModel( + type: type, + data: data, + paymentResult: paymentResult + ) + } + + func toList() -> [Any?] { + [ + type.rawValue, + data, + paymentResult?.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ComponentCommunicationModel { - var type: ComponentCommunicationType - var componentId: String - var data: Any? = nil - var paymentResult: PaymentResultDTO? = nil - - static func fromList(_ list: [Any?]) -> ComponentCommunicationModel? { - let type = ComponentCommunicationType(rawValue: list[0] as! Int)! - let componentId = list[1] as! String - let data: Any? = list[2] - var paymentResult: PaymentResultDTO? = nil - if let paymentResultList: [Any?] = nilOrValue(list[3]) { - paymentResult = PaymentResultDTO.fromList(paymentResultList) - } - - return ComponentCommunicationModel( - type: type, - componentId: componentId, - data: data, - paymentResult: paymentResult - ) - } - func toList() -> [Any?] { - return [ - type.rawValue, - componentId, - data, - paymentResult?.toList(), - ] - } + var type: ComponentCommunicationType + var componentId: String + var data: Any? + var paymentResult: PaymentResultDTO? + + static func fromList(_ list: [Any?]) -> ComponentCommunicationModel? { + let type = ComponentCommunicationType(rawValue: list[0] as! Int)! + let componentId = list[1] as! String + let data: Any? = list[2] + var paymentResult: PaymentResultDTO? + if let paymentResultList: [Any?] = nilOrValue(list[3]) { + paymentResult = PaymentResultDTO.fromList(paymentResultList) + } + + return ComponentCommunicationModel( + type: type, + componentId: componentId, + data: data, + paymentResult: paymentResult + ) + } + + func toList() -> [Any?] { + [ + type.rawValue, + componentId, + data, + paymentResult?.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct PaymentEventDTO { - var paymentEventType: PaymentEventType - var result: String? = nil - var data: [String?: Any?]? = nil - var error: ErrorDTO? = nil - - static func fromList(_ list: [Any?]) -> PaymentEventDTO? { - let paymentEventType = PaymentEventType(rawValue: list[0] as! Int)! - let result: String? = nilOrValue(list[1]) - let data: [String?: Any?]? = nilOrValue(list[2]) - var error: ErrorDTO? = nil - if let errorList: [Any?] = nilOrValue(list[3]) { - error = ErrorDTO.fromList(errorList) - } - - return PaymentEventDTO( - paymentEventType: paymentEventType, - result: result, - data: data, - error: error - ) - } - func toList() -> [Any?] { - return [ - paymentEventType.rawValue, - result, - data, - error?.toList(), - ] - } + var paymentEventType: PaymentEventType + var result: String? + var data: [String?: Any?]? + var error: ErrorDTO? + + static func fromList(_ list: [Any?]) -> PaymentEventDTO? { + let paymentEventType = PaymentEventType(rawValue: list[0] as! Int)! + let result: String? = nilOrValue(list[1]) + let data: [String?: Any?]? = nilOrValue(list[2]) + var error: ErrorDTO? + if let errorList: [Any?] = nilOrValue(list[3]) { + error = ErrorDTO.fromList(errorList) + } + + return PaymentEventDTO( + paymentEventType: paymentEventType, + result: result, + data: data, + error: error + ) + } + + func toList() -> [Any?] { + [ + paymentEventType.rawValue, + result, + data, + error?.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ErrorDTO { - var errorMessage: String? = nil - var reason: String? = nil - var dismissDropIn: Bool? = nil - - static func fromList(_ list: [Any?]) -> ErrorDTO? { - let errorMessage: String? = nilOrValue(list[0]) - let reason: String? = nilOrValue(list[1]) - let dismissDropIn: Bool? = nilOrValue(list[2]) - - return ErrorDTO( - errorMessage: errorMessage, - reason: reason, - dismissDropIn: dismissDropIn - ) - } - func toList() -> [Any?] { - return [ - errorMessage, - reason, - dismissDropIn, - ] - } + var errorMessage: String? + var reason: String? + var dismissDropIn: Bool? + + static func fromList(_ list: [Any?]) -> ErrorDTO? { + let errorMessage: String? = nilOrValue(list[0]) + let reason: String? = nilOrValue(list[1]) + let dismissDropIn: Bool? = nilOrValue(list[2]) + + return ErrorDTO( + errorMessage: errorMessage, + reason: reason, + dismissDropIn: dismissDropIn + ) + } + + func toList() -> [Any?] { + [ + errorMessage, + reason, + dismissDropIn + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct DeletedStoredPaymentMethodResultDTO { - var storedPaymentMethodId: String - var isSuccessfullyRemoved: Bool - - static func fromList(_ list: [Any?]) -> DeletedStoredPaymentMethodResultDTO? { - let storedPaymentMethodId = list[0] as! String - let isSuccessfullyRemoved = list[1] as! Bool - - return DeletedStoredPaymentMethodResultDTO( - storedPaymentMethodId: storedPaymentMethodId, - isSuccessfullyRemoved: isSuccessfullyRemoved - ) - } - func toList() -> [Any?] { - return [ - storedPaymentMethodId, - isSuccessfullyRemoved, - ] - } + var storedPaymentMethodId: String + var isSuccessfullyRemoved: Bool + + static func fromList(_ list: [Any?]) -> DeletedStoredPaymentMethodResultDTO? { + let storedPaymentMethodId = list[0] as! String + let isSuccessfullyRemoved = list[1] as! Bool + + return DeletedStoredPaymentMethodResultDTO( + storedPaymentMethodId: storedPaymentMethodId, + isSuccessfullyRemoved: isSuccessfullyRemoved + ) + } + + func toList() -> [Any?] { + [ + storedPaymentMethodId, + isSuccessfullyRemoved + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct CardComponentConfigurationDTO { - var environment: Environment - var clientKey: String - var countryCode: String - var amount: AmountDTO? = nil - var shopperLocale: String? = nil - var cardConfiguration: CardConfigurationDTO - var analyticsOptionsDTO: AnalyticsOptionsDTO - - static func fromList(_ list: [Any?]) -> CardComponentConfigurationDTO? { - let environment = Environment(rawValue: list[0] as! Int)! - let clientKey = list[1] as! String - let countryCode = list[2] as! String - var amount: AmountDTO? = nil - if let amountList: [Any?] = nilOrValue(list[3]) { - amount = AmountDTO.fromList(amountList) - } - let shopperLocale: String? = nilOrValue(list[4]) - let cardConfiguration = CardConfigurationDTO.fromList(list[5] as! [Any?])! - let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[6] as! [Any?])! - - return CardComponentConfigurationDTO( - environment: environment, - clientKey: clientKey, - countryCode: countryCode, - amount: amount, - shopperLocale: shopperLocale, - cardConfiguration: cardConfiguration, - analyticsOptionsDTO: analyticsOptionsDTO - ) - } - func toList() -> [Any?] { - return [ - environment.rawValue, - clientKey, - countryCode, - amount?.toList(), - shopperLocale, - cardConfiguration.toList(), - analyticsOptionsDTO.toList(), - ] - } + var environment: Environment + var clientKey: String + var countryCode: String + var amount: AmountDTO? + var shopperLocale: String? + var cardConfiguration: CardConfigurationDTO + var analyticsOptionsDTO: AnalyticsOptionsDTO + + static func fromList(_ list: [Any?]) -> CardComponentConfigurationDTO? { + let environment = Environment(rawValue: list[0] as! Int)! + let clientKey = list[1] as! String + let countryCode = list[2] as! String + var amount: AmountDTO? + if let amountList: [Any?] = nilOrValue(list[3]) { + amount = AmountDTO.fromList(amountList) + } + let shopperLocale: String? = nilOrValue(list[4]) + let cardConfiguration = CardConfigurationDTO.fromList(list[5] as! [Any?])! + let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[6] as! [Any?])! + + return CardComponentConfigurationDTO( + environment: environment, + clientKey: clientKey, + countryCode: countryCode, + amount: amount, + shopperLocale: shopperLocale, + cardConfiguration: cardConfiguration, + analyticsOptionsDTO: analyticsOptionsDTO + ) + } + + func toList() -> [Any?] { + [ + environment.rawValue, + clientKey, + countryCode, + amount?.toList(), + shopperLocale, + cardConfiguration.toList(), + analyticsOptionsDTO.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct InstantPaymentConfigurationDTO { - var instantPaymentType: InstantPaymentType - var environment: Environment - var clientKey: String - var countryCode: String - var amount: AmountDTO? = nil - var shopperLocale: String? = nil - var analyticsOptionsDTO: AnalyticsOptionsDTO - var googlePayConfigurationDTO: GooglePayConfigurationDTO? = nil - var applePayConfigurationDTO: ApplePayConfigurationDTO? = nil - - static func fromList(_ list: [Any?]) -> InstantPaymentConfigurationDTO? { - let instantPaymentType = InstantPaymentType(rawValue: list[0] as! Int)! - let environment = Environment(rawValue: list[1] as! Int)! - let clientKey = list[2] as! String - let countryCode = list[3] as! String - var amount: AmountDTO? = nil - if let amountList: [Any?] = nilOrValue(list[4]) { - amount = AmountDTO.fromList(amountList) - } - let shopperLocale: String? = nilOrValue(list[5]) - let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[6] as! [Any?])! - var googlePayConfigurationDTO: GooglePayConfigurationDTO? = nil - if let googlePayConfigurationDTOList: [Any?] = nilOrValue(list[7]) { - googlePayConfigurationDTO = GooglePayConfigurationDTO.fromList(googlePayConfigurationDTOList) - } - var applePayConfigurationDTO: ApplePayConfigurationDTO? = nil - if let applePayConfigurationDTOList: [Any?] = nilOrValue(list[8]) { - applePayConfigurationDTO = ApplePayConfigurationDTO.fromList(applePayConfigurationDTOList) - } - - return InstantPaymentConfigurationDTO( - instantPaymentType: instantPaymentType, - environment: environment, - clientKey: clientKey, - countryCode: countryCode, - amount: amount, - shopperLocale: shopperLocale, - analyticsOptionsDTO: analyticsOptionsDTO, - googlePayConfigurationDTO: googlePayConfigurationDTO, - applePayConfigurationDTO: applePayConfigurationDTO - ) - } - func toList() -> [Any?] { - return [ - instantPaymentType.rawValue, - environment.rawValue, - clientKey, - countryCode, - amount?.toList(), - shopperLocale, - analyticsOptionsDTO.toList(), - googlePayConfigurationDTO?.toList(), - applePayConfigurationDTO?.toList(), - ] - } + var instantPaymentType: InstantPaymentType + var environment: Environment + var clientKey: String + var countryCode: String + var amount: AmountDTO? + var shopperLocale: String? + var analyticsOptionsDTO: AnalyticsOptionsDTO + var googlePayConfigurationDTO: GooglePayConfigurationDTO? + var applePayConfigurationDTO: ApplePayConfigurationDTO? + + static func fromList(_ list: [Any?]) -> InstantPaymentConfigurationDTO? { + let instantPaymentType = InstantPaymentType(rawValue: list[0] as! Int)! + let environment = Environment(rawValue: list[1] as! Int)! + let clientKey = list[2] as! String + let countryCode = list[3] as! String + var amount: AmountDTO? + if let amountList: [Any?] = nilOrValue(list[4]) { + amount = AmountDTO.fromList(amountList) + } + let shopperLocale: String? = nilOrValue(list[5]) + let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[6] as! [Any?])! + var googlePayConfigurationDTO: GooglePayConfigurationDTO? + if let googlePayConfigurationDTOList: [Any?] = nilOrValue(list[7]) { + googlePayConfigurationDTO = GooglePayConfigurationDTO.fromList(googlePayConfigurationDTOList) + } + var applePayConfigurationDTO: ApplePayConfigurationDTO? + if let applePayConfigurationDTOList: [Any?] = nilOrValue(list[8]) { + applePayConfigurationDTO = ApplePayConfigurationDTO.fromList(applePayConfigurationDTOList) + } + + return InstantPaymentConfigurationDTO( + instantPaymentType: instantPaymentType, + environment: environment, + clientKey: clientKey, + countryCode: countryCode, + amount: amount, + shopperLocale: shopperLocale, + analyticsOptionsDTO: analyticsOptionsDTO, + googlePayConfigurationDTO: googlePayConfigurationDTO, + applePayConfigurationDTO: applePayConfigurationDTO + ) + } + + func toList() -> [Any?] { + [ + instantPaymentType.rawValue, + environment.rawValue, + clientKey, + countryCode, + amount?.toList(), + shopperLocale, + analyticsOptionsDTO.toList(), + googlePayConfigurationDTO?.toList(), + applePayConfigurationDTO?.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct InstantPaymentSetupResultDTO { - var instantPaymentType: InstantPaymentType - var isSupported: Bool - var resultData: Any? = nil - - static func fromList(_ list: [Any?]) -> InstantPaymentSetupResultDTO? { - let instantPaymentType = InstantPaymentType(rawValue: list[0] as! Int)! - let isSupported = list[1] as! Bool - let resultData: Any? = list[2] - - return InstantPaymentSetupResultDTO( - instantPaymentType: instantPaymentType, - isSupported: isSupported, - resultData: resultData - ) - } - func toList() -> [Any?] { - return [ - instantPaymentType.rawValue, - isSupported, - resultData, - ] - } + var instantPaymentType: InstantPaymentType + var isSupported: Bool + var resultData: Any? + + static func fromList(_ list: [Any?]) -> InstantPaymentSetupResultDTO? { + let instantPaymentType = InstantPaymentType(rawValue: list[0] as! Int)! + let isSupported = list[1] as! Bool + let resultData: Any? = list[2] + + return InstantPaymentSetupResultDTO( + instantPaymentType: instantPaymentType, + isSupported: isSupported, + resultData: resultData + ) + } + + func toList() -> [Any?] { + [ + instantPaymentType.rawValue, + isSupported, + resultData + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct UnencryptedCardDTO { - var cardNumber: String? = nil - var expiryMonth: String? = nil - var expiryYear: String? = nil - var cvc: String? = nil - - static func fromList(_ list: [Any?]) -> UnencryptedCardDTO? { - let cardNumber: String? = nilOrValue(list[0]) - let expiryMonth: String? = nilOrValue(list[1]) - let expiryYear: String? = nilOrValue(list[2]) - let cvc: String? = nilOrValue(list[3]) - - return UnencryptedCardDTO( - cardNumber: cardNumber, - expiryMonth: expiryMonth, - expiryYear: expiryYear, - cvc: cvc - ) - } - func toList() -> [Any?] { - return [ - cardNumber, - expiryMonth, - expiryYear, - cvc, - ] - } + var cardNumber: String? + var expiryMonth: String? + var expiryYear: String? + var cvc: String? + + static func fromList(_ list: [Any?]) -> UnencryptedCardDTO? { + let cardNumber: String? = nilOrValue(list[0]) + let expiryMonth: String? = nilOrValue(list[1]) + let expiryYear: String? = nilOrValue(list[2]) + let cvc: String? = nilOrValue(list[3]) + + return UnencryptedCardDTO( + cardNumber: cardNumber, + expiryMonth: expiryMonth, + expiryYear: expiryYear, + cvc: cvc + ) + } + + func toList() -> [Any?] { + [ + cardNumber, + expiryMonth, + expiryYear, + cvc + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct EncryptedCardDTO { - var encryptedCardNumber: String? = nil - var encryptedExpiryMonth: String? = nil - var encryptedExpiryYear: String? = nil - var encryptedSecurityCode: String? = nil - - static func fromList(_ list: [Any?]) -> EncryptedCardDTO? { - let encryptedCardNumber: String? = nilOrValue(list[0]) - let encryptedExpiryMonth: String? = nilOrValue(list[1]) - let encryptedExpiryYear: String? = nilOrValue(list[2]) - let encryptedSecurityCode: String? = nilOrValue(list[3]) - - return EncryptedCardDTO( - encryptedCardNumber: encryptedCardNumber, - encryptedExpiryMonth: encryptedExpiryMonth, - encryptedExpiryYear: encryptedExpiryYear, - encryptedSecurityCode: encryptedSecurityCode - ) - } - func toList() -> [Any?] { - return [ - encryptedCardNumber, - encryptedExpiryMonth, - encryptedExpiryYear, - encryptedSecurityCode, - ] - } + var encryptedCardNumber: String? + var encryptedExpiryMonth: String? + var encryptedExpiryYear: String? + var encryptedSecurityCode: String? + + static func fromList(_ list: [Any?]) -> EncryptedCardDTO? { + let encryptedCardNumber: String? = nilOrValue(list[0]) + let encryptedExpiryMonth: String? = nilOrValue(list[1]) + let encryptedExpiryYear: String? = nilOrValue(list[2]) + let encryptedSecurityCode: String? = nilOrValue(list[3]) + + return EncryptedCardDTO( + encryptedCardNumber: encryptedCardNumber, + encryptedExpiryMonth: encryptedExpiryMonth, + encryptedExpiryYear: encryptedExpiryYear, + encryptedSecurityCode: encryptedSecurityCode + ) + } + + func toList() -> [Any?] { + [ + encryptedCardNumber, + encryptedExpiryMonth, + encryptedExpiryYear, + encryptedSecurityCode + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct ActionComponentConfigurationDTO { - var environment: Environment - var clientKey: String - var shopperLocale: String? = nil - var amount: AmountDTO? = nil - var analyticsOptionsDTO: AnalyticsOptionsDTO - - static func fromList(_ list: [Any?]) -> ActionComponentConfigurationDTO? { - let environment = Environment(rawValue: list[0] as! Int)! - let clientKey = list[1] as! String - let shopperLocale: String? = nilOrValue(list[2]) - var amount: AmountDTO? = nil - if let amountList: [Any?] = nilOrValue(list[3]) { - amount = AmountDTO.fromList(amountList) - } - let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[4] as! [Any?])! - - return ActionComponentConfigurationDTO( - environment: environment, - clientKey: clientKey, - shopperLocale: shopperLocale, - amount: amount, - analyticsOptionsDTO: analyticsOptionsDTO - ) - } - func toList() -> [Any?] { - return [ - environment.rawValue, - clientKey, - shopperLocale, - amount?.toList(), - analyticsOptionsDTO.toList(), - ] - } + var environment: Environment + var clientKey: String + var shopperLocale: String? + var amount: AmountDTO? + var analyticsOptionsDTO: AnalyticsOptionsDTO + + static func fromList(_ list: [Any?]) -> ActionComponentConfigurationDTO? { + let environment = Environment(rawValue: list[0] as! Int)! + let clientKey = list[1] as! String + let shopperLocale: String? = nilOrValue(list[2]) + var amount: AmountDTO? + if let amountList: [Any?] = nilOrValue(list[3]) { + amount = AmountDTO.fromList(amountList) + } + let analyticsOptionsDTO = AnalyticsOptionsDTO.fromList(list[4] as! [Any?])! + + return ActionComponentConfigurationDTO( + environment: environment, + clientKey: clientKey, + shopperLocale: shopperLocale, + amount: amount, + analyticsOptionsDTO: analyticsOptionsDTO + ) + } + + func toList() -> [Any?] { + [ + environment.rawValue, + clientKey, + shopperLocale, + amount?.toList(), + analyticsOptionsDTO.toList() + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct OrderCancelResponseDTO { - var orderCancelResponseBody: [String?: Any?] - var updatedPaymentMethods: [String?: Any?]? = nil - - static func fromList(_ list: [Any?]) -> OrderCancelResponseDTO? { - let orderCancelResponseBody = list[0] as! [String?: Any?] - let updatedPaymentMethods: [String?: Any?]? = nilOrValue(list[1]) - - return OrderCancelResponseDTO( - orderCancelResponseBody: orderCancelResponseBody, - updatedPaymentMethods: updatedPaymentMethods - ) - } - func toList() -> [Any?] { - return [ - orderCancelResponseBody, - updatedPaymentMethods, - ] - } + var orderCancelResponseBody: [String?: Any?] + var updatedPaymentMethods: [String?: Any?]? + + static func fromList(_ list: [Any?]) -> OrderCancelResponseDTO? { + let orderCancelResponseBody = list[0] as! [String?: Any?] + let updatedPaymentMethods: [String?: Any?]? = nilOrValue(list[1]) + + return OrderCancelResponseDTO( + orderCancelResponseBody: orderCancelResponseBody, + updatedPaymentMethods: updatedPaymentMethods + ) + } + + func toList() -> [Any?] { + [ + orderCancelResponseBody, + updatedPaymentMethods + ] + } } private class CheckoutPlatformInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return ActionComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 129: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 130: - return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) - case 131: - return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 132: - return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) - case 133: - return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) - case 134: - return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) - case 135: - return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 136: - return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 137: - return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 138: - return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 139: - return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) - case 140: - return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) - case 141: - return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 142: - return EncryptedCardDTO.fromList(self.readValue() as! [Any?]) - case 143: - return ErrorDTO.fromList(self.readValue() as! [Any?]) - case 144: - return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 145: - return InstantPaymentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 146: - return InstantPaymentSetupResultDTO.fromList(self.readValue() as! [Any?]) - case 147: - return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) - case 148: - return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) - case 149: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) - case 150: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) - case 151: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) - case 152: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) - case 153: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) - case 154: - return SessionDTO.fromList(self.readValue() as! [Any?]) - case 155: - return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 156: - return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return ActionComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 129: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 130: + return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) + case 131: + return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 132: + return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) + case 133: + return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) + case 134: + return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) + case 135: + return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 136: + return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 137: + return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 138: + return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 139: + return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) + case 140: + return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) + case 141: + return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 142: + return EncryptedCardDTO.fromList(self.readValue() as! [Any?]) + case 143: + return ErrorDTO.fromList(self.readValue() as! [Any?]) + case 144: + return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 145: + return InstantPaymentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 146: + return InstantPaymentSetupResultDTO.fromList(self.readValue() as! [Any?]) + case 147: + return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) + case 148: + return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) + case 149: + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + case 150: + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + case 151: + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + case 152: + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + case 153: + return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + case 154: + return SessionDTO.fromList(self.readValue() as! [Any?]) + case 155: + return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 156: + return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class CheckoutPlatformInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? ActionComponentConfigurationDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? AmountDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? AnalyticsOptionsDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayConfigurationDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayContactDTO { - super.writeByte(132) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayShippingMethodDTO { - super.writeByte(133) - super.writeValue(value.toList()) - } else if let value = value as? ApplePaySummaryItemDTO { - super.writeByte(134) - super.writeValue(value.toList()) - } else if let value = value as? BillingAddressParametersDTO { - super.writeByte(135) - super.writeValue(value.toList()) - } else if let value = value as? CardComponentConfigurationDTO { - super.writeByte(136) - super.writeValue(value.toList()) - } else if let value = value as? CardConfigurationDTO { - super.writeByte(137) - super.writeValue(value.toList()) - } else if let value = value as? CashAppPayConfigurationDTO { - super.writeByte(138) - super.writeValue(value.toList()) - } else if let value = value as? ComponentCommunicationModel { - super.writeByte(139) - super.writeValue(value.toList()) - } else if let value = value as? DeletedStoredPaymentMethodResultDTO { - super.writeByte(140) - super.writeValue(value.toList()) - } else if let value = value as? DropInConfigurationDTO { - super.writeByte(141) - super.writeValue(value.toList()) - } else if let value = value as? EncryptedCardDTO { - super.writeByte(142) - super.writeValue(value.toList()) - } else if let value = value as? ErrorDTO { - super.writeByte(143) - super.writeValue(value.toList()) - } else if let value = value as? GooglePayConfigurationDTO { - super.writeByte(144) - super.writeValue(value.toList()) - } else if let value = value as? InstantPaymentConfigurationDTO { - super.writeByte(145) - super.writeValue(value.toList()) - } else if let value = value as? InstantPaymentSetupResultDTO { - super.writeByte(146) - super.writeValue(value.toList()) - } else if let value = value as? MerchantInfoDTO { - super.writeByte(147) - super.writeValue(value.toList()) - } else if let value = value as? OrderCancelResponseDTO { - super.writeByte(148) - super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { - super.writeByte(149) - super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { - super.writeByte(150) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { - super.writeByte(151) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { - super.writeByte(152) - super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { - super.writeByte(153) - super.writeValue(value.toList()) - } else if let value = value as? SessionDTO { - super.writeByte(154) - super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { - super.writeByte(155) - super.writeValue(value.toList()) - } else if let value = value as? UnencryptedCardDTO { - super.writeByte(156) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? ActionComponentConfigurationDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? AmountDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? AnalyticsOptionsDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayConfigurationDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayContactDTO { + super.writeByte(132) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayShippingMethodDTO { + super.writeByte(133) + super.writeValue(value.toList()) + } else if let value = value as? ApplePaySummaryItemDTO { + super.writeByte(134) + super.writeValue(value.toList()) + } else if let value = value as? BillingAddressParametersDTO { + super.writeByte(135) + super.writeValue(value.toList()) + } else if let value = value as? CardComponentConfigurationDTO { + super.writeByte(136) + super.writeValue(value.toList()) + } else if let value = value as? CardConfigurationDTO { + super.writeByte(137) + super.writeValue(value.toList()) + } else if let value = value as? CashAppPayConfigurationDTO { + super.writeByte(138) + super.writeValue(value.toList()) + } else if let value = value as? ComponentCommunicationModel { + super.writeByte(139) + super.writeValue(value.toList()) + } else if let value = value as? DeletedStoredPaymentMethodResultDTO { + super.writeByte(140) + super.writeValue(value.toList()) + } else if let value = value as? DropInConfigurationDTO { + super.writeByte(141) + super.writeValue(value.toList()) + } else if let value = value as? EncryptedCardDTO { + super.writeByte(142) + super.writeValue(value.toList()) + } else if let value = value as? ErrorDTO { + super.writeByte(143) + super.writeValue(value.toList()) + } else if let value = value as? GooglePayConfigurationDTO { + super.writeByte(144) + super.writeValue(value.toList()) + } else if let value = value as? InstantPaymentConfigurationDTO { + super.writeByte(145) + super.writeValue(value.toList()) + } else if let value = value as? InstantPaymentSetupResultDTO { + super.writeByte(146) + super.writeValue(value.toList()) + } else if let value = value as? MerchantInfoDTO { + super.writeByte(147) + super.writeValue(value.toList()) + } else if let value = value as? OrderCancelResponseDTO { + super.writeByte(148) + super.writeValue(value.toList()) + } else if let value = value as? OrderResponseDTO { + super.writeByte(149) + super.writeValue(value.toList()) + } else if let value = value as? PaymentEventDTO { + super.writeByte(150) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultDTO { + super.writeByte(151) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultModelDTO { + super.writeByte(152) + super.writeValue(value.toList()) + } else if let value = value as? PlatformCommunicationModel { + super.writeByte(153) + super.writeValue(value.toList()) + } else if let value = value as? SessionDTO { + super.writeByte(154) + super.writeValue(value.toList()) + } else if let value = value as? ShippingAddressParametersDTO { + super.writeByte(155) + super.writeValue(value.toList()) + } else if let value = value as? UnencryptedCardDTO { + super.writeByte(156) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class CheckoutPlatformInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - return CheckoutPlatformInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + CheckoutPlatformInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - return CheckoutPlatformInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + CheckoutPlatformInterfaceCodecWriter(data: data) + } } class CheckoutPlatformInterfaceCodec: FlutterStandardMessageCodec { - static let shared = CheckoutPlatformInterfaceCodec(readerWriter: CheckoutPlatformInterfaceCodecReaderWriter()) + static let shared = CheckoutPlatformInterfaceCodec(readerWriter: CheckoutPlatformInterfaceCodecReaderWriter()) } /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol CheckoutPlatformInterface { - func getReturnUrl(completion: @escaping (Result) -> Void) - func createSession(sessionId: String, sessionData: String, configuration: Any?, completion: @escaping (Result) -> Void) - func clearSession() throws - func encryptCard(unencryptedCardDTO: UnencryptedCardDTO, publicKey: String, completion: @escaping (Result) -> Void) - func encryptBin(bin: String, publicKey: String, completion: @escaping (Result) -> Void) - func enableConsoleLogging(loggingEnabled: Bool) throws + func getReturnUrl(completion: @escaping (Result) -> Void) + func createSession(sessionId: String, sessionData: String, configuration: Any?, completion: @escaping (Result) -> Void) + func clearSession() throws + func encryptCard(unencryptedCardDTO: UnencryptedCardDTO, publicKey: String, completion: @escaping (Result) -> Void) + func encryptBin(bin: String, publicKey: String, completion: @escaping (Result) -> Void) + func enableConsoleLogging(loggingEnabled: Bool) throws } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class CheckoutPlatformInterfaceSetup { - /// The codec used by CheckoutPlatformInterface. - static var codec: FlutterStandardMessageCodec { CheckoutPlatformInterfaceCodec.shared } - /// Sets up an instance of `CheckoutPlatformInterface` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: CheckoutPlatformInterface?) { - let getReturnUrlChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - getReturnUrlChannel.setMessageHandler { _, reply in - api.getReturnUrl { result in - switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) - } + /// The codec used by CheckoutPlatformInterface. + static var codec: FlutterStandardMessageCodec { CheckoutPlatformInterfaceCodec.shared } + /// Sets up an instance of `CheckoutPlatformInterface` to handle messages through the `binaryMessenger`. + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: CheckoutPlatformInterface?) { + let getReturnUrlChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl", binaryMessenger: binaryMessenger, codec: codec) + if let api { + getReturnUrlChannel.setMessageHandler { _, reply in + api.getReturnUrl { result in + switch result { + case let .success(res): + reply(wrapResult(res)) + case let .failure(error): + reply(wrapError(error)) + } + } + } + } else { + getReturnUrlChannel.setMessageHandler(nil) } - } - } else { - getReturnUrlChannel.setMessageHandler(nil) - } - let createSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - createSessionChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let sessionIdArg = args[0] as! String - let sessionDataArg = args[1] as! String - let configurationArg: Any? = args[2] - api.createSession(sessionId: sessionIdArg, sessionData: sessionDataArg, configuration: configurationArg) { result in - switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) - } + let createSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession", binaryMessenger: binaryMessenger, codec: codec) + if let api { + createSessionChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let sessionIdArg = args[0] as! String + let sessionDataArg = args[1] as! String + let configurationArg: Any? = args[2] + api.createSession(sessionId: sessionIdArg, sessionData: sessionDataArg, configuration: configurationArg) { result in + switch result { + case let .success(res): + reply(wrapResult(res)) + case let .failure(error): + reply(wrapError(error)) + } + } + } + } else { + createSessionChannel.setMessageHandler(nil) } - } - } else { - createSessionChannel.setMessageHandler(nil) - } - let clearSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - clearSessionChannel.setMessageHandler { _, reply in - do { - try api.clearSession() - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let clearSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession", binaryMessenger: binaryMessenger, codec: codec) + if let api { + clearSessionChannel.setMessageHandler { _, reply in + do { + try api.clearSession() + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + clearSessionChannel.setMessageHandler(nil) } - } - } else { - clearSessionChannel.setMessageHandler(nil) - } - let encryptCardChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - encryptCardChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let unencryptedCardDTOArg = args[0] as! UnencryptedCardDTO - let publicKeyArg = args[1] as! String - api.encryptCard(unencryptedCardDTO: unencryptedCardDTOArg, publicKey: publicKeyArg) { result in - switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) - } + let encryptCardChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard", binaryMessenger: binaryMessenger, codec: codec) + if let api { + encryptCardChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let unencryptedCardDTOArg = args[0] as! UnencryptedCardDTO + let publicKeyArg = args[1] as! String + api.encryptCard(unencryptedCardDTO: unencryptedCardDTOArg, publicKey: publicKeyArg) { result in + switch result { + case let .success(res): + reply(wrapResult(res)) + case let .failure(error): + reply(wrapError(error)) + } + } + } + } else { + encryptCardChannel.setMessageHandler(nil) } - } - } else { - encryptCardChannel.setMessageHandler(nil) - } - let encryptBinChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - encryptBinChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let binArg = args[0] as! String - let publicKeyArg = args[1] as! String - api.encryptBin(bin: binArg, publicKey: publicKeyArg) { result in - switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) - } + let encryptBinChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin", binaryMessenger: binaryMessenger, codec: codec) + if let api { + encryptBinChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let binArg = args[0] as! String + let publicKeyArg = args[1] as! String + api.encryptBin(bin: binArg, publicKey: publicKeyArg) { result in + switch result { + case let .success(res): + reply(wrapResult(res)) + case let .failure(error): + reply(wrapError(error)) + } + } + } + } else { + encryptBinChannel.setMessageHandler(nil) } - } - } else { - encryptBinChannel.setMessageHandler(nil) - } - let enableConsoleLoggingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - enableConsoleLoggingChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let loggingEnabledArg = args[0] as! Bool - do { - try api.enableConsoleLogging(loggingEnabled: loggingEnabledArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let enableConsoleLoggingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging", binaryMessenger: binaryMessenger, codec: codec) + if let api { + enableConsoleLoggingChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let loggingEnabledArg = args[0] as! Bool + do { + try api.enableConsoleLogging(loggingEnabled: loggingEnabledArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + enableConsoleLoggingChannel.setMessageHandler(nil) } - } - } else { - enableConsoleLoggingChannel.setMessageHandler(nil) } - } } + private class DropInPlatformInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 129: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 130: - return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) - case 131: - return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 132: - return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) - case 133: - return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) - case 134: - return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) - case 135: - return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 136: - return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 137: - return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 138: - return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) - case 139: - return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 140: - return ErrorDTO.fromList(self.readValue() as! [Any?]) - case 141: - return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 142: - return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) - case 143: - return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) - case 144: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) - case 145: - return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 129: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 130: + return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) + case 131: + return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 132: + return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) + case 133: + return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) + case 134: + return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) + case 135: + return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 136: + return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 137: + return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 138: + return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) + case 139: + return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 140: + return ErrorDTO.fromList(self.readValue() as! [Any?]) + case 141: + return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 142: + return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) + case 143: + return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) + case 144: + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + case 145: + return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class DropInPlatformInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? AmountDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? AmountDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? AnalyticsOptionsDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayConfigurationDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayContactDTO { - super.writeByte(132) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayShippingMethodDTO { - super.writeByte(133) - super.writeValue(value.toList()) - } else if let value = value as? ApplePaySummaryItemDTO { - super.writeByte(134) - super.writeValue(value.toList()) - } else if let value = value as? BillingAddressParametersDTO { - super.writeByte(135) - super.writeValue(value.toList()) - } else if let value = value as? CardConfigurationDTO { - super.writeByte(136) - super.writeValue(value.toList()) - } else if let value = value as? CashAppPayConfigurationDTO { - super.writeByte(137) - super.writeValue(value.toList()) - } else if let value = value as? DeletedStoredPaymentMethodResultDTO { - super.writeByte(138) - super.writeValue(value.toList()) - } else if let value = value as? DropInConfigurationDTO { - super.writeByte(139) - super.writeValue(value.toList()) - } else if let value = value as? ErrorDTO { - super.writeByte(140) - super.writeValue(value.toList()) - } else if let value = value as? GooglePayConfigurationDTO { - super.writeByte(141) - super.writeValue(value.toList()) - } else if let value = value as? MerchantInfoDTO { - super.writeByte(142) - super.writeValue(value.toList()) - } else if let value = value as? OrderCancelResponseDTO { - super.writeByte(143) - super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { - super.writeByte(144) - super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { - super.writeByte(145) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? AmountDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? AmountDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? AnalyticsOptionsDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayConfigurationDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayContactDTO { + super.writeByte(132) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayShippingMethodDTO { + super.writeByte(133) + super.writeValue(value.toList()) + } else if let value = value as? ApplePaySummaryItemDTO { + super.writeByte(134) + super.writeValue(value.toList()) + } else if let value = value as? BillingAddressParametersDTO { + super.writeByte(135) + super.writeValue(value.toList()) + } else if let value = value as? CardConfigurationDTO { + super.writeByte(136) + super.writeValue(value.toList()) + } else if let value = value as? CashAppPayConfigurationDTO { + super.writeByte(137) + super.writeValue(value.toList()) + } else if let value = value as? DeletedStoredPaymentMethodResultDTO { + super.writeByte(138) + super.writeValue(value.toList()) + } else if let value = value as? DropInConfigurationDTO { + super.writeByte(139) + super.writeValue(value.toList()) + } else if let value = value as? ErrorDTO { + super.writeByte(140) + super.writeValue(value.toList()) + } else if let value = value as? GooglePayConfigurationDTO { + super.writeByte(141) + super.writeValue(value.toList()) + } else if let value = value as? MerchantInfoDTO { + super.writeByte(142) + super.writeValue(value.toList()) + } else if let value = value as? OrderCancelResponseDTO { + super.writeByte(143) + super.writeValue(value.toList()) + } else if let value = value as? PaymentEventDTO { + super.writeByte(144) + super.writeValue(value.toList()) + } else if let value = value as? ShippingAddressParametersDTO { + super.writeByte(145) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class DropInPlatformInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - return DropInPlatformInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + DropInPlatformInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - return DropInPlatformInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + DropInPlatformInterfaceCodecWriter(data: data) + } } class DropInPlatformInterfaceCodec: FlutterStandardMessageCodec { - static let shared = DropInPlatformInterfaceCodec(readerWriter: DropInPlatformInterfaceCodecReaderWriter()) + static let shared = DropInPlatformInterfaceCodec(readerWriter: DropInPlatformInterfaceCodecReaderWriter()) } /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol DropInPlatformInterface { - func showDropInSession(dropInConfigurationDTO: DropInConfigurationDTO) throws - func showDropInAdvanced(dropInConfigurationDTO: DropInConfigurationDTO, paymentMethodsResponse: String) throws - func onPaymentsResult(paymentsResult: PaymentEventDTO) throws - func onPaymentsDetailsResult(paymentsDetailsResult: PaymentEventDTO) throws - func onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) throws - func onBalanceCheckResult(balanceCheckResponse: String) throws - func onOrderRequestResult(orderRequestResponse: String) throws - func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws - func cleanUpDropIn() throws + func showDropInSession(dropInConfigurationDTO: DropInConfigurationDTO) throws + func showDropInAdvanced(dropInConfigurationDTO: DropInConfigurationDTO, paymentMethodsResponse: String) throws + func onPaymentsResult(paymentsResult: PaymentEventDTO) throws + func onPaymentsDetailsResult(paymentsDetailsResult: PaymentEventDTO) throws + func onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) throws + func onBalanceCheckResult(balanceCheckResponse: String) throws + func onOrderRequestResult(orderRequestResponse: String) throws + func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws + func cleanUpDropIn() throws } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class DropInPlatformInterfaceSetup { - /// The codec used by DropInPlatformInterface. - static var codec: FlutterStandardMessageCodec { DropInPlatformInterfaceCodec.shared } - /// Sets up an instance of `DropInPlatformInterface` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: DropInPlatformInterface?) { - let showDropInSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - showDropInSessionChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let dropInConfigurationDTOArg = args[0] as! DropInConfigurationDTO - do { - try api.showDropInSession(dropInConfigurationDTO: dropInConfigurationDTOArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + /// The codec used by DropInPlatformInterface. + static var codec: FlutterStandardMessageCodec { DropInPlatformInterfaceCodec.shared } + /// Sets up an instance of `DropInPlatformInterface` to handle messages through the `binaryMessenger`. + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: DropInPlatformInterface?) { + let showDropInSessionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession", binaryMessenger: binaryMessenger, codec: codec) + if let api { + showDropInSessionChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let dropInConfigurationDTOArg = args[0] as! DropInConfigurationDTO + do { + try api.showDropInSession(dropInConfigurationDTO: dropInConfigurationDTOArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + showDropInSessionChannel.setMessageHandler(nil) } - } - } else { - showDropInSessionChannel.setMessageHandler(nil) - } - let showDropInAdvancedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - showDropInAdvancedChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let dropInConfigurationDTOArg = args[0] as! DropInConfigurationDTO - let paymentMethodsResponseArg = args[1] as! String - do { - try api.showDropInAdvanced(dropInConfigurationDTO: dropInConfigurationDTOArg, paymentMethodsResponse: paymentMethodsResponseArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let showDropInAdvancedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced", binaryMessenger: binaryMessenger, codec: codec) + if let api { + showDropInAdvancedChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let dropInConfigurationDTOArg = args[0] as! DropInConfigurationDTO + let paymentMethodsResponseArg = args[1] as! String + do { + try api.showDropInAdvanced(dropInConfigurationDTO: dropInConfigurationDTOArg, paymentMethodsResponse: paymentMethodsResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + showDropInAdvancedChannel.setMessageHandler(nil) } - } - } else { - showDropInAdvancedChannel.setMessageHandler(nil) - } - let onPaymentsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onPaymentsResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let paymentsResultArg = args[0] as! PaymentEventDTO - do { - try api.onPaymentsResult(paymentsResult: paymentsResultArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onPaymentsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onPaymentsResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let paymentsResultArg = args[0] as! PaymentEventDTO + do { + try api.onPaymentsResult(paymentsResult: paymentsResultArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onPaymentsResultChannel.setMessageHandler(nil) } - } - } else { - onPaymentsResultChannel.setMessageHandler(nil) - } - let onPaymentsDetailsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onPaymentsDetailsResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let paymentsDetailsResultArg = args[0] as! PaymentEventDTO - do { - try api.onPaymentsDetailsResult(paymentsDetailsResult: paymentsDetailsResultArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onPaymentsDetailsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onPaymentsDetailsResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let paymentsDetailsResultArg = args[0] as! PaymentEventDTO + do { + try api.onPaymentsDetailsResult(paymentsDetailsResult: paymentsDetailsResultArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onPaymentsDetailsResultChannel.setMessageHandler(nil) } - } - } else { - onPaymentsDetailsResultChannel.setMessageHandler(nil) - } - let onDeleteStoredPaymentMethodResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onDeleteStoredPaymentMethodResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let deleteStoredPaymentMethodResultDTOArg = args[0] as! DeletedStoredPaymentMethodResultDTO - do { - try api.onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: deleteStoredPaymentMethodResultDTOArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onDeleteStoredPaymentMethodResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onDeleteStoredPaymentMethodResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let deleteStoredPaymentMethodResultDTOArg = args[0] as! DeletedStoredPaymentMethodResultDTO + do { + try api.onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: deleteStoredPaymentMethodResultDTOArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onDeleteStoredPaymentMethodResultChannel.setMessageHandler(nil) } - } - } else { - onDeleteStoredPaymentMethodResultChannel.setMessageHandler(nil) - } - let onBalanceCheckResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onBalanceCheckResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let balanceCheckResponseArg = args[0] as! String - do { - try api.onBalanceCheckResult(balanceCheckResponse: balanceCheckResponseArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onBalanceCheckResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onBalanceCheckResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let balanceCheckResponseArg = args[0] as! String + do { + try api.onBalanceCheckResult(balanceCheckResponse: balanceCheckResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onBalanceCheckResultChannel.setMessageHandler(nil) } - } - } else { - onBalanceCheckResultChannel.setMessageHandler(nil) - } - let onOrderRequestResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onOrderRequestResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let orderRequestResponseArg = args[0] as! String - do { - try api.onOrderRequestResult(orderRequestResponse: orderRequestResponseArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onOrderRequestResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onOrderRequestResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let orderRequestResponseArg = args[0] as! String + do { + try api.onOrderRequestResult(orderRequestResponse: orderRequestResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onOrderRequestResultChannel.setMessageHandler(nil) } - } - } else { - onOrderRequestResultChannel.setMessageHandler(nil) - } - let onOrderCancelResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onOrderCancelResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let orderCancelResponseArg = args[0] as! OrderCancelResponseDTO - do { - try api.onOrderCancelResult(orderCancelResponse: orderCancelResponseArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onOrderCancelResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onOrderCancelResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let orderCancelResponseArg = args[0] as! OrderCancelResponseDTO + do { + try api.onOrderCancelResult(orderCancelResponse: orderCancelResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onOrderCancelResultChannel.setMessageHandler(nil) } - } - } else { - onOrderCancelResultChannel.setMessageHandler(nil) - } - let cleanUpDropInChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - cleanUpDropInChannel.setMessageHandler { _, reply in - do { - try api.cleanUpDropIn() - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let cleanUpDropInChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn", binaryMessenger: binaryMessenger, codec: codec) + if let api { + cleanUpDropInChannel.setMessageHandler { _, reply in + do { + try api.cleanUpDropIn() + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + cleanUpDropInChannel.setMessageHandler(nil) } - } - } else { - cleanUpDropInChannel.setMessageHandler(nil) } - } } + private class DropInFlutterInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 129: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) - case 130: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) - case 131: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) - case 132: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 129: + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + case 130: + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + case 131: + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + case 132: + return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class DropInFlutterInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? AmountDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { - super.writeByte(132) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? AmountDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? OrderResponseDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultModelDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? PlatformCommunicationModel { + super.writeByte(132) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class DropInFlutterInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - return DropInFlutterInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + DropInFlutterInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - return DropInFlutterInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + DropInFlutterInterfaceCodecWriter(data: data) + } } class DropInFlutterInterfaceCodec: FlutterStandardMessageCodec { - static let shared = DropInFlutterInterfaceCodec(readerWriter: DropInFlutterInterfaceCodecReaderWriter()) + static let shared = DropInFlutterInterfaceCodec(readerWriter: DropInFlutterInterfaceCodecReaderWriter()) } /// 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 onDropInSessionPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) + func onDropInAdvancedPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) } + class DropInFlutterInterface: DropInFlutterInterfaceProtocol { - private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger) { - self.binaryMessenger = binaryMessenger - } - var codec: FlutterStandardMessageCodec { - return DropInFlutterInterfaceCodec.shared - } - func onDropInSessionPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication" - 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(FlutterError(code: code, message: message, details: details))) - } else { - completion(.success(Void())) - } - } - } - func onDropInAdvancedPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication" - 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(FlutterError(code: code, message: message, details: details))) - } else { - completion(.success(Void())) - } - } - } + private let binaryMessenger: FlutterBinaryMessenger + init(binaryMessenger: FlutterBinaryMessenger) { + self.binaryMessenger = binaryMessenger + } + + var codec: FlutterStandardMessageCodec { + DropInFlutterInterfaceCodec.shared + } + + func onDropInSessionPlatformCommunication(platformCommunicationModel platformCommunicationModelArg: PlatformCommunicationModel, completion: @escaping (Result) -> Void) { + let channelName = "dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication" + 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(FlutterError(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" + 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(FlutterError(code: code, message: message, details: details))) + } else { + completion(.success(())) + } + } + } } + private class ComponentPlatformInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return ActionComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 129: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 130: - return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) - case 131: - return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 132: - return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) - case 133: - return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) - case 134: - return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) - case 135: - return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 136: - return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 137: - return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 138: - return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 139: - return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) - case 140: - return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) - case 141: - return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 142: - return EncryptedCardDTO.fromList(self.readValue() as! [Any?]) - case 143: - return ErrorDTO.fromList(self.readValue() as! [Any?]) - case 144: - return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 145: - return InstantPaymentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 146: - return InstantPaymentSetupResultDTO.fromList(self.readValue() as! [Any?]) - case 147: - return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) - case 148: - return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) - case 149: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) - case 150: - return PaymentEventDTO.fromList(self.readValue() as! [Any?]) - case 151: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) - case 152: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) - case 153: - return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) - case 154: - return SessionDTO.fromList(self.readValue() as! [Any?]) - case 155: - return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) - case 156: - return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return ActionComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 129: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 130: + return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) + case 131: + return ApplePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 132: + return ApplePayContactDTO.fromList(self.readValue() as! [Any?]) + case 133: + return ApplePayShippingMethodDTO.fromList(self.readValue() as! [Any?]) + case 134: + return ApplePaySummaryItemDTO.fromList(self.readValue() as! [Any?]) + case 135: + return BillingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 136: + return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 137: + return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 138: + return CashAppPayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 139: + return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) + case 140: + return DeletedStoredPaymentMethodResultDTO.fromList(self.readValue() as! [Any?]) + case 141: + return DropInConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 142: + return EncryptedCardDTO.fromList(self.readValue() as! [Any?]) + case 143: + return ErrorDTO.fromList(self.readValue() as! [Any?]) + case 144: + return GooglePayConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 145: + return InstantPaymentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 146: + return InstantPaymentSetupResultDTO.fromList(self.readValue() as! [Any?]) + case 147: + return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) + case 148: + return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) + case 149: + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + case 150: + return PaymentEventDTO.fromList(self.readValue() as! [Any?]) + case 151: + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + case 152: + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + case 153: + return PlatformCommunicationModel.fromList(self.readValue() as! [Any?]) + case 154: + return SessionDTO.fromList(self.readValue() as! [Any?]) + case 155: + return ShippingAddressParametersDTO.fromList(self.readValue() as! [Any?]) + case 156: + return UnencryptedCardDTO.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class ComponentPlatformInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? ActionComponentConfigurationDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? AmountDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? AnalyticsOptionsDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayConfigurationDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayContactDTO { - super.writeByte(132) - super.writeValue(value.toList()) - } else if let value = value as? ApplePayShippingMethodDTO { - super.writeByte(133) - super.writeValue(value.toList()) - } else if let value = value as? ApplePaySummaryItemDTO { - super.writeByte(134) - super.writeValue(value.toList()) - } else if let value = value as? BillingAddressParametersDTO { - super.writeByte(135) - super.writeValue(value.toList()) - } else if let value = value as? CardComponentConfigurationDTO { - super.writeByte(136) - super.writeValue(value.toList()) - } else if let value = value as? CardConfigurationDTO { - super.writeByte(137) - super.writeValue(value.toList()) - } else if let value = value as? CashAppPayConfigurationDTO { - super.writeByte(138) - super.writeValue(value.toList()) - } else if let value = value as? ComponentCommunicationModel { - super.writeByte(139) - super.writeValue(value.toList()) - } else if let value = value as? DeletedStoredPaymentMethodResultDTO { - super.writeByte(140) - super.writeValue(value.toList()) - } else if let value = value as? DropInConfigurationDTO { - super.writeByte(141) - super.writeValue(value.toList()) - } else if let value = value as? EncryptedCardDTO { - super.writeByte(142) - super.writeValue(value.toList()) - } else if let value = value as? ErrorDTO { - super.writeByte(143) - super.writeValue(value.toList()) - } else if let value = value as? GooglePayConfigurationDTO { - super.writeByte(144) - super.writeValue(value.toList()) - } else if let value = value as? InstantPaymentConfigurationDTO { - super.writeByte(145) - super.writeValue(value.toList()) - } else if let value = value as? InstantPaymentSetupResultDTO { - super.writeByte(146) - super.writeValue(value.toList()) - } else if let value = value as? MerchantInfoDTO { - super.writeByte(147) - super.writeValue(value.toList()) - } else if let value = value as? OrderCancelResponseDTO { - super.writeByte(148) - super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { - super.writeByte(149) - super.writeValue(value.toList()) - } else if let value = value as? PaymentEventDTO { - super.writeByte(150) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { - super.writeByte(151) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { - super.writeByte(152) - super.writeValue(value.toList()) - } else if let value = value as? PlatformCommunicationModel { - super.writeByte(153) - super.writeValue(value.toList()) - } else if let value = value as? SessionDTO { - super.writeByte(154) - super.writeValue(value.toList()) - } else if let value = value as? ShippingAddressParametersDTO { - super.writeByte(155) - super.writeValue(value.toList()) - } else if let value = value as? UnencryptedCardDTO { - super.writeByte(156) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? ActionComponentConfigurationDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? AmountDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? AnalyticsOptionsDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayConfigurationDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayContactDTO { + super.writeByte(132) + super.writeValue(value.toList()) + } else if let value = value as? ApplePayShippingMethodDTO { + super.writeByte(133) + super.writeValue(value.toList()) + } else if let value = value as? ApplePaySummaryItemDTO { + super.writeByte(134) + super.writeValue(value.toList()) + } else if let value = value as? BillingAddressParametersDTO { + super.writeByte(135) + super.writeValue(value.toList()) + } else if let value = value as? CardComponentConfigurationDTO { + super.writeByte(136) + super.writeValue(value.toList()) + } else if let value = value as? CardConfigurationDTO { + super.writeByte(137) + super.writeValue(value.toList()) + } else if let value = value as? CashAppPayConfigurationDTO { + super.writeByte(138) + super.writeValue(value.toList()) + } else if let value = value as? ComponentCommunicationModel { + super.writeByte(139) + super.writeValue(value.toList()) + } else if let value = value as? DeletedStoredPaymentMethodResultDTO { + super.writeByte(140) + super.writeValue(value.toList()) + } else if let value = value as? DropInConfigurationDTO { + super.writeByte(141) + super.writeValue(value.toList()) + } else if let value = value as? EncryptedCardDTO { + super.writeByte(142) + super.writeValue(value.toList()) + } else if let value = value as? ErrorDTO { + super.writeByte(143) + super.writeValue(value.toList()) + } else if let value = value as? GooglePayConfigurationDTO { + super.writeByte(144) + super.writeValue(value.toList()) + } else if let value = value as? InstantPaymentConfigurationDTO { + super.writeByte(145) + super.writeValue(value.toList()) + } else if let value = value as? InstantPaymentSetupResultDTO { + super.writeByte(146) + super.writeValue(value.toList()) + } else if let value = value as? MerchantInfoDTO { + super.writeByte(147) + super.writeValue(value.toList()) + } else if let value = value as? OrderCancelResponseDTO { + super.writeByte(148) + super.writeValue(value.toList()) + } else if let value = value as? OrderResponseDTO { + super.writeByte(149) + super.writeValue(value.toList()) + } else if let value = value as? PaymentEventDTO { + super.writeByte(150) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultDTO { + super.writeByte(151) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultModelDTO { + super.writeByte(152) + super.writeValue(value.toList()) + } else if let value = value as? PlatformCommunicationModel { + super.writeByte(153) + super.writeValue(value.toList()) + } else if let value = value as? SessionDTO { + super.writeByte(154) + super.writeValue(value.toList()) + } else if let value = value as? ShippingAddressParametersDTO { + super.writeByte(155) + super.writeValue(value.toList()) + } else if let value = value as? UnencryptedCardDTO { + super.writeByte(156) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class ComponentPlatformInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - return ComponentPlatformInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + ComponentPlatformInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - return ComponentPlatformInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + ComponentPlatformInterfaceCodecWriter(data: data) + } } class ComponentPlatformInterfaceCodec: FlutterStandardMessageCodec { - static let shared = ComponentPlatformInterfaceCodec(readerWriter: ComponentPlatformInterfaceCodecReaderWriter()) + static let shared = ComponentPlatformInterfaceCodec(readerWriter: ComponentPlatformInterfaceCodecReaderWriter()) } /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol ComponentPlatformInterface { - func updateViewHeight(viewId: Int64) throws - func onPaymentsResult(componentId: String, paymentsResult: PaymentEventDTO) throws - func onPaymentsDetailsResult(componentId: String, paymentsDetailsResult: PaymentEventDTO) throws - func isInstantPaymentSupportedByPlatform(instantPaymentConfigurationDTO: InstantPaymentConfigurationDTO, paymentMethodResponse: String, componentId: String, completion: @escaping (Result) -> Void) - func onInstantPaymentPressed(instantPaymentConfigurationDTO: InstantPaymentConfigurationDTO, encodedPaymentMethod: String, componentId: String) throws - func handleAction(actionComponentConfiguration: ActionComponentConfigurationDTO, componentId: String, actionResponse: [String?: Any?]?) throws - func onDispose(componentId: String) throws + func updateViewHeight(viewId: Int64) throws + func onPaymentsResult(componentId: String, paymentsResult: PaymentEventDTO) throws + func onPaymentsDetailsResult(componentId: String, paymentsDetailsResult: PaymentEventDTO) throws + func isInstantPaymentSupportedByPlatform(instantPaymentConfigurationDTO: InstantPaymentConfigurationDTO, paymentMethodResponse: String, componentId: String, completion: @escaping (Result) -> Void) + func onInstantPaymentPressed(instantPaymentConfigurationDTO: InstantPaymentConfigurationDTO, encodedPaymentMethod: String, componentId: String) throws + func handleAction(actionComponentConfiguration: ActionComponentConfigurationDTO, componentId: String, actionResponse: [String?: Any?]?) throws + func onDispose(componentId: String) throws } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class ComponentPlatformInterfaceSetup { - /// The codec used by ComponentPlatformInterface. - static var codec: FlutterStandardMessageCodec { ComponentPlatformInterfaceCodec.shared } - /// Sets up an instance of `ComponentPlatformInterface` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: ComponentPlatformInterface?) { - let updateViewHeightChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - updateViewHeightChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let viewIdArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) - do { - try api.updateViewHeight(viewId: viewIdArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + /// The codec used by ComponentPlatformInterface. + static var codec: FlutterStandardMessageCodec { ComponentPlatformInterfaceCodec.shared } + /// Sets up an instance of `ComponentPlatformInterface` to handle messages through the `binaryMessenger`. + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: ComponentPlatformInterface?) { + let updateViewHeightChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight", binaryMessenger: binaryMessenger, codec: codec) + if let api { + updateViewHeightChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let viewIdArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) + do { + try api.updateViewHeight(viewId: viewIdArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + updateViewHeightChannel.setMessageHandler(nil) } - } - } else { - updateViewHeightChannel.setMessageHandler(nil) - } - let onPaymentsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onPaymentsResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let componentIdArg = args[0] as! String - let paymentsResultArg = args[1] as! PaymentEventDTO - do { - try api.onPaymentsResult(componentId: componentIdArg, paymentsResult: paymentsResultArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onPaymentsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onPaymentsResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let componentIdArg = args[0] as! String + let paymentsResultArg = args[1] as! PaymentEventDTO + do { + try api.onPaymentsResult(componentId: componentIdArg, paymentsResult: paymentsResultArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onPaymentsResultChannel.setMessageHandler(nil) } - } - } else { - onPaymentsResultChannel.setMessageHandler(nil) - } - let onPaymentsDetailsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onPaymentsDetailsResultChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let componentIdArg = args[0] as! String - let paymentsDetailsResultArg = args[1] as! PaymentEventDTO - do { - try api.onPaymentsDetailsResult(componentId: componentIdArg, paymentsDetailsResult: paymentsDetailsResultArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onPaymentsDetailsResultChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onPaymentsDetailsResultChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let componentIdArg = args[0] as! String + let paymentsDetailsResultArg = args[1] as! PaymentEventDTO + do { + try api.onPaymentsDetailsResult(componentId: componentIdArg, paymentsDetailsResult: paymentsDetailsResultArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onPaymentsDetailsResultChannel.setMessageHandler(nil) } - } - } else { - onPaymentsDetailsResultChannel.setMessageHandler(nil) - } - let isInstantPaymentSupportedByPlatformChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - isInstantPaymentSupportedByPlatformChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let instantPaymentConfigurationDTOArg = args[0] as! InstantPaymentConfigurationDTO - let paymentMethodResponseArg = args[1] as! String - let componentIdArg = args[2] as! String - api.isInstantPaymentSupportedByPlatform(instantPaymentConfigurationDTO: instantPaymentConfigurationDTOArg, paymentMethodResponse: paymentMethodResponseArg, componentId: componentIdArg) { result in - switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) - } + let isInstantPaymentSupportedByPlatformChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform", binaryMessenger: binaryMessenger, codec: codec) + if let api { + isInstantPaymentSupportedByPlatformChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let instantPaymentConfigurationDTOArg = args[0] as! InstantPaymentConfigurationDTO + let paymentMethodResponseArg = args[1] as! String + let componentIdArg = args[2] as! String + api.isInstantPaymentSupportedByPlatform(instantPaymentConfigurationDTO: instantPaymentConfigurationDTOArg, paymentMethodResponse: paymentMethodResponseArg, componentId: componentIdArg) { result in + switch result { + case let .success(res): + reply(wrapResult(res)) + case let .failure(error): + reply(wrapError(error)) + } + } + } + } else { + isInstantPaymentSupportedByPlatformChannel.setMessageHandler(nil) } - } - } else { - isInstantPaymentSupportedByPlatformChannel.setMessageHandler(nil) - } - let onInstantPaymentPressedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onInstantPaymentPressedChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let instantPaymentConfigurationDTOArg = args[0] as! InstantPaymentConfigurationDTO - let encodedPaymentMethodArg = args[1] as! String - let componentIdArg = args[2] as! String - do { - try api.onInstantPaymentPressed(instantPaymentConfigurationDTO: instantPaymentConfigurationDTOArg, encodedPaymentMethod: encodedPaymentMethodArg, componentId: componentIdArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onInstantPaymentPressedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onInstantPaymentPressedChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let instantPaymentConfigurationDTOArg = args[0] as! InstantPaymentConfigurationDTO + let encodedPaymentMethodArg = args[1] as! String + let componentIdArg = args[2] as! String + do { + try api.onInstantPaymentPressed(instantPaymentConfigurationDTO: instantPaymentConfigurationDTOArg, encodedPaymentMethod: encodedPaymentMethodArg, componentId: componentIdArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onInstantPaymentPressedChannel.setMessageHandler(nil) } - } - } else { - onInstantPaymentPressedChannel.setMessageHandler(nil) - } - let handleActionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - handleActionChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let actionComponentConfigurationArg = args[0] as! ActionComponentConfigurationDTO - let componentIdArg = args[1] as! String - let actionResponseArg: [String?: Any?]? = nilOrValue(args[2]) - do { - try api.handleAction(actionComponentConfiguration: actionComponentConfigurationArg, componentId: componentIdArg, actionResponse: actionResponseArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let handleActionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction", binaryMessenger: binaryMessenger, codec: codec) + if let api { + handleActionChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let actionComponentConfigurationArg = args[0] as! ActionComponentConfigurationDTO + let componentIdArg = args[1] as! String + let actionResponseArg: [String?: Any?]? = nilOrValue(args[2]) + do { + try api.handleAction(actionComponentConfiguration: actionComponentConfigurationArg, componentId: componentIdArg, actionResponse: actionResponseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + handleActionChannel.setMessageHandler(nil) } - } - } else { - handleActionChannel.setMessageHandler(nil) - } - let onDisposeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { - onDisposeChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let componentIdArg = args[0] as! String - do { - try api.onDispose(componentId: componentIdArg) - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) + let onDisposeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose", binaryMessenger: binaryMessenger, codec: codec) + if let api { + onDisposeChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let componentIdArg = args[0] as! String + do { + try api.onDispose(componentId: componentIdArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + onDisposeChannel.setMessageHandler(nil) } - } - } else { - onDisposeChannel.setMessageHandler(nil) } - } } + private class ComponentFlutterInterfaceCodecReader: FlutterStandardReader { - override func readValue(ofType type: UInt8) -> Any? { - switch type { - case 128: - return AmountDTO.fromList(self.readValue() as! [Any?]) - case 129: - return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) - case 130: - return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 131: - return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) - case 132: - return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) - case 133: - return OrderResponseDTO.fromList(self.readValue() as! [Any?]) - case 134: - return PaymentResultDTO.fromList(self.readValue() as! [Any?]) - case 135: - return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) - case 136: - return SessionDTO.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) - } - } + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 128: + return AmountDTO.fromList(self.readValue() as! [Any?]) + case 129: + return AnalyticsOptionsDTO.fromList(self.readValue() as! [Any?]) + case 130: + return CardComponentConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 131: + return CardConfigurationDTO.fromList(self.readValue() as! [Any?]) + case 132: + return ComponentCommunicationModel.fromList(self.readValue() as! [Any?]) + case 133: + return OrderResponseDTO.fromList(self.readValue() as! [Any?]) + case 134: + return PaymentResultDTO.fromList(self.readValue() as! [Any?]) + case 135: + return PaymentResultModelDTO.fromList(self.readValue() as! [Any?]) + case 136: + return SessionDTO.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } } private class ComponentFlutterInterfaceCodecWriter: FlutterStandardWriter { - override func writeValue(_ value: Any) { - if let value = value as? AmountDTO { - super.writeByte(128) - super.writeValue(value.toList()) - } else if let value = value as? AnalyticsOptionsDTO { - super.writeByte(129) - super.writeValue(value.toList()) - } else if let value = value as? CardComponentConfigurationDTO { - super.writeByte(130) - super.writeValue(value.toList()) - } else if let value = value as? CardConfigurationDTO { - super.writeByte(131) - super.writeValue(value.toList()) - } else if let value = value as? ComponentCommunicationModel { - super.writeByte(132) - super.writeValue(value.toList()) - } else if let value = value as? OrderResponseDTO { - super.writeByte(133) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultDTO { - super.writeByte(134) - super.writeValue(value.toList()) - } else if let value = value as? PaymentResultModelDTO { - super.writeByte(135) - super.writeValue(value.toList()) - } else if let value = value as? SessionDTO { - super.writeByte(136) - super.writeValue(value.toList()) - } else { - super.writeValue(value) - } - } + override func writeValue(_ value: Any) { + if let value = value as? AmountDTO { + super.writeByte(128) + super.writeValue(value.toList()) + } else if let value = value as? AnalyticsOptionsDTO { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? CardComponentConfigurationDTO { + super.writeByte(130) + super.writeValue(value.toList()) + } else if let value = value as? CardConfigurationDTO { + super.writeByte(131) + super.writeValue(value.toList()) + } else if let value = value as? ComponentCommunicationModel { + super.writeByte(132) + super.writeValue(value.toList()) + } else if let value = value as? OrderResponseDTO { + super.writeByte(133) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultDTO { + super.writeByte(134) + super.writeValue(value.toList()) + } else if let value = value as? PaymentResultModelDTO { + super.writeByte(135) + super.writeValue(value.toList()) + } else if let value = value as? SessionDTO { + super.writeByte(136) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } } private class ComponentFlutterInterfaceCodecReaderWriter: FlutterStandardReaderWriter { - override func reader(with data: Data) -> FlutterStandardReader { - return ComponentFlutterInterfaceCodecReader(data: data) - } + override func reader(with data: Data) -> FlutterStandardReader { + ComponentFlutterInterfaceCodecReader(data: data) + } - override func writer(with data: NSMutableData) -> FlutterStandardWriter { - return ComponentFlutterInterfaceCodecWriter(data: data) - } + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + ComponentFlutterInterfaceCodecWriter(data: data) + } } class ComponentFlutterInterfaceCodec: FlutterStandardMessageCodec { - static let shared = ComponentFlutterInterfaceCodec(readerWriter: ComponentFlutterInterfaceCodecReaderWriter()) + static let shared = ComponentFlutterInterfaceCodec(readerWriter: ComponentFlutterInterfaceCodecReaderWriter()) } /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol ComponentFlutterInterfaceProtocol { - func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) - func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) + func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) + func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) } + class ComponentFlutterInterface: ComponentFlutterInterfaceProtocol { - private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger) { - self.binaryMessenger = binaryMessenger - } - var codec: FlutterStandardMessageCodec { - return ComponentFlutterInterfaceCodec.shared - } - func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([cardComponentConfigurationDTOArg, sessionDTOArg] 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(FlutterError(code: code, message: message, details: details))) - } else { - completion(.success(Void())) - } - } - } - func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([componentCommunicationModelArg] 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(FlutterError(code: code, message: message, details: details))) - } else { - completion(.success(Void())) - } - } - } + private let binaryMessenger: FlutterBinaryMessenger + init(binaryMessenger: FlutterBinaryMessenger) { + self.binaryMessenger = binaryMessenger + } + + var codec: FlutterStandardMessageCodec { + ComponentFlutterInterfaceCodec.shared + } + + func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) { + let channelName = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([cardComponentConfigurationDTOArg, sessionDTOArg] 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(FlutterError(code: code, message: message, details: details))) + } else { + completion(.success(())) + } + } + } + + func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) { + let channelName = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([componentCommunicationModelArg] 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(FlutterError(code: code, message: message, details: details))) + } else { + completion(.success(())) + } + } + } } diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index d76651a4..7dd5acca 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -11,6 +11,8 @@ class DropInPlatformApi: DropInPlatformInterface { private var dropInSessionStoredPaymentMethodsDelegate: DropInSessionsStoredPaymentMethodsDelegate? private var dropInAdvancedFlowDelegate: DropInAdvancedFlowDelegate? private var dropInAdvancedFlowStoredPaymentMethodsDelegate: DropInAdvancedFlowStoredPaymentMethodsDelegate? + private var checkBalanceHandler: ((Result) -> Void)? + private var requestOrderHandler: ((Result) -> Void)? init( dropInFlutterApi: DropInFlutterInterface, @@ -84,10 +86,10 @@ class DropInPlatformApi: DropInPlatformInterface { ) } - let paymentMethodsWithoutGiftCards = removeGiftCardPaymentMethods(paymentMethods: paymentMethods) + let paymentMethodsWithoutGiftCards = removeGiftCardPaymentMethods(paymentMethods: paymentMethods, dropInConfigurationDTO.isPartialPaymentSupported) let configuration = try dropInConfigurationDTO.createDropInConfiguration(payment: adyenContext.payment) let dropInComponent = DropInComponent( - paymentMethods: paymentMethodsWithoutGiftCards, + paymentMethods: paymentMethods, context: adyenContext, configuration: configuration, title: dropInConfigurationDTO.preselectedPaymentMethodTitle @@ -95,6 +97,9 @@ class DropInPlatformApi: DropInPlatformInterface { dropInAdvancedFlowDelegate = DropInAdvancedFlowDelegate(dropInFlutterApi: dropInFlutterApi) dropInAdvancedFlowDelegate?.dropInInteractorDelegate = self dropInComponent.delegate = dropInAdvancedFlowDelegate + if dropInConfigurationDTO.isPartialPaymentSupported { + dropInComponent.partialPaymentDelegate = self + } if dropInConfigurationDTO.isRemoveStoredPaymentMethodEnabled == true { dropInAdvancedFlowStoredPaymentMethodsDelegate = DropInAdvancedFlowStoredPaymentMethodsDelegate( viewController: viewController, @@ -134,16 +139,30 @@ class DropInPlatformApi: DropInPlatformInterface { } func onBalanceCheckResult(balanceCheckResponse: String) throws { + guard let checkBalanceHandler else { return } + do { + guard let balanceCheckData = balanceCheckResponse.data(using: .utf8) else { throw PlatformError(errorDescription: "Failure parsing balance check response.") } + let balance = try jsonDecoder.decode(Balance.self, from: balanceCheckData) + checkBalanceHandler(.success(balance)) + } catch { + checkBalanceHandler(.failure(error)) + } } func onOrderRequestResult(orderRequestResponse: String) throws { + guard let requestOrderHandler else { return } + do { + guard let orderRequestData = orderRequestResponse.data(using: .utf8) else { throw PlatformError(errorDescription: "Failure parsing order request response.") } + let partialPaymentOrder = try jsonDecoder.decode(PartialPaymentOrder.self, from: orderRequestData) + requestOrderHandler(.success(partialPaymentOrder)) + } catch { + requestOrderHandler(.failure(error)) + } } - func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws { - - } + func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws {} func cleanUpDropIn() { sessionHolder.reset() @@ -151,6 +170,8 @@ class DropInPlatformApi: DropInPlatformInterface { dropInAdvancedFlowDelegate?.dropInInteractorDelegate = nil dropInAdvancedFlowDelegate = nil dropInAdvancedFlowStoredPaymentMethodsDelegate = nil + checkBalanceHandler = nil + requestOrderHandler = nil dropInViewController = nil hostViewController = nil } @@ -164,7 +185,7 @@ class DropInPlatformApi: DropInPlatformInterface { case .error: onDropInResultError(paymentEventDTO: paymentEventDTO) case .update: - return + onDropInResultUpdate(paymentEventDTO: paymentEventDTO) } } @@ -235,8 +256,32 @@ class DropInPlatformApi: DropInPlatformInterface { hostViewController?.adyen.topPresenter.present(alertController, animated: true) } } + + private func onDropInResultUpdate(paymentEventDTO: PaymentEventDTO) { + do { + guard let updatedPaymentMethods = paymentEventDTO.data?[Constants.updatedPaymentMethodsKey] ?? "" else { + throw PlatformError(errorDescription: "Updated payment methods not provided.") + } + + guard let orderResponse = paymentEventDTO.data?[Constants.orderResponseKey] ?? "" else { + throw PlatformError(errorDescription: "Order not provided.") + } + + let updatedPaymentMethodsData = try JSONSerialization.data(withJSONObject: updatedPaymentMethods, options: []) + let paymentMethods = try jsonDecoder.decode(PaymentMethods.self, from: updatedPaymentMethodsData) + let orderData = try JSONSerialization.data(withJSONObject: orderResponse, options: []) + let order = try jsonDecoder.decode(PartialPaymentOrder.self, from: orderData) + try dropInViewController?.dropInComponent.reload(with: order, paymentMethods) + } catch { + adyenPrint(error.localizedDescription) + } + } - private func removeGiftCardPaymentMethods(paymentMethods: PaymentMethods) -> PaymentMethods { + private func removeGiftCardPaymentMethods(paymentMethods: PaymentMethods, isPartialPaymentSupported: Bool) -> PaymentMethods { + if isPartialPaymentSupported { + return paymentMethods + } + let storedPaymentMethods = paymentMethods.stored.filter { !($0.type == PaymentMethodType.giftcard) } let paymentMethods = paymentMethods.regular.filter { !($0.type == PaymentMethodType.giftcard) } return PaymentMethods(regular: paymentMethods, stored: storedPaymentMethods) @@ -297,3 +342,40 @@ extension DropInPlatformApi: DropInInteractorDelegate { } } } + +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, + data: data.jsonObject.toJsonStringRepresentation() + ) + dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + } catch { + completion(.failure(error)) + } + } + + 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 }) + } + + func cancelOrder(_ order: Adyen.PartialPaymentOrder, component: any Adyen.Component) { + do { + let cancelOrderData: [String: Any] = [ + Constants.orderKey: order.jsonObject, + Constants.shouldUpdatePaymentMethodsKey: false + ] + 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 }) + } catch { + adyenPrint(error.localizedDescription) + } + } + +} diff --git a/ios/Classes/utils/Constants.swift b/ios/Classes/utils/Constants.swift new file mode 100644 index 00000000..d73ee00c --- /dev/null +++ b/ios/Classes/utils/Constants.swift @@ -0,0 +1,7 @@ + +enum Constants { + static let orderKey = "order" + static let orderResponseKey = "orderResponse" + static let updatedPaymentMethodsKey = "updatedPaymentMethods" + static let shouldUpdatePaymentMethodsKey = "shouldUpdatePaymentMethods" +} diff --git a/lib/src/common/adyen_checkout_session.dart b/lib/src/common/adyen_checkout_session.dart index 124ad223..db5ef305 100644 --- a/lib/src/common/adyen_checkout_session.dart +++ b/lib/src/common/adyen_checkout_session.dart @@ -69,7 +69,7 @@ class AdyenCheckoutSession { InstantPaymentType.applePay, ); } else if (configuration is DropInConfiguration) { - return configuration.toDTO(sdkVersionNumber); + return configuration.toDTO(sdkVersionNumber, true); } else if (configuration is InstantComponentConfiguration) { return configuration.toDTO( sdkVersionNumber, diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 8ccdcb7f..71465b98 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -36,7 +36,7 @@ class DropIn { await sdkVersionNumberProvider.getSdkVersionNumber(); dropInPlatformApi.showDropInSession( - dropInConfiguration.toDTO(sdkVersionNumber), + dropInConfiguration.toDTO(sdkVersionNumber, true), ); dropInFlutterApi.dropInSessionPlatformCommunicationStream = @@ -93,9 +93,13 @@ class DropIn { paymentMethodsResponse, toEncodable: (value) => throw Exception("Could not encode $value"), ); + final isPartialPaymentSupported = advancedCheckout.partialPayment != null; dropInPlatformApi.showDropInAdvanced( - dropInConfiguration.toDTO(sdkVersionNumber), + dropInConfiguration.toDTO( + sdkVersionNumber, + isPartialPaymentSupported, + ), encodedPaymentMethodsResponse, ); @@ -241,7 +245,8 @@ class DropIn { final Map submitDataDecoded = jsonDecode(submitData); switch (advancedCheckout) { case AdvancedCheckout it: - if (submitDataDecoded[Constants.submitDataKey].containsKey("order")) { + if (submitDataDecoded[Constants.submitDataKey] + .containsKey(Constants.orderKey)) { _mapOrderToCompactOrder(submitDataDecoded); } @@ -255,11 +260,13 @@ class DropIn { } } + // iOS provides more fields than needed. Therefore, only the necessary fields are used. void _mapOrderToCompactOrder(Map submitDataDecoded) { - final order = submitDataDecoded[Constants.submitDataKey]["order"]; - submitDataDecoded[Constants.submitDataKey]["order"] = { - "pspReference": order["pspReference"], - "orderData": order["orderData"], + final order = + submitDataDecoded[Constants.submitDataKey][Constants.orderKey]; + submitDataDecoded[Constants.submitDataKey][Constants.orderKey] = { + Constants.pspReferenceKey: order[Constants.pspReferenceKey], + Constants.orderDataKey: order[Constants.orderDataKey], }; } @@ -278,55 +285,55 @@ class DropIn { PlatformCommunicationModel event, PartialPayment? partialPayment, ) async { - if (partialPayment == null) { - //TODO Check with Android to investigate the race condition + try { + final data = jsonDecode(event.data as String); + final Map balanceCheckRequestBody = { + Constants.paymentMethodKey: data[Constants.paymentMethodKey], + Constants.amountKey: data[Constants.amountKey], + }; + final balanceCheckResponse = + await partialPayment?.onCheckBalance(balanceCheckRequestBody); + dropInPlatformApi.onBalanceCheckResult(jsonEncode(balanceCheckResponse)); + } catch (error) { + // This delay is necessary because Android shows the spinner after a short delay. await Future.delayed(const Duration(milliseconds: 300)); dropInPlatformApi.onBalanceCheckResult(""); - throw Exception("Partial payment implementation is not provided."); } - - final data = jsonDecode(event.data as String); - final Map requestBody = { - "paymentMethod": data["paymentMethod"], - "amount": data["amount"], - }; - - final balanceCheckResponse = - await partialPayment.onCheckBalance(requestBody); - dropInPlatformApi.onBalanceCheckResult(jsonEncode(balanceCheckResponse)); } void _handleOrderRequest( PlatformCommunicationModel event, PartialPayment? partialPayment, ) async { - if (partialPayment == null) { - //TODO Check with Android to investigate the race condition + try { + final orderRequestResponse = await partialPayment?.onRequestOrder(); + dropInPlatformApi.onOrderRequestResult(jsonEncode(orderRequestResponse)); + } catch (error) { + // This delay is necessary because Android shows the spinner after a short delay. await Future.delayed(const Duration(milliseconds: 300)); dropInPlatformApi.onOrderRequestResult(""); - throw Exception("Partial payment implementation is not provided."); } - - final orderRequestResponse = await partialPayment.onRequestOrder(); - dropInPlatformApi.onOrderRequestResult(jsonEncode(orderRequestResponse)); } void _handleOrderCancel( PlatformCommunicationModel event, PartialPayment? partialPayment, ) async { - if (partialPayment == null) { + try { + final orderResponse = jsonDecode(event.data as String); + final orderCancelResponse = await partialPayment?.onCancelOrder( + orderResponse[Constants.shouldUpdatePaymentMethodsKey] as bool? ?? + false, + orderResponse[Constants.orderKey], + ); + final orderCancelResponseDTO = orderCancelResponse?.toDTO() ?? + OrderCancelResponseDTO(orderCancelResponseBody: {}); + dropInPlatformApi.onOrderCancelResult(orderCancelResponseDTO); + } catch (error) { + // This delay is necessary because Android shows the spinner after a short delay. + await Future.delayed(const Duration(milliseconds: 300)); dropInPlatformApi.onOrderCancelResult( OrderCancelResponseDTO(orderCancelResponseBody: {})); - throw Exception("Partial payment implementation is not provided."); } - - final orderResponse = jsonDecode(event.data as String); - final orderCancelResponse = await partialPayment.onCancelOrder( - orderResponse["shouldUpdatePaymentMethods"] as bool? ?? false, - orderResponse["order"], - ); - - dropInPlatformApi.onOrderCancelResult(orderCancelResponse.toDTO()); } } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index b5fa400e..83775ec6 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 []; } @@ -220,6 +221,7 @@ class DropInConfigurationDTO { required this.isRemoveStoredPaymentMethodEnabled, this.preselectedPaymentMethodTitle, this.paymentMethodNames, + required this.isPartialPaymentSupported, }); Environment environment; @@ -252,6 +254,8 @@ class DropInConfigurationDTO { Map? paymentMethodNames; + bool isPartialPaymentSupported; + Object encode() { return [ environment.index, @@ -269,6 +273,7 @@ class DropInConfigurationDTO { isRemoveStoredPaymentMethodEnabled, preselectedPaymentMethodTitle, paymentMethodNames, + isPartialPaymentSupported, ]; } @@ -294,12 +299,15 @@ class DropInConfigurationDTO { cashAppPayConfigurationDTO: result[8] != null ? CashAppPayConfigurationDTO.decode(result[8]! as List) : null, - analyticsOptionsDTO: AnalyticsOptionsDTO.decode(result[9]! as List), + analyticsOptionsDTO: + AnalyticsOptionsDTO.decode(result[9]! as List), showPreselectedStoredPaymentMethod: result[10]! as bool, 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, ); } } @@ -354,7 +362,8 @@ class CardConfigurationDTO { showCvcForStoredCard: result[3]! as bool, showCvc: result[4]! as bool, kcpFieldVisibility: FieldVisibility.values[result[5]! as int], - socialSecurityNumberFieldVisibility: FieldVisibility.values[result[6]! as int], + socialSecurityNumberFieldVisibility: + FieldVisibility.values[result[6]! as int], supportedCardTypes: (result[7] as List?)!.cast(), ); } @@ -431,12 +440,15 @@ 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] != null ? ApplePayContactDTO.decode(result[5]! as List) : null, - requiredShippingContactFields: (result[6] as List?)?.cast(), + requiredShippingContactFields: + (result[6] as List?)?.cast(), shippingContact: result[7] != null ? ApplePayContactDTO.decode(result[7]! as List) : null, @@ -444,7 +456,8 @@ class ApplePayConfigurationDTO { ? ApplePayShippingType.values[result[8]! as int] : null, 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] != null @@ -694,9 +707,8 @@ class GooglePayConfigurationDTO { merchantInfoDTO: result[2] != null ? MerchantInfoDTO.decode(result[2]! as List) : null, - totalPriceStatus: result[3] != null - ? TotalPriceStatus.values[result[3]! as int] - : null, + totalPriceStatus: + result[3] != null ? TotalPriceStatus.values[result[3]! as int] : null, allowedCardNetworks: (result[4] as List?)?.cast(), allowedAuthMethods: (result[5] as List?)?.cast(), allowPrepaidCards: result[6] as bool?, @@ -1149,8 +1161,10 @@ class CardComponentConfigurationDTO { ? AmountDTO.decode(result[3]! as List) : null, shopperLocale: result[4] as String?, - cardConfiguration: CardConfigurationDTO.decode(result[5]! as List), - analyticsOptionsDTO: AnalyticsOptionsDTO.decode(result[6]! as List), + cardConfiguration: + CardConfigurationDTO.decode(result[5]! as List), + analyticsOptionsDTO: + AnalyticsOptionsDTO.decode(result[6]! as List), ); } } @@ -1211,7 +1225,8 @@ class InstantPaymentConfigurationDTO { ? AmountDTO.decode(result[4]! as List) : null, shopperLocale: result[5] as String?, - analyticsOptionsDTO: AnalyticsOptionsDTO.decode(result[6]! as List), + analyticsOptionsDTO: + AnalyticsOptionsDTO.decode(result[6]! as List), googlePayConfigurationDTO: result[7] != null ? GooglePayConfigurationDTO.decode(result[7]! as List) : null, @@ -1363,7 +1378,8 @@ class ActionComponentConfigurationDTO { amount: result[3] != null ? AmountDTO.decode(result[3]! as List) : null, - analyticsOptionsDTO: AnalyticsOptionsDTO.decode(result[4]! as List), + analyticsOptionsDTO: + AnalyticsOptionsDTO.decode(result[4]! as List), ); } } @@ -1388,8 +1404,10 @@ class OrderCancelResponseDTO { static OrderCancelResponseDTO decode(Object result) { result as List; return OrderCancelResponseDTO( - orderCancelResponseBody: (result[0] as Map?)!.cast(), - updatedPaymentMethods: (result[1] as Map?)?.cast(), + orderCancelResponseBody: + (result[0] as Map?)!.cast(), + updatedPaymentMethods: + (result[1] as Map?)?.cast(), ); } } @@ -1493,63 +1511,63 @@ class _CheckoutPlatformInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ActionComponentConfigurationDTO.decode(readValue(buffer)!); - case 129: + case 129: return AmountDTO.decode(readValue(buffer)!); - case 130: + case 130: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 131: + case 131: return ApplePayConfigurationDTO.decode(readValue(buffer)!); - case 132: + case 132: return ApplePayContactDTO.decode(readValue(buffer)!); - case 133: + case 133: return ApplePayShippingMethodDTO.decode(readValue(buffer)!); - case 134: + case 134: return ApplePaySummaryItemDTO.decode(readValue(buffer)!); - case 135: + case 135: return BillingAddressParametersDTO.decode(readValue(buffer)!); - case 136: + case 136: return CardComponentConfigurationDTO.decode(readValue(buffer)!); - case 137: + case 137: return CardConfigurationDTO.decode(readValue(buffer)!); - case 138: + case 138: return CashAppPayConfigurationDTO.decode(readValue(buffer)!); - case 139: + case 139: return ComponentCommunicationModel.decode(readValue(buffer)!); - case 140: + case 140: return DeletedStoredPaymentMethodResultDTO.decode(readValue(buffer)!); - case 141: + case 141: return DropInConfigurationDTO.decode(readValue(buffer)!); - case 142: + case 142: return EncryptedCardDTO.decode(readValue(buffer)!); - case 143: + case 143: return ErrorDTO.decode(readValue(buffer)!); - case 144: + case 144: return GooglePayConfigurationDTO.decode(readValue(buffer)!); - case 145: + case 145: return InstantPaymentConfigurationDTO.decode(readValue(buffer)!); - case 146: + case 146: return InstantPaymentSetupResultDTO.decode(readValue(buffer)!); - case 147: + case 147: return MerchantInfoDTO.decode(readValue(buffer)!); - case 148: + case 148: return OrderCancelResponseDTO.decode(readValue(buffer)!); - case 149: + case 149: return OrderResponseDTO.decode(readValue(buffer)!); - case 150: + case 150: return PaymentEventDTO.decode(readValue(buffer)!); - case 151: + case 151: return PaymentResultDTO.decode(readValue(buffer)!); - case 152: + case 152: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 153: + case 153: return PlatformCommunicationModel.decode(readValue(buffer)!); - case 154: + case 154: return SessionDTO.decode(readValue(buffer)!); - case 155: + case 155: return ShippingAddressParametersDTO.decode(readValue(buffer)!); - case 156: + case 156: return UnencryptedCardDTO.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1565,11 +1583,14 @@ class CheckoutPlatformInterface { : __pigeon_binaryMessenger = binaryMessenger; final BinaryMessenger? __pigeon_binaryMessenger; - static const MessageCodec pigeonChannelCodec = _CheckoutPlatformInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = + _CheckoutPlatformInterfaceCodec(); Future getReturnUrl() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.getReturnUrl'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1594,15 +1615,19 @@ class CheckoutPlatformInterface { } } - Future createSession(String sessionId, String sessionData, Object? configuration) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future createSession( + String sessionId, String sessionData, Object? configuration) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.createSession'; + 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) { @@ -1622,8 +1647,10 @@ class CheckoutPlatformInterface { } Future clearSession() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.clearSession'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -1643,15 +1670,18 @@ class CheckoutPlatformInterface { } } - Future encryptCard(UnencryptedCardDTO unencryptedCardDTO, String publicKey) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future encryptCard( + UnencryptedCardDTO unencryptedCardDTO, String publicKey) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptCard'; + 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) { @@ -1671,14 +1701,16 @@ class CheckoutPlatformInterface { } Future encryptBin(String bin, String publicKey) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.encryptBin'; + 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) { @@ -1698,14 +1730,16 @@ class CheckoutPlatformInterface { } Future enableConsoleLogging(bool loggingEnabled) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.enableConsoleLogging'; + 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) { @@ -1786,41 +1820,41 @@ class _DropInPlatformInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return AmountDTO.decode(readValue(buffer)!); - case 129: + case 129: return AmountDTO.decode(readValue(buffer)!); - case 130: + case 130: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 131: + case 131: return ApplePayConfigurationDTO.decode(readValue(buffer)!); - case 132: + case 132: return ApplePayContactDTO.decode(readValue(buffer)!); - case 133: + case 133: return ApplePayShippingMethodDTO.decode(readValue(buffer)!); - case 134: + case 134: return ApplePaySummaryItemDTO.decode(readValue(buffer)!); - case 135: + case 135: return BillingAddressParametersDTO.decode(readValue(buffer)!); - case 136: + case 136: return CardConfigurationDTO.decode(readValue(buffer)!); - case 137: + case 137: return CashAppPayConfigurationDTO.decode(readValue(buffer)!); - case 138: + case 138: return DeletedStoredPaymentMethodResultDTO.decode(readValue(buffer)!); - case 139: + case 139: return DropInConfigurationDTO.decode(readValue(buffer)!); - case 140: + case 140: return ErrorDTO.decode(readValue(buffer)!); - case 141: + case 141: return GooglePayConfigurationDTO.decode(readValue(buffer)!); - case 142: + case 142: return MerchantInfoDTO.decode(readValue(buffer)!); - case 143: + case 143: return OrderCancelResponseDTO.decode(readValue(buffer)!); - case 144: + case 144: return PaymentEventDTO.decode(readValue(buffer)!); - case 145: + case 145: return ShippingAddressParametersDTO.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1836,17 +1870,21 @@ class DropInPlatformInterface { : __pigeon_binaryMessenger = binaryMessenger; final BinaryMessenger? __pigeon_binaryMessenger; - static const MessageCodec pigeonChannelCodec = _DropInPlatformInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = + _DropInPlatformInterfaceCodec(); - Future showDropInSession(DropInConfigurationDTO dropInConfigurationDTO) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future showDropInSession( + DropInConfigurationDTO dropInConfigurationDTO) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInSession'; + 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) { @@ -1860,15 +1898,19 @@ class DropInPlatformInterface { } } - Future showDropInAdvanced(DropInConfigurationDTO dropInConfigurationDTO, String paymentMethodsResponse) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future showDropInAdvanced(DropInConfigurationDTO dropInConfigurationDTO, + String paymentMethodsResponse) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.showDropInAdvanced'; + 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) { @@ -1883,14 +1925,16 @@ class DropInPlatformInterface { } Future onPaymentsResult(PaymentEventDTO paymentsResult) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsResult'; + 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) { @@ -1904,15 +1948,18 @@ class DropInPlatformInterface { } } - Future onPaymentsDetailsResult(PaymentEventDTO paymentsDetailsResult) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onPaymentsDetailsResult( + PaymentEventDTO paymentsDetailsResult) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onPaymentsDetailsResult'; + 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) { @@ -1926,15 +1973,19 @@ class DropInPlatformInterface { } } - Future onDeleteStoredPaymentMethodResult(DeletedStoredPaymentMethodResultDTO deleteStoredPaymentMethodResultDTO) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onDeleteStoredPaymentMethodResult( + DeletedStoredPaymentMethodResultDTO + deleteStoredPaymentMethodResultDTO) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onDeleteStoredPaymentMethodResult'; + 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) { @@ -1949,14 +2000,16 @@ class DropInPlatformInterface { } Future onBalanceCheckResult(String balanceCheckResponse) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onBalanceCheckResult'; + 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) { @@ -1971,14 +2024,16 @@ class DropInPlatformInterface { } Future onOrderRequestResult(String orderRequestResponse) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderRequestResult'; + 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) { @@ -1992,15 +2047,18 @@ class DropInPlatformInterface { } } - Future onOrderCancelResult(OrderCancelResponseDTO orderCancelResponse) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onOrderCancelResult( + OrderCancelResponseDTO orderCancelResponse) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([orderCancelResponse]) as List?; + final List? __pigeon_replyList = await __pigeon_channel + .send([orderCancelResponse]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2015,8 +2073,10 @@ class DropInPlatformInterface { } Future cleanUpDropIn() async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.cleanUpDropIn'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2064,15 +2124,15 @@ class _DropInFlutterInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return AmountDTO.decode(readValue(buffer)!); - case 129: + case 129: return OrderResponseDTO.decode(readValue(buffer)!); - case 130: + case 130: return PaymentResultDTO.decode(readValue(buffer)!); - case 131: + case 131: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 132: + case 132: return PlatformCommunicationModel.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -2081,59 +2141,73 @@ class _DropInFlutterInterfaceCodec extends StandardMessageCodec { } abstract class DropInFlutterInterface { - static const MessageCodec pigeonChannelCodec = _DropInFlutterInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = + _DropInFlutterInterfaceCodec(); - void onDropInSessionPlatformCommunication(PlatformCommunicationModel platformCommunicationModel); + void onDropInSessionPlatformCommunication( + PlatformCommunicationModel platformCommunicationModel); - void onDropInAdvancedPlatformCommunication(PlatformCommunicationModel platformCommunicationModel); + void onDropInAdvancedPlatformCommunication( + PlatformCommunicationModel platformCommunicationModel); - static void setup(DropInFlutterInterface? api, {BinaryMessenger? binaryMessenger}) { + static void setup(DropInFlutterInterface? api, + {BinaryMessenger? binaryMessenger}) { { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInSessionPlatformCommunication', + 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.'); + '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?); + 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!); + 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())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.adyen_checkout.DropInFlutterInterface.onDropInAdvancedPlatformCommunication', + 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.onDropInAdvancedPlatformCommunication 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.'); try { - api.onDropInAdvancedPlatformCommunication(arg_platformCommunicationModel!); + api.onDropInAdvancedPlatformCommunication( + 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())); } }); } @@ -2240,63 +2314,63 @@ class _ComponentPlatformInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ActionComponentConfigurationDTO.decode(readValue(buffer)!); - case 129: + case 129: return AmountDTO.decode(readValue(buffer)!); - case 130: + case 130: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 131: + case 131: return ApplePayConfigurationDTO.decode(readValue(buffer)!); - case 132: + case 132: return ApplePayContactDTO.decode(readValue(buffer)!); - case 133: + case 133: return ApplePayShippingMethodDTO.decode(readValue(buffer)!); - case 134: + case 134: return ApplePaySummaryItemDTO.decode(readValue(buffer)!); - case 135: + case 135: return BillingAddressParametersDTO.decode(readValue(buffer)!); - case 136: + case 136: return CardComponentConfigurationDTO.decode(readValue(buffer)!); - case 137: + case 137: return CardConfigurationDTO.decode(readValue(buffer)!); - case 138: + case 138: return CashAppPayConfigurationDTO.decode(readValue(buffer)!); - case 139: + case 139: return ComponentCommunicationModel.decode(readValue(buffer)!); - case 140: + case 140: return DeletedStoredPaymentMethodResultDTO.decode(readValue(buffer)!); - case 141: + case 141: return DropInConfigurationDTO.decode(readValue(buffer)!); - case 142: + case 142: return EncryptedCardDTO.decode(readValue(buffer)!); - case 143: + case 143: return ErrorDTO.decode(readValue(buffer)!); - case 144: + case 144: return GooglePayConfigurationDTO.decode(readValue(buffer)!); - case 145: + case 145: return InstantPaymentConfigurationDTO.decode(readValue(buffer)!); - case 146: + case 146: return InstantPaymentSetupResultDTO.decode(readValue(buffer)!); - case 147: + case 147: return MerchantInfoDTO.decode(readValue(buffer)!); - case 148: + case 148: return OrderCancelResponseDTO.decode(readValue(buffer)!); - case 149: + case 149: return OrderResponseDTO.decode(readValue(buffer)!); - case 150: + case 150: return PaymentEventDTO.decode(readValue(buffer)!); - case 151: + case 151: return PaymentResultDTO.decode(readValue(buffer)!); - case 152: + case 152: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 153: + case 153: return PlatformCommunicationModel.decode(readValue(buffer)!); - case 154: + case 154: return SessionDTO.decode(readValue(buffer)!); - case 155: + case 155: return ShippingAddressParametersDTO.decode(readValue(buffer)!); - case 156: + case 156: return UnencryptedCardDTO.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -2312,11 +2386,14 @@ class ComponentPlatformInterface { : __pigeon_binaryMessenger = binaryMessenger; final BinaryMessenger? __pigeon_binaryMessenger; - static const MessageCodec pigeonChannelCodec = _ComponentPlatformInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = + _ComponentPlatformInterfaceCodec(); Future updateViewHeight(int viewId) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.updateViewHeight'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2336,15 +2413,18 @@ class ComponentPlatformInterface { } } - Future onPaymentsResult(String componentId, PaymentEventDTO paymentsResult) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onPaymentsResult( + String componentId, PaymentEventDTO paymentsResult) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsResult'; + 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) { @@ -2358,15 +2438,18 @@ class ComponentPlatformInterface { } } - Future onPaymentsDetailsResult(String componentId, PaymentEventDTO paymentsDetailsResult) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onPaymentsDetailsResult( + String componentId, PaymentEventDTO paymentsDetailsResult) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onPaymentsDetailsResult'; + 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) { @@ -2380,15 +2463,24 @@ class ComponentPlatformInterface { } } - Future isInstantPaymentSupportedByPlatform(InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, String paymentMethodResponse, String componentId) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future isInstantPaymentSupportedByPlatform( + InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, + String paymentMethodResponse, + String componentId) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.isInstantPaymentSupportedByPlatform'; + 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) { @@ -2407,15 +2499,24 @@ class ComponentPlatformInterface { } } - Future onInstantPaymentPressed(InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, String encodedPaymentMethod, String componentId) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future onInstantPaymentPressed( + InstantPaymentConfigurationDTO instantPaymentConfigurationDTO, + String encodedPaymentMethod, + String componentId) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onInstantPaymentPressed'; + 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) { @@ -2429,15 +2530,24 @@ class ComponentPlatformInterface { } } - Future handleAction(ActionComponentConfigurationDTO actionComponentConfiguration, String componentId, Map? actionResponse) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + Future handleAction( + ActionComponentConfigurationDTO actionComponentConfiguration, + String componentId, + Map? actionResponse) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.handleAction'; + 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) { @@ -2452,8 +2562,10 @@ class ComponentPlatformInterface { } Future onDispose(String componentId) async { - const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose'; - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( + const String __pigeon_channelName = + 'dev.flutter.pigeon.adyen_checkout.ComponentPlatformInterface.onDispose'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, @@ -2513,23 +2625,23 @@ class _ComponentFlutterInterfaceCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return AmountDTO.decode(readValue(buffer)!); - case 129: + case 129: return AnalyticsOptionsDTO.decode(readValue(buffer)!); - case 130: + case 130: return CardComponentConfigurationDTO.decode(readValue(buffer)!); - case 131: + case 131: return CardConfigurationDTO.decode(readValue(buffer)!); - case 132: + case 132: return ComponentCommunicationModel.decode(readValue(buffer)!); - case 133: + case 133: return OrderResponseDTO.decode(readValue(buffer)!); - case 134: + case 134: return PaymentResultDTO.decode(readValue(buffer)!); - case 135: + case 135: return PaymentResultModelDTO.decode(readValue(buffer)!); - case 136: + case 136: return SessionDTO.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -2538,53 +2650,67 @@ class _ComponentFlutterInterfaceCodec extends StandardMessageCodec { } abstract class ComponentFlutterInterface { - static const MessageCodec pigeonChannelCodec = _ComponentFlutterInterfaceCodec(); + static const MessageCodec pigeonChannelCodec = + _ComponentFlutterInterfaceCodec(); - 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}) { + static void setup(ComponentFlutterInterface? api, + {BinaryMessenger? binaryMessenger}) { { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel( - 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs', + 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', pigeonChannelCodec, + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface.onComponentCommunication', + 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 { @@ -2592,8 +2718,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/lib/src/util/constants.dart b/lib/src/util/constants.dart index 11c99501..b1075cce 100644 --- a/lib/src/util/constants.dart +++ b/lib/src/util/constants.dart @@ -11,4 +11,12 @@ class Constants { static const String componentIdKey = "componentId"; static const String submitDataKey = "data"; static const String submitExtraKey = "extra"; + static const String amountKey = "amount"; + static const String pspReferenceKey = "pspReference"; + static const String orderKey = "order"; + static const String orderDataKey = "orderData"; + static const String orderResponseKey = "orderResponse"; + static const String updatedPaymentMethodsKey = "updatedPaymentMethods"; + static const String shouldUpdatePaymentMethodsKey = + "shouldUpdatePaymentMethods"; } diff --git a/lib/src/util/dto_mapper.dart b/lib/src/util/dto_mapper.dart index c7687451..103365b2 100644 --- a/lib/src/util/dto_mapper.dart +++ b/lib/src/util/dto_mapper.dart @@ -11,27 +11,30 @@ extension AnalyticsOptionsMapper on AnalyticsOptions { } extension DropInConfigurationMapper on DropInConfiguration { - DropInConfigurationDTO toDTO(String sdkVersionNumber) => + DropInConfigurationDTO toDTO( + String sdkVersionNumber, + isPartialPaymentSupported, + ) => DropInConfigurationDTO( - environment: environment, - clientKey: clientKey, - countryCode: countryCode.toUpperCase(), - amount: amount?.toDTO(), - shopperLocale: shopperLocale, - cardConfigurationDTO: cardConfiguration?.toDTO(), - applePayConfigurationDTO: applePayConfiguration?.toDTO(), - googlePayConfigurationDTO: googlePayConfiguration?.toDTO(), - cashAppPayConfigurationDTO: cashAppPayConfiguration?.toDTO(), - analyticsOptionsDTO: analyticsOptions.toDTO(sdkVersionNumber), - isRemoveStoredPaymentMethodEnabled: - _isRemoveStoredPaymentMethodEnabled( - storedPaymentMethodConfiguration), - showPreselectedStoredPaymentMethod: storedPaymentMethodConfiguration - ?.showPreselectedStoredPaymentMethod ?? - true, - skipListWhenSinglePaymentMethod: skipListWhenSinglePaymentMethod, - preselectedPaymentMethodTitle: preselectedPaymentMethodTitle, - paymentMethodNames: paymentMethodNames, + environment: environment, + clientKey: clientKey, + countryCode: countryCode.toUpperCase(), + amount: amount?.toDTO(), + shopperLocale: shopperLocale, + cardConfigurationDTO: cardConfiguration?.toDTO(), + applePayConfigurationDTO: applePayConfiguration?.toDTO(), + googlePayConfigurationDTO: googlePayConfiguration?.toDTO(), + cashAppPayConfigurationDTO: cashAppPayConfiguration?.toDTO(), + analyticsOptionsDTO: analyticsOptions.toDTO(sdkVersionNumber), + isRemoveStoredPaymentMethodEnabled: _isRemoveStoredPaymentMethodEnabled( + storedPaymentMethodConfiguration), + showPreselectedStoredPaymentMethod: storedPaymentMethodConfiguration + ?.showPreselectedStoredPaymentMethod ?? + true, + skipListWhenSinglePaymentMethod: skipListWhenSinglePaymentMethod, + preselectedPaymentMethodTitle: preselectedPaymentMethodTitle, + paymentMethodNames: paymentMethodNames, + isPartialPaymentSupported: isPartialPaymentSupported, ); bool _isRemoveStoredPaymentMethodEnabled( diff --git a/lib/src/util/payment_event_handler.dart b/lib/src/util/payment_event_handler.dart index 098f41be..117d08f7 100644 --- a/lib/src/util/payment_event_handler.dart +++ b/lib/src/util/payment_event_handler.dart @@ -1,5 +1,6 @@ import 'package:adyen_checkout/src/common/model/payment_event.dart'; import 'package:adyen_checkout/src/generated/platform_api.g.dart'; +import 'package:adyen_checkout/src/util/constants.dart'; class PaymentEventHandler { PaymentEventDTO mapToPaymentEventDTO(PaymentEvent paymentEvent) { @@ -23,8 +24,8 @@ class PaymentEventHandler { Update() => PaymentEventDTO( paymentEventType: PaymentEventType.update, data: { - "updatedPaymentMethods": paymentEvent.paymentMethods, - "orderResponse": paymentEvent.orderResponse, + Constants.updatedPaymentMethodsKey: paymentEvent.paymentMethods, + Constants.orderResponseKey: paymentEvent.orderResponse, }, ), }; diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 60928b7f..1d791f96 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -154,6 +154,7 @@ class DropInConfigurationDTO { final bool isRemoveStoredPaymentMethodEnabled; final String? preselectedPaymentMethodTitle; final Map? paymentMethodNames; + final bool isPartialPaymentSupported; DropInConfigurationDTO( this.environment, @@ -171,6 +172,7 @@ class DropInConfigurationDTO { this.isRemoveStoredPaymentMethodEnabled, this.preselectedPaymentMethodTitle, this.paymentMethodNames, + this.isPartialPaymentSupported, ); } diff --git a/test/dto_mapping_test.dart b/test/dto_mapping_test.dart index 56086b2f..725f0695 100644 --- a/test/dto_mapping_test.dart +++ b/test/dto_mapping_test.dart @@ -25,7 +25,7 @@ void main() { shopperLocale: shopperLocal, storedPaymentMethodConfiguration: storedPaymentMethodConfiguration); - final dropInConfigurationDto = dropInConfiguration.toDTO("0.0.1"); + final dropInConfigurationDto = dropInConfiguration.toDTO("0.0.1", true); expect(dropInConfigurationDto.environment, Environment.test); expect(dropInConfigurationDto.clientKey, demoClientKey); @@ -42,6 +42,7 @@ void main() { expect(dropInConfigurationDto.skipListWhenSinglePaymentMethod, false); expect(dropInConfigurationDto.showPreselectedStoredPaymentMethod, true); expect(dropInConfigurationDto.isRemoveStoredPaymentMethodEnabled, true); + expect(dropInConfigurationDto.isPartialPaymentSupported, true); }); test( From 7b686589fc4970e26179a7a091bf38555c9264a4 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 19 Nov 2024 16:41:20 +0100 Subject: [PATCH 06/21] removed error dialogs for android and fixed missing parameter name on iOS --- .../dropIn/advanced/AdvancedDropInService.kt | 24 +++++-------------- ios/Classes/dropIn/DropInPlatformApi.swift | 4 ++-- lib/src/drop_in/drop_in.dart | 4 ++-- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index 3ee54a3f..143f49c3 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -203,9 +203,9 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { // TODO - the error message should be provided by the native SDK RecurringDropInServiceResult.Error( errorDialog = - ErrorDialog( - message = "Removal of the stored payment method failed. Please try again later." - ) + ErrorDialog( + message = "Removal of the stored payment method failed. Please try again later." + ) ) } } @@ -286,11 +286,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { else -> BalanceDropInServiceResult.Error( - errorDialog = - ErrorDialog( - title = resultCode, - message = jsonResponse.optString(Constants.MESSAGE_KEY) ?: "Unknown" - ), + errorDialog = null, dismissDropIn = false ) } @@ -309,11 +305,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { "Success" -> OrderDropInServiceResult.OrderCreated(OrderResponse.SERIALIZER.deserialize(jsonResponse)) else -> OrderDropInServiceResult.Error( - errorDialog = - ErrorDialog( - title = resultCode, - message = jsonResponse.optString(Constants.MESSAGE_KEY) ?: "Unknown" - ), + errorDialog = null, dismissDropIn = false ) } @@ -344,11 +336,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { else -> DropInServiceResult.Error( - errorDialog = - ErrorDialog( - title = resultCode, - message = orderCancelResponseBody?.optString(Constants.MESSAGE_KEY) ?: "Unknown" - ), + errorDialog = null, dismissDropIn = false, ) } diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 7dd5acca..0948ea9a 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -86,10 +86,10 @@ class DropInPlatformApi: DropInPlatformInterface { ) } - let paymentMethodsWithoutGiftCards = removeGiftCardPaymentMethods(paymentMethods: paymentMethods, dropInConfigurationDTO.isPartialPaymentSupported) + let paymentMethodsWithoutGiftCards = removeGiftCardPaymentMethods(paymentMethods: paymentMethods, isPartialPaymentSupported: dropInConfigurationDTO.isPartialPaymentSupported) let configuration = try dropInConfigurationDTO.createDropInConfiguration(payment: adyenContext.payment) let dropInComponent = DropInComponent( - paymentMethods: paymentMethods, + paymentMethods: paymentMethodsWithoutGiftCards, context: adyenContext, configuration: configuration, title: dropInConfigurationDTO.preselectedPaymentMethodTitle diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 71465b98..6115b95d 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -297,7 +297,7 @@ class DropIn { } catch (error) { // This delay is necessary because Android shows the spinner after a short delay. await Future.delayed(const Duration(milliseconds: 300)); - dropInPlatformApi.onBalanceCheckResult(""); + dropInPlatformApi.onBalanceCheckResult(error.toString()); } } @@ -311,7 +311,7 @@ class DropIn { } catch (error) { // This delay is necessary because Android shows the spinner after a short delay. await Future.delayed(const Duration(milliseconds: 300)); - dropInPlatformApi.onOrderRequestResult(""); + dropInPlatformApi.onOrderRequestResult(error.toString()); } } From ee8409c0d67b734c1fb57deed8574435d9659a7f Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 19 Nov 2024 17:13:05 +0100 Subject: [PATCH 07/21] Adjusted tests --- .../flutter/dropIn/advanced/AdvancedDropInService.kt | 6 +++--- example/ios/RunnerTests/RunnerTests.swift | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index 143f49c3..a66a41cf 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -203,9 +203,9 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { // TODO - the error message should be provided by the native SDK RecurringDropInServiceResult.Error( errorDialog = - ErrorDialog( - message = "Removal of the stored payment method failed. Please try again later." - ) + ErrorDialog( + message = "Removal of the stored payment method failed. Please try again later." + ) ) } } diff --git a/example/ios/RunnerTests/RunnerTests.swift b/example/ios/RunnerTests/RunnerTests.swift index 1925abb8..d07880f5 100644 --- a/example/ios/RunnerTests/RunnerTests.swift +++ b/example/ios/RunnerTests/RunnerTests.swift @@ -23,7 +23,8 @@ class RunnerTests: XCTestCase { analyticsOptionsDTO: AnalyticsOptionsDTO(enabled: false, version: "0.0.1"), showPreselectedStoredPaymentMethod: false, skipListWhenSinglePaymentMethod: false, - isRemoveStoredPaymentMethodEnabled: false + isRemoveStoredPaymentMethodEnabled: false, + isPartialPaymentSupported: true ) let adyenContext = try dropInConfigurationDTO.createAdyenContext() From c84e42a66b1ad1c9a2a512517a991ae1d79715b4 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Nov 2024 10:55:24 +0100 Subject: [PATCH 08/21] Fixed failing android test --- .../kotlin/com/adyen/checkout/flutter/ConfigurationMapperTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/android/src/test/kotlin/com/adyen/checkout/flutter/ConfigurationMapperTest.kt b/android/src/test/kotlin/com/adyen/checkout/flutter/ConfigurationMapperTest.kt index 97a8de57..fe99bcbb 100644 --- a/android/src/test/kotlin/com/adyen/checkout/flutter/ConfigurationMapperTest.kt +++ b/android/src/test/kotlin/com/adyen/checkout/flutter/ConfigurationMapperTest.kt @@ -37,6 +37,7 @@ class ConfigurationMapperTest { showPreselectedStoredPaymentMethod = false, skipListWhenSinglePaymentMethod = false, isRemoveStoredPaymentMethodEnabled = false, + isPartialPaymentSupported = true, ) val dropInConfiguration = dropInConfigurationDTO.mapToDropInConfiguration(mockContext) From 2e98c7b89019e877dee588c3168225bef1a66bf1 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Nov 2024 11:55:22 +0100 Subject: [PATCH 09/21] Improved naming --- .../flutter/dropIn/advanced/AdvancedDropInService.kt | 2 +- .../kotlin/com/adyen/checkout/flutter/utils/Constants.kt | 2 -- example/lib/network/service.dart | 2 -- example/lib/repositories/adyen_drop_in_repository.dart | 4 ++-- example/lib/utils/payment_event_handler.dart | 8 ++++---- ios/Classes/dropIn/DropInPlatformApi.swift | 8 ++++---- ios/Classes/utils/Constants.swift | 7 +++---- lib/src/common/model/payment_event.dart | 8 ++++---- lib/src/util/constants.dart | 1 - lib/src/util/payment_event_handler.dart | 4 ++-- 10 files changed, 20 insertions(+), 26 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index a66a41cf..be24a0f9 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -248,7 +248,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { val updatedPaymentMethodsJSON = JSONObject(paymentEventDTO.data[Constants.UPDATED_PAYMENT_METHODS_KEY] as HashMap<*, *>) val orderResponseJSON = - JSONObject(paymentEventDTO.data[Constants.ORDER_RESPONSE_KEY] as HashMap<*, *>) + JSONObject(paymentEventDTO.data[Constants.ORDER_KEY] as HashMap<*, *>) val paymentMethods = PaymentMethodsApiResponse.SERIALIZER.deserialize(updatedPaymentMethodsJSON) val orderResponse = OrderResponse.SERIALIZER.deserialize(orderResponseJSON) DropInServiceResult.Update(paymentMethods, orderResponse) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/utils/Constants.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/utils/Constants.kt index 11465b84..69dfe747 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/utils/Constants.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/utils/Constants.kt @@ -16,10 +16,8 @@ class Constants { const val ADVANCED_PAYMENT_DATA_KEY = "data" const val ADVANCED_EXTRA_DATA_KEY = "extra" const val ORDER_KEY = "order" - const val ORDER_RESPONSE_KEY = "orderResponse" const val SHOULD_UPDATE_PAYMENT_METHODS_KEY = "shouldUpdatePaymentMethods" const val UPDATED_PAYMENT_METHODS_KEY = "updatedPaymentMethods" const val RESULT_CODE_KEY = "resultCode" - const val MESSAGE_KEY = "message" } } diff --git a/example/lib/network/service.dart b/example/lib/network/service.dart index 6b71c7ed..afb7b2af 100644 --- a/example/lib/network/service.dart +++ b/example/lib/network/service.dart @@ -1,7 +1,6 @@ // ignore_for_file: avoid_print import 'dart:convert'; -import 'dart:developer'; import 'package:adyen_checkout/adyen_checkout.dart'; import 'package:adyen_checkout_example/config.dart'; @@ -41,7 +40,6 @@ class Service { body: jsonEncode(body), ); print("PspReference: ${response.headers["pspreference"]}"); - log(response.body); return jsonDecode(response.body); } diff --git a/example/lib/repositories/adyen_drop_in_repository.dart b/example/lib/repositories/adyen_drop_in_repository.dart index cfeb3b75..45bca8eb 100644 --- a/example/lib/repositories/adyen_drop_in_repository.dart +++ b/example/lib/repositories/adyen_drop_in_repository.dart @@ -131,7 +131,7 @@ class AdyenDropInRepository extends AdyenBaseRepository { Future _evaluatePaymentsResponse( Map response) async { if (_hasOrderWithRemainingAmount(response)) { - final Map updatedPaymentMethods = + final Map updatedPaymentMethodsJson = await fetchPaymentMethods( orderResponse: { "pspReference": response["order"]["pspReference"], @@ -140,7 +140,7 @@ class AdyenDropInRepository extends AdyenBaseRepository { ); return paymentEventHandler.handleResponse( jsonResponse: response, - updatedPaymentMethods: updatedPaymentMethods, + updatedPaymentMethodsJson: updatedPaymentMethodsJson, ); } else { return paymentEventHandler.handleResponse(jsonResponse: response); diff --git a/example/lib/utils/payment_event_handler.dart b/example/lib/utils/payment_event_handler.dart index d8ab70cb..2b20c271 100644 --- a/example/lib/utils/payment_event_handler.dart +++ b/example/lib/utils/payment_event_handler.dart @@ -10,7 +10,7 @@ class PaymentEventHandler { PaymentEvent handleResponse({ required Map jsonResponse, - Map updatedPaymentMethods = const {}, + Map updatedPaymentMethodsJson = const {}, }) { if (_isError(jsonResponse)) { return Error( @@ -33,10 +33,10 @@ class PaymentEventHandler { } if (_isNonFullyPaidOrder(jsonResponse) && - updatedPaymentMethods.isNotEmpty) { + updatedPaymentMethodsJson.isNotEmpty) { return Update( - orderResponse: jsonResponse["order"], - paymentMethods: updatedPaymentMethods, + orderJson: jsonResponse["order"], + paymentMethodsJson: updatedPaymentMethodsJson, ); } diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 0948ea9a..3b49b079 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -259,11 +259,11 @@ class DropInPlatformApi: DropInPlatformInterface { private func onDropInResultUpdate(paymentEventDTO: PaymentEventDTO) { do { - guard let updatedPaymentMethods = paymentEventDTO.data?[Constants.updatedPaymentMethodsKey] ?? "" else { + guard let updatedPaymentMethods = paymentEventDTO.data?[Constants.UPDATED_PAYMENT_METHODS_KEY] ?? "" else { throw PlatformError(errorDescription: "Updated payment methods not provided.") } - guard let orderResponse = paymentEventDTO.data?[Constants.orderResponseKey] ?? "" else { + guard let orderResponse = paymentEventDTO.data?[Constants.ORDER_KEY] ?? "" else { throw PlatformError(errorDescription: "Order not provided.") } @@ -366,8 +366,8 @@ extension DropInPlatformApi: PartialPaymentDelegate { func cancelOrder(_ order: Adyen.PartialPaymentOrder, component: any Adyen.Component) { do { let cancelOrderData: [String: Any] = [ - Constants.orderKey: order.jsonObject, - Constants.shouldUpdatePaymentMethodsKey: false + Constants.ORDER_KEY: order.jsonObject, + Constants.SHOULD_UPDATE_PAYMENT_METHODS_KEY: false ] let data = try JSONSerialization.data(withJSONObject: cancelOrderData, options: []) let cancelOrderDataString = String(data: data, encoding: .utf8) diff --git a/ios/Classes/utils/Constants.swift b/ios/Classes/utils/Constants.swift index d73ee00c..1a793807 100644 --- a/ios/Classes/utils/Constants.swift +++ b/ios/Classes/utils/Constants.swift @@ -1,7 +1,6 @@ enum Constants { - static let orderKey = "order" - static let orderResponseKey = "orderResponse" - static let updatedPaymentMethodsKey = "updatedPaymentMethods" - static let shouldUpdatePaymentMethodsKey = "shouldUpdatePaymentMethods" + static let ORDER_KEY = "order" + static let UPDATED_PAYMENT_METHODS_KEY = "updatedPaymentMethods" + static let SHOULD_UPDATE_PAYMENT_METHODS_KEY = "shouldUpdatePaymentMethods" } diff --git a/lib/src/common/model/payment_event.dart b/lib/src/common/model/payment_event.dart index 5585a1f0..da63b7c8 100644 --- a/lib/src/common/model/payment_event.dart +++ b/lib/src/common/model/payment_event.dart @@ -13,12 +13,12 @@ class Action extends PaymentEvent { } class Update extends PaymentEvent { - final Map paymentMethods; - final Map orderResponse; + final Map paymentMethodsJson; + final Map orderJson; Update({ - required this.paymentMethods, - required this.orderResponse, + required this.paymentMethodsJson, + required this.orderJson, }); } diff --git a/lib/src/util/constants.dart b/lib/src/util/constants.dart index b1075cce..9338c80b 100644 --- a/lib/src/util/constants.dart +++ b/lib/src/util/constants.dart @@ -15,7 +15,6 @@ class Constants { static const String pspReferenceKey = "pspReference"; static const String orderKey = "order"; static const String orderDataKey = "orderData"; - static const String orderResponseKey = "orderResponse"; static const String updatedPaymentMethodsKey = "updatedPaymentMethods"; static const String shouldUpdatePaymentMethodsKey = "shouldUpdatePaymentMethods"; diff --git a/lib/src/util/payment_event_handler.dart b/lib/src/util/payment_event_handler.dart index 117d08f7..e9b621ce 100644 --- a/lib/src/util/payment_event_handler.dart +++ b/lib/src/util/payment_event_handler.dart @@ -24,8 +24,8 @@ class PaymentEventHandler { Update() => PaymentEventDTO( paymentEventType: PaymentEventType.update, data: { - Constants.updatedPaymentMethodsKey: paymentEvent.paymentMethods, - Constants.orderResponseKey: paymentEvent.orderResponse, + Constants.updatedPaymentMethodsKey: paymentEvent.paymentMethodsJson, + Constants.orderKey: paymentEvent.orderJson, }, ), }; From 4446cb0dace240835ddc329f38df4691e2dc84ef Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Nov 2024 13:22:51 +0100 Subject: [PATCH 10/21] Renamed OrderCancelResponse into OrderCancelResult and improved parameter names --- .../com/adyen/checkout/flutter/PlatformApi.kt | 37 ++++++++--------- .../flutter/dropIn/DropInPlatformApi.kt | 6 +-- .../dropIn/advanced/AdvancedDropInService.kt | 10 ++--- .../advanced/DropInServiceResultMessenger.kt | 6 +-- .../adyen_drop_in_repository.dart | 14 +++---- ios/Classes/PlatformApi.swift | 40 +++++++++---------- ios/Classes/dropIn/DropInPlatformApi.swift | 2 +- lib/adyen_checkout.dart | 2 +- .../order_cancel_response.dart | 9 ----- .../partial_payment/order_cancel_result.dart | 9 +++++ .../partial_payment/partial_payment.dart | 4 +- lib/src/drop_in/drop_in.dart | 6 +-- lib/src/drop_in/drop_in_platform_api.dart | 3 +- lib/src/generated/platform_api.g.dart | 40 +++++++++---------- lib/src/util/dto_mapper.dart | 12 +++--- pigeons/platform_api.dart | 14 +++---- 16 files changed, 106 insertions(+), 108 deletions(-) delete mode 100644 lib/src/common/model/partial_payment/order_cancel_response.dart create mode 100644 lib/src/common/model/partial_payment/order_cancel_result.dart diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt index 340a2b85..5f25e6a8 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt @@ -317,6 +317,7 @@ data class DropInConfigurationDTO ( val preselectedPaymentMethodTitle: String? = null, val paymentMethodNames: Map? = null, val isPartialPaymentSupported: Boolean + ) { companion object { @Suppress("UNCHECKED_CAST") @@ -1181,23 +1182,23 @@ data class ActionComponentConfigurationDTO ( } /** Generated class from Pigeon that represents data sent in messages. */ -data class OrderCancelResponseDTO ( - val orderCancelResponseBody: Map, - val updatedPaymentMethods: Map? = null +data class OrderCancelResultDTO ( + val orderCancelJson: Map, + val updatedPaymentMethodsJson: Map? = null ) { companion object { @Suppress("UNCHECKED_CAST") - fun fromList(list: List): OrderCancelResponseDTO { - val orderCancelResponseBody = list[0] as Map - val updatedPaymentMethods = list[1] as Map? - return OrderCancelResponseDTO(orderCancelResponseBody, updatedPaymentMethods) + fun fromList(list: List): OrderCancelResultDTO { + val orderCancelJson = list[0] as Map + val updatedPaymentMethodsJson = list[1] as Map? + return OrderCancelResultDTO(orderCancelJson, updatedPaymentMethodsJson) } } fun toList(): List { return listOf( - orderCancelResponseBody, - updatedPaymentMethods, + orderCancelJson, + updatedPaymentMethodsJson, ) } } @@ -1308,7 +1309,7 @@ private object CheckoutPlatformInterfaceCodec : StandardMessageCodec() { } 148.toByte() -> { return (readValue(buffer) as? List)?.let { - OrderCancelResponseDTO.fromList(it) + OrderCancelResultDTO.fromList(it) } } 149.toByte() -> { @@ -1436,7 +1437,7 @@ private object CheckoutPlatformInterfaceCodec : StandardMessageCodec() { stream.write(147) writeValue(stream, value.toList()) } - is OrderCancelResponseDTO -> { + is OrderCancelResultDTO -> { stream.write(148) writeValue(stream, value.toList()) } @@ -1696,7 +1697,7 @@ private object DropInPlatformInterfaceCodec : StandardMessageCodec() { } 143.toByte() -> { return (readValue(buffer) as? List)?.let { - OrderCancelResponseDTO.fromList(it) + OrderCancelResultDTO.fromList(it) } } 144.toByte() -> { @@ -1774,7 +1775,7 @@ private object DropInPlatformInterfaceCodec : StandardMessageCodec() { stream.write(142) writeValue(stream, value.toList()) } - is OrderCancelResponseDTO -> { + is OrderCancelResultDTO -> { stream.write(143) writeValue(stream, value.toList()) } @@ -1800,7 +1801,7 @@ interface DropInPlatformInterface { fun onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) fun onBalanceCheckResult(balanceCheckResponse: String) fun onOrderRequestResult(orderRequestResponse: String) - fun onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) + fun onOrderCancelResult(orderCancelResult: OrderCancelResultDTO) fun cleanUpDropIn() companion object { @@ -1950,10 +1951,10 @@ interface DropInPlatformInterface { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val orderCancelResponseArg = args[0] as OrderCancelResponseDTO + val orderCancelResultArg = args[0] as OrderCancelResultDTO var wrapped: List try { - api.onOrderCancelResult(orderCancelResponseArg) + api.onOrderCancelResult(orderCancelResultArg) wrapped = listOf(null) } catch (exception: Throwable) { wrapped = wrapError(exception) @@ -2191,7 +2192,7 @@ private object ComponentPlatformInterfaceCodec : StandardMessageCodec() { } 148.toByte() -> { return (readValue(buffer) as? List)?.let { - OrderCancelResponseDTO.fromList(it) + OrderCancelResultDTO.fromList(it) } } 149.toByte() -> { @@ -2319,7 +2320,7 @@ private object ComponentPlatformInterfaceCodec : StandardMessageCodec() { stream.write(147) writeValue(stream, value.toList()) } - is OrderCancelResponseDTO -> { + is OrderCancelResultDTO -> { stream.write(148) writeValue(stream, value.toList()) } 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 e6fb1c50..86aadf53 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 @@ -4,7 +4,7 @@ import DeletedStoredPaymentMethodResultDTO import DropInConfigurationDTO import DropInFlutterInterface import DropInPlatformInterface -import OrderCancelResponseDTO +import OrderCancelResultDTO import PaymentEventDTO import PaymentEventType import PaymentResultDTO @@ -134,8 +134,8 @@ class DropInPlatformApi( DropInOrderRequestResultMessenger.sendResult(orderRequestResponse) } - override fun onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) { - DropInOrderCancelResultMessenger.sendResult(orderCancelResponse) + override fun onOrderCancelResult(orderCancelResult: OrderCancelResultDTO) { + DropInOrderCancelResultMessenger.sendResult(orderCancelResult) } override fun cleanUpDropIn() { diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index be24a0f9..4f0946c7 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -2,7 +2,7 @@ package com.adyen.checkout.flutter.dropIn.advanced import DeletedStoredPaymentMethodResultDTO import ErrorDTO -import OrderCancelResponseDTO +import OrderCancelResultDTO import PaymentEventDTO import PaymentEventType import android.content.Intent @@ -318,14 +318,14 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } private fun mapToOrderCancelDropInServiceResult( - orderCancelResponseDTO: OrderCancelResponseDTO? + orderCancelResponseDTO: OrderCancelResultDTO? ): DropInServiceResult? { try { - val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelResponseBody?.let { JSONObject(it) } + val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelJson?.let { JSONObject(it) } return when (val resultCode = orderCancelResponseBody?.optString(Constants.RESULT_CODE_KEY)) { "Received" -> { - if (orderCancelResponseDTO.updatedPaymentMethods?.isNotEmpty() == true) { - val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethods + if (orderCancelResponseDTO.updatedPaymentMethodsJson?.isNotEmpty() == true) { + val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethodsJson val paymentMethods = PaymentMethodsApiResponse.SERIALIZER.deserialize(JSONObject(updatedPaymentMethods)) val orderResponse = OrderResponse.SERIALIZER.deserialize(orderCancelResponseBody) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt index ffec1900..9a596224 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/DropInServiceResultMessenger.kt @@ -1,7 +1,7 @@ package com.adyen.checkout.flutter.dropIn.advanced import DeletedStoredPaymentMethodResultDTO -import OrderCancelResponseDTO +import OrderCancelResultDTO import PaymentEventDTO import androidx.lifecycle.LiveData import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletionModel @@ -149,14 +149,14 @@ class DropInOrderCancelPlatformMessenger : LiveData>() { } } -class DropInOrderCancelResultMessenger : LiveData>() { +class DropInOrderCancelResultMessenger : LiveData>() { companion object { private val dropInOrderCancelResultMessenger = DropInOrderCancelResultMessenger() fun instance() = dropInOrderCancelResultMessenger - fun sendResult(value: OrderCancelResponseDTO) { + fun sendResult(value: OrderCancelResultDTO) { dropInOrderCancelResultMessenger.postValue(Event(value)) } } diff --git a/example/lib/repositories/adyen_drop_in_repository.dart b/example/lib/repositories/adyen_drop_in_repository.dart index 45bca8eb..30a46186 100644 --- a/example/lib/repositories/adyen_drop_in_repository.dart +++ b/example/lib/repositories/adyen_drop_in_repository.dart @@ -184,7 +184,7 @@ class AdyenDropInRepository extends AdyenBaseRepository { return service.postOrders(orderRequestBody); } - Future onCancelOrder( + Future onCancelOrder( bool shouldUpdatePaymentMethods, Map order, ) async { @@ -192,16 +192,16 @@ class AdyenDropInRepository extends AdyenBaseRepository { "merchantAccount": Config.merchantAccount, "order": order, }; - final Map orderCancelResponseBody = + final Map orderCancelJson = await service.postOrdersCancel(orderCancelRequestBody); - final OrderCancelResponse orderCancelResponse = - OrderCancelResponse(orderCancelResponseBody: orderCancelResponseBody); + final OrderCancelResult orderCancelResult = + OrderCancelResult(orderCancelJson: orderCancelJson); if (shouldUpdatePaymentMethods == true) { - final paymentMethods = await fetchPaymentMethods(); - orderCancelResponse.updatedPaymentMethods = paymentMethods; + final paymentMethodsJson = await fetchPaymentMethods(); + orderCancelResult.updatedPaymentMethodsJson = paymentMethodsJson; } - return orderCancelResponse; + return orderCancelResult; } bool _hasOrderWithRemainingAmount(jsonResponse) { diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index 75950c6b..6bcc7a08 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -1241,24 +1241,24 @@ struct ActionComponentConfigurationDTO { } /// Generated class from Pigeon that represents data sent in messages. -struct OrderCancelResponseDTO { - var orderCancelResponseBody: [String?: Any?] - var updatedPaymentMethods: [String?: Any?]? +struct OrderCancelResultDTO { + var orderCancelJson: [String?: Any?] + var updatedPaymentMethodsJson: [String?: Any?]? - static func fromList(_ list: [Any?]) -> OrderCancelResponseDTO? { - let orderCancelResponseBody = list[0] as! [String?: Any?] - let updatedPaymentMethods: [String?: Any?]? = nilOrValue(list[1]) + static func fromList(_ list: [Any?]) -> OrderCancelResultDTO? { + let orderCancelJson = list[0] as! [String?: Any?] + let updatedPaymentMethodsJson: [String?: Any?]? = nilOrValue(list[1]) - return OrderCancelResponseDTO( - orderCancelResponseBody: orderCancelResponseBody, - updatedPaymentMethods: updatedPaymentMethods + return OrderCancelResultDTO( + orderCancelJson: orderCancelJson, + updatedPaymentMethodsJson: updatedPaymentMethodsJson ) } func toList() -> [Any?] { [ - orderCancelResponseBody, - updatedPaymentMethods + orderCancelJson, + updatedPaymentMethodsJson ] } } @@ -1307,7 +1307,7 @@ private class CheckoutPlatformInterfaceCodecReader: FlutterStandardReader { case 147: return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) case 148: - return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) + return OrderCancelResultDTO.fromList(self.readValue() as! [Any?]) case 149: return OrderResponseDTO.fromList(self.readValue() as! [Any?]) case 150: @@ -1392,7 +1392,7 @@ private class CheckoutPlatformInterfaceCodecWriter: FlutterStandardWriter { } else if let value = value as? MerchantInfoDTO { super.writeByte(147) super.writeValue(value.toList()) - } else if let value = value as? OrderCancelResponseDTO { + } else if let value = value as? OrderCancelResultDTO { super.writeByte(148) super.writeValue(value.toList()) } else if let value = value as? OrderResponseDTO { @@ -1590,7 +1590,7 @@ private class DropInPlatformInterfaceCodecReader: FlutterStandardReader { case 142: return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) case 143: - return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) + return OrderCancelResultDTO.fromList(self.readValue() as! [Any?]) case 144: return PaymentEventDTO.fromList(self.readValue() as! [Any?]) case 145: @@ -1648,7 +1648,7 @@ private class DropInPlatformInterfaceCodecWriter: FlutterStandardWriter { } else if let value = value as? MerchantInfoDTO { super.writeByte(142) super.writeValue(value.toList()) - } else if let value = value as? OrderCancelResponseDTO { + } else if let value = value as? OrderCancelResultDTO { super.writeByte(143) super.writeValue(value.toList()) } else if let value = value as? PaymentEventDTO { @@ -1686,7 +1686,7 @@ protocol DropInPlatformInterface { func onDeleteStoredPaymentMethodResult(deleteStoredPaymentMethodResultDTO: DeletedStoredPaymentMethodResultDTO) throws func onBalanceCheckResult(balanceCheckResponse: String) throws func onOrderRequestResult(orderRequestResponse: String) throws - func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws + func onOrderCancelResult(orderCancelResult: OrderCancelResultDTO) throws func cleanUpDropIn() throws } @@ -1806,9 +1806,9 @@ class DropInPlatformInterfaceSetup { if let api { onOrderCancelResultChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let orderCancelResponseArg = args[0] as! OrderCancelResponseDTO + let orderCancelResultArg = args[0] as! OrderCancelResultDTO do { - try api.onOrderCancelResult(orderCancelResponse: orderCancelResponseArg) + try api.onOrderCancelResult(orderCancelResult: orderCancelResultArg) reply(wrapResult(nil)) } catch { reply(wrapError(error)) @@ -1988,7 +1988,7 @@ private class ComponentPlatformInterfaceCodecReader: FlutterStandardReader { case 147: return MerchantInfoDTO.fromList(self.readValue() as! [Any?]) case 148: - return OrderCancelResponseDTO.fromList(self.readValue() as! [Any?]) + return OrderCancelResultDTO.fromList(self.readValue() as! [Any?]) case 149: return OrderResponseDTO.fromList(self.readValue() as! [Any?]) case 150: @@ -2073,7 +2073,7 @@ private class ComponentPlatformInterfaceCodecWriter: FlutterStandardWriter { } else if let value = value as? MerchantInfoDTO { super.writeByte(147) super.writeValue(value.toList()) - } else if let value = value as? OrderCancelResponseDTO { + } else if let value = value as? OrderCancelResultDTO { super.writeByte(148) super.writeValue(value.toList()) } else if let value = value as? OrderResponseDTO { diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 3b49b079..1f411026 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -162,7 +162,7 @@ class DropInPlatformApi: DropInPlatformInterface { } } - func onOrderCancelResult(orderCancelResponse: OrderCancelResponseDTO) throws {} + func onOrderCancelResult(orderCancelResult: OrderCancelResultDTO) throws {} func cleanUpDropIn() { sessionHolder.reset() diff --git a/lib/adyen_checkout.dart b/lib/adyen_checkout.dart index 5335de90..f14b95be 100644 --- a/lib/adyen_checkout.dart +++ b/lib/adyen_checkout.dart @@ -5,7 +5,7 @@ export 'src/common/model/checkout.dart'; export 'src/common/model/cse/encrypted_card.dart'; export 'src/common/model/cse/unencrypted_card.dart'; export 'src/common/model/order_response.dart'; -export 'src/common/model/partial_payment/order_cancel_response.dart'; +export 'src/common/model/partial_payment/order_cancel_result.dart'; export 'src/common/model/partial_payment/partial_payment.dart'; export 'src/common/model/payment_event.dart'; export 'src/common/model/payment_method_configurations/apple_pay/apple_pay_configuration.dart'; diff --git a/lib/src/common/model/partial_payment/order_cancel_response.dart b/lib/src/common/model/partial_payment/order_cancel_response.dart deleted file mode 100644 index ba477625..00000000 --- a/lib/src/common/model/partial_payment/order_cancel_response.dart +++ /dev/null @@ -1,9 +0,0 @@ -class OrderCancelResponse { - final Map orderCancelResponseBody; - Map? updatedPaymentMethods; - - OrderCancelResponse({ - required this.orderCancelResponseBody, - this.updatedPaymentMethods, - }); -} diff --git a/lib/src/common/model/partial_payment/order_cancel_result.dart b/lib/src/common/model/partial_payment/order_cancel_result.dart new file mode 100644 index 00000000..72029f0b --- /dev/null +++ b/lib/src/common/model/partial_payment/order_cancel_result.dart @@ -0,0 +1,9 @@ +class OrderCancelResult { + final Map orderCancelJson; + Map? updatedPaymentMethodsJson; + + OrderCancelResult({ + required this.orderCancelJson, + this.updatedPaymentMethodsJson, + }); +} diff --git a/lib/src/common/model/partial_payment/partial_payment.dart b/lib/src/common/model/partial_payment/partial_payment.dart index 4fb248cd..ea218f3f 100644 --- a/lib/src/common/model/partial_payment/partial_payment.dart +++ b/lib/src/common/model/partial_payment/partial_payment.dart @@ -1,10 +1,10 @@ -import 'package:adyen_checkout/src/common/model/partial_payment/order_cancel_response.dart'; +import 'package:adyen_checkout/src/common/model/partial_payment/order_cancel_result.dart'; class PartialPayment { Future> Function(Map requestBody) onCheckBalance; Future> Function() onRequestOrder; - Future Function( + Future Function( bool shouldUpdatePaymentMethods, Map order, ) onCancelOrder; diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 6115b95d..7136b81d 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -327,13 +327,13 @@ class DropIn { orderResponse[Constants.orderKey], ); final orderCancelResponseDTO = orderCancelResponse?.toDTO() ?? - OrderCancelResponseDTO(orderCancelResponseBody: {}); + OrderCancelResultDTO(orderCancelJson: {}); dropInPlatformApi.onOrderCancelResult(orderCancelResponseDTO); } catch (error) { // This delay is necessary because Android shows the spinner after a short delay. await Future.delayed(const Duration(milliseconds: 300)); - dropInPlatformApi.onOrderCancelResult( - OrderCancelResponseDTO(orderCancelResponseBody: {})); + dropInPlatformApi + .onOrderCancelResult(OrderCancelResultDTO(orderCancelJson: {})); } } } diff --git a/lib/src/drop_in/drop_in_platform_api.dart b/lib/src/drop_in/drop_in_platform_api.dart index 8618ef56..74609c61 100644 --- a/lib/src/drop_in/drop_in_platform_api.dart +++ b/lib/src/drop_in/drop_in_platform_api.dart @@ -47,7 +47,6 @@ class DropInPlatformApi implements DropInPlatformInterface { _dropInPlatformInterface.onOrderRequestResult(orderRequestResponse); @override - Future onOrderCancelResult( - OrderCancelResponseDTO orderCancelResponse) => + Future onOrderCancelResult(OrderCancelResultDTO orderCancelResponse) => _dropInPlatformInterface.onOrderCancelResult(orderCancelResponse); } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index 83775ec6..dd970840 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -1384,29 +1384,29 @@ class ActionComponentConfigurationDTO { } } -class OrderCancelResponseDTO { - OrderCancelResponseDTO({ - required this.orderCancelResponseBody, - this.updatedPaymentMethods, +class OrderCancelResultDTO { + OrderCancelResultDTO({ + required this.orderCancelJson, + this.updatedPaymentMethodsJson, }); - Map orderCancelResponseBody; + Map orderCancelJson; - Map? updatedPaymentMethods; + Map? updatedPaymentMethodsJson; Object encode() { return [ - orderCancelResponseBody, - updatedPaymentMethods, + orderCancelJson, + updatedPaymentMethodsJson, ]; } - static OrderCancelResponseDTO decode(Object result) { + static OrderCancelResultDTO decode(Object result) { result as List; - return OrderCancelResponseDTO( - orderCancelResponseBody: + return OrderCancelResultDTO( + orderCancelJson: (result[0] as Map?)!.cast(), - updatedPaymentMethods: + updatedPaymentMethodsJson: (result[1] as Map?)?.cast(), ); } @@ -1476,7 +1476,7 @@ class _CheckoutPlatformInterfaceCodec extends StandardMessageCodec { } else if (value is MerchantInfoDTO) { buffer.putUint8(147); writeValue(buffer, value.encode()); - } else if (value is OrderCancelResponseDTO) { + } else if (value is OrderCancelResultDTO) { buffer.putUint8(148); writeValue(buffer, value.encode()); } else if (value is OrderResponseDTO) { @@ -1552,7 +1552,7 @@ class _CheckoutPlatformInterfaceCodec extends StandardMessageCodec { case 147: return MerchantInfoDTO.decode(readValue(buffer)!); case 148: - return OrderCancelResponseDTO.decode(readValue(buffer)!); + return OrderCancelResultDTO.decode(readValue(buffer)!); case 149: return OrderResponseDTO.decode(readValue(buffer)!); case 150: @@ -1803,7 +1803,7 @@ class _DropInPlatformInterfaceCodec extends StandardMessageCodec { } else if (value is MerchantInfoDTO) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is OrderCancelResponseDTO) { + } else if (value is OrderCancelResultDTO) { buffer.putUint8(143); writeValue(buffer, value.encode()); } else if (value is PaymentEventDTO) { @@ -1851,7 +1851,7 @@ class _DropInPlatformInterfaceCodec extends StandardMessageCodec { case 142: return MerchantInfoDTO.decode(readValue(buffer)!); case 143: - return OrderCancelResponseDTO.decode(readValue(buffer)!); + return OrderCancelResultDTO.decode(readValue(buffer)!); case 144: return PaymentEventDTO.decode(readValue(buffer)!); case 145: @@ -2048,7 +2048,7 @@ class DropInPlatformInterface { } Future onOrderCancelResult( - OrderCancelResponseDTO orderCancelResponse) async { + OrderCancelResultDTO orderCancelResult) async { const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult'; final BasicMessageChannel __pigeon_channel = @@ -2058,7 +2058,7 @@ class DropInPlatformInterface { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = await __pigeon_channel - .send([orderCancelResponse]) as List?; + .send([orderCancelResult]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2279,7 +2279,7 @@ class _ComponentPlatformInterfaceCodec extends StandardMessageCodec { } else if (value is MerchantInfoDTO) { buffer.putUint8(147); writeValue(buffer, value.encode()); - } else if (value is OrderCancelResponseDTO) { + } else if (value is OrderCancelResultDTO) { buffer.putUint8(148); writeValue(buffer, value.encode()); } else if (value is OrderResponseDTO) { @@ -2355,7 +2355,7 @@ class _ComponentPlatformInterfaceCodec extends StandardMessageCodec { case 147: return MerchantInfoDTO.decode(readValue(buffer)!); case 148: - return OrderCancelResponseDTO.decode(readValue(buffer)!); + return OrderCancelResultDTO.decode(readValue(buffer)!); case 149: return OrderResponseDTO.decode(readValue(buffer)!); case 150: diff --git a/lib/src/util/dto_mapper.dart b/lib/src/util/dto_mapper.dart index 103365b2..82223bbb 100644 --- a/lib/src/util/dto_mapper.dart +++ b/lib/src/util/dto_mapper.dart @@ -307,11 +307,9 @@ extension ActionComponentConfigurationMapper on ActionComponentConfiguration { ); } -extension OrderCancelResponseMapper on OrderCancelResponse { - OrderCancelResponseDTO toDTO() { - return OrderCancelResponseDTO( - orderCancelResponseBody: orderCancelResponseBody, - updatedPaymentMethods: updatedPaymentMethods, - ); - } +extension OrderCancelResponseMapper on OrderCancelResult { + OrderCancelResultDTO toDTO() => OrderCancelResultDTO( + orderCancelJson: orderCancelJson, + updatedPaymentMethodsJson: updatedPaymentMethodsJson, + ); } diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 1d791f96..306f0966 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -576,13 +576,13 @@ class ActionComponentConfigurationDTO { ); } -class OrderCancelResponseDTO { - final Map orderCancelResponseBody; - final Map? updatedPaymentMethods; +class OrderCancelResultDTO { + final Map orderCancelJson; + final Map? updatedPaymentMethodsJson; - OrderCancelResponseDTO( - this.orderCancelResponseBody, - this.updatedPaymentMethods, + OrderCancelResultDTO( + this.orderCancelJson, + this.updatedPaymentMethodsJson, ); } @@ -635,7 +635,7 @@ abstract class DropInPlatformInterface { void onOrderRequestResult(String orderRequestResponse); - void onOrderCancelResult(OrderCancelResponseDTO orderCancelResponse); + void onOrderCancelResult(OrderCancelResultDTO orderCancelResult); void cleanUpDropIn(); } From 86cc0f5a655aedc857d2fe61b3e1351eab8ee6d4 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Nov 2024 13:37:02 +0100 Subject: [PATCH 11/21] Added delay on Android layer until SDK update is available --- .../dropIn/advanced/AdvancedDropInService.kt | 18 +++++++++++++++--- example/ios/Runner/AppDelegate.swift | 4 ++-- lib/src/drop_in/drop_in.dart | 6 ------ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index 4f0946c7..e1a77bea 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -10,6 +10,7 @@ import android.os.IBinder import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ServiceLifecycleDispatcher +import androidx.lifecycle.lifecycleScope import com.adyen.checkout.components.core.ActionComponentData import com.adyen.checkout.components.core.BalanceResult import com.adyen.checkout.components.core.Order @@ -29,6 +30,8 @@ import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletion import com.adyen.checkout.flutter.dropIn.model.DropInType import com.adyen.checkout.flutter.utils.Constants import com.adyen.checkout.googlepay.GooglePayComponentState +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch import org.json.JSONObject class AdvancedDropInService : DropInService(), LifecycleOwner { @@ -166,7 +169,10 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } val balanceResult = mapToBalanceDropInServiceResult(message.contentIfNotHandled as String) - sendBalanceResult(balanceResult) + lifecycleScope.launch { + delay(300) + sendBalanceResult(balanceResult) + } } } @@ -178,7 +184,10 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } val orderResult = mapToOrderDropInServiceResult(message.contentIfNotHandled as String) - sendOrderResult(orderResult) + lifecycleScope.launch { + delay(300) + sendOrderResult(orderResult) + } } } @@ -190,7 +199,10 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } val orderResult = mapToOrderCancelDropInServiceResult(message.contentIfNotHandled) ?: return@observe - sendResult(orderResult) + lifecycleScope.launch { + delay(300) + sendResult(orderResult) + } } } diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index d6ef9906..9b5768e9 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -19,14 +19,14 @@ import UIKit RedirectComponent.applicationDidOpen(from: url) return true } - + private func setDropInStyle() { var dropInStyle = Adyen.DropInComponent.Style() dropInStyle.formComponent.mainButtonItem.button.backgroundColor = .black dropInStyle.formComponent.mainButtonItem.button.title.color = .white AdyenAppearance.dropInStyle = dropInStyle } - + private func setCardComponentStyle() { var cardComponentStyle = Adyen.FormComponentStyle() cardComponentStyle.mainButtonItem.button.backgroundColor = .black diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 7136b81d..f3be6159 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -295,8 +295,6 @@ class DropIn { await partialPayment?.onCheckBalance(balanceCheckRequestBody); dropInPlatformApi.onBalanceCheckResult(jsonEncode(balanceCheckResponse)); } catch (error) { - // This delay is necessary because Android shows the spinner after a short delay. - await Future.delayed(const Duration(milliseconds: 300)); dropInPlatformApi.onBalanceCheckResult(error.toString()); } } @@ -309,8 +307,6 @@ class DropIn { final orderRequestResponse = await partialPayment?.onRequestOrder(); dropInPlatformApi.onOrderRequestResult(jsonEncode(orderRequestResponse)); } catch (error) { - // This delay is necessary because Android shows the spinner after a short delay. - await Future.delayed(const Duration(milliseconds: 300)); dropInPlatformApi.onOrderRequestResult(error.toString()); } } @@ -330,8 +326,6 @@ class DropIn { OrderCancelResultDTO(orderCancelJson: {}); dropInPlatformApi.onOrderCancelResult(orderCancelResponseDTO); } catch (error) { - // This delay is necessary because Android shows the spinner after a short delay. - await Future.delayed(const Duration(milliseconds: 300)); dropInPlatformApi .onOrderCancelResult(OrderCancelResultDTO(orderCancelJson: {})); } From 6b0b95690f39c5c454fa49061b753210656b2d5b Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Nov 2024 14:01:22 +0100 Subject: [PATCH 12/21] Changed constant names to camelCase --- ios/Classes/dropIn/DropInPlatformApi.swift | 8 ++++---- ios/Classes/utils/Constants.swift | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 1f411026..54ae6ce9 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -259,11 +259,11 @@ class DropInPlatformApi: DropInPlatformInterface { private func onDropInResultUpdate(paymentEventDTO: PaymentEventDTO) { do { - guard let updatedPaymentMethods = paymentEventDTO.data?[Constants.UPDATED_PAYMENT_METHODS_KEY] ?? "" else { + guard let updatedPaymentMethods = paymentEventDTO.data?[Constants.updatedPaymentMethodsKey] ?? "" else { throw PlatformError(errorDescription: "Updated payment methods not provided.") } - guard let orderResponse = paymentEventDTO.data?[Constants.ORDER_KEY] ?? "" else { + guard let orderResponse = paymentEventDTO.data?[Constants.orderKey] ?? "" else { throw PlatformError(errorDescription: "Order not provided.") } @@ -366,8 +366,8 @@ extension DropInPlatformApi: PartialPaymentDelegate { func cancelOrder(_ order: Adyen.PartialPaymentOrder, component: any Adyen.Component) { do { let cancelOrderData: [String: Any] = [ - Constants.ORDER_KEY: order.jsonObject, - Constants.SHOULD_UPDATE_PAYMENT_METHODS_KEY: false + Constants.orderKey: order.jsonObject, + Constants.shouldUpdatePaymentMethodsKey: false ] let data = try JSONSerialization.data(withJSONObject: cancelOrderData, options: []) let cancelOrderDataString = String(data: data, encoding: .utf8) diff --git a/ios/Classes/utils/Constants.swift b/ios/Classes/utils/Constants.swift index 1a793807..3511af02 100644 --- a/ios/Classes/utils/Constants.swift +++ b/ios/Classes/utils/Constants.swift @@ -1,6 +1,6 @@ enum Constants { - static let ORDER_KEY = "order" - static let UPDATED_PAYMENT_METHODS_KEY = "updatedPaymentMethods" - static let SHOULD_UPDATE_PAYMENT_METHODS_KEY = "shouldUpdatePaymentMethods" + static let orderKey = "order" + static let updatedPaymentMethodsKey = "updatedPaymentMethods" + static let shouldUpdatePaymentMethodsKey = "shouldUpdatePaymentMethods" } From c2d93ebfa038877d8512bc01ad7cd075a06aaf87 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 21 Nov 2024 16:01:44 +0100 Subject: [PATCH 13/21] Improved naming of orderCancelResult class properties --- .../com/adyen/checkout/flutter/PlatformApi.kt | 14 +++++------ .../dropIn/advanced/AdvancedDropInService.kt | 6 ++--- .../adyen_drop_in_repository.dart | 25 ++++++++++--------- ios/Classes/PlatformApi.swift | 16 ++++++------ .../partial_payment/order_cancel_result.dart | 8 +++--- .../partial_payment/partial_payment.dart | 15 ++++++----- lib/src/drop_in/drop_in.dart | 17 +++++++------ lib/src/generated/platform_api.g.dart | 16 ++++++------ lib/src/util/dto_mapper.dart | 4 +-- pigeons/platform_api.dart | 8 +++--- 10 files changed, 67 insertions(+), 62 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt index 5f25e6a8..24c7a6e2 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt @@ -1183,22 +1183,22 @@ data class ActionComponentConfigurationDTO ( /** Generated class from Pigeon that represents data sent in messages. */ data class OrderCancelResultDTO ( - val orderCancelJson: Map, - val updatedPaymentMethodsJson: Map? = null + val orderCancelResponseBody: Map, + val updatedPaymentMethodsResponseBody: Map? = null ) { companion object { @Suppress("UNCHECKED_CAST") fun fromList(list: List): OrderCancelResultDTO { - val orderCancelJson = list[0] as Map - val updatedPaymentMethodsJson = list[1] as Map? - return OrderCancelResultDTO(orderCancelJson, updatedPaymentMethodsJson) + val orderCancelResponseBody = list[0] as Map + val updatedPaymentMethodsResponseBody = list[1] as Map? + return OrderCancelResultDTO(orderCancelResponseBody, updatedPaymentMethodsResponseBody) } } fun toList(): List { return listOf( - orderCancelJson, - updatedPaymentMethodsJson, + orderCancelResponseBody, + updatedPaymentMethodsResponseBody, ) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index e1a77bea..cb958fe1 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -333,11 +333,11 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { orderCancelResponseDTO: OrderCancelResultDTO? ): DropInServiceResult? { try { - val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelJson?.let { JSONObject(it) } + val orderCancelResponseBody = orderCancelResponseDTO?.orderCancelResponseBody?.let { JSONObject(it) } return when (val resultCode = orderCancelResponseBody?.optString(Constants.RESULT_CODE_KEY)) { "Received" -> { - if (orderCancelResponseDTO.updatedPaymentMethodsJson?.isNotEmpty() == true) { - val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethodsJson + if (orderCancelResponseDTO.updatedPaymentMethodsResponseBody?.isNotEmpty() == true) { + val updatedPaymentMethods = orderCancelResponseDTO.updatedPaymentMethodsResponseBody val paymentMethods = PaymentMethodsApiResponse.SERIALIZER.deserialize(JSONObject(updatedPaymentMethods)) val orderResponse = OrderResponse.SERIALIZER.deserialize(orderCancelResponseBody) diff --git a/example/lib/repositories/adyen_drop_in_repository.dart b/example/lib/repositories/adyen_drop_in_repository.dart index 30a46186..364c8099 100644 --- a/example/lib/repositories/adyen_drop_in_repository.dart +++ b/example/lib/repositories/adyen_drop_in_repository.dart @@ -166,10 +166,11 @@ class AdyenDropInRepository extends AdyenBaseRepository { ); } - Future> onCheckBalance( - Map balanceRequestBody) async { - balanceRequestBody.addAll({"merchantAccount": Config.merchantAccount}); - return service.postPaymentMethodsBalance(balanceRequestBody); + Future> onCheckBalance({ + required Map balanceCheckRequestBody, + }) async { + balanceCheckRequestBody.addAll({"merchantAccount": Config.merchantAccount}); + return service.postPaymentMethodsBalance(balanceCheckRequestBody); } Future> onRequestOrder() async { @@ -184,21 +185,21 @@ class AdyenDropInRepository extends AdyenBaseRepository { return service.postOrders(orderRequestBody); } - Future onCancelOrder( - bool shouldUpdatePaymentMethods, - Map order, - ) async { + Future onCancelOrder({ + required bool shouldUpdatePaymentMethods, + required Map order, + }) async { final orderCancelRequestBody = { "merchantAccount": Config.merchantAccount, "order": order, }; - final Map orderCancelJson = + final Map cancelResponse = await service.postOrdersCancel(orderCancelRequestBody); final OrderCancelResult orderCancelResult = - OrderCancelResult(orderCancelJson: orderCancelJson); + OrderCancelResult(orderCancelResponseBody: cancelResponse); if (shouldUpdatePaymentMethods == true) { - final paymentMethodsJson = await fetchPaymentMethods(); - orderCancelResult.updatedPaymentMethodsJson = paymentMethodsJson; + orderCancelResult.updatedPaymentMethodsResponseBody = + await fetchPaymentMethods(); } return orderCancelResult; diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index 6bcc7a08..b25e7342 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -1242,23 +1242,23 @@ struct ActionComponentConfigurationDTO { /// Generated class from Pigeon that represents data sent in messages. struct OrderCancelResultDTO { - var orderCancelJson: [String?: Any?] - var updatedPaymentMethodsJson: [String?: Any?]? + var orderCancelResponseBody: [String?: Any?] + var updatedPaymentMethodsResponseBody: [String?: Any?]? static func fromList(_ list: [Any?]) -> OrderCancelResultDTO? { - let orderCancelJson = list[0] as! [String?: Any?] - let updatedPaymentMethodsJson: [String?: Any?]? = nilOrValue(list[1]) + let orderCancelResponseBody = list[0] as! [String?: Any?] + let updatedPaymentMethodsResponseBody: [String?: Any?]? = nilOrValue(list[1]) return OrderCancelResultDTO( - orderCancelJson: orderCancelJson, - updatedPaymentMethodsJson: updatedPaymentMethodsJson + orderCancelResponseBody: orderCancelResponseBody, + updatedPaymentMethodsResponseBody: updatedPaymentMethodsResponseBody ) } func toList() -> [Any?] { [ - orderCancelJson, - updatedPaymentMethodsJson + orderCancelResponseBody, + updatedPaymentMethodsResponseBody ] } } diff --git a/lib/src/common/model/partial_payment/order_cancel_result.dart b/lib/src/common/model/partial_payment/order_cancel_result.dart index 72029f0b..355e805f 100644 --- a/lib/src/common/model/partial_payment/order_cancel_result.dart +++ b/lib/src/common/model/partial_payment/order_cancel_result.dart @@ -1,9 +1,9 @@ class OrderCancelResult { - final Map orderCancelJson; - Map? updatedPaymentMethodsJson; + final Map orderCancelResponseBody; + Map? updatedPaymentMethodsResponseBody; OrderCancelResult({ - required this.orderCancelJson, - this.updatedPaymentMethodsJson, + required this.orderCancelResponseBody, + this.updatedPaymentMethodsResponseBody, }); } diff --git a/lib/src/common/model/partial_payment/partial_payment.dart b/lib/src/common/model/partial_payment/partial_payment.dart index ea218f3f..52208759 100644 --- a/lib/src/common/model/partial_payment/partial_payment.dart +++ b/lib/src/common/model/partial_payment/partial_payment.dart @@ -1,13 +1,16 @@ import 'package:adyen_checkout/src/common/model/partial_payment/order_cancel_result.dart'; class PartialPayment { - Future> Function(Map requestBody) - onCheckBalance; + Future> Function({ + required Map balanceCheckRequestBody, + }) onCheckBalance; + Future> Function() onRequestOrder; - Future Function( - bool shouldUpdatePaymentMethods, - Map order, - ) onCancelOrder; + + Future Function({ + required bool shouldUpdatePaymentMethods, + required Map order, + }) onCancelOrder; PartialPayment({ required this.onCheckBalance, diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index f3be6159..f1d5e91f 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -291,8 +291,8 @@ class DropIn { Constants.paymentMethodKey: data[Constants.paymentMethodKey], Constants.amountKey: data[Constants.amountKey], }; - final balanceCheckResponse = - await partialPayment?.onCheckBalance(balanceCheckRequestBody); + final balanceCheckResponse = await partialPayment?.onCheckBalance( + balanceCheckRequestBody: balanceCheckRequestBody); dropInPlatformApi.onBalanceCheckResult(jsonEncode(balanceCheckResponse)); } catch (error) { dropInPlatformApi.onBalanceCheckResult(error.toString()); @@ -318,16 +318,17 @@ class DropIn { try { final orderResponse = jsonDecode(event.data as String); final orderCancelResponse = await partialPayment?.onCancelOrder( - orderResponse[Constants.shouldUpdatePaymentMethodsKey] as bool? ?? - false, - orderResponse[Constants.orderKey], + shouldUpdatePaymentMethods: + orderResponse[Constants.shouldUpdatePaymentMethodsKey] as bool? ?? + false, + order: orderResponse[Constants.orderKey], ); final orderCancelResponseDTO = orderCancelResponse?.toDTO() ?? - OrderCancelResultDTO(orderCancelJson: {}); + OrderCancelResultDTO(orderCancelResponseBody: {}); dropInPlatformApi.onOrderCancelResult(orderCancelResponseDTO); } catch (error) { - dropInPlatformApi - .onOrderCancelResult(OrderCancelResultDTO(orderCancelJson: {})); + dropInPlatformApi.onOrderCancelResult( + OrderCancelResultDTO(orderCancelResponseBody: {})); } } } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index dd970840..bc01aee9 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -1386,27 +1386,27 @@ class ActionComponentConfigurationDTO { class OrderCancelResultDTO { OrderCancelResultDTO({ - required this.orderCancelJson, - this.updatedPaymentMethodsJson, + required this.orderCancelResponseBody, + this.updatedPaymentMethodsResponseBody, }); - Map orderCancelJson; + Map orderCancelResponseBody; - Map? updatedPaymentMethodsJson; + Map? updatedPaymentMethodsResponseBody; Object encode() { return [ - orderCancelJson, - updatedPaymentMethodsJson, + orderCancelResponseBody, + updatedPaymentMethodsResponseBody, ]; } static OrderCancelResultDTO decode(Object result) { result as List; return OrderCancelResultDTO( - orderCancelJson: + orderCancelResponseBody: (result[0] as Map?)!.cast(), - updatedPaymentMethodsJson: + updatedPaymentMethodsResponseBody: (result[1] as Map?)?.cast(), ); } diff --git a/lib/src/util/dto_mapper.dart b/lib/src/util/dto_mapper.dart index 82223bbb..2021a7e2 100644 --- a/lib/src/util/dto_mapper.dart +++ b/lib/src/util/dto_mapper.dart @@ -309,7 +309,7 @@ extension ActionComponentConfigurationMapper on ActionComponentConfiguration { extension OrderCancelResponseMapper on OrderCancelResult { OrderCancelResultDTO toDTO() => OrderCancelResultDTO( - orderCancelJson: orderCancelJson, - updatedPaymentMethodsJson: updatedPaymentMethodsJson, + orderCancelResponseBody: orderCancelResponseBody, + updatedPaymentMethodsResponseBody: updatedPaymentMethodsResponseBody, ); } diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 306f0966..ba8e6d51 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -577,12 +577,12 @@ class ActionComponentConfigurationDTO { } class OrderCancelResultDTO { - final Map orderCancelJson; - final Map? updatedPaymentMethodsJson; + final Map orderCancelResponseBody; + final Map? updatedPaymentMethodsResponseBody; OrderCancelResultDTO( - this.orderCancelJson, - this.updatedPaymentMethodsJson, + this.orderCancelResponseBody, + this.updatedPaymentMethodsResponseBody, ); } From 9cc78f6c59e7b025b69af60ca855df1ffeb2278d Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 28 Nov 2024 13:23:35 +0100 Subject: [PATCH 14/21] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f33284a..97986bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 1.2.0 +* Added support for partial payments. * Improved dynamic viewport of card component. * Added the missing loading bottom sheet for the advanced flow google pay component. * Updated iOS SDK to v5.14.0. From 68ca648d9f5173ebef576dbfd059744aa4f0f50c Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 10 Dec 2024 11:38:09 +0100 Subject: [PATCH 15/21] Added badges and required minimum AGP version to readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 88fc045e..07695ba9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ ![Flutter](https://github.com/Adyen/adyen-flutter/assets/13377878/66a9fab8-dba0-426f-acd4-ab0bfd469d20) # Adyen Flutter +[![Pub Package](https://img.shields.io/pub/v/adyen_checkout.svg)](https://pub.dev/packages/adyen_checkout) +[![Adyen iOS](https://img.shields.io/badge/ios-v5.14.0-brightgreen.svg)](https://github.com/Adyen/adyen-ios/releases/tag/5.14.0) +[![Adyen Android](https://img.shields.io/badge/android-v5.8.0-brightgreen.svg)](https://github.com/Adyen/adyen-android/releases/tag/5.8.0) The Adyen Flutter package provides you with the building blocks to create a checkout experience for your shoppers, allowing them to pay using the payment method of their choice. This is @@ -54,6 +57,7 @@ release a new version when we need to. #### Android * [Android 5.0](https://www.android.com/versions/lollipop-5-0/) (API 21) or later. * [Kotlin 1.8](https://kotlinlang.org/docs/releases.html) or later. +* [AGP 8.0](https://developer.android.com/build/releases/gradle-plugin) or later. * Requires the usage of a `FlutterFragmentActivity` instead of the default `FlutterActivity` in the MainActivity of your [native Android](https://github.com/Adyen/adyen-flutter/blob/main/example/android/app/src/main/kotlin/com/adyen/checkout/flutter/example/MainActivity.kt) layer. #### iOS From ac7a59693c6324fb30f58dcfabf0482b9591cff0 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 10 Dec 2024 11:43:51 +0100 Subject: [PATCH 16/21] Specified required AGP version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07695ba9..f8f049b4 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ release a new version when we need to. #### Android * [Android 5.0](https://www.android.com/versions/lollipop-5-0/) (API 21) or later. * [Kotlin 1.8](https://kotlinlang.org/docs/releases.html) or later. -* [AGP 8.0](https://developer.android.com/build/releases/gradle-plugin) or later. +* [AGP 8.1](https://developer.android.com/build/releases/gradle-plugin) or later. * Requires the usage of a `FlutterFragmentActivity` instead of the default `FlutterActivity` in the MainActivity of your [native Android](https://github.com/Adyen/adyen-flutter/blob/main/example/android/app/src/main/kotlin/com/adyen/checkout/flutter/example/MainActivity.kt) layer. #### iOS From c0c7a8d378a1ca4944ecfc75e60e86f5e22d29a9 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 10 Dec 2024 13:15:01 +0100 Subject: [PATCH 17/21] Adjusted required Kotlin version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8f049b4..cc44c4d5 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ release a new version when we need to. #### Android * [Android 5.0](https://www.android.com/versions/lollipop-5-0/) (API 21) or later. -* [Kotlin 1.8](https://kotlinlang.org/docs/releases.html) or later. +* [Kotlin 1.8.22](https://kotlinlang.org/docs/releases.html) or later. * [AGP 8.1](https://developer.android.com/build/releases/gradle-plugin) or later. * Requires the usage of a `FlutterFragmentActivity` instead of the default `FlutterActivity` in the MainActivity of your [native Android](https://github.com/Adyen/adyen-flutter/blob/main/example/android/app/src/main/kotlin/com/adyen/checkout/flutter/example/MainActivity.kt) layer. From e2b2369b0f4107213e28ed288caa37b33147fad9 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Wed, 18 Dec 2024 16:03:08 +0100 Subject: [PATCH 18/21] Applied adjustments from iOS code review --- ios/Classes/components/instant/InstantAdvancedComponent.swift | 1 + ios/Classes/dropIn/DropInPlatformApi.swift | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ios/Classes/components/instant/InstantAdvancedComponent.swift b/ios/Classes/components/instant/InstantAdvancedComponent.swift index b70da073..d4cd1260 100644 --- a/ios/Classes/components/instant/InstantAdvancedComponent.swift +++ b/ios/Classes/components/instant/InstantAdvancedComponent.swift @@ -52,6 +52,7 @@ class InstantAdvancedComponent: BaseInstantComponent, InstantComponentProtocol { case .action: onAction(paymentEventDTO: paymentEventDTO) case .update: + // The Instant Component does not support updating the payment flow return } } diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 54ae6ce9..84c04f96 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -278,7 +278,7 @@ class DropInPlatformApi: DropInPlatformInterface { } private func removeGiftCardPaymentMethods(paymentMethods: PaymentMethods, isPartialPaymentSupported: Bool) -> PaymentMethods { - if isPartialPaymentSupported { + guard isPartialPaymentSupported else { return paymentMethods } From 3be8f1040208ca9d9a692595cf17cc97266a51f1 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Wed, 18 Dec 2024 17:00:10 +0100 Subject: [PATCH 19/21] Removed the delays because they are no longer needed. --- .../dropIn/advanced/AdvancedDropInService.kt | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt index cb958fe1..315e54e1 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/advanced/AdvancedDropInService.kt @@ -10,7 +10,6 @@ import android.os.IBinder import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ServiceLifecycleDispatcher -import androidx.lifecycle.lifecycleScope import com.adyen.checkout.components.core.ActionComponentData import com.adyen.checkout.components.core.BalanceResult import com.adyen.checkout.components.core.Order @@ -30,8 +29,6 @@ import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletion import com.adyen.checkout.flutter.dropIn.model.DropInType import com.adyen.checkout.flutter.utils.Constants import com.adyen.checkout.googlepay.GooglePayComponentState -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch import org.json.JSONObject class AdvancedDropInService : DropInService(), LifecycleOwner { @@ -169,10 +166,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } val balanceResult = mapToBalanceDropInServiceResult(message.contentIfNotHandled as String) - lifecycleScope.launch { - delay(300) - sendBalanceResult(balanceResult) - } + sendBalanceResult(balanceResult) } } @@ -184,10 +178,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } val orderResult = mapToOrderDropInServiceResult(message.contentIfNotHandled as String) - lifecycleScope.launch { - delay(300) - sendOrderResult(orderResult) - } + sendOrderResult(orderResult) } } @@ -199,10 +190,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } val orderResult = mapToOrderCancelDropInServiceResult(message.contentIfNotHandled) ?: return@observe - lifecycleScope.launch { - delay(300) - sendResult(orderResult) - } + sendResult(orderResult) } } From 2b05fee9a6f032d5bfe7e24ff21c1196f90a62f5 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 19 Dec 2024 10:46:27 +0100 Subject: [PATCH 20/21] Fixed isPartialPaymentSupported check on iOS --- example/lib/repositories/adyen_drop_in_repository.dart | 1 + ios/Classes/dropIn/DropInPlatformApi.swift | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/example/lib/repositories/adyen_drop_in_repository.dart b/example/lib/repositories/adyen_drop_in_repository.dart index 364c8099..fa8fb51b 100644 --- a/example/lib/repositories/adyen_drop_in_repository.dart +++ b/example/lib/repositories/adyen_drop_in_repository.dart @@ -111,6 +111,7 @@ class AdyenDropInRepository extends AdyenBaseRepository { ), countryCode: Config.countryCode, channel: determineChannel(), + recurringProcessingModel: RecurringProcessingModel.cardOnFile, authenticationData: { "attemptAuthentication": "always", "threeDSRequestData": { diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 84c04f96..2c95debd 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -278,7 +278,7 @@ class DropInPlatformApi: DropInPlatformInterface { } private func removeGiftCardPaymentMethods(paymentMethods: PaymentMethods, isPartialPaymentSupported: Bool) -> PaymentMethods { - guard isPartialPaymentSupported else { + guard !isPartialPaymentSupported else { return paymentMethods } From 63affaa8145a2a0817b3a3b1abeee42cf085a2a8 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 19 Dec 2024 17:24:46 +0100 Subject: [PATCH 21/21] Applied change from code review --- ios/Classes/dropIn/DropInPlatformApi.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 2c95debd..54ae6ce9 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -278,7 +278,7 @@ class DropInPlatformApi: DropInPlatformInterface { } private func removeGiftCardPaymentMethods(paymentMethods: PaymentMethods, isPartialPaymentSupported: Bool) -> PaymentMethods { - guard !isPartialPaymentSupported else { + if isPartialPaymentSupported { return paymentMethods }