Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disabled ktlint for PlatformApi.kt because the class is generated code
diff --git a/android/.editorconfig b/android/.editorconfig index c04ece5..911c5a6 100644 --- a/android/.editorconfig +++ b/android/.editorconfig @@ -106,7 +106,7 @@ ij_java_for_statement_wrap = off ij_java_generate_final_locals = false ij_java_generate_final_parameters = false ij_java_if_brace_force = never -ij_java_imports_layout = $android.**,$androidx.**,$com.**,$junit.**,$net.**,$org.**,$java.**,$javax.**,$*,|,android.**,|,androidx.**,|,com.**,|,junit.**,|,net.**,|,org.**,|,java.**,|,javax.**,|,*,| +ij_java_imports_layout = $android.**, $androidx.**, $com.**, $junit.**, $net.**, $org.**, $java.**, $javax.**, $*, |, android.**, |, androidx.**, |, com.**, |, junit.**, |, net.**, |, org.**, |, java.**, |, javax.**, |, *, | ij_java_indent_case_from_switch = true ij_java_insert_inner_class_imports = false ij_java_insert_override_annotation = true @@ -347,7 +347,7 @@ ij_groovy_for_statement_right_paren_on_new_line = false ij_groovy_for_statement_wrap = off ij_groovy_if_brace_force = never ij_groovy_import_annotation_wrap = 2 -ij_groovy_imports_layout = *,|,javax.**,java.**,|,$* +ij_groovy_imports_layout = *, |, javax.**, java.**, |, $* ij_groovy_indent_case_from_switch = true ij_groovy_indent_label_blocks = true ij_groovy_insert_inner_class_imports = false @@ -472,6 +472,7 @@ ij_groovy_wrap_long_lines = false # noinspection EditorConfigKeyCorrectness [{*.kt,*.kts}] +ktlint_code_style = ktlint_official ktlint_standard_import-ordering = disabled ktlint_standard_multiline-if-else = disabled ktlint_standard_trailing-comma-on-call-site = disabled @@ -511,7 +512,7 @@ ij_kotlin_field_annotation_wrap = split_into_lines ij_kotlin_finally_on_new_line = false ij_kotlin_if_rparen_on_new_line = true ij_kotlin_import_nested_classes = false -ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^ +ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^ ij_kotlin_insert_whitespaces_in_simple_one_line_method = true ij_kotlin_keep_blank_lines_before_right_brace = 2 ij_kotlin_keep_blank_lines_in_code = 2 @@ -529,7 +530,7 @@ ij_kotlin_method_parameters_right_paren_on_new_line = true ij_kotlin_method_parameters_wrap = on_every_item ij_kotlin_name_count_to_use_star_import = 2147483647 ij_kotlin_name_count_to_use_star_import_for_members = 2147483647 -ij_kotlin_packages_to_use_import_on_demand = kotlinx.android.synthetic.**,io.ktor.** +ij_kotlin_packages_to_use_import_on_demand = kotlinx.android.synthetic.**, io.ktor.** ij_kotlin_parameter_annotation_wrap = off ij_kotlin_space_after_comma = true ij_kotlin_space_after_extend_colon = true @@ -574,22 +575,22 @@ ij_json_spaces_within_brackets = false ij_json_wrap_long_lines = false [{*.htm,*.html,*.sht,*.shtm,*.shtml}] -ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3 +ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3 ij_html_align_attributes = true ij_html_align_text = false ij_html_attribute_wrap = normal ij_html_block_comment_at_first_column = true ij_html_do_not_align_children_of_min_lines = 0 -ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p -ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot +ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p +ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot ij_html_enforce_quotes = false -ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var +ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var ij_html_keep_blank_lines = 2 ij_html_keep_indents_on_empty_lines = false ij_html_keep_line_breaks = true ij_html_keep_line_breaks_in_text = true ij_html_keep_whitespaces = false -ij_html_keep_whitespaces_inside = span,pre,textarea +ij_html_keep_whitespaces_inside = span, pre, textarea ij_html_line_comment_at_first_column = true ij_html_new_line_after_last_attribute = never ij_html_new_line_before_first_attribute = never @@ -612,3 +613,7 @@ ij_yaml_sequence_on_new_line = false ij_yaml_space_before_colon = false ij_yaml_spaces_within_braces = true ij_yaml_spaces_within_brackets = true + + +[{PlatformApi.kt,PlatformApi.kts}] +ktlint_standard = disabled diff --git a/android/src/main/kotlin/com/adyen/adyen_checkout/AdyenCheckoutPlugin.kt b/android/src/main/kotlin/com/adyen/adyen_checkout/AdyenCheckoutPlugin.kt index c2aa5cb..74e635d 100644 --- a/android/src/main/kotlin/com/adyen/adyen_checkout/AdyenCheckoutPlugin.kt +++ b/android/src/main/kotlin/com/adyen/adyen_checkout/AdyenCheckoutPlugin.kt @@ -21,7 +21,6 @@ import io.flutter.embedding.engine.plugins.FlutterPlugin import io.flutter.embedding.engine.plugins.activity.ActivityAware import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding import io.flutter.embedding.engine.plugins.lifecycle.HiddenLifecycleReference -import DropInResult as FlutterDropInResult /** AdyenCheckoutPlugin */ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware { @@ -45,8 +44,9 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware { override fun onDetachedFromActivityForConfigChanges() = teardown() - override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) = - setupActivity(binding) + override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) = setupActivity( + binding + ) override fun onDetachedFromActivity() = teardown() @@ -70,10 +70,9 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware { Lifecycle.Event.ON_CREATE -> { checkoutPlatformApi?.dropInSessionLauncher = DropIn.registerForDropInResult(fragmentActivity, sessionDropInCallback()) - checkoutPlatformApi?.dropInAdvancedFlowLauncher = - DropIn.registerForDropInResult( - fragmentActivity, dropInAdvancedFlowCallback - ) + checkoutPlatformApi?.dropInAdvancedFlowLauncher = DropIn.registerForDropInResult( + fragmentActivity, dropInAdvancedFlowCallback + ) } else -> {} @@ -92,11 +91,13 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware { ) is SessionDropInResult.Error -> PaymentResult( - PaymentResultEnum.ERROR, reason = sessionDropInResult.reason + PaymentResultEnum.ERROR, + reason = sessionDropInResult.reason ) is SessionDropInResult.Finished -> PaymentResult( - PaymentResultEnum.FINISHED, result = with(sessionDropInResult.result) { + PaymentResultEnum.FINISHED, + result = with(sessionDropInResult.result) { PaymentResultModel( sessionId, sessionData, @@ -120,18 +121,22 @@ class AdyenCheckoutPlugin : FlutterPlugin, ActivityAware { ) is DropInResult.Error -> PaymentResult( - PaymentResultEnum.ERROR, reason = dropInAdvancedFlowResult.reason + PaymentResultEnum.ERROR, + reason = dropInAdvancedFlowResult.reason ) is DropInResult.Finished -> PaymentResult( - PaymentResultEnum.FINISHED, result = PaymentResultModel( + PaymentResultEnum.FINISHED, + result = PaymentResultModel( resultCode = dropInAdvancedFlowResult.result ) ) } val model = PlatformCommunicationModel( - PlatformCommunicationType.RESULT, data = "", paymentResult = mappedResult + PlatformCommunicationType.RESULT, + data = "", + paymentResult = mappedResult ) checkoutFlutterApi?.onDropInAdvancedFlowPlatformCommunication(model) {} } diff --git a/android/src/main/kotlin/com/adyen/adyen_checkout/CheckoutPlatformApi.kt b/android/src/main/kotlin/com/adyen/adyen_checkout/CheckoutPlatformApi.kt index eddc4c9..bd858f6 100644 --- a/android/src/main/kotlin/com/adyen/adyen_checkout/CheckoutPlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/adyen_checkout/CheckoutPlatformApi.kt @@ -35,136 +35,139 @@ import org.json.JSONObject @Suppress("NAME_SHADOWING") class CheckoutPlatformApi(private val checkoutFlutterApi: CheckoutFlutterApi?) : CheckoutPlatformInterface { - lateinit var activity: FragmentActivity - lateinit var dropInSessionLauncher: ActivityResultLauncher<SessionDropInResultContractParams> - lateinit var dropInAdvancedFlowLauncher: ActivityResultLauncher<DropInResultContractParams> + lateinit var activity: FragmentActivity + lateinit var dropInSessionLauncher: + ActivityResultLauncher<SessionDropInResultContractParams> + lateinit var dropInAdvancedFlowLauncher: ActivityResultLauncher<DropInResultContractParams> - override fun getPlatformVersion(callback: (Result<String>) -> Unit) { - callback.invoke(Result.success("Android ${android.os.Build.VERSION.RELEASE}")) - } + override fun getPlatformVersion(callback: (Result<String>) -> Unit) { + callback.invoke(Result.success("Android ${android.os.Build.VERSION.RELEASE}")) + } - override fun getReturnUrl(callback: (Result<String>) -> Unit) { - callback(Result.success(RedirectComponent.getReturnUrl(activity.applicationContext))) - } + override fun getReturnUrl(callback: (Result<String>) -> Unit) { + callback(Result.success(RedirectComponent.getReturnUrl(activity.applicationContext))) + } - override fun startDropInSessionPayment( - dropInConfiguration: DropInConfiguration, - session: Session, - ) { - checkForFlutterFragmentActivity() - activity.lifecycleScope.launch(Dispatchers.IO) { - val sessionModel = session.mapToSession() - val dropInConfiguration = - dropInConfiguration.mapToDropInConfiguration(activity.applicationContext) - val checkoutSession = createCheckoutSession(sessionModel, dropInConfiguration) - withContext(Dispatchers.Main) { - DropIn.startPayment( - activity.applicationContext, - dropInSessionLauncher, - checkoutSession, - dropInConfiguration, - ) + override fun startDropInSessionPayment( + dropInConfiguration: DropInConfiguration, + session: Session, + ) { + checkForFlutterFragmentActivity() + activity.lifecycleScope.launch(Dispatchers.IO) { + val sessionModel = session.mapToSession() + val dropInConfiguration = + dropInConfiguration.mapToDropInConfiguration(activity.applicationContext) + val checkoutSession = createCheckoutSession(sessionModel, dropInConfiguration) + withContext(Dispatchers.Main) { + DropIn.startPayment( + activity.applicationContext, + dropInSessionLauncher, + checkoutSession, + dropInConfiguration, + ) + } } } - } - override fun startDropInAdvancedFlowPayment( - dropInConfiguration: DropInConfiguration, - paymentMethodsResponse: String, - ) { - checkForFlutterFragmentActivity() - setAdvancedFlowDropInServiceObserver() - activity.lifecycleScope.launch(Dispatchers.IO) { - val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize( - JSONObject(paymentMethodsResponse), - ) - val paymentMethodsWithoutGiftCards = - removeGiftCardPaymentMethods(paymentMethodsApiResponse) - val dropInConfiguration = - dropInConfiguration.mapToDropInConfiguration(activity.applicationContext) - withContext(Dispatchers.Main) { - DropIn.startPayment( - activity.applicationContext, - dropInAdvancedFlowLauncher, - paymentMethodsWithoutGiftCards, - dropInConfiguration, - AdvancedFlowDropInService::class.java, + override fun startDropInAdvancedFlowPayment( + dropInConfiguration: DropInConfiguration, + paymentMethodsResponse: String, + ) { + checkForFlutterFragmentActivity() + setAdvancedFlowDropInServiceObserver() + activity.lifecycleScope.launch(Dispatchers.IO) { + val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize( + JSONObject(paymentMethodsResponse), ) + val paymentMethodsWithoutGiftCards = + removeGiftCardPaymentMethods(paymentMethodsApiResponse) + val dropInConfiguration = + dropInConfiguration.mapToDropInConfiguration(activity.applicationContext) + withContext(Dispatchers.Main) { + DropIn.startPayment( + activity.applicationContext, + dropInAdvancedFlowLauncher, + paymentMethodsWithoutGiftCards, + dropInConfiguration, + AdvancedFlowDropInService::class.java, + ) + } } } - } - override fun onPaymentsResult(paymentsResult: DropInResult) { - if (paymentsResult.dropInResultType == DropInResultType.ACTION) { - setAdvanceFlowDropInAdditionalDetailsMessengerObserver() - } - - DropInPaymentResultMessenger.sendResult(paymentsResult) - } + override fun onPaymentsResult(paymentsResult: DropInResult) { + if (paymentsResult.dropInResultType == DropInResultType.ACTION) { + setAdvanceFlowDropInAdditionalDetailsMessengerObserver() + } - override fun onPaymentsDetailsResult(paymentsDetailsResult: DropInResult) { - DropInAdditionalDetailsResultMessenger.sendResult(paymentsDetailsResult) - } + DropInPaymentResultMessenger.sendResult(paymentsResult) + } - private suspend fun createCheckoutSession( - sessionModel: com.adyen.checkout.sessions.core.SessionModel, - dropInConfiguration: com.adyen.checkout.dropin.DropInConfiguration, - ): CheckoutSession { - val checkoutSessionResult = - CheckoutSessionProvider.createSession(sessionModel, dropInConfiguration) - return when (checkoutSessionResult) { - is CheckoutSessionResult.Success -> checkoutSessionResult.checkoutSession - is CheckoutSessionResult.Error -> throw checkoutSessionResult.exception + override fun onPaymentsDetailsResult(paymentsDetailsResult: DropInResult) { + DropInAdditionalDetailsResultMessenger.sendResult(paymentsDetailsResult) } - } - private fun setAdvancedFlowDropInServiceObserver() { - DropInServiceResultMessenger.instance().removeObservers(activity) - DropInServiceResultMessenger.instance().observe(activity) { message -> - if (message.hasBeenHandled()) { - return@observe + private suspend fun createCheckoutSession( + sessionModel: com.adyen.checkout.sessions.core.SessionModel, + dropInConfiguration: com.adyen.checkout.dropin.DropInConfiguration, + ): CheckoutSession { + val checkoutSessionResult = + CheckoutSessionProvider.createSession(sessionModel, dropInConfiguration) + return when (checkoutSessionResult) { + is CheckoutSessionResult.Success -> checkoutSessionResult.checkoutSession + is CheckoutSessionResult.Error -> throw checkoutSessionResult.exception } - - val model = PlatformCommunicationModel( - PlatformCommunicationType.PAYMENTCOMPONENT, - data = message.contentIfNotHandled.toString(), - ) - checkoutFlutterApi?.onDropInAdvancedFlowPlatformCommunication(model) {} } - } - private fun setAdvanceFlowDropInAdditionalDetailsMessengerObserver() { - DropInAdditionalDetailsPlatformMessenger.instance().removeObservers(activity) - DropInAdditionalDetailsPlatformMessenger.instance().observe(activity) { message -> - if (message.hasBeenHandled()) { - return@observe + private fun setAdvancedFlowDropInServiceObserver() { + DropInServiceResultMessenger.instance().removeObservers(activity) + DropInServiceResultMessenger.instance().observe(activity) { message -> + if (message.hasBeenHandled()) { + return@observe + } + + val model = PlatformCommunicationModel( + PlatformCommunicationType.PAYMENTCOMPONENT, + data = message.contentIfNotHandled.toString(), + ) + checkoutFlutterApi?.onDropInAdvancedFlowPlatformCommunication(model) {} } + } - val model = PlatformCommunicationModel( - PlatformCommunicationType.ADDITIONALDETAILS, - data = message.contentIfNotHandled.toString(), - ) - checkoutFlutterApi?.onDropInAdvancedFlowPlatformCommunication(model) {} + private fun setAdvanceFlowDropInAdditionalDetailsMessengerObserver() { + DropInAdditionalDetailsPlatformMessenger.instance().removeObservers(activity) + DropInAdditionalDetailsPlatformMessenger.instance().observe(activity) { message -> + if (message.hasBeenHandled()) { + return@observe + } + + val model = PlatformCommunicationModel( + PlatformCommunicationType.ADDITIONALDETAILS, + data = message.contentIfNotHandled.toString(), + ) + checkoutFlutterApi?.onDropInAdvancedFlowPlatformCommunication(model) {} + } } - } - private fun checkForFlutterFragmentActivity() { - if (!this::activity.isInitialized) { - throw Exception(WRONG_FLUTTER_ACTIVITY_USAGE_ERROR_MESSAGE) + private fun checkForFlutterFragmentActivity() { + if (!this::activity.isInitialized) { + throw Exception(WRONG_FLUTTER_ACTIVITY_USAGE_ERROR_MESSAGE) + } } - } - //Gift cards will be supported in a later version - private fun removeGiftCardPaymentMethods(paymentMethodsResponse: PaymentMethodsApiResponse): PaymentMethodsApiResponse { - val giftCardTypeIdentifier = "giftcard" - val storedPaymentMethods = - paymentMethodsResponse.storedPaymentMethods?.filterNot { it.type == giftCardTypeIdentifier } - val paymentMethods = - paymentMethodsResponse.paymentMethods?.filterNot { it.type == giftCardTypeIdentifier } - - return PaymentMethodsApiResponse( - storedPaymentMethods = storedPaymentMethods, - paymentMethods = paymentMethods - ) + // Gift cards will be supported in a later version + private fun removeGiftCardPaymentMethods( + paymentMethodsResponse: PaymentMethodsApiResponse + ): PaymentMethodsApiResponse { + val giftCardTypeIdentifier = "giftcard" + val storedPaymentMethods = + paymentMethodsResponse.storedPaymentMethods?.filterNot { it.type == giftCardTypeIdentifier } + val paymentMethods = + paymentMethodsResponse.paymentMethods?.filterNot { it.type == giftCardTypeIdentifier } + + return PaymentMethodsApiResponse( + storedPaymentMethods = storedPaymentMethods, + paymentMethods = paymentMethods + ) + } } -} diff --git a/android/src/main/kotlin/com/adyen/adyen_checkout/PlatformApi.kt b/android/src/main/kotlin/com/adyen/adyen_checkout/PlatformApi.kt index 5b0559c..2957598 100644 --- a/android/src/main/kotlin/com/adyen/adyen_checkout/PlatformApi.kt +++ b/android/src/main/kotlin/com/adyen/adyen_checkout/PlatformApi.kt @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v11.0.0), do not edit directly. +// Autogenerated from Pigeon (v11.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon diff --git a/android/src/main/kotlin/com/adyen/adyen_checkout/dropInAdvancedFlow/AdvancedFlowDropInService.kt b/android/src/main/kotlin/com/adyen/adyen_checkout/dropInAdvancedFlow/AdvancedFlowDropInService.kt index 5362117..cccafb2 100644 --- a/android/src/main/kotlin/com/adyen/adyen_checkout/dropInAdvancedFlow/AdvancedFlowDropInService.kt +++ b/android/src/main/kotlin/com/adyen/adyen_checkout/dropInAdvancedFlow/AdvancedFlowDropInService.kt @@ -1,8 +1,7 @@ package com.adyen.adyen_checkout.dropInAdvancedFlow - import DropInResult -import DropInResultType.* +import DropInResultType import android.content.Intent import android.os.IBinder import androidx.lifecycle.Lifecycle @@ -83,15 +82,17 @@ class AdvancedFlowDropInService : DropInService(), LifecycleOwner { private fun mapToDropInResult(dropInResult: DropInResult?): DropInServiceResult { return when (dropInResult?.dropInResultType) { - FINISHED -> DropInServiceResult.Finished(result = "${dropInResult.result}") + DropInResultType.FINISHED -> DropInServiceResult.Finished( + result = "${dropInResult.result}" + ) - ERROR -> DropInServiceResult.Error( + DropInResultType.ERROR -> DropInServiceResult.Error( errorDialog = null, reason = dropInResult.error?.reason, dismissDropIn = dropInResult.error?.dismissDropIn ?: false ) - ACTION -> { + DropInResultType.ACTION -> { if (dropInResult.actionResponse == null) { DropInServiceResult.Error( errorDialog = null, @@ -141,4 +142,3 @@ class AdvancedFlowDropInService : DropInService(), LifecycleOwner { override val lifecycle: Lifecycle get() = dispatcher.lifecycle } - diff --git a/android/src/main/kotlin/com/adyen/adyen_checkout/utils/Constants.kt b/android/src/main/kotlin/com/adyen/adyen_checkout/utils/Constants.kt index b85cefb..d4cbe2c 100644 --- a/android/src/main/kotlin/com/adyen/adyen_checkout/utils/Constants.kt +++ b/android/src/main/kotlin/com/adyen/adyen_checkout/utils/Constants.kt @@ -5,4 +5,4 @@ class Constants { const val WRONG_FLUTTER_ACTIVITY_USAGE_ERROR_MESSAGE = "FlutterFragmentActivity not used. Your activity needs to inherit from FlutterFragmentActivity." } -} \ No newline at end of file +} diff --git a/ios/Classes/PlatformApi.swift b/ios/Classes/PlatformApi.swift index 33a473e..0cace8a 100644 --- a/ios/Classes/PlatformApi.swift +++ b/ios/Classes/PlatformApi.swift @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v11.0.0), do not edit directly. +// Autogenerated from Pigeon (v11.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation diff --git a/lib/platform_api.g.dart b/lib/platform_api.g.dart index 6980e9a..5512b87 100644 --- a/lib/platform_api.g.dart +++ b/lib/platform_api.g.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v11.0.0), do not edit directly. +// Autogenerated from Pigeon (v11.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
- Loading branch information