From f9eb2afcf69733186e04aeac6bf8f43bd0c10fb8 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 14 Jan 2025 14:02:34 +0100 Subject: [PATCH 01/12] Added onBinLookup callback for DropIn with the advanced flow on Android --- .../com/adyen/checkout/flutter/PlatformApi.kt | 3 +- .../flutter/dropIn/DropInPlatformApi.kt | 43 +- .../dropIn/advanced/AdvancedDropInService.kt | 23 + .../dropIn/model/BinLookupDataExtension.kt | 20 + .../adyen/checkout/flutter/utils/Constants.kt | 2 +- .../lib/screens/drop_in/drop_in_screen.dart | 10 + ios/Classes/PlatformApi.swift | 4294 ++++++++--------- lib/adyen_checkout.dart | 2 + .../model/card_callbacks/bin_lookup_data.dart | 11 + .../model/card_callbacks/card_callbacks.dart | 7 + lib/src/common/model/checkout.dart | 4 + lib/src/drop_in/drop_in.dart | 28 + lib/src/generated/platform_api.g.dart | 641 +-- pigeons/platform_api.dart | 1 + 14 files changed, 2520 insertions(+), 2569 deletions(-) create mode 100644 android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt create mode 100644 lib/src/common/model/card_callbacks/bin_lookup_data.dart create mode 100644 lib/src/common/model/card_callbacks/card_callbacks.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 e5f6cefd..a28fc9e5 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt @@ -136,7 +136,8 @@ enum class PlatformCommunicationType(val raw: Int) { DELETESTOREDPAYMENTMETHOD(3), BALANCECHECK(4), REQUESTORDER(5), - CANCELORDER(6); + CANCELORDER(6), + BINLOOKUP(7); companion object { fun ofRaw(raw: Int): PlatformCommunicationType? { 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 86aadf53..a951ba38 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 @@ -46,17 +46,24 @@ import com.adyen.checkout.flutter.utils.ConfigurationMapper.mapToEnvironment import com.adyen.checkout.sessions.core.CheckoutSession import com.adyen.checkout.sessions.core.SessionSetupResponse import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.json.JSONObject -class DropInPlatformApi( +internal class DropInPlatformApi( private val dropInFlutterApi: DropInFlutterInterface, private val activity: FragmentActivity, private val sessionHolder: SessionHolder, ) : DropInPlatformInterface { lateinit var dropInSessionLauncher: ActivityResultLauncher lateinit var dropInAdvancedFlowLauncher: ActivityResultLauncher + private var dropInPlatformMessengerJob : Job? = null + + companion object { + val dropInPlatformMessageFlow = MutableSharedFlow() + } override fun showDropInSession(dropInConfigurationDTO: DropInConfigurationDTO) { setStoredPaymentMethodDeletionObserver() @@ -85,6 +92,14 @@ class DropInPlatformApi( setBalanceCheckPlatformMessengerObserver() setOrderRequestPlatformMessengerObserver() setOrderCancelPlatformMessengerObserver() + + dropInPlatformMessengerJob?.cancel() + dropInPlatformMessengerJob = activity.lifecycleScope.launch { + dropInPlatformMessageFlow.collect { platformCommunicationModel -> + dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + } + } + activity.lifecycleScope.launch(Dispatchers.IO) { val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize( @@ -139,6 +154,8 @@ class DropInPlatformApi( } override fun cleanUpDropIn() { + dropInPlatformMessengerJob?.cancel() + DropInServiceResultMessenger.instance().removeObservers(activity) DropInAdditionalDetailsPlatformMessenger.instance().removeObservers(activity) DropInPaymentMethodDeletionPlatformMessenger.instance().removeObservers(activity) @@ -315,15 +332,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() + ) + } ) } @@ -360,9 +377,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 8d16cb0a..5114867d 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 @@ -5,11 +5,15 @@ import ErrorDTO import OrderCancelResultDTO import PaymentEventDTO import PaymentEventType +import PlatformCommunicationModel 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 androidx.lifecycle.lifecycleScope +import com.adyen.checkout.card.BinLookupData import com.adyen.checkout.components.core.ActionComponentData import com.adyen.checkout.components.core.BalanceResult import com.adyen.checkout.components.core.Order @@ -25,10 +29,15 @@ 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.DropInPlatformApi import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletionModel import com.adyen.checkout.flutter.dropIn.model.DropInType +import com.adyen.checkout.flutter.dropIn.model.toJson import com.adyen.checkout.flutter.utils.Constants +import com.adyen.checkout.flutter.utils.Constants.Companion.ADYEN_LOG_TAG import com.adyen.checkout.googlepay.GooglePayComponentState +import kotlinx.coroutines.launch +import org.json.JSONException import org.json.JSONObject class AdvancedDropInService : DropInService(), LifecycleOwner { @@ -98,6 +107,20 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } } + override fun onBinLookup(data: List) { + lifecycleScope.launch { + try { + val platformCommunicationModel = PlatformCommunicationModel( + PlatformCommunicationType.BINLOOKUP, + data = data.toJson() + ) + DropInPlatformApi.dropInPlatformMessageFlow.emit(platformCommunicationModel) + } catch (exception: Exception) { + Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") + } + } + } + private fun onPaymentComponentState(state: PaymentComponentState<*>) { try { setAdvancedFlowDropInServiceObserver() diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt new file mode 100644 index 00000000..cc5bbed7 --- /dev/null +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt @@ -0,0 +1,20 @@ +package com.adyen.checkout.flutter.dropIn.model + +import com.adyen.checkout.card.BinLookupData +import org.json.JSONArray +import org.json.JSONException +import org.json.JSONObject + +@Throws(JSONException::class) +fun List.toJson(): String { + val jsonArray = JSONArray() + for (item in this) { + val jsonObject = JSONObject() + // Let's discuss if we want to use models instead of JSON to avoid unnoticed changes + jsonObject.put("brand", item.brand) + jsonObject.put("paymentMethodVariant", item.paymentMethodVariant) + jsonObject.put("isReliable", item.isReliable) + jsonArray.put(jsonObject) + } + return jsonArray.toString() +} 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 f890e44b..0b03b80a 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 @@ -5,7 +5,7 @@ class Constants { const val WRONG_FLUTTER_ACTIVITY_USAGE_ERROR_MESSAGE = "FlutterFragmentActivity not used. Your activity needs to inherit from FlutterFragmentActivity." const val UNKNOWN_PAYMENT_METHOD_TYPE_ERROR_MESSAGE = "Unknown payment method type." - + const val ADYEN_LOG_TAG = "ADYEN_CHECKOUT" const val GOOGLE_PAY_SESSION_COMPONENT_KEY = "GOOGLE_PAY_SESSION_COMPONENT" const val GOOGLE_PAY_ADVANCED_COMPONENT_KEY = "GOOGLE_PAY_ADVANCED_COMPONENT" const val INSTANT_SESSION_COMPONENT_KEY = "INSTANT_SESSION_COMPONENT" diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index 22974b4c..47838e2f 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -80,6 +80,9 @@ class DropInScreen extends StatelessWidget { onRequestOrder: repository.onRequestOrder, onCancelOrder: repository.onCancelOrder, ), + cardCallbacks: CardCallbacks( + onBinLookup: _onBinLookup, + ), ); final paymentResult = await AdyenCheckout.advanced.startDropIn( @@ -144,4 +147,11 @@ class DropInScreen extends StatelessWidget { return dropInConfiguration; } + + void _onBinLookup(List binLookupData) { + for (var element in binLookupData) { + debugPrint( + "Bin lookup data: brand:${element.brand}, isReliable:${element.isReliable}, paymentMethodVariant:${element.paymentMethodVariant}"); + } + } } diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index 9d4ad7a8..94d734fc 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -4,2457 +4,2417 @@ 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 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 + case binLookup = 7 } 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 } enum CardNumberValidationResultDTO: Int { - case valid = 0 - case invalidIllegalCharacters = 1 - case invalidLuhnCheck = 2 - case invalidTooShort = 3 - case invalidTooLong = 4 - case invalidOtherReason = 5 + case valid = 0 + case invalidIllegalCharacters = 1 + case invalidLuhnCheck = 2 + case invalidTooShort = 3 + case invalidTooLong = 4 + case invalidOtherReason = 5 } enum CardExpiryDateValidationResultDTO: Int { - case valid = 0 - case invalidTooFarInTheFuture = 1 - case invalidTooOld = 2 - case nonParseableDate = 3 - case invalidOtherReason = 4 + case valid = 0 + case invalidTooFarInTheFuture = 1 + case invalidTooOld = 2 + case nonParseableDate = 3 + case invalidOtherReason = 4 } enum CardSecurityCodeValidationResultDTO: Int { - case valid = 0 - case invalid = 1 + case valid = 0 + case invalid = 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?]? - 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 - ] - } + 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 + 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? = 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]) + 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?] { + return [ + 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?] { - [ - 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 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() - ] - } + 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(), + ] + } } /// 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(), + ] + } } /// Generated class from Pigeon that represents data sent in messages. struct OrderCancelResultDTO { - var orderCancelResponseBody: [String?: Any?] - var updatedPaymentMethodsResponseBody: [String?: Any?]? - - static func fromList(_ list: [Any?]) -> OrderCancelResultDTO? { - let orderCancelResponseBody = list[0] as! [String?: Any?] - let updatedPaymentMethodsResponseBody: [String?: Any?]? = nilOrValue(list[1]) - - return OrderCancelResultDTO( - orderCancelResponseBody: orderCancelResponseBody, - updatedPaymentMethodsResponseBody: updatedPaymentMethodsResponseBody - ) - } - - func toList() -> [Any?] { - [ - orderCancelResponseBody, - updatedPaymentMethodsResponseBody - ] - } + var orderCancelResponseBody: [String?: Any?] + var updatedPaymentMethodsResponseBody: [String?: Any?]? = nil + + static func fromList(_ list: [Any?]) -> OrderCancelResultDTO? { + let orderCancelResponseBody = list[0] as! [String?: Any?] + let updatedPaymentMethodsResponseBody: [String?: Any?]? = nilOrValue(list[1]) + + return OrderCancelResultDTO( + orderCancelResponseBody: orderCancelResponseBody, + updatedPaymentMethodsResponseBody: updatedPaymentMethodsResponseBody + ) + } + func toList() -> [Any?] { + return [ + orderCancelResponseBody, + updatedPaymentMethodsResponseBody, + ] + } } 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 OrderCancelResultDTO.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 OrderCancelResultDTO.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? OrderCancelResultDTO { - 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? OrderCancelResultDTO { + 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 { - 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 validateCardNumber(cardNumber: String, enableLuhnCheck: Bool) throws -> CardNumberValidationResultDTO - func validateCardExpiryDate(expiryMonth: String, expiryYear: String) throws -> CardExpiryDateValidationResultDTO - func validateCardSecurityCode(securityCode: String, cardBrandTxVariant: String?) throws -> CardSecurityCodeValidationResultDTO - 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 validateCardNumber(cardNumber: String, enableLuhnCheck: Bool) throws -> CardNumberValidationResultDTO + func validateCardExpiryDate(expiryMonth: String, expiryYear: String) throws -> CardExpiryDateValidationResultDTO + func validateCardSecurityCode(securityCode: String, cardBrandTxVariant: String?) throws -> CardSecurityCodeValidationResultDTO + 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) - } - 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) - } - 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) - } - 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) - } - 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 validateCardNumberChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardNumber", binaryMessenger: binaryMessenger, codec: codec) - if let api { - validateCardNumberChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let cardNumberArg = args[0] as! String - let enableLuhnCheckArg = args[1] as! Bool - do { - let result = try api.validateCardNumber(cardNumber: cardNumberArg, enableLuhnCheck: enableLuhnCheckArg) - reply(wrapResult(result.rawValue)) - } catch { - reply(wrapError(error)) - } - } - } else { - validateCardNumberChannel.setMessageHandler(nil) - } - let validateCardExpiryDateChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardExpiryDate", binaryMessenger: binaryMessenger, codec: codec) - if let api { - validateCardExpiryDateChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let expiryMonthArg = args[0] as! String - let expiryYearArg = args[1] as! String - do { - let result = try api.validateCardExpiryDate(expiryMonth: expiryMonthArg, expiryYear: expiryYearArg) - reply(wrapResult(result.rawValue)) - } catch { - reply(wrapError(error)) - } - } - } else { - validateCardExpiryDateChannel.setMessageHandler(nil) - } - let validateCardSecurityCodeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardSecurityCode", binaryMessenger: binaryMessenger, codec: codec) - if let api { - validateCardSecurityCodeChannel.setMessageHandler { message, reply in - let args = message as! [Any?] - let securityCodeArg = args[0] as! String - let cardBrandTxVariantArg: String? = nilOrValue(args[1]) - do { - let result = try api.validateCardSecurityCode(securityCode: securityCodeArg, cardBrandTxVariant: cardBrandTxVariantArg) - reply(wrapResult(result.rawValue)) - } catch { - reply(wrapError(error)) - } - } - } else { - validateCardSecurityCodeChannel.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) - } - } + /// 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)) + } + } + } + } 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)) + } + } + } + } 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 + 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)) + } + } + } + } 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)) + } + } + } + } else { + encryptBinChannel.setMessageHandler(nil) + } + let validateCardNumberChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardNumber", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + validateCardNumberChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let cardNumberArg = args[0] as! String + let enableLuhnCheckArg = args[1] as! Bool + do { + let result = try api.validateCardNumber(cardNumber: cardNumberArg, enableLuhnCheck: enableLuhnCheckArg) + reply(wrapResult(result.rawValue)) + } catch { + reply(wrapError(error)) + } + } + } else { + validateCardNumberChannel.setMessageHandler(nil) + } + let validateCardExpiryDateChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardExpiryDate", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + validateCardExpiryDateChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let expiryMonthArg = args[0] as! String + let expiryYearArg = args[1] as! String + do { + let result = try api.validateCardExpiryDate(expiryMonth: expiryMonthArg, expiryYear: expiryYearArg) + reply(wrapResult(result.rawValue)) + } catch { + reply(wrapError(error)) + } + } + } else { + validateCardExpiryDateChannel.setMessageHandler(nil) + } + let validateCardSecurityCodeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardSecurityCode", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + validateCardSecurityCodeChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let securityCodeArg = args[0] as! String + let cardBrandTxVariantArg: String? = nilOrValue(args[1]) + do { + let result = try api.validateCardSecurityCode(securityCode: securityCodeArg, cardBrandTxVariant: cardBrandTxVariantArg) + reply(wrapResult(result.rawValue)) + } catch { + reply(wrapError(error)) + } + } + } else { + validateCardSecurityCodeChannel.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 OrderCancelResultDTO.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 OrderCancelResultDTO.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? OrderCancelResultDTO { - 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? OrderCancelResultDTO { + 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 { - 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 onBalanceCheckResult(balanceCheckResponse: String) throws - func onOrderRequestResult(orderRequestResponse: String) throws - func onOrderCancelResult(orderCancelResult: OrderCancelResultDTO) 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(orderCancelResult: OrderCancelResultDTO) 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) - } - 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) - } - 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) - } - 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) - } - 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) - } - 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) - } - 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) - } - 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 orderCancelResultArg = args[0] as! OrderCancelResultDTO - do { - try api.onOrderCancelResult(orderCancelResult: orderCancelResultArg) - 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 { - cleanUpDropInChannel.setMessageHandler { _, reply in - do { - try api.cleanUpDropIn() - reply(wrapResult(nil)) - } catch { - reply(wrapError(error)) - } - } - } else { - cleanUpDropInChannel.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)) + } + } + } 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)) + } + } + } 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)) + } + } + } 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)) + } + } + } 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)) + } + } + } 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 orderCancelResultArg = args[0] as! OrderCancelResultDTO + do { + try api.onOrderCancelResult(orderCancelResult: orderCancelResultArg) + 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 + 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 OrderCancelResultDTO.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 OrderCancelResultDTO.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? OrderCancelResultDTO { - 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? OrderCancelResultDTO { + 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 { - 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) - } - 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) - } - 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) - } - 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) - } - 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) - } - 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) - } - 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) - } - } + /// 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)) + } + } + } 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)) + } + } + } 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)) + } + } + } 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)) + } + } + } + } 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)) + } + } + } 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)) + } + } + } 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/lib/adyen_checkout.dart b/lib/adyen_checkout.dart index dde76013..7b27826c 100644 --- a/lib/adyen_checkout.dart +++ b/lib/adyen_checkout.dart @@ -4,6 +4,8 @@ export 'src/common/model/analytics_options.dart'; export 'src/common/model/api_only/card_expiry_date_validation_result.dart'; export 'src/common/model/api_only/card_number_validation_result.dart'; export 'src/common/model/api_only/card_security_code_validation_result.dart'; +export 'src/common/model/card_callbacks/bin_lookup_data.dart'; +export 'src/common/model/card_callbacks/card_callbacks.dart'; export 'src/common/model/checkout.dart'; export 'src/common/model/cse/encrypted_card.dart'; export 'src/common/model/cse/unencrypted_card.dart'; diff --git a/lib/src/common/model/card_callbacks/bin_lookup_data.dart b/lib/src/common/model/card_callbacks/bin_lookup_data.dart new file mode 100644 index 00000000..30bc0cef --- /dev/null +++ b/lib/src/common/model/card_callbacks/bin_lookup_data.dart @@ -0,0 +1,11 @@ +class BinLookupData { + final String brand; + final bool isReliable; + final String? paymentMethodVariant; + + BinLookupData({ + required this.brand, + required this.isReliable, + this.paymentMethodVariant, + }); +} diff --git a/lib/src/common/model/card_callbacks/card_callbacks.dart b/lib/src/common/model/card_callbacks/card_callbacks.dart new file mode 100644 index 00000000..d66f9281 --- /dev/null +++ b/lib/src/common/model/card_callbacks/card_callbacks.dart @@ -0,0 +1,7 @@ +import 'package:adyen_checkout/src/common/model/card_callbacks/bin_lookup_data.dart'; + +class CardCallbacks { + void Function(List)? onBinLookup; + + CardCallbacks({this.onBinLookup}); +} diff --git a/lib/src/common/model/checkout.dart b/lib/src/common/model/checkout.dart index ff2055ae..9f637dfd 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/card_callbacks/card_callbacks.dart'; import 'package:adyen_checkout/src/common/model/partial_payment/partial_payment.dart'; import 'package:adyen_checkout/src/common/model/payment_event.dart'; @@ -26,9 +27,12 @@ class AdvancedCheckout extends Checkout { PartialPayment? partialPayment; + CardCallbacks? cardCallbacks; + AdvancedCheckout({ required this.onSubmit, required this.onAdditionalDetails, this.partialPayment, + this.cardCallbacks, }); } diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 93e0303e..0c5b1c69 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -127,6 +127,8 @@ class DropIn { _handleOrderRequest(event, advancedCheckout.partialPayment); case PlatformCommunicationType.cancelOrder: _handleOrderCancel(event, advancedCheckout.partialPayment); + case PlatformCommunicationType.binLookup: + _handleOnBinLookup(event, advancedCheckout.cardCallbacks); } }); @@ -332,4 +334,30 @@ class DropIn { OrderCancelResultDTO(orderCancelResponseBody: {})); } } + + void _handleOnBinLookup( + PlatformCommunicationModel event, + CardCallbacks? cardCallbacks, + ) { + if (cardCallbacks == null || cardCallbacks.onBinLookup == null) { + adyenLogger.print("onBinLookup callback not provided"); + return; + } + + final encodedBinLookupData = event.data; + if (encodedBinLookupData == null) { + adyenLogger.print("bin lookup data is null"); + return; + } + + final List binLookupDataJson = jsonDecode(encodedBinLookupData); + final List binLookupDataList = binLookupDataJson + .map((entry) => BinLookupData( + brand: entry['brand'], + paymentMethodVariant: entry['paymentMethodVariant'], + isReliable: entry['isReliable'], + )) + .toList(); + cardCallbacks.onBinLookup?.call(binLookupDataList); + } } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index ecacab75..45cb93dd 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 []; } @@ -76,6 +75,7 @@ enum PlatformCommunicationType { balanceCheck, requestOrder, cancelOrder, + binLookup, } enum ComponentCommunicationType { @@ -321,14 +321,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(), isPartialPaymentSupported: result[15]! as bool, ); } @@ -384,8 +382,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(), ); } @@ -462,15 +459,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, @@ -478,8 +472,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 @@ -729,8 +722,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?, @@ -1183,10 +1177,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), ); } } @@ -1247,8 +1239,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, @@ -1400,8 +1391,7 @@ 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), ); } } @@ -1426,10 +1416,8 @@ class OrderCancelResultDTO { static OrderCancelResultDTO decode(Object result) { result as List; return OrderCancelResultDTO( - orderCancelResponseBody: - (result[0] as Map?)!.cast(), - updatedPaymentMethodsResponseBody: - (result[1] as Map?)?.cast(), + orderCancelResponseBody: (result[0] as Map?)!.cast(), + updatedPaymentMethodsResponseBody: (result[1] as Map?)?.cast(), ); } } @@ -1533,63 +1521,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 OrderCancelResultDTO.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); @@ -1605,14 +1593,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, @@ -1637,19 +1622,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) { @@ -1669,10 +1650,8 @@ 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, @@ -1692,18 +1671,15 @@ 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) { @@ -1723,16 +1699,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) { @@ -1751,18 +1725,15 @@ class CheckoutPlatformInterface { } } - Future validateCardNumber( - String cardNumber, bool enableLuhnCheck) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardNumber'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future validateCardNumber(String cardNumber, bool enableLuhnCheck) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardNumber'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([cardNumber, enableLuhnCheck]) as List?; + final List? __pigeon_replyList = + await __pigeon_channel.send([cardNumber, enableLuhnCheck]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1777,23 +1748,19 @@ class CheckoutPlatformInterface { message: 'Host platform returned null value for non-null return value.', ); } else { - return CardNumberValidationResultDTO - .values[__pigeon_replyList[0]! as int]; + return CardNumberValidationResultDTO.values[__pigeon_replyList[0]! as int]; } } - Future validateCardExpiryDate( - String expiryMonth, String expiryYear) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardExpiryDate'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future validateCardExpiryDate(String expiryMonth, String expiryYear) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardExpiryDate'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([expiryMonth, expiryYear]) as List?; + final List? __pigeon_replyList = + await __pigeon_channel.send([expiryMonth, expiryYear]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1808,23 +1775,19 @@ class CheckoutPlatformInterface { message: 'Host platform returned null value for non-null return value.', ); } else { - return CardExpiryDateValidationResultDTO - .values[__pigeon_replyList[0]! as int]; + return CardExpiryDateValidationResultDTO.values[__pigeon_replyList[0]! as int]; } } - Future validateCardSecurityCode( - String securityCode, String? cardBrandTxVariant) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardSecurityCode'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future validateCardSecurityCode(String securityCode, String? cardBrandTxVariant) async { + const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardSecurityCode'; + final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, pigeonChannelCodec, binaryMessenger: __pigeon_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([securityCode, cardBrandTxVariant]) as List?; + final List? __pigeon_replyList = + await __pigeon_channel.send([securityCode, cardBrandTxVariant]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1839,22 +1802,19 @@ class CheckoutPlatformInterface { message: 'Host platform returned null value for non-null return value.', ); } else { - return CardSecurityCodeValidationResultDTO - .values[__pigeon_replyList[0]! as int]; + return CardSecurityCodeValidationResultDTO.values[__pigeon_replyList[0]! as int]; } } 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) { @@ -1935,41 +1895,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 OrderCancelResultDTO.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); @@ -1985,21 +1945,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) { @@ -2013,19 +1969,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) { @@ -2040,16 +1992,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) { @@ -2063,18 +2013,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) { @@ -2088,19 +2035,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) { @@ -2115,16 +2058,14 @@ 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) { @@ -2139,16 +2080,14 @@ 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) { @@ -2162,18 +2101,15 @@ class DropInPlatformInterface { } } - Future onOrderCancelResult( - OrderCancelResultDTO orderCancelResult) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.adyen_checkout.DropInPlatformInterface.onOrderCancelResult'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( + Future onOrderCancelResult(OrderCancelResultDTO orderCancelResult) 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([orderCancelResult]) as List?; + final List? __pigeon_replyList = + await __pigeon_channel.send([orderCancelResult]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2188,10 +2124,8 @@ 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, @@ -2239,15 +2173,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); @@ -2256,73 +2190,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())); } }); } @@ -2429,63 +2349,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 OrderCancelResultDTO.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); @@ -2501,14 +2421,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, @@ -2528,18 +2445,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) { @@ -2553,18 +2467,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) { @@ -2578,24 +2489,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) { @@ -2614,24 +2516,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) { @@ -2645,24 +2538,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) { @@ -2677,10 +2561,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, @@ -2740,23 +2622,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); @@ -2765,67 +2647,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 { @@ -2833,9 +2701,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/pigeons/platform_api.dart b/pigeons/platform_api.dart index 47628aa0..6877b7fb 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -61,6 +61,7 @@ enum PlatformCommunicationType { balanceCheck, requestOrder, cancelOrder, + binLookup } enum ComponentCommunicationType { From 90c3d91237bf5441770ca999b6c0c63e273d319b Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Wed, 15 Jan 2025 14:19:46 +0100 Subject: [PATCH 02/12] Added onBinValue callback for DropIn with the advanced flow on Android --- .../com/adyen/checkout/flutter/PlatformApi.kt | 3 ++- .../dropIn/advanced/AdvancedDropInService.kt | 10 ++++++++ .../lib/screens/drop_in/drop_in_screen.dart | 5 ++++ ios/Classes/PlatformApi.swift | 1 + .../model/card_callbacks/card_callbacks.dart | 6 ++++- lib/src/drop_in/drop_in.dart | 24 +++++++++++++++++-- lib/src/generated/platform_api.g.dart | 1 + pigeons/platform_api.dart | 3 ++- 8 files changed, 48 insertions(+), 5 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 a28fc9e5..779cfffd 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/PlatformApi.kt @@ -137,7 +137,8 @@ enum class PlatformCommunicationType(val raw: Int) { BALANCECHECK(4), REQUESTORDER(5), CANCELORDER(6), - BINLOOKUP(7); + BINLOOKUP(7), + BINVALUE(8); companion object { fun ofRaw(raw: Int): PlatformCommunicationType? { 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 5114867d..faea8cd4 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 @@ -121,6 +121,16 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { } } + override fun onBinValue(binValue: String) { + lifecycleScope.launch { + val platformCommunicationModel = PlatformCommunicationModel( + PlatformCommunicationType.BINVALUE, + data = binValue + ) + DropInPlatformApi.dropInPlatformMessageFlow.emit(platformCommunicationModel) + } + } + private fun onPaymentComponentState(state: PaymentComponentState<*>) { try { setAdvancedFlowDropInServiceObserver() diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index 47838e2f..fdffd182 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -82,6 +82,7 @@ class DropInScreen extends StatelessWidget { ), cardCallbacks: CardCallbacks( onBinLookup: _onBinLookup, + onBinValue: _onBinValue, ), ); @@ -154,4 +155,8 @@ class DropInScreen extends StatelessWidget { "Bin lookup data: brand:${element.brand}, isReliable:${element.isReliable}, paymentMethodVariant:${element.paymentMethodVariant}"); } } + + void _onBinValue(String binValue) { + debugPrint("Bin value is: $binValue"); + } } diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index 94d734fc..451c5cd2 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -94,6 +94,7 @@ enum PlatformCommunicationType: Int { case requestOrder = 5 case cancelOrder = 6 case binLookup = 7 + case binValue = 8 } enum ComponentCommunicationType: Int { diff --git a/lib/src/common/model/card_callbacks/card_callbacks.dart b/lib/src/common/model/card_callbacks/card_callbacks.dart index d66f9281..1e63504c 100644 --- a/lib/src/common/model/card_callbacks/card_callbacks.dart +++ b/lib/src/common/model/card_callbacks/card_callbacks.dart @@ -2,6 +2,10 @@ import 'package:adyen_checkout/src/common/model/card_callbacks/bin_lookup_data.d class CardCallbacks { void Function(List)? onBinLookup; + void Function(String)? onBinValue; - CardCallbacks({this.onBinLookup}); + CardCallbacks({ + this.onBinLookup, + this.onBinValue, + }); } diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 0c5b1c69..93916c22 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -129,6 +129,8 @@ class DropIn { _handleOrderCancel(event, advancedCheckout.partialPayment); case PlatformCommunicationType.binLookup: _handleOnBinLookup(event, advancedCheckout.cardCallbacks); + case PlatformCommunicationType.binValue: + _handleOnBinValue(event, advancedCheckout.cardCallbacks); } }); @@ -340,13 +342,13 @@ class DropIn { CardCallbacks? cardCallbacks, ) { if (cardCallbacks == null || cardCallbacks.onBinLookup == null) { - adyenLogger.print("onBinLookup callback not provided"); + adyenLogger.print("onBinLookup callback not provided."); return; } final encodedBinLookupData = event.data; if (encodedBinLookupData == null) { - adyenLogger.print("bin lookup data is null"); + adyenLogger.print("BinLookup data is null."); return; } @@ -360,4 +362,22 @@ class DropIn { .toList(); cardCallbacks.onBinLookup?.call(binLookupDataList); } + + void _handleOnBinValue( + PlatformCommunicationModel event, + CardCallbacks? cardCallbacks, + ) { + if (cardCallbacks == null || cardCallbacks.onBinValue == null) { + adyenLogger.print("onBinValue callback not provided."); + return; + } + + final binValue = event.data; + if (binValue == null) { + adyenLogger.print("BinValue is null."); + return; + } + + cardCallbacks.onBinValue?.call(binValue); + } } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index 45cb93dd..e6152c76 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -76,6 +76,7 @@ enum PlatformCommunicationType { requestOrder, cancelOrder, binLookup, + binValue, } enum ComponentCommunicationType { diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index 6877b7fb..d43b884f 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -61,7 +61,8 @@ enum PlatformCommunicationType { balanceCheck, requestOrder, cancelOrder, - binLookup + binLookup, + binValue } enum ComponentCommunicationType { From 8f241fdbe45058c08454be915a291365116ef0f9 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Mon, 20 Jan 2025 15:02:41 +0100 Subject: [PATCH 03/12] Added bin lookup callbacks to ios layer --- .../flutter/dropIn/DropInPlatformApi.kt | 35 ++++++++++--------- .../dropIn/advanced/AdvancedDropInService.kt | 19 +++++----- .../dropIn/model/BinLookupDataExtension.kt | 2 -- .../lib/screens/drop_in/drop_in_screen.dart | 3 +- ios/Classes/dropIn/DropInPlatformApi.swift | 30 ++++++++++++++++ ios/Classes/utils/Constants.swift | 1 + .../model/card_callbacks/bin_lookup_data.dart | 8 +---- lib/src/drop_in/drop_in.dart | 6 +--- 8 files changed, 62 insertions(+), 42 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index a951ba38..97bff4fc 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 @@ -59,7 +59,7 @@ internal class DropInPlatformApi( ) : DropInPlatformInterface { lateinit var dropInSessionLauncher: ActivityResultLauncher lateinit var dropInAdvancedFlowLauncher: ActivityResultLauncher - private var dropInPlatformMessengerJob : Job? = null + private var dropInPlatformMessengerJob: Job? = null companion object { val dropInPlatformMessageFlow = MutableSharedFlow() @@ -94,11 +94,12 @@ internal class DropInPlatformApi( setOrderCancelPlatformMessengerObserver() dropInPlatformMessengerJob?.cancel() - dropInPlatformMessengerJob = activity.lifecycleScope.launch { - dropInPlatformMessageFlow.collect { platformCommunicationModel -> - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + dropInPlatformMessengerJob = + activity.lifecycleScope.launch { + dropInPlatformMessageFlow.collect { platformCommunicationModel -> + dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + } } - } activity.lifecycleScope.launch(Dispatchers.IO) { val paymentMethodsApiResponse = @@ -332,15 +333,15 @@ internal 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() + ) + } ) } @@ -377,9 +378,9 @@ internal 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 faea8cd4..8ea7cd16 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 @@ -37,7 +37,6 @@ import com.adyen.checkout.flutter.utils.Constants import com.adyen.checkout.flutter.utils.Constants.Companion.ADYEN_LOG_TAG import com.adyen.checkout.googlepay.GooglePayComponentState import kotlinx.coroutines.launch -import org.json.JSONException import org.json.JSONObject class AdvancedDropInService : DropInService(), LifecycleOwner { @@ -110,10 +109,11 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { override fun onBinLookup(data: List) { lifecycleScope.launch { try { - val platformCommunicationModel = PlatformCommunicationModel( - PlatformCommunicationType.BINLOOKUP, - data = data.toJson() - ) + val platformCommunicationModel = + PlatformCommunicationModel( + PlatformCommunicationType.BINLOOKUP, + data = data.toJson() + ) DropInPlatformApi.dropInPlatformMessageFlow.emit(platformCommunicationModel) } catch (exception: Exception) { Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") @@ -123,10 +123,11 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { override fun onBinValue(binValue: String) { lifecycleScope.launch { - val platformCommunicationModel = PlatformCommunicationModel( - PlatformCommunicationType.BINVALUE, - data = binValue - ) + val platformCommunicationModel = + PlatformCommunicationModel( + PlatformCommunicationType.BINVALUE, + data = binValue + ) DropInPlatformApi.dropInPlatformMessageFlow.emit(platformCommunicationModel) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt index cc5bbed7..b11cda8f 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt @@ -12,8 +12,6 @@ fun List.toJson(): String { val jsonObject = JSONObject() // Let's discuss if we want to use models instead of JSON to avoid unnoticed changes jsonObject.put("brand", item.brand) - jsonObject.put("paymentMethodVariant", item.paymentMethodVariant) - jsonObject.put("isReliable", item.isReliable) jsonArray.put(jsonObject) } return jsonArray.toString() diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index fdffd182..402f4c41 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -152,11 +152,10 @@ class DropInScreen extends StatelessWidget { void _onBinLookup(List binLookupData) { for (var element in binLookupData) { debugPrint( - "Bin lookup data: brand:${element.brand}, isReliable:${element.isReliable}, paymentMethodVariant:${element.paymentMethodVariant}"); + "Bin lookup data: brand:${element.brand}"); } } void _onBinValue(String binValue) { - debugPrint("Bin value is: $binValue"); } } diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index 54ae6ce9..7bb7af2c 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -97,6 +97,7 @@ class DropInPlatformApi: DropInPlatformInterface { dropInAdvancedFlowDelegate = DropInAdvancedFlowDelegate(dropInFlutterApi: dropInFlutterApi) dropInAdvancedFlowDelegate?.dropInInteractorDelegate = self dropInComponent.delegate = dropInAdvancedFlowDelegate + dropInComponent.cardComponentDelegate = self if dropInConfigurationDTO.isPartialPaymentSupported { dropInComponent.partialPaymentDelegate = self } @@ -379,3 +380,32 @@ extension DropInPlatformApi: PartialPaymentDelegate { } } + +extension DropInPlatformApi : CardComponentDelegate { + func didSubmit(lastFour: String, finalBIN: String, component: Adyen.CardComponent) {} + + func didChangeBIN(_ value: String, component: Adyen.CardComponent) { + let platformCommunicationModel = PlatformCommunicationModel(type: PlatformCommunicationType.binValue, data: value) + dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + } + + func didChangeCardBrand(_ value: [Adyen.CardBrand]?, component: Adyen.CardComponent) { + do { + guard let binLookupData = value else { + return + } + var binLookupDataList: [[String: Any]] = [] + for item in binLookupData { + var jsonObject: [String: Any] = [:] + jsonObject[Constants.brandKey] = item.type.rawValue + binLookupDataList.append(jsonObject) + } + + let data = try JSONSerialization.data(withJSONObject: binLookupDataList, options: []) + let platformCommunicationModel = PlatformCommunicationModel(type: PlatformCommunicationType.binLookup, data: String(data: data, encoding: .utf8)) + dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + } catch { + + } + } +} diff --git a/ios/Classes/utils/Constants.swift b/ios/Classes/utils/Constants.swift index 3511af02..fb30e627 100644 --- a/ios/Classes/utils/Constants.swift +++ b/ios/Classes/utils/Constants.swift @@ -3,4 +3,5 @@ enum Constants { static let orderKey = "order" static let updatedPaymentMethodsKey = "updatedPaymentMethods" static let shouldUpdatePaymentMethodsKey = "shouldUpdatePaymentMethods" + static let brandKey = "brand" } diff --git a/lib/src/common/model/card_callbacks/bin_lookup_data.dart b/lib/src/common/model/card_callbacks/bin_lookup_data.dart index 30bc0cef..810ed775 100644 --- a/lib/src/common/model/card_callbacks/bin_lookup_data.dart +++ b/lib/src/common/model/card_callbacks/bin_lookup_data.dart @@ -1,11 +1,5 @@ class BinLookupData { final String brand; - final bool isReliable; - final String? paymentMethodVariant; - BinLookupData({ - required this.brand, - required this.isReliable, - this.paymentMethodVariant, - }); + BinLookupData({required this.brand}); } diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 93916c22..4b531934 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -354,11 +354,7 @@ class DropIn { final List binLookupDataJson = jsonDecode(encodedBinLookupData); final List binLookupDataList = binLookupDataJson - .map((entry) => BinLookupData( - brand: entry['brand'], - paymentMethodVariant: entry['paymentMethodVariant'], - isReliable: entry['isReliable'], - )) + .map((entry) => BinLookupData(brand: entry['brand'])) .toList(); cardCallbacks.onBinLookup?.call(binLookupDataList); } From c4ff089390167142e6a53d5f42bb3530c3690be7 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 4 Feb 2025 14:43:14 +0100 Subject: [PATCH 04/12] Added binLookup callbacks to session flow on Android --- .../flutter/dropIn/DropInPlatformApi.kt | 14 +++++++-- .../dropIn/advanced/AdvancedDropInService.kt | 4 +-- .../dropIn/session/SessionDropInService.kt | 29 +++++++++++++++++++ .../lib/screens/drop_in/drop_in_screen.dart | 9 ++++-- ios/Classes/PlatformApi.swift | 6 ++-- lib/src/common/model/checkout.dart | 3 +- lib/src/drop_in/drop_in.dart | 6 +++- lib/src/generated/platform_api.g.dart | 4 +-- 8 files changed, 62 insertions(+), 13 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index 97bff4fc..fe92e28b 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 @@ -62,7 +62,8 @@ internal class DropInPlatformApi( private var dropInPlatformMessengerJob: Job? = null companion object { - val dropInPlatformMessageFlow = MutableSharedFlow() + val dropInSessionPlatformMessageFlow = MutableSharedFlow() + val dropInAdvancedPlatformMessageFlow = MutableSharedFlow() } override fun showDropInSession(dropInConfigurationDTO: DropInConfigurationDTO) { @@ -74,6 +75,15 @@ internal class DropInPlatformApi( dropInConfigurationDTO.environment.mapToEnvironment(), dropInConfigurationDTO.clientKey ) + + dropInPlatformMessengerJob?.cancel() + dropInPlatformMessengerJob = + activity.lifecycleScope.launch { + dropInSessionPlatformMessageFlow.collect { platformCommunicationModel -> + dropInFlutterApi.onDropInSessionPlatformCommunication(platformCommunicationModel) {} + } + } + DropIn.startPayment( activity.applicationContext, dropInSessionLauncher, @@ -96,7 +106,7 @@ internal class DropInPlatformApi( dropInPlatformMessengerJob?.cancel() dropInPlatformMessengerJob = activity.lifecycleScope.launch { - dropInPlatformMessageFlow.collect { platformCommunicationModel -> + dropInAdvancedPlatformMessageFlow.collect { platformCommunicationModel -> dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} } } 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 8ea7cd16..04eb7820 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 @@ -114,7 +114,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { PlatformCommunicationType.BINLOOKUP, data = data.toJson() ) - DropInPlatformApi.dropInPlatformMessageFlow.emit(platformCommunicationModel) + DropInPlatformApi.dropInAdvancedPlatformMessageFlow.emit(platformCommunicationModel) } catch (exception: Exception) { Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") } @@ -128,7 +128,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { PlatformCommunicationType.BINVALUE, data = binValue ) - DropInPlatformApi.dropInPlatformMessageFlow.emit(platformCommunicationModel) + DropInPlatformApi.dropInAdvancedPlatformMessageFlow.emit(platformCommunicationModel) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt index 4dfcafd1..afc7263e 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt @@ -1,19 +1,27 @@ package com.adyen.checkout.flutter.dropIn.session import DeletedStoredPaymentMethodResultDTO +import PlatformCommunicationModel 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 androidx.lifecycle.lifecycleScope +import com.adyen.checkout.card.BinLookupData import com.adyen.checkout.components.core.StoredPaymentMethod import com.adyen.checkout.dropin.ErrorDialog import com.adyen.checkout.dropin.RecurringDropInServiceResult import com.adyen.checkout.dropin.SessionDropInService +import com.adyen.checkout.flutter.dropIn.DropInPlatformApi import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionPlatformMessenger import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionResultMessenger import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletionModel import com.adyen.checkout.flutter.dropIn.model.DropInType +import com.adyen.checkout.flutter.dropIn.model.toJson +import com.adyen.checkout.flutter.utils.Constants.Companion.ADYEN_LOG_TAG +import kotlinx.coroutines.launch class SessionDropInService : SessionDropInService(), LifecycleOwner { private val dispatcher = ServiceLifecycleDispatcher(this) @@ -32,6 +40,27 @@ class SessionDropInService : SessionDropInService(), LifecycleOwner { } } + override fun onBinLookup(data: List) { + lifecycleScope.launch { + try { + val binLookupDataJson = data.toJson() + val platformCommunicationModel = PlatformCommunicationModel( + PlatformCommunicationType.BINLOOKUP, + binLookupDataJson) + DropInPlatformApi.dropInSessionPlatformMessageFlow.emit(platformCommunicationModel) + } catch (exception: Exception) { + Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") + } + } + } + + override fun onBinValue(binValue: String) { + lifecycleScope.launch { + val platformCommunicationModel = PlatformCommunicationModel(PlatformCommunicationType.BINVALUE, binValue) + DropInPlatformApi.dropInSessionPlatformMessageFlow.emit(platformCommunicationModel) + } + } + private fun setStoredPaymentMethodDeletionObserver() { DropInPaymentMethodDeletionResultMessenger.instance().removeObservers(this) DropInPaymentMethodDeletionResultMessenger.instance().observe(this) { message -> diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index 4157851e..9ee2b09c 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -53,6 +53,11 @@ class DropInScreen extends StatelessWidget { configuration: dropInConfiguration, ); + sessionCheckout.cardCallbacks = CardCallbacks( + onBinLookup: _onBinLookup, + onBinValue: _onBinValue, + ); + final PaymentResult paymentResult = await AdyenCheckout.session.startDropIn( dropInConfiguration: dropInConfiguration, @@ -150,11 +155,11 @@ class DropInScreen extends StatelessWidget { void _onBinLookup(List binLookupData) { for (var element in binLookupData) { - debugPrint( - "Bin lookup data: brand:${element.brand}"); + debugPrint("Bin lookup data: brand:${element.brand}"); } } void _onBinValue(String binValue) { + debugPrint("Bin value: $binValue"); } } diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index 451c5cd2..1cb794af 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -1443,7 +1443,7 @@ protocol CheckoutPlatformInterface { func encryptBin(bin: String, publicKey: String, completion: @escaping (Result) -> Void) func validateCardNumber(cardNumber: String, enableLuhnCheck: Bool) throws -> CardNumberValidationResultDTO func validateCardExpiryDate(expiryMonth: String, expiryYear: String) throws -> CardExpiryDateValidationResultDTO - func validateCardSecurityCode(securityCode: String, cardBrandTxVariant: String?) throws -> CardSecurityCodeValidationResultDTO + func validateCardSecurityCode(securityCode: String, cardBrand: String?) throws -> CardSecurityCodeValidationResultDTO func enableConsoleLogging(loggingEnabled: Bool) throws } @@ -1573,9 +1573,9 @@ class CheckoutPlatformInterfaceSetup { validateCardSecurityCodeChannel.setMessageHandler { message, reply in let args = message as! [Any?] let securityCodeArg = args[0] as! String - let cardBrandTxVariantArg: String? = nilOrValue(args[1]) + let cardBrandArg: String? = nilOrValue(args[1]) do { - let result = try api.validateCardSecurityCode(securityCode: securityCodeArg, cardBrandTxVariant: cardBrandTxVariantArg) + let result = try api.validateCardSecurityCode(securityCode: securityCodeArg, cardBrand: cardBrandArg) reply(wrapResult(result.rawValue)) } catch { reply(wrapError(error)) diff --git a/lib/src/common/model/checkout.dart b/lib/src/common/model/checkout.dart index 9f637dfd..e574ccc3 100644 --- a/lib/src/common/model/checkout.dart +++ b/lib/src/common/model/checkout.dart @@ -8,11 +8,13 @@ class SessionCheckout extends Checkout { final String id; final String sessionData; final Map paymentMethods; + CardCallbacks? cardCallbacks; SessionCheckout({ required this.id, required this.sessionData, required this.paymentMethods, + this.cardCallbacks, }); } @@ -26,7 +28,6 @@ class AdvancedCheckout extends Checkout { onAdditionalDetails; PartialPayment? partialPayment; - CardCallbacks? cardCallbacks; AdvancedCheckout({ diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 4b531934..2129e276 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -28,7 +28,7 @@ class DropIn { Future startDropInSessionsPayment( DropInConfiguration dropInConfiguration, - SessionCheckout dropInSession, + SessionCheckout sessionCheckout, ) async { adyenLogger.print("Start Drop-in session"); final dropInSessionCompleter = Completer(); @@ -52,6 +52,10 @@ class DropIn { event, dropInConfiguration.storedPaymentMethodConfiguration, ); + case PlatformCommunicationType.binLookup: + _handleOnBinLookup(event, sessionCheckout.cardCallbacks); + case PlatformCommunicationType.binValue: + _handleOnBinValue(event, sessionCheckout.cardCallbacks); default: } }); diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index e6152c76..486f56db 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -1780,7 +1780,7 @@ class CheckoutPlatformInterface { } } - Future validateCardSecurityCode(String securityCode, String? cardBrandTxVariant) async { + Future validateCardSecurityCode(String securityCode, String? cardBrand) async { const String __pigeon_channelName = 'dev.flutter.pigeon.adyen_checkout.CheckoutPlatformInterface.validateCardSecurityCode'; final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, @@ -1788,7 +1788,7 @@ class CheckoutPlatformInterface { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send([securityCode, cardBrandTxVariant]) as List?; + await __pigeon_channel.send([securityCode, cardBrand]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { From fbdcdb5b3e64871a1e7b920fc61707056ad8427b Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Mon, 17 Feb 2025 16:08:18 +0100 Subject: [PATCH 05/12] Updated latest changes --- .../flutter/dropIn/DropInPlatformApi.kt | 8 ++-- .../dropIn/advanced/AdvancedDropInService.kt | 18 +++++---- .../dropIn/session/SessionDropInService.kt | 14 ++++--- .../checkout/flutter/generated/PlatformApi.kt | 4 +- .../lib/screens/drop_in/drop_in_screen.dart | 16 +++----- ios/Classes/dropIn/DropInPlatformApi.swift | 15 ++++---- ios/Classes/generated/PlatformApi.swift | 2 + .../model/card_callbacks/card_callbacks.dart | 10 ++++- lib/src/common/model/checkout.dart | 5 --- .../card_configuration.dart | 4 +- lib/src/drop_in/drop_in.dart | 38 ++++++++++--------- lib/src/generated/platform_api.g.dart | 2 + 12 files changed, 75 insertions(+), 61 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index f574d4cd..7ff823cb 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 @@ -61,8 +61,8 @@ internal class DropInPlatformApi( private var dropInPlatformMessengerJob: Job? = null companion object { - val dropInSessionPlatformMessageFlow = MutableSharedFlow() - val dropInAdvancedPlatformMessageFlow = MutableSharedFlow() + val dropInSessionPlatformMessageFlow = MutableSharedFlow() + val dropInAdvancedPlatformMessageFlow = MutableSharedFlow() } override fun showDropInSession(dropInConfigurationDTO: DropInConfigurationDTO) { @@ -79,7 +79,7 @@ internal class DropInPlatformApi( dropInPlatformMessengerJob = activity.lifecycleScope.launch { dropInSessionPlatformMessageFlow.collect { platformCommunicationModel -> - dropInFlutterApi.onDropInSessionPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(platformCommunicationModel) {} } } @@ -106,7 +106,7 @@ internal class DropInPlatformApi( dropInPlatformMessengerJob = activity.lifecycleScope.launch { dropInAdvancedPlatformMessageFlow.collect { platformCommunicationModel -> - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel) {} + checkoutFlutter.send(platformCommunicationModel) {} } } 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 be06b3cc..cc1f2528 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 @@ -32,6 +32,8 @@ import com.adyen.checkout.flutter.generated.OrderCancelResultDTO import com.adyen.checkout.flutter.generated.PaymentEventDTO import com.adyen.checkout.flutter.generated.PaymentEventType import com.adyen.checkout.flutter.dropIn.model.toJson +import com.adyen.checkout.flutter.generated.CheckoutEvent +import com.adyen.checkout.flutter.generated.CheckoutEventType import com.adyen.checkout.flutter.utils.Constants import com.adyen.checkout.flutter.utils.Constants.Companion.ADYEN_LOG_TAG import com.adyen.checkout.googlepay.GooglePayComponentState @@ -108,12 +110,12 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { override fun onBinLookup(data: List) { lifecycleScope.launch { try { - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.BINLOOKUP, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.BIN_LOOKUP, data = data.toJson() ) - DropInPlatformApi.dropInAdvancedPlatformMessageFlow.emit(platformCommunicationModel) + DropInPlatformApi.dropInAdvancedPlatformMessageFlow.emit(checkoutEvent) } catch (exception: Exception) { Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") } @@ -122,12 +124,12 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { override fun onBinValue(binValue: String) { lifecycleScope.launch { - val platformCommunicationModel = - PlatformCommunicationModel( - PlatformCommunicationType.BINVALUE, + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.BIN_VALUE, data = binValue ) - DropInPlatformApi.dropInAdvancedPlatformMessageFlow.emit(platformCommunicationModel) + DropInPlatformApi.dropInAdvancedPlatformMessageFlow.emit(checkoutEvent) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt index 96e9c66e..6d04bbf0 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt @@ -19,6 +19,8 @@ import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletion import com.adyen.checkout.flutter.dropIn.model.DropInType import com.adyen.checkout.flutter.generated.DeletedStoredPaymentMethodResultDTO import com.adyen.checkout.flutter.dropIn.model.toJson +import com.adyen.checkout.flutter.generated.CheckoutEvent +import com.adyen.checkout.flutter.generated.CheckoutEventType import com.adyen.checkout.flutter.utils.Constants.Companion.ADYEN_LOG_TAG import kotlinx.coroutines.launch @@ -43,10 +45,12 @@ class SessionDropInService : SessionDropInService(), LifecycleOwner { lifecycleScope.launch { try { val binLookupDataJson = data.toJson() - val platformCommunicationModel = PlatformCommunicationModel( - PlatformCommunicationType.BINLOOKUP, - binLookupDataJson) - DropInPlatformApi.dropInSessionPlatformMessageFlow.emit(platformCommunicationModel) + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.BIN_LOOKUP, + binLookupDataJson + ) + DropInPlatformApi.dropInSessionPlatformMessageFlow.emit(checkoutEvent) } catch (exception: Exception) { Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") } @@ -55,7 +59,7 @@ class SessionDropInService : SessionDropInService(), LifecycleOwner { override fun onBinValue(binValue: String) { lifecycleScope.launch { - val platformCommunicationModel = PlatformCommunicationModel(PlatformCommunicationType.BINVALUE, binValue) + val platformCommunicationModel = CheckoutEvent(CheckoutEventType.BIN_VALUE, binValue) DropInPlatformApi.dropInSessionPlatformMessageFlow.emit(platformCommunicationModel) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt index 22621377..e9d644cb 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt @@ -138,7 +138,9 @@ enum class CheckoutEventType(val raw: Int) { DELETE_STORED_PAYMENT_METHOD(3), BALANCE_CHECK(4), REQUEST_ORDER(5), - CANCEL_ORDER(6); + CANCEL_ORDER(6), + BIN_LOOKUP(7), + BIN_VALUE(8); companion object { fun ofRaw(raw: Int): CheckoutEventType? { diff --git a/example/lib/screens/drop_in/drop_in_screen.dart b/example/lib/screens/drop_in/drop_in_screen.dart index 9ee2b09c..60a18d46 100644 --- a/example/lib/screens/drop_in/drop_in_screen.dart +++ b/example/lib/screens/drop_in/drop_in_screen.dart @@ -53,11 +53,6 @@ class DropInScreen extends StatelessWidget { configuration: dropInConfiguration, ); - sessionCheckout.cardCallbacks = CardCallbacks( - onBinLookup: _onBinLookup, - onBinValue: _onBinValue, - ); - final PaymentResult paymentResult = await AdyenCheckout.session.startDropIn( dropInConfiguration: dropInConfiguration, @@ -84,10 +79,6 @@ class DropInScreen extends StatelessWidget { onRequestOrder: repository.onRequestOrder, onCancelOrder: repository.onCancelOrder, ), - cardCallbacks: CardCallbacks( - onBinLookup: _onBinLookup, - onBinValue: _onBinValue, - ), ); final paymentResult = await AdyenCheckout.advanced.startDropIn( @@ -105,7 +96,12 @@ class DropInScreen extends StatelessWidget { } Future _createDropInConfiguration() async { - const CardConfiguration cardsConfiguration = CardConfiguration(); + CardConfiguration cardsConfiguration = CardConfiguration( + cardCallbacks: CardCallbacks( + onBinLookup: _onBinLookup, + onBinValue: _onBinValue, + ), + ); ApplePayConfiguration applePayConfiguration = ApplePayConfiguration( merchantId: Config.merchantId, diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index dd1e920b..a866dcae 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -57,6 +57,7 @@ class DropInPlatformApi: DropInPlatformInterface { ) dropInComponent.delegate = sessionHolder.session dropInComponent.partialPaymentDelegate = sessionHolder.session + dropInComponent.cardComponentDelegate = self if dropInConfigurationDTO.isRemoveStoredPaymentMethodEnabled { dropInComponent.storedPaymentMethodsDelegate = dropInSessionStoredPaymentMethodsDelegate } @@ -375,12 +376,12 @@ extension DropInPlatformApi: PartialPaymentDelegate { } -extension DropInPlatformApi : CardComponentDelegate { +extension DropInPlatformApi: CardComponentDelegate { func didSubmit(lastFour: String, finalBIN: String, component: Adyen.CardComponent) {} func didChangeBIN(_ value: String, component: Adyen.CardComponent) { - let platformCommunicationModel = PlatformCommunicationModel(type: PlatformCommunicationType.binValue, data: value) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.binValue, data: value) + checkoutFlutter.send(event: checkoutEvent, completion: { _ in }) } func didChangeCardBrand(_ value: [Adyen.CardBrand]?, component: Adyen.CardComponent) { @@ -396,10 +397,8 @@ extension DropInPlatformApi : CardComponentDelegate { } let data = try JSONSerialization.data(withJSONObject: binLookupDataList, options: []) - let platformCommunicationModel = PlatformCommunicationModel(type: PlatformCommunicationType.binLookup, data: String(data: data, encoding: .utf8)) - dropInFlutterApi.onDropInAdvancedPlatformCommunication(platformCommunicationModel: platformCommunicationModel, completion: { _ in }) - } catch { - - } + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.binLookup, data: String(data: data, encoding: .utf8)) + checkoutFlutter.send(event: checkoutEvent, completion: { _ in }) + } catch {} } } diff --git a/ios/Classes/generated/PlatformApi.swift b/ios/Classes/generated/PlatformApi.swift index 3f97d88e..9df4fcf1 100644 --- a/ios/Classes/generated/PlatformApi.swift +++ b/ios/Classes/generated/PlatformApi.swift @@ -117,6 +117,8 @@ enum CheckoutEventType: Int { case balanceCheck = 4 case requestOrder = 5 case cancelOrder = 6 + case binLookup = 7 + case binValue = 8 } enum ComponentCommunicationType: Int { diff --git a/lib/src/common/model/card_callbacks/card_callbacks.dart b/lib/src/common/model/card_callbacks/card_callbacks.dart index 1e63504c..155487e5 100644 --- a/lib/src/common/model/card_callbacks/card_callbacks.dart +++ b/lib/src/common/model/card_callbacks/card_callbacks.dart @@ -1,11 +1,19 @@ import 'package:adyen_checkout/src/common/model/card_callbacks/bin_lookup_data.dart'; -class CardCallbacks { +abstract class CardCallbacksInterface { void Function(List)? onBinLookup; void Function(String)? onBinValue; +} +class CardCallbacks implements CardCallbacksInterface { CardCallbacks({ this.onBinLookup, this.onBinValue, }); + + @override + void Function(List)? onBinLookup; + + @override + void Function(String)? onBinValue; } diff --git a/lib/src/common/model/checkout.dart b/lib/src/common/model/checkout.dart index e574ccc3..ff2055ae 100644 --- a/lib/src/common/model/checkout.dart +++ b/lib/src/common/model/checkout.dart @@ -1,4 +1,3 @@ -import 'package:adyen_checkout/src/common/model/card_callbacks/card_callbacks.dart'; import 'package:adyen_checkout/src/common/model/partial_payment/partial_payment.dart'; import 'package:adyen_checkout/src/common/model/payment_event.dart'; @@ -8,13 +7,11 @@ class SessionCheckout extends Checkout { final String id; final String sessionData; final Map paymentMethods; - CardCallbacks? cardCallbacks; SessionCheckout({ required this.id, required this.sessionData, required this.paymentMethods, - this.cardCallbacks, }); } @@ -28,12 +25,10 @@ class AdvancedCheckout extends Checkout { onAdditionalDetails; PartialPayment? partialPayment; - CardCallbacks? cardCallbacks; AdvancedCheckout({ required this.onSubmit, required this.onAdditionalDetails, this.partialPayment, - this.cardCallbacks, }); } diff --git a/lib/src/common/model/payment_method_configurations/card_configuration.dart b/lib/src/common/model/payment_method_configurations/card_configuration.dart index f7f9e6df..9ab85595 100644 --- a/lib/src/common/model/payment_method_configurations/card_configuration.dart +++ b/lib/src/common/model/payment_method_configurations/card_configuration.dart @@ -1,4 +1,4 @@ -import 'package:adyen_checkout/src/generated/platform_api.g.dart'; +import 'package:adyen_checkout/adyen_checkout.dart'; class CardConfiguration { final bool holderNameRequired; @@ -9,6 +9,7 @@ class CardConfiguration { final FieldVisibility kcpFieldVisibility; final FieldVisibility socialSecurityNumberFieldVisibility; final List supportedCardTypes; + final CardCallbacksInterface? cardCallbacks; const CardConfiguration({ this.holderNameRequired = false, @@ -19,5 +20,6 @@ class CardConfiguration { this.kcpFieldVisibility = FieldVisibility.hide, this.socialSecurityNumberFieldVisibility = FieldVisibility.hide, this.supportedCardTypes = const [], + this.cardCallbacks, }); } diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 70cd092e..a256e96f 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -50,10 +50,10 @@ class DropIn { event, dropInConfiguration.storedPaymentMethodConfiguration, ); - case PlatformCommunicationType.binLookup: - _handleOnBinLookup(event, sessionCheckout.cardCallbacks); - case PlatformCommunicationType.binValue: - _handleOnBinValue(event, sessionCheckout.cardCallbacks); + case CheckoutEventType.binLookup: + _handleOnBinLookup(event, dropInConfiguration.cardConfiguration); + case CheckoutEventType.binValue: + _handleOnBinValue(event, dropInConfiguration.cardConfiguration); default: } }); @@ -127,10 +127,10 @@ class DropIn { _handleOrderRequest(event, advancedCheckout.partialPayment); case CheckoutEventType.cancelOrder: _handleOrderCancel(event, advancedCheckout.partialPayment); - case PlatformCommunicationType.binLookup: - _handleOnBinLookup(event, advancedCheckout.cardCallbacks); - case PlatformCommunicationType.binValue: - _handleOnBinValue(event, advancedCheckout.cardCallbacks); + case CheckoutEventType.binLookup: + _handleOnBinLookup(event, dropInConfiguration.cardConfiguration); + case CheckoutEventType.binValue: + _handleOnBinValue(event, dropInConfiguration.cardConfiguration); } }); @@ -346,15 +346,16 @@ class DropIn { } void _handleOnBinLookup( - PlatformCommunicationModel event, - CardCallbacks? cardCallbacks, + CheckoutEvent event, + CardConfiguration? cardConfiguration, ) { - if (cardCallbacks == null || cardCallbacks.onBinLookup == null) { + if (cardConfiguration?.cardCallbacks == null || + cardConfiguration?.cardCallbacks?.onBinLookup == null) { adyenLogger.print("onBinLookup callback not provided."); return; } - final encodedBinLookupData = event.data; + final encodedBinLookupData = event.data as String?; if (encodedBinLookupData == null) { adyenLogger.print("BinLookup data is null."); return; @@ -364,24 +365,25 @@ class DropIn { final List binLookupDataList = binLookupDataJson .map((entry) => BinLookupData(brand: entry['brand'])) .toList(); - cardCallbacks.onBinLookup?.call(binLookupDataList); + cardConfiguration?.cardCallbacks?.onBinLookup?.call(binLookupDataList); } void _handleOnBinValue( - PlatformCommunicationModel event, - CardCallbacks? cardCallbacks, + CheckoutEvent event, + CardConfiguration? cardConfiguration, ) { - if (cardCallbacks == null || cardCallbacks.onBinValue == null) { + if (cardConfiguration?.cardCallbacks == null || + cardConfiguration?.cardCallbacks?.onBinValue == null) { adyenLogger.print("onBinValue callback not provided."); return; } - final binValue = event.data; + final binValue = event.data as String?; if (binValue == null) { adyenLogger.print("BinValue is null."); return; } - cardCallbacks.onBinValue?.call(binValue); + cardConfiguration?.cardCallbacks?.onBinValue?.call(binValue); } } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index d8cbbc51..4c3437bc 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -76,6 +76,8 @@ enum CheckoutEventType { balanceCheck, requestOrder, cancelOrder, + binLookup, + binValue, } enum ComponentCommunicationType { From 8ca3c0956866d51a7716a588a7a6c2fba8f97206 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Tue, 18 Feb 2025 12:00:22 +0100 Subject: [PATCH 06/12] Naming adjustments --- .../checkout/flutter/dropIn/DropInPlatformApi.kt | 15 +++------------ .../dropIn/advanced/AdvancedDropInService.kt | 4 ++-- .../dropIn/session/SessionDropInService.kt | 4 ++-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/DropInPlatformApi.kt index 7ff823cb..fe94a8ac 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 @@ -61,8 +61,7 @@ internal class DropInPlatformApi( private var dropInPlatformMessengerJob: Job? = null companion object { - val dropInSessionPlatformMessageFlow = MutableSharedFlow() - val dropInAdvancedPlatformMessageFlow = MutableSharedFlow() + val dropInMessageFlow = MutableSharedFlow() } override fun showDropInSession(dropInConfigurationDTO: DropInConfigurationDTO) { @@ -77,11 +76,7 @@ internal class DropInPlatformApi( dropInPlatformMessengerJob?.cancel() dropInPlatformMessengerJob = - activity.lifecycleScope.launch { - dropInSessionPlatformMessageFlow.collect { platformCommunicationModel -> - checkoutFlutter.send(platformCommunicationModel) {} - } - } + activity.lifecycleScope.launch { dropInMessageFlow.collect { event -> checkoutFlutter.send(event) {} } } DropIn.startPayment( activity.applicationContext, @@ -104,11 +99,7 @@ internal class DropInPlatformApi( dropInPlatformMessengerJob?.cancel() dropInPlatformMessengerJob = - activity.lifecycleScope.launch { - dropInAdvancedPlatformMessageFlow.collect { platformCommunicationModel -> - checkoutFlutter.send(platformCommunicationModel) {} - } - } + activity.lifecycleScope.launch { dropInMessageFlow.collect { event -> checkoutFlutter.send(event) {} } } activity.lifecycleScope.launch(Dispatchers.IO) { val paymentMethodsApiResponse = 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 cc1f2528..c3f8114c 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 @@ -115,7 +115,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { CheckoutEventType.BIN_LOOKUP, data = data.toJson() ) - DropInPlatformApi.dropInAdvancedPlatformMessageFlow.emit(checkoutEvent) + DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } catch (exception: Exception) { Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") } @@ -129,7 +129,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { CheckoutEventType.BIN_VALUE, data = binValue ) - DropInPlatformApi.dropInAdvancedPlatformMessageFlow.emit(checkoutEvent) + DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt index 6d04bbf0..6fed6375 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt @@ -50,7 +50,7 @@ class SessionDropInService : SessionDropInService(), LifecycleOwner { CheckoutEventType.BIN_LOOKUP, binLookupDataJson ) - DropInPlatformApi.dropInSessionPlatformMessageFlow.emit(checkoutEvent) + DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } catch (exception: Exception) { Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") } @@ -60,7 +60,7 @@ class SessionDropInService : SessionDropInService(), LifecycleOwner { override fun onBinValue(binValue: String) { lifecycleScope.launch { val platformCommunicationModel = CheckoutEvent(CheckoutEventType.BIN_VALUE, binValue) - DropInPlatformApi.dropInSessionPlatformMessageFlow.emit(platformCommunicationModel) + DropInPlatformApi.dropInMessageFlow.emit(platformCommunicationModel) } } From fc8f05eda7d5ac32e025d54d4807ce68b3a00ed9 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 20 Feb 2025 14:52:50 +0100 Subject: [PATCH 07/12] Optimized dto mapping --- .../dropIn/advanced/AdvancedDropInService.kt | 7 +- .../dropIn/model/BinLookupDataExtension.kt | 18 --- .../dropIn/session/SessionDropInService.kt | 6 +- .../checkout/flutter/generated/PlatformApi.kt | 102 +++++++++++------ ios/Classes/dropIn/DropInPlatformApi.swift | 25 ++-- ios/Classes/generated/PlatformApi.swift | 101 ++++++++++------- lib/src/drop_in/drop_in.dart | 36 ++---- lib/src/generated/platform_api.g.dart | 107 +++++++++++------- pigeons/platform_api.dart | 7 ++ 9 files changed, 229 insertions(+), 180 deletions(-) delete mode 100644 android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt 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 c3f8114c..e2eede9b 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 @@ -26,12 +26,12 @@ import com.adyen.checkout.dropin.RecurringDropInServiceResult import com.adyen.checkout.flutter.dropIn.DropInPlatformApi import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletionModel import com.adyen.checkout.flutter.dropIn.model.DropInType +import com.adyen.checkout.flutter.generated.BinLookupDataDTO import com.adyen.checkout.flutter.generated.DeletedStoredPaymentMethodResultDTO import com.adyen.checkout.flutter.generated.ErrorDTO import com.adyen.checkout.flutter.generated.OrderCancelResultDTO import com.adyen.checkout.flutter.generated.PaymentEventDTO import com.adyen.checkout.flutter.generated.PaymentEventType -import com.adyen.checkout.flutter.dropIn.model.toJson import com.adyen.checkout.flutter.generated.CheckoutEvent import com.adyen.checkout.flutter.generated.CheckoutEventType import com.adyen.checkout.flutter.utils.Constants @@ -110,10 +110,11 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { override fun onBinLookup(data: List) { lifecycleScope.launch { try { + val binLookupDataList = data.map { BinLookupDataDTO(it.brand) } val checkoutEvent = CheckoutEvent( CheckoutEventType.BIN_LOOKUP, - data = data.toJson() + binLookupDataList ) DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } catch (exception: Exception) { @@ -127,7 +128,7 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { val checkoutEvent = CheckoutEvent( CheckoutEventType.BIN_VALUE, - data = binValue + binValue ) DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt deleted file mode 100644 index b11cda8f..00000000 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/model/BinLookupDataExtension.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.adyen.checkout.flutter.dropIn.model - -import com.adyen.checkout.card.BinLookupData -import org.json.JSONArray -import org.json.JSONException -import org.json.JSONObject - -@Throws(JSONException::class) -fun List.toJson(): String { - val jsonArray = JSONArray() - for (item in this) { - val jsonObject = JSONObject() - // Let's discuss if we want to use models instead of JSON to avoid unnoticed changes - jsonObject.put("brand", item.brand) - jsonArray.put(jsonObject) - } - return jsonArray.toString() -} diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt index 6fed6375..12549e80 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt @@ -17,8 +17,8 @@ import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionPla import com.adyen.checkout.flutter.dropIn.advanced.DropInPaymentMethodDeletionResultMessenger import com.adyen.checkout.flutter.dropIn.model.DropInStoredPaymentMethodDeletionModel import com.adyen.checkout.flutter.dropIn.model.DropInType +import com.adyen.checkout.flutter.generated.BinLookupDataDTO import com.adyen.checkout.flutter.generated.DeletedStoredPaymentMethodResultDTO -import com.adyen.checkout.flutter.dropIn.model.toJson import com.adyen.checkout.flutter.generated.CheckoutEvent import com.adyen.checkout.flutter.generated.CheckoutEventType import com.adyen.checkout.flutter.utils.Constants.Companion.ADYEN_LOG_TAG @@ -44,11 +44,11 @@ class SessionDropInService : SessionDropInService(), LifecycleOwner { override fun onBinLookup(data: List) { lifecycleScope.launch { try { - val binLookupDataJson = data.toJson() + val binLookupDataList = data.map { BinLookupDataDTO(it.brand) } val checkoutEvent = CheckoutEvent( CheckoutEventType.BIN_LOOKUP, - binLookupDataJson + binLookupDataList ) DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } catch (exception: Exception) { diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt index e9d644cb..bd682a37 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/generated/PlatformApi.kt @@ -1193,6 +1193,25 @@ data class OrderCancelResultDTO ( ) } } + +/** Generated class from Pigeon that represents data sent in messages. */ +data class BinLookupDataDTO ( + val brand: String + +) { + companion object { + @Suppress("LocalVariableName") + fun fromList(__pigeon_list: List): BinLookupDataDTO { + val brand = __pigeon_list[0] as String + return BinLookupDataDTO(brand) + } + } + fun toList(): List { + return listOf( + brand, + ) + } +} private object PlatformApiPigeonCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { @@ -1342,91 +1361,96 @@ private object PlatformApiPigeonCodec : StandardMessageCodec() { } } 158.toByte() -> { + return (readValue(buffer) as? List)?.let { + BinLookupDataDTO.fromList(it) + } + } + 159.toByte() -> { return (readValue(buffer) as Int?)?.let { Environment.ofRaw(it) } } - 159.toByte() -> { + 160.toByte() -> { return (readValue(buffer) as Int?)?.let { AddressMode.ofRaw(it) } } - 160.toByte() -> { + 161.toByte() -> { return (readValue(buffer) as Int?)?.let { CardAuthMethod.ofRaw(it) } } - 161.toByte() -> { + 162.toByte() -> { return (readValue(buffer) as Int?)?.let { TotalPriceStatus.ofRaw(it) } } - 162.toByte() -> { + 163.toByte() -> { return (readValue(buffer) as Int?)?.let { GooglePayEnvironment.ofRaw(it) } } - 163.toByte() -> { + 164.toByte() -> { return (readValue(buffer) as Int?)?.let { CashAppPayEnvironment.ofRaw(it) } } - 164.toByte() -> { + 165.toByte() -> { return (readValue(buffer) as Int?)?.let { PaymentResultEnum.ofRaw(it) } } - 165.toByte() -> { + 166.toByte() -> { return (readValue(buffer) as Int?)?.let { CheckoutEventType.ofRaw(it) } } - 166.toByte() -> { + 167.toByte() -> { return (readValue(buffer) as Int?)?.let { ComponentCommunicationType.ofRaw(it) } } - 167.toByte() -> { + 168.toByte() -> { return (readValue(buffer) as Int?)?.let { PaymentEventType.ofRaw(it) } } - 168.toByte() -> { + 169.toByte() -> { return (readValue(buffer) as Int?)?.let { FieldVisibility.ofRaw(it) } } - 169.toByte() -> { + 170.toByte() -> { return (readValue(buffer) as Int?)?.let { InstantPaymentType.ofRaw(it) } } - 170.toByte() -> { + 171.toByte() -> { return (readValue(buffer) as Int?)?.let { ApplePayShippingType.ofRaw(it) } } - 171.toByte() -> { + 172.toByte() -> { return (readValue(buffer) as Int?)?.let { ApplePayMerchantCapability.ofRaw(it) } } - 172.toByte() -> { + 173.toByte() -> { return (readValue(buffer) as Int?)?.let { ApplePaySummaryItemType.ofRaw(it) } } - 173.toByte() -> { + 174.toByte() -> { return (readValue(buffer) as Int?)?.let { CardNumberValidationResultDTO.ofRaw(it) } } - 174.toByte() -> { + 175.toByte() -> { return (readValue(buffer) as Int?)?.let { CardExpiryDateValidationResultDTO.ofRaw(it) } } - 175.toByte() -> { + 176.toByte() -> { return (readValue(buffer) as Int?)?.let { CardSecurityCodeValidationResultDTO.ofRaw(it) } @@ -1552,76 +1576,80 @@ private object PlatformApiPigeonCodec : StandardMessageCodec() { stream.write(157) writeValue(stream, value.toList()) } - is Environment -> { + is BinLookupDataDTO -> { stream.write(158) + writeValue(stream, value.toList()) + } + is Environment -> { + stream.write(159) writeValue(stream, value.raw) } is AddressMode -> { - stream.write(159) + stream.write(160) writeValue(stream, value.raw) } is CardAuthMethod -> { - stream.write(160) + stream.write(161) writeValue(stream, value.raw) } is TotalPriceStatus -> { - stream.write(161) + stream.write(162) writeValue(stream, value.raw) } is GooglePayEnvironment -> { - stream.write(162) + stream.write(163) writeValue(stream, value.raw) } is CashAppPayEnvironment -> { - stream.write(163) + stream.write(164) writeValue(stream, value.raw) } is PaymentResultEnum -> { - stream.write(164) + stream.write(165) writeValue(stream, value.raw) } is CheckoutEventType -> { - stream.write(165) + stream.write(166) writeValue(stream, value.raw) } is ComponentCommunicationType -> { - stream.write(166) + stream.write(167) writeValue(stream, value.raw) } is PaymentEventType -> { - stream.write(167) + stream.write(168) writeValue(stream, value.raw) } is FieldVisibility -> { - stream.write(168) + stream.write(169) writeValue(stream, value.raw) } is InstantPaymentType -> { - stream.write(169) + stream.write(170) writeValue(stream, value.raw) } is ApplePayShippingType -> { - stream.write(170) + stream.write(171) writeValue(stream, value.raw) } is ApplePayMerchantCapability -> { - stream.write(171) + stream.write(172) writeValue(stream, value.raw) } is ApplePaySummaryItemType -> { - stream.write(172) + stream.write(173) writeValue(stream, value.raw) } is CardNumberValidationResultDTO -> { - stream.write(173) + stream.write(174) writeValue(stream, value.raw) } is CardExpiryDateValidationResultDTO -> { - stream.write(174) + stream.write(175) writeValue(stream, value.raw) } is CardSecurityCodeValidationResultDTO -> { - stream.write(175) + stream.write(176) writeValue(stream, value.raw) } else -> super.writeValue(stream, value) @@ -2201,12 +2229,12 @@ class ComponentFlutterInterface(private val binaryMessenger: BinaryMessenger, pr PlatformApiPigeonCodec } } - fun _generateCodecForDTOs(cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTOArg: SessionDTO, callback: (Result) -> Unit) + fun _generateCodecForDTOs(cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTOArg: SessionDTO, binLookupDataDTOArg: BinLookupDataDTO, callback: (Result) -> Unit) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" val channelName = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs$separatedMessageChannelSuffix" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(cardComponentConfigurationDTOArg, sessionDTOArg)) { + channel.send(listOf(cardComponentConfigurationDTOArg, sessionDTOArg, binLookupDataDTOArg)) { if (it is List<*>) { if (it.size > 1) { callback(Result.failure(AdyenPigeonError(it[0] as String, it[1] as String, it[2] as String?))) diff --git a/ios/Classes/dropIn/DropInPlatformApi.swift b/ios/Classes/dropIn/DropInPlatformApi.swift index a866dcae..2c1b0516 100644 --- a/ios/Classes/dropIn/DropInPlatformApi.swift +++ b/ios/Classes/dropIn/DropInPlatformApi.swift @@ -385,20 +385,15 @@ extension DropInPlatformApi: CardComponentDelegate { } func didChangeCardBrand(_ value: [Adyen.CardBrand]?, component: Adyen.CardComponent) { - do { - guard let binLookupData = value else { - return - } - var binLookupDataList: [[String: Any]] = [] - for item in binLookupData { - var jsonObject: [String: Any] = [:] - jsonObject[Constants.brandKey] = item.type.rawValue - binLookupDataList.append(jsonObject) - } - - let data = try JSONSerialization.data(withJSONObject: binLookupDataList, options: []) - let checkoutEvent = CheckoutEvent(type: CheckoutEventType.binLookup, data: String(data: data, encoding: .utf8)) - checkoutFlutter.send(event: checkoutEvent, completion: { _ in }) - } catch {} + guard let binLookupData = value else { + return + } + + let binLookupDataDtoList: [BinLookupDataDTO] = binLookupData.map { cardBrand in + BinLookupDataDTO(brand: cardBrand.type.rawValue) + } + + let checkoutEvent = CheckoutEvent(type: CheckoutEventType.binLookup, data: binLookupDataDtoList) + checkoutFlutter.send(event: checkoutEvent, completion: { _ in }) } } diff --git a/ios/Classes/generated/PlatformApi.swift b/ios/Classes/generated/PlatformApi.swift index 9df4fcf1..50e7c38b 100644 --- a/ios/Classes/generated/PlatformApi.swift +++ b/ios/Classes/generated/PlatformApi.swift @@ -1258,6 +1258,26 @@ struct OrderCancelResultDTO { } } +/// Generated class from Pigeon that represents data sent in messages. +struct BinLookupDataDTO { + var brand: String + + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> BinLookupDataDTO? { + let brand = __pigeon_list[0] as! String + + return BinLookupDataDTO( + brand: brand + ) + } + + func toList() -> [Any?] { + [ + brand + ] + } +} + private class PlatformApiPigeonCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { @@ -1320,125 +1340,127 @@ private class PlatformApiPigeonCodecReader: FlutterStandardReader { case 157: return OrderCancelResultDTO.fromList(self.readValue() as! [Any?]) case 158: + return BinLookupDataDTO.fromList(self.readValue() as! [Any?]) + case 159: var enumResult: Environment? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = Environment(rawValue: enumResultAsInt) } return enumResult - case 159: + case 160: var enumResult: AddressMode? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = AddressMode(rawValue: enumResultAsInt) } return enumResult - case 160: + case 161: var enumResult: CardAuthMethod? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = CardAuthMethod(rawValue: enumResultAsInt) } return enumResult - case 161: + case 162: var enumResult: TotalPriceStatus? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = TotalPriceStatus(rawValue: enumResultAsInt) } return enumResult - case 162: + case 163: var enumResult: GooglePayEnvironment? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = GooglePayEnvironment(rawValue: enumResultAsInt) } return enumResult - case 163: + case 164: var enumResult: CashAppPayEnvironment? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = CashAppPayEnvironment(rawValue: enumResultAsInt) } return enumResult - case 164: + case 165: var enumResult: PaymentResultEnum? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = PaymentResultEnum(rawValue: enumResultAsInt) } return enumResult - case 165: + case 166: var enumResult: CheckoutEventType? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = CheckoutEventType(rawValue: enumResultAsInt) } return enumResult - case 166: + case 167: var enumResult: ComponentCommunicationType? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = ComponentCommunicationType(rawValue: enumResultAsInt) } return enumResult - case 167: + case 168: var enumResult: PaymentEventType? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = PaymentEventType(rawValue: enumResultAsInt) } return enumResult - case 168: + case 169: var enumResult: FieldVisibility? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = FieldVisibility(rawValue: enumResultAsInt) } return enumResult - case 169: + case 170: var enumResult: InstantPaymentType? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = InstantPaymentType(rawValue: enumResultAsInt) } return enumResult - case 170: + case 171: var enumResult: ApplePayShippingType? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = ApplePayShippingType(rawValue: enumResultAsInt) } return enumResult - case 171: + case 172: var enumResult: ApplePayMerchantCapability? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = ApplePayMerchantCapability(rawValue: enumResultAsInt) } return enumResult - case 172: + case 173: var enumResult: ApplePaySummaryItemType? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = ApplePaySummaryItemType(rawValue: enumResultAsInt) } return enumResult - case 173: + case 174: var enumResult: CardNumberValidationResultDTO? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = CardNumberValidationResultDTO(rawValue: enumResultAsInt) } return enumResult - case 174: + case 175: var enumResult: CardExpiryDateValidationResultDTO? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { enumResult = CardExpiryDateValidationResultDTO(rawValue: enumResultAsInt) } return enumResult - case 175: + case 176: var enumResult: CardSecurityCodeValidationResultDTO? = nil let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) if let enumResultAsInt { @@ -1540,59 +1562,62 @@ private class PlatformApiPigeonCodecWriter: FlutterStandardWriter { } else if let value = value as? OrderCancelResultDTO { super.writeByte(157) super.writeValue(value.toList()) - } else if let value = value as? Environment { + } else if let value = value as? BinLookupDataDTO { super.writeByte(158) + super.writeValue(value.toList()) + } else if let value = value as? Environment { + super.writeByte(159) super.writeValue(value.rawValue) } else if let value = value as? AddressMode { - super.writeByte(159) + super.writeByte(160) super.writeValue(value.rawValue) } else if let value = value as? CardAuthMethod { - super.writeByte(160) + super.writeByte(161) super.writeValue(value.rawValue) } else if let value = value as? TotalPriceStatus { - super.writeByte(161) + super.writeByte(162) super.writeValue(value.rawValue) } else if let value = value as? GooglePayEnvironment { - super.writeByte(162) + super.writeByte(163) super.writeValue(value.rawValue) } else if let value = value as? CashAppPayEnvironment { - super.writeByte(163) + super.writeByte(164) super.writeValue(value.rawValue) } else if let value = value as? PaymentResultEnum { - super.writeByte(164) + super.writeByte(165) super.writeValue(value.rawValue) } else if let value = value as? CheckoutEventType { - super.writeByte(165) + super.writeByte(166) super.writeValue(value.rawValue) } else if let value = value as? ComponentCommunicationType { - super.writeByte(166) + super.writeByte(167) super.writeValue(value.rawValue) } else if let value = value as? PaymentEventType { - super.writeByte(167) + super.writeByte(168) super.writeValue(value.rawValue) } else if let value = value as? FieldVisibility { - super.writeByte(168) + super.writeByte(169) super.writeValue(value.rawValue) } else if let value = value as? InstantPaymentType { - super.writeByte(169) + super.writeByte(170) super.writeValue(value.rawValue) } else if let value = value as? ApplePayShippingType { - super.writeByte(170) + super.writeByte(171) super.writeValue(value.rawValue) } else if let value = value as? ApplePayMerchantCapability { - super.writeByte(171) + super.writeByte(172) super.writeValue(value.rawValue) } else if let value = value as? ApplePaySummaryItemType { - super.writeByte(172) + super.writeByte(173) super.writeValue(value.rawValue) } else if let value = value as? CardNumberValidationResultDTO { - super.writeByte(173) + super.writeByte(174) super.writeValue(value.rawValue) } else if let value = value as? CardExpiryDateValidationResultDTO { - super.writeByte(174) + super.writeByte(175) super.writeValue(value.rawValue) } else if let value = value as? CardSecurityCodeValidationResultDTO { - super.writeByte(175) + super.writeByte(176) super.writeValue(value.rawValue) } else { super.writeValue(value) @@ -2112,7 +2137,7 @@ class ComponentPlatformInterfaceSetup { /// 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 _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, binLookupDataDTO binLookupDataDTOArg: BinLookupDataDTO, completion: @escaping (Result) -> Void) func onComponentCommunication(componentCommunicationModel componentCommunicationModelArg: ComponentCommunicationModel, completion: @escaping (Result) -> Void) } @@ -2128,10 +2153,10 @@ class ComponentFlutterInterface: ComponentFlutterInterfaceProtocol { PlatformApiPigeonCodec.shared } - func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, completion: @escaping (Result) -> Void) { + func _generateCodecForDTOs(cardComponentConfigurationDTO cardComponentConfigurationDTOArg: CardComponentConfigurationDTO, sessionDTO sessionDTOArg: SessionDTO, binLookupDataDTO binLookupDataDTOArg: BinLookupDataDTO, completion: @escaping (Result) -> Void) { let channelName = "dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs\(messageChannelSuffix)" let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([cardComponentConfigurationDTOArg, sessionDTOArg] as [Any?]) { response in + channel.sendMessage([cardComponentConfigurationDTOArg, sessionDTOArg, binLookupDataDTOArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index a256e96f..48302622 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -349,41 +349,21 @@ class DropIn { CheckoutEvent event, CardConfiguration? cardConfiguration, ) { - if (cardConfiguration?.cardCallbacks == null || - cardConfiguration?.cardCallbacks?.onBinLookup == null) { - adyenLogger.print("onBinLookup callback not provided."); - return; + if (event.data case List binLookupDataDTOList) { + final List binLookupDataList = binLookupDataDTOList + .whereType() + .map((entry) => BinLookupData(brand: entry.brand)) + .toList(); + cardConfiguration?.cardCallbacks?.onBinLookup?.call(binLookupDataList); } - - final encodedBinLookupData = event.data as String?; - if (encodedBinLookupData == null) { - adyenLogger.print("BinLookup data is null."); - return; - } - - final List binLookupDataJson = jsonDecode(encodedBinLookupData); - final List binLookupDataList = binLookupDataJson - .map((entry) => BinLookupData(brand: entry['brand'])) - .toList(); - cardConfiguration?.cardCallbacks?.onBinLookup?.call(binLookupDataList); } void _handleOnBinValue( CheckoutEvent event, CardConfiguration? cardConfiguration, ) { - if (cardConfiguration?.cardCallbacks == null || - cardConfiguration?.cardCallbacks?.onBinValue == null) { - adyenLogger.print("onBinValue callback not provided."); - return; + if (event.data case String binValue) { + cardConfiguration?.cardCallbacks?.onBinValue?.call(binValue); } - - final binValue = event.data as String?; - if (binValue == null) { - adyenLogger.print("BinValue is null."); - return; - } - - cardConfiguration?.cardCallbacks?.onBinValue?.call(binValue); } } diff --git a/lib/src/generated/platform_api.g.dart b/lib/src/generated/platform_api.g.dart index 4c3437bc..f0e18b43 100644 --- a/lib/src/generated/platform_api.g.dart +++ b/lib/src/generated/platform_api.g.dart @@ -1376,6 +1376,27 @@ class OrderCancelResultDTO { } } +class BinLookupDataDTO { + BinLookupDataDTO({ + required this.brand, + }); + + String brand; + + Object encode() { + return [ + brand, + ]; + } + + static BinLookupDataDTO decode(Object result) { + result as List; + return BinLookupDataDTO( + brand: result[0]! as String, + ); + } +} + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -1467,59 +1488,62 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is OrderCancelResultDTO) { buffer.putUint8(157); writeValue(buffer, value.encode()); - } else if (value is Environment) { + } else if (value is BinLookupDataDTO) { buffer.putUint8(158); + writeValue(buffer, value.encode()); + } else if (value is Environment) { + buffer.putUint8(159); writeValue(buffer, value.index); } else if (value is AddressMode) { - buffer.putUint8(159); + buffer.putUint8(160); writeValue(buffer, value.index); } else if (value is CardAuthMethod) { - buffer.putUint8(160); + buffer.putUint8(161); writeValue(buffer, value.index); } else if (value is TotalPriceStatus) { - buffer.putUint8(161); + buffer.putUint8(162); writeValue(buffer, value.index); } else if (value is GooglePayEnvironment) { - buffer.putUint8(162); + buffer.putUint8(163); writeValue(buffer, value.index); } else if (value is CashAppPayEnvironment) { - buffer.putUint8(163); + buffer.putUint8(164); writeValue(buffer, value.index); } else if (value is PaymentResultEnum) { - buffer.putUint8(164); + buffer.putUint8(165); writeValue(buffer, value.index); } else if (value is CheckoutEventType) { - buffer.putUint8(165); + buffer.putUint8(166); writeValue(buffer, value.index); } else if (value is ComponentCommunicationType) { - buffer.putUint8(166); + buffer.putUint8(167); writeValue(buffer, value.index); } else if (value is PaymentEventType) { - buffer.putUint8(167); + buffer.putUint8(168); writeValue(buffer, value.index); } else if (value is FieldVisibility) { - buffer.putUint8(168); + buffer.putUint8(169); writeValue(buffer, value.index); } else if (value is InstantPaymentType) { - buffer.putUint8(169); + buffer.putUint8(170); writeValue(buffer, value.index); } else if (value is ApplePayShippingType) { - buffer.putUint8(170); + buffer.putUint8(171); writeValue(buffer, value.index); } else if (value is ApplePayMerchantCapability) { - buffer.putUint8(171); + buffer.putUint8(172); writeValue(buffer, value.index); } else if (value is ApplePaySummaryItemType) { - buffer.putUint8(172); + buffer.putUint8(173); writeValue(buffer, value.index); } else if (value is CardNumberValidationResultDTO) { - buffer.putUint8(173); + buffer.putUint8(174); writeValue(buffer, value.index); } else if (value is CardExpiryDateValidationResultDTO) { - buffer.putUint8(174); + buffer.putUint8(175); writeValue(buffer, value.index); } else if (value is CardSecurityCodeValidationResultDTO) { - buffer.putUint8(175); + buffer.putUint8(176); writeValue(buffer, value.index); } else { super.writeValue(buffer, value); @@ -1588,61 +1612,63 @@ class _PigeonCodec extends StandardMessageCodec { case 157: return OrderCancelResultDTO.decode(readValue(buffer)!); case 158: + return BinLookupDataDTO.decode(readValue(buffer)!); + case 159: final int? value = readValue(buffer) as int?; return value == null ? null : Environment.values[value]; - case 159: + case 160: final int? value = readValue(buffer) as int?; return value == null ? null : AddressMode.values[value]; - case 160: + case 161: final int? value = readValue(buffer) as int?; return value == null ? null : CardAuthMethod.values[value]; - case 161: + case 162: final int? value = readValue(buffer) as int?; return value == null ? null : TotalPriceStatus.values[value]; - case 162: + case 163: final int? value = readValue(buffer) as int?; return value == null ? null : GooglePayEnvironment.values[value]; - case 163: + case 164: final int? value = readValue(buffer) as int?; return value == null ? null : CashAppPayEnvironment.values[value]; - case 164: + case 165: final int? value = readValue(buffer) as int?; return value == null ? null : PaymentResultEnum.values[value]; - case 165: + case 166: final int? value = readValue(buffer) as int?; return value == null ? null : CheckoutEventType.values[value]; - case 166: + case 167: final int? value = readValue(buffer) as int?; return value == null ? null : ComponentCommunicationType.values[value]; - case 167: + case 168: final int? value = readValue(buffer) as int?; return value == null ? null : PaymentEventType.values[value]; - case 168: + case 169: final int? value = readValue(buffer) as int?; return value == null ? null : FieldVisibility.values[value]; - case 169: + case 170: final int? value = readValue(buffer) as int?; return value == null ? null : InstantPaymentType.values[value]; - case 170: + case 171: final int? value = readValue(buffer) as int?; return value == null ? null : ApplePayShippingType.values[value]; - case 171: + case 172: final int? value = readValue(buffer) as int?; return value == null ? null : ApplePayMerchantCapability.values[value]; - case 172: + case 173: final int? value = readValue(buffer) as int?; return value == null ? null : ApplePaySummaryItemType.values[value]; - case 173: + case 174: final int? value = readValue(buffer) as int?; return value == null ? null : CardNumberValidationResultDTO.values[value]; - case 174: + case 175: final int? value = readValue(buffer) as int?; return value == null ? null : CardExpiryDateValidationResultDTO.values[value]; - case 175: + case 176: final int? value = readValue(buffer) as int?; return value == null ? null @@ -2425,7 +2451,8 @@ abstract class ComponentFlutterInterface { void _generateCodecForDTOs( CardComponentConfigurationDTO cardComponentConfigurationDTO, - SessionDTO sessionDTO); + SessionDTO sessionDTO, + BinLookupDataDTO binLookupDataDTO); void onComponentCommunication( ComponentCommunicationModel componentCommunicationModel); @@ -2458,9 +2485,13 @@ abstract class ComponentFlutterInterface { 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.'); + final BinLookupDataDTO? arg_binLookupDataDTO = + (args[2] as BinLookupDataDTO?); + assert(arg_binLookupDataDTO != null, + 'Argument for dev.flutter.pigeon.adyen_checkout.ComponentFlutterInterface._generateCodecForDTOs was null, expected non-null BinLookupDataDTO.'); try { - api._generateCodecForDTOs( - arg_cardComponentConfigurationDTO!, arg_sessionDTO!); + api._generateCodecForDTOs(arg_cardComponentConfigurationDTO!, + arg_sessionDTO!, arg_binLookupDataDTO!); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); diff --git a/pigeons/platform_api.dart b/pigeons/platform_api.dart index e5336847..a7226cfd 100644 --- a/pigeons/platform_api.dart +++ b/pigeons/platform_api.dart @@ -608,6 +608,12 @@ class OrderCancelResultDTO { ); } +class BinLookupDataDTO { + final String brand; + + BinLookupDataDTO({required this.brand}); +} + @HostApi() abstract class CheckoutPlatformInterface { @async @@ -724,6 +730,7 @@ abstract class ComponentFlutterInterface { void _generateCodecForDTOs( CardComponentConfigurationDTO cardComponentConfigurationDTO, SessionDTO sessionDTO, + BinLookupDataDTO binLookupDataDTO, ); void onComponentCommunication( From 47d965ccd3a9b9582322b453c43fddbcb53ce0e9 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 20 Feb 2025 15:00:15 +0100 Subject: [PATCH 08/12] Remove unnecessary exception catching --- .../dropIn/session/SessionDropInService.kt | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt index 12549e80..6b4e6134 100644 --- a/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt +++ b/android/src/main/kotlin/com/adyen/checkout/flutter/dropIn/session/SessionDropInService.kt @@ -2,7 +2,6 @@ package com.adyen.checkout.flutter.dropIn.session import android.content.Intent import android.os.IBinder -import android.util.Log import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ServiceLifecycleDispatcher @@ -21,7 +20,6 @@ import com.adyen.checkout.flutter.generated.BinLookupDataDTO import com.adyen.checkout.flutter.generated.DeletedStoredPaymentMethodResultDTO import com.adyen.checkout.flutter.generated.CheckoutEvent import com.adyen.checkout.flutter.generated.CheckoutEventType -import com.adyen.checkout.flutter.utils.Constants.Companion.ADYEN_LOG_TAG import kotlinx.coroutines.launch class SessionDropInService : SessionDropInService(), LifecycleOwner { @@ -43,17 +41,13 @@ class SessionDropInService : SessionDropInService(), LifecycleOwner { override fun onBinLookup(data: List) { lifecycleScope.launch { - try { - val binLookupDataList = data.map { BinLookupDataDTO(it.brand) } - val checkoutEvent = - CheckoutEvent( - CheckoutEventType.BIN_LOOKUP, - binLookupDataList - ) - DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) - } catch (exception: Exception) { - Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") - } + val binLookupDataDtoList = data.map { BinLookupDataDTO(it.brand) } + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.BIN_LOOKUP, + binLookupDataDtoList + ) + DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } } From 84665d4778a48dc4017aead24881db9c4e862e93 Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 20 Feb 2025 15:23:43 +0100 Subject: [PATCH 09/12] removed unnecessary try/catch --- .../dropIn/advanced/AdvancedDropInService.kt | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 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 e2eede9b..f22633c0 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,6 @@ package com.adyen.checkout.flutter.dropIn.advanced import android.content.Intent import android.os.IBinder -import android.util.Log import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ServiceLifecycleDispatcher @@ -35,7 +34,6 @@ import com.adyen.checkout.flutter.generated.PaymentEventType import com.adyen.checkout.flutter.generated.CheckoutEvent import com.adyen.checkout.flutter.generated.CheckoutEventType import com.adyen.checkout.flutter.utils.Constants -import com.adyen.checkout.flutter.utils.Constants.Companion.ADYEN_LOG_TAG import com.adyen.checkout.googlepay.GooglePayComponentState import kotlinx.coroutines.launch import org.json.JSONObject @@ -109,17 +107,13 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { override fun onBinLookup(data: List) { lifecycleScope.launch { - try { - val binLookupDataList = data.map { BinLookupDataDTO(it.brand) } - val checkoutEvent = - CheckoutEvent( - CheckoutEventType.BIN_LOOKUP, - binLookupDataList - ) - DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) - } catch (exception: Exception) { - Log.d(ADYEN_LOG_TAG, "BinLookupData parsing failed: ${exception.message}") - } + val binLookupDataList = data.map { BinLookupDataDTO(it.brand) } + val checkoutEvent = + CheckoutEvent( + CheckoutEventType.BIN_LOOKUP, + binLookupDataList + ) + DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } } From 2a5cab7fda3705e4434e5c81edf9933cf5f14e0a Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 20 Feb 2025 15:23:55 +0100 Subject: [PATCH 10/12] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f1437e4..26845db8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### New +- Added bin lookup callbacks for Drop-In. - Set minimum SDK version to Flutter 3.16/Dart 3.2 - Android Components/Drop-in version: [5.9.0](https://docs.adyen.com/online-payments/release-notes/?title%5B0%5D=Android+Components%2FDrop-in#releaseNote=2025-01-17-android-componentsdrop-in-5.9.0). From 03aec32fda559cfb6219f1fa6406c4a739670e8d Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Thu, 20 Feb 2025 15:39:47 +0100 Subject: [PATCH 11/12] Naming alignment --- .../checkout/flutter/dropIn/advanced/AdvancedDropInService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 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 f22633c0..d572fe85 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 @@ -107,11 +107,11 @@ class AdvancedDropInService : DropInService(), LifecycleOwner { override fun onBinLookup(data: List) { lifecycleScope.launch { - val binLookupDataList = data.map { BinLookupDataDTO(it.brand) } + val binLookupDataDtoList = data.map { BinLookupDataDTO(it.brand) } val checkoutEvent = CheckoutEvent( CheckoutEventType.BIN_LOOKUP, - binLookupDataList + binLookupDataDtoList ) DropInPlatformApi.dropInMessageFlow.emit(checkoutEvent) } From 1e4def165e240718e818b360cfb450c7c5c508cd Mon Sep 17 00:00:00 2001 From: Robert Schulze Dieckhoff Date: Wed, 5 Mar 2025 09:20:34 +0100 Subject: [PATCH 12/12] Added early return for binLookup and binValue --- lib/src/drop_in/drop_in.dart | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/src/drop_in/drop_in.dart b/lib/src/drop_in/drop_in.dart index 48302622..bd89810f 100644 --- a/lib/src/drop_in/drop_in.dart +++ b/lib/src/drop_in/drop_in.dart @@ -51,9 +51,15 @@ class DropIn { dropInConfiguration.storedPaymentMethodConfiguration, ); case CheckoutEventType.binLookup: - _handleOnBinLookup(event, dropInConfiguration.cardConfiguration); + _handleOnBinLookup( + event, + dropInConfiguration.cardConfiguration?.cardCallbacks?.onBinLookup, + ); case CheckoutEventType.binValue: - _handleOnBinValue(event, dropInConfiguration.cardConfiguration); + _handleOnBinValue( + event, + dropInConfiguration.cardConfiguration?.cardCallbacks?.onBinValue, + ); default: } }); @@ -128,9 +134,15 @@ class DropIn { case CheckoutEventType.cancelOrder: _handleOrderCancel(event, advancedCheckout.partialPayment); case CheckoutEventType.binLookup: - _handleOnBinLookup(event, dropInConfiguration.cardConfiguration); + _handleOnBinLookup( + event, + dropInConfiguration.cardConfiguration?.cardCallbacks?.onBinLookup, + ); case CheckoutEventType.binValue: - _handleOnBinValue(event, dropInConfiguration.cardConfiguration); + _handleOnBinValue( + event, + dropInConfiguration.cardConfiguration?.cardCallbacks?.onBinValue, + ); } }); @@ -347,23 +359,31 @@ class DropIn { void _handleOnBinLookup( CheckoutEvent event, - CardConfiguration? cardConfiguration, + Function? binLookupCallback, ) { + if (binLookupCallback == null) { + return; + } + if (event.data case List binLookupDataDTOList) { final List binLookupDataList = binLookupDataDTOList .whereType() .map((entry) => BinLookupData(brand: entry.brand)) .toList(); - cardConfiguration?.cardCallbacks?.onBinLookup?.call(binLookupDataList); + binLookupCallback.call(binLookupDataList); } } void _handleOnBinValue( CheckoutEvent event, - CardConfiguration? cardConfiguration, + Function? binValueCallback, ) { + if (binValueCallback == null) { + return; + } + if (event.data case String binValue) { - cardConfiguration?.cardCallbacks?.onBinValue?.call(binValue); + binValueCallback.call(binValue); } } }