diff --git a/.editorconfig b/.editorconfig index 084314645..c020c0144 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,19 +1,16 @@ -# top-most EditorConfig file root = true [*.{kt,kts}] -# true (recommended) / false +indent_style = space +indent_size = 4 insert_final_newline = true trim_trailing_whitespace = true -# Comma-separated list of rules to disable (Since 0.34.0) -# Note that rules in any ruleset other than the standard ruleset will need to be prefixed -# by the ruleset identifier. -disabled_rules = experimental:annotation, import-ordering, indent -# Max symbols in line max_line_length = 120 +ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL +ij_any_method_parameters_wrap = normal +ij_kotlin_allow_trailing_comma = true +ij_kotlin_allow_trailing_comma_on_call_site = true -# According to https://kotlinlang.org/docs/reference/coding-conventions.html#names-for-test-methods it is acceptable to write method names -# in natural language. When using natural language, the description tends to be longer. Allow lines containing an identifier between -# backticks to be longer than the maximum line length. (Since 0.41.0) [**/test/**.kt] +max-line-length = 120 ktlint_ignore_back_ticked_identifier = true \ No newline at end of file diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index 69f056eb6..d4408591a 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -52,7 +52,7 @@ object Versions { const val espresso = "3.3.0" // Static code analyze - const val ktlint = "0.45.2" + const val ktlint = "0.50.0" const val detect = "1.20.0" // Logger diff --git a/checkout/build.gradle.kts b/checkout/build.gradle.kts index 7081822af..6e53e3be8 100644 --- a/checkout/build.gradle.kts +++ b/checkout/build.gradle.kts @@ -1,9 +1,9 @@ +import com.checkout.buildsrc.BuildConfigFieldName +import com.checkout.buildsrc.applyAndroidJUnit4Configuration import com.checkout.buildsrc.applyAndroidJUnit5Configuration import com.checkout.buildsrc.applyCommonLibConfigurations -import com.checkout.buildsrc.applyAndroidJUnit4Configuration -import com.checkout.buildsrc.applyNetworkConfigurations -import com.checkout.buildsrc.BuildConfigFieldName import com.checkout.buildsrc.applyJacocoTestReport +import com.checkout.buildsrc.applyNetworkConfigurations plugins { id("com.android.library") @@ -26,19 +26,19 @@ android { buildConfigField( "String", BuildConfigFieldName.productVersion, - "\"${CheckoutConfig.version}\"" + "\"${CheckoutConfig.version}\"", ) buildConfigField( "String", BuildConfigFieldName.productName, - "\"${CheckoutConfig.pomName}\"" + "\"${CheckoutConfig.pomName}\"", ) buildConfigField( "String", BuildConfigFieldName.productIdentifier, - "\"${CheckoutConfig.groupId}.${CheckoutConfig.artifactId}\"" + "\"${CheckoutConfig.groupId}.${CheckoutConfig.artifactId}\"", ) consumerProguardFiles("consumer-rules.pro") @@ -51,7 +51,7 @@ android { buildConfigField( "Boolean", BuildConfigFieldName.defaultLogcatMonitoring, - "false" + "false", ) } @@ -59,7 +59,7 @@ android { buildConfigField( "Boolean", BuildConfigFieldName.defaultLogcatMonitoring, - "true" + "true", ) } } diff --git a/checkout/src/main/java/com/checkout/CardValidatorFactory.kt b/checkout/src/main/java/com/checkout/CardValidatorFactory.kt index d214015c5..0185f86cf 100644 --- a/checkout/src/main/java/com/checkout/CardValidatorFactory.kt +++ b/checkout/src/main/java/com/checkout/CardValidatorFactory.kt @@ -23,7 +23,7 @@ public object CardValidatorFactory { ExpiryDateValidator(), CvvValidator(), CardNumberValidator(LuhnChecker()), - EventLoggerProvider.provide() + EventLoggerProvider.provide(), ) } @@ -35,7 +35,7 @@ public object CardValidatorFactory { return CardDetailsValidator( ExpiryDateValidator(), CvvValidator(), - CardNumberValidator(LuhnChecker()) + CardNumberValidator(LuhnChecker()), ) } } diff --git a/checkout/src/main/java/com/checkout/CheckoutApiServiceFactory.kt b/checkout/src/main/java/com/checkout/CheckoutApiServiceFactory.kt index 5f064e9c0..5a6bcda97 100644 --- a/checkout/src/main/java/com/checkout/CheckoutApiServiceFactory.kt +++ b/checkout/src/main/java/com/checkout/CheckoutApiServiceFactory.kt @@ -35,7 +35,7 @@ public object CheckoutApiServiceFactory { public fun create( publicKey: String, environment: Environment, - context: Context + context: Context, ): CheckoutApiService { val logger = EventLoggerProvider.provide() @@ -43,13 +43,13 @@ public object CheckoutApiServiceFactory { return CheckoutApiClient( provideTokenRepository(publicKey, environment), - provideThreeDSExecutor(logger) + provideThreeDSExecutor(logger), ) } private fun provideTokenRepository( publicKey: String, - environment: Environment + environment: Environment, ): TokenRepository = TokenRepositoryImpl( networkApiClient = provideNetworkApiClient(publicKey, environment.url), cardToTokenRequestMapper = CardToTokenRequestMapper(), @@ -59,25 +59,25 @@ public object CheckoutApiServiceFactory { CardValidatorFactory.createInternal(), AddressValidator(), PhoneValidator(), - AddressToAddressValidationRequestDataMapper() + AddressToAddressValidationRequestDataMapper(), ), validateCVVTokenizationDataUseCase = ValidateCVVTokenizationDataUseCase(CVVComponentValidatorFactory.create()), logger = TokenizationEventLogger(EventLoggerProvider.provide()), publicKey = publicKey, - cvvTokenizationNetworkDataMapper = CVVTokenizationNetworkDataMapper() + cvvTokenizationNetworkDataMapper = CVVTokenizationNetworkDataMapper(), ) private fun provideNetworkApiClient( publicKey: String, - url: String + url: String, ) = TokenNetworkApiClient( url, OkHttpProvider.createOkHttpClient(publicKey), - Moshi.Builder().addLast(KotlinJsonAdapterFactory()).build() + Moshi.Builder().addLast(KotlinJsonAdapterFactory()).build(), ) private fun provideThreeDSExecutor(logger: Logger): Executor = ThreeDSExecutor( ProcessThreeDSUseCase(), - ThreeDSEventLogger(logger) + ThreeDSEventLogger(logger), ) } diff --git a/checkout/src/main/java/com/checkout/api/CheckoutApiClient.kt b/checkout/src/main/java/com/checkout/api/CheckoutApiClient.kt index a8e7d1afc..36972b100 100644 --- a/checkout/src/main/java/com/checkout/api/CheckoutApiClient.kt +++ b/checkout/src/main/java/com/checkout/api/CheckoutApiClient.kt @@ -12,7 +12,7 @@ import com.checkout.tokenization.repository.TokenRepository internal class CheckoutApiClient( private val tokenRepository: TokenRepository, - private val threeDSExecutor: Executor + private val threeDSExecutor: Executor, ) : CheckoutApiService { init { diff --git a/checkout/src/main/java/com/checkout/api/logging/ApiClientEventType.kt b/checkout/src/main/java/com/checkout/api/logging/ApiClientEventType.kt index 9f53982b8..9210797cd 100644 --- a/checkout/src/main/java/com/checkout/api/logging/ApiClientEventType.kt +++ b/checkout/src/main/java/com/checkout/api/logging/ApiClientEventType.kt @@ -3,5 +3,5 @@ package com.checkout.api.logging import com.checkout.logging.LoggingEventType internal enum class ApiClientEventType(override val eventId: String) : LoggingEventType { - INITIALIZE("checkout_api_client_initialised") + INITIALIZE("checkout_api_client_initialised"), } diff --git a/checkout/src/main/java/com/checkout/base/model/CardScheme.kt b/checkout/src/main/java/com/checkout/base/model/CardScheme.kt index c225c18e6..7645f770d 100644 --- a/checkout/src/main/java/com/checkout/base/model/CardScheme.kt +++ b/checkout/src/main/java/com/checkout/base/model/CardScheme.kt @@ -43,7 +43,7 @@ public enum class CardScheme( * Card scheme icon. */ @DrawableRes - public val imageId: Int = R.drawable.cko_ic_scheme_placeholder + public val imageId: Int = R.drawable.cko_ic_scheme_placeholder, ) { AMERICAN_EXPRESS( cvvLength = setOf(4), @@ -51,7 +51,7 @@ public enum class CardScheme( eagerRegex = Regex("^3[47]\\d*$"), maxNumberLength = 15, numberSeparatorPattern = listOf(4, 11), - imageId = R.drawable.cko_ic_scheme_amex + imageId = R.drawable.cko_ic_scheme_amex, ), DINERS_CLUB( cvvLength = setOf(3), @@ -59,7 +59,7 @@ public enum class CardScheme( eagerRegex = Regex("^3(0|[68])\\d*$"), maxNumberLength = 19, numberSeparatorPattern = listOf(4, 9, 14, 19), - imageId = R.drawable.cko_ic_scheme_diners + imageId = R.drawable.cko_ic_scheme_diners, ), DISCOVER( cvvLength = setOf(3), @@ -67,7 +67,7 @@ public enum class CardScheme( eagerRegex = Regex("^6(011|4[4-9]|5)\\d*$"), maxNumberLength = 16, numberSeparatorPattern = listOf(4, 9, 14), - imageId = R.drawable.cko_ic_scheme_discover + imageId = R.drawable.cko_ic_scheme_discover, ), JCB( cvvLength = setOf(3), @@ -75,45 +75,45 @@ public enum class CardScheme( eagerRegex = Regex("^35\\d*$"), maxNumberLength = 19, numberSeparatorPattern = listOf(4, 9, 14, 19), - imageId = R.drawable.cko_ic_scheme_jcb + imageId = R.drawable.cko_ic_scheme_jcb, ), MADA( cvvLength = setOf(3), regex = Regex( "^(4(0(0861|1757|6996|7(197|395)|9201)|1(2565|0685|7633|9593)|2(281(7|8|9)|8(331|67(1|2|3)))" + - "|3(1361|2328|4107|9954)|4(0(533|647|795)|5564|6(393|404|672))|5(5(036|708)|7865|7997|8456)" + - "|6(2220|854(0|1|2|3))|8(301(0|1|2)|4783|609(4|5|6)|931(7|8|9))|93428)|5(0(4300|6968|8160)" + - "|13213|2(0058|1076|4(130|514)|9(415|741))|3(0(060|906)|1(095|196)|2013|5(825|989)|6023|7767" + - "|9931)|4(3(085|357)|9760)|5(4180|7606|8848)|8(5265|8(8(4(5|6|7|8|9)|5(0|1))|98(2|3))" + - "|9(005|206)))|6(0(4906|5141)|36120)|9682(0(1|2|3|4|5|6|7|8|9)|1(0|1)))\\d{10}$" + "|3(1361|2328|4107|9954)|4(0(533|647|795)|5564|6(393|404|672))|5(5(036|708)|7865|7997|8456)" + + "|6(2220|854(0|1|2|3))|8(301(0|1|2)|4783|609(4|5|6)|931(7|8|9))|93428)|5(0(4300|6968|8160)" + + "|13213|2(0058|1076|4(130|514)|9(415|741))|3(0(060|906)|1(095|196)|2013|5(825|989)|6023|7767" + + "|9931)|4(3(085|357)|9760)|5(4180|7606|8848)|8(5265|8(8(4(5|6|7|8|9)|5(0|1))|98(2|3))" + + "|9(005|206)))|6(0(4906|5141)|36120)|9682(0(1|2|3|4|5|6|7|8|9)|1(0|1)))\\d{10}$", ), eagerRegex = Regex( "^(4(0(0861|1757|6996|7(197|395)|9201)|1(2565|0685|7633|9593)|2(281(7|8|9)|8(331|67(1|2|3)))" + - "|3(1361|2328|4107|9954)|4(0(533|647|795)|5564|6(393|404|672))|5(5(036|708)|7865|7997|8456)" + - "|6(2220|854(0|1|2|3))|8(301(0|1|2)|4783|609(4|5|6)|931(7|8|9))|93428)" + - "|5(0(4300|6968|8160)|13213|2(0058|1076|4(130|514)|9(415|741))" + - "|3(0(060|906)|1(095|196)|2013|5(825|989)|6023|7767|9931)|4(3(085|357)|9760)|5(4180|7606|8848)" + - "|8(5265|8(8(4(5|6|7|8|9)|5(0|1))|98(2|3))|9(005|206)))|6(0(4906|5141)|36120)" + - "|9682(0(1|2|3|4|5|6|7|8|9)|1(0|1)))\\d*$" + "|3(1361|2328|4107|9954)|4(0(533|647|795)|5564|6(393|404|672))|5(5(036|708)|7865|7997|8456)" + + "|6(2220|854(0|1|2|3))|8(301(0|1|2)|4783|609(4|5|6)|931(7|8|9))|93428)" + + "|5(0(4300|6968|8160)|13213|2(0058|1076|4(130|514)|9(415|741))" + + "|3(0(060|906)|1(095|196)|2013|5(825|989)|6023|7767|9931)|4(3(085|357)|9760)|5(4180|7606|8848)" + + "|8(5265|8(8(4(5|6|7|8|9)|5(0|1))|98(2|3))|9(005|206)))|6(0(4906|5141)|36120)" + + "|9682(0(1|2|3|4|5|6|7|8|9)|1(0|1)))\\d*$", ), - imageId = R.drawable.cko_ic_scheme_mada + imageId = R.drawable.cko_ic_scheme_mada, ), MAESTRO( cvvLength = setOf(0, 3), regex = Regex( "^(?:5[06789]\\d\\d|(?!6011[0234])(?!60117[4789])(?!60118[6789])(?!60119)" + - "(?!64[456789])(?!65)6\\d{3})\\d{8,15}$" + "(?!64[456789])(?!65)6\\d{3})\\d{8,15}$", ), eagerRegex = Regex("^(5[0|6-8]\\d{0,17}|6\\d{0,18})$"), maxNumberLength = 19, numberSeparatorPattern = listOf(4, 9, 14, 19), - imageId = R.drawable.cko_ic_scheme_maestro + imageId = R.drawable.cko_ic_scheme_maestro, ), MASTERCARD( cvvLength = setOf(3), regex = Regex("^(5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)\\d{12}$"), eagerRegex = Regex("^(2[3-7]|22[2-9]|5[1-5])\\d*$"), - imageId = R.drawable.cko_ic_scheme_mastercard + imageId = R.drawable.cko_ic_scheme_mastercard, ), VISA( cvvLength = setOf(3), @@ -128,8 +128,9 @@ public enum class CardScheme( regex = Regex(""), eagerRegex = Regex(""), maxNumberLength = 19, - numberSeparatorPattern = listOf(4, 9, 14, 19) - ); + numberSeparatorPattern = listOf(4, 9, 14, 19), + ), + ; public companion object { @JvmStatic @@ -141,7 +142,7 @@ public enum class CardScheme( @JvmStatic public fun fromString(cardSchemeValue: String): CardScheme = CardScheme.values().find { cardScheme -> cardScheme.name.contains( - cardSchemeValue.uppercase().substringBefore("_").substringBefore(" ") + cardSchemeValue.uppercase().substringBefore("_").substringBefore(" "), ) } ?: UNKNOWN } diff --git a/checkout/src/main/java/com/checkout/base/model/Country.kt b/checkout/src/main/java/com/checkout/base/model/Country.kt index 88f9883ba..e7d23c2eb 100644 --- a/checkout/src/main/java/com/checkout/base/model/Country.kt +++ b/checkout/src/main/java/com/checkout/base/model/Country.kt @@ -2,7 +2,7 @@ package com.checkout.base.model public enum class Country( public val iso3166Alpha2: String, - public val dialingCode: String + public val dialingCode: String, ) { AFGHANISTAN("AF", "93"), ALAND_ISLANDS("AX", "358"), @@ -254,13 +254,13 @@ public enum class Country( WESTERN_SAHARA("EH", "2125288"), YEMEN("YE", "967"), ZAMBIA("ZM", "260"), - ZIMBABWE("ZW", "263"); + ZIMBABWE("ZW", "263"), + ; public companion object { @JvmStatic public fun from(iso3166Alpha2: String?): Country? { - val country: Country? = values().firstOrNull { it.iso3166Alpha2.equals(iso3166Alpha2, true) } @@ -271,7 +271,7 @@ public enum class Country( internal fun getCountry(dialingCode: String?, iso3166Alpha2: String?): Country? { val country: Country? = values().firstOrNull { country -> country.dialingCode.equals(dialingCode, true) && - country.iso3166Alpha2.equals(iso3166Alpha2, true) + country.iso3166Alpha2.equals(iso3166Alpha2, true) } return country diff --git a/checkout/src/main/java/com/checkout/base/model/Environment.kt b/checkout/src/main/java/com/checkout/base/model/Environment.kt index 7a59645ec..99463fa1c 100644 --- a/checkout/src/main/java/com/checkout/base/model/Environment.kt +++ b/checkout/src/main/java/com/checkout/base/model/Environment.kt @@ -4,5 +4,5 @@ import com.checkout.base.util.EnvironmentConstants public enum class Environment(public val url: String) { PRODUCTION(EnvironmentConstants.PRODUCTION_SERVER_URL), - SANDBOX(EnvironmentConstants.SANDBOX_SERVER_URL) + SANDBOX(EnvironmentConstants.SANDBOX_SERVER_URL), } diff --git a/checkout/src/main/java/com/checkout/logging/EventLogger.kt b/checkout/src/main/java/com/checkout/logging/EventLogger.kt index 2db213573..84406c880 100644 --- a/checkout/src/main/java/com/checkout/logging/EventLogger.kt +++ b/checkout/src/main/java/com/checkout/logging/EventLogger.kt @@ -23,12 +23,12 @@ internal class EventLogger(private val logger: CheckoutEventLogger) : Logger { context: Context, environment: Environment, identifier: String = BuildConfig.PRODUCT_IDENTIFIER, - version: String = BuildConfig.PRODUCT_VERSION + version: String = BuildConfig.PRODUCT_VERSION, ) /** diff --git a/checkout/src/main/java/com/checkout/logging/model/LoggingEvent.kt b/checkout/src/main/java/com/checkout/logging/model/LoggingEvent.kt index e4b91b984..56f2d4461 100644 --- a/checkout/src/main/java/com/checkout/logging/model/LoggingEvent.kt +++ b/checkout/src/main/java/com/checkout/logging/model/LoggingEvent.kt @@ -10,7 +10,7 @@ import java.util.Date public class LoggingEvent constructor( internal val eventType: LoggingEventType, override val monitoringLevel: MonitoringLevel = MonitoringLevel.INFO, - override val properties: Map = emptyMap() + override val properties: Map = emptyMap(), ) : Event { override val time: Date = Date() diff --git a/checkout/src/main/java/com/checkout/network/OkHttpProvider.kt b/checkout/src/main/java/com/checkout/network/OkHttpProvider.kt index 4159977c8..a162f2128 100644 --- a/checkout/src/main/java/com/checkout/network/OkHttpProvider.kt +++ b/checkout/src/main/java/com/checkout/network/OkHttpProvider.kt @@ -1,11 +1,11 @@ package com.checkout.network -import com.checkout.network.utils.OkHttpConstants.CALL_TIMEOUT_MS -import com.checkout.network.utils.OkHttpConstants.CONNECTION_TIMEOUT_MS -import com.checkout.network.utils.OkHttpConstants.READ_TIMEOUT_MS import com.checkout.network.extension.addLocalInterceptors import com.checkout.network.extension.addRequestInterceptors import com.checkout.network.extension.buildConnectionSpecs +import com.checkout.network.utils.OkHttpConstants.CALL_TIMEOUT_MS +import com.checkout.network.utils.OkHttpConstants.CONNECTION_TIMEOUT_MS +import com.checkout.network.utils.OkHttpConstants.READ_TIMEOUT_MS import okhttp3.OkHttpClient import java.util.concurrent.TimeUnit diff --git a/checkout/src/main/java/com/checkout/network/error/NetworkError.kt b/checkout/src/main/java/com/checkout/network/error/NetworkError.kt index 63ebb6c41..bfade03d7 100644 --- a/checkout/src/main/java/com/checkout/network/error/NetworkError.kt +++ b/checkout/src/main/java/com/checkout/network/error/NetworkError.kt @@ -5,11 +5,11 @@ import com.checkout.base.error.CheckoutError internal class NetworkError( errorCode: String, message: String? = null, - cause: Throwable? = null + cause: Throwable? = null, ) : CheckoutError( errorCode, message, - cause + cause, ) { companion object { const val CONNECTION_FAILED_ERROR = "NetworkError:2001" diff --git a/checkout/src/main/java/com/checkout/network/extension/OkHttpClientExtension.kt b/checkout/src/main/java/com/checkout/network/extension/OkHttpClientExtension.kt index 9cee1ded1..750f1df7f 100644 --- a/checkout/src/main/java/com/checkout/network/extension/OkHttpClientExtension.kt +++ b/checkout/src/main/java/com/checkout/network/extension/OkHttpClientExtension.kt @@ -22,14 +22,17 @@ import okhttp3.Response internal inline fun OkHttpClient.executeHttpRequest( request: Request, successAdapter: JsonAdapter, - errorAdapter: JsonAdapter + errorAdapter: JsonAdapter, ): NetworkApiResponse { return try { newCall(request) .execute() .use { - if (it.isSuccessful) provideSuccessResult(it, successAdapter) - else provideErrorResult(it, errorAdapter) + if (it.isSuccessful) { + provideSuccessResult(it, successAdapter) + } else { + provideErrorResult(it, errorAdapter) + } } } catch (e: Throwable) { NetworkApiResponse.NetworkError(e) @@ -39,20 +42,20 @@ internal inline fun OkHttpClient.executeHttpRequest( @Throws(CheckoutError::class) private inline fun provideSuccessResult( result: Response, - adapter: JsonAdapter + adapter: JsonAdapter, ): NetworkApiResponse = result.body?.source()?.let { adapter.fromJson(it)?.let { successResponse -> NetworkApiResponse.Success(successResponse) } } ?: throw CheckoutError( errorCode = RESPONSE_PARSING_ERROR, - message = "Success response is null, can not be parsed" + message = "Success response is null, can not be parsed", ) private fun provideErrorResult( result: Response, - errorAdapter: JsonAdapter + errorAdapter: JsonAdapter, ) = NetworkApiResponse.ServerError( result.body?.source()?.let { errorAdapter.fromJson(it) }, - result.code + result.code, ) diff --git a/checkout/src/main/java/com/checkout/network/extension/OkHttpProviderExtension.kt b/checkout/src/main/java/com/checkout/network/extension/OkHttpProviderExtension.kt index 129561d07..cc784bd23 100644 --- a/checkout/src/main/java/com/checkout/network/extension/OkHttpProviderExtension.kt +++ b/checkout/src/main/java/com/checkout/network/extension/OkHttpProviderExtension.kt @@ -27,11 +27,11 @@ private fun createNetworkApiRequestInterceptor(publicKey: String) = Interceptor with(requestBuilder) { addHeader( HEADER_AUTHORIZATION, - publicKey + publicKey, ) addHeader( HEADER_USER_AGENT_NAME, - HEADER_USER_AGENT_VALUE + HEADER_USER_AGENT_VALUE, ) } chain.proceed(requestBuilder.build()) @@ -39,7 +39,7 @@ private fun createNetworkApiRequestInterceptor(publicKey: String) = Interceptor internal fun buildConnectionSpecs(): List = listOf( ConnectionSpec.RESTRICTED_TLS, - ConnectionSpec.CLEARTEXT // Allow ClearText in debugBuilds + ConnectionSpec.CLEARTEXT, // Allow ClearText in debugBuilds ) private fun httpLoggingInterceptor() = HttpLoggingInterceptor { message -> diff --git a/checkout/src/main/java/com/checkout/network/response/ErrorResponse.kt b/checkout/src/main/java/com/checkout/network/response/ErrorResponse.kt index bd8b283c0..33b9aec74 100644 --- a/checkout/src/main/java/com/checkout/network/response/ErrorResponse.kt +++ b/checkout/src/main/java/com/checkout/network/response/ErrorResponse.kt @@ -15,5 +15,5 @@ internal data class ErrorResponse( val errorType: String?, @Json(name = "error_codes") - val errorCodes: List? + val errorCodes: List?, ) diff --git a/checkout/src/main/java/com/checkout/threedsecure/ThreeDSExecutor.kt b/checkout/src/main/java/com/checkout/threedsecure/ThreeDSExecutor.kt index 9f02efc07..cfc89e36a 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/ThreeDSExecutor.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/ThreeDSExecutor.kt @@ -16,7 +16,7 @@ import com.checkout.threedsecure.webview.ThreeDSWebViewClient @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public class ThreeDSExecutor( private val processResultUseCase: UseCase, - private val logger: ThreeDSLogger + private val logger: ThreeDSLogger, ) : Executor { override fun execute(request: ThreeDSRequest): Unit = request.container.addView(provideWebView(request)) @@ -27,7 +27,7 @@ public class ThreeDSExecutor( webViewClient = ThreeDSWebViewClient( onResult = { handleResult(it, successUrl, failureUrl, resultHandler) }, onError = { handleError(it, resultHandler) }, - logger + logger, ) loadUrl(request.challengeUrl) } @@ -38,7 +38,7 @@ public class ThreeDSExecutor( url: String?, successUrl: String, failureUrl: String, - resultHandler: ThreeDSResultHandler + resultHandler: ThreeDSResultHandler, ): Boolean { val threeDSResult = processResultUseCase.execute(ProcessThreeDSRequest(url, successUrl, failureUrl)) @@ -46,7 +46,7 @@ public class ThreeDSExecutor( logger.logCompletedEvent( success = it is ThreeDSResult.Success, token = (it as? ThreeDSResult.Success)?.token, - error = (it as? ThreeDSResult.Error)?.error + error = (it as? ThreeDSResult.Error)?.error, ) resultHandler.invoke(it) return true diff --git a/checkout/src/main/java/com/checkout/threedsecure/logging/ThreeDSEventLogger.kt b/checkout/src/main/java/com/checkout/threedsecure/logging/ThreeDSEventLogger.kt index 98e54fbad..304193dac 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/logging/ThreeDSEventLogger.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/logging/ThreeDSEventLogger.kt @@ -4,13 +4,13 @@ import androidx.annotation.RestrictTo import com.checkout.eventlogger.domain.model.MonitoringLevel import com.checkout.logging.Logger import com.checkout.logging.model.LoggingEvent -import com.checkout.logging.utils.putErrorAttributes import com.checkout.logging.utils.SUCCESS import com.checkout.logging.utils.TOKEN_ID +import com.checkout.logging.utils.putErrorAttributes @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public class ThreeDSEventLogger( - private val logger: Logger + private val logger: Logger, ) : ThreeDSLogger { override fun logPresentedEvent(): Unit = logEvent(ThreeDSEventType.PRESENTED) @@ -25,14 +25,14 @@ public class ThreeDSEventLogger( eventType: ThreeDSEventType, success: Boolean? = null, error: Throwable? = null, - token: String? = null + token: String? = null, ) = logger.log(provideLoggingEvent(eventType, success, token, error)) private fun provideLoggingEvent( eventType: ThreeDSEventType, success: Boolean?, token: String?, - error: Throwable? + error: Throwable?, ): LoggingEvent { val properties = hashMapOf() @@ -43,7 +43,7 @@ public class ThreeDSEventLogger( return LoggingEvent( eventType, if (error == null) MonitoringLevel.INFO else MonitoringLevel.ERROR, - properties + properties, ) } } diff --git a/checkout/src/main/java/com/checkout/threedsecure/logging/ThreeDSEventType.kt b/checkout/src/main/java/com/checkout/threedsecure/logging/ThreeDSEventType.kt index 6f75a3b96..50bec7c53 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/logging/ThreeDSEventType.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/logging/ThreeDSEventType.kt @@ -5,5 +5,5 @@ import com.checkout.logging.LoggingEventType internal enum class ThreeDSEventType(override val eventId: String) : LoggingEventType { PRESENTED("3ds_webview_presented"), LOADED("3ds_challenge_loaded"), - COMPLETED("3ds_challenge_complete") + COMPLETED("3ds_challenge_complete"), } diff --git a/checkout/src/main/java/com/checkout/threedsecure/model/ProcessThreeDSRequest.kt b/checkout/src/main/java/com/checkout/threedsecure/model/ProcessThreeDSRequest.kt index fca0df9e9..fb6e79b62 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/model/ProcessThreeDSRequest.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/model/ProcessThreeDSRequest.kt @@ -6,5 +6,5 @@ import androidx.annotation.RestrictTo public data class ProcessThreeDSRequest( val redirectUrl: String?, val successUrl: String, - val failureUrl: String + val failureUrl: String, ) diff --git a/checkout/src/main/java/com/checkout/threedsecure/model/ThreeDSRequest.kt b/checkout/src/main/java/com/checkout/threedsecure/model/ThreeDSRequest.kt index c17d270d9..390db6aaf 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/model/ThreeDSRequest.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/model/ThreeDSRequest.kt @@ -7,7 +7,7 @@ public data class ThreeDSRequest( val challengeUrl: String, val successUrl: String, val failureUrl: String, - val resultHandler: ThreeDSResultHandler + val resultHandler: ThreeDSResultHandler, ) public typealias ThreeDSResultHandler = (result: ThreeDSResult) -> Unit diff --git a/checkout/src/main/java/com/checkout/threedsecure/usecase/ProcessThreeDSUseCase.kt b/checkout/src/main/java/com/checkout/threedsecure/usecase/ProcessThreeDSUseCase.kt index 8d1b4c295..d9fe81bbc 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/usecase/ProcessThreeDSUseCase.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/usecase/ProcessThreeDSUseCase.kt @@ -23,8 +23,11 @@ public class ProcessThreeDSUseCase : UseCase { val token = provideToken(redirectUrl) - if (token == null) provideError(ThreeDSError.COULD_NOT_EXTRACT_TOKEN, "Url can't be null.") - else ThreeDSResult.Success(token) + if (token == null) { + provideError(ThreeDSError.COULD_NOT_EXTRACT_TOKEN, "Url can't be null.") + } else { + ThreeDSResult.Success(token) + } } Uri.parse(failureUrl).matches(redirectUri) -> ThreeDSResult.Failure else -> null diff --git a/checkout/src/main/java/com/checkout/threedsecure/utils/UriExtension.kt b/checkout/src/main/java/com/checkout/threedsecure/utils/UriExtension.kt index 6c865c578..d517a34e6 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/utils/UriExtension.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/utils/UriExtension.kt @@ -24,6 +24,9 @@ private fun getQueryParameters(uri: Uri) = uri.query?.split("&")?.toSet() ?: set private fun getBase(uri: Uri): String { val query = uri.query ?: "" - return if (query.isBlank()) uri.toString() - else uri.toString().replace("?$query", "") + return if (query.isBlank()) { + uri.toString() + } else { + uri.toString().replace("?$query", "") + } } diff --git a/checkout/src/main/java/com/checkout/threedsecure/utils/WebResourcesExtension.kt b/checkout/src/main/java/com/checkout/threedsecure/utils/WebResourcesExtension.kt index 58f166bf0..cbe041865 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/utils/WebResourcesExtension.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/utils/WebResourcesExtension.kt @@ -9,4 +9,6 @@ internal fun WebResourceResponse.toThreeDSError() = ThreeDSError(this.statusCode internal fun WebResourceError.toThreeDSError() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { ThreeDSError(this.errorCode.toString(), this.description.toString()) -} else null +} else { + null +} diff --git a/checkout/src/main/java/com/checkout/threedsecure/webview/ThreeDSWebView.kt b/checkout/src/main/java/com/checkout/threedsecure/webview/ThreeDSWebView.kt index 02f1f8a97..47439709e 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/webview/ThreeDSWebView.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/webview/ThreeDSWebView.kt @@ -25,7 +25,7 @@ internal class ThreeDSWebView constructor(context: Context) : WebView(context) { } layoutParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, - FrameLayout.LayoutParams.MATCH_PARENT + FrameLayout.LayoutParams.MATCH_PARENT, ) } diff --git a/checkout/src/main/java/com/checkout/threedsecure/webview/ThreeDSWebViewClient.kt b/checkout/src/main/java/com/checkout/threedsecure/webview/ThreeDSWebViewClient.kt index c58e3b56b..7ddaaeff0 100644 --- a/checkout/src/main/java/com/checkout/threedsecure/webview/ThreeDSWebViewClient.kt +++ b/checkout/src/main/java/com/checkout/threedsecure/webview/ThreeDSWebViewClient.kt @@ -1,11 +1,11 @@ package com.checkout.threedsecure.webview import android.graphics.Bitmap -import android.webkit.WebViewClient -import android.webkit.WebView -import android.webkit.WebResourceRequest import android.webkit.WebResourceError +import android.webkit.WebResourceRequest import android.webkit.WebResourceResponse +import android.webkit.WebView +import android.webkit.WebViewClient import com.checkout.threedsecure.error.ThreeDSError import com.checkout.threedsecure.logging.ThreeDSLogger import com.checkout.threedsecure.utils.toThreeDSError @@ -13,7 +13,7 @@ import com.checkout.threedsecure.utils.toThreeDSError internal class ThreeDSWebViewClient( private val onResult: (url: String?) -> Boolean, private val onError: (error: ThreeDSError) -> Unit, - private val logger: ThreeDSLogger + private val logger: ThreeDSLogger, ) : WebViewClient() { private var presentedFirstTime = true diff --git a/checkout/src/main/java/com/checkout/tokenization/NetworkApiClient.kt b/checkout/src/main/java/com/checkout/tokenization/NetworkApiClient.kt index 907d8548f..0fff7dc73 100644 --- a/checkout/src/main/java/com/checkout/tokenization/NetworkApiClient.kt +++ b/checkout/src/main/java/com/checkout/tokenization/NetworkApiClient.kt @@ -28,7 +28,7 @@ internal interface NetworkApiClient { * It encapsulates the result as a [CVVTokenDetailsResponse] on success or an error message on failure. */ suspend fun sendCVVTokenRequest(cvvTokenNetworkRequest: CVVTokenNetworkRequest): - NetworkApiResponse + NetworkApiResponse /** Sending GooglePayToken request * @@ -36,6 +36,6 @@ internal interface NetworkApiClient { * @return response with its body parsed as a String */ suspend fun sendGooglePayTokenRequest( - googlePayTokenNetworkRequest: GooglePayTokenNetworkRequest + googlePayTokenNetworkRequest: GooglePayTokenNetworkRequest, ): NetworkApiResponse } diff --git a/checkout/src/main/java/com/checkout/tokenization/TokenNetworkApiClient.kt b/checkout/src/main/java/com/checkout/tokenization/TokenNetworkApiClient.kt index 73d582841..4c4f35359 100644 --- a/checkout/src/main/java/com/checkout/tokenization/TokenNetworkApiClient.kt +++ b/checkout/src/main/java/com/checkout/tokenization/TokenNetworkApiClient.kt @@ -20,13 +20,12 @@ import okhttp3.RequestBody.Companion.toRequestBody internal class TokenNetworkApiClient( private val url: String, private val okHttpClient: OkHttpClient, - private val moshiClient: Moshi + private val moshiClient: Moshi, ) : NetworkApiClient { override suspend fun sendCardTokenRequest( - cardTokenRequest: TokenRequest + cardTokenRequest: TokenRequest, ): NetworkApiResponse { - val jsonTokenRequestAdapter = moshiClient.adapter(TokenRequest::class.java) val requestBody = @@ -40,14 +39,13 @@ internal class TokenNetworkApiClient( return okHttpClient.executeHttpRequest( request, moshiClient.adapter(TokenDetailsResponse::class.java), - moshiClient.adapter(ErrorResponse::class.java) + moshiClient.adapter(ErrorResponse::class.java), ) } override suspend fun sendCVVTokenRequest( - cvvTokenNetworkRequest: CVVTokenNetworkRequest + cvvTokenNetworkRequest: CVVTokenNetworkRequest, ): NetworkApiResponse { - val jsonTokenRequestAdapter = moshiClient.adapter(CVVTokenNetworkRequest::class.java) val requestBody = @@ -61,18 +59,18 @@ internal class TokenNetworkApiClient( return okHttpClient.executeHttpRequest( request, moshiClient.adapter(CVVTokenDetailsResponse::class.java), - moshiClient.adapter(ErrorResponse::class.java) + moshiClient.adapter(ErrorResponse::class.java), ) } override suspend fun sendGooglePayTokenRequest( - googlePayTokenNetworkRequest: GooglePayTokenNetworkRequest + googlePayTokenNetworkRequest: GooglePayTokenNetworkRequest, ): NetworkApiResponse { val jsonGooglePayTokenRequestAdapter = moshiClient.adapter(GooglePayTokenNetworkRequest::class.java) val requestBody = jsonGooglePayTokenRequestAdapter.toJson( - googlePayTokenNetworkRequest + googlePayTokenNetworkRequest, ).toRequestBody(TokenizationConstants.jsonMediaType) val request = Request.Builder() @@ -83,7 +81,7 @@ internal class TokenNetworkApiClient( return okHttpClient.executeHttpRequest( request, moshiClient.adapter(TokenDetailsResponse::class.java), - moshiClient.adapter(ErrorResponse::class.java) + moshiClient.adapter(ErrorResponse::class.java), ) } } diff --git a/checkout/src/main/java/com/checkout/tokenization/entity/AddressEntity.kt b/checkout/src/main/java/com/checkout/tokenization/entity/AddressEntity.kt index 91091eba2..5dd508d34 100644 --- a/checkout/src/main/java/com/checkout/tokenization/entity/AddressEntity.kt +++ b/checkout/src/main/java/com/checkout/tokenization/entity/AddressEntity.kt @@ -43,5 +43,5 @@ internal data class AddressEntity internal constructor( * Billing address country code (iso3166Alpha2) */ @Json(name = "country") - val country: String? + val country: String?, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/entity/GooglePayEntity.kt b/checkout/src/main/java/com/checkout/tokenization/entity/GooglePayEntity.kt index 62ace0b75..c66f90748 100755 --- a/checkout/src/main/java/com/checkout/tokenization/entity/GooglePayEntity.kt +++ b/checkout/src/main/java/com/checkout/tokenization/entity/GooglePayEntity.kt @@ -16,5 +16,5 @@ internal data class GooglePayEntity( var protocolVersion: String? = null, @Json(name = "signedMessage") - var signedMessage: String? = null + var signedMessage: String? = null, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/entity/TokenDataEntity.kt b/checkout/src/main/java/com/checkout/tokenization/entity/TokenDataEntity.kt index bca097cc9..b260a7432 100644 --- a/checkout/src/main/java/com/checkout/tokenization/entity/TokenDataEntity.kt +++ b/checkout/src/main/java/com/checkout/tokenization/entity/TokenDataEntity.kt @@ -6,5 +6,5 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) internal data class TokenDataEntity internal constructor( @Json(name = "cvv") - val cvv: String = "" + val cvv: String = "", ) diff --git a/checkout/src/main/java/com/checkout/tokenization/error/TokenizationError.kt b/checkout/src/main/java/com/checkout/tokenization/error/TokenizationError.kt index cb0753381..ee314f923 100644 --- a/checkout/src/main/java/com/checkout/tokenization/error/TokenizationError.kt +++ b/checkout/src/main/java/com/checkout/tokenization/error/TokenizationError.kt @@ -5,11 +5,11 @@ import com.checkout.base.error.CheckoutError internal class TokenizationError( errorCode: String, message: String? = null, - cause: Throwable? = null + cause: Throwable? = null, ) : CheckoutError( errorCode, message, - cause + cause, ) { companion object { const val INVALID_TOKEN_REQUEST = "TokenizationError.Server:3000" diff --git a/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationEventLogger.kt b/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationEventLogger.kt index 61ae83709..f2cff94b3 100644 --- a/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationEventLogger.kt +++ b/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationEventLogger.kt @@ -3,16 +3,16 @@ package com.checkout.tokenization.logging import com.checkout.eventlogger.domain.model.MonitoringLevel import com.checkout.logging.Logger import com.checkout.logging.model.LoggingEvent -import com.checkout.logging.utils.TOKEN_TYPE -import com.checkout.logging.utils.PUBLIC_KEY +import com.checkout.logging.utils.ERROR_CODES import com.checkout.logging.utils.ERROR_TYPE import com.checkout.logging.utils.HTTP_STATUS_CODE +import com.checkout.logging.utils.PUBLIC_KEY +import com.checkout.logging.utils.REQUEST_ID import com.checkout.logging.utils.SCHEME -import com.checkout.logging.utils.ERROR_CODES -import com.checkout.logging.utils.putErrorAttributes -import com.checkout.logging.utils.TOKEN_ID import com.checkout.logging.utils.SERVER_ERROR -import com.checkout.logging.utils.REQUEST_ID +import com.checkout.logging.utils.TOKEN_ID +import com.checkout.logging.utils.TOKEN_TYPE +import com.checkout.logging.utils.putErrorAttributes import com.checkout.network.response.ErrorResponse import com.checkout.tokenization.response.TokenDetailsResponse @@ -30,7 +30,7 @@ internal class TokenizationEventLogger(private val logger: Logger) publicKey: String, tokenDetails: TokenDetailsResponse?, code: Int?, - errorResponse: ErrorResponse? + errorResponse: ErrorResponse?, ) = logEvent(TokenizationEventType.TOKEN_RESPONSE, tokenType, publicKey, null, tokenDetails, code, errorResponse) override fun resetSession() = logger.resetSession() @@ -42,7 +42,7 @@ internal class TokenizationEventLogger(private val logger: Logger) error: Throwable? = null, tokenDetails: TokenDetailsResponse? = null, code: Int? = null, - errorResponse: ErrorResponse? = null + errorResponse: ErrorResponse? = null, ) = logger.log( provideLoggingEvent( tokenizationEventType, @@ -51,8 +51,8 @@ internal class TokenizationEventLogger(private val logger: Logger) error, tokenDetails, code, - errorResponse - ) + errorResponse, + ), ) private fun provideLoggingEvent( @@ -62,7 +62,7 @@ internal class TokenizationEventLogger(private val logger: Logger) error: Throwable?, tokenDetails: TokenDetailsResponse?, code: Int?, - errorResponse: ErrorResponse? + errorResponse: ErrorResponse?, ): LoggingEvent { val properties = hashMapOf() properties[TOKEN_TYPE] = tokenType @@ -83,14 +83,14 @@ internal class TokenizationEventLogger(private val logger: Logger) properties[SERVER_ERROR] = mapOf( REQUEST_ID to it.requestId, ERROR_TYPE to it.errorType, - ERROR_CODES to it.errorCodes + ERROR_CODES to it.errorCodes, ) } return LoggingEvent( tokenizationEventType, if (error == null) MonitoringLevel.INFO else MonitoringLevel.ERROR, - properties + properties, ) } } diff --git a/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationEventType.kt b/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationEventType.kt index f57f4b58e..28d8d59ff 100644 --- a/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationEventType.kt +++ b/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationEventType.kt @@ -4,5 +4,5 @@ import com.checkout.logging.LoggingEventType internal enum class TokenizationEventType(override val eventId: String) : LoggingEventType { TOKEN_REQUESTED("token_requested"), - TOKEN_RESPONSE("token_response") + TOKEN_RESPONSE("token_response"), } diff --git a/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationLogger.kt b/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationLogger.kt index a9bccbfaf..3b06e0d64 100644 --- a/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationLogger.kt +++ b/checkout/src/main/java/com/checkout/tokenization/logging/TokenizationLogger.kt @@ -26,7 +26,7 @@ internal interface TokenizationLogger { publicKey: String, tokenDetails: TokenDetailsResponse? = null, code: Int? = null, - errorResponse: ErrorResponse? = null + errorResponse: ErrorResponse? = null, ) /** diff --git a/checkout/src/main/java/com/checkout/tokenization/mapper/TokenizationNetworkDataMapper.kt b/checkout/src/main/java/com/checkout/tokenization/mapper/TokenizationNetworkDataMapper.kt index 9fe520a8b..a8bf2e77e 100644 --- a/checkout/src/main/java/com/checkout/tokenization/mapper/TokenizationNetworkDataMapper.kt +++ b/checkout/src/main/java/com/checkout/tokenization/mapper/TokenizationNetworkDataMapper.kt @@ -1,13 +1,13 @@ package com.checkout.tokenization.mapper import com.checkout.base.error.CheckoutError -import com.checkout.tokenization.model.TokenResult import com.checkout.network.error.NetworkError import com.checkout.network.response.NetworkApiResponse import com.checkout.tokenization.error.TokenizationError import com.checkout.tokenization.error.TokenizationError.Companion.INVALID_KEY import com.checkout.tokenization.error.TokenizationError.Companion.INVALID_TOKEN_REQUEST import com.checkout.tokenization.error.TokenizationError.Companion.TOKENIZATION_API_RESPONSE_PROCESSING_ERROR +import com.checkout.tokenization.model.TokenResult /** * Base implementation of mapping from data object to domain classes. @@ -36,7 +36,7 @@ internal abstract class TokenizationNetworkDataMapper { CheckoutError( errorCode = TOKENIZATION_API_RESPONSE_PROCESSING_ERROR, message = exception.message, - throwable = exception + throwable = exception, ) } return TokenResult.Failure(tokenError) @@ -50,11 +50,11 @@ internal abstract class TokenizationNetworkDataMapper { val error = when (serverError.code) { 401 -> TokenizationError( INVALID_KEY, - serverError.toErrorMessage("Invalid key") + serverError.toErrorMessage("Invalid key"), ) else -> TokenizationError( INVALID_TOKEN_REQUEST, - serverError.toErrorMessage("Token request failed") + serverError.toErrorMessage("Token request failed"), ) } return TokenResult.Failure(error) @@ -66,7 +66,7 @@ internal abstract class TokenizationNetworkDataMapper { else -> NetworkError( errorCode = NetworkError.CONNECTION_FAILED_ERROR, message = networkError.throwable.message, - cause = networkError.throwable + cause = networkError.throwable, ) } @@ -79,7 +79,7 @@ internal abstract class TokenizationNetworkDataMapper { else -> TokenizationError( errorCode = TokenizationError.GOOGLE_PAY_REQUEST_PARSING_ERROR, message = internalError.throwable.message, - cause = internalError.throwable + cause = internalError.throwable, ) } diff --git a/checkout/src/main/java/com/checkout/tokenization/mapper/request/AddressToAddressEntityDataMapper.kt b/checkout/src/main/java/com/checkout/tokenization/mapper/request/AddressToAddressEntityDataMapper.kt index 3a53c2d4c..29fa68e1a 100644 --- a/checkout/src/main/java/com/checkout/tokenization/mapper/request/AddressToAddressEntityDataMapper.kt +++ b/checkout/src/main/java/com/checkout/tokenization/mapper/request/AddressToAddressEntityDataMapper.kt @@ -1,8 +1,8 @@ package com.checkout.tokenization.mapper.request import com.checkout.base.mapper.Mapper -import com.checkout.tokenization.model.Address import com.checkout.tokenization.entity.AddressEntity +import com.checkout.tokenization.model.Address /** * Mapping of [Address] to [AddressEntity] @@ -15,6 +15,6 @@ internal class AddressToAddressEntityDataMapper : Mapper from.city, from.state, from.zip, - from.country?.iso3166Alpha2 + from.country?.iso3166Alpha2, ) } diff --git a/checkout/src/main/java/com/checkout/tokenization/mapper/request/AddressToAddressValidationRequestDataMapper.kt b/checkout/src/main/java/com/checkout/tokenization/mapper/request/AddressToAddressValidationRequestDataMapper.kt index 36f2fd929..2a954a6b2 100644 --- a/checkout/src/main/java/com/checkout/tokenization/mapper/request/AddressToAddressValidationRequestDataMapper.kt +++ b/checkout/src/main/java/com/checkout/tokenization/mapper/request/AddressToAddressValidationRequestDataMapper.kt @@ -15,6 +15,6 @@ internal class AddressToAddressValidationRequestDataMapper : Mapper { from.name, from.cvv, from.billingAddress?.let { AddressToAddressEntityDataMapper().map(it) }, - from.phone?.let { PhoneToPhoneEntityDataMapper().map(it) } + from.phone?.let { PhoneToPhoneEntityDataMapper().map(it) }, ) } diff --git a/checkout/src/main/java/com/checkout/tokenization/mapper/request/PhoneToPhoneEntityDataMapper.kt b/checkout/src/main/java/com/checkout/tokenization/mapper/request/PhoneToPhoneEntityDataMapper.kt index 942f472f4..9f712a6e4 100644 --- a/checkout/src/main/java/com/checkout/tokenization/mapper/request/PhoneToPhoneEntityDataMapper.kt +++ b/checkout/src/main/java/com/checkout/tokenization/mapper/request/PhoneToPhoneEntityDataMapper.kt @@ -1,8 +1,8 @@ package com.checkout.tokenization.mapper.request import com.checkout.base.mapper.Mapper -import com.checkout.tokenization.model.Phone import com.checkout.tokenization.entity.PhoneEntity +import com.checkout.tokenization.model.Phone /** * Mapping of [Phone] to [PhoneEntity] diff --git a/checkout/src/main/java/com/checkout/tokenization/mapper/response/AddressEntityToAddressDataMapper.kt b/checkout/src/main/java/com/checkout/tokenization/mapper/response/AddressEntityToAddressDataMapper.kt index 5c4e0269d..b0ce88118 100644 --- a/checkout/src/main/java/com/checkout/tokenization/mapper/response/AddressEntityToAddressDataMapper.kt +++ b/checkout/src/main/java/com/checkout/tokenization/mapper/response/AddressEntityToAddressDataMapper.kt @@ -1,9 +1,9 @@ package com.checkout.tokenization.mapper.response import com.checkout.base.mapper.Mapper -import com.checkout.tokenization.model.Address import com.checkout.base.model.Country import com.checkout.tokenization.entity.AddressEntity +import com.checkout.tokenization.model.Address /** * Mapping of [AddressEntity] to [Address] @@ -16,6 +16,6 @@ internal class AddressEntityToAddressDataMapper : Mapper from.city, from.state, from.zip, - Country.from(from.country) + Country.from(from.country), ) } diff --git a/checkout/src/main/java/com/checkout/tokenization/mapper/response/CVVTokenizationNetworkDataMapper.kt b/checkout/src/main/java/com/checkout/tokenization/mapper/response/CVVTokenizationNetworkDataMapper.kt index ed4da569f..abf00c7ae 100644 --- a/checkout/src/main/java/com/checkout/tokenization/mapper/response/CVVTokenizationNetworkDataMapper.kt +++ b/checkout/src/main/java/com/checkout/tokenization/mapper/response/CVVTokenizationNetworkDataMapper.kt @@ -1,8 +1,8 @@ package com.checkout.tokenization.mapper.response import com.checkout.base.error.CheckoutError -import com.checkout.tokenization.mapper.TokenizationNetworkDataMapper import com.checkout.tokenization.error.TokenizationError.Companion.TOKENIZATION_API_MALFORMED_JSON +import com.checkout.tokenization.mapper.TokenizationNetworkDataMapper import com.checkout.tokenization.model.CVVTokenDetails import com.checkout.tokenization.response.GetCVVTokenDetailsResponse @@ -14,13 +14,16 @@ internal class CVVTokenizationNetworkDataMapper : TokenizationNetworkDataMapper< override fun createMappedResult(resultBody: T): CVVTokenDetails = when (resultBody) { is GetCVVTokenDetailsResponse -> fromCardTokenizationResponse(resultBody) else -> throw CheckoutError( - TOKENIZATION_API_MALFORMED_JSON, "${resultBody.javaClass.name} cannot be mapped to a CVVTokenDetails" + TOKENIZATION_API_MALFORMED_JSON, + "${resultBody.javaClass.name} cannot be mapped to a CVVTokenDetails", ) } private fun fromCardTokenizationResponse(result: GetCVVTokenDetailsResponse) = with(result) { CVVTokenDetails( - type = type, token = token, expiresOn = expiresOn + type = type, + token = token, + expiresOn = expiresOn, ) } } diff --git a/checkout/src/main/java/com/checkout/tokenization/mapper/response/CardTokenizationNetworkDataMapper.kt b/checkout/src/main/java/com/checkout/tokenization/mapper/response/CardTokenizationNetworkDataMapper.kt index df1126d48..24f03ddf6 100644 --- a/checkout/src/main/java/com/checkout/tokenization/mapper/response/CardTokenizationNetworkDataMapper.kt +++ b/checkout/src/main/java/com/checkout/tokenization/mapper/response/CardTokenizationNetworkDataMapper.kt @@ -1,10 +1,10 @@ package com.checkout.tokenization.mapper.response import com.checkout.base.error.CheckoutError -import com.checkout.tokenization.model.TokenDetails +import com.checkout.tokenization.error.TokenizationError.Companion.TOKENIZATION_API_MALFORMED_JSON import com.checkout.tokenization.mapper.TokenizationNetworkDataMapper +import com.checkout.tokenization.model.TokenDetails import com.checkout.tokenization.response.GetTokenDetailsResponse -import com.checkout.tokenization.error.TokenizationError.Companion.TOKENIZATION_API_MALFORMED_JSON /** * An implementation of mapping from [GetTokenDetailsResponse] data object to [TokenDetails]. @@ -16,7 +16,7 @@ internal class CardTokenizationNetworkDataMapper : TokenizationNetworkDataMapper is GetTokenDetailsResponse -> fromCardTokenizationResponse(resultBody) else -> throw CheckoutError( TOKENIZATION_API_MALFORMED_JSON, - "${resultBody.javaClass.name} cannot be mapped to a TokenDetails" + "${resultBody.javaClass.name} cannot be mapped to a TokenDetails", ) } @@ -41,6 +41,6 @@ internal class CardTokenizationNetworkDataMapper : TokenizationNetworkDataMapper phone = result.phone?.let { PhoneEntityToPhoneDataMapper().map(from = it to result.billingAddress?.country) }, - name = result.name + name = result.name, ) } diff --git a/checkout/src/main/java/com/checkout/tokenization/mapper/response/PhoneEntityToPhoneDataMapper.kt b/checkout/src/main/java/com/checkout/tokenization/mapper/response/PhoneEntityToPhoneDataMapper.kt index c0dcfd4ce..38046dd09 100644 --- a/checkout/src/main/java/com/checkout/tokenization/mapper/response/PhoneEntityToPhoneDataMapper.kt +++ b/checkout/src/main/java/com/checkout/tokenization/mapper/response/PhoneEntityToPhoneDataMapper.kt @@ -2,8 +2,8 @@ package com.checkout.tokenization.mapper.response import com.checkout.base.mapper.Mapper import com.checkout.base.model.Country -import com.checkout.tokenization.model.Phone import com.checkout.tokenization.entity.PhoneEntity +import com.checkout.tokenization.model.Phone /** * Mapping of [PhoneEntity] to [Phone] @@ -12,6 +12,6 @@ internal class PhoneEntityToPhoneDataMapper : Mapper, override fun map(from: Pair): Phone = Phone( from.first.number, - Country.getCountry(from.first.countryCode, from.second) + Country.getCountry(from.first.countryCode, from.second), ) } diff --git a/checkout/src/main/java/com/checkout/tokenization/model/Address.kt b/checkout/src/main/java/com/checkout/tokenization/model/Address.kt index 5d8a8d993..222d8d925 100644 --- a/checkout/src/main/java/com/checkout/tokenization/model/Address.kt +++ b/checkout/src/main/java/com/checkout/tokenization/model/Address.kt @@ -35,5 +35,5 @@ public data class Address constructor( /** * Billing address country [Country] */ - var country: Country? = null + var country: Country? = null, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/model/Card.kt b/checkout/src/main/java/com/checkout/tokenization/model/Card.kt index d599354a1..495c94e13 100644 --- a/checkout/src/main/java/com/checkout/tokenization/model/Card.kt +++ b/checkout/src/main/java/com/checkout/tokenization/model/Card.kt @@ -32,6 +32,6 @@ public data class Card @JvmOverloads constructor( /** * Cardholder [Phone]. */ - val phone: Phone? = null + val phone: Phone? = null, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/model/CardTokenRequest.kt b/checkout/src/main/java/com/checkout/tokenization/model/CardTokenRequest.kt index f6964cda9..3c3c61049 100644 --- a/checkout/src/main/java/com/checkout/tokenization/model/CardTokenRequest.kt +++ b/checkout/src/main/java/com/checkout/tokenization/model/CardTokenRequest.kt @@ -10,5 +10,5 @@ package com.checkout.tokenization.model public data class CardTokenRequest( val card: Card, val onSuccess: (tokenDetails: TokenDetails) -> Unit, - val onFailure: (errorMessage: String) -> Unit + val onFailure: (errorMessage: String) -> Unit, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/model/ExpiryDate.kt b/checkout/src/main/java/com/checkout/tokenization/model/ExpiryDate.kt index bf24ab428..ee37a5dc9 100644 --- a/checkout/src/main/java/com/checkout/tokenization/model/ExpiryDate.kt +++ b/checkout/src/main/java/com/checkout/tokenization/model/ExpiryDate.kt @@ -11,5 +11,5 @@ public data class ExpiryDate( /** * The expiry year representing as an [Int] value YYYY format. (E.g. 2021) */ - val expiryYear: Int + val expiryYear: Int, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/model/GooglePayTokenRequest.kt b/checkout/src/main/java/com/checkout/tokenization/model/GooglePayTokenRequest.kt index d81ba3285..4944120a5 100644 --- a/checkout/src/main/java/com/checkout/tokenization/model/GooglePayTokenRequest.kt +++ b/checkout/src/main/java/com/checkout/tokenization/model/GooglePayTokenRequest.kt @@ -10,5 +10,5 @@ package com.checkout.tokenization.model public data class GooglePayTokenRequest( val tokenJsonPayload: String, val onSuccess: (tokenDetails: TokenDetails) -> Unit, - val onFailure: (errorMessage: String) -> Unit + val onFailure: (errorMessage: String) -> Unit, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/model/Phone.kt b/checkout/src/main/java/com/checkout/tokenization/model/Phone.kt index 9582d3f4d..104e99e08 100644 --- a/checkout/src/main/java/com/checkout/tokenization/model/Phone.kt +++ b/checkout/src/main/java/com/checkout/tokenization/model/Phone.kt @@ -14,5 +14,5 @@ public data class Phone constructor( /** * The international country calling code. (Required for some risk checks) */ - val country: Country? + val country: Country?, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/model/TokenDetails.kt b/checkout/src/main/java/com/checkout/tokenization/model/TokenDetails.kt index a2e9b4ddc..28b467206 100644 --- a/checkout/src/main/java/com/checkout/tokenization/model/TokenDetails.kt +++ b/checkout/src/main/java/com/checkout/tokenization/model/TokenDetails.kt @@ -35,5 +35,5 @@ public data class TokenDetails( val phone: Phone? = null, - val name: String? + val name: String?, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/model/ValidateCVVTokenizationRequest.kt b/checkout/src/main/java/com/checkout/tokenization/model/ValidateCVVTokenizationRequest.kt index e663b1c26..85175cb53 100644 --- a/checkout/src/main/java/com/checkout/tokenization/model/ValidateCVVTokenizationRequest.kt +++ b/checkout/src/main/java/com/checkout/tokenization/model/ValidateCVVTokenizationRequest.kt @@ -4,5 +4,5 @@ import com.checkout.base.model.CardScheme internal data class ValidateCVVTokenizationRequest( val cvv: String, - val cardScheme: CardScheme = CardScheme.UNKNOWN + val cardScheme: CardScheme = CardScheme.UNKNOWN, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/repository/TokenRepositoryImpl.kt b/checkout/src/main/java/com/checkout/tokenization/repository/TokenRepositoryImpl.kt index 8530d27ed..e99035f5f 100644 --- a/checkout/src/main/java/com/checkout/tokenization/repository/TokenRepositoryImpl.kt +++ b/checkout/src/main/java/com/checkout/tokenization/repository/TokenRepositoryImpl.kt @@ -13,11 +13,11 @@ import com.checkout.tokenization.mapper.TokenizationNetworkDataMapper import com.checkout.tokenization.model.CVVTokenDetails import com.checkout.tokenization.model.CVVTokenizationRequest import com.checkout.tokenization.model.CVVTokenizationResultHandler -import com.checkout.tokenization.model.GooglePayTokenRequest +import com.checkout.tokenization.model.Card import com.checkout.tokenization.model.CardTokenRequest +import com.checkout.tokenization.model.GooglePayTokenRequest import com.checkout.tokenization.model.TokenDetails import com.checkout.tokenization.model.TokenResult -import com.checkout.tokenization.model.Card import com.checkout.tokenization.model.ValidateCVVTokenizationRequest import com.checkout.tokenization.request.CVVTokenNetworkRequest import com.checkout.tokenization.request.GooglePayTokenNetworkRequest @@ -27,10 +27,10 @@ import com.checkout.tokenization.response.TokenDetailsResponse import com.checkout.tokenization.utils.TokenizationConstants import com.checkout.validation.model.ValidationResult import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.launch -import kotlinx.coroutines.CoroutineScope import org.json.JSONException import org.json.JSONObject @@ -50,8 +50,8 @@ internal class TokenRepositoryImpl( @VisibleForTesting var networkCoroutineScope = CoroutineScope( CoroutineName(BuildConfig.PRODUCT_IDENTIFIER) + - Dispatchers.IO + - NonCancellable + Dispatchers.IO + + NonCancellable, ) @Suppress("TooGenericExceptionCaught") @@ -70,7 +70,7 @@ internal class TokenRepositoryImpl( logger.logTokenRequestEvent(TokenizationConstants.CARD, publicKey) response = networkApiClient.sendCardTokenRequest( - cardToTokenRequestMapper.map(cardTokenRequest.card) + cardToTokenRequestMapper.map(cardTokenRequest.card), ) logResponse(response, TokenizationConstants.CARD) @@ -91,7 +91,8 @@ internal class TokenRepositoryImpl( with(cvvTokenizationRequest) { networkCoroutineScope.launch { val validateCVVRequest = ValidateCVVTokenizationRequest( - cvv = cvv, cardScheme = cardScheme + cvv = cvv, + cardScheme = cardScheme, ) val validationTokenizationDataResult = validateCVVTokenizationDataUseCase.execute(validateCVVRequest) @@ -103,7 +104,7 @@ internal class TokenRepositoryImpl( is ValidationResult.Success -> { networkApiClient.sendCVVTokenRequest( - cvvToTokenNetworkRequestMapper.map(from = cvvTokenizationRequest) + cvvToTokenNetworkRequestMapper.map(from = cvvTokenizationRequest), ) } } @@ -135,7 +136,7 @@ internal class TokenRepositoryImpl( try { val request = GooglePayTokenNetworkRequest( TokenizationConstants.GOOGLE_PAY, - creatingTokenData(googlePayTokenRequest.tokenJsonPayload) + creatingTokenData(googlePayTokenRequest.tokenJsonPayload), ) logger.logTokenRequestEvent(TokenizationConstants.GOOGLE_PAY, publicKey) @@ -148,14 +149,14 @@ internal class TokenRepositoryImpl( val error = TokenizationError( TokenizationError.GOOGLE_PAY_REQUEST_PARSING_ERROR, exception.message, - exception.cause + exception.cause, ) response = NetworkApiResponse.InternalError(error) logger.logErrorOnTokenRequestedEvent(TokenizationConstants.GOOGLE_PAY, publicKey, error) } val tokenResult = cardTokenizationNetworkDataMapper.toTokenResult( - response + response, ) launch(Dispatchers.Main) { @@ -171,14 +172,14 @@ internal class TokenRepositoryImpl( return GooglePayEntity( tokenDataJsonObject.getString("signature"), tokenDataJsonObject.getString("protocolVersion"), - tokenDataJsonObject.getString("signedMessage") + tokenDataJsonObject.getString("signedMessage"), ) } private fun handleResponse( tokenResult: TokenResult, success: (tokenDetails: TokenDetails) -> Unit, - failure: (errorMessage: String) -> Unit + failure: (errorMessage: String) -> Unit, ) { when (tokenResult) { is TokenResult.Success -> { @@ -198,7 +199,7 @@ internal class TokenRepositoryImpl( publicKey, null, response.code, - response.body + response.body, ) is NetworkApiResponse.Success -> logger.logTokenResponseEvent(tokenType, publicKey, response.body) diff --git a/checkout/src/main/java/com/checkout/tokenization/request/CVVTokenNetworkRequest.kt b/checkout/src/main/java/com/checkout/tokenization/request/CVVTokenNetworkRequest.kt index b569d3191..e99708af8 100644 --- a/checkout/src/main/java/com/checkout/tokenization/request/CVVTokenNetworkRequest.kt +++ b/checkout/src/main/java/com/checkout/tokenization/request/CVVTokenNetworkRequest.kt @@ -10,5 +10,5 @@ internal data class CVVTokenNetworkRequest( val type: String, @Json(name = "token_data") - val tokenDataEntity: TokenDataEntity + val tokenDataEntity: TokenDataEntity, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/request/GooglePayTokenNetworkRequest.kt b/checkout/src/main/java/com/checkout/tokenization/request/GooglePayTokenNetworkRequest.kt index a84f58c18..b023c9c93 100644 --- a/checkout/src/main/java/com/checkout/tokenization/request/GooglePayTokenNetworkRequest.kt +++ b/checkout/src/main/java/com/checkout/tokenization/request/GooglePayTokenNetworkRequest.kt @@ -10,5 +10,5 @@ internal data class GooglePayTokenNetworkRequest( val type: String, @Json(name = "token_data") - val tokenData: GooglePayEntity + val tokenData: GooglePayEntity, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/response/TokenDetailsResponse.kt b/checkout/src/main/java/com/checkout/tokenization/response/TokenDetailsResponse.kt index bd1857858..f8f2db83b 100644 --- a/checkout/src/main/java/com/checkout/tokenization/response/TokenDetailsResponse.kt +++ b/checkout/src/main/java/com/checkout/tokenization/response/TokenDetailsResponse.kt @@ -64,5 +64,5 @@ internal data class TokenDetailsResponse( val phone: PhoneEntity? = null, @Json(name = "name") - val name: String? + val name: String?, ) diff --git a/checkout/src/main/java/com/checkout/tokenization/usecase/ValidateCVVTokenizationDataUseCase.kt b/checkout/src/main/java/com/checkout/tokenization/usecase/ValidateCVVTokenizationDataUseCase.kt index 4a79f7aaf..696b0665e 100644 --- a/checkout/src/main/java/com/checkout/tokenization/usecase/ValidateCVVTokenizationDataUseCase.kt +++ b/checkout/src/main/java/com/checkout/tokenization/usecase/ValidateCVVTokenizationDataUseCase.kt @@ -12,11 +12,14 @@ internal class ValidateCVVTokenizationDataUseCase( override fun execute(data: ValidateCVVTokenizationRequest): ValidationResult { with(cvvComponentValidator.validate(data.cvv, data.cardScheme)) { - if (this is ValidationResult.Failure || data.cvv.isEmpty()) return ValidationResult.Failure( - ValidationError( - errorCode = ValidationError.CVV_INVALID_LENGTH, message = "Please enter a valid security code" + if (this is ValidationResult.Failure || data.cvv.isEmpty()) { + return ValidationResult.Failure( + ValidationError( + errorCode = ValidationError.CVV_INVALID_LENGTH, + message = "Please enter a valid security code", + ), ) - ) + } } return ValidationResult.Success(Unit) diff --git a/checkout/src/main/java/com/checkout/tokenization/usecase/ValidateTokenizationDataUseCase.kt b/checkout/src/main/java/com/checkout/tokenization/usecase/ValidateTokenizationDataUseCase.kt index bb7b5d06d..1955474a9 100644 --- a/checkout/src/main/java/com/checkout/tokenization/usecase/ValidateTokenizationDataUseCase.kt +++ b/checkout/src/main/java/com/checkout/tokenization/usecase/ValidateTokenizationDataUseCase.kt @@ -16,7 +16,7 @@ internal class ValidateTokenizationDataUseCase( private val cardValidator: CardValidator, private val addressValidator: Validator, private val phoneValidator: Validator, - private val addressToAddressValidationRequestDataMapper: Mapper + private val addressToAddressValidationRequestDataMapper: Mapper, ) : UseCase> { override fun execute(data: Card): ValidationResult { diff --git a/checkout/src/main/java/com/checkout/validation/api/CardValidator.kt b/checkout/src/main/java/com/checkout/validation/api/CardValidator.kt index c6085417d..976f5c866 100644 --- a/checkout/src/main/java/com/checkout/validation/api/CardValidator.kt +++ b/checkout/src/main/java/com/checkout/validation/api/CardValidator.kt @@ -1,7 +1,7 @@ package com.checkout.validation.api -import com.checkout.tokenization.model.ExpiryDate import com.checkout.base.model.CardScheme +import com.checkout.tokenization.model.ExpiryDate import com.checkout.validation.model.ValidationResult /** diff --git a/checkout/src/main/java/com/checkout/validation/logging/ValidationEventType.kt b/checkout/src/main/java/com/checkout/validation/logging/ValidationEventType.kt index abd5c57b1..8cde714b6 100644 --- a/checkout/src/main/java/com/checkout/validation/logging/ValidationEventType.kt +++ b/checkout/src/main/java/com/checkout/validation/logging/ValidationEventType.kt @@ -8,5 +8,5 @@ internal enum class ValidationEventType(override val eventId: String) : LoggingE VALIDATE_CARD_NUMBER_EAGER("card_validator_card_number_eager"), VALIDATE_EXPIRY_DATE_STRING("card_validator_expiry_string"), VALIDATE_EXPIRY_DATE_INT("card_validator_expiry_integer"), - VALIDATE_CVV("card_validator_cvv") + VALIDATE_CVV("card_validator_cvv"), } diff --git a/checkout/src/main/java/com/checkout/validation/model/AddressValidationRequest.kt b/checkout/src/main/java/com/checkout/validation/model/AddressValidationRequest.kt index 832c0f82b..cae330167 100644 --- a/checkout/src/main/java/com/checkout/validation/model/AddressValidationRequest.kt +++ b/checkout/src/main/java/com/checkout/validation/model/AddressValidationRequest.kt @@ -35,5 +35,5 @@ internal data class AddressValidationRequest internal constructor( /** * Billing address country */ - val country: Country? + val country: Country?, ) diff --git a/checkout/src/main/java/com/checkout/validation/model/CardNumberValidationRequest.kt b/checkout/src/main/java/com/checkout/validation/model/CardNumberValidationRequest.kt index 2df61436a..e4a69c9e8 100644 --- a/checkout/src/main/java/com/checkout/validation/model/CardNumberValidationRequest.kt +++ b/checkout/src/main/java/com/checkout/validation/model/CardNumberValidationRequest.kt @@ -11,5 +11,5 @@ internal data class CardNumberValidationRequest( /** * The eager validation flag representing as an [Boolean], false by default */ - val isEagerValidation: Boolean = false + val isEagerValidation: Boolean = false, ) diff --git a/checkout/src/main/java/com/checkout/validation/model/CvvValidationRequest.kt b/checkout/src/main/java/com/checkout/validation/model/CvvValidationRequest.kt index 08da7f3b4..b8de3aa99 100644 --- a/checkout/src/main/java/com/checkout/validation/model/CvvValidationRequest.kt +++ b/checkout/src/main/java/com/checkout/validation/model/CvvValidationRequest.kt @@ -13,5 +13,5 @@ internal data class CvvValidationRequest( /** * The card scheme representing as an [CardScheme] */ - val cardScheme: CardScheme + val cardScheme: CardScheme, ) diff --git a/checkout/src/main/java/com/checkout/validation/model/ExpiryDateValidationRequest.kt b/checkout/src/main/java/com/checkout/validation/model/ExpiryDateValidationRequest.kt index 14f873bfb..7fc42901d 100644 --- a/checkout/src/main/java/com/checkout/validation/model/ExpiryDateValidationRequest.kt +++ b/checkout/src/main/java/com/checkout/validation/model/ExpiryDateValidationRequest.kt @@ -11,5 +11,5 @@ internal data class ExpiryDateValidationRequest( /** * The expiry year representing as an [String] value YYYY format. (E.g. 2021) */ - val expiryYear: String + val expiryYear: String, ) diff --git a/checkout/src/main/java/com/checkout/validation/validator/AddressValidator.kt b/checkout/src/main/java/com/checkout/validation/validator/AddressValidator.kt index cacdc47b4..00857badb 100644 --- a/checkout/src/main/java/com/checkout/validation/validator/AddressValidator.kt +++ b/checkout/src/main/java/com/checkout/validation/validator/AddressValidator.kt @@ -1,12 +1,12 @@ package com.checkout.validation.validator -import com.checkout.tokenization.model.Address import com.checkout.base.util.ADDRESS_LINE1_LENGTH import com.checkout.base.util.ADDRESS_LINE2_LENGTH import com.checkout.base.util.CITY_LENGTH -import com.checkout.base.util.ZIP_LENGTH import com.checkout.base.util.STATE_LENGTH +import com.checkout.base.util.ZIP_LENGTH import com.checkout.tokenization.mapper.request.AddressValidationRequestToAddressDataMapper +import com.checkout.tokenization.model.Address import com.checkout.validation.error.ValidationError import com.checkout.validation.model.AddressValidationRequest import com.checkout.validation.model.ValidationResult @@ -46,23 +46,23 @@ internal class AddressValidator : Validator { when { address.addressLine1.length > ADDRESS_LINE1_LENGTH -> throw ValidationError( ValidationError.ADDRESS_LINE1_INCORRECT_LENGTH, - "Address line 1 exceeding minimum length of characters" + "Address line 1 exceeding minimum length of characters", ) address.addressLine2.length > ADDRESS_LINE2_LENGTH -> throw ValidationError( ValidationError.ADDRESS_LINE2_INCORRECT_LENGTH, - "Address line 2 exceeding minimum length of characters" + "Address line 2 exceeding minimum length of characters", ) address.city.length > CITY_LENGTH -> throw ValidationError( ValidationError.INVALID_CITY_LENGTH, - "City exceeding minimum length of characters" + "City exceeding minimum length of characters", ) address.state.length > STATE_LENGTH -> throw ValidationError( ValidationError.INVALID_STATE_LENGTH, - "State exceeding minimum length of characters" + "State exceeding minimum length of characters", ) address.zip.length > ZIP_LENGTH -> throw ValidationError( ValidationError.INVALID_ZIP_LENGTH, - "Zipcode exceeding minimum length of characters" + "Zipcode exceeding minimum length of characters", ) } } diff --git a/checkout/src/main/java/com/checkout/validation/validator/CVVComponentDetailsValidator.kt b/checkout/src/main/java/com/checkout/validation/validator/CVVComponentDetailsValidator.kt index 63e5c19f1..b8ef740d2 100644 --- a/checkout/src/main/java/com/checkout/validation/validator/CVVComponentDetailsValidator.kt +++ b/checkout/src/main/java/com/checkout/validation/validator/CVVComponentDetailsValidator.kt @@ -13,8 +13,9 @@ internal class CVVComponentDetailsValidator(private val cvvValidator: Validator< override fun validate(cvv: String, cardScheme: CardScheme): ValidationResult = if (cvv.isEmpty()) { ValidationResult.Failure( ValidationError( - errorCode = ValidationError.CVV_INVALID_LENGTH, message = "Please enter a valid security code" - ) + errorCode = ValidationError.CVV_INVALID_LENGTH, + message = "Please enter a valid security code", + ), ) } else { cvvValidator.validate(CvvValidationRequest(cvv, cardScheme)) diff --git a/checkout/src/main/java/com/checkout/validation/validator/CardDetailsValidator.kt b/checkout/src/main/java/com/checkout/validation/validator/CardDetailsValidator.kt index 4e35fa29e..120872791 100644 --- a/checkout/src/main/java/com/checkout/validation/validator/CardDetailsValidator.kt +++ b/checkout/src/main/java/com/checkout/validation/validator/CardDetailsValidator.kt @@ -1,22 +1,22 @@ package com.checkout.validation.validator -import com.checkout.tokenization.model.ExpiryDate import com.checkout.base.model.CardScheme import com.checkout.logging.Logger import com.checkout.logging.model.LoggingEvent +import com.checkout.tokenization.model.ExpiryDate import com.checkout.validation.api.CardValidator import com.checkout.validation.logging.ValidationEventType +import com.checkout.validation.model.CardNumberValidationRequest import com.checkout.validation.model.CvvValidationRequest -import com.checkout.validation.model.ValidationResult import com.checkout.validation.model.ExpiryDateValidationRequest -import com.checkout.validation.model.CardNumberValidationRequest +import com.checkout.validation.model.ValidationResult import com.checkout.validation.validator.contract.Validator internal class CardDetailsValidator( private val expiryDateValidator: Validator, private val cvvValidator: Validator, private val cardNumberValidator: Validator, - private val logger: Logger? = null + private val logger: Logger? = null, ) : CardValidator { init { @@ -25,7 +25,7 @@ internal class CardDetailsValidator( override fun validateExpiryDate( expiryMonth: String, - expiryYear: String + expiryYear: String, ): ValidationResult { logEvent(ValidationEventType.VALIDATE_EXPIRY_DATE_STRING) return expiryDateValidator.validate(ExpiryDateValidationRequest(expiryMonth, expiryYear)) @@ -33,7 +33,7 @@ internal class CardDetailsValidator( override fun validateExpiryDate( expiryMonth: Int, - expiryYear: Int + expiryYear: Int, ): ValidationResult { logEvent(ValidationEventType.VALIDATE_EXPIRY_DATE_INT) return expiryDateValidator.validate(ExpiryDateValidationRequest(expiryMonth.toString(), expiryYear.toString())) @@ -41,7 +41,7 @@ internal class CardDetailsValidator( override fun validateCvv( cvv: String, - cardScheme: CardScheme + cardScheme: CardScheme, ): ValidationResult { logEvent(ValidationEventType.VALIDATE_CVV) return cvvValidator.validate(CvvValidationRequest(cvv, cardScheme)) diff --git a/checkout/src/main/java/com/checkout/validation/validator/CardNumberValidator.kt b/checkout/src/main/java/com/checkout/validation/validator/CardNumberValidator.kt index ea875845c..74b804632 100644 --- a/checkout/src/main/java/com/checkout/validation/validator/CardNumberValidator.kt +++ b/checkout/src/main/java/com/checkout/validation/validator/CardNumberValidator.kt @@ -11,7 +11,7 @@ import com.checkout.validation.validator.contract.Validator * Class used to validate card number. */ internal class CardNumberValidator( - private val checker: Checker + private val checker: Checker, ) : Validator { /** @@ -42,15 +42,19 @@ internal class CardNumberValidator( private fun validate(cardNumber: String): CardScheme { val cardScheme = provideCardScheme(cardNumber, false) - if (cardScheme == CardScheme.UNKNOWN) throw ValidationError( - ValidationError.CARD_NUMBER_SCHEME_UNRECOGNIZED, - "Card scheme not recognized" - ) + if (cardScheme == CardScheme.UNKNOWN) { + throw ValidationError( + ValidationError.CARD_NUMBER_SCHEME_UNRECOGNIZED, + "Card scheme not recognized", + ) + } - if (!checker.check(cardNumber)) throw ValidationError( - ValidationError.CARD_NUMBER_LUHN_CHECK_ERROR, - "Card number Luhn check error" - ) + if (!checker.check(cardNumber)) { + throw ValidationError( + ValidationError.CARD_NUMBER_LUHN_CHECK_ERROR, + "Card number Luhn check error", + ) + } return cardScheme } @@ -66,10 +70,12 @@ internal class CardNumberValidator( @Throws(ValidationError::class) private fun provideCardScheme(cardNumber: String, isEager: Boolean): CardScheme { - if (cardNumber.any { !it.isDigit() }) throw ValidationError( - ValidationError.CARD_NUMBER_INVALID_CHARACTERS, - "Card number should contain only digits" - ) + if (cardNumber.any { !it.isDigit() }) { + throw ValidationError( + ValidationError.CARD_NUMBER_INVALID_CHARACTERS, + "Card number should contain only digits", + ) + } CardScheme.values().forEach { val regex = if (isEager) it.eagerRegex else it.regex diff --git a/checkout/src/main/java/com/checkout/validation/validator/CvvValidator.kt b/checkout/src/main/java/com/checkout/validation/validator/CvvValidator.kt index c20aea6fe..4e999ffa8 100644 --- a/checkout/src/main/java/com/checkout/validation/validator/CvvValidator.kt +++ b/checkout/src/main/java/com/checkout/validation/validator/CvvValidator.kt @@ -35,19 +35,19 @@ internal class CvvValidator : Validator { when { cvv.any { !it.isDigit() } -> throw ValidationError( ValidationError.CVV_CONTAINS_NON_DIGITS, - "CVV should contain only digits" + "CVV should contain only digits", ) cvvLength.any { it == cvv.length } -> return cvv.length < cvvLength.min() || cvv.length < cvvLength.max() -> throw ValidationError( ValidationError.CVV_INCOMPLETE_LENGTH, - "Incomplete CVV length, it should be $cvvLength" + "Incomplete CVV length, it should be $cvvLength", ) else -> throw ValidationError( ValidationError.CVV_INVALID_LENGTH, - "Invalid CVV length, it should be $cvvLength" + "Invalid CVV length, it should be $cvvLength", ) } } diff --git a/checkout/src/main/java/com/checkout/validation/validator/ExpiryDateValidator.kt b/checkout/src/main/java/com/checkout/validation/validator/ExpiryDateValidator.kt index cede4f439..fc241a73c 100644 --- a/checkout/src/main/java/com/checkout/validation/validator/ExpiryDateValidator.kt +++ b/checkout/src/main/java/com/checkout/validation/validator/ExpiryDateValidator.kt @@ -23,7 +23,7 @@ internal class ExpiryDateValidator : Validator = try { val expiryDate = ExpiryDate( provideValidatedMonth(data.expiryMonth), - provideValidated4DigitYear(data.expiryYear) + provideValidated4DigitYear(data.expiryYear), ) validateExpiryDate(expiryDate) @@ -43,11 +43,11 @@ internal class ExpiryDateValidator : Validator throw ValidationError( ValidationError.INVALID_MONTH_STRING, - "Invalid value provided for month: $month" + "Invalid value provided for month: $month", ) !in MONTH_RANGE -> throw ValidationError( ValidationError.INVALID_MONTH, - "Month must be >= ${MONTH_RANGE.first} && <= ${MONTH_RANGE.last}" + "Month must be >= ${MONTH_RANGE.first} && <= ${MONTH_RANGE.last}", ) else -> month } @@ -67,18 +67,18 @@ internal class ExpiryDateValidator : Validator throw ValidationError( ValidationError.INVALID_YEAR_STRING, - "Invalid value provided for year: $value" + "Invalid value provided for year: $value", ) year < 0 -> throw ValidationError( ValidationError.INVALID_YEAR, - "Year cannot be a negative value: $value" + "Year cannot be a negative value: $value", ) (value.length == 1 && value.first() < referenceYear.first()) || value.length == YEAR_SHORT_FORMAT -> year + YEAR_LONG_DELTA // Convert 2 digit year to 4 digit year value.length == YEAR_LONG_FORMAT -> year else -> throw ValidationError( ValidationError.INVALID_YEAR, - "Unexpected year value detected: $value" + "Unexpected year value detected: $value", ) } } @@ -98,7 +98,7 @@ internal class ExpiryDateValidator : Validator { for (i in reversedNumber.indices) { val digit = reversedNumber[i].digitToIntOrNull() ?: return false - if (i % 2 == 0) oddSum += digit - else evenSum += digit / 5 + 2 * digit % 10 + if (i % 2 == 0) { + oddSum += digit + } else { + evenSum += digit / 5 + 2 * digit % 10 + } } return (oddSum + evenSum) % 10 == 0 diff --git a/checkout/src/main/java/com/checkout/validation/validator/PhoneValidator.kt b/checkout/src/main/java/com/checkout/validation/validator/PhoneValidator.kt index 0e01968a9..a92ccbba9 100644 --- a/checkout/src/main/java/com/checkout/validation/validator/PhoneValidator.kt +++ b/checkout/src/main/java/com/checkout/validation/validator/PhoneValidator.kt @@ -1,8 +1,8 @@ package com.checkout.validation.validator -import com.checkout.tokenization.model.Phone import com.checkout.base.util.PHONE_MAX_LENGTH import com.checkout.base.util.PHONE_MIN_LENGTH +import com.checkout.tokenization.model.Phone import com.checkout.validation.error.ValidationError import com.checkout.validation.model.PhoneValidationRequest import com.checkout.validation.model.ValidationResult @@ -22,7 +22,7 @@ internal class PhoneValidator : Validator { override fun validate(data: PhoneValidationRequest): ValidationResult = try { val phone = Phone( data.number, - data.country + data.country, ) validatePhone(phone) @@ -44,7 +44,7 @@ internal class PhoneValidator : Validator { when { phone.number.length < PHONE_MIN_LENGTH || phone.number.length > PHONE_MAX_LENGTH -> throw ValidationError( ValidationError.NUMBER_INCORRECT_LENGTH, - "Invalid length of phone number" + "Invalid length of phone number", ) } } diff --git a/checkout/src/test/java/com/checkout/CheckoutApiServiceFactoryTest.kt b/checkout/src/test/java/com/checkout/CheckoutApiServiceFactoryTest.kt index 9a15a7cbf..4eea27064 100644 --- a/checkout/src/test/java/com/checkout/CheckoutApiServiceFactoryTest.kt +++ b/checkout/src/test/java/com/checkout/CheckoutApiServiceFactoryTest.kt @@ -5,12 +5,12 @@ import com.checkout.base.model.Environment import com.checkout.logging.EventLoggerProvider import com.checkout.logging.Logger import com.checkout.logging.model.LoggingEvent -import io.mockk.mockkObject import io.mockk.every -import io.mockk.mockk -import io.mockk.verify import io.mockk.impl.annotations.RelaxedMockK import io.mockk.junit5.MockKExtension +import io.mockk.mockk +import io.mockk.mockkObject +import io.mockk.verify import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/checkout/src/test/java/com/checkout/api/CheckoutApiClientTest.kt b/checkout/src/test/java/com/checkout/api/CheckoutApiClientTest.kt index e5d9d40e3..649f2490c 100644 --- a/checkout/src/test/java/com/checkout/api/CheckoutApiClientTest.kt +++ b/checkout/src/test/java/com/checkout/api/CheckoutApiClientTest.kt @@ -11,13 +11,13 @@ import com.checkout.tokenization.model.CVVTokenizationRequest import com.checkout.tokenization.model.CardTokenRequest import com.checkout.tokenization.model.GooglePayTokenRequest import com.checkout.tokenization.repository.TokenRepository -import io.mockk.mockkObject import io.mockk.every -import io.mockk.slot -import io.mockk.verify -import io.mockk.mockk import io.mockk.impl.annotations.RelaxedMockK import io.mockk.junit5.MockKExtension +import io.mockk.mockk +import io.mockk.mockkObject +import io.mockk.slot +import io.mockk.verify import org.amshove.kluent.internal.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -44,7 +44,7 @@ internal class CheckoutApiClientTest { checkoutApiService = CheckoutApiClient( mockTokenRepository, - mockThreeDSExecutor + mockThreeDSExecutor, ) } diff --git a/checkout/src/test/java/com/checkout/logging/EventLoggerTest.kt b/checkout/src/test/java/com/checkout/logging/EventLoggerTest.kt index 3b3a79d7d..b2aad5875 100644 --- a/checkout/src/test/java/com/checkout/logging/EventLoggerTest.kt +++ b/checkout/src/test/java/com/checkout/logging/EventLoggerTest.kt @@ -9,16 +9,15 @@ import com.checkout.eventlogger.domain.model.Event import com.checkout.eventlogger.domain.model.MonitoringLevel import com.checkout.eventlogger.domain.model.RemoteProcessorMetadata import com.checkout.logging.model.LoggingEvent -import io.mockk.spyk -import io.mockk.mockk -import io.mockk.verify -import io.mockk.slot import io.mockk.every import io.mockk.impl.annotations.RelaxedMockK import io.mockk.junit5.MockKExtension +import io.mockk.mockk +import io.mockk.slot +import io.mockk.spyk +import io.mockk.verify import org.amshove.kluent.internal.assertEquals import org.junit.jupiter.api.Assertions.assertTrue - import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -45,7 +44,7 @@ internal class EventLoggerTest { mockContext, "sandbox", BuildConfig.PRODUCT_IDENTIFIER, - BuildConfig.PRODUCT_VERSION + BuildConfig.PRODUCT_VERSION, ) // When @@ -55,7 +54,7 @@ internal class EventLoggerTest { verify { mockLogger.enableRemoteProcessor( eq(com.checkout.eventlogger.Environment.SANDBOX), - eq(expectedMetadata) + eq(expectedMetadata), ) } } diff --git a/checkout/src/test/java/com/checkout/mock/GetTokenDetailsResponseTestJson.kt b/checkout/src/test/java/com/checkout/mock/GetTokenDetailsResponseTestJson.kt index 97149602a..dbe94ec08 100644 --- a/checkout/src/test/java/com/checkout/mock/GetTokenDetailsResponseTestJson.kt +++ b/checkout/src/test/java/com/checkout/mock/GetTokenDetailsResponseTestJson.kt @@ -3,17 +3,17 @@ package com.checkout.mock internal object GetTokenDetailsResponseTestJson { const val addressJson = "{\n" + - " \"address_line1\": \"Checkout.com\",\n" + - " \"address_line2\": \"90 Tottenham Court Road\",\n" + - " \"city\": \"London\",\n" + - " \"state\": \"London\",\n" + - " \"zip\": \"W1T 4TJ\",\n" + - " \"country\": \"GB\"\n" + - " }" + " \"address_line1\": \"Checkout.com\",\n" + + " \"address_line2\": \"90 Tottenham Court Road\",\n" + + " \"city\": \"London\",\n" + + " \"state\": \"London\",\n" + + " \"zip\": \"W1T 4TJ\",\n" + + " \"country\": \"GB\"\n" + + " }" const val phoneJson = "{\n" + - " \"number\": \"4155552671\",\n" + - " \"country_code\": \"44\"\n" + - " }" + " \"number\": \"4155552671\",\n" + + " \"country_code\": \"44\"\n" + + " }" val cardTokenDetailsResponse = """ { @@ -45,7 +45,7 @@ internal object GetTokenDetailsResponseTestJson { }, "name": "Bruce Wayne" } - """.trimIndent() + """.trimIndent() val cvvTokenDetailsResponse = """ { @@ -53,7 +53,7 @@ internal object GetTokenDetailsResponseTestJson { "token": "tok_ubfj2q76miwundwlk72vxt2i7q", "expires_on": "2019-08-24T14:15:22Z" } - """.trimIndent() + """.trimIndent() val googlePayTokenDetailsResponse = """ { @@ -72,7 +72,7 @@ internal object GetTokenDetailsResponseTestJson { "product_id": "F", "product_type": "CLASSIC" } - """.trimIndent() + """.trimIndent() val cardTokenDetailsErrorResponse = """ { @@ -83,7 +83,7 @@ internal object GetTokenDetailsResponseTestJson { "cvv_invalid" ] } - """.trimIndent() + """.trimIndent() val cvvTokenDetailsErrorResponse = """ { @@ -93,7 +93,7 @@ internal object GetTokenDetailsResponseTestJson { "cvv_invalid" ] } - """.trimIndent() + """.trimIndent() val googlePayTokenDetailsErrorResponse = """ { @@ -103,5 +103,5 @@ internal object GetTokenDetailsResponseTestJson { "token_data_invalid" ] } - """.trimIndent() + """.trimIndent() } diff --git a/checkout/src/test/java/com/checkout/mock/TokenizationRequestTestData.kt b/checkout/src/test/java/com/checkout/mock/TokenizationRequestTestData.kt index 3d50438ad..874fae01a 100644 --- a/checkout/src/test/java/com/checkout/mock/TokenizationRequestTestData.kt +++ b/checkout/src/test/java/com/checkout/mock/TokenizationRequestTestData.kt @@ -7,9 +7,9 @@ import com.checkout.tokenization.entity.AddressEntity import com.checkout.tokenization.entity.PhoneEntity import com.checkout.tokenization.model.Address import com.checkout.tokenization.model.CVVTokenizationRequest -import com.checkout.tokenization.model.Phone -import com.checkout.tokenization.model.ExpiryDate import com.checkout.tokenization.model.Card +import com.checkout.tokenization.model.ExpiryDate +import com.checkout.tokenization.model.Phone import com.checkout.tokenization.response.TokenDetailsResponse import com.checkout.validation.model.AddressValidationRequest @@ -21,7 +21,7 @@ internal object TokenizationRequestTestData { "London", "London", "W1T 4TJ", - "GB" + "GB", ) private val country = Country.from("GB") @@ -33,7 +33,7 @@ internal object TokenizationRequestTestData { "London", "London", "W1T 4TJ", - country + country, ) val addressValidationRequest = AddressValidationRequest( @@ -42,7 +42,7 @@ internal object TokenizationRequestTestData { "London", "London", "W1T 4TJ", - country + country, ) val cvvTokenizationRequest = CVVTokenizationRequest(cvv = "123", cardScheme = CardScheme.VISA, resultHandler = { }) @@ -59,13 +59,13 @@ internal object TokenizationRequestTestData { "4242424242424242", "123", address, - phone + phone, ) fun errorResponse() = ErrorResponse( "testID", "testErrorType", - listOf("testErrorCodes") + listOf("testErrorCodes"), ) fun tokenDetailsResponse() = TokenDetailsResponse( @@ -86,37 +86,37 @@ internal object TokenizationRequestTestData { productType = "CLASSIC", billingAddress = null, phone = null, - name = "Bruce Wayne" + name = "Bruce Wayne", ) val invalidAddress = Address( "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem" + - " Ipsum has been the" + - " industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type" + - " and " + - "scrambled it to make a type specimen book. It has survived not only five centuries, but also" + - " the leap" + - " into electronic typesetting, remaining essentially unchanged. It was popularised" + - " in the 1960s with the" + - " release of Letraset sheets containing Lorem Ipsum passages, " + - "and more recently with desktop publishing" + - " software like Aldus PageMaker including versions of Lorem Ipsum.\n", + " Ipsum has been the" + + " industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type" + + " and " + + "scrambled it to make a type specimen book. It has survived not only five centuries, but also" + + " the leap" + + " into electronic typesetting, remaining essentially unchanged. It was popularised" + + " in the 1960s with the" + + " release of Letraset sheets containing Lorem Ipsum passages, " + + "and more recently with desktop publishing" + + " software like Aldus PageMaker including versions of Lorem Ipsum.\n", "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem\" +\n" + - "\" Ipsum has been the\" +\n" + - "\" industry's standard dummy text ever since the 1500s, when an unknown printer took a" + - " galley of type\" +\n" + - "\" and \" +\n" + - "\"scrambled it to make a type specimen book. It has survived not only five centuries, but also\" +\n" + - "\" the leap\" +\n" + - "\" into electronic typesetting, remaining essentially unchanged. It was popularised\" +\n" + - "\" in the 1960s with the\" +\n" + - "\" release of Letraset sheets containing Lorem Ipsum passages, \" +\n" + - "\"and more recently with desktop publishing\" +\n" + - "\" software like Aldus PageMaker including versions of Lorem Ipsum.\\n\"", + "\" Ipsum has been the\" +\n" + + "\" industry's standard dummy text ever since the 1500s, when an unknown printer took a" + + " galley of type\" +\n" + + "\" and \" +\n" + + "\"scrambled it to make a type specimen book. It has survived not only five centuries, but also\" +\n" + + "\" the leap\" +\n" + + "\" into electronic typesetting, remaining essentially unchanged. It was popularised\" +\n" + + "\" in the 1960s with the\" +\n" + + "\" release of Letraset sheets containing Lorem Ipsum passages, \" +\n" + + "\"and more recently with desktop publishing\" +\n" + + "\" software like Aldus PageMaker including versions of Lorem Ipsum.\\n\"", "dummyLongCity????????????????????????????????????????", "dummyLongCity???????????????????????????????????sdds", "dummyLongCity???????????????????????????????????sdds", - invalidCountry + invalidCountry, ) val inValidPhone = Phone("412", invalidCountry) diff --git a/checkout/src/test/java/com/checkout/threedsecure/ThreeDSExecutorTest.kt b/checkout/src/test/java/com/checkout/threedsecure/ThreeDSExecutorTest.kt index 50548ee02..d830cf2ec 100644 --- a/checkout/src/test/java/com/checkout/threedsecure/ThreeDSExecutorTest.kt +++ b/checkout/src/test/java/com/checkout/threedsecure/ThreeDSExecutorTest.kt @@ -12,15 +12,14 @@ import com.checkout.threedsecure.model.ThreeDSRequest import com.checkout.threedsecure.model.ThreeDSResult import com.checkout.threedsecure.model.ThreeDSResultHandler import com.checkout.threedsecure.webview.ThreeDSWebView +import io.mockk.every +import io.mockk.impl.annotations.RelaxedMockK +import io.mockk.junit5.MockKExtension import io.mockk.mockk import io.mockk.slot import io.mockk.spyk -import io.mockk.every import io.mockk.verify -import io.mockk.impl.annotations.RelaxedMockK -import io.mockk.junit5.MockKExtension import org.amshove.kluent.internal.assertEquals - import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -66,7 +65,7 @@ internal class ThreeDSExecutorTest { challengeUrl = "https://www.test.com", successUrl = "https://success", failureUrl = "https://failure", - resultHandler = {} + resultHandler = {}, ) // When @@ -104,7 +103,7 @@ internal class ThreeDSExecutorTest { @ParameterizedTest( name = "when handle result is invoked with {0} " + - "then complete event with success = {1}, error = {2} and token {3} is logged" + "then complete event with success = {1}, error = {2} and token {3} is logged", ) @MethodSource("resultArguments") fun `when handle result is invoked then complete event with correct data is logged`( @@ -169,7 +168,7 @@ internal class ThreeDSExecutorTest { fun resultArguments(): Stream = Stream.of( Arguments.of(ThreeDSResult.Success("token"), true), Arguments.of(ThreeDSResult.Error(ThreeDSError("123", "test")), false), - Arguments.of(ThreeDSResult.Failure, false) + Arguments.of(ThreeDSResult.Failure, false), ) } } diff --git a/checkout/src/test/java/com/checkout/threedsecure/logging/ThreeDSEventLoggerTest.kt b/checkout/src/test/java/com/checkout/threedsecure/logging/ThreeDSEventLoggerTest.kt index c98e9f905..2b8af4d7b 100644 --- a/checkout/src/test/java/com/checkout/threedsecure/logging/ThreeDSEventLoggerTest.kt +++ b/checkout/src/test/java/com/checkout/threedsecure/logging/ThreeDSEventLoggerTest.kt @@ -9,7 +9,6 @@ import io.mockk.junit5.MockKExtension import io.mockk.slot import io.mockk.verify import org.amshove.kluent.internal.assertEquals - import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -70,7 +69,7 @@ internal class ThreeDSEventLoggerTest { val expected = LoggingEvent( ThreeDSEventType.COMPLETED, MonitoringLevel.INFO, - mapOf("success" to true, "tokenID" to "testToken") + mapOf("success" to true, "tokenID" to "testToken"), ) val capturedEvent = slot() @@ -97,8 +96,8 @@ internal class ThreeDSEventLoggerTest { "success" to false, "errorCodes" to "123", "message" to "testMessage", - "exception" to (mockError).stackTraceToString() - ) + "exception" to (mockError).stackTraceToString(), + ), ) val capturedEvent = slot() diff --git a/checkout/src/test/java/com/checkout/threedsecure/usecase/ProcessThreeDSUseCaseTest.kt b/checkout/src/test/java/com/checkout/threedsecure/usecase/ProcessThreeDSUseCaseTest.kt index 6ab0e8567..1e8df81c4 100644 --- a/checkout/src/test/java/com/checkout/threedsecure/usecase/ProcessThreeDSUseCaseTest.kt +++ b/checkout/src/test/java/com/checkout/threedsecure/usecase/ProcessThreeDSUseCaseTest.kt @@ -9,7 +9,6 @@ import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test - import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -30,7 +29,7 @@ internal class ProcessThreeDSUseCaseTest { val mockRequest = ProcessThreeDSRequest( redirectUrl = "https://test.com/success?cko-payment-token=paymentToken&cko-session-id=sessionId", successUrl = "https://test.com/success", - failureUrl = "https://test.com/failure" + failureUrl = "https://test.com/failure", ) // When @@ -47,7 +46,7 @@ internal class ProcessThreeDSUseCaseTest { val mockRequest = ProcessThreeDSRequest( redirectUrl = "https://www.successUrl.com/test?cko-session-id=sessionId", successUrl = "https://www.successUrl.com/test", - failureUrl = "https://www.failure.com" + failureUrl = "https://www.failure.com", ) // When @@ -64,10 +63,10 @@ internal class ProcessThreeDSUseCaseTest { val mockRequest = ProcessThreeDSRequest( redirectUrl = "https://successUrl/test", successUrl = "https://successUrl/test", - failureUrl = "https://failure/test" + failureUrl = "https://failure/test", ) val expected = ThreeDSResult.Error( - ThreeDSError(ThreeDSError.COULD_NOT_EXTRACT_TOKEN, "Url can't be null.") + ThreeDSError(ThreeDSError.COULD_NOT_EXTRACT_TOKEN, "Url can't be null."), ) // When @@ -84,7 +83,7 @@ internal class ProcessThreeDSUseCaseTest { val mockRequest = ProcessThreeDSRequest( redirectUrl = "https://failure/test", successUrl = "https://successUrl/test", - failureUrl = "https://failure/test" + failureUrl = "https://failure/test", ) // When @@ -100,7 +99,7 @@ internal class ProcessThreeDSUseCaseTest { val mockRequest = ProcessThreeDSRequest( redirectUrl = "https://www.test.for.test/unknown", successUrl = "https://successUrl/test", - failureUrl = "https://failure/test" + failureUrl = "https://failure/test", ) // When diff --git a/checkout/src/test/java/com/checkout/threedsecure/utils/UriExtensionKtTest.kt b/checkout/src/test/java/com/checkout/threedsecure/utils/UriExtensionKtTest.kt index 8dfbbee15..94dc3e6a6 100644 --- a/checkout/src/test/java/com/checkout/threedsecure/utils/UriExtensionKtTest.kt +++ b/checkout/src/test/java/com/checkout/threedsecure/utils/UriExtensionKtTest.kt @@ -9,13 +9,13 @@ import org.robolectric.ParameterizedRobolectricTestRunner internal class UriExtensionKtTest( private val expectedUrl: String, private val targetUrl: String, - private val result: Boolean + private val result: Boolean, ) { companion object { @JvmStatic @ParameterizedRobolectricTestRunner.Parameters( - name = "When expected Url {0} compared with target Url {1} then {2} is returned" + name = "When expected Url {0} compared with target Url {1} then {2} is returned", ) fun data() = listOf( arrayOf("www.example.com/Success", "https://www.example.com/Success", false), @@ -30,13 +30,13 @@ internal class UriExtensionKtTest( arrayOf( "https://www.example.com/test?q=Success", "https://www.example.com/test?q=Success&cko-session-id=wrongValue", - true + true, ), arrayOf( "https://www.example.com/test?q=Success&hello=world", "https://www.example.com/test?hello=world&q=Success", - true - ) + true, + ), ) } diff --git a/checkout/src/test/java/com/checkout/tokenization/TokenNetworkApiClientTest.kt b/checkout/src/test/java/com/checkout/tokenization/TokenNetworkApiClientTest.kt index a79d32516..cf59be21c 100644 --- a/checkout/src/test/java/com/checkout/tokenization/TokenNetworkApiClientTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/TokenNetworkApiClientTest.kt @@ -2,8 +2,8 @@ package com.checkout.tokenization import android.os.Build import androidx.annotation.RequiresApi -import com.checkout.mock.TokenizationRequestTestData import com.checkout.mock.GetTokenDetailsResponseTestJson +import com.checkout.mock.TokenizationRequestTestData import com.checkout.network.OkHttpProvider import com.checkout.network.response.NetworkApiResponse import com.checkout.tokenization.entity.GooglePayEntity @@ -22,13 +22,13 @@ import okhttp3.mockwebserver.SocketPolicy import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldNotBeNull import org.amshove.kluent.shouldNotBeNullOrEmpty -import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test -import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource @@ -56,7 +56,7 @@ internal class TokenNetworkApiClientTest { tokenNetworkApiClient = TokenNetworkApiClient( serverBaseUrl, OkHttpProvider.createOkHttpClient("test_key"), - moshiClient + moshiClient, ) } @@ -91,12 +91,12 @@ internal class TokenNetworkApiClientTest { // Given enqueueMockResponse( 200, - GetTokenDetailsResponseTestJson.cardTokenDetailsResponse + GetTokenDetailsResponseTestJson.cardTokenDetailsResponse, ) // When val response = tokenNetworkApiClient.sendCardTokenRequest( - CardToTokenRequestMapper().map(TokenizationRequestTestData.card) + CardToTokenRequestMapper().map(TokenizationRequestTestData.card), ) launch { @@ -137,12 +137,12 @@ internal class TokenNetworkApiClientTest { // Given enqueueMockResponse( errorCode, - GetTokenDetailsResponseTestJson.cardTokenDetailsErrorResponse + GetTokenDetailsResponseTestJson.cardTokenDetailsErrorResponse, ) // When val response = tokenNetworkApiClient.sendCardTokenRequest( - CardToTokenRequestMapper().map(TokenizationRequestTestData.card) + CardToTokenRequestMapper().map(TokenizationRequestTestData.card), ) // Then @@ -172,7 +172,7 @@ internal class TokenNetworkApiClientTest { // When val response = tokenNetworkApiClient.sendCardTokenRequest( - CardToTokenRequestMapper().map(TokenizationRequestTestData.card) + CardToTokenRequestMapper().map(TokenizationRequestTestData.card), ) launch { @@ -200,12 +200,12 @@ internal class TokenNetworkApiClientTest { // Given enqueueMockResponse( 200, - GetTokenDetailsResponseTestJson.cvvTokenDetailsResponse + GetTokenDetailsResponseTestJson.cvvTokenDetailsResponse, ) // When val response = tokenNetworkApiClient.sendCVVTokenRequest( - CVVToTokenNetworkRequestMapper().map(TokenizationRequestTestData.cvvTokenizationRequest) + CVVToTokenNetworkRequestMapper().map(TokenizationRequestTestData.cvvTokenizationRequest), ) launch { @@ -232,12 +232,12 @@ internal class TokenNetworkApiClientTest { // Given enqueueMockResponse( code = errorCode, - json = GetTokenDetailsResponseTestJson.cvvTokenDetailsErrorResponse + json = GetTokenDetailsResponseTestJson.cvvTokenDetailsErrorResponse, ) // When val response = tokenNetworkApiClient.sendCVVTokenRequest( - CVVToTokenNetworkRequestMapper().map(TokenizationRequestTestData.cvvTokenizationRequest) + CVVToTokenNetworkRequestMapper().map(TokenizationRequestTestData.cvvTokenizationRequest), ) // Then @@ -267,7 +267,7 @@ internal class TokenNetworkApiClientTest { // When val response = tokenNetworkApiClient.sendCVVTokenRequest( - CVVToTokenNetworkRequestMapper().map(TokenizationRequestTestData.cvvTokenizationRequest) + CVVToTokenNetworkRequestMapper().map(TokenizationRequestTestData.cvvTokenizationRequest), ) launch { @@ -295,7 +295,7 @@ internal class TokenNetworkApiClientTest { // Given enqueueMockResponse( 200, - GetTokenDetailsResponseTestJson.googlePayTokenDetailsResponse + GetTokenDetailsResponseTestJson.googlePayTokenDetailsResponse, ) // When @@ -303,8 +303,8 @@ internal class TokenNetworkApiClientTest { tokenNetworkApiClient.sendGooglePayTokenRequest( GooglePayTokenNetworkRequest( TokenizationConstants.GOOGLE_PAY, - GooglePayEntity() - ) + GooglePayEntity(), + ), ) // Then @@ -329,14 +329,14 @@ internal class TokenNetworkApiClientTest { is NetworkApiResponse.NetworkError -> { org.amshove.kluent.fail( "Get googlePayToken details should be successful:" + - " ${response.throwable.message}" + " ${response.throwable.message}", ) } is NetworkApiResponse.ServerError -> { org.amshove.kluent.fail( "Get googlePayToken details should be successful: " + - "${response.body?.errorCodes}" + "${response.body?.errorCodes}", ) } is NetworkApiResponse.InternalError -> { @@ -352,15 +352,15 @@ internal class TokenNetworkApiClientTest { // Given enqueueMockResponse( errorCode, - GetTokenDetailsResponseTestJson.googlePayTokenDetailsErrorResponse + GetTokenDetailsResponseTestJson.googlePayTokenDetailsErrorResponse, ) // When val response = tokenNetworkApiClient.sendGooglePayTokenRequest( GooglePayTokenNetworkRequest( TokenizationConstants.GOOGLE_PAY, - GooglePayEntity() - ) + GooglePayEntity(), + ), ) // Then @@ -392,8 +392,8 @@ internal class TokenNetworkApiClientTest { val response = tokenNetworkApiClient.sendGooglePayTokenRequest( GooglePayTokenNetworkRequest( TokenizationConstants.GOOGLE_PAY, - GooglePayEntity() - ) + GooglePayEntity(), + ), ) launch { diff --git a/checkout/src/test/java/com/checkout/tokenization/logging/TokenizationEventLoggerTest.kt b/checkout/src/test/java/com/checkout/tokenization/logging/TokenizationEventLoggerTest.kt index cbe761213..ed75ca489 100644 --- a/checkout/src/test/java/com/checkout/tokenization/logging/TokenizationEventLoggerTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/logging/TokenizationEventLoggerTest.kt @@ -44,7 +44,7 @@ internal class TokenizationEventLoggerTest { val mockTokenizationError = TokenizationError( "123", "testMessage", - NullPointerException() + NullPointerException(), ) val expected = LoggingEvent( @@ -55,15 +55,16 @@ internal class TokenizationEventLoggerTest { "publicKey" to "test_key", "errorCodes" to "123", "message" to "testMessage", - "exception" to (mockTokenizationError).stackTraceToString() - ) + "exception" to (mockTokenizationError).stackTraceToString(), + ), ) val capturedEvent = slot() // When tokenizationEventLogger.logErrorOnTokenRequestedEvent( TokenizationConstants.GOOGLE_PAY, - "test_key", error = mockTokenizationError + "test_key", + error = mockTokenizationError, ) // Then @@ -110,7 +111,7 @@ internal class TokenizationEventLoggerTest { val expected = LoggingEvent( TokenizationEventType.TOKEN_REQUESTED, MonitoringLevel.INFO, - mapOf("tokenType" to tokenType, "publicKey" to "test_key") + mapOf("tokenType" to tokenType, "publicKey" to "test_key"), ) val capturedEvent = slot() @@ -135,8 +136,8 @@ internal class TokenizationEventLoggerTest { "tokenType" to tokenType, "publicKey" to "test_key", "tokenID" to "tok_test", - "scheme" to "VISA" - ) + "scheme" to "VISA", + ), ) val capturedEvent = slot() @@ -145,7 +146,7 @@ internal class TokenizationEventLoggerTest { tokenizationEventLogger.logTokenResponseEvent( tokenType = tokenType, publicKey = "test_key", - tokenDetails = TokenizationRequestTestData.tokenDetailsResponse() + tokenDetails = TokenizationRequestTestData.tokenDetailsResponse(), ) // Then @@ -171,7 +172,7 @@ internal class TokenizationEventLoggerTest { "errorCodes" to listOf("testErrorCodes"), ), "httpStatusCode" to 501, - ) + ), ) val capturedEvent = slot() @@ -182,7 +183,7 @@ internal class TokenizationEventLoggerTest { "test_key", null, 501, - TokenizationRequestTestData.errorResponse() + TokenizationRequestTestData.errorResponse(), ) // Then diff --git a/checkout/src/test/java/com/checkout/tokenization/mapper/CardTokenizationNetworkDataMapperTest.kt b/checkout/src/test/java/com/checkout/tokenization/mapper/CardTokenizationNetworkDataMapperTest.kt index 188b19528..e80393d9e 100644 --- a/checkout/src/test/java/com/checkout/tokenization/mapper/CardTokenizationNetworkDataMapperTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/mapper/CardTokenizationNetworkDataMapperTest.kt @@ -44,7 +44,7 @@ internal class CardTokenizationNetworkDataMapperTest { // Given val expectedResult = expectedTokenDetails() setupMockResponses( - expectedResult + expectedResult, ) // When @@ -72,7 +72,7 @@ internal class CardTokenizationNetworkDataMapperTest { mappedResult `should be instance of` TokenResult.Failure::class (mappedResult as TokenResult.Failure).error.message `should be equal to` - "${Card::class.java.name} cannot be mapped to a TokenDetails" + "${Card::class.java.name} cannot be mapped to a TokenDetails" } private fun expectedTokenDetails(): TokenDetails = @@ -94,13 +94,13 @@ internal class CardTokenizationNetworkDataMapperTest { productType = "CLASSIC", billingAddress = AddressEntityToAddressDataMapper().map(TokenizationRequestTestData.addressEntity), phone = PhoneEntityToPhoneDataMapper().map( - from = TokenizationRequestTestData.phoneEntity to TokenizationRequestTestData.addressEntity.country + from = TokenizationRequestTestData.phoneEntity to TokenizationRequestTestData.addressEntity.country, ), - name = "Bruce Wayne" + name = "Bruce Wayne", ) private fun setupMockResponses( - tokenDetails: TokenDetails + tokenDetails: TokenDetails, ) { every { mockGetTokenDetailsResponse.type } returns tokenDetails.type every { mockGetTokenDetailsResponse.token } returns tokenDetails.token @@ -119,12 +119,12 @@ internal class CardTokenizationNetworkDataMapperTest { every { mockGetTokenDetailsResponse.productType } returns tokenDetails.productType every { mockGetTokenDetailsResponse.billingAddress } returns tokenDetails.billingAddress?.let { AddressToAddressEntityDataMapper().map( - it + it, ) } every { mockGetTokenDetailsResponse.phone } returns tokenDetails.phone?.let { PhoneToPhoneEntityDataMapper().map( - it + it, ) } every { mockGetTokenDetailsResponse.name } returns tokenDetails.name @@ -153,7 +153,7 @@ internal class CardTokenizationNetworkDataMapperTest { // Then mappedResult `should be instance of` TokenResult.Failure::class (mappedResult as TokenResult.Failure).error.message `should be equal to` - "Token request failed - testErrorType (HttpStatus: 400)" + "Token request failed - testErrorType (HttpStatus: 400)" } @Test diff --git a/checkout/src/test/java/com/checkout/tokenization/mapper/request/AddressToAddressEntityDataMapperTest.kt b/checkout/src/test/java/com/checkout/tokenization/mapper/request/AddressToAddressEntityDataMapperTest.kt index 4dbb58be7..fc699bcf7 100644 --- a/checkout/src/test/java/com/checkout/tokenization/mapper/request/AddressToAddressEntityDataMapperTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/mapper/request/AddressToAddressEntityDataMapperTest.kt @@ -23,7 +23,7 @@ internal class AddressToAddressEntityDataMapperTest { "London", "London", "W1T 4TJ", - "GB" + "GB", ) // When diff --git a/checkout/src/test/java/com/checkout/tokenization/mapper/request/CVVToTokenNetworkRequestMapperTest.kt b/checkout/src/test/java/com/checkout/tokenization/mapper/request/CVVToTokenNetworkRequestMapperTest.kt index e78a32c56..e7fa90911 100644 --- a/checkout/src/test/java/com/checkout/tokenization/mapper/request/CVVToTokenNetworkRequestMapperTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/mapper/request/CVVToTokenNetworkRequestMapperTest.kt @@ -20,7 +20,8 @@ internal class CVVToTokenNetworkRequestMapperTest { fun `mapping of CVVTokenizationRequest to CVVTokenNetworkRequest data`() { // Given val expectedCVVTokenNetworkRequest = CVVTokenNetworkRequest( - TokenizationConstants.CVV, TokenDataEntity("123") + TokenizationConstants.CVV, + TokenDataEntity("123"), ) val request = TokenizationRequestTestData.cvvTokenizationRequest diff --git a/checkout/src/test/java/com/checkout/tokenization/mapper/request/CardToTokenRequestMapperTest.kt b/checkout/src/test/java/com/checkout/tokenization/mapper/request/CardToTokenRequestMapperTest.kt index ac71926f2..d68323215 100644 --- a/checkout/src/test/java/com/checkout/tokenization/mapper/request/CardToTokenRequestMapperTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/mapper/request/CardToTokenRequestMapperTest.kt @@ -26,7 +26,7 @@ internal class CardToTokenRequestMapperTest { "Bob martin", "123", AddressToAddressEntityDataMapper().map(TokenizationRequestTestData.address), - PhoneToPhoneEntityDataMapper().map(TokenizationRequestTestData.phone) + PhoneToPhoneEntityDataMapper().map(TokenizationRequestTestData.phone), ) // When diff --git a/checkout/src/test/java/com/checkout/tokenization/mapper/response/AddressEntityToAddressDataMapperTest.kt b/checkout/src/test/java/com/checkout/tokenization/mapper/response/AddressEntityToAddressDataMapperTest.kt index c701859a8..1025d074a 100644 --- a/checkout/src/test/java/com/checkout/tokenization/mapper/response/AddressEntityToAddressDataMapperTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/mapper/response/AddressEntityToAddressDataMapperTest.kt @@ -25,7 +25,7 @@ internal class AddressEntityToAddressDataMapperTest { "London", "London", "W1T 4TJ", - Country.from("GB") + Country.from("GB"), ) // When diff --git a/checkout/src/test/java/com/checkout/tokenization/mapper/response/CVVTokenizationNetworkDataMapperTest.kt b/checkout/src/test/java/com/checkout/tokenization/mapper/response/CVVTokenizationNetworkDataMapperTest.kt index a00a7bca3..0c5f994bc 100644 --- a/checkout/src/test/java/com/checkout/tokenization/mapper/response/CVVTokenizationNetworkDataMapperTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/mapper/response/CVVTokenizationNetworkDataMapperTest.kt @@ -42,7 +42,7 @@ internal class CVVTokenizationNetworkDataMapperTest { // When val mappedResult = cvvTokenizationNetworkDataMapper.toTokenResult( - NetworkApiResponse.Success(mockGetCVVTokenDetailsResponse) + NetworkApiResponse.Success(mockGetCVVTokenDetailsResponse), ) // Then @@ -66,11 +66,13 @@ internal class CVVTokenizationNetworkDataMapperTest { mappedResult `should be instance of` TokenResult.Failure::class (mappedResult as TokenResult.Failure).error.message `should be equal to` - "${CVVTokenizationRequest::class.java.name} cannot be mapped to a CVVTokenDetails" + "${CVVTokenizationRequest::class.java.name} cannot be mapped to a CVVTokenDetails" } private fun expectedCVVTokenDetails(): CVVTokenDetails = CVVTokenDetails( - type = "CVV", token = "tok_test", expiresOn = "2019-08-24T14:15:22Z" + type = "CVV", + token = "tok_test", + expiresOn = "2019-08-24T14:15:22Z", ) private fun setupMockResponses( @@ -104,7 +106,7 @@ internal class CVVTokenizationNetworkDataMapperTest { // Then mappedResult `should be instance of` TokenResult.Failure::class (mappedResult as TokenResult.Failure).error.message `should be equal to` - "Token request failed - testErrorType (HttpStatus: 400)" + "Token request failed - testErrorType (HttpStatus: 400)" } @Test diff --git a/checkout/src/test/java/com/checkout/tokenization/mapper/response/PhoneEntityToPhoneDataMapperTest.kt b/checkout/src/test/java/com/checkout/tokenization/mapper/response/PhoneEntityToPhoneDataMapperTest.kt index 0478865dd..c5e92ee2e 100644 --- a/checkout/src/test/java/com/checkout/tokenization/mapper/response/PhoneEntityToPhoneDataMapperTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/mapper/response/PhoneEntityToPhoneDataMapperTest.kt @@ -22,8 +22,8 @@ internal class PhoneEntityToPhoneDataMapperTest { number = "4155552671", country = Country.getCountry( dialingCode = "44", - iso3166Alpha2 = "GB" - ) + iso3166Alpha2 = "GB", + ), ) // When diff --git a/checkout/src/test/java/com/checkout/tokenization/repository/TokenRepositoryImplTest.kt b/checkout/src/test/java/com/checkout/tokenization/repository/TokenRepositoryImplTest.kt index 54d27ab63..7cbf4e98f 100644 --- a/checkout/src/test/java/com/checkout/tokenization/repository/TokenRepositoryImplTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/repository/TokenRepositoryImplTest.kt @@ -56,7 +56,7 @@ internal class TokenRepositoryImplTest { @RelaxedMockK private lateinit var mockValidateCVVTokenizationDataUseCase: - UseCase> + UseCase> @RelaxedMockK private lateinit var mockTokenizationLogger: TokenizationLogger @@ -74,7 +74,7 @@ internal class TokenRepositoryImplTest { validateCVVTokenizationDataUseCase = mockValidateCVVTokenizationDataUseCase, logger = mockTokenizationLogger, publicKey = "test_key", - cvvTokenizationNetworkDataMapper = CVVTokenizationNetworkDataMapper() + cvvTokenizationNetworkDataMapper = CVVTokenizationNetworkDataMapper(), ) } @@ -85,7 +85,7 @@ internal class TokenRepositoryImplTest { fun `when sendCardTokenRequest invoked with success response then success handler invoked`() { testCardTokenResultInvocation( true, - NetworkApiResponse.Success(TokenizationRequestTestData.tokenDetailsResponse()) + NetworkApiResponse.Success(TokenizationRequestTestData.tokenDetailsResponse()), ) } @@ -93,7 +93,7 @@ internal class TokenRepositoryImplTest { fun `when sendCardTokenRequest invoked with network error response then failure handler invoked`() { testCardTokenResultInvocation( false, - NetworkApiResponse.NetworkError(NullPointerException()) + NetworkApiResponse.NetworkError(NullPointerException()), ) } @@ -101,7 +101,7 @@ internal class TokenRepositoryImplTest { fun `when sendCardTokenRequest invoked with server error response then failure handler invoked`() { testCardTokenResultInvocation( false, - NetworkApiResponse.ServerError(null, 123) + NetworkApiResponse.ServerError(null, 123), ) } @@ -113,9 +113,9 @@ internal class TokenRepositoryImplTest { TokenizationError( "dummy code", "exception.message", - null - ) - ) + null, + ), + ), ) } @@ -147,8 +147,8 @@ internal class TokenRepositoryImplTest { CardTokenRequest( TokenizationRequestTestData.card, onSuccess = { }, - onFailure = { } - ) + onFailure = { }, + ), ) // Then @@ -156,100 +156,103 @@ internal class TokenRepositoryImplTest { verify(exactly = 1) { mockTokenizationLogger.logTokenRequestEvent( TokenizationConstants.CARD, - "test_key" + "test_key", ) } } } } - private fun testCardTokenResultInvocation( - successHandlerInvoked: Boolean, - response: NetworkApiResponse - ) = - runTest { - // Given - var isSuccess = false + private fun testCardTokenResultInvocation( + successHandlerInvoked: Boolean, + response: NetworkApiResponse, + ) = + runTest { + // Given + var isSuccess = false - val testDispatcher = UnconfinedTestDispatcher(testScheduler) - Dispatchers.setMain(testDispatcher) + val testDispatcher = UnconfinedTestDispatcher(testScheduler) + Dispatchers.setMain(testDispatcher) - tokenRepositoryImpl.networkCoroutineScope = CoroutineScope(StandardTestDispatcher(testScheduler)) + tokenRepositoryImpl.networkCoroutineScope = CoroutineScope(StandardTestDispatcher(testScheduler)) - coEvery { mockValidateTokenizationDataUseCase.execute(any()) } returns ValidationResult.Success(Unit) + coEvery { mockValidateTokenizationDataUseCase.execute(any()) } returns ValidationResult.Success(Unit) - coEvery { mockTokenNetworkApiClient.sendCardTokenRequest(any()) } returns response + coEvery { mockTokenNetworkApiClient.sendCardTokenRequest(any()) } returns response - // When - tokenRepositoryImpl.sendCardTokenRequest( - CardTokenRequest( - TokenizationRequestTestData.card, - onSuccess = { isSuccess = true }, - onFailure = { isSuccess = false } - ) - ) + // When + tokenRepositoryImpl.sendCardTokenRequest( + CardTokenRequest( + TokenizationRequestTestData.card, + onSuccess = { isSuccess = true }, + onFailure = { isSuccess = false }, + ), + ) - // Then - launch { - if (successHandlerInvoked) assertTrue(isSuccess) - else assertFalse(isSuccess) + // Then + launch { + if (successHandlerInvoked) { + assertTrue(isSuccess) + } else { + assertFalse(isSuccess) } } + } - private fun testCardTokenEventInvocation(isSuccessResponse: Boolean) = - runTest { - // Given - val successBody = mockk() - val serverErrorBody = mockk() + private fun testCardTokenEventInvocation(isSuccessResponse: Boolean) = + runTest { + // Given + val successBody = mockk() + val serverErrorBody = mockk() - val response = if (isSuccessResponse) { - NetworkApiResponse.Success(successBody) - } else { - NetworkApiResponse.ServerError(serverErrorBody, 501) - } + val response = if (isSuccessResponse) { + NetworkApiResponse.Success(successBody) + } else { + NetworkApiResponse.ServerError(serverErrorBody, 501) + } - val testDispatcher = UnconfinedTestDispatcher(testScheduler) - Dispatchers.setMain(testDispatcher) + val testDispatcher = UnconfinedTestDispatcher(testScheduler) + Dispatchers.setMain(testDispatcher) - tokenRepositoryImpl.networkCoroutineScope = CoroutineScope(StandardTestDispatcher(testScheduler)) + tokenRepositoryImpl.networkCoroutineScope = CoroutineScope(StandardTestDispatcher(testScheduler)) - every { mockValidateTokenizationDataUseCase.execute(any()) } returns ValidationResult.Success(Unit) - coEvery { mockTokenNetworkApiClient.sendCardTokenRequest(any()) } returns response + every { mockValidateTokenizationDataUseCase.execute(any()) } returns ValidationResult.Success(Unit) + coEvery { mockTokenNetworkApiClient.sendCardTokenRequest(any()) } returns response - // When - tokenRepositoryImpl.sendCardTokenRequest( - CardTokenRequest( - TokenizationRequestTestData.card, - onSuccess = { }, - onFailure = { } - ) - ) + // When + tokenRepositoryImpl.sendCardTokenRequest( + CardTokenRequest( + TokenizationRequestTestData.card, + onSuccess = { }, + onFailure = { }, + ), + ) - // Then - launch { - if (isSuccessResponse) { - verify(exactly = 1) { - mockTokenizationLogger.logTokenResponseEvent( - eq(TokenizationConstants.CARD), - eq("test_key"), - eq(successBody) - ) - } - } else { - verify(exactly = 1) { - mockTokenizationLogger.logTokenResponseEvent( - eq(TokenizationConstants.CARD), - eq("test_key"), - null, - 501, - serverErrorBody - ) - } + // Then + launch { + if (isSuccessResponse) { + verify(exactly = 1) { + mockTokenizationLogger.logTokenResponseEvent( + eq(TokenizationConstants.CARD), + eq("test_key"), + eq(successBody), + ) + } + } else { + verify(exactly = 1) { + mockTokenizationLogger.logTokenResponseEvent( + eq(TokenizationConstants.CARD), + eq("test_key"), + null, + 501, + serverErrorBody, + ) } - - verify(exactly = 1) { mockTokenizationLogger.resetSession() } } - } + + verify(exactly = 1) { mockTokenizationLogger.resetSession() } + } + } @DisplayName("GooglePayToken Details invocation") @Nested @@ -258,7 +261,7 @@ internal class TokenRepositoryImplTest { fun `when sendGooglePayTokenRequest invoked with success response then success handler invoked`() { testGooglePayTokenResultInvocation( true, - NetworkApiResponse.Success(TokenizationRequestTestData.tokenDetailsResponse()) + NetworkApiResponse.Success(TokenizationRequestTestData.tokenDetailsResponse()), ) } @@ -266,7 +269,7 @@ internal class TokenRepositoryImplTest { fun `when sendGooglePayTokenRequest invoked with network error response then failure handler invoked`() { testGooglePayTokenResultInvocation( false, - NetworkApiResponse.NetworkError(Exception("Network connection lost")) + NetworkApiResponse.NetworkError(Exception("Network connection lost")), ) } @@ -274,7 +277,7 @@ internal class TokenRepositoryImplTest { fun `when sendGooglePayTokenRequest invoked with server error response then failure handler invoked`() { testGooglePayTokenResultInvocation( false, - NetworkApiResponse.ServerError(null, 123) + NetworkApiResponse.ServerError(null, 123), ) } @@ -286,9 +289,9 @@ internal class TokenRepositoryImplTest { TokenizationError( TokenizationError.GOOGLE_PAY_REQUEST_PARSING_ERROR, "exception.message", - null - ) - ) + null, + ), + ), ) } @@ -299,9 +302,9 @@ internal class TokenRepositoryImplTest { TokenizationError( TokenizationError.GOOGLE_PAY_REQUEST_PARSING_ERROR, "JSONObject[\"protocolVersion\"] not found.", - null - ) - ) + null, + ), + ), ) } @@ -323,7 +326,7 @@ internal class TokenRepositoryImplTest { TokenizationError( TokenizationError.GOOGLE_PAY_REQUEST_PARSING_ERROR, "testMessage", - java.lang.NullPointerException() + java.lang.NullPointerException(), ) val captureError = mutableListOf() @@ -341,8 +344,8 @@ internal class TokenRepositoryImplTest { GooglePayTokenRequest( "{protocolVersion: ECv1,signature: “test”,signedMessage: testSignedMessage}", onSuccess = { }, - onFailure = { } - ) + onFailure = { }, + ), ) // Then @@ -351,20 +354,20 @@ internal class TokenRepositoryImplTest { mockTokenizationLogger.logErrorOnTokenRequestedEvent( any(), any(), - captureNullable(captureError) + captureNullable(captureError), ) } assertEquals( expectedInternalErrorBody.errorCode, - (captureError.firstOrNull() as? TokenizationError)?.errorCode + (captureError.firstOrNull() as? TokenizationError)?.errorCode, ) assertEquals( expectedInternalErrorBody.message, - (captureError.firstOrNull() as? TokenizationError)?.message + (captureError.firstOrNull() as? TokenizationError)?.message, ) assertEquals( expectedInternalErrorBody.cause, - (captureError.firstOrNull() as? TokenizationError)?.cause + (captureError.firstOrNull() as? TokenizationError)?.cause, ) } } @@ -387,8 +390,8 @@ internal class TokenRepositoryImplTest { GooglePayTokenRequest( "{protocolVersion: ECv1,signature: “test”,signedMessage: testSignedMessage}", onSuccess = { }, - onFailure = { } - ) + onFailure = { }, + ), ) // Then @@ -401,7 +404,7 @@ internal class TokenRepositoryImplTest { private fun testGooglePayTokenResultInvocation( successHandlerInvoked: Boolean, - response: NetworkApiResponse + response: NetworkApiResponse, ) = runTest { // Given @@ -419,8 +422,8 @@ internal class TokenRepositoryImplTest { GooglePayTokenRequest( "{protocolVersion: ECv1,signature: “test”,signedMessage: testSignedMessage}", onSuccess = { isSuccess = true }, - onFailure = { isSuccess = false } - ) + onFailure = { isSuccess = false }, + ), ) // Then @@ -430,7 +433,7 @@ internal class TokenRepositoryImplTest { } private fun testGooglePayErrorHandlerInvocation( - response: NetworkApiResponse + response: NetworkApiResponse, ) = runTest { // Given var isSuccess: Boolean? = null @@ -452,8 +455,8 @@ internal class TokenRepositoryImplTest { onFailure = { isSuccess = false errorMessage = it - } - ) + }, + ), ) // Then @@ -487,8 +490,8 @@ internal class TokenRepositoryImplTest { GooglePayTokenRequest( "{protocolVersion: ECv1,signature: “test”,signedMessage: testSignedMessage}", onSuccess = { }, - onFailure = { } - ) + onFailure = { }, + ), ) // Then @@ -498,7 +501,7 @@ internal class TokenRepositoryImplTest { mockTokenizationLogger.logTokenResponseEvent( eq(TokenizationConstants.GOOGLE_PAY), eq("test_key"), - eq(successBody) + eq(successBody), ) } } else { @@ -508,7 +511,7 @@ internal class TokenRepositoryImplTest { eq("test_key"), null, 501, - serverErrorBody + serverErrorBody, ) } } @@ -528,9 +531,9 @@ internal class TokenRepositoryImplTest { body = CVVTokenDetailsResponse( type = "cvv", token = "test_token", - expiresOn = "2019-08-24T14:15:22Z" - ) - ) + expiresOn = "2019-08-24T14:15:22Z", + ), + ), ) } @@ -538,7 +541,7 @@ internal class TokenRepositoryImplTest { fun `when sendCVVTokenizationRequest invoked with network error response then failure handler invoked`() { testCVVTokenResultInvocation( successHandlerInvoked = false, - response = NetworkApiResponse.NetworkError(Exception("Network connection lost")) + response = NetworkApiResponse.NetworkError(Exception("Network connection lost")), ) } @@ -546,7 +549,7 @@ internal class TokenRepositoryImplTest { fun `when sendCVVTokenizationRequest invoked with server error response then failure handler invoked`() { testCVVTokenResultInvocation( successHandlerInvoked = false, - response = NetworkApiResponse.ServerError(body = null, code = 123) + response = NetworkApiResponse.ServerError(body = null, code = 123), ) } @@ -558,15 +561,15 @@ internal class TokenRepositoryImplTest { TokenizationError( errorCode = "internal_error", message = "exception.message", - cause = null - ) - ) + cause = null, + ), + ), ) } private fun testCVVTokenResultInvocation( successHandlerInvoked: Boolean, - response: NetworkApiResponse + response: NetworkApiResponse, ) = runTest { // Given @@ -587,12 +590,12 @@ internal class TokenRepositoryImplTest { cvv = "123", cardScheme = CardScheme.VISA, resultHandler = { result -> - isSuccess = when (result) { - is CVVTokenizationResultHandler.Success -> true - is CVVTokenizationResultHandler.Failure -> false - } - } - ) + isSuccess = when (result) { + is CVVTokenizationResultHandler.Success -> true + is CVVTokenizationResultHandler.Failure -> false + } + }, + ), ) // Then diff --git a/checkout/src/test/java/com/checkout/validation/validator/AddressValidatorTest.kt b/checkout/src/test/java/com/checkout/validation/validator/AddressValidatorTest.kt index 7fc06a8fa..e1086734a 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/AddressValidatorTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/AddressValidatorTest.kt @@ -1,8 +1,8 @@ package com.checkout.validation.validator import android.annotation.SuppressLint -import com.checkout.tokenization.model.Address import com.checkout.base.model.Country +import com.checkout.tokenization.model.Address import com.checkout.validation.error.ValidationError import com.checkout.validation.model.AddressValidationRequest import com.checkout.validation.model.ValidationResult @@ -36,7 +36,7 @@ internal class AddressValidatorTest { testState: String, testZip: String, testCountry: Country, - expectedResult: ValidationResult
+ expectedResult: ValidationResult
, ) { // Given val addressValidationRequest = AddressValidationRequest( @@ -45,7 +45,7 @@ internal class AddressValidatorTest { testCity, testState, testZip, - testCountry + testCountry, ) // When @@ -59,7 +59,7 @@ internal class AddressValidatorTest { } is ValidationResult.Failure -> Assertions.assertEquals( expectedResult.error.errorCode, - (result as? ValidationResult.Failure)?.error?.errorCode + (result as? ValidationResult.Failure)?.error?.errorCode, ) } } @@ -69,26 +69,26 @@ internal class AddressValidatorTest { fun invalidAddressArguments(): Stream = Stream.of( Arguments.of( "26 Eaton Road,Northampton,England, Lucas Green Nurseries, Lucas Green, West End, " + - "Flat 2, 21 Harbour Road, Rushed\",NN10 0FS, 11 Headland Close, Portland,Flat 15," + - " Milled Lodge, 275 Wake Green Road, Birmingham", + "Flat 2, 21 Harbour Road, Rushed\",NN10 0FS, 11 Headland Close, Portland,Flat 15," + + " Milled Lodge, 275 Wake Green Road, Birmingham", "Lucas Green Nurseries, Lucas Green", "City of London", "England", "SE1P", Country.from("GB"), - provideFailure(ValidationError.ADDRESS_LINE1_INCORRECT_LENGTH) + provideFailure(ValidationError.ADDRESS_LINE1_INCORRECT_LENGTH), ), Arguments.of( "26 Eaton Road", "26 Eaton Road,Northampton,England, Lucas Green Nurseries," + - " Lucas Green, West End, Flat 2, 21 Harbour Road, Rushed\",NN10 0FS, " + - "11 Headland Close, Portland,Flat 15, Milled Lodge, 275 Wake Green Road, Birmingham", + " Lucas Green, West End, Flat 2, 21 Harbour Road, Rushed\",NN10 0FS, " + + "11 Headland Close, Portland,Flat 15, Milled Lodge, 275 Wake Green Road, Birmingham", "City of London", "England", "SE1P", Country.from("GB"), - provideFailure(ValidationError.ADDRESS_LINE2_INCORRECT_LENGTH) + provideFailure(ValidationError.ADDRESS_LINE2_INCORRECT_LENGTH), ), Arguments.of( @@ -98,7 +98,7 @@ internal class AddressValidatorTest { "England", "SE1P", Country.from("GB"), - provideFailure(ValidationError.INVALID_CITY_LENGTH) + provideFailure(ValidationError.INVALID_CITY_LENGTH), ), Arguments.of( @@ -108,7 +108,7 @@ internal class AddressValidatorTest { "Northern Ireland,Scotland, England and dummy state entries", "SE1P", Country.from("GB"), - provideFailure(ValidationError.INVALID_STATE_LENGTH) + provideFailure(ValidationError.INVALID_STATE_LENGTH), ), Arguments.of( @@ -118,8 +118,8 @@ internal class AddressValidatorTest { "Northern Ireland", "SW1W 0NY, EC1–EC4, NW1W, SE1P, SW1 fake entries zip code", Country.from("GB"), - provideFailure(ValidationError.INVALID_ZIP_LENGTH) - ) + provideFailure(ValidationError.INVALID_ZIP_LENGTH), + ), ) @JvmStatic @@ -138,10 +138,10 @@ internal class AddressValidatorTest { "Cordon", "England", "CR7 6DU", - Country.from("GB") - ) - ) - ) + Country.from("GB"), + ), + ), + ), ) private fun provideFailure(errorCode: String) = ValidationResult.Failure(ValidationError(errorCode)) diff --git a/checkout/src/test/java/com/checkout/validation/validator/CVVComponentDetailsValidatorTest.kt b/checkout/src/test/java/com/checkout/validation/validator/CVVComponentDetailsValidatorTest.kt index 87012babb..6b0c72b78 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/CVVComponentDetailsValidatorTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/CVVComponentDetailsValidatorTest.kt @@ -51,7 +51,7 @@ internal class CVVComponentDetailsValidatorTest { val expectedResult = ValidationResult.Failure(CheckoutError(CVV_INVALID_LENGTH)) every { mockCvvValidator.validate( - CvvValidationRequest(mockCvv, mockCardScheme) + CvvValidationRequest(mockCvv, mockCardScheme), ) } returns ValidationResult.Failure(CheckoutError(CVV_INVALID_LENGTH)) diff --git a/checkout/src/test/java/com/checkout/validation/validator/CardDetailsValidatorTest.kt b/checkout/src/test/java/com/checkout/validation/validator/CardDetailsValidatorTest.kt index a076b094b..f69c20c30 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/CardDetailsValidatorTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/CardDetailsValidatorTest.kt @@ -1,9 +1,9 @@ package com.checkout.validation.validator -import com.checkout.tokenization.model.ExpiryDate import com.checkout.base.model.CardScheme import com.checkout.logging.Logger import com.checkout.logging.model.LoggingEvent +import com.checkout.tokenization.model.ExpiryDate import com.checkout.validation.api.CardValidator import com.checkout.validation.logging.ValidationEventType import com.checkout.validation.model.CardNumberValidationRequest @@ -44,7 +44,7 @@ internal class CardDetailsValidatorTest { mockExpiryDateValidator, mockCvvValidator, mockCardNumberValidator, - mockLogger + mockLogger, ) every { mockLogger.logOnce(capture(capturedEvent)) } returns Unit } diff --git a/checkout/src/test/java/com/checkout/validation/validator/CardNumberValidatorTest.kt b/checkout/src/test/java/com/checkout/validation/validator/CardNumberValidatorTest.kt index c102df107..947143fb0 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/CardNumberValidatorTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/CardNumberValidatorTest.kt @@ -79,18 +79,18 @@ internal class CardNumberValidatorTest { } @ParameterizedTest( - name = "Expected validation result {2} received " + "when card number {0} validation (isEager = {1}) requested" + name = "Expected validation result {2} received " + "when card number {0} validation (isEager = {1}) requested", ) @MethodSource( "validationSuccessArguments", "validationFailureArguments", "eagerValidationSuccessArguments", - "eagerValidationFailureArguments" + "eagerValidationFailureArguments", ) fun `Validation of given card number returns correct validation result`( cardNumber: String, isEager: Boolean, - expectedResult: ValidationResult + expectedResult: ValidationResult, ) { // Given val request = CardNumberValidationRequest(cardNumber, isEager) @@ -106,7 +106,7 @@ internal class CardNumberValidatorTest { } is ValidationResult.Failure -> assertEquals( expectedResult.error.errorCode, - (result as? ValidationResult.Failure)?.error?.errorCode + (result as? ValidationResult.Failure)?.error?.errorCode, ) } } @@ -158,7 +158,7 @@ internal class CardNumberValidatorTest { // With whitespaces Arguments.of("37828 22463 10005", false, provideSuccess(CardScheme.AMERICAN_EXPRESS)), Arguments.of("37828\n22463\n10005", false, provideSuccess(CardScheme.AMERICAN_EXPRESS)), - Arguments.of("\t37828\t22463\t10005", false, provideSuccess(CardScheme.AMERICAN_EXPRESS)) + Arguments.of("\t37828\t22463\t10005", false, provideSuccess(CardScheme.AMERICAN_EXPRESS)), ) @JvmStatic @@ -170,7 +170,7 @@ internal class CardNumberValidatorTest { Arguments.of("529741qwe2542005689", false, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)), Arguments.of("6016607_ 0950586", false, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)), Arguments.of("223488 888888-8882", false, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)), - Arguments.of("2720333333333.", false, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)) + Arguments.of("2720333333333.", false, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)), ) @JvmStatic @@ -213,7 +213,7 @@ internal class CardNumberValidatorTest { // With whitespaces Arguments.of("37828 22", true, provideSuccess(CardScheme.AMERICAN_EXPRESS)), Arguments.of("37828\n22463\n10", true, provideSuccess(CardScheme.AMERICAN_EXPRESS)), - Arguments.of("\t37828\t2246", true, provideSuccess(CardScheme.AMERICAN_EXPRESS)) + Arguments.of("\t37828\t2246", true, provideSuccess(CardScheme.AMERICAN_EXPRESS)), ) @JvmStatic @@ -225,7 +225,7 @@ internal class CardNumberValidatorTest { Arguments.of("529741qwe2542005689", true, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)), Arguments.of("6016607_ 0950586", true, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)), Arguments.of("223488 888888-8882", true, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)), - Arguments.of("272333333.", true, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)) + Arguments.of("272333333.", true, provideFailure(ValidationError.CARD_NUMBER_INVALID_CHARACTERS)), ) private fun provideFailure(errorCode: String) = ValidationResult.Failure(ValidationError(errorCode)) diff --git a/checkout/src/test/java/com/checkout/validation/validator/CvvValidatorTest.kt b/checkout/src/test/java/com/checkout/validation/validator/CvvValidatorTest.kt index 7d8a1fdb1..ee1e93e36 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/CvvValidatorTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/CvvValidatorTest.kt @@ -6,14 +6,12 @@ import com.checkout.validation.error.ValidationError import com.checkout.validation.model.CvvValidationRequest import com.checkout.validation.model.ValidationResult import com.checkout.validation.validator.contract.Validator -import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertEquals - +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource - import java.util.stream.Stream @SuppressLint("NewApi") @@ -30,12 +28,12 @@ internal class CvvValidatorTest { @MethodSource( "invalidCvvArguments", "validCvvArguments", - "invalidCardSchemeArguments" + "invalidCardSchemeArguments", ) fun `Validation of given cvv and card scheme returns correct validation result`( cvv: String, cardScheme: CardScheme, - expectedResult: ValidationResult + expectedResult: ValidationResult, ) { // When val result = cvvValidator.validate(CvvValidationRequest(cvv, cardScheme)) @@ -45,7 +43,7 @@ internal class CvvValidatorTest { is ValidationResult.Success -> assertTrue(result is ValidationResult.Success) is ValidationResult.Failure -> assertEquals( expectedResult.error.errorCode, - (result as ValidationResult.Failure).error.errorCode + (result as ValidationResult.Failure).error.errorCode, ) } } @@ -98,7 +96,7 @@ internal class CvvValidatorTest { Arguments.of("1234", CardScheme.MASTERCARD, provideFailure(ValidationError.CVV_INVALID_LENGTH)), Arguments.of("12", CardScheme.MASTERCARD, provideFailure(ValidationError.CVV_INCOMPLETE_LENGTH)), Arguments.of("12 ", CardScheme.MASTERCARD, provideFailure(ValidationError.CVV_CONTAINS_NON_DIGITS)), - Arguments.of("12q", CardScheme.MASTERCARD, provideFailure(ValidationError.CVV_CONTAINS_NON_DIGITS)) + Arguments.of("12q", CardScheme.MASTERCARD, provideFailure(ValidationError.CVV_CONTAINS_NON_DIGITS)), ) @@ -115,7 +113,7 @@ internal class CvvValidatorTest { Arguments.of("567", CardScheme.VISA, provideSuccess()), Arguments.of("", CardScheme.UNKNOWN, provideSuccess()), Arguments.of("123", CardScheme.UNKNOWN, provideSuccess()), - Arguments.of("1234", CardScheme.UNKNOWN, provideSuccess()) + Arguments.of("1234", CardScheme.UNKNOWN, provideSuccess()), ) @JvmStatic diff --git a/checkout/src/test/java/com/checkout/validation/validator/ExpiryDateValidatorTest.kt b/checkout/src/test/java/com/checkout/validation/validator/ExpiryDateValidatorTest.kt index 22ead6cac..266b22d1a 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/ExpiryDateValidatorTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/ExpiryDateValidatorTest.kt @@ -1,15 +1,14 @@ package com.checkout.validation.validator import android.annotation.SuppressLint -import com.checkout.validation.error.ValidationError import com.checkout.tokenization.model.ExpiryDate +import com.checkout.validation.error.ValidationError import com.checkout.validation.model.ExpiryDateValidationRequest import com.checkout.validation.model.ValidationResult import com.checkout.validation.validator.contract.Validator import org.amshove.kluent.`should be equal to` import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.fail - import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest @@ -74,12 +73,12 @@ internal class ExpiryDateValidatorTest { @MethodSource( "invalidMonthStringArguments", "invalidYearStringArguments", - "invalidExpiryDateArguments" + "invalidExpiryDateArguments", ) fun `given month or year is not valid returns failure`( testMonth: String, testYear: String, - expectedErrorCode: String + expectedErrorCode: String, ) { // When val expiryDateValidationResult = expiryDateValidator.validate(ExpiryDateValidationRequest(testMonth, testYear)) diff --git a/checkout/src/test/java/com/checkout/validation/validator/LuhnCheckerTest.kt b/checkout/src/test/java/com/checkout/validation/validator/LuhnCheckerTest.kt index 67f541b12..2e1bb1ea8 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/LuhnCheckerTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/LuhnCheckerTest.kt @@ -23,7 +23,7 @@ internal class LuhnCheckerTest { @MethodSource("testArguments") fun `given month or year is not valid returns failure`( cardNumber: String, - expectedResult: Boolean + expectedResult: Boolean, ) { // When val result = luhnChecker.check(cardNumber) @@ -77,7 +77,7 @@ internal class LuhnCheckerTest { Arguments.of("371673901387168", false), Arguments.of("6501111111111117", false), Arguments.of("4000056655665", false), - Arguments.of("a492993918735559", false) + Arguments.of("a492993918735559", false), ) } } diff --git a/checkout/src/test/java/com/checkout/validation/validator/PhoneValidatorTest.kt b/checkout/src/test/java/com/checkout/validation/validator/PhoneValidatorTest.kt index d74a03ba0..a722d84fd 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/PhoneValidatorTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/PhoneValidatorTest.kt @@ -32,12 +32,12 @@ internal class PhoneValidatorTest { fun `Validation of given phone returns correct validation result`( testNumber: String, testCountry: Country?, - expectedResult: ValidationResult + expectedResult: ValidationResult, ) { // Given val phoneValidationRequest = PhoneValidationRequest( testNumber, - testCountry + testCountry, ) // When @@ -51,7 +51,7 @@ internal class PhoneValidatorTest { } is ValidationResult.Failure -> Assertions.assertEquals( expectedResult.error.errorCode, - (result as? ValidationResult.Failure)?.error?.errorCode + (result as? ValidationResult.Failure)?.error?.errorCode, ) } } @@ -62,13 +62,13 @@ internal class PhoneValidatorTest { Arguments.of( "74049", Country.from("GB"), - provideFailure(ValidationError.NUMBER_INCORRECT_LENGTH) + provideFailure(ValidationError.NUMBER_INCORRECT_LENGTH), ), Arguments.of( "+44 7404953067462348736428472364", Country.from("GB"), - provideFailure(ValidationError.NUMBER_INCORRECT_LENGTH) - ) + provideFailure(ValidationError.NUMBER_INCORRECT_LENGTH), + ), ) @JvmStatic @@ -76,13 +76,13 @@ internal class PhoneValidatorTest { Arguments.of( "+44 7404953067", Country.from("GB"), - provideSuccess(Phone("+44 7404953067", Country.from("GB"))) + provideSuccess(Phone("+44 7404953067", Country.from("GB"))), ), Arguments.of( "7404953067", Country.from(""), - provideSuccess(Phone("7404953067", Country.from(""))) - ) + provideSuccess(Phone("7404953067", Country.from(""))), + ), ) private fun provideFailure(errorCode: String) = ValidationResult.Failure(ValidationError(errorCode)) diff --git a/checkout/src/test/java/com/checkout/validation/validator/usecase/ValidateCVVTokenizationDataUseCaseTest.kt b/checkout/src/test/java/com/checkout/validation/validator/usecase/ValidateCVVTokenizationDataUseCaseTest.kt index 16fc4bcd6..eba648550 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/usecase/ValidateCVVTokenizationDataUseCaseTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/usecase/ValidateCVVTokenizationDataUseCaseTest.kt @@ -25,7 +25,7 @@ internal class ValidateCVVTokenizationDataUseCaseTest { lateinit var mockCVVComponentValidator: CVVComponentValidator private lateinit var validateCVVTokenizationDataUseCase: - UseCase> + UseCase> @BeforeEach fun setUp() { @@ -42,8 +42,9 @@ internal class ValidateCVVTokenizationDataUseCaseTest { val cardScheme = CardScheme.VISA val expectedResult = ValidationResult.Failure( CheckoutError( - errorCode = ValidationError.CVV_INVALID_LENGTH, message = "Please enter a valid security code" - ) + errorCode = ValidationError.CVV_INVALID_LENGTH, + message = "Please enter a valid security code", + ), ) every { mockRequest.cvv } returns cvv @@ -51,12 +52,12 @@ internal class ValidateCVVTokenizationDataUseCaseTest { every { mockCVVComponentValidator.validate( - eq(cvv), eq(cardScheme) + eq(cvv), eq(cardScheme), ) } returns ValidationResult.Failure( CheckoutError( - errorCode = ValidationError.CVV_INVALID_LENGTH, message = "Please enter a valid security code" - ) + errorCode = ValidationError.CVV_INVALID_LENGTH, message = "Please enter a valid security code", + ), ) // When @@ -82,7 +83,7 @@ internal class ValidateCVVTokenizationDataUseCaseTest { every { mockCVVComponentValidator.validate( - eq(cvv), eq(cardScheme) + eq(cvv), eq(cardScheme), ) } returns ValidationResult.Success(Unit) diff --git a/checkout/src/test/java/com/checkout/validation/validator/usecase/ValidateTokenizationDataUseCaseTest.kt b/checkout/src/test/java/com/checkout/validation/validator/usecase/ValidateTokenizationDataUseCaseTest.kt index 84a3dc056..292f53d27 100644 --- a/checkout/src/test/java/com/checkout/validation/validator/usecase/ValidateTokenizationDataUseCaseTest.kt +++ b/checkout/src/test/java/com/checkout/validation/validator/usecase/ValidateTokenizationDataUseCaseTest.kt @@ -50,7 +50,7 @@ internal class ValidateTokenizationDataUseCaseTest { mockCardValidator, mockAddressValidator, mockPhoneValidator, - addressToAddressValidationRequestDataMapper + addressToAddressValidationRequestDataMapper, ) every { mockCardValidator.validateCardNumber(any()) } returns ValidationResult.Success(CardScheme.VISA) @@ -59,14 +59,14 @@ internal class ValidateTokenizationDataUseCaseTest { every { mockCardValidator.validateExpiryDate( any(), - any() + any(), ) } returns ValidationResult.Success(ExpiryDate(20, 25)) every { mockCardValidator.validateExpiryDate( any(), - any() + any(), ) } returns ValidationResult.Success(ExpiryDate(20, 25)) @@ -75,7 +75,7 @@ internal class ValidateTokenizationDataUseCaseTest { } returns TokenizationRequestTestData.addressValidationRequest every { mockAddressValidator.validate(any()) } returns - ValidationResult.Success(TokenizationRequestTestData.address) + ValidationResult.Success(TokenizationRequestTestData.address) every { mockPhoneValidator.validate(any()) } returns ValidationResult.Success(TokenizationRequestTestData.phone) } @@ -95,7 +95,7 @@ internal class ValidateTokenizationDataUseCaseTest { verify { mockCardValidator.validateExpiryDate( eq(mockRequest.expiryDate.expiryMonth), - eq(mockRequest.expiryDate.expiryYear) + eq(mockRequest.expiryDate.expiryYear), ) } mockRequest.billingAddress?.let { verify { mockAddressValidator.validate(capture(captureAddress)) } } @@ -138,7 +138,7 @@ internal class ValidateTokenizationDataUseCaseTest { every { mockRequest.number } returns mockNumber every { mockCardValidator.validateCardNumber(eq(mockNumber)) } returns - ValidationResult.Failure(CheckoutError("123")) + ValidationResult.Failure(CheckoutError("123")) // When val result = validateTokenizationDataUseCase.execute(mockRequest) @@ -163,7 +163,7 @@ internal class ValidateTokenizationDataUseCaseTest { every { mockCardValidator.validateExpiryDate( eq(expiryMonth), - eq(expiryYear) + eq(expiryYear), ) } returns ValidationResult.Failure(CheckoutError("123")) @@ -190,7 +190,7 @@ internal class ValidateTokenizationDataUseCaseTest { every { mockCardValidator.validateCvv( eq(cvv), - eq(cardScheme) + eq(cardScheme), ) } returns ValidationResult.Failure(CheckoutError("123")) diff --git a/example_app_frames/build.gradle.kts b/example_app_frames/build.gradle.kts index 1fbe6768e..3ecdf1b12 100644 --- a/example_app_frames/build.gradle.kts +++ b/example_app_frames/build.gradle.kts @@ -12,8 +12,10 @@ android { buildTypes { release { isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro") + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro", + ) } } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomBillingFormStyle.kt b/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomBillingFormStyle.kt index c36377812..89e12da73 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomBillingFormStyle.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomBillingFormStyle.kt @@ -41,7 +41,7 @@ object CustomBillingFormStyle { fun provideBillingFormStyle() = BillingFormStyle( billingAddressDetailsStyle = provideBillingAddressDetailsStyle(), - countryPickerStyle = provideCountryPickerStyle() + countryPickerStyle = provideCountryPickerStyle(), ) private fun provideCountryPickerStyle(): CountryPickerStyle { @@ -50,10 +50,10 @@ object CustomBillingFormStyle { style = style.copy( screenTitleStyle = style.screenTitleStyle.copy( textStyle = style.screenTitleStyle.textStyle.copy(color = textColor), - leadingIconStyle = style.screenTitleStyle.leadingIconStyle?.copy(tinColor = textColor) + leadingIconStyle = style.screenTitleStyle.leadingIconStyle?.copy(tinColor = textColor), ), containerStyle = style.containerStyle.copy( - color = backgroundColor + color = backgroundColor, ), searchFieldStyle = with(style.searchFieldStyle) { copy( @@ -61,24 +61,24 @@ object CustomBillingFormStyle { margin = Margin( start = CountryPickerScreenConstants.margin, end = CountryPickerScreenConstants.margin, - bottom = CountryPickerScreenConstants.margin - ) + bottom = CountryPickerScreenConstants.margin, + ), ), indicatorStyle = provideIndicatorStyle(), placeholderStyle = placeholderStyle.copy(color = PaymentFormConstants.placeHolderTextColor), leadingIconStyle = leadingIconStyle?.copy( - tinColor = textColor + tinColor = textColor, ), trailingIconStyle = trailingIconStyle?.copy( - tinColor = textColor - ) + tinColor = textColor, + ), ) }, searchItemStyle = style.searchItemStyle.copy( textStyle = style.searchItemStyle.textStyle.copy( - color = textColor - ) - ) + color = textColor, + ), + ), ) return style } @@ -87,7 +87,7 @@ object CustomBillingFormStyle { headerComponentStyle = provideHeaderComponentStyle(), inputComponentsContainerStyle = InputComponentsContainerStyle(fetchInputComponentStyleValues()), countryComponentStyle = provideCountryComponentStyle(), - containerStyle = ContainerStyle(color = backgroundColor) + containerStyle = ContainerStyle(color = backgroundColor), ) private fun provideCountryComponentStyle(): CountryComponentStyle { @@ -98,12 +98,12 @@ object CustomBillingFormStyle { inputFieldStyle = provideInputFieldStyle(inputStyle.inputFieldStyle), titleStyle = inputStyle.titleStyle?.copy( textStyle = inputStyle.titleStyle?.textStyle?.copy(color = textColor) ?: TextStyle(), - containerStyle = ContainerStyle(padding = Padding(start = cornerRadius, bottom = paddingTenDp)) - ) + containerStyle = ContainerStyle(padding = Padding(start = cornerRadius, bottom = paddingTenDp)), + ), ) style = style.copy( - inputStyle = inputStyle + inputStyle = inputStyle, ) return style @@ -114,16 +114,16 @@ object CustomBillingFormStyle { style = style.copy( headerTitleStyle = style.headerTitleStyle.copy( textStyle = style.headerTitleStyle.textStyle.copy( - color = textColor, fontWeight = FontWeight.Bold + color = textColor, fontWeight = FontWeight.Bold, ), ), headerButtonStyle = style.headerButtonStyle .copy( - contentColor = inputFieldColor, - containerColor = textColor, - shape = Shape.Circle, - cornerRadius = inputFieldCornerRadius - ) + contentColor = inputFieldColor, + containerColor = textColor, + shape = Shape.Circle, + cornerRadius = inputFieldCornerRadius, + ), ) return style @@ -141,8 +141,8 @@ object CustomBillingFormStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding - ) + bottom = LightStyleConstants.inputComponentBottomPadding, + ), ) inputComponentsStyles[BillingFormFields.AddressLineOne] = provideInputComponentStyle( @@ -152,7 +152,7 @@ object CustomBillingFormStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - ) + ), ) inputComponentsStyles[BillingFormFields.AddressLineTwo] = provideInputComponentStyle( @@ -163,8 +163,8 @@ object CustomBillingFormStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding - ) + bottom = LightStyleConstants.inputComponentBottomPadding, + ), ) inputComponentsStyles[BillingFormFields.City] = provideInputComponentStyle( @@ -173,8 +173,8 @@ object CustomBillingFormStyle { keyboardOptions = defaultKeyboardOptions, padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, - end = LightStyleConstants.inputComponentRightPadding - ) + end = LightStyleConstants.inputComponentRightPadding, + ), ) inputComponentsStyles[BillingFormFields.State] = provideInputComponentStyle( @@ -185,8 +185,8 @@ object CustomBillingFormStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding - ) + bottom = LightStyleConstants.inputComponentBottomPadding, + ), ) inputComponentsStyles[BillingFormFields.PostCode] = provideInputComponentStyle( @@ -196,8 +196,8 @@ object CustomBillingFormStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding - ) + bottom = LightStyleConstants.inputComponentBottomPadding, + ), ) inputComponentsStyles[BillingFormFields.Phone] = provideInputComponentStyle( @@ -208,8 +208,8 @@ object CustomBillingFormStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = paddingTenDp - ) + bottom = paddingTenDp, + ), ) inputComponentsStyles[BillingFormFields.Country] = DefaultLightStyle.inputComponentStyle( @@ -219,8 +219,8 @@ object CustomBillingFormStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding - ) + bottom = LightStyleConstants.inputComponentBottomPadding, + ), ) return inputComponentsStyles @@ -231,25 +231,25 @@ object CustomBillingFormStyle { @StringRes infoTextId: Int? = null, isFieldOptional: Boolean = false, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, - padding: Padding = Padding() + padding: Padding = Padding(), ): InputComponentStyle { var style = DefaultLightStyle.inputComponentStyle( placeholderResourceTextId = placeholderTextId, infoTextId = infoTextId, padding = padding, isFieldOptional = isFieldOptional, - keyboardOptions = keyboardOptions + keyboardOptions = keyboardOptions, ) style = style.copy( infoStyle = style.infoStyle?.copy( containerStyle = ContainerStyle( padding = Padding( - top = paddingSixDp, bottom = paddingSixDp, end = cornerRadius - ) - ) + top = paddingSixDp, bottom = paddingSixDp, end = cornerRadius, + ), + ), ), - inputFieldStyle = provideInputFieldStyle(style.inputFieldStyle) + inputFieldStyle = provideInputFieldStyle(style.inputFieldStyle), ) return style @@ -260,21 +260,24 @@ object CustomBillingFormStyle { containerStyle = provideContainerStyle(), indicatorStyle = provideIndicatorStyle(), placeholderStyle = inputFieldStyle.placeholderStyle.copy( - color = PaymentFormConstants.placeHolderTextColor + color = PaymentFormConstants.placeHolderTextColor, ), trailingIconStyle = inputFieldStyle.trailingIconStyle?.copy( - tinColor = textColor - ) + tinColor = textColor, + ), ) } private fun provideIndicatorStyle(): InputFieldIndicatorStyle = InputFieldIndicatorStyle.Underline( - focusedUnderlineThickness = 0, unfocusedUnderlineThickness = 0 + focusedUnderlineThickness = 0, + unfocusedUnderlineThickness = 0, ) private fun provideContainerStyle(): ContainerStyle { return ContainerStyle( - shape = inputFieldBorderShape, color = inputFieldColor, cornerRadius = inputFieldCornerRadius + shape = inputFieldBorderShape, + color = inputFieldColor, + cornerRadius = inputFieldCornerRadius, ) } } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomPaymentDetailsStyle.kt b/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomPaymentDetailsStyle.kt index c2589ecae..7d7f4393e 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomPaymentDetailsStyle.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomPaymentDetailsStyle.kt @@ -24,10 +24,10 @@ import com.checkout.frames.style.component.addresssummary.AddressSummaryComponen import com.checkout.frames.style.component.base.ContainerStyle import com.checkout.frames.style.component.base.InputFieldIndicatorStyle import com.checkout.frames.style.component.base.TextLabelStyle -import com.checkout.frames.style.component.default.DefaultButtonStyle import com.checkout.frames.style.component.default.DefaultAddressSummaryComponentStyle -import com.checkout.frames.style.component.default.DefaultLightStyle +import com.checkout.frames.style.component.default.DefaultButtonStyle import com.checkout.frames.style.component.default.DefaultImageStyle +import com.checkout.frames.style.component.default.DefaultLightStyle import com.checkout.frames.style.component.default.DefaultTextLabelStyle import com.checkout.frames.style.screen.PaymentDetailsStyle import com.checkout.frames.utils.constants.ErrorConstants @@ -49,9 +49,9 @@ object CustomPaymentDetailsStyle { color = backgroundColor, padding = Padding( start = PaymentFormConstants.padding, - end = PaymentFormConstants.padding - ) - ) + end = PaymentFormConstants.padding, + ), + ), ) private fun providePayButtonStyle(): PayButtonComponentStyle { @@ -65,7 +65,7 @@ object CustomPaymentDetailsStyle { fontWeight = FontWeight.Bold, margin = Margin(top = marginBottom), shape = Shape.Circle, - cornerRadius = inputFieldCornerRadius + cornerRadius = inputFieldCornerRadius, ) return PayButtonComponentStyle(buttonStyle = buttonStyle) } @@ -83,17 +83,17 @@ object CustomPaymentDetailsStyle { textId = R.string.cko_add_billing_address, trailingIconStyle = DefaultImageStyle.buttonTrailingImageStyle(tinColor = textColor), fontWeight = FontWeight.SemiBold, - contentColor = textColor + contentColor = textColor, ), summarySectionStyle = style.summarySectionStyle.copy( editAddressButtonStyle = DefaultButtonStyle.lightSolid( textId = R.string.cko_edit_billing_address, trailingIconStyle = DefaultImageStyle.buttonTrailingImageStyle(tinColor = textColor), fontWeight = FontWeight.SemiBold, - contentColor = textColor + contentColor = textColor, ), - containerStyle = containerStyle - ) + containerStyle = containerStyle, + ), ) return style } @@ -110,17 +110,17 @@ object CustomPaymentDetailsStyle { containerStyle = provideContainerStyle(inputFieldCornerRadius.copy(bottomStart = 0, bottomEnd = 0)), indicatorStyle = provideIndicatorStyle(), placeholderStyle = inputStyle.inputFieldStyle.placeholderStyle.copy( - color = placeHolderTextColor - ) - ) - ) + color = placeHolderTextColor, + ), + ), + ), ) } private fun provideExpiryDateStyle(): ExpiryDateComponentStyle { val inputStyle = DefaultLightStyle.inputComponentStyle( placeholderResourceTextId = R.string.cko_expiry_date_component_title, - margin = Margin(top = 2) + margin = Margin(top = 2), ) return ExpiryDateComponentStyle( inputStyle.copy( @@ -129,17 +129,17 @@ object CustomPaymentDetailsStyle { containerStyle = provideContainerStyle(CornerRadius()), indicatorStyle = provideIndicatorStyle(), placeholderStyle = inputStyle.inputFieldStyle.placeholderStyle.copy( - color = placeHolderTextColor - ) - ) - ) + color = placeHolderTextColor, + ), + ), + ), ) } private fun provideCVVStyle(): CvvComponentStyle { val inputStyle = DefaultLightStyle.inputComponentStyle( placeholderResourceTextId = R.string.cko_cvv_component_title, - margin = Margin(top = 2, bottom = margin) + margin = Margin(top = 2, bottom = margin), ) return CvvComponentStyle( inputStyle.copy( @@ -148,10 +148,10 @@ object CustomPaymentDetailsStyle { containerStyle = provideContainerStyle(inputFieldCornerRadius.copy(topStart = 0, topEnd = 0)), indicatorStyle = provideIndicatorStyle(), placeholderStyle = inputStyle.inputFieldStyle.placeholderStyle.copy( - color = placeHolderTextColor - ) - ) - ) + color = placeHolderTextColor, + ), + ), + ), ) } @@ -159,20 +159,20 @@ object CustomPaymentDetailsStyle { DefaultTextLabelStyle.error( padding = Padding( top = ErrorConstants.errorMessageTopPadding, - bottom = ErrorConstants.errorMessageTopPadding - ) + bottom = ErrorConstants.errorMessageTopPadding, + ), ) private fun provideIndicatorStyle(): InputFieldIndicatorStyle = InputFieldIndicatorStyle.Underline( focusedUnderlineThickness = 0, - unfocusedUnderlineThickness = 0 + unfocusedUnderlineThickness = 0, ) private fun provideContainerStyle(cornerRadius: CornerRadius): ContainerStyle { return ContainerStyle( shape = inputFieldBorderShape, color = inputFieldColor, - cornerRadius = cornerRadius + cornerRadius = cornerRadius, ) } @@ -181,11 +181,11 @@ object CustomPaymentDetailsStyle { containerStyle = ContainerStyle( margin = Margin( top = marginTop, - bottom = marginBottom - ) + bottom = marginBottom, + ), ), titleStyle = DefaultTextLabelStyle.subtitle(textId = R.string.accepted_card_schemes, color = textColor), - imageStyle = null + imageStyle = null, ) private fun provideHeaderStyle() = DefaultLightStyle.screenHeader( @@ -193,8 +193,8 @@ object CustomPaymentDetailsStyle { imageId = R.drawable.ic_back_arrow, leadingIconSize = backIconSize, textColor = textColor, - fontWeight = FontWeight.Bold + fontWeight = FontWeight.Bold, ).copy( - containerStyle = ContainerStyle(color = backgroundColor) + containerStyle = ContainerStyle(color = backgroundColor), ) } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomPaymentFormTheme.kt b/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomPaymentFormTheme.kt index 6b0b9f6d4..96b917b5a 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomPaymentFormTheme.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/CustomPaymentFormTheme.kt @@ -3,13 +3,13 @@ package com.checkout.example.frames.paymentformstyling import com.checkout.frames.R import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.Shape -import com.checkout.frames.style.theme.PaymentFormThemeColors +import com.checkout.frames.style.theme.DefaultPaymentFormTheme import com.checkout.frames.style.theme.PaymentFormComponentBuilder import com.checkout.frames.style.theme.PaymentFormComponentField -import com.checkout.frames.style.theme.PaymentFormTheme -import com.checkout.frames.style.theme.DefaultPaymentFormTheme -import com.checkout.frames.style.theme.PaymentFormShape import com.checkout.frames.style.theme.PaymentFormCornerRadius +import com.checkout.frames.style.theme.PaymentFormShape +import com.checkout.frames.style.theme.PaymentFormTheme +import com.checkout.frames.style.theme.PaymentFormThemeColors object CustomPaymentFormTheme { private val paymentFormThemeColors = PaymentFormThemeColors( @@ -19,7 +19,7 @@ object CustomPaymentFormTheme { backgroundColor = 0xFF17201E, fieldBackgroundColor = 0XFF24302D, enabledButtonColor = 0xFFFFFFFF, - disabledButtonColor = 0XFF003300 + disabledButtonColor = 0XFF003300, ) private val cardNumber = PaymentFormComponentBuilder() @@ -90,7 +90,7 @@ object CustomPaymentFormTheme { addressLineTwo = addressLineTwo, addBillingSummaryButton = addBillingSummaryButton, editBillingSummaryButton = editBillingSummaryButton, - country = country + country = country, ), /** * option 2: Use default components @@ -98,12 +98,13 @@ object CustomPaymentFormTheme { */ paymentFormShape = PaymentFormShape( inputFieldShape = Shape.RoundCorner, - addressSummaryShape = Shape.Rectangle, buttonShape = Shape.Circle + addressSummaryShape = Shape.Rectangle, + buttonShape = Shape.Circle, ), paymentFormCornerRadius = PaymentFormCornerRadius( inputFieldCornerRadius = CornerRadius(INPUT_FIELD_CORNER_RADIUS), - addressSummaryCornerRadius = CornerRadius(INPUT_FIELD_CORNER_RADIUS) - ) + addressSummaryCornerRadius = CornerRadius(INPUT_FIELD_CORNER_RADIUS), + ), ) } } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/PaymentFormConstants.kt b/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/PaymentFormConstants.kt index 80018e22c..145f6a994 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/PaymentFormConstants.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/paymentformstyling/PaymentFormConstants.kt @@ -8,6 +8,7 @@ object PaymentFormConstants { const val inputFieldColor: Long = 0XFFFFFFFF const val textColor: Long = 0XFF461E67 const val placeHolderTextColor: Long = 0XFFACA2B4 + /** Screen padding in dp. */ const val padding: Int = 16 const val paddingTenDp: Int = 10 diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/styling/CustomCVVInputFieldStyle.kt b/example_app_frames/src/main/java/com/checkout/example/frames/styling/CustomCVVInputFieldStyle.kt index 63be1c705..2745c82d5 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/styling/CustomCVVInputFieldStyle.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/styling/CustomCVVInputFieldStyle.kt @@ -26,11 +26,12 @@ object CustomCVVInputFieldStyle { color = backgroundColor, padding = Padding(end = 2), shape = Shape.RoundCorner, - cornerRadius = CornerRadius(9) + cornerRadius = CornerRadius(9), ), cursorStyle = CursorStyle(0XFF00CC2D), indicatorStyle = InputFieldIndicatorStyle.Underline( - focusedUnderlineThickness = 0, unfocusedUnderlineThickness = 0 - ) + focusedUnderlineThickness = 0, + unfocusedUnderlineThickness = 0, + ), ) } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ButtonComponent.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ButtonComponent.kt index 3fe7d9450..e8427fa93 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ButtonComponent.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ButtonComponent.kt @@ -34,25 +34,30 @@ internal fun ButtonComponent(buttonTitleId: Int, imageResourceID: Int, modifier: shape = RoundedCornerShape(CORNER_RADIUS_PERCENT), border = BorderStroke(width = 1.dp, color = ButtonBorder), colors = ButtonDefaults.buttonColors( - containerColor = Color.Transparent, contentColor = DarkBlue + containerColor = Color.Transparent, + contentColor = DarkBlue, ), ) { Row( - horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically + horizontalArrangement = Arrangement.Center, + verticalAlignment = Alignment.CenterVertically, ) { Image( painter = painterResource(id = imageResourceID), modifier = Modifier .size(44.dp) .background( - color = LightBlue, shape = CircleShape + color = LightBlue, + shape = CircleShape, ), - contentScale = ContentScale.Inside, alignment = Alignment.Center, contentDescription = null + contentScale = ContentScale.Inside, + alignment = Alignment.Center, + contentDescription = null, ) Text( text = stringResource(id = buttonTitleId), modifier = Modifier.padding(start = 8.dp), - fontSize = 12.sp + fontSize = 12.sp, ) } } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ClickableImage.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ClickableImage.kt index 3d8af350b..f8e3e2e82 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ClickableImage.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ClickableImage.kt @@ -14,7 +14,7 @@ fun ClickableImage( painter: Painter, contentDescription: String, onClick: () -> Unit, - paddingValues: PaddingValues + paddingValues: PaddingValues, ) { Image( painter = painter, @@ -22,6 +22,6 @@ fun ClickableImage( modifier = Modifier .defaultMinSize() .padding(paddingValues) - .clickable { onClick() } + .clickable { onClick() }, ) } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/CustomButton.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/CustomButton.kt index 721fcdc83..e54c3905e 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/CustomButton.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/CustomButton.kt @@ -19,7 +19,9 @@ fun CustomButton( }, enabled = isCVVValid.value, colors = ButtonDefaults.buttonColors( - contentColor = Color.White, containerColor = Color(0xFF0B5FF0), disabledContentColor = Color.Gray + contentColor = Color.White, + containerColor = Color(0xFF0B5FF0), + disabledContentColor = Color.Gray, ), ) { Text(text = "Pay") diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/LoadCVVComponent.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/LoadCVVComponent.kt index a9a51cec1..019e9efbd 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/LoadCVVComponent.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/LoadCVVComponent.kt @@ -32,14 +32,16 @@ fun LoadCVVComponent( is CVVTokenizationResultHandler.Success -> { val tokenDetails = result.tokenDetails context.showAlertDialog( - title = context.getString(R.string.token_generated), message = tokenDetails.token + title = context.getString(R.string.token_generated), + message = tokenDetails.token, ) } is CVVTokenizationResultHandler.Failure -> { val errorMessage = result.errorMessage context.showAlertDialog( - title = context.getString(R.string.token_generated_failed), message = errorMessage + title = context.getString(R.string.token_generated_failed), + message = errorMessage, ) } } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/TextComponent.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/TextComponent.kt index 39a10e514..6f81f328b 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/TextComponent.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/TextComponent.kt @@ -18,7 +18,7 @@ internal fun TextComponent( fontSize: Int, textColor: Color, fontWeight: FontWeight, - paddingValues: PaddingValues + paddingValues: PaddingValues, ) = Text( text = stringResource(titleResourceId), fontSize = fontSize.sp, @@ -27,5 +27,5 @@ internal fun TextComponent( modifier = Modifier .padding(paddingValues) .fillMaxWidth(), - textAlign = TextAlign.Start + textAlign = TextAlign.Start, ) diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ThreedsComponent.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ThreedsComponent.kt index aaf201d62..6d3f5b0e7 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ThreedsComponent.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/component/ThreedsComponent.kt @@ -47,7 +47,7 @@ fun ThreedComponent(context: Context) { .fillMaxWidth() .padding(start = 24.dp, end = 24.dp, bottom = 14.dp), horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically + verticalAlignment = Alignment.CenterVertically, ) { var textValue by remember { mutableStateOf(TextFieldValue("")) } OutlinedTextField( @@ -58,9 +58,10 @@ fun ThreedComponent(context: Context) { shape = RoundedCornerShape(CORNER_RADIUS_PERCENT), placeholder = { Text(context.getString(R.string.enter_3ds_redirection_url)) }, colors = TextFieldDefaults.outlinedTextFieldColors( - unfocusedBorderColor = ButtonBorder, placeholderColor = GrayColor + unfocusedBorderColor = ButtonBorder, + placeholderColor = GrayColor, ), - onValueChange = { textValue = it } + onValueChange = { textValue = it }, ) Card( @@ -78,11 +79,12 @@ fun ThreedComponent(context: Context) { context.startActivity(intent) } else { context.showAlertDialog( - context.getString(R.string.empty_url), context.getString(R.string.paste_valid_link) + context.getString(R.string.empty_url), + context.getString(R.string.paste_valid_link), ) } }, - colors = CardDefaults.cardColors(containerColor = Color.Transparent, contentColor = DarkBlue) + colors = CardDefaults.cardColors(containerColor = Color.Transparent, contentColor = DarkBlue), ) { Image( painter = painterResource(id = R.mipmap.cloud), @@ -91,7 +93,7 @@ fun ThreedComponent(context: Context) { .padding(top = 12.dp, bottom = 12.dp) .align(CenterHorizontally), alignment = Alignment.Center, - contentDescription = null + contentDescription = null, ) } } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/extension/showAlertDialog.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/extension/Extensions.kt similarity index 100% rename from example_app_frames/src/main/java/com/checkout/example/frames/ui/extension/showAlertDialog.kt rename to example_app_frames/src/main/java/com/checkout/example/frames/ui/extension/Extensions.kt diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/CVVTokenizationScreen.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/CVVTokenizationScreen.kt index faf26bdaf..21c5cdbf1 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/CVVTokenizationScreen.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/CVVTokenizationScreen.kt @@ -33,23 +33,23 @@ fun CVVTokenizationScreen(navController: NavHostController) { val cvvComponentApi = CVVComponentApiFactory.create( publicKey = PUBLIC_KEY_CVV_TOKENIZATION, environment = Environment.SANDBOX, - context = LocalContext.current + context = LocalContext.current, ) val visaMediator = createMediator( cvvComponentApi = cvvComponentApi, schemeValue = "Visa", inputFieldStyle = DefaultCVVInputFieldStyle.create().copy( - containerStyle = ContainerStyle(width = 250, padding = Padding(end = 10)) + containerStyle = ContainerStyle(width = 250, padding = Padding(end = 10)), ), - enteredVisaCVVUpdated = cvvTokenizationViewModel.isEnteredVisaCVVValid + enteredVisaCVVUpdated = cvvTokenizationViewModel.isEnteredVisaCVVValid, ) val maestroMediator = createMediator( cvvComponentApi = cvvComponentApi, schemeValue = "Maestro", inputFieldStyle = CustomCVVInputFieldStyle.create(), - enteredVisaCVVUpdated = cvvTokenizationViewModel.isEnteredMaestroCVVValid + enteredVisaCVVUpdated = cvvTokenizationViewModel.isEnteredMaestroCVVValid, ) val amexMediator = createMediator( @@ -61,11 +61,11 @@ fun CVVTokenizationScreen(navController: NavHostController) { color = 0XFF24302D, shape = Shape.Rectangle, padding = Padding(end = 2), - cornerRadius = CornerRadius(9) + cornerRadius = CornerRadius(9), ), - textStyle = TextStyle(16, color = 0XFF00CC2D, font = Font.Serif) + textStyle = TextStyle(16, color = 0XFF00CC2D, font = Font.Serif), ), - enteredVisaCVVUpdated = cvvTokenizationViewModel.isEnteredAmexCVVValid + enteredVisaCVVUpdated = cvvTokenizationViewModel.isEnteredAmexCVVValid, ) val unknownMediator = createMediator( @@ -77,8 +77,8 @@ fun CVVTokenizationScreen(navController: NavHostController) { padding = Padding(end = 2), color = PaymentFormConstants.backgroundColor, shape = Shape.Circle, - cornerRadius = CornerRadius(9) - ) + cornerRadius = CornerRadius(9), + ), ), ) @@ -88,7 +88,7 @@ fun CVVTokenizationScreen(navController: NavHostController) { visaMediator = visaMediator, maestroMediator = maestroMediator, amexMediator = amexMediator, - unknownMediator = unknownMediator + unknownMediator = unknownMediator, ) } @@ -99,9 +99,11 @@ fun createMediator( enteredVisaCVVUpdated: MutableState = mutableStateOf(true), ): CVVComponentMediator { val cvvComponentConfig = CVVComponentConfig( - cardScheme = CardScheme.fromString(cardSchemeValue = schemeValue), onCVVValueChange = { isValidCVV -> + cardScheme = CardScheme.fromString(cardSchemeValue = schemeValue), + onCVVValueChange = { isValidCVV -> enteredVisaCVVUpdated.value = isValidCVV - }, cvvInputFieldStyle = inputFieldStyle + }, + cvvInputFieldStyle = inputFieldStyle, ) return cvvComponentApi.createComponentMediator(cvvComponentConfig) diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/HomeScreen.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/HomeScreen.kt index a82b9a8ec..4f38999b5 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/HomeScreen.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/HomeScreen.kt @@ -4,24 +4,24 @@ import android.content.Context import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Image import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults -import androidx.compose.material3.Surface -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment.Companion.Start @@ -36,8 +36,6 @@ import androidx.compose.ui.unit.dp import androidx.navigation.NavController import com.checkout.CheckoutApiServiceFactory import com.checkout.base.model.Environment -import com.checkout.example.frames.ui.utils.PromptUtils -import com.checkout.example.frames.ui.utils.PromptUtils.neutralButton import com.checkout.example.frames.navigation.Screen import com.checkout.example.frames.ui.component.ButtonComponent import com.checkout.example.frames.ui.component.TextComponent @@ -46,6 +44,8 @@ import com.checkout.example.frames.ui.theme.ButtonBorder import com.checkout.example.frames.ui.theme.DarkBlue import com.checkout.example.frames.ui.theme.FramesTheme import com.checkout.example.frames.ui.theme.GrayColor +import com.checkout.example.frames.ui.utils.PromptUtils +import com.checkout.example.frames.ui.utils.PromptUtils.neutralButton import com.checkout.frames.R import com.checkout.tokenization.model.GooglePayTokenRequest @@ -56,21 +56,22 @@ fun HomeScreen(navController: NavController) { FramesTheme { // A surface container using the 'background' color from the theme Surface( - modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background, ) { Column( modifier = Modifier .fillMaxSize() .verticalScroll(state = rememberScrollState()), verticalArrangement = Arrangement.Top, - horizontalAlignment = Start + horizontalAlignment = Start, ) { Icon( painter = painterResource(id = R.drawable.ic_logo), modifier = Modifier .padding(start = 6.dp, top = 16.dp) .size(60.dp), - contentDescription = null + contentDescription = null, ) TextComponent( @@ -78,7 +79,7 @@ fun HomeScreen(navController: NavController) { fontSize = 24, fontWeight = FontWeight.Bold, paddingValues = PaddingValues(start = 24.dp), - textColor = Color(0XFF7F819A) + textColor = Color(0XFF7F819A), ) TextComponent( @@ -86,7 +87,7 @@ fun HomeScreen(navController: NavController) { fontSize = 24, fontWeight = FontWeight.Bold, paddingValues = PaddingValues(start = 24.dp), - textColor = DarkBlue + textColor = DarkBlue, ) Spacer(Modifier.height(35.dp)) @@ -96,21 +97,21 @@ fun HomeScreen(navController: NavController) { fontSize = 20, fontWeight = FontWeight.SemiBold, paddingValues = PaddingValues(start = 24.dp, bottom = 14.dp), - textColor = DarkBlue + textColor = DarkBlue, ) Row( modifier = Modifier .fillMaxWidth() .padding(start = 24.dp, end = 24.dp, bottom = 14.dp), - horizontalArrangement = Arrangement.SpaceBetween + horizontalArrangement = Arrangement.SpaceBetween, ) { ButtonComponent( buttonTitleId = R.string.default_ui, imageResourceID = R.drawable.ic_ui_type, Modifier .weight(1F) - .size(width = Dp.Unspecified, height = 80.dp) + .size(width = Dp.Unspecified, height = 80.dp), ) { navController.navigate(Screen.DefaultUI.route) } @@ -120,7 +121,7 @@ fun HomeScreen(navController: NavController) { Modifier .weight(1F) .padding(start = 8.dp) - .size(width = Dp.Unspecified, height = 80.dp) + .size(width = Dp.Unspecified, height = 80.dp), ) { navController.navigate(Screen.CustomThemingUI.route) } @@ -130,14 +131,14 @@ fun HomeScreen(navController: NavController) { modifier = Modifier .fillMaxWidth() .padding(start = 24.dp, end = 24.dp, bottom = 14.dp), - horizontalArrangement = Arrangement.SpaceBetween + horizontalArrangement = Arrangement.SpaceBetween, ) { ButtonComponent( buttonTitleId = R.string.custom_ui, imageResourceID = R.drawable.ic_ui_type, Modifier .weight(1F) - .size(width = Dp.Unspecified, height = 80.dp) + .size(width = Dp.Unspecified, height = 80.dp), ) { navController.navigate(Screen.CustomUI.route) } @@ -147,7 +148,7 @@ fun HomeScreen(navController: NavController) { Modifier .weight(1F) .padding(start = 8.dp) - .size(width = Dp.Unspecified, height = 80.dp) + .size(width = Dp.Unspecified, height = 80.dp), ) { navController.navigate(Screen.CVVTokenization.route) } @@ -160,7 +161,7 @@ fun HomeScreen(navController: NavController) { fontSize = 20, fontWeight = FontWeight.SemiBold, paddingValues = PaddingValues(start = 24.dp, bottom = 14.dp), - textColor = DarkBlue + textColor = DarkBlue, ) ThreedComponent(context) @@ -170,7 +171,7 @@ fun HomeScreen(navController: NavController) { fontSize = 20, fontWeight = FontWeight.SemiBold, paddingValues = PaddingValues(start = 24.dp, bottom = 14.dp), - textColor = DarkBlue + textColor = DarkBlue, ) Card( @@ -181,31 +182,31 @@ fun HomeScreen(navController: NavController) { .clickable { invokeCheckoutSDKToGenerateTokenForGooglePay(context) }, shape = RoundedCornerShape(12), colors = CardDefaults.cardColors(containerColor = Color.Transparent, contentColor = DarkBlue), - border = BorderStroke(width = 1.dp, color = ButtonBorder) + border = BorderStroke(width = 1.dp, color = ButtonBorder), ) { Column( - modifier = Modifier.padding(start = 20.dp, top = 10.dp) + modifier = Modifier.padding(start = 20.dp, top = 10.dp), ) { Image( painter = painterResource(id = R.drawable.ic_gpay), modifier = Modifier.size(50.dp), contentScale = ContentScale.Inside, alignment = Alignment.Center, - contentDescription = null + contentDescription = null, ) TextComponent( titleResourceId = R.string.google_pay, fontSize = 18, fontWeight = FontWeight.SemiBold, paddingValues = PaddingValues(bottom = 6.dp, top = 10.dp), - textColor = DarkBlue + textColor = DarkBlue, ) TextComponent( titleResourceId = R.string.payment_data, fontSize = 16, fontWeight = FontWeight.Normal, paddingValues = PaddingValues(bottom = 30.dp), - textColor = GrayColor + textColor = GrayColor, ) } } @@ -219,7 +220,9 @@ fun invokeCheckoutSDKToGenerateTokenForGooglePay(context: Context) { * Creating instance of CheckoutApiClient */ val checkoutApiClient = CheckoutApiServiceFactory.create( - "pk_test_6e40a700-d563-43cd-89d0-f9bb17d35e73", Environment.SANDBOX, context + "pk_test_6e40a700-d563-43cd-89d0-f9bb17d35e73", + Environment.SANDBOX, + context, ) /** @@ -229,24 +232,25 @@ fun invokeCheckoutSDKToGenerateTokenForGooglePay(context: Context) { checkoutApiClient.createToken( GooglePayTokenRequest( "{" + "\t\"protocolVersion\": \"ECv1\",\n" + "\t\"signature\":" + - "\"MEYCIQDRBIlMOzMjCEduZ6ENicfHlVx8679owbXV0lWbJ7pKDAIhAMEKPvzx8AlW6zxFNePoQMHCXjsHe" + - "PAhxnZwPkVywI2I\"," + - "\t\"signedMessage\": \"{\\\"encryptedMessage\\\":" + - "\\\"/rICAjT7ge2qvw0BU86Kt/v/5nLMiMdDhx6EXRRpKPvZGfZThR7FADqfrPvVJ0eStDTwD1v" + - "Xq+l+sXhBrQ+EdpHSv2oow3nQZeYwNU+nofKxfqSIDJBPgTMemphcBFkRsCdyDtOTI6AtVM7mxFm/QOiMzX0MdRNBrpLJp9" + - "cfQcxVX7O3z5IjG0t50dy4XtJPrdAd7N+0XG/KbrY466iNFPQuRYET65H4jXLGFK0RN+EQYe4gVAib91Y9KFenCh0x94V" + - "hoq4ayd6PCOL7Apj4G+yceDOoL5OAseGYk2JGwlW1DVLOj0YLUVBsWh86n0mRCARcgI5IuV6acHVL9XzEJQY/Z98oVSyVTo/" + - "PbeQKeaWR/qjcI9bdbpa9XIrYBCiKXrIau/mU2zg/Bq+OMrVJhRuFWFK9HMgxol0U+zNUVA9tOY4/QcHAEmfJgA2bhPCQQz" + - "qHYTn6g5Mv4vqCeV+k0MMcauinrDeJDgrFWKc2+Hu26uImWVk4\\\",\\\"ephemeralPublicKey\\\":\\\"BPPQFAG" + - "zdzp/TeDiBNABnju6FsL0lTNqKZTpUhzcyeWaK8XV19gtf1zhVAiZjOrLVGj3txoge9fW+x8bBghnFQc\\\\u003d\\\"," + - "\\\"tag\\\":\\\"Ewh1yD3bR5wqTRlEV6TPQpvWaUSBFTMsCAILpGejmtI\\\\u003d\\\"}\"\n" + - "}", + "\"MEYCIQDRBIlMOzMjCEduZ6ENicfHlVx8679owbXV0lWbJ7pKDAIhAMEKPvzx8AlW6zxFNePoQMHCXjsHe" + + "PAhxnZwPkVywI2I\"," + + "\t\"signedMessage\": \"{\\\"encryptedMessage\\\":" + + "\\\"/rICAjT7ge2qvw0BU86Kt/v/5nLMiMdDhx6EXRRpKPvZGfZThR7FADqfrPvVJ0eStDTwD1v" + + "Xq+l+sXhBrQ+EdpHSv2oow3nQZeYwNU+nofKxfqSIDJBPgTMemphcBFkRsCdyDtOTI6AtVM7mxFm/QOiMzX0MdRNBrpLJp9" + + "cfQcxVX7O3z5IjG0t50dy4XtJPrdAd7N+0XG/KbrY466iNFPQuRYET65H4jXLGFK0RN+EQYe4gVAib91Y9KFenCh0x94V" + + "hoq4ayd6PCOL7Apj4G+yceDOoL5OAseGYk2JGwlW1DVLOj0YLUVBsWh86n0mRCARcgI5IuV6acHVL9XzEJQY/Z98oVSyVTo/" + + "PbeQKeaWR/qjcI9bdbpa9XIrYBCiKXrIau/mU2zg/Bq+OMrVJhRuFWFK9HMgxol0U+zNUVA9tOY4/QcHAEmfJgA2bhPCQQz" + + "qHYTn6g5Mv4vqCeV+k0MMcauinrDeJDgrFWKc2+Hu26uImWVk4\\\",\\\"ephemeralPublicKey\\\":\\\"BPPQFAG" + + "zdzp/TeDiBNABnju6FsL0lTNqKZTpUhzcyeWaK8XV19gtf1zhVAiZjOrLVGj3txoge9fW+x8bBghnFQc\\\\u003d\\\"," + + "\\\"tag\\\":\\\"Ewh1yD3bR5wqTRlEV6TPQpvWaUSBFTMsCAILpGejmtI\\\\u003d\\\"}\"\n" + + "}", onSuccess = { showAlertDialog(context, context.getString(R.string.token_generated), it.token) - }, onFailure = { + }, + onFailure = { showAlertDialog(context, context.getString(R.string.token_generated_failed), it) - } - ) + }, + ), ) } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/LoadCVVComponentsContents.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/LoadCVVComponentsContents.kt index 19d2d7aa8..5cbfec118 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/LoadCVVComponentsContents.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/LoadCVVComponentsContents.kt @@ -40,7 +40,8 @@ fun LoadCVVComponentsContents( ) { FramesTheme { Surface( - modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background, ) { Column( modifier = Modifier @@ -49,11 +50,10 @@ fun LoadCVVComponentsContents( .padding(start = 10.dp, end = 24.dp, bottom = 14.dp), verticalArrangement = Arrangement.Top, ) { - Row( - modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Start + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.Start, ) { - ClickableImage( painter = painterResource(id = R.drawable.ic_back_arrow), contentDescription = "Back Arrow", @@ -66,7 +66,7 @@ fun LoadCVVComponentsContents( fontSize = 20, fontWeight = FontWeight.SemiBold, paddingValues = PaddingValues(top = 20.dp, start = 10.dp, bottom = 14.dp), - textColor = DarkBlue + textColor = DarkBlue, ) } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/MainActivity.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/MainActivity.kt index 91b8f6a47..18931089e 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/MainActivity.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/MainActivity.kt @@ -17,11 +17,11 @@ import com.checkout.example.frames.ui.utils.ENVIRONMENT import com.checkout.example.frames.ui.utils.PUBLIC_KEY import com.checkout.example.frames.ui.utils.PrefillDataHelper import com.checkout.frames.R -import com.checkout.frames.screen.paymentform.model.PaymentFormConfig -import com.checkout.frames.api.PaymentFormMediator -import com.checkout.frames.style.screen.PaymentFormStyle import com.checkout.frames.api.PaymentFlowHandler +import com.checkout.frames.api.PaymentFormMediator +import com.checkout.frames.screen.paymentform.model.PaymentFormConfig import com.checkout.frames.screen.paymentform.model.PrefillData +import com.checkout.frames.style.screen.PaymentFormStyle import com.checkout.frames.style.theme.paymentform.PaymentFormStyleProvider import com.checkout.tokenization.model.TokenDetails @@ -32,7 +32,7 @@ class MainActivity : ComponentActivity() { Navigator( this.applicationContext, { showAlertDialog(this, getString(R.string.token_generated), it.token) }, - { showAlertDialog(this, getString(R.string.token_generated_failed), it) } + { showAlertDialog(this, getString(R.string.token_generated_failed), it) }, ) } } @@ -43,7 +43,7 @@ class MainActivity : ComponentActivity() { fun Navigator( context: Context, onSuccess: (TokenDetails) -> Unit, - onFailure: (String) -> Unit + onFailure: (String) -> Unit, ) { val navController = rememberNavController() val defaultPaymentFormConfig = PaymentFormConfig( @@ -67,36 +67,36 @@ fun Navigator( CardScheme.DISCOVER, CardScheme.MASTERCARD, CardScheme.MAESTRO, - CardScheme.AMERICAN_EXPRESS + CardScheme.AMERICAN_EXPRESS, ), - prefillData = PrefillDataHelper.prefillData + prefillData = PrefillDataHelper.prefillData, ) val defaultPaymentFormMediator = PaymentFormMediator(defaultPaymentFormConfig) val customThemingPaymentFormMediator = PaymentFormMediator( defaultPaymentFormConfig.copy( style = PaymentFormStyleProvider.provide(CustomPaymentFormTheme.providePaymentFormTheme()), - prefillData = PrefillData(cardHolderName = "Test Name") - ) + prefillData = PrefillData(cardHolderName = "Test Name"), + ), ) val customPaymentFormMediator = PaymentFormMediator( defaultPaymentFormConfig.copy( style = PaymentFormStyle( CustomPaymentDetailsStyle.providePaymentDetailsStyle(), - CustomBillingFormStyle.provideBillingFormStyle() + CustomBillingFormStyle.provideBillingFormStyle(), ), supportedCardSchemeList = listOf( CardScheme.VISA, CardScheme.MASTERCARD, - CardScheme.AMERICAN_EXPRESS + CardScheme.AMERICAN_EXPRESS, ), prefillData = PrefillDataHelper.prefillData.copy( billingFormAddress = PrefillDataHelper.prefillData.billingFormAddress?.copy( - name = "Test name" - ) - ) - ) + name = "Test name", + ), + ), + ), ) NavHost(navController, startDestination = Screen.Home.route) { diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/ThreedSecureActivity.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/ThreedSecureActivity.kt index 51ce82ca3..f09329cb1 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/ThreedSecureActivity.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/screen/ThreedSecureActivity.kt @@ -68,7 +68,9 @@ class ThreedSecureActivity : ComponentActivity() { val request = ThreeDSRequest( container = viewGroup, // Provide a ViewGroup container for 3DS WebView challengeUrl = url, // Provide a 3D Secure URL - successUrl = SUCCESS_URL, failureUrl = FAILURE_URL, resultHandler = threeDSResultHandler + successUrl = SUCCESS_URL, + failureUrl = FAILURE_URL, + resultHandler = threeDSResultHandler, ) /** @@ -85,13 +87,17 @@ class ThreedSecureActivity : ComponentActivity() { showAlertDialog(this, getString(R.string.authentication_success), threeDSResult.token) } // Used when [ProcessThreeDSRequest.redirectUrl] contains [ThreeDSRequest.successUrl] - is ThreeDSResult.Failure -> { /* Handle failure result */ + is ThreeDSResult.Failure -> { + /* Handle failure result */ showAlertDialog(this, this.getString(R.string.token_generated_failed), "") } // Used when [ProcessThreeDSRequest.redirectUrl] can't be parsed or when error received from 3DS WebView - is ThreeDSResult.Error -> { /* Handle success result */ + is ThreeDSResult.Error -> { + /* Handle success result */ showAlertDialog( - this, this.getString(R.string.token_generated_failed), threeDSResult.error.message.toString() + this, + this.getString(R.string.token_generated_failed), + threeDSResult.error.message.toString(), ) } } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Color.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Color.kt index 853f357b5..6a4e181da 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Color.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Color.kt @@ -1,4 +1,5 @@ @file:Suppress("MagicNumber") + package com.checkout.example.frames.ui.theme import androidx.compose.ui.graphics.Color diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Theme.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Theme.kt index a83d25d6e..9533b3d9a 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Theme.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Theme.kt @@ -13,13 +13,13 @@ import androidx.compose.ui.platform.LocalContext private val DarkColorScheme = darkColorScheme( primary = DarkBlue, secondary = PurpleGrey80, - tertiary = Pink80 + tertiary = Pink80, ) private val LightColorScheme = lightColorScheme( primary = DarkBlue, secondary = PurpleGrey40, - tertiary = Pink40 + tertiary = Pink40, /* Other default colors to override background = Color(0xFFFFFBFE), @@ -29,7 +29,7 @@ private val LightColorScheme = lightColorScheme( onTertiary = Color.White, onBackground = Color(0xFF1C1B1F), onSurface = Color(0xFF1C1B1F), - */ + */ ) @Composable @@ -51,6 +51,6 @@ fun FramesTheme( MaterialTheme( colorScheme = colorScheme, typography = Typography, - content = content + content = content, ) } diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Type.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Type.kt index e63c46eff..476364fd3 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Type.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/theme/Type.kt @@ -13,8 +13,8 @@ val Typography = Typography( fontWeight = FontWeight.Normal, fontSize = 16.sp, lineHeight = 24.sp, - letterSpacing = 0.5.sp - ) + letterSpacing = 0.5.sp, + ), /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, @@ -30,5 +30,5 @@ val Typography = Typography( lineHeight = 16.sp, letterSpacing = 0.5.sp ) - */ + */ ) diff --git a/example_app_frames/src/main/java/com/checkout/example/frames/ui/utils/PrefillDataHelper.kt b/example_app_frames/src/main/java/com/checkout/example/frames/ui/utils/PrefillDataHelper.kt index b69736467..c60ef7c29 100644 --- a/example_app_frames/src/main/java/com/checkout/example/frames/ui/utils/PrefillDataHelper.kt +++ b/example_app_frames/src/main/java/com/checkout/example/frames/ui/utils/PrefillDataHelper.kt @@ -16,9 +16,9 @@ internal object PrefillDataHelper { city = "London", state = "London", zip = "W1T 4TJ", - country = Country.from(iso3166Alpha2 = "GB") + country = Country.from(iso3166Alpha2 = "GB"), ), - phone = Phone("7405987323", Country.UNITED_KINGDOM) - ) + phone = Phone("7405987323", Country.UNITED_KINGDOM), + ), ) } diff --git a/frames/build.gradle.kts b/frames/build.gradle.kts index 44b37baf2..e18b6cf99 100644 --- a/frames/build.gradle.kts +++ b/frames/build.gradle.kts @@ -1,9 +1,9 @@ +import com.checkout.buildsrc.BuildConfigFieldName import com.checkout.buildsrc.applyAndroidJUnit4Configuration import com.checkout.buildsrc.applyAndroidJUnit5Configuration import com.checkout.buildsrc.applyCommonLibConfigurations -import com.checkout.buildsrc.applyDeclarativeUIConfigurations import com.checkout.buildsrc.applyDIConfigurations -import com.checkout.buildsrc.BuildConfigFieldName +import com.checkout.buildsrc.applyDeclarativeUIConfigurations import com.checkout.buildsrc.applyJacocoTestReport import org.jetbrains.dokka.gradle.DokkaTask @@ -30,25 +30,25 @@ android { buildConfigField( "String", BuildConfigFieldName.productVersion, - "\"${FramesConfig.productVersion}\"" + "\"${FramesConfig.productVersion}\"", ) buildConfigField( "String", BuildConfigFieldName.productName, - "\"${FramesConfig.pomName}\"" + "\"${FramesConfig.pomName}\"", ) buildConfigField( "String", BuildConfigFieldName.productIdentifier, - "\"${FramesConfig.productGroupId}.${FramesConfig.productArtefactId}\"" + "\"${FramesConfig.productGroupId}.${FramesConfig.productArtefactId}\"", ) buildConfigField( "String", BuildConfigFieldName.loggingIdentifier, - "\"${FramesConfig.loggingGroupId}.${FramesConfig.productArtefactId}\"" + "\"${FramesConfig.loggingGroupId}.${FramesConfig.productArtefactId}\"", ) consumerProguardFiles("consumer-rules.pro") diff --git a/frames/src/androidTest/kotlin/com/checkout/frames/cvvinputfield/CVVInputFieldTest.kt b/frames/src/androidTest/kotlin/com/checkout/frames/cvvinputfield/CVVInputFieldTest.kt index 7d1328023..c2a4087fb 100644 --- a/frames/src/androidTest/kotlin/com/checkout/frames/cvvinputfield/CVVInputFieldTest.kt +++ b/frames/src/androidTest/kotlin/com/checkout/frames/cvvinputfield/CVVInputFieldTest.kt @@ -18,7 +18,7 @@ internal class CVVInputFieldTest { @Test fun testCVVInputFieldTextChange() { - // When + // When var cvvText = "" composeTestRule.setContent { CVVInputField( diff --git a/frames/src/androidTest/kotlin/com/checkout/frames/cvvinputfield/InternalCVVComponentMediatorUITest.kt b/frames/src/androidTest/kotlin/com/checkout/frames/cvvinputfield/InternalCVVComponentMediatorUITest.kt index 2c6b61a77..a7b7aa2ec 100644 --- a/frames/src/androidTest/kotlin/com/checkout/frames/cvvinputfield/InternalCVVComponentMediatorUITest.kt +++ b/frames/src/androidTest/kotlin/com/checkout/frames/cvvinputfield/InternalCVVComponentMediatorUITest.kt @@ -31,8 +31,8 @@ internal class InternalCVVComponentMediatorUITest { cvvComponentConfig = cvvComponentConfig, cvvTokenizationUseCase = CVVTokenizationUseCase( CheckoutApiServiceFactory.create( - publicKey = "", environment = Environment.SANDBOX, context = context - ) + publicKey = "", environment = Environment.SANDBOX, context = context, + ), ), ) } diff --git a/frames/src/androidTest/kotlin/com/checkout/frames/screen/PaymentFormScreenTest.kt b/frames/src/androidTest/kotlin/com/checkout/frames/screen/PaymentFormScreenTest.kt index 4946088c1..d08ceb796 100644 --- a/frames/src/androidTest/kotlin/com/checkout/frames/screen/PaymentFormScreenTest.kt +++ b/frames/src/androidTest/kotlin/com/checkout/frames/screen/PaymentFormScreenTest.kt @@ -53,13 +53,14 @@ internal class PaymentFormScreenTest { city = "London", state = "London", zip = "W1T 4TJ", - country = Country.from(iso3166Alpha2 = "GB") + country = Country.from(iso3166Alpha2 = "GB"), ), phone = Phone( - number = "4155552671", country = Country.from(iso3166Alpha2 = "GB") - ) - ) - ) + number = "4155552671", + country = Country.from(iso3166Alpha2 = "GB"), + ), + ), + ), ) @Test diff --git a/frames/src/main/java/com/checkout/frames/api/PaymentFormMediator.kt b/frames/src/main/java/com/checkout/frames/api/PaymentFormMediator.kt index 4618f40d0..1fa56c86e 100644 --- a/frames/src/main/java/com/checkout/frames/api/PaymentFormMediator.kt +++ b/frames/src/main/java/com/checkout/frames/api/PaymentFormMediator.kt @@ -7,8 +7,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.fragment.app.Fragment -import com.checkout.frames.screen.paymentform.model.PaymentFormConfig import com.checkout.frames.screen.paymentform.PaymentFormScreen +import com.checkout.frames.screen.paymentform.model.PaymentFormConfig import com.checkout.logging.EventLoggerProvider import com.checkout.threedsecure.Executor import com.checkout.threedsecure.ThreeDSExecutor @@ -17,7 +17,7 @@ import com.checkout.threedsecure.model.ThreeDSRequest import com.checkout.threedsecure.usecase.ProcessThreeDSUseCase public class PaymentFormMediator( - private val config: PaymentFormConfig + private val config: PaymentFormConfig, ) { /** @@ -58,7 +58,7 @@ public class PaymentFormMediator( @JvmOverloads public fun provideFragmentContent( fragment: Fragment, - strategy: ViewCompositionStrategy = ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed + strategy: ViewCompositionStrategy = ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed, ): View = ComposeView(fragment.requireContext()).apply { // Dispose of the Composition when the view's LifecycleOwner is destroyed setViewCompositionStrategy(strategy) diff --git a/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryComponent.kt b/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryComponent.kt index 5a160245b..082012370 100644 --- a/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryComponent.kt @@ -17,10 +17,10 @@ import com.checkout.frames.view.TextLabelState internal fun AddressSummaryComponent( style: AddressSummaryComponentStyle, injector: Injector, - goToBillingAddressForm: () -> Unit + goToBillingAddressForm: () -> Unit, ) { val viewModel: AddressSummaryViewModel = viewModel( - factory = AddressSummaryViewModel.Factory(injector, style) + factory = AddressSummaryViewModel.Factory(injector, style), ) viewModel.prepare() @@ -39,14 +39,14 @@ internal fun AddressSummaryComponent( InternalButton( style = viewModel.componentStyle.addAddressButtonStyle, state = viewModel.componentState.addAddressButtonState, - onClick = goToBillingAddressForm + onClick = goToBillingAddressForm, ) } else { AddressSummarySection( style = viewModel.componentStyle.summarySectionStyle, addressPreviewState = viewModel.componentState.addressPreviewState, editAddressButtonState = viewModel.componentState.editAddressButtonState, - onEditButtonPress = goToBillingAddressForm + onEditButtonPress = goToBillingAddressForm, ) } } @@ -57,7 +57,7 @@ private fun AddressSummarySection( style: AddressSummarySectionViewStyle, addressPreviewState: TextLabelState, editAddressButtonState: InternalButtonState, - onEditButtonPress: () -> Unit + onEditButtonPress: () -> Unit, ) { Column(modifier = style.modifier) { // Address Preview @@ -68,7 +68,7 @@ private fun AddressSummarySection( InternalButton( style = style.editAddressButtonStyle, state = editAddressButtonState, - onClick = onEditButtonPress + onClick = onEditButtonPress, ) } } diff --git a/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryComponentState.kt b/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryComponentState.kt index ad4128f4e..e9fc787bc 100644 --- a/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryComponentState.kt +++ b/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryComponentState.kt @@ -8,5 +8,5 @@ internal data class AddressSummaryComponentState( val subTitleState: TextLabelState, val addressPreviewState: TextLabelState, val editAddressButtonState: InternalButtonState, - val addAddressButtonState: InternalButtonState + val addAddressButtonState: InternalButtonState, ) diff --git a/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryViewModel.kt b/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryViewModel.kt index 7783b87f5..4ab187b23 100644 --- a/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/component/addresssummary/AddressSummaryViewModel.kt @@ -20,7 +20,7 @@ internal class AddressSummaryViewModel @Inject constructor( style: AddressSummaryComponentStyle, private val paymentStateManager: PaymentStateManager, private val componentStateMapper: Mapper, - private val componentStyleMapper: Mapper + private val componentStyleMapper: Mapper, ) : ViewModel() { val componentState = provideState(style) @@ -31,9 +31,11 @@ internal class AddressSummaryViewModel @Inject constructor( componentState.addressPreviewState.text.value = if (paymentStateManager.billingAddress.value.isEdited() && paymentStateManager.isBillingAddressEnabled.value - ) + ) { billingAddress.summary() - else "" + } else { + "" + } } } @@ -54,7 +56,7 @@ internal class AddressSummaryViewModel @Inject constructor( internal class Factory( private val injector: Injector, - private val style: AddressSummaryComponentStyle + private val style: AddressSummaryComponentStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/component/base/InputComponent.kt b/frames/src/main/java/com/checkout/frames/component/base/InputComponent.kt index 8b9c96811..4bafa24e7 100644 --- a/frames/src/main/java/com/checkout/frames/component/base/InputComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/base/InputComponent.kt @@ -15,14 +15,14 @@ internal fun InputComponent( style: InputComponentViewStyle, state: InputComponentState, onFocusChanged: ((Boolean) -> Unit)? = null, - onValueChange: (String) -> Unit + onValueChange: (String) -> Unit, ) = with(state) { Column(modifier = style.containerModifier.wrapContentHeight()) { Row { Column( modifier = Modifier .weight(1F) - .wrapContentHeight() + .wrapContentHeight(), ) { // Title label if (titleState.isVisible.value) TextLabel(style.titleStyle, titleState) @@ -32,7 +32,7 @@ internal fun InputComponent( Column( Modifier .align(Alignment.Bottom) - .wrapContentHeight() + .wrapContentHeight(), ) { // Info label if (infoState.isVisible.value) TextLabel(style.infoStyle, infoState) diff --git a/frames/src/main/java/com/checkout/frames/component/base/InputComponentState.kt b/frames/src/main/java/com/checkout/frames/component/base/InputComponentState.kt index e7b112853..bd2602474 100644 --- a/frames/src/main/java/com/checkout/frames/component/base/InputComponentState.kt +++ b/frames/src/main/java/com/checkout/frames/component/base/InputComponentState.kt @@ -9,5 +9,5 @@ internal data class InputComponentState( val subtitleState: TextLabelState = TextLabelState(), val infoState: TextLabelState = TextLabelState(), val errorState: TextLabelState = TextLabelState(), - val isInputFieldOptional: Boolean = false + val isInputFieldOptional: Boolean = false, ) diff --git a/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressDynamicInputComponent.kt b/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressDynamicInputComponent.kt index 3adefc593..8cc908b4d 100644 --- a/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressDynamicInputComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressDynamicInputComponent.kt @@ -10,12 +10,12 @@ internal fun BillingAddressDynamicInputComponent( inputComponentViewStyle: BillingAddressInputComponentViewStyle, inputComponentState: BillingAddressInputComponentState, onFocusChanged: (Int, Boolean) -> Unit, - onValueChange: (Int, String) -> Unit + onValueChange: (Int, String) -> Unit, ) { InputComponent( style = inputComponentViewStyle.inputComponentViewStyle, state = inputComponentState.inputComponentState, onFocusChanged = { onFocusChanged(position, it) }, - onValueChange = { onValueChange(position, it) } + onValueChange = { onValueChange(position, it) }, ) } diff --git a/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressInputComponentState.kt b/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressInputComponentState.kt index 10e6d82f3..e5aaa3cb0 100644 --- a/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressInputComponentState.kt +++ b/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressInputComponentState.kt @@ -6,7 +6,7 @@ import kotlinx.coroutines.flow.MutableStateFlow internal data class BillingAddressInputComponentState( val addressFieldName: String, var inputComponentState: InputComponentState, - val isAddressFieldValid: MutableStateFlow = MutableStateFlow(false) + val isAddressFieldValid: MutableStateFlow = MutableStateFlow(false), ) { var isInputFieldOptional = inputComponentState.isInputFieldOptional diff --git a/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressInputComponentsContainerState.kt b/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressInputComponentsContainerState.kt index 0650b464f..a57329a42 100644 --- a/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressInputComponentsContainerState.kt +++ b/frames/src/main/java/com/checkout/frames/component/billingaddressfields/BillingAddressInputComponentsContainerState.kt @@ -1,5 +1,5 @@ package com.checkout.frames.component.billingaddressfields internal data class BillingAddressInputComponentsContainerState( - val inputComponentStateList: List = emptyList() + val inputComponentStateList: List = emptyList(), ) diff --git a/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameComponent.kt b/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameComponent.kt index 189f7033c..a5aaa4e69 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameComponent.kt @@ -9,16 +9,16 @@ import com.checkout.frames.style.component.CardHolderNameComponentStyle @Composable internal fun CardHolderNameComponent( style: CardHolderNameComponentStyle, - injector: Injector + injector: Injector, ) { val viewModel: CardHolderNameViewModel = viewModel( - factory = CardHolderNameViewModel.Factory(injector, style) + factory = CardHolderNameViewModel.Factory(injector, style), ) InputComponent( style = viewModel.componentStyle, state = viewModel.componentState.inputState, onFocusChanged = viewModel::onFocusChanged, - onValueChange = viewModel::onCardHolderNameChange + onValueChange = viewModel::onCardHolderNameChange, ) } diff --git a/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameComponentState.kt b/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameComponentState.kt index 8c9ba842f..873903e7e 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameComponentState.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameComponentState.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.MutableStateFlow internal data class CardHolderNameComponentState( val inputState: InputComponentState, - val isCardHolderNameFieldValid: MutableStateFlow = MutableStateFlow(false) + val isCardHolderNameFieldValid: MutableStateFlow = MutableStateFlow(false), ) { val cardHolderName by lazy { inputState.inputFieldState.text } diff --git a/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameViewModel.kt b/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameViewModel.kt index 29e728e73..d6832d0e6 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardholdername/CardHolderNameViewModel.kt @@ -22,7 +22,7 @@ internal class CardHolderNameViewModel @Inject constructor( private val paymentStateManager: PaymentStateManager, private val inputComponentStyleMapper: Mapper, private val inputComponentStateMapper: Mapper, - style: CardHolderNameComponentStyle + style: CardHolderNameComponentStyle, ) : ViewModel() { val componentState = provideViewState(style) @@ -52,8 +52,11 @@ internal class CardHolderNameViewModel @Inject constructor( val isValid = cardHolderName.isNotBlank() || componentStyle.isInputFieldOptional paymentStateManager.isCardHolderNameValid.update { isValid } - if (wasFocused && isValid) componentState.hideError() - else componentState.showError(R.string.cko_cardholder_name_error) + if (wasFocused && isValid) { + componentState.hideError() + } else { + componentState.showError(R.string.cko_cardholder_name_error) + } } fun onCardHolderNameChange(text: String) = with(text) { @@ -73,8 +76,8 @@ internal class CardHolderNameViewModel @Inject constructor( viewStyle = viewStyle.copy( inputFieldStyle = viewStyle.inputFieldStyle.copy( - keyboardOptions = keyboardOptions, forceLTR = true - ) + keyboardOptions = keyboardOptions, forceLTR = true, + ), ) return viewStyle diff --git a/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberComponent.kt b/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberComponent.kt index 4422806d8..826006d7b 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberComponent.kt @@ -9,16 +9,16 @@ import com.checkout.frames.style.component.CardNumberComponentStyle @Composable internal fun CardNumberComponent( style: CardNumberComponentStyle, - injector: Injector + injector: Injector, ) { val viewModel: CardNumberViewModel = viewModel( - factory = CardNumberViewModel.Factory(injector, style) + factory = CardNumberViewModel.Factory(injector, style), ) InputComponent( style = viewModel.componentStyle, state = viewModel.componentState.inputState, onFocusChanged = viewModel::onFocusChanged, - onValueChange = viewModel::onCardNumberChange + onValueChange = viewModel::onCardNumberChange, ) } diff --git a/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberComponentState.kt b/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberComponentState.kt index f7afdffd8..691566f41 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberComponentState.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberComponentState.kt @@ -7,7 +7,7 @@ import com.checkout.frames.component.base.InputComponentState internal data class CardNumberComponentState( val inputState: InputComponentState, - val cardScheme: MutableState = mutableStateOf(CardScheme.UNKNOWN) + val cardScheme: MutableState = mutableStateOf(CardScheme.UNKNOWN), ) { val cardNumber = inputState.inputFieldState.text val cardNumberLength = inputState.inputFieldState.maxLength diff --git a/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberTransformation.kt b/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberTransformation.kt index c4088b264..d57399275 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberTransformation.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberTransformation.kt @@ -10,7 +10,7 @@ import java.lang.StringBuilder internal class CardNumberTransformation( private val separator: Char, - private val cardScheme: MutableState + private val cardScheme: MutableState, ) : VisualTransformation { override fun filter(text: AnnotatedString): TransformedText = defaultCardNumberFormat(text) diff --git a/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberViewModel.kt b/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberViewModel.kt index 3aeb55634..1c9de84f9 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardnumber/CardNumberViewModel.kt @@ -32,7 +32,7 @@ internal class CardNumberViewModel @Inject constructor( private val inputComponentStyleMapper: Mapper, private val inputComponentStateMapper: Mapper, private val imageMapper: ImageStyleToDynamicComposableImageMapper, - private val style: CardNumberComponentStyle + private val style: CardNumberComponentStyle, ) : ViewModel() { val componentState = provideViewState(style) @@ -57,7 +57,7 @@ internal class CardNumberViewModel @Inject constructor( handleValidationResult( cardValidator.validateCardNumber(cardNumber), isEagerCheck = false, - isRequiredToHandleError = true + isRequiredToHandleError = true, ) } } @@ -77,7 +77,7 @@ internal class CardNumberViewModel @Inject constructor( handleValidationResult( result = cardValidator.validateCardNumber(this), isEagerCheck = false, - isRequiredToHandleError = false + isRequiredToHandleError = false, ) } } @@ -86,7 +86,7 @@ internal class CardNumberViewModel @Inject constructor( private fun handleValidationResult( result: ValidationResult, isEagerCheck: Boolean, - isRequiredToHandleError: Boolean + isRequiredToHandleError: Boolean, ) = when (result) { is ValidationResult.Success -> with(result.value) { paymentStateManager.isCardSchemeUpdated.update { true } @@ -98,8 +98,11 @@ internal class CardNumberViewModel @Inject constructor( } if (isRequiredToHandleError) { - if (this in paymentStateManager.supportedCardSchemeList) hideValidationError() - else showValidationError() + if (this in paymentStateManager.supportedCardSchemeList) { + hideValidationError() + } else { + showValidationError() + } } else { paymentStateManager.isCardNumberValid.update { true } } @@ -107,8 +110,11 @@ internal class CardNumberViewModel @Inject constructor( is ValidationResult.Failure -> { paymentStateManager.isCardSchemeUpdated.update { false } - if (isRequiredToHandleError) showValidationError() - else paymentStateManager.isCardNumberValid.update { false } + if (isRequiredToHandleError) { + showValidationError() + } else { + paymentStateManager.isCardNumberValid.update { false } + } } } @@ -128,8 +134,8 @@ internal class CardNumberViewModel @Inject constructor( viewState.inputState.inputFieldState.leadingIcon.value = imageMapper.map( ImageStyleToDynamicImageRequest( style.inputStyle.inputFieldStyle.leadingIconStyle, - snapshotFlow { viewState.cardScheme.value }.map { it.imageId } - ) + snapshotFlow { viewState.cardScheme.value }.map { it.imageId }, + ), ) return viewState @@ -143,8 +149,8 @@ internal class CardNumberViewModel @Inject constructor( inputFieldStyle = viewStyle.inputFieldStyle.copy( keyboardOptions = keyboardOptions, visualTransformation = CardNumberTransformation(style.cardNumberSeparator, componentState.cardScheme), - forceLTR = true - ) + forceLTR = true, + ), ) return viewStyle @@ -152,7 +158,7 @@ internal class CardNumberViewModel @Inject constructor( internal class Factory( private val injector: Injector, - private val style: CardNumberComponentStyle + private val style: CardNumberComponentStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeComponent.kt b/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeComponent.kt index 0180c383f..d4bca56a1 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeComponent.kt @@ -13,16 +13,16 @@ import com.google.accompanist.flowlayout.FlowRow @Composable internal fun CardSchemeComponent( style: CardSchemeComponentStyle, - injector: Injector + injector: Injector, ) { val viewModel: CardSchemeViewModel = viewModel( - factory = CardSchemeViewModel.Factory(injector, style) + factory = CardSchemeViewModel.Factory(injector, style), ) BasicCardSchemeComponent( viewModel.componentStyle, viewModel.componentState, - viewModel.componentSupportedCardSchemeIcons + viewModel.componentSupportedCardSchemeIcons, ) } @@ -30,7 +30,7 @@ internal fun CardSchemeComponent( private fun BasicCardSchemeComponent( style: CardSchemeComponentViewStyle, state: CardSchemeComponentState, - supportedCardSchemeIconList: List<@Composable (() -> Unit)?> + supportedCardSchemeIconList: List<@Composable (() -> Unit)?>, ) = with(style) { Column(modifier = style.containerModifier.wrapContentHeight()) { // Title label @@ -41,7 +41,7 @@ private fun BasicCardSchemeComponent( FlowRow( modifier = flowRowViewStyle.imagesContainerModifier, mainAxisSpacing = flowRowViewStyle.mainAxisSpacing, - crossAxisSpacing = flowRowViewStyle.crossAxisSpacing + crossAxisSpacing = flowRowViewStyle.crossAxisSpacing, ) { supportedCardSchemeIconList.forEach { it?.invoke() } } diff --git a/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeComponentState.kt b/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeComponentState.kt index 67457f0ec..d25fd729c 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeComponentState.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeComponentState.kt @@ -3,5 +3,5 @@ package com.checkout.frames.component.cardscheme import com.checkout.frames.view.TextLabelState internal data class CardSchemeComponentState( - val textLabelState: TextLabelState? = null + val textLabelState: TextLabelState? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeViewModel.kt b/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeViewModel.kt index bea1d7326..f1c1a27cc 100644 --- a/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/component/cardscheme/CardSchemeViewModel.kt @@ -20,7 +20,7 @@ internal class CardSchemeViewModel @Inject constructor( private val cardSchemeComponentStyleMapper: Mapper, private val cardSchemeComponentStateMapper: Mapper, private val imageMapper: ImageStyleToComposableImageMapper, - private val style: CardSchemeComponentStyle + private val style: CardSchemeComponentStyle, ) : ViewModel() { val componentState = provideViewState(style) @@ -45,7 +45,7 @@ internal class CardSchemeViewModel @Inject constructor( internal class Factory( private val injector: Injector, - private val style: CardSchemeComponentStyle + private val style: CardSchemeComponentStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/component/country/CountryComponent.kt b/frames/src/main/java/com/checkout/frames/component/country/CountryComponent.kt index 71c71e0a7..fea0085cf 100644 --- a/frames/src/main/java/com/checkout/frames/component/country/CountryComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/country/CountryComponent.kt @@ -18,7 +18,7 @@ internal fun CountryComponent( goToCountryPicker: () -> Unit, ) { val viewModel: CountryViewModel = viewModel( - factory = CountryViewModel.Factory(injector, style) + factory = CountryViewModel.Factory(injector, style), ) viewModel.prepare(onCountryUpdated) @@ -26,13 +26,13 @@ internal fun CountryComponent( with(viewModel.componentStyle.inputFieldStyle) { modifier = modifier.clickable( interactionSource = remember { MutableInteractionSource() }, - indication = null + indication = null, ) { goToCountryPicker() } } InputComponent( style = viewModel.componentStyle, state = viewModel.componentState, - onValueChange = {} + onValueChange = {}, ) } diff --git a/frames/src/main/java/com/checkout/frames/component/country/CountryViewModel.kt b/frames/src/main/java/com/checkout/frames/component/country/CountryViewModel.kt index 99d3052ec..d17becf68 100644 --- a/frames/src/main/java/com/checkout/frames/component/country/CountryViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/component/country/CountryViewModel.kt @@ -24,7 +24,7 @@ internal class CountryViewModel @Inject constructor( private val paymentStateManager: PaymentStateManager, private val inputComponentStyleMapper: Mapper, private val inputComponentStateMapper: Mapper, - style: CountryComponentStyle + style: CountryComponentStyle, ) : ViewModel() { val componentState = provideViewState(style.inputStyle) @@ -70,8 +70,8 @@ internal class CountryViewModel @Inject constructor( viewStyle = viewStyle.copy( inputFieldStyle = viewStyle.inputFieldStyle.copy( readOnly = true, - enabled = false - ) + enabled = false, + ), ) return viewStyle @@ -79,7 +79,7 @@ internal class CountryViewModel @Inject constructor( internal class Factory( private val injector: Injector, - private val style: CountryComponentStyle + private val style: CountryComponentStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/component/cvv/CvvComponent.kt b/frames/src/main/java/com/checkout/frames/component/cvv/CvvComponent.kt index 7f4e9bf4d..0c8285681 100644 --- a/frames/src/main/java/com/checkout/frames/component/cvv/CvvComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/cvv/CvvComponent.kt @@ -9,10 +9,10 @@ import com.checkout.frames.style.component.CvvComponentStyle @Composable internal fun CvvComponent( style: CvvComponentStyle, - injector: Injector + injector: Injector, ) { val viewModel: CvvViewModel = viewModel( - factory = CvvViewModel.Factory(injector, style) + factory = CvvViewModel.Factory(injector, style), ) viewModel.prepare() @@ -21,6 +21,6 @@ internal fun CvvComponent( style = viewModel.componentStyle, state = viewModel.componentState.inputState, onFocusChanged = viewModel::onFocusChanged, - onValueChange = viewModel::onCvvChange + onValueChange = viewModel::onCvvChange, ) } diff --git a/frames/src/main/java/com/checkout/frames/component/cvv/CvvComponentState.kt b/frames/src/main/java/com/checkout/frames/component/cvv/CvvComponentState.kt index 56fe55419..ee06eafa1 100644 --- a/frames/src/main/java/com/checkout/frames/component/cvv/CvvComponentState.kt +++ b/frames/src/main/java/com/checkout/frames/component/cvv/CvvComponentState.kt @@ -3,7 +3,7 @@ package com.checkout.frames.component.cvv import com.checkout.frames.component.base.InputComponentState internal data class CvvComponentState( - val inputState: InputComponentState + val inputState: InputComponentState, ) { val cvv = inputState.inputFieldState.text diff --git a/frames/src/main/java/com/checkout/frames/component/cvv/CvvViewModel.kt b/frames/src/main/java/com/checkout/frames/component/cvv/CvvViewModel.kt index fd130f69a..1bfce2e57 100644 --- a/frames/src/main/java/com/checkout/frames/component/cvv/CvvViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/component/cvv/CvvViewModel.kt @@ -29,7 +29,7 @@ internal class CvvViewModel @Inject constructor( private val cardValidator: CardValidator, private val inputComponentStyleMapper: Mapper, private val inputComponentStateMapper: Mapper, - style: CvvComponentStyle + style: CvvComponentStyle, ) : ViewModel() { val componentState = provideViewState(style) @@ -101,8 +101,8 @@ internal class CvvViewModel @Inject constructor( viewStyle = viewStyle.copy( inputFieldStyle = viewStyle.inputFieldStyle.copy( keyboardOptions = keyboardOptions, - forceLTR = true - ) + forceLTR = true, + ), ) return viewStyle @@ -110,7 +110,7 @@ internal class CvvViewModel @Inject constructor( internal class Factory( private val injector: Injector, - private val style: CvvComponentStyle + private val style: CvvComponentStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateComponent.kt b/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateComponent.kt index 7ccbedcfd..d58809bc7 100644 --- a/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateComponent.kt @@ -12,13 +12,13 @@ internal fun ExpiryDateComponent( injector: Injector, ) { val viewModel: ExpiryDateViewModel = viewModel( - factory = ExpiryDateViewModel.Factory(injector, style) + factory = ExpiryDateViewModel.Factory(injector, style), ) InputComponent( style = viewModel.componentStyle, state = viewModel.componentState.inputState, onFocusChanged = viewModel::onFocusChanged, - onValueChange = viewModel::onExpiryDateInputChange + onValueChange = viewModel::onExpiryDateInputChange, ) } diff --git a/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateComponentState.kt b/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateComponentState.kt index 006d357f8..74c681c91 100644 --- a/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateComponentState.kt +++ b/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateComponentState.kt @@ -3,7 +3,7 @@ package com.checkout.frames.component.expirydate import com.checkout.frames.component.base.InputComponentState internal data class ExpiryDateComponentState( - val inputState: InputComponentState + val inputState: InputComponentState, ) { val expiryDate = inputState.inputFieldState.text val expiryDateMaxLength = inputState.inputFieldState.maxLength diff --git a/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateViewModel.kt b/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateViewModel.kt index 1bee42f3d..bc132ced3 100644 --- a/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateViewModel.kt @@ -64,16 +64,22 @@ internal class ExpiryDateViewModel @Inject constructor( instantly invoked the onValueChange from the ExpiryDateComponent(without any user input) resulting in hiding/blinking the visible expiry date error. */ - if (componentState.expiryDate.value == this && wasInvalidPastExpiryDate) + if (componentState.expiryDate.value == this && wasInvalidPastExpiryDate) { wasInvalidPastExpiryDate = false - else validateExpiryDate(this, true) + } else { + validateExpiryDate(this, true) + } } private fun updateExpiryDateMaxLength(smartLogicExpiryDateUseCase: ValidationResult.Success) { componentState.expiryDateMaxLength.value = if ( smartLogicExpiryDateUseCase.value.isNotEmpty() && smartLogicExpiryDateUseCase.value.first() > EXPIRY_DATE_ZERO_POSITION_CHECK - ) EXPIRY_DATE_MAXIMUM_LENGTH_THREE else EXPIRY_DATE_MAXIMUM_LENGTH_FOUR + ) { + EXPIRY_DATE_MAXIMUM_LENGTH_THREE + } else { + EXPIRY_DATE_MAXIMUM_LENGTH_FOUR + } } private fun validateExpiryDate(expiryDate: String, isFocused: Boolean) { @@ -122,8 +128,8 @@ internal class ExpiryDateViewModel @Inject constructor( inputFieldStyle = viewStyle.inputFieldStyle.copy( keyboardOptions = keyboardOptions, visualTransformation = ExpiryDateVisualTransformation(), - forceLTR = true - ) + forceLTR = true, + ), ) return viewStyle diff --git a/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateVisualTransformation.kt b/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateVisualTransformation.kt index 443bb8c1a..bb71547f8 100644 --- a/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateVisualTransformation.kt +++ b/frames/src/main/java/com/checkout/frames/component/expirydate/ExpiryDateVisualTransformation.kt @@ -4,8 +4,8 @@ import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.input.OffsetMapping import androidx.compose.ui.text.input.TransformedText import androidx.compose.ui.text.input.VisualTransformation -import com.checkout.frames.utils.constants.EXPIRY_DATE_ZERO_POSITION_CHECK import com.checkout.frames.utils.constants.EXPIRY_DATE_PREFIX_ZERO +import com.checkout.frames.utils.constants.EXPIRY_DATE_ZERO_POSITION_CHECK internal class ExpiryDateVisualTransformation : VisualTransformation { diff --git a/frames/src/main/java/com/checkout/frames/component/expirydate/model/SmartExpiryDateValidationRequest.kt b/frames/src/main/java/com/checkout/frames/component/expirydate/model/SmartExpiryDateValidationRequest.kt index 5187ed245..1910d8cb4 100644 --- a/frames/src/main/java/com/checkout/frames/component/expirydate/model/SmartExpiryDateValidationRequest.kt +++ b/frames/src/main/java/com/checkout/frames/component/expirydate/model/SmartExpiryDateValidationRequest.kt @@ -2,5 +2,5 @@ package com.checkout.frames.component.expirydate.model internal data class SmartExpiryDateValidationRequest( val isFocused: Boolean, - val inputExpiryDate: String + val inputExpiryDate: String, ) diff --git a/frames/src/main/java/com/checkout/frames/component/expirydate/usecase/SmartExpiryDateValidationUseCase.kt b/frames/src/main/java/com/checkout/frames/component/expirydate/usecase/SmartExpiryDateValidationUseCase.kt index 88d8c67b1..72aab81f8 100644 --- a/frames/src/main/java/com/checkout/frames/component/expirydate/usecase/SmartExpiryDateValidationUseCase.kt +++ b/frames/src/main/java/com/checkout/frames/component/expirydate/usecase/SmartExpiryDateValidationUseCase.kt @@ -13,10 +13,13 @@ internal class SmartExpiryDateValidationUseCase(private val cardValidator: CardV override fun execute(data: SmartExpiryDateValidationRequest): ValidationResult { val isZeroPrefixExist = data.inputExpiryDate.isNotEmpty() && - data.inputExpiryDate[0] > EXPIRY_DATE_ZERO_POSITION_CHECK + data.inputExpiryDate[0] > EXPIRY_DATE_ZERO_POSITION_CHECK - return if (data.isFocused) validateFocusedExpiryDate(data.inputExpiryDate, isZeroPrefixExist) - else validateExpiryDate(data.inputExpiryDate, isZeroPrefixExist) + return if (data.isFocused) { + validateFocusedExpiryDate(data.inputExpiryDate, isZeroPrefixExist) + } else { + validateExpiryDate(data.inputExpiryDate, isZeroPrefixExist) + } } private fun validateFocusedExpiryDate( diff --git a/frames/src/main/java/com/checkout/frames/component/paybutton/PayButtonComponent.kt b/frames/src/main/java/com/checkout/frames/component/paybutton/PayButtonComponent.kt index d5076ad30..9bf14da3f 100644 --- a/frames/src/main/java/com/checkout/frames/component/paybutton/PayButtonComponent.kt +++ b/frames/src/main/java/com/checkout/frames/component/paybutton/PayButtonComponent.kt @@ -9,10 +9,10 @@ import com.checkout.frames.view.InternalButton @Composable internal fun PayButtonComponent( style: PayButtonComponentStyle, - injector: Injector + injector: Injector, ) { val viewModel: PayButtonViewModel = viewModel( - factory = PayButtonViewModel.Factory(injector, style) + factory = PayButtonViewModel.Factory(injector, style), ) viewModel.prepare() diff --git a/frames/src/main/java/com/checkout/frames/component/paybutton/PayButtonViewModel.kt b/frames/src/main/java/com/checkout/frames/component/paybutton/PayButtonViewModel.kt index 3c8699aa4..6fa7ddf30 100644 --- a/frames/src/main/java/com/checkout/frames/component/paybutton/PayButtonViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/component/paybutton/PayButtonViewModel.kt @@ -32,7 +32,7 @@ internal class PayButtonViewModel @Inject constructor( private val cardTokenizationUseCase: UseCase, private val buttonStyleMapper: Mapper, buttonStateMapper: Mapper, - private val logger: Logger + private val logger: Logger, ) : ViewModel() { val buttonStyle = provideButtonViewStyle() @@ -51,7 +51,7 @@ internal class PayButtonViewModel @Inject constructor( val request = InternalCardTokenRequest( provideCardData(), onSuccess = onPaymentFinished, - onFailure = onPaymentFinished + onFailure = onPaymentFinished, ) buttonState.isEnabled.value = false @@ -75,13 +75,13 @@ internal class PayButtonViewModel @Inject constructor( cardNumber.value, cvv.value, address?.address, - address?.phone + address?.phone, ) } internal class Factory( private val injector: Injector, - private val style: PayButtonComponentStyle + private val style: PayButtonComponentStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/component/provider/ComposableComponentProvider.kt b/frames/src/main/java/com/checkout/frames/component/provider/ComposableComponentProvider.kt index a96267e6f..176678c55 100644 --- a/frames/src/main/java/com/checkout/frames/component/provider/ComposableComponentProvider.kt +++ b/frames/src/main/java/com/checkout/frames/component/provider/ComposableComponentProvider.kt @@ -18,12 +18,12 @@ import com.checkout.frames.style.component.PayButtonComponentStyle import com.checkout.frames.style.component.addresssummary.AddressSummaryComponentStyle internal class ComposableComponentProvider( - private val injector: Injector + private val injector: Injector, ) : ComponentProvider { @Composable override fun CardScheme(style: CardSchemeComponentStyle) { - CardSchemeComponent(style, injector) + CardSchemeComponent(style, injector) } @Composable diff --git a/frames/src/main/java/com/checkout/frames/cvvinputfield/CVVInputField.kt b/frames/src/main/java/com/checkout/frames/cvvinputfield/CVVInputField.kt index 93c369396..572168fcb 100644 --- a/frames/src/main/java/com/checkout/frames/cvvinputfield/CVVInputField.kt +++ b/frames/src/main/java/com/checkout/frames/cvvinputfield/CVVInputField.kt @@ -29,10 +29,10 @@ internal fun CVVInputField( inputFieldStateMapper = InputFieldStyleToInputFieldStateMapper(ImageStyleToComposableImageMapper()), inputFieldStyleMapper = InputFieldStyleToViewStyleMapper( TextLabelStyleToViewStyleMapper( - ContainerStyleToModifierMapper() - ) - ) - ) + ContainerStyleToModifierMapper(), + ), + ), + ), ) onValueChange(viewModel.cvvInputFieldState.inputFieldState.text.value) diff --git a/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentApi.kt b/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentApi.kt index 0b254053e..850d7ec6d 100644 --- a/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentApi.kt +++ b/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentApi.kt @@ -16,8 +16,10 @@ internal class InternalCVVComponentApi( cvvComponentConfig = cvvComponentConfig, cvvTokenizationUseCase = CVVTokenizationUseCase( checkoutApiService = CheckoutApiServiceFactory.create( - publicKey = publicKey, environment = environment, context = context - ) - ) + publicKey = publicKey, + environment = environment, + context = context, + ), + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentMediator.kt b/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentMediator.kt index 814cd7935..8d06fb8a0 100644 --- a/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentMediator.kt +++ b/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentMediator.kt @@ -42,7 +42,7 @@ internal class InternalCVVComponentMediator( val internalCVVTokenRequest = InternalCVVTokenRequest( cvv = cvvInputFieldTextValue.value, cardScheme = cvvComponentConfig.cardScheme, - resultHandler = resultHandler + resultHandler = resultHandler, ) cvvTokenizationUseCase.execute(internalCVVTokenRequest) diff --git a/frames/src/main/java/com/checkout/frames/cvvinputfield/usecase/CVVTokenizationUseCase.kt b/frames/src/main/java/com/checkout/frames/cvvinputfield/usecase/CVVTokenizationUseCase.kt index 1aec7618c..ee281d9cc 100644 --- a/frames/src/main/java/com/checkout/frames/cvvinputfield/usecase/CVVTokenizationUseCase.kt +++ b/frames/src/main/java/com/checkout/frames/cvvinputfield/usecase/CVVTokenizationUseCase.kt @@ -10,6 +10,6 @@ internal class CVVTokenizationUseCase( ) : UseCase { override fun execute(data: InternalCVVTokenRequest) = checkoutApiService.createToken( - CVVTokenizationRequest(cvv = data.cvv, cardScheme = data.cardScheme, resultHandler = data.resultHandler) - ) + CVVTokenizationRequest(cvv = data.cvv, cardScheme = data.cardScheme, resultHandler = data.resultHandler), + ) } diff --git a/frames/src/main/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModel.kt b/frames/src/main/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModel.kt index 1029db902..7330bd950 100644 --- a/frames/src/main/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModel.kt @@ -44,9 +44,10 @@ internal class CVVInputFieldViewModel internal constructor( private fun provideViewStyle(inputStyle: InputFieldStyle): InputFieldViewStyle = inputFieldStyleMapper.map(inputStyle).copy( keyboardOptions = KeyboardOptions( - keyboardType = KeyboardType.Number, imeAction = ImeAction.Done + keyboardType = KeyboardType.Number, + imeAction = ImeAction.Done, ), - forceLTR = false + forceLTR = false, ) private fun provideViewState(inputFieldStyle: InputFieldStyle): CVVInputFieldState = diff --git a/frames/src/main/java/com/checkout/frames/di/component/FramesDIComponent.kt b/frames/src/main/java/com/checkout/frames/di/component/FramesDIComponent.kt index adabb9ad2..a87f2ae59 100644 --- a/frames/src/main/java/com/checkout/frames/di/component/FramesDIComponent.kt +++ b/frames/src/main/java/com/checkout/frames/di/component/FramesDIComponent.kt @@ -1,24 +1,24 @@ package com.checkout.frames.di.component import com.checkout.base.model.CardScheme -import com.checkout.frames.component.addresssummary.AddressSummaryViewModel import com.checkout.base.usecase.UseCase +import com.checkout.frames.component.addresssummary.AddressSummaryViewModel import com.checkout.frames.component.cardholdername.CardHolderNameViewModel import com.checkout.frames.component.cardnumber.CardNumberViewModel import com.checkout.frames.component.cardscheme.CardSchemeViewModel import com.checkout.frames.component.country.CountryViewModel -import com.checkout.frames.component.expirydate.ExpiryDateViewModel import com.checkout.frames.component.cvv.CvvViewModel +import com.checkout.frames.component.expirydate.ExpiryDateViewModel import com.checkout.frames.component.paybutton.PayButtonViewModel import com.checkout.frames.di.CLOSE_PAYMENT_FLOW_DI import com.checkout.frames.di.module.PaymentModule -import com.checkout.frames.di.module.ValidationModule import com.checkout.frames.di.module.StylesModule +import com.checkout.frames.di.module.ValidationModule +import com.checkout.frames.model.request.InternalCardTokenRequest import com.checkout.frames.screen.billingaddress.billingaddressdetails.BillingAddressDetailsViewModel import com.checkout.frames.screen.countrypicker.CountryPickerViewModel import com.checkout.frames.screen.paymentdetails.PaymentDetailsViewModel import com.checkout.frames.screen.paymentform.PaymentFormViewModel -import com.checkout.frames.model.request.InternalCardTokenRequest import com.checkout.frames.screen.paymentform.model.PrefillData import com.checkout.logging.Logger import com.checkout.logging.model.LoggingEvent @@ -56,7 +56,7 @@ internal abstract class FramesDIComponent { @BindsInstance fun closePaymentFlowUseCase( @Named(CLOSE_PAYMENT_FLOW_DI) - closePaymentFlowUseCase: UseCase + closePaymentFlowUseCase: UseCase, ): Builder @BindsInstance diff --git a/frames/src/main/java/com/checkout/frames/di/injector/FramesInjector.kt b/frames/src/main/java/com/checkout/frames/di/injector/FramesInjector.kt index 675227cea..8e8be319c 100644 --- a/frames/src/main/java/com/checkout/frames/di/injector/FramesInjector.kt +++ b/frames/src/main/java/com/checkout/frames/di/injector/FramesInjector.kt @@ -5,10 +5,12 @@ import com.checkout.CheckoutApiServiceFactory import com.checkout.base.model.CardScheme import com.checkout.base.model.Environment import com.checkout.frames.BuildConfig +import com.checkout.frames.api.PaymentFlowHandler import com.checkout.frames.component.addresssummary.AddressSummaryViewModel +import com.checkout.frames.component.cardholdername.CardHolderNameViewModel import com.checkout.frames.component.cardnumber.CardNumberViewModel -import com.checkout.frames.component.country.CountryViewModel import com.checkout.frames.component.cardscheme.CardSchemeViewModel +import com.checkout.frames.component.country.CountryViewModel import com.checkout.frames.component.cvv.CvvViewModel import com.checkout.frames.component.expirydate.ExpiryDateViewModel import com.checkout.frames.component.paybutton.PayButtonViewModel @@ -21,8 +23,6 @@ import com.checkout.frames.screen.billingaddress.billingaddressdetails.BillingAd import com.checkout.frames.screen.countrypicker.CountryPickerViewModel import com.checkout.frames.screen.paymentdetails.PaymentDetailsViewModel import com.checkout.frames.screen.paymentform.PaymentFormViewModel -import com.checkout.frames.api.PaymentFlowHandler -import com.checkout.frames.component.cardholdername.CardHolderNameViewModel import com.checkout.frames.screen.paymentform.model.PrefillData import com.checkout.frames.usecase.CardTokenizationUseCase import com.checkout.frames.usecase.ClosePaymentFlowUseCase @@ -56,7 +56,7 @@ internal class FramesInjector(private val component: FramesDIComponent) : Inject environment: Environment, paymentFlowHandler: PaymentFlowHandler, supportedCardSchemeList: List = emptyList(), - prefillData: PrefillData? = null + prefillData: PrefillData? = null, ): Injector { val logger = EventLoggerProvider.provide().apply { setup(context, environment, BuildConfig.LOGGING_IDENTIFIER, BuildConfig.PRODUCT_VERSION) @@ -67,7 +67,7 @@ internal class FramesInjector(private val component: FramesDIComponent) : Inject CheckoutApiServiceFactory.create(publicKey, environment, context), paymentFlowHandler::onSubmit, paymentFlowHandler::onSuccess, - paymentFlowHandler::onFailure + paymentFlowHandler::onFailure, ) return FramesInjector( DaggerFramesDIComponent.builder() @@ -76,7 +76,7 @@ internal class FramesInjector(private val component: FramesDIComponent) : Inject .closePaymentFlowUseCase(closePaymentFlowUseCase) .supportedCardSchemes(supportedCardSchemeList) .prefillData(prefillData) - .build() + .build(), ) } } diff --git a/frames/src/main/java/com/checkout/frames/di/module/AddressSummaryModule.kt b/frames/src/main/java/com/checkout/frames/di/module/AddressSummaryModule.kt index 0b49101dd..9181c230c 100644 --- a/frames/src/main/java/com/checkout/frames/di/module/AddressSummaryModule.kt +++ b/frames/src/main/java/com/checkout/frames/di/module/AddressSummaryModule.kt @@ -35,13 +35,13 @@ internal class AddressSummaryModule { textLabelMapper: Mapper, dividerMapper: Mapper, buttonMapper: Mapper, - containerMapper: Mapper + containerMapper: Mapper, ): Mapper = AddressSummarySectionStyleToViewStyleMapper( textLabelMapper, dividerMapper, buttonMapper, - containerMapper + containerMapper, ) @Provides @@ -49,23 +49,23 @@ internal class AddressSummaryModule { textLabelMapper: Mapper, buttonMapper: Mapper, summarySectionMapper: Mapper, - containerMapper: Mapper + containerMapper: Mapper, ): Mapper = AddressSummaryComponentStyleToViewStyleMapper( textLabelMapper, buttonMapper, summarySectionMapper, - containerMapper + containerMapper, ) @Provides fun provideAddressSummaryComponentStateMapper( textLabelStateMapper: Mapper, - internalButtonStateMapper: Mapper + internalButtonStateMapper: Mapper, ): Mapper = AddressSummaryComponentStyleToStateMapper( textLabelStateMapper, - internalButtonStateMapper + internalButtonStateMapper, ) } } diff --git a/frames/src/main/java/com/checkout/frames/di/module/BillingAddressDetailsModule.kt b/frames/src/main/java/com/checkout/frames/di/module/BillingAddressDetailsModule.kt index 91c5fd5b4..e1ae84b8d 100644 --- a/frames/src/main/java/com/checkout/frames/di/module/BillingAddressDetailsModule.kt +++ b/frames/src/main/java/com/checkout/frames/di/module/BillingAddressDetailsModule.kt @@ -3,8 +3,8 @@ package com.checkout.frames.di.module import com.checkout.base.mapper.Mapper import com.checkout.base.usecase.UseCase import com.checkout.frames.component.base.InputComponentState -import com.checkout.frames.component.billingaddressfields.BillingAddressInputComponentsContainerState import com.checkout.frames.component.billingaddressfields.BillingAddressInputComponentState +import com.checkout.frames.component.billingaddressfields.BillingAddressInputComponentsContainerState import com.checkout.frames.mapper.billingaddressdetails.BillingAddressInputComponentStyleToStateMapper import com.checkout.frames.mapper.billingaddressdetails.BillingAddressInputComponentStyleToViewStyleMapper import com.checkout.frames.screen.billingaddress.usecase.BillingAddressInputComponentStateUseCase @@ -29,21 +29,21 @@ internal class BillingAddressDetailsModule { @Provides fun provideBillingAddressInputComponentsStateMapper( - inputComponentStateMapper: Mapper + inputComponentStateMapper: Mapper, ): Mapper = BillingAddressInputComponentStyleToStateMapper(inputComponentStateMapper) @Provides fun provideBillingAddressInputComponentsStateUseCase( billingAddressInputComponentStateMapper: - Mapper + Mapper, ): UseCase = BillingAddressInputComponentStateUseCase(billingAddressInputComponentStateMapper) @Provides fun provideBillingAddressInputComponentsStyleUseCase( billingAddressInputComponentStyleMapper: - Mapper + Mapper, ): UseCase = BillingAddressInputComponentStyleUseCase(billingAddressInputComponentStyleMapper) } diff --git a/frames/src/main/java/com/checkout/frames/di/module/CardSchemeModule.kt b/frames/src/main/java/com/checkout/frames/di/module/CardSchemeModule.kt index bee45631b..0d4be43e7 100644 --- a/frames/src/main/java/com/checkout/frames/di/module/CardSchemeModule.kt +++ b/frames/src/main/java/com/checkout/frames/di/module/CardSchemeModule.kt @@ -20,13 +20,13 @@ internal class CardSchemeModule { @Provides fun provideCardSchemeComponentStyleMapper( textLabelStyleMapper: Mapper, - containerMapper: Mapper + containerMapper: Mapper, ): Mapper = CardSchemeComponentStyleToViewStyleMapper(textLabelStyleMapper, containerMapper) @Provides fun provideCardSchemeComponentStateMapper( - textLabelMapper: Mapper + textLabelMapper: Mapper, ): Mapper = CardSchemeComponentStyleToStateMapper(textLabelMapper) } diff --git a/frames/src/main/java/com/checkout/frames/di/module/PaymentModule.kt b/frames/src/main/java/com/checkout/frames/di/module/PaymentModule.kt index 64c7098fa..73e0da72c 100644 --- a/frames/src/main/java/com/checkout/frames/di/module/PaymentModule.kt +++ b/frames/src/main/java/com/checkout/frames/di/module/PaymentModule.kt @@ -1,11 +1,11 @@ package com.checkout.frames.di.module import com.checkout.base.model.CardScheme -import com.checkout.frames.di.component.CardSchemeViewModelSubComponent import com.checkout.frames.di.component.AddressSummaryViewModelSubComponent import com.checkout.frames.di.component.BillingFormViewModelSubComponent import com.checkout.frames.di.component.CardHolderNameViewModelSubComponent import com.checkout.frames.di.component.CardNumberViewModelSubComponent +import com.checkout.frames.di.component.CardSchemeViewModelSubComponent import com.checkout.frames.di.component.CountryPickerViewModelSubComponent import com.checkout.frames.di.component.CountryViewModelSubComponent import com.checkout.frames.di.component.CvvViewModelSubComponent @@ -30,20 +30,21 @@ import javax.inject.Singleton CountryPickerViewModelSubComponent::class, BillingFormViewModelSubComponent::class, CardSchemeViewModelSubComponent::class, - AddressSummaryViewModelSubComponent::class - ] + AddressSummaryViewModelSubComponent::class, + ], ) - internal class PaymentModule { companion object { @Provides @Singleton fun paymentStateManager( supportedCardSchemes: List, - prefillData: PrefillData? + prefillData: PrefillData?, ): PaymentStateManager = PaymentFormStateManager( - supportedCardSchemes, prefillData, BillingFormAddressToBillingAddressMapper.INSTANCE + supportedCardSchemes, + prefillData, + BillingFormAddressToBillingAddressMapper.INSTANCE, ) } } diff --git a/frames/src/main/java/com/checkout/frames/di/module/StylesModule.kt b/frames/src/main/java/com/checkout/frames/di/module/StylesModule.kt index 797ce419d..6988f245a 100644 --- a/frames/src/main/java/com/checkout/frames/di/module/StylesModule.kt +++ b/frames/src/main/java/com/checkout/frames/di/module/StylesModule.kt @@ -25,11 +25,11 @@ import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper import com.checkout.frames.mapper.TextLabelStyleToStateMapper import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper +import com.checkout.frames.style.component.base.ButtonStyle import com.checkout.frames.style.component.base.ContainerStyle -import com.checkout.frames.style.component.base.TextLabelStyle import com.checkout.frames.style.component.base.InputComponentStyle import com.checkout.frames.style.component.base.InputFieldStyle -import com.checkout.frames.style.component.base.ButtonStyle +import com.checkout.frames.style.component.base.TextLabelStyle import com.checkout.frames.style.view.InputComponentViewStyle import com.checkout.frames.style.view.InputFieldViewStyle import com.checkout.frames.style.view.InternalButtonViewStyle @@ -51,8 +51,8 @@ import dagger.Provides CountryPickerViewModelSubComponent::class, BillingFormViewModelSubComponent::class, AddressSummaryViewModelSubComponent::class, - PayButtonViewModelSubComponent::class - ] + PayButtonViewModelSubComponent::class, + ], ) internal abstract class StylesModule { @@ -76,50 +76,51 @@ internal abstract class StylesModule { @Provides fun provideTextLabelStyleToStateMapper( - imageMapper: ImageStyleToComposableImageMapper + imageMapper: ImageStyleToComposableImageMapper, ): Mapper = TextLabelStyleToStateMapper(imageMapper) @Provides fun provideInputFieldStyleToStateMapper( - imageMapper: ImageStyleToComposableImageMapper + imageMapper: ImageStyleToComposableImageMapper, ): Mapper = InputFieldStyleToInputFieldStateMapper(imageMapper) @Provides fun provideInputComponentStyleToStateMapper( textLabelMapper: Mapper, - inputFieldStateMapper: Mapper + inputFieldStateMapper: Mapper, ): Mapper = InputComponentStyleToStateMapper(textLabelMapper, inputFieldStateMapper) @Provides fun provideInputFieldStyleToViewStyleMapper( - textLabelStyleMapper: Mapper + textLabelStyleMapper: Mapper, ): Mapper = InputFieldStyleToViewStyleMapper(textLabelStyleMapper) @Provides fun provideTextLabelStyleToViewStyleMapper( - containerMapper: Mapper + containerMapper: Mapper, ): Mapper = TextLabelStyleToViewStyleMapper(containerMapper) @Provides fun provideInputComponentStyleMapper( textLabelStyleMapper: Mapper, inputFieldStyleMapper: Mapper, - containerMapper: Mapper + containerMapper: Mapper, ): Mapper = InputComponentStyleToViewStyleMapper(textLabelStyleMapper, inputFieldStyleMapper, containerMapper) @Provides fun provideButtonStyleMapper( textLabelStyleMapper: Mapper, - containerMapper: Mapper + containerMapper: Mapper, ): Mapper = ButtonStyleToInternalViewStyleMapper( - containerMapper, textLabelStyleMapper + containerMapper, + textLabelStyleMapper, ) @Provides fun provideButtonStateMapper( - textLabelStateMapper: Mapper + textLabelStateMapper: Mapper, ): Mapper = ButtonStyleToInternalStateMapper(textLabelStateMapper) } } diff --git a/frames/src/main/java/com/checkout/frames/di/module/ValidationModule.kt b/frames/src/main/java/com/checkout/frames/di/module/ValidationModule.kt index 7ce969ef1..0db0787a6 100644 --- a/frames/src/main/java/com/checkout/frames/di/module/ValidationModule.kt +++ b/frames/src/main/java/com/checkout/frames/di/module/ValidationModule.kt @@ -20,7 +20,7 @@ internal abstract class ValidationModule { @Provides fun provideValidateExpiryDateUseCase(cardValidator: CardValidator): - UseCase> = + UseCase> = SmartExpiryDateValidationUseCase(cardValidator) } } diff --git a/frames/src/main/java/com/checkout/frames/logging/BillingFormEventType.kt b/frames/src/main/java/com/checkout/frames/logging/BillingFormEventType.kt index 73e8e55fd..57c425be5 100644 --- a/frames/src/main/java/com/checkout/frames/logging/BillingFormEventType.kt +++ b/frames/src/main/java/com/checkout/frames/logging/BillingFormEventType.kt @@ -5,5 +5,5 @@ import com.checkout.logging.LoggingEventType internal enum class BillingFormEventType(override val eventId: String) : LoggingEventType { PRESENTED("billing_form_presented"), SUBMIT("billing_form_submit"), - CANCELED("billing_form_cancelled") + CANCELED("billing_form_cancelled"), } diff --git a/frames/src/main/java/com/checkout/frames/logging/PaymentFormEventType.kt b/frames/src/main/java/com/checkout/frames/logging/PaymentFormEventType.kt index a1a7ceb87..472f4e5ae 100644 --- a/frames/src/main/java/com/checkout/frames/logging/PaymentFormEventType.kt +++ b/frames/src/main/java/com/checkout/frames/logging/PaymentFormEventType.kt @@ -6,5 +6,5 @@ internal enum class PaymentFormEventType(override val eventId: String) : Logging INITIALISED("payment_form_initialised"), PRESENTED("payment_form_presented"), SUBMITTED("payment_form_submitted"), - CANCELED("payment_form_cancelled") + CANCELED("payment_form_cancelled"), } diff --git a/frames/src/main/java/com/checkout/frames/mapper/BillingFormAddressToBillingAddressMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/BillingFormAddressToBillingAddressMapper.kt index cdd4848e5..eb747d15d 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/BillingFormAddressToBillingAddressMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/BillingFormAddressToBillingAddressMapper.kt @@ -7,7 +7,9 @@ import com.checkout.frames.screen.paymentform.model.BillingFormAddress internal class BillingFormAddressToBillingAddressMapper : Mapper { override fun map(from: BillingFormAddress?) = BillingAddress( - name = from?.name, phone = from?.phone, address = from?.address + name = from?.name, + phone = from?.phone, + address = from?.address, ) internal companion object { diff --git a/frames/src/main/java/com/checkout/frames/mapper/ButtonStyleToInternalStateMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/ButtonStyleToInternalStateMapper.kt index eec6310fe..721256709 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/ButtonStyleToInternalStateMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/ButtonStyleToInternalStateMapper.kt @@ -7,10 +7,10 @@ import com.checkout.frames.view.InternalButtonState import com.checkout.frames.view.TextLabelState internal class ButtonStyleToInternalStateMapper( - private val textLabelMapper: Mapper + private val textLabelMapper: Mapper, ) : Mapper { override fun map(from: ButtonStyle): InternalButtonState = InternalButtonState( - textState = textLabelMapper.map(from.textStyle) + textState = textLabelMapper.map(from.textStyle), ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/ButtonStyleToInternalViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/ButtonStyleToInternalViewStyleMapper.kt index efa820c5f..97a000f18 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/ButtonStyleToInternalViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/ButtonStyleToInternalViewStyleMapper.kt @@ -15,7 +15,7 @@ import com.checkout.frames.utils.extensions.toPaddingValues internal class ButtonStyleToInternalViewStyleMapper( private val containerMapper: Mapper, - private val textLabelMapper: Mapper + private val textLabelMapper: Mapper, ) : Mapper { override fun map(from: ButtonStyle): InternalButtonViewStyle = InternalButtonViewStyle( @@ -32,6 +32,6 @@ internal class ButtonStyleToInternalViewStyleMapper( shape = from.shape.toComposeShape(from.cornerRadius), border = from.borderStroke?.toComposeStroke(), contentPadding = from.contentPadding.toPaddingValues(), - textStyle = textLabelMapper.map(from.textStyle) + textStyle = textLabelMapper.map(from.textStyle), ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/CardSchemeComponentStyleToStateMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/CardSchemeComponentStyleToStateMapper.kt index 5d82d8d59..2923aeb93 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/CardSchemeComponentStyleToStateMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/CardSchemeComponentStyleToStateMapper.kt @@ -7,7 +7,7 @@ import com.checkout.frames.style.component.base.TextLabelStyle import com.checkout.frames.view.TextLabelState internal class CardSchemeComponentStyleToStateMapper( - private val textLabelMapper: Mapper + private val textLabelMapper: Mapper, ) : Mapper { override fun map(from: CardSchemeComponentStyle): CardSchemeComponentState { diff --git a/frames/src/main/java/com/checkout/frames/mapper/CardSchemeComponentStyleToViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/CardSchemeComponentStyleToViewStyleMapper.kt index cd92ac8eb..db15ecfc3 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/CardSchemeComponentStyleToViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/CardSchemeComponentStyleToViewStyleMapper.kt @@ -14,7 +14,7 @@ import com.checkout.frames.style.view.TextLabelViewStyle internal class CardSchemeComponentStyleToViewStyleMapper( private val textLabelStyleMapper: Mapper, - private val containerMapper: Mapper + private val containerMapper: Mapper, ) : Mapper { override fun map(from: CardSchemeComponentStyle) = CardSchemeComponentViewStyle( @@ -30,7 +30,7 @@ internal class CardSchemeComponentStyleToViewStyleMapper( FlowRowViewStyle( mainAxisSpacing.dp, crossAxisSpacing.dp, - containerMapper.map(containerStyle).fillMaxWidth() + containerMapper.map(containerStyle).fillMaxWidth(), ) } } diff --git a/frames/src/main/java/com/checkout/frames/mapper/ContainerStyleToModifierMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/ContainerStyleToModifierMapper.kt index e6dc38942..112d7ee84 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/ContainerStyleToModifierMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/ContainerStyleToModifierMapper.kt @@ -27,7 +27,7 @@ internal class ContainerStyleToModifierMapper : Mapper modifier = modifier.background( color = Color(color), - shape = composeShape + shape = composeShape, ) borderStroke?.let { modifier = modifier.border(it.toComposeStroke(), composeShape) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/DividerStyleToViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/DividerStyleToViewStyleMapper.kt index aac175377..b7a2fcc8b 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/DividerStyleToViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/DividerStyleToViewStyleMapper.kt @@ -18,7 +18,7 @@ internal class DividerStyleToViewStyleMapper : Mapper, - private val inputFieldStateMapper: Mapper + private val inputFieldStateMapper: Mapper, ) : Mapper { override fun map(from: InputComponentStyle): InputComponentState { @@ -20,7 +20,7 @@ internal class InputComponentStyleToStateMapper( subtitleState = textLabelMapper.map(from.subtitleStyle), infoState = textLabelMapper.map(from.infoStyle), errorState = textLabelMapper.map(from.errorMessageStyle), - isInputFieldOptional = from.isInputFieldOptional + isInputFieldOptional = from.isInputFieldOptional, ) } } diff --git a/frames/src/main/java/com/checkout/frames/mapper/InputComponentStyleToViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/InputComponentStyleToViewStyleMapper.kt index e528fb4e7..0f4b03be2 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/InputComponentStyleToViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/InputComponentStyleToViewStyleMapper.kt @@ -14,7 +14,7 @@ import com.checkout.frames.style.view.TextLabelViewStyle internal class InputComponentStyleToViewStyleMapper( private val textLabelStyleMapper: Mapper, private val inputFieldStyleMapper: Mapper, - private val containerMapper: Mapper + private val containerMapper: Mapper, ) : Mapper { override fun map(from: InputComponentStyle) = InputComponentViewStyle( @@ -24,6 +24,6 @@ internal class InputComponentStyleToViewStyleMapper( errorMessageStyle = from.errorMessageStyle?.let { textLabelStyleMapper.map(it) } ?: TextLabelViewStyle(), inputFieldStyle = inputFieldStyleMapper.map(from.inputFieldStyle), containerModifier = containerMapper.map(from.containerStyle).fillMaxWidth(), - isInputFieldOptional = from.isInputFieldOptional + isInputFieldOptional = from.isInputFieldOptional, ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/InputFieldStyleToInputFieldStateMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/InputFieldStyleToInputFieldStateMapper.kt index 3e3653d0a..fcc663523 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/InputFieldStyleToInputFieldStateMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/InputFieldStyleToInputFieldStateMapper.kt @@ -8,12 +8,12 @@ import com.checkout.frames.style.component.base.InputFieldStyle import com.checkout.frames.view.InputFieldState internal class InputFieldStyleToInputFieldStateMapper( - private val imageMapper: Mapper Unit)?> + private val imageMapper: Mapper Unit)?>, ) : Mapper { override fun map(from: InputFieldStyle): InputFieldState = InputFieldState( maxLength = mutableStateOf(from.textStyle.maxLength), leadingIcon = mutableStateOf(imageMapper.map(from.leadingIconStyle)), - trailingIcon = mutableStateOf(imageMapper.map(from.trailingIconStyle)) + trailingIcon = mutableStateOf(imageMapper.map(from.trailingIconStyle)), ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/InputFieldStyleToViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/InputFieldStyleToViewStyleMapper.kt index 8214dfe9f..943e8cac2 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/InputFieldStyleToViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/InputFieldStyleToViewStyleMapper.kt @@ -15,11 +15,11 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.checkout.base.mapper.Mapper import com.checkout.frames.model.InputFieldColors -import com.checkout.frames.style.component.base.TextLabelStyle -import com.checkout.frames.style.component.base.InputFieldStyle import com.checkout.frames.style.component.base.ContainerStyle -import com.checkout.frames.style.component.base.TextStyle import com.checkout.frames.style.component.base.InputFieldIndicatorStyle +import com.checkout.frames.style.component.base.InputFieldStyle +import com.checkout.frames.style.component.base.TextLabelStyle +import com.checkout.frames.style.component.base.TextStyle import com.checkout.frames.style.view.InputFieldViewStyle import com.checkout.frames.style.view.TextLabelViewStyle import com.checkout.frames.utils.extensions.disabledIndicatorColor @@ -32,7 +32,7 @@ import com.checkout.frames.view.TextLabel import com.checkout.frames.view.TextLabelState internal class InputFieldStyleToViewStyleMapper( - private val textLabelStyleMapper: Mapper + private val textLabelStyleMapper: Mapper, ) : Mapper { override fun map(from: InputFieldStyle): InputFieldViewStyle = InputFieldViewStyle( @@ -45,7 +45,7 @@ internal class InputFieldStyleToViewStyleMapper( colors = provideColors(from), focusedBorderThickness = provideFocusedBorderThickness(from.indicatorStyle), unfocusedBorderThickness = provideUnfocusedBorderThickness(from.indicatorStyle), - keyboardOptions = from.keyboardOptions + keyboardOptions = from.keyboardOptions, ) @SuppressLint("ModifierFactoryExtensionFunction") @@ -63,7 +63,7 @@ internal class InputFieldStyleToViewStyleMapper( private fun providePlaceholder( placeholderText: String, placeholderTextId: Int?, - placeholderStyle: TextStyle + placeholderStyle: TextStyle, ): @Composable (() -> Unit) = @Composable { TextLabel( @@ -71,14 +71,14 @@ internal class InputFieldStyleToViewStyleMapper( TextLabelStyle( placeholderText, placeholderTextId, - textStyle = placeholderStyle - ) + textStyle = placeholderStyle, + ), ), TextLabelState( mutableStateOf(placeholderText), mutableStateOf(placeholderTextId), - isVisible = mutableStateOf(true) - ) + isVisible = mutableStateOf(true), + ), ) } @@ -108,6 +108,6 @@ internal class InputFieldStyleToViewStyleMapper( cursorColor = style.cursorStyle?.cursorColor?.let { Color(it) }, errorCursorColor = style.cursorStyle?.errorCursorColor?.let { Color(it) }, cursorHandleColor = style.cursorStyle?.cursorHandleColor?.let { Color(it) }, - cursorHighlightColor = style.cursorStyle?.cursorHighlightColor?.let { Color(it) } + cursorHighlightColor = style.cursorStyle?.cursorHighlightColor?.let { Color(it) }, ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/TextLabelStyleToStateMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/TextLabelStyleToStateMapper.kt index 404c9f0b6..7332c28cf 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/TextLabelStyleToStateMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/TextLabelStyleToStateMapper.kt @@ -8,7 +8,7 @@ import com.checkout.frames.style.component.base.TextLabelStyle import com.checkout.frames.view.TextLabelState internal class TextLabelStyleToStateMapper( - private val imageMapper: Mapper Unit)?> + private val imageMapper: Mapper Unit)?>, ) : Mapper { override fun map(from: TextLabelStyle?): TextLabelState = TextLabelState( @@ -16,6 +16,6 @@ internal class TextLabelStyleToStateMapper( textId = mutableStateOf(from?.textId), leadingIcon = mutableStateOf(imageMapper.map(from?.leadingIconStyle)), trailingIcon = mutableStateOf(imageMapper.map(from?.trailingIconStyle)), - isVisible = mutableStateOf(from?.text?.isNotBlank() == true || from?.textId != null) + isVisible = mutableStateOf(from?.text?.isNotBlank() == true || from?.textId != null), ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/TextLabelStyleToViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/TextLabelStyleToViewStyleMapper.kt index 576d5e886..ebb088871 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/TextLabelStyleToViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/TextLabelStyleToViewStyleMapper.kt @@ -8,13 +8,13 @@ import com.checkout.base.mapper.Mapper import com.checkout.frames.style.component.base.ContainerStyle import com.checkout.frames.style.component.base.TextLabelStyle import com.checkout.frames.style.view.TextLabelViewStyle -import com.checkout.frames.utils.extensions.toComposeFontWeight import com.checkout.frames.utils.extensions.toComposeFontStyle +import com.checkout.frames.utils.extensions.toComposeFontWeight import com.checkout.frames.utils.extensions.toComposeTextAlign import com.checkout.frames.utils.extensions.toFontFamily internal class TextLabelStyleToViewStyleMapper( - private val containerMapper: Mapper + private val containerMapper: Mapper, ) : Mapper { override fun map(from: TextLabelStyle): TextLabelViewStyle = TextLabelViewStyle( @@ -26,6 +26,6 @@ internal class TextLabelStyleToViewStyleMapper( fontStyle = from.textStyle.fontStyle.toComposeFontStyle(), fontWeight = from.textStyle.fontWeight.toComposeFontWeight(), maxLines = from.textStyle.maxLines, - lineHeight = from.textStyle.lineHeight?.sp ?: TextUnit.Unspecified + lineHeight = from.textStyle.lineHeight?.sp ?: TextUnit.Unspecified, ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummaryComponentStyleToStateMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummaryComponentStyleToStateMapper.kt index 53a6e8a91..d7127511b 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummaryComponentStyleToStateMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummaryComponentStyleToStateMapper.kt @@ -10,7 +10,7 @@ import com.checkout.frames.view.TextLabelState internal class AddressSummaryComponentStyleToStateMapper( private val textLabelStateMapper: Mapper, - private val buttonStateMapper: Mapper + private val buttonStateMapper: Mapper, ) : Mapper { override fun map(from: AddressSummaryComponentStyle): AddressSummaryComponentState = with(from) { diff --git a/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummaryComponentStyleToViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummaryComponentStyleToViewStyleMapper.kt index 8bf07d247..d835e7164 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummaryComponentStyleToViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummaryComponentStyleToViewStyleMapper.kt @@ -16,7 +16,7 @@ internal class AddressSummaryComponentStyleToViewStyleMapper( private val textLabelMapper: Mapper, private val buttonMapper: Mapper, private val summarySectionMapper: Mapper, - private val containerMapper: Mapper + private val containerMapper: Mapper, ) : Mapper { override fun map(from: AddressSummaryComponentStyle): AddressSummaryComponentViewStyle = with(from) { @@ -25,7 +25,7 @@ internal class AddressSummaryComponentStyleToViewStyleMapper( subTitleStyle = subTitleStyle?.let { textLabelMapper.map(it) }, addAddressButtonStyle = buttonMapper.map(addAddressButtonStyle), summarySectionStyle = summarySectionMapper.map(summarySectionStyle), - modifier = containerMapper.map(containerStyle) + modifier = containerMapper.map(containerStyle), ) } } diff --git a/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummarySectionStyleToViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummarySectionStyleToViewStyleMapper.kt index e00d113b1..a70be9bf5 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummarySectionStyleToViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/addresssummary/AddressSummarySectionStyleToViewStyleMapper.kt @@ -16,7 +16,7 @@ internal class AddressSummarySectionStyleToViewStyleMapper( private val textLabelMapper: Mapper, private val dividerMapper: Mapper, private val buttonMapper: Mapper, - private val containerMapper: Mapper + private val containerMapper: Mapper, ) : Mapper { override fun map(from: AddressSummarySectionStyle): AddressSummarySectionViewStyle = with(from) { @@ -24,7 +24,7 @@ internal class AddressSummarySectionStyleToViewStyleMapper( addressTextStyle = textLabelMapper.map(addressTextStyle), dividerStyle = dividerStyle?.let { dividerMapper.map(dividerStyle) }, editAddressButtonStyle = buttonMapper.map(editAddressButtonStyle), - modifier = containerMapper.map(containerStyle) + modifier = containerMapper.map(containerStyle), ) } } diff --git a/frames/src/main/java/com/checkout/frames/mapper/billingaddressdetails/BillingAddressInputComponentStyleToStateMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/billingaddressdetails/BillingAddressInputComponentStyleToStateMapper.kt index efab86bb5..69ae3190a 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/billingaddressdetails/BillingAddressInputComponentStyleToStateMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/billingaddressdetails/BillingAddressInputComponentStyleToStateMapper.kt @@ -14,6 +14,6 @@ internal class BillingAddressInputComponentStyleToStateMapper( override fun map(from: BillingAddressInputComponentStyle) = BillingAddressInputComponentState( addressFieldName = from.addressFieldName, isAddressFieldValid = MutableStateFlow(from.inputComponentStyle.isInputFieldOptional), - inputComponentState = inputComponentStateMapper.map(from.inputComponentStyle) + inputComponentState = inputComponentStateMapper.map(from.inputComponentStyle), ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/billingaddressdetails/BillingAddressInputComponentStyleToViewStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/billingaddressdetails/BillingAddressInputComponentStyleToViewStyleMapper.kt index 9fad41450..b8c055964 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/billingaddressdetails/BillingAddressInputComponentStyleToViewStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/billingaddressdetails/BillingAddressInputComponentStyleToViewStyleMapper.kt @@ -12,6 +12,6 @@ internal class BillingAddressInputComponentStyleToViewStyleMapper( override fun map(from: BillingAddressInputComponentStyle) = BillingAddressInputComponentViewStyle( addressFieldName = from.addressFieldName, - inputComponentViewStyle = inputComponentStyleMapper.map(from.inputComponentStyle) + inputComponentViewStyle = inputComponentStyleMapper.map(from.inputComponentStyle), ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/theme/BillingFormStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/theme/BillingFormStyleMapper.kt index 735ad8241..375507b41 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/theme/BillingFormStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/theme/BillingFormStyleMapper.kt @@ -17,12 +17,12 @@ import com.checkout.frames.style.theme.PaymentFormComponent import com.checkout.frames.style.theme.PaymentFormComponentField import com.checkout.frames.style.theme.PaymentFormTheme import com.checkout.frames.utils.extensions.provideContainerStyle -import com.checkout.frames.utils.extensions.provideInfoStyle import com.checkout.frames.utils.extensions.provideErrorMessageStyle import com.checkout.frames.utils.extensions.provideIndicatorStyle +import com.checkout.frames.utils.extensions.provideInfoStyle import com.checkout.frames.utils.extensions.provideInputFieldContainerStyle -import com.checkout.frames.utils.extensions.provideSolidButtonStyle import com.checkout.frames.utils.extensions.provideInputFieldStyle +import com.checkout.frames.utils.extensions.provideSolidButtonStyle import com.checkout.frames.utils.extensions.provideSubTitleStyle import com.checkout.frames.utils.extensions.provideTitleStyle @@ -33,15 +33,15 @@ internal class BillingFormStyleMapper : Mapper screenHeaderStyle = screenHeaderStyle.copy( headerTitleStyle = screenHeaderStyle.headerTitleStyle.provideTitleStyle(component, from) - ?: TextLabelStyle() + ?: TextLabelStyle(), ) } headerButtonComponent?.let { component -> screenHeaderStyle = screenHeaderStyle.copy( - headerButtonStyle = screenHeaderStyle.headerButtonStyle.provideSolidButtonStyle(from, component) + headerButtonStyle = screenHeaderStyle.headerButtonStyle.provideSolidButtonStyle(from, component), ) } diff --git a/frames/src/main/java/com/checkout/frames/mapper/theme/PaymentDetailsStyleMapper.kt b/frames/src/main/java/com/checkout/frames/mapper/theme/PaymentDetailsStyleMapper.kt index 1959808f2..70ff478e8 100644 --- a/frames/src/main/java/com/checkout/frames/mapper/theme/PaymentDetailsStyleMapper.kt +++ b/frames/src/main/java/com/checkout/frames/mapper/theme/PaymentDetailsStyleMapper.kt @@ -6,8 +6,8 @@ import com.checkout.frames.model.BorderStroke import com.checkout.frames.model.Margin import com.checkout.frames.model.Padding import com.checkout.frames.style.component.CardHolderNameComponentStyle -import com.checkout.frames.style.component.CardSchemeComponentStyle import com.checkout.frames.style.component.CardNumberComponentStyle +import com.checkout.frames.style.component.CardSchemeComponentStyle import com.checkout.frames.style.component.CvvComponentStyle import com.checkout.frames.style.component.ExpiryDateComponentStyle import com.checkout.frames.style.component.PayButtonComponentStyle @@ -15,26 +15,26 @@ import com.checkout.frames.style.component.ScreenHeaderStyle import com.checkout.frames.style.component.addresssummary.AddressSummaryComponentStyle import com.checkout.frames.style.component.base.ContainerStyle import com.checkout.frames.style.component.base.TextLabelStyle -import com.checkout.frames.style.component.default.DefaultCvvComponentStyle import com.checkout.frames.style.component.default.DefaultAddressSummaryComponentStyle import com.checkout.frames.style.component.default.DefaultCardHolderNameComponentStyle import com.checkout.frames.style.component.default.DefaultCardNumberComponentStyle +import com.checkout.frames.style.component.default.DefaultCvvComponentStyle import com.checkout.frames.style.component.default.DefaultExpiryDateComponentStyle -import com.checkout.frames.style.component.default.DefaultPayButtonComponentStyle import com.checkout.frames.style.component.default.DefaultLightStyle +import com.checkout.frames.style.component.default.DefaultPayButtonComponentStyle import com.checkout.frames.style.screen.PaymentDetailsStyle import com.checkout.frames.style.theme.PaymentFormComponent import com.checkout.frames.style.theme.PaymentFormComponentField import com.checkout.frames.style.theme.PaymentFormTheme -import com.checkout.frames.utils.constants.PaymentDetailsScreenConstants import com.checkout.frames.utils.constants.AddressSummaryConstants import com.checkout.frames.utils.constants.BorderConstants import com.checkout.frames.utils.constants.ContainerConstants -import com.checkout.frames.utils.extensions.provideOutLinedButtonStyle +import com.checkout.frames.utils.constants.PaymentDetailsScreenConstants import com.checkout.frames.utils.extensions.provideContainerStyle import com.checkout.frames.utils.extensions.provideErrorMessageStyle import com.checkout.frames.utils.extensions.provideInfoStyle import com.checkout.frames.utils.extensions.provideInputFieldStyle +import com.checkout.frames.utils.extensions.provideOutLinedButtonStyle import com.checkout.frames.utils.extensions.provideSolidButtonStyle import com.checkout.frames.utils.extensions.provideSubTitleStyle import com.checkout.frames.utils.extensions.provideText @@ -56,9 +56,9 @@ internal class PaymentDetailsStyleMapper : Mapper cardSchemeComponentStyle = cardSchemeComponentStyle.copy( - titleStyle = cardSchemeComponentStyle.titleStyle.provideTitleStyle(component, from) ?: TextLabelStyle() + titleStyle = cardSchemeComponentStyle.titleStyle.provideTitleStyle(component, from) ?: TextLabelStyle(), ) } @@ -91,9 +91,9 @@ internal class PaymentDetailsStyleMapper : Mapper payButtonComponentStyle = payButtonComponentStyle.copy( - buttonStyle = payButtonComponentStyle.buttonStyle.provideSolidButtonStyle(from, component) + buttonStyle = payButtonComponentStyle.buttonStyle.provideSolidButtonStyle(from, component), ) } @@ -286,7 +288,7 @@ internal class PaymentDetailsStyleMapper : Mapper, - private val billingFormStyleMapper: Mapper + private val billingFormStyleMapper: Mapper, ) : Mapper { override fun map(from: PaymentFormTheme) = PaymentFormStyle( paymentDetailsStyleMapper.map(from), - billingFormStyleMapper.map(from) + billingFormStyleMapper.map(from), ) } diff --git a/frames/src/main/java/com/checkout/frames/model/BorderStroke.kt b/frames/src/main/java/com/checkout/frames/model/BorderStroke.kt index 2b524ee7f..182c7dd7d 100644 --- a/frames/src/main/java/com/checkout/frames/model/BorderStroke.kt +++ b/frames/src/main/java/com/checkout/frames/model/BorderStroke.kt @@ -13,5 +13,5 @@ public data class BorderStroke( val width: Int, /** The 32-bit ARGB border color. */ @ColorLong - val color: Long + val color: Long, ) diff --git a/frames/src/main/java/com/checkout/frames/model/ButtonElevation.kt b/frames/src/main/java/com/checkout/frames/model/ButtonElevation.kt index 3f1f743fc..29f3afbef 100644 --- a/frames/src/main/java/com/checkout/frames/model/ButtonElevation.kt +++ b/frames/src/main/java/com/checkout/frames/model/ButtonElevation.kt @@ -5,7 +5,7 @@ public data class ButtonElevation( val pressedElevation: Int = 0, val focusedElevation: Int = 0, val hoveredElevation: Int = 0, - val disabledElevation: Int = 0 + val disabledElevation: Int = 0, ) { public constructor(elevation: Int) : this(elevation, elevation, elevation, elevation, elevation) } diff --git a/frames/src/main/java/com/checkout/frames/model/CornerRadius.kt b/frames/src/main/java/com/checkout/frames/model/CornerRadius.kt index c440c07ab..0ca95e4b9 100644 --- a/frames/src/main/java/com/checkout/frames/model/CornerRadius.kt +++ b/frames/src/main/java/com/checkout/frames/model/CornerRadius.kt @@ -4,7 +4,7 @@ public data class CornerRadius( val topStart: Int = 0, val topEnd: Int = 0, val bottomEnd: Int = 0, - val bottomStart: Int = 0 + val bottomStart: Int = 0, ) { public constructor(radius: Int) : this(radius, radius, radius, radius) } diff --git a/frames/src/main/java/com/checkout/frames/model/InputFieldColors.kt b/frames/src/main/java/com/checkout/frames/model/InputFieldColors.kt index 7c2a36e74..a376082ce 100644 --- a/frames/src/main/java/com/checkout/frames/model/InputFieldColors.kt +++ b/frames/src/main/java/com/checkout/frames/model/InputFieldColors.kt @@ -13,5 +13,5 @@ internal data class InputFieldColors( val cursorColor: Color? = null, val errorCursorColor: Color? = null, val cursorHandleColor: Color? = null, - val cursorHighlightColor: Color? = null + val cursorHighlightColor: Color? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/model/Margin.kt b/frames/src/main/java/com/checkout/frames/model/Margin.kt index d55195787..1bacc5220 100644 --- a/frames/src/main/java/com/checkout/frames/model/Margin.kt +++ b/frames/src/main/java/com/checkout/frames/model/Margin.kt @@ -8,7 +8,7 @@ public data class Margin( /** Start margin in dp. */ val start: Int = 0, /** End margin in dp. */ - val end: Int = 0 + val end: Int = 0, ) { public constructor(margin: Int) : this(margin, margin, margin, margin) } diff --git a/frames/src/main/java/com/checkout/frames/model/Padding.kt b/frames/src/main/java/com/checkout/frames/model/Padding.kt index 9bdfee144..154d488d8 100644 --- a/frames/src/main/java/com/checkout/frames/model/Padding.kt +++ b/frames/src/main/java/com/checkout/frames/model/Padding.kt @@ -8,7 +8,7 @@ public data class Padding( /** Start padding in dp. */ val start: Int = 0, /** End padding in dp. */ - val end: Int = 0 + val end: Int = 0, ) { public constructor(padding: Int) : this(padding, padding, padding, padding) } diff --git a/frames/src/main/java/com/checkout/frames/model/Shape.kt b/frames/src/main/java/com/checkout/frames/model/Shape.kt index f05dc0e16..f29948749 100644 --- a/frames/src/main/java/com/checkout/frames/model/Shape.kt +++ b/frames/src/main/java/com/checkout/frames/model/Shape.kt @@ -5,5 +5,5 @@ public enum class Shape { Circle, RoundCorner, CutCorner, - None + None, } diff --git a/frames/src/main/java/com/checkout/frames/model/TextAlign.kt b/frames/src/main/java/com/checkout/frames/model/TextAlign.kt index 79729ce5d..351fb7e65 100644 --- a/frames/src/main/java/com/checkout/frames/model/TextAlign.kt +++ b/frames/src/main/java/com/checkout/frames/model/TextAlign.kt @@ -6,5 +6,5 @@ package com.checkout.frames.model public enum class TextAlign { Start, Center, - End + End, } diff --git a/frames/src/main/java/com/checkout/frames/model/font/FontStyle.kt b/frames/src/main/java/com/checkout/frames/model/font/FontStyle.kt index 8aacdd1bc..4587eaff1 100644 --- a/frames/src/main/java/com/checkout/frames/model/font/FontStyle.kt +++ b/frames/src/main/java/com/checkout/frames/model/font/FontStyle.kt @@ -2,5 +2,5 @@ package com.checkout.frames.model.font public enum class FontStyle { Normal, - Italic + Italic, } diff --git a/frames/src/main/java/com/checkout/frames/model/font/FontWeight.kt b/frames/src/main/java/com/checkout/frames/model/font/FontWeight.kt index 200fddbcc..4301e7463 100644 --- a/frames/src/main/java/com/checkout/frames/model/font/FontWeight.kt +++ b/frames/src/main/java/com/checkout/frames/model/font/FontWeight.kt @@ -6,5 +6,5 @@ public enum class FontWeight { Medium, SemiBold, Bold, - ExtraBold + ExtraBold, } diff --git a/frames/src/main/java/com/checkout/frames/model/request/ImageStyleToClickableImageRequest.kt b/frames/src/main/java/com/checkout/frames/model/request/ImageStyleToClickableImageRequest.kt index 8f1f262a4..fbe986001 100644 --- a/frames/src/main/java/com/checkout/frames/model/request/ImageStyleToClickableImageRequest.kt +++ b/frames/src/main/java/com/checkout/frames/model/request/ImageStyleToClickableImageRequest.kt @@ -4,5 +4,5 @@ import com.checkout.frames.style.component.base.ImageStyle internal data class ImageStyleToClickableImageRequest( val style: ImageStyle?, - val onImageClick: () -> Unit = {} + val onImageClick: () -> Unit = {}, ) diff --git a/frames/src/main/java/com/checkout/frames/model/request/ImageStyleToDynamicImageRequest.kt b/frames/src/main/java/com/checkout/frames/model/request/ImageStyleToDynamicImageRequest.kt index c902a0c3f..aac9dcc74 100644 --- a/frames/src/main/java/com/checkout/frames/model/request/ImageStyleToDynamicImageRequest.kt +++ b/frames/src/main/java/com/checkout/frames/model/request/ImageStyleToDynamicImageRequest.kt @@ -7,5 +7,5 @@ import kotlinx.coroutines.flow.flowOf internal data class ImageStyleToDynamicImageRequest( val style: ImageStyle?, val dynamicImageId: Flow, - val onImageClick: Flow<(() -> Unit)?> = flowOf(null) + val onImageClick: Flow<(() -> Unit)?> = flowOf(null), ) diff --git a/frames/src/main/java/com/checkout/frames/model/request/InternalCardTokenRequest.kt b/frames/src/main/java/com/checkout/frames/model/request/InternalCardTokenRequest.kt index cc31ce6a2..4c23662c7 100644 --- a/frames/src/main/java/com/checkout/frames/model/request/InternalCardTokenRequest.kt +++ b/frames/src/main/java/com/checkout/frames/model/request/InternalCardTokenRequest.kt @@ -13,5 +13,5 @@ import com.checkout.tokenization.model.Card internal data class InternalCardTokenRequest( val card: Card, val onSuccess: () -> Unit, - val onFailure: () -> Unit + val onFailure: () -> Unit, ) diff --git a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/BillingAddressDetailsScreen.kt b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/BillingAddressDetailsScreen.kt index ab7c9b6cc..fd92be34e 100644 --- a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/BillingAddressDetailsScreen.kt +++ b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/BillingAddressDetailsScreen.kt @@ -34,13 +34,13 @@ internal fun BillingAddressDetailsScreen( style: BillingAddressDetailsStyle, injector: Injector, navController: NavHostController, - onClose: () -> Unit + onClose: () -> Unit, ) { val interactionSource = remember { MutableInteractionSource() } val resetFocus = remember { mutableStateOf(false) } val viewModel: BillingAddressDetailsViewModel = viewModel( - factory = BillingAddressDetailsViewModel.Factory(injector, style) + factory = BillingAddressDetailsViewModel.Factory(injector, style), ) if (viewModel.goBack.value) onClose() @@ -50,21 +50,22 @@ internal fun BillingAddressDetailsScreen( .fillMaxWidth() .fillMaxHeight() .clickable( - interactionSource = interactionSource, indication = null - ) { resetFocus.value = true } + interactionSource = interactionSource, + indication = null, + ) { resetFocus.value = true }, ) { HeaderComponent( screenTitleStyle = viewModel.screenTitleStyle, screenTitleState = viewModel.screenTitleState, screenButtonStyle = viewModel.screenButtonStyle, screenButtonState = viewModel.screenButtonState, - onTapDoneButton = viewModel::onTapDoneButton + onTapDoneButton = viewModel::onTapDoneButton, ) LazyColumn( modifier = viewModel.inputComponentsContainerModifier .fillMaxWidth() - .fillMaxHeight() + .fillMaxHeight(), ) { itemsIndexed(items = viewModel.inputComponentsStateList) { index, state -> if (state.addressFieldName == BillingFormFields.Country.name) { @@ -80,7 +81,7 @@ internal fun BillingAddressDetailsScreen( inputComponentViewStyle = viewModel.inputComponentViewStyleList[index], inputComponentState = state, onFocusChanged = viewModel::onFocusChanged, - onValueChange = viewModel::onAddressFieldTextChange + onValueChange = viewModel::onAddressFieldTextChange, ) } } @@ -99,7 +100,7 @@ private fun HeaderComponent( screenTitleState: TextLabelState, screenButtonStyle: InternalButtonViewStyle, screenButtonState: InternalButtonState, - onTapDoneButton: () -> Unit + onTapDoneButton: () -> Unit, ) { Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) { TextLabel(style = screenTitleStyle, state = screenTitleState) diff --git a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/BillingAddressDetailsViewModel.kt b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/BillingAddressDetailsViewModel.kt index 953f080ef..28ec8eaf9 100644 --- a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/BillingAddressDetailsViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/BillingAddressDetailsViewModel.kt @@ -86,7 +86,7 @@ internal class BillingAddressDetailsViewModel @Inject constructor( } init { - prepare() + prepare() } fun onFocusChanged(position: Int, isFocused: Boolean) { @@ -99,8 +99,11 @@ internal class BillingAddressDetailsViewModel @Inject constructor( } fun onAddressFieldTextChange(position: Int, text: String) = with(inputComponentsStateList[position]) { - val changedTextValue = if (addressFieldName == BillingFormFields.Phone.name) - text.replace(onlyDigitsRegex, "") else text + val changedTextValue = if (addressFieldName == BillingFormFields.Phone.name) { + text.replace(onlyDigitsRegex, "") + } else { + text + } addressFieldText.value = changedTextValue isAddressFieldValid.value = changedTextValue.isNotBlank() || isInputFieldOptional @@ -145,11 +148,11 @@ internal class BillingAddressDetailsViewModel @Inject constructor( } private fun isReadyToSaveAddress(): StateFlow = combine( - inputComponentsStateList.map { it.isAddressFieldValid } + inputComponentsStateList.map { it.isAddressFieldValid }, ) { values -> values.all { it } }.stateIn(MainScope(), SharingStarted.Lazily, false) private fun provideInputComponentViewStyleList( - billingAddressDetailsStyle: BillingAddressDetailsStyle + billingAddressDetailsStyle: BillingAddressDetailsStyle, ): List { return billingAddressDetailsComponentStyleUseCase .execute(billingAddressDetailsStyle) @@ -157,7 +160,7 @@ internal class BillingAddressDetailsViewModel @Inject constructor( } private fun provideInputComponentStateList( - billingAddressDetailsStyle: BillingAddressDetailsStyle + billingAddressDetailsStyle: BillingAddressDetailsStyle, ): List { val inputComponentStateList = billingAddressDetailsComponentStateUseCase .execute(billingAddressDetailsStyle) @@ -169,8 +172,8 @@ internal class BillingAddressDetailsViewModel @Inject constructor( inputComponentStateList[index].inputComponentState = inputComponentStateList[index].inputComponentState.copy( inputFieldState = inputComponentStateList[index].inputComponentState.inputFieldState.copy( - maxLength = mutableStateOf(BillingAddressDetailsConstants.defaultPhoneNumberMaxLength) - ) + maxLength = mutableStateOf(BillingAddressDetailsConstants.defaultPhoneNumberMaxLength), + ), ) } } @@ -187,8 +190,8 @@ internal class BillingAddressDetailsViewModel @Inject constructor( ImageStyleToDynamicImageRequest( style.leadingIconStyle, flowOf(R.drawable.cko_ic_cross_close), - flowOf { onClose() } - ) + flowOf { onClose() }, + ), ) return state @@ -217,7 +220,7 @@ internal class BillingAddressDetailsViewModel @Inject constructor( internal class Factory( private val injector: Injector, - private val style: BillingAddressDetailsStyle + private val style: BillingAddressDetailsStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/models/BillingAddress.kt b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/models/BillingAddress.kt index 68ce3488c..e8a624913 100644 --- a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/models/BillingAddress.kt +++ b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/models/BillingAddress.kt @@ -6,11 +6,11 @@ import com.checkout.tokenization.model.Phone internal data class BillingAddress( val name: String? = null, val address: Address? = null, - val phone: Phone? = null + val phone: Phone? = null, ) { internal constructor() : this( "", - Address("", "", "", "", "") + Address("", "", "", "", ""), ) internal companion object { @@ -18,7 +18,7 @@ internal data class BillingAddress( // Whether the [BillingAddress] has been edited or same as the default one. internal fun BillingAddress.isEdited() = ( - name == DEFAULT_BILLING_ADDRESS.name && + name == DEFAULT_BILLING_ADDRESS.name && address?.addressLine1 == DEFAULT_BILLING_ADDRESS.address?.addressLine1 && address?.addressLine2 == DEFAULT_BILLING_ADDRESS.address?.addressLine2 && address?.city == DEFAULT_BILLING_ADDRESS.address?.city && @@ -26,6 +26,6 @@ internal data class BillingAddress( address?.zip == DEFAULT_BILLING_ADDRESS.address?.zip && address?.country == DEFAULT_BILLING_ADDRESS.address?.country && phone == DEFAULT_BILLING_ADDRESS.phone - ).not() + ).not() } } diff --git a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/models/BillingFormFields.kt b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/models/BillingFormFields.kt index 110771ad9..1c85af673 100644 --- a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/models/BillingFormFields.kt +++ b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressdetails/models/BillingFormFields.kt @@ -20,7 +20,8 @@ public enum class BillingFormFields(internal var isFieldOptional: Boolean = fals State, PostCode, Country, - Phone; + Phone, + ; public companion object { @@ -36,8 +37,8 @@ public enum class BillingFormFields(internal var isFieldOptional: Boolean = fals State.withOptional(true), PostCode.withOptional(false), Country.withOptional(false), - Phone.withOptional(false) - ) + Phone.withOptional(false), + ), ) } } diff --git a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressform/BillingAddressFormScreen.kt b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressform/BillingAddressFormScreen.kt index 63185917c..3a4fa3784 100644 --- a/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressform/BillingAddressFormScreen.kt +++ b/frames/src/main/java/com/checkout/frames/screen/billingaddress/billingaddressform/BillingAddressFormScreen.kt @@ -19,19 +19,19 @@ import com.google.accompanist.navigation.animation.rememberAnimatedNavController internal fun BillingAddressFormScreen( style: BillingFormStyle, injector: Injector, - onClose: () -> Unit + onClose: () -> Unit, ) { val animationDuration = 250 val childNavController = rememberAnimatedNavController() AnimatedNavHost(childNavController, startDestination = Screen.BillingFormDetails.route) { composable( - Screen.BillingFormDetails.route + Screen.BillingFormDetails.route, ) { BillingAddressDetailsScreen( style.billingAddressDetailsStyle, injector, - childNavController + childNavController, ) { onClose() } } composable( @@ -41,11 +41,11 @@ internal fun BillingAddressFormScreen( }, exitTransition = { slideOutOfContainer(AnimatedContentScope.SlideDirection.Down, tween(animationDuration)) - } + }, ) { CountryPickerScreen( style.countryPickerStyle, - injector + injector, ) { childNavController.navigateUp() } diff --git a/frames/src/main/java/com/checkout/frames/screen/billingaddress/usecase/BillingAddressInputComponentStateUseCase.kt b/frames/src/main/java/com/checkout/frames/screen/billingaddress/usecase/BillingAddressInputComponentStateUseCase.kt index 37716424a..bc5dd7553 100644 --- a/frames/src/main/java/com/checkout/frames/screen/billingaddress/usecase/BillingAddressInputComponentStateUseCase.kt +++ b/frames/src/main/java/com/checkout/frames/screen/billingaddress/usecase/BillingAddressInputComponentStateUseCase.kt @@ -2,14 +2,16 @@ package com.checkout.frames.screen.billingaddress.usecase import com.checkout.base.mapper.Mapper import com.checkout.base.usecase.UseCase -import com.checkout.frames.component.billingaddressfields.BillingAddressInputComponentsContainerState import com.checkout.frames.component.billingaddressfields.BillingAddressInputComponentState +import com.checkout.frames.component.billingaddressfields.BillingAddressInputComponentsContainerState import com.checkout.frames.style.component.billingformdetails.BillingAddressInputComponentStyle import com.checkout.frames.style.screen.BillingAddressDetailsStyle internal class BillingAddressInputComponentStateUseCase( - private val billingAddressInputComponentStateMapper: Mapper + private val billingAddressInputComponentStateMapper: Mapper< + BillingAddressInputComponentStyle, + BillingAddressInputComponentState, + >, ) : UseCase { override fun execute(data: BillingAddressDetailsStyle): BillingAddressInputComponentsContainerState { @@ -17,14 +19,14 @@ internal class BillingAddressInputComponentStateUseCase( data.inputComponentsContainerStyle.inputComponentStyleValues.forEach { inputComponentStyleValue -> - inputComponentStateList.add( - billingAddressInputComponentStateMapper.map( - BillingAddressInputComponentStyle( - inputComponentStyleValue.key.name, - inputComponentStyleValue.value - ) - ) - ) + inputComponentStateList.add( + billingAddressInputComponentStateMapper.map( + BillingAddressInputComponentStyle( + inputComponentStyleValue.key.name, + inputComponentStyleValue.value, + ), + ), + ) } return BillingAddressInputComponentsContainerState(inputComponentStateList) diff --git a/frames/src/main/java/com/checkout/frames/screen/billingaddress/usecase/BillingAddressInputComponentStyleUseCase.kt b/frames/src/main/java/com/checkout/frames/screen/billingaddress/usecase/BillingAddressInputComponentStyleUseCase.kt index 61c5fcb51..38c84a8ed 100644 --- a/frames/src/main/java/com/checkout/frames/screen/billingaddress/usecase/BillingAddressInputComponentStyleUseCase.kt +++ b/frames/src/main/java/com/checkout/frames/screen/billingaddress/usecase/BillingAddressInputComponentStyleUseCase.kt @@ -8,8 +8,10 @@ import com.checkout.frames.style.view.BillingAddressInputComponentViewStyle import com.checkout.frames.style.view.billingformdetails.BillingAddressInputComponentsViewContainerStyle internal class BillingAddressInputComponentStyleUseCase( - private val billingAddressInputComponentStyleMapper: Mapper + private val billingAddressInputComponentStyleMapper: Mapper< + BillingAddressInputComponentStyle, + BillingAddressInputComponentViewStyle, + >, ) : UseCase { override fun execute(data: BillingAddressDetailsStyle): BillingAddressInputComponentsViewContainerStyle { @@ -19,8 +21,11 @@ internal class BillingAddressInputComponentStyleUseCase( inputComponentViewStyleList.add( billingAddressInputComponentStyleMapper.map( - BillingAddressInputComponentStyle(inputComponentStyleValue.key.name, inputComponentStyleValue.value) - ) + BillingAddressInputComponentStyle( + inputComponentStyleValue.key.name, + inputComponentStyleValue.value, + ), + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryItem.kt b/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryItem.kt index bf1073455..f4b6b57c8 100644 --- a/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryItem.kt +++ b/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryItem.kt @@ -3,5 +3,5 @@ package com.checkout.frames.screen.countrypicker internal data class CountryItem( val name: String, val emojiFlag: String, - val iso2: String + val iso2: String, ) diff --git a/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryPickerScreen.kt b/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryPickerScreen.kt index db0975f78..038f4c7dd 100644 --- a/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryPickerScreen.kt +++ b/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryPickerScreen.kt @@ -2,19 +2,19 @@ package com.checkout.frames.screen.countrypicker import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.runtime.Composable -import androidx.lifecycle.viewmodel.compose.viewModel -import com.checkout.frames.di.base.Injector -import com.checkout.frames.style.screen.CountryPickerStyle import androidx.compose.foundation.lazy.items +import androidx.compose.runtime.Composable import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalSoftwareKeyboardController +import androidx.lifecycle.viewmodel.compose.viewModel +import com.checkout.frames.di.base.Injector +import com.checkout.frames.style.screen.CountryPickerStyle import com.checkout.frames.style.view.InputFieldViewStyle import com.checkout.frames.style.view.TextLabelViewStyle import com.checkout.frames.view.InputField @@ -27,10 +27,10 @@ import com.checkout.frames.view.TextLabelState internal fun CountryPickerScreen( style: CountryPickerStyle, injector: Injector, - onClose: () -> Unit + onClose: () -> Unit, ) { val viewModel: CountryPickerViewModel = viewModel( - factory = CountryPickerViewModel.Factory(injector, style) + factory = CountryPickerViewModel.Factory(injector, style), ) if (viewModel.goBack.value) { @@ -45,7 +45,7 @@ internal fun CountryPickerScreen( Column( modifier = viewModel.screenModifier .fillMaxWidth() - .fillMaxHeight() + .fillMaxHeight(), ) { HeaderComponent( screenTitleStyle = viewModel.screenTitleStyle, @@ -53,7 +53,7 @@ internal fun CountryPickerScreen( searchFieldStyle = viewModel.searchFieldStyle, searchFieldState = viewModel.searchFieldState, onSearchFocusChange = viewModel::onFocusChanged, - onSearchValueChange = viewModel::onSearchChange + onSearchValueChange = viewModel::onSearchChange, ) LazyColumn { items(viewModel.searchCountries.value) { itemData -> @@ -70,7 +70,7 @@ private fun HeaderComponent( searchFieldStyle: InputFieldViewStyle, searchFieldState: InputFieldState, onSearchFocusChange: (Boolean) -> Unit, - onSearchValueChange: (String) -> Unit + onSearchValueChange: (String) -> Unit, ) { Column { TextLabel(style = screenTitleStyle, state = screenTitleState) @@ -82,7 +82,7 @@ private fun HeaderComponent( private fun CountryItemComponent( labelStyle: TextLabelViewStyle, data: CountryItem, - onClick: (String) -> Unit + onClick: (String) -> Unit, ) { val state = TextLabelState().apply { isVisible.value = true @@ -92,7 +92,7 @@ private fun CountryItemComponent( Row( modifier = Modifier .fillMaxWidth() - .clickable { onClick(data.iso2) } + .clickable { onClick(data.iso2) }, ) { TextLabel(style = labelStyle, state = state) } diff --git a/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryPickerViewModel.kt b/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryPickerViewModel.kt index b91c08c2e..52fa996ba 100644 --- a/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryPickerViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/screen/countrypicker/CountryPickerViewModel.kt @@ -39,7 +39,7 @@ internal class CountryPickerViewModel @Inject constructor( private val textLabelStateMapper: Mapper, containerMapper: Mapper, private val imageMapper: ImageStyleToDynamicComposableImageMapper, - style: CountryPickerStyle + style: CountryPickerStyle, ) : ViewModel() { val screenTitleStyle = textLabelStyleMapper.map(style.screenTitleStyle) @@ -81,8 +81,11 @@ internal class CountryPickerViewModel @Inject constructor( @VisibleForTesting fun onClear() { - if (isInputFocused) onSearchChange("") - else onReset() + if (isInputFocused) { + onSearchChange("") + } else { + onReset() + } } @VisibleForTesting @@ -99,8 +102,8 @@ internal class CountryPickerViewModel @Inject constructor( ImageStyleToDynamicImageRequest( style.leadingIconStyle, flowOf(R.drawable.cko_ic_cross_close), - flowOf { onLeaveScreen() } - ) + flowOf { onLeaveScreen() }, + ), ) return state @@ -113,13 +116,16 @@ internal class CountryPickerViewModel @Inject constructor( ImageStyleToDynamicImageRequest( style.leadingIconStyle, snapshotFlow { isSearchActive.value }.map { - if (it) R.drawable.cko_ic_arrow_back - else R.drawable.cko_ic_search + if (it) { + R.drawable.cko_ic_arrow_back + } else { + R.drawable.cko_ic_search + } }, snapshotFlow { isSearchActive.value }.map { if (it) this::onReset else null - } - ) + }, + ), ) viewState.trailingIcon.value = imageMapper.map( @@ -128,8 +134,8 @@ internal class CountryPickerViewModel @Inject constructor( snapshotFlow { viewState.text.value }.map { if (it.isEmpty()) null else R.drawable.cko_ic_cross_clear }, - flowOf { onClear() } - ) + flowOf { onClear() }, + ), ) return viewState @@ -139,13 +145,13 @@ internal class CountryPickerViewModel @Inject constructor( CountryItem( name = Locale(Locale.getDefault().language, it.iso3166Alpha2).displayCountry, emojiFlag = it.emojiFlag(), - iso2 = it.iso3166Alpha2 + iso2 = it.iso3166Alpha2, ) } internal class Factory( private val injector: Injector, - private val style: CountryPickerStyle + private val style: CountryPickerStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/screen/manager/PaymentFormStateManager.kt b/frames/src/main/java/com/checkout/frames/screen/manager/PaymentFormStateManager.kt index 008630721..65b3106bc 100644 --- a/frames/src/main/java/com/checkout/frames/screen/manager/PaymentFormStateManager.kt +++ b/frames/src/main/java/com/checkout/frames/screen/manager/PaymentFormStateManager.kt @@ -8,16 +8,16 @@ import com.checkout.frames.screen.billingaddress.billingaddressdetails.models.Bi import com.checkout.frames.screen.paymentform.model.BillingFormAddress import com.checkout.frames.screen.paymentform.model.PrefillData import kotlinx.coroutines.MainScope -import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.stateIn internal class PaymentFormStateManager( private val supportedCardSchemes: List, private val paymentFormPrefillData: PrefillData? = null, - private val billingFormAddressToBillingAddressMapper: Mapper + private val billingFormAddressToBillingAddressMapper: Mapper, ) : PaymentStateManager { override val cardNumber: MutableStateFlow = MutableStateFlow("") @@ -37,7 +37,7 @@ internal class PaymentFormStateManager( override val billingAddress: MutableStateFlow = MutableStateFlow(provideBillingFormAddress()) override val selectedCountry: MutableStateFlow = MutableStateFlow( - paymentFormPrefillData?.billingFormAddress?.address?.country + paymentFormPrefillData?.billingFormAddress?.address?.country, ) override val isBillingAddressValid: MutableStateFlow = MutableStateFlow(false) @@ -79,6 +79,10 @@ internal class PaymentFormStateManager( } ?: BillingAddress() private fun provideIsReadyTokenizeFlow(): StateFlow = combine( - isCardNumberValid, isExpiryDateValid, isCardHolderNameValid, isCvvValid, isBillingAddressValid + isCardNumberValid, + isExpiryDateValid, + isCardHolderNameValid, + isCvvValid, + isBillingAddressValid, ) { values -> values.all { it } }.stateIn(MainScope(), SharingStarted.Lazily, false) } diff --git a/frames/src/main/java/com/checkout/frames/screen/manager/PaymentStateManager.kt b/frames/src/main/java/com/checkout/frames/screen/manager/PaymentStateManager.kt index c02cccb58..8c6b0cd6c 100644 --- a/frames/src/main/java/com/checkout/frames/screen/manager/PaymentStateManager.kt +++ b/frames/src/main/java/com/checkout/frames/screen/manager/PaymentStateManager.kt @@ -30,6 +30,7 @@ internal interface PaymentStateManager { val billingAddress: MutableStateFlow val selectedCountry: MutableStateFlow val isBillingAddressValid: MutableStateFlow + // Whether the billing address form is enabled or set to null val isBillingAddressEnabled: MutableStateFlow diff --git a/frames/src/main/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsScreen.kt b/frames/src/main/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsScreen.kt index 5f69d612a..1b8090298 100644 --- a/frames/src/main/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsScreen.kt +++ b/frames/src/main/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsScreen.kt @@ -3,14 +3,14 @@ package com.checkout.frames.screen.paymentdetails import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.remember import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -32,12 +32,12 @@ import com.checkout.frames.view.TextLabel internal fun PaymentDetailsScreen( style: PaymentDetailsStyle, injector: Injector, - navController: NavController + navController: NavController, ) { val interactionSource = remember { MutableInteractionSource() } val resetFocus = remember { mutableStateOf(false) } val viewModel: PaymentDetailsViewModel = viewModel( - factory = PaymentDetailsViewModel.Factory(injector, style) + factory = PaymentDetailsViewModel.Factory(injector, style), ) val lifecycleOwner = LocalLifecycleOwner.current @@ -50,9 +50,9 @@ internal fun PaymentDetailsScreen( object : DefaultLifecycleObserver { override fun onResume(owner: LifecycleOwner) { super.onResume(owner) - viewModel.resetCountrySelection() + viewModel.resetCountrySelection() } - } + }, ) DisposableEffect(lifecycleOwner) { @@ -65,8 +65,9 @@ internal fun PaymentDetailsScreen( Column( modifier = Modifier.clickable( - interactionSource = interactionSource, indication = null - ) { resetFocus.value = true } + interactionSource = interactionSource, + indication = null, + ) { resetFocus.value = true }, ) { TextLabel(style = viewModel.headerStyle, state = viewModel.headerState) @@ -74,7 +75,7 @@ internal fun PaymentDetailsScreen( modifier = viewModel.fieldsContainerModifier .fillMaxWidth() .fillMaxHeight() - .verticalScroll(rememberScrollState()) + .verticalScroll(rememberScrollState()), ) { // Cards schemes viewModel.componentProvider.CardScheme(style = style.cardSchemeStyle) diff --git a/frames/src/main/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsViewModel.kt b/frames/src/main/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsViewModel.kt index 45b7ef776..a6fbeaa05 100644 --- a/frames/src/main/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsViewModel.kt @@ -43,7 +43,7 @@ internal class PaymentDetailsViewModel @Inject constructor( private val closePaymentFlowUseCase: UseCase, private val paymentStateManager: PaymentStateManager, private val logger: Logger, - private val style: PaymentDetailsStyle + private val style: PaymentDetailsStyle, ) : ViewModel() { val headerStyle: TextLabelViewStyle = provideHeaderViewStyle() @@ -59,7 +59,7 @@ internal class PaymentDetailsViewModel @Inject constructor( isCvvValidByDefault, isCardHolderNameValidByDefault, isBillingAddressValidByDefault, - isBillingAddressValidEnabled + isBillingAddressValidEnabled, ) logger.logEventWithLocale(PaymentFormEventType.PRESENTED) } @@ -67,14 +67,14 @@ internal class PaymentDetailsViewModel @Inject constructor( internal fun provideIsCardHolderNameValid(): Boolean { val isCardHolderNamePrefilled = paymentStateManager.cardHolderName.value.isNotBlank() && style.cardHolderNameStyle != null - return isCardHolderNamePrefilled || style.cardHolderNameStyle?.inputStyle?.isInputFieldOptional ?: true + return isCardHolderNamePrefilled || style.cardHolderNameStyle?.inputStyle?.isInputFieldOptional ?: true } internal fun provideIsBillingAddressValid(): Boolean { val isBillingAddressPrefilled = style.addressSummaryStyle != null && - paymentStateManager.billingAddress.value.isEdited() && - paymentStateManager.billingAddress.value.isValid() + paymentStateManager.billingAddress.value.isEdited() && + paymentStateManager.billingAddress.value.isValid() return if (isBillingAddressPrefilled) true else style.addressSummaryStyle?.isOptional ?: true } @@ -87,7 +87,7 @@ internal class PaymentDetailsViewModel @Inject constructor( private fun provideHeaderViewStyle(): TextLabelViewStyle = with(style.paymentDetailsHeaderStyle) { textLabelStyleMapper.map( - TextLabelStyle(text, textId, textStyle, containerStyle = containerStyle) + TextLabelStyle(text, textId, textStyle, containerStyle = containerStyle), ).apply { modifier = modifier.fillMaxWidth() } } @@ -95,7 +95,7 @@ internal class PaymentDetailsViewModel @Inject constructor( val imageRequest = ImageStyleToClickableImageRequest(backIconStyle) { onClose() } textLabelStateMapper.map( - TextLabelStyle(text, textId, textStyle, containerStyle = containerStyle) + TextLabelStyle(text, textId, textStyle, containerStyle = containerStyle), ).apply { leadingIcon.value = clickableImageStyleMapper.map(imageRequest) } } @@ -109,7 +109,7 @@ internal class PaymentDetailsViewModel @Inject constructor( internal class Factory( private val injector: Injector, - private val style: PaymentDetailsStyle + private val style: PaymentDetailsStyle, ) : ViewModelProvider.Factory, InjectionClient { @Inject diff --git a/frames/src/main/java/com/checkout/frames/screen/paymentform/PaymentFormScreen.kt b/frames/src/main/java/com/checkout/frames/screen/paymentform/PaymentFormScreen.kt index 5c201c54e..ccf0e5e48 100644 --- a/frames/src/main/java/com/checkout/frames/screen/paymentform/PaymentFormScreen.kt +++ b/frames/src/main/java/com/checkout/frames/screen/paymentform/PaymentFormScreen.kt @@ -26,8 +26,8 @@ internal fun PaymentFormScreen(config: PaymentFormConfig) { environment = config.environment, paymentFlowHandler = config.paymentFlowHandler, supportedCardSchemes = config.supportedCardSchemeList, - prefillData = config.prefillData - ) + prefillData = config.prefillData, + ), ) AnimatedNavHost(navController, startDestination = Screen.PaymentDetails.route) { @@ -35,7 +35,7 @@ internal fun PaymentFormScreen(config: PaymentFormConfig) { PaymentDetailsScreen( config.style.paymentDetailsStyle, viewModel.injector, - navController + navController, ) } @@ -46,11 +46,11 @@ internal fun PaymentFormScreen(config: PaymentFormConfig) { }, exitTransition = { slideOutOfContainer(AnimatedContentScope.SlideDirection.Right, tween(animationDuration)) - } + }, ) { BillingAddressFormScreen( config.style.billingFormStyle, - viewModel.injector + viewModel.injector, ) { navController.navigateUp() } diff --git a/frames/src/main/java/com/checkout/frames/screen/paymentform/PaymentFormViewModel.kt b/frames/src/main/java/com/checkout/frames/screen/paymentform/PaymentFormViewModel.kt index 788a60fe2..fad11ff82 100644 --- a/frames/src/main/java/com/checkout/frames/screen/paymentform/PaymentFormViewModel.kt +++ b/frames/src/main/java/com/checkout/frames/screen/paymentform/PaymentFormViewModel.kt @@ -5,10 +5,10 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import com.checkout.base.model.CardScheme import com.checkout.base.model.Environment +import com.checkout.frames.api.PaymentFlowHandler import com.checkout.frames.di.base.InjectionClient import com.checkout.frames.di.base.Injector import com.checkout.frames.di.injector.FramesInjector -import com.checkout.frames.api.PaymentFlowHandler import com.checkout.frames.screen.paymentform.model.PrefillData import javax.inject.Inject @@ -22,7 +22,7 @@ internal class PaymentFormViewModel @Inject internal constructor() : ViewModel() private val environment: Environment, private val paymentFlowHandler: PaymentFlowHandler, private val supportedCardSchemes: List = emptyList(), - private val prefillData: PrefillData? = null + private val prefillData: PrefillData? = null, ) : ViewModelProvider.Factory, InjectionClient { @Inject @@ -33,7 +33,7 @@ internal class PaymentFormViewModel @Inject internal constructor() : ViewModel() @Suppress("UNCHECKED_CAST") override fun create(modelClass: Class): T { injector = FramesInjector.create( - publicKey, context, environment, paymentFlowHandler, supportedCardSchemes, prefillData + publicKey, context, environment, paymentFlowHandler, supportedCardSchemes, prefillData, ) injector.inject(this) diff --git a/frames/src/main/java/com/checkout/frames/screen/paymentform/model/PaymentFormConfig.kt b/frames/src/main/java/com/checkout/frames/screen/paymentform/model/PaymentFormConfig.kt index e2f2559b8..99c3a0e51 100644 --- a/frames/src/main/java/com/checkout/frames/screen/paymentform/model/PaymentFormConfig.kt +++ b/frames/src/main/java/com/checkout/frames/screen/paymentform/model/PaymentFormConfig.kt @@ -3,8 +3,8 @@ package com.checkout.frames.screen.paymentform.model import android.content.Context import com.checkout.base.model.CardScheme import com.checkout.base.model.Environment -import com.checkout.frames.style.screen.PaymentFormStyle import com.checkout.frames.api.PaymentFlowHandler +import com.checkout.frames.style.screen.PaymentFormStyle /** * @param publicKey - used for client-side authentication in the SDK @@ -22,5 +22,5 @@ public data class PaymentFormConfig @JvmOverloads constructor( public var style: PaymentFormStyle, public val paymentFlowHandler: PaymentFlowHandler, public var supportedCardSchemeList: List = emptyList(), - public val prefillData: PrefillData? = null + public val prefillData: PrefillData? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/screen/paymentform/model/PrefillData.kt b/frames/src/main/java/com/checkout/frames/screen/paymentform/model/PrefillData.kt index 831c576de..c73b81057 100644 --- a/frames/src/main/java/com/checkout/frames/screen/paymentform/model/PrefillData.kt +++ b/frames/src/main/java/com/checkout/frames/screen/paymentform/model/PrefillData.kt @@ -6,5 +6,5 @@ package com.checkout.frames.screen.paymentform.model */ public data class PrefillData @JvmOverloads constructor( public val cardHolderName: String? = null, - public val billingFormAddress: BillingFormAddress? = null + public val billingFormAddress: BillingFormAddress? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/CardHolderNameComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/CardHolderNameComponentStyle.kt index 888221790..dd9f5d77b 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/CardHolderNameComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/CardHolderNameComponentStyle.kt @@ -3,5 +3,5 @@ package com.checkout.frames.style.component import com.checkout.frames.style.component.base.InputComponentStyle public data class CardHolderNameComponentStyle( - var inputStyle: InputComponentStyle = InputComponentStyle() + var inputStyle: InputComponentStyle = InputComponentStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/CardNumberComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/CardNumberComponentStyle.kt index fb379feec..5d5cbc2fb 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/CardNumberComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/CardNumberComponentStyle.kt @@ -5,5 +5,5 @@ import com.checkout.frames.utils.constants.CARD_NUMBER_SEPARATOR public data class CardNumberComponentStyle @JvmOverloads constructor( var inputStyle: InputComponentStyle = InputComponentStyle(), - var cardNumberSeparator: Char = CARD_NUMBER_SEPARATOR + var cardNumberSeparator: Char = CARD_NUMBER_SEPARATOR, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/CardSchemeComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/CardSchemeComponentStyle.kt index 31d108555..74dab6e6d 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/CardSchemeComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/CardSchemeComponentStyle.kt @@ -9,5 +9,5 @@ public data class CardSchemeComponentStyle @JvmOverloads constructor( val titleStyle: TextLabelStyle = TextLabelStyle(), val imageStyle: ImageStyle? = null, val containerStyle: ContainerStyle = ContainerStyle(), - val imageContainerStyle: ImageContainerStyle = ImageContainerStyle() + val imageContainerStyle: ImageContainerStyle = ImageContainerStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/CountryComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/CountryComponentStyle.kt index 21c15af89..7c39d4ade 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/CountryComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/CountryComponentStyle.kt @@ -3,5 +3,5 @@ package com.checkout.frames.style.component import com.checkout.frames.style.component.base.InputComponentStyle public data class CountryComponentStyle @JvmOverloads constructor( - var inputStyle: InputComponentStyle = InputComponentStyle() + var inputStyle: InputComponentStyle = InputComponentStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/CvvComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/CvvComponentStyle.kt index c44491fc7..8cf5b3b67 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/CvvComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/CvvComponentStyle.kt @@ -3,5 +3,5 @@ package com.checkout.frames.style.component import com.checkout.frames.style.component.base.InputComponentStyle public data class CvvComponentStyle( - var inputStyle: InputComponentStyle = InputComponentStyle() + var inputStyle: InputComponentStyle = InputComponentStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/ExpiryDateComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/ExpiryDateComponentStyle.kt index 99ef303f0..8b6bbf3e0 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/ExpiryDateComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/ExpiryDateComponentStyle.kt @@ -3,5 +3,5 @@ package com.checkout.frames.style.component import com.checkout.frames.style.component.base.InputComponentStyle public data class ExpiryDateComponentStyle( - val inputStyle: InputComponentStyle + val inputStyle: InputComponentStyle, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/PayButtonComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/PayButtonComponentStyle.kt index c2db11269..3f486418d 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/PayButtonComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/PayButtonComponentStyle.kt @@ -3,5 +3,5 @@ package com.checkout.frames.style.component import com.checkout.frames.style.component.base.ButtonStyle public data class PayButtonComponentStyle( - val buttonStyle: ButtonStyle + val buttonStyle: ButtonStyle, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/ScreenHeaderStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/ScreenHeaderStyle.kt index 9599b1bce..87c85e18e 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/ScreenHeaderStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/ScreenHeaderStyle.kt @@ -11,5 +11,5 @@ public data class ScreenHeaderStyle @JvmOverloads constructor( var textId: Int? = null, var textStyle: TextStyle = TextStyle(), public var backIconStyle: ImageStyle = ImageStyle(), - public var containerStyle: ContainerStyle = ContainerStyle() + public var containerStyle: ContainerStyle = ContainerStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/addresssummary/AddressSummaryComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/addresssummary/AddressSummaryComponentStyle.kt index cf51f17e9..8107ffa47 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/addresssummary/AddressSummaryComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/addresssummary/AddressSummaryComponentStyle.kt @@ -12,8 +12,8 @@ public data class AddressSummaryComponentStyle @JvmOverloads constructor( TextLabelStyle(), null, ButtonStyle(), - ContainerStyle() + ContainerStyle(), ), val containerStyle: ContainerStyle = ContainerStyle(), - val isOptional: Boolean = false + val isOptional: Boolean = false, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/addresssummary/AddressSummarySectionStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/addresssummary/AddressSummarySectionStyle.kt index cc3aff43d..9f53082bf 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/addresssummary/AddressSummarySectionStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/addresssummary/AddressSummarySectionStyle.kt @@ -9,5 +9,5 @@ public data class AddressSummarySectionStyle @JvmOverloads constructor( val addressTextStyle: TextLabelStyle, val dividerStyle: DividerStyle? = null, val editAddressButtonStyle: ButtonStyle, - val containerStyle: ContainerStyle + val containerStyle: ContainerStyle, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/ButtonStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/ButtonStyle.kt index 9a6fe899e..bfef71c2d 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/ButtonStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/ButtonStyle.kt @@ -1,11 +1,11 @@ package com.checkout.frames.style.component.base import androidx.annotation.ColorLong -import com.checkout.frames.model.Shape -import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.BorderStroke import com.checkout.frames.model.ButtonElevation +import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.Padding +import com.checkout.frames.model.Shape public data class ButtonStyle @JvmOverloads constructor( /** The 32-bit ARGB container color of this Button when enabled. */ @@ -33,5 +33,5 @@ public data class ButtonStyle @JvmOverloads constructor( /** The text label style. Can be used to set leading and trailing icons. */ val textStyle: TextLabelStyle = TextLabelStyle(), /** Top level button container style. */ - val containerStyle: ContainerStyle = ContainerStyle() + val containerStyle: ContainerStyle = ContainerStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/ContainerStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/ContainerStyle.kt index 8d21c8448..71f8430b4 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/ContainerStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/ContainerStyle.kt @@ -1,11 +1,11 @@ package com.checkout.frames.style.component.base import androidx.annotation.ColorLong +import com.checkout.frames.model.BorderStroke import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.Margin import com.checkout.frames.model.Padding import com.checkout.frames.model.Shape -import com.checkout.frames.model.BorderStroke import com.checkout.frames.utils.constants.ContainerConstants public data class ContainerStyle @JvmOverloads constructor( @@ -28,5 +28,5 @@ public data class ContainerStyle @JvmOverloads constructor( /** Height in dp. */ val height: Int? = null, val padding: Padding? = null, - val margin: Margin? = null + val margin: Margin? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/CursorStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/CursorStyle.kt index f43b9e005..b6d51fd16 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/CursorStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/CursorStyle.kt @@ -13,7 +13,7 @@ public data class CursorStyle( public val cursorHandleColor: Long, /** The 32-bit ARGB color for input field highlighted text. */ @ColorLong - public val cursorHighlightColor: Long + public val cursorHighlightColor: Long, ) { public constructor(cursorColor: Long) : this(cursorColor, cursorColor, cursorColor, cursorColor) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/DividerStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/DividerStyle.kt index 43d300ffc..eff2b02bd 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/DividerStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/DividerStyle.kt @@ -9,5 +9,5 @@ public data class DividerStyle @JvmOverloads constructor( /** The 32-bit ARGB color for divider. */ @ColorLong val color: Long, - val margin: Margin? = null + val margin: Margin? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/ImageContainerStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/ImageContainerStyle.kt index 6094061dd..f0002d4b6 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/ImageContainerStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/ImageContainerStyle.kt @@ -6,5 +6,5 @@ public data class ImageContainerStyle @JvmOverloads constructor( /** The cross axis spacing between the rows of the layout. */ val crossAxisSpacing: Int = 0, /** supported images container style. */ - val containerStyle: ContainerStyle = ContainerStyle() + val containerStyle: ContainerStyle = ContainerStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/ImageStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/ImageStyle.kt index e2fa87f76..6ba79055e 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/ImageStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/ImageStyle.kt @@ -15,5 +15,5 @@ public data class ImageStyle @JvmOverloads constructor( val height: Int? = null, /** Width in dp. */ val width: Int? = null, - val padding: Padding? = null + val padding: Padding? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/InputComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/InputComponentStyle.kt index fa37e217a..fa462ec81 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/InputComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/InputComponentStyle.kt @@ -9,5 +9,5 @@ public data class InputComponentStyle @JvmOverloads constructor( val inputFieldStyle: InputFieldStyle = InputFieldStyle(), val errorMessageStyle: TextLabelStyle? = DefaultTextLabelStyle.error(), val containerStyle: ContainerStyle = ContainerStyle(), - val isInputFieldOptional: Boolean = false + val isInputFieldOptional: Boolean = false, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/InputFieldIndicatorStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/InputFieldIndicatorStyle.kt index fd17efcff..608aa0c28 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/InputFieldIndicatorStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/InputFieldIndicatorStyle.kt @@ -27,7 +27,7 @@ public sealed class InputFieldIndicatorStyle { val disabledBorderColor: Long = BorderConstants.disabledBorderColor, /** The 32-bit ARGB color to create an error border Color from. */ @ColorLong - val errorBorderColor: Long = BorderConstants.errorBorderColor + val errorBorderColor: Long = BorderConstants.errorBorderColor, ) : InputFieldIndicatorStyle() public data class Underline @JvmOverloads constructor( @@ -46,6 +46,6 @@ public sealed class InputFieldIndicatorStyle { val disabledUnderlineColor: Long = UnderlineConstants.disabledUnderlineColor, /** The 32-bit ARGB color to create an error border Color from. */ @ColorLong - val errorUnderlineColor: Long = UnderlineConstants.errorUnderlineColor + val errorUnderlineColor: Long = UnderlineConstants.errorUnderlineColor, ) : InputFieldIndicatorStyle() } diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/InputFieldStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/InputFieldStyle.kt index 6b094350c..e3f5104d0 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/InputFieldStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/InputFieldStyle.kt @@ -14,5 +14,5 @@ public data class InputFieldStyle @JvmOverloads constructor( val leadingIconStyle: ImageStyle? = null, val trailingIconStyle: ImageStyle? = null, val cursorStyle: CursorStyle? = null, - val keyboardOptions: KeyboardOptions = KeyboardOptions.Default + val keyboardOptions: KeyboardOptions = KeyboardOptions.Default, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/TextLabelStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/TextLabelStyle.kt index bac1a8b9f..f1fcb3557 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/TextLabelStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/TextLabelStyle.kt @@ -9,5 +9,5 @@ public data class TextLabelStyle @JvmOverloads constructor( var textStyle: TextStyle = TextStyle(), var leadingIconStyle: ImageStyle? = null, var trailingIconStyle: ImageStyle? = null, - var containerStyle: ContainerStyle = ContainerStyle() + var containerStyle: ContainerStyle = ContainerStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/base/TextStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/base/TextStyle.kt index b7996e20a..a67a4cca8 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/base/TextStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/base/TextStyle.kt @@ -28,5 +28,5 @@ public data class TextStyle @JvmOverloads constructor( /** Optional maximum symbols limit. Applicable for editable text fields. */ val maxLength: Int? = null, /** Line height in sp. **/ - var lineHeight: Int? = null + var lineHeight: Int? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/BillingAddressInputComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/BillingAddressInputComponentStyle.kt index 0afeacda2..47f5e3cf5 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/BillingAddressInputComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/BillingAddressInputComponentStyle.kt @@ -4,5 +4,5 @@ import com.checkout.frames.style.component.base.InputComponentStyle public data class BillingAddressInputComponentStyle( val addressFieldName: String, - val inputComponentStyle: InputComponentStyle + val inputComponentStyle: InputComponentStyle, ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/HeaderComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/HeaderComponentStyle.kt index 1ffae4e58..46d3a5938 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/HeaderComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/HeaderComponentStyle.kt @@ -7,5 +7,5 @@ import com.checkout.frames.style.component.base.TextLabelStyle public data class HeaderComponentStyle @JvmOverloads constructor( val headerTitleStyle: TextLabelStyle = TextLabelStyle(), val headerButtonStyle: ButtonStyle = ButtonStyle(), - val headerContainerStyle: ContainerStyle = ContainerStyle() + val headerContainerStyle: ContainerStyle = ContainerStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/InputComponentsContainerStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/InputComponentsContainerStyle.kt index a8f179414..f168a78a0 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/InputComponentsContainerStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/billingformdetails/InputComponentsContainerStyle.kt @@ -6,5 +6,5 @@ import com.checkout.frames.style.component.base.InputComponentStyle public data class InputComponentsContainerStyle @JvmOverloads constructor( val inputComponentStyleValues: LinkedHashMap = linkedMapOf(), - var containerStyle: ContainerStyle = ContainerStyle() + var containerStyle: ContainerStyle = ContainerStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultAddressSummaryComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultAddressSummaryComponentStyle.kt index 120309861..767a7f258 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultAddressSummaryComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultAddressSummaryComponentStyle.kt @@ -1,14 +1,14 @@ package com.checkout.frames.style.component.default import com.checkout.frames.R -import com.checkout.frames.model.Margin +import com.checkout.frames.model.BorderStroke import com.checkout.frames.model.CornerRadius +import com.checkout.frames.model.Margin import com.checkout.frames.model.Shape -import com.checkout.frames.model.BorderStroke import com.checkout.frames.style.component.addresssummary.AddressSummaryComponentStyle import com.checkout.frames.style.component.addresssummary.AddressSummarySectionStyle -import com.checkout.frames.style.component.base.DividerStyle import com.checkout.frames.style.component.base.ContainerStyle +import com.checkout.frames.style.component.base.DividerStyle import com.checkout.frames.utils.constants.AddressSummaryConstants import com.checkout.frames.utils.constants.BorderConstants import com.checkout.frames.utils.constants.LightStyleConstants @@ -24,40 +24,43 @@ public object DefaultAddressSummaryComponentStyle { * For billing summary, if field is optional, required to hide subtitle from the screen */ val subTitleStyle = - if (isOptional) null - else DefaultTextLabelStyle.subtitle(textId = R.string.cko_billing_address_info) + if (isOptional) { + null + } else { + DefaultTextLabelStyle.subtitle(textId = R.string.cko_billing_address_info) + } val addAddressButtonStyle = DefaultButtonStyle.lightOutline( textId = R.string.cko_add_billing_address, trailingIconStyle = DefaultImageStyle.buttonTrailingImageStyle(), margin = Margin( top = AddressSummaryConstants.marginBeforeSummarySection, - bottom = PaymentDetailsScreenConstants.marginBottom - ) + bottom = PaymentDetailsScreenConstants.marginBottom, + ), ) val summarySectionStyle = AddressSummarySectionStyle( addressTextStyle = DefaultTextLabelStyle.text( padding = AddressSummaryConstants.addressSummaryTextPadding, - lineHeight = AddressSummaryConstants.addressSummaryTextLineHeight + lineHeight = AddressSummaryConstants.addressSummaryTextLineHeight, ), dividerStyle = DividerStyle(color = AddressSummaryConstants.dividerColor), editAddressButtonStyle = DefaultButtonStyle.lightSolid( textId = R.string.cko_edit_billing_address, trailingIconStyle = DefaultImageStyle.buttonTrailingImageStyle(), - cornerRadius = CornerRadius(bottomStart = BorderConstants.radius, bottomEnd = BorderConstants.radius) + cornerRadius = CornerRadius(bottomStart = BorderConstants.radius, bottomEnd = BorderConstants.radius), ), containerStyle = ContainerStyle( shape = Shape.RoundCorner, cornerRadius = CornerRadius(BorderConstants.radius), borderStroke = BorderStroke( BorderConstants.unfocusedBorderThickness, - LightStyleConstants.unfocusedBorderColor + LightStyleConstants.unfocusedBorderColor, ), margin = Margin( top = AddressSummaryConstants.marginBeforeSummarySection, - bottom = PaymentDetailsScreenConstants.marginBottom - ) - ) + bottom = PaymentDetailsScreenConstants.marginBottom, + ), + ), ) return AddressSummaryComponentStyle( @@ -65,7 +68,7 @@ public object DefaultAddressSummaryComponentStyle { subTitleStyle, addAddressButtonStyle, summarySectionStyle, - isOptional = isOptional + isOptional = isOptional, ) } } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultButtonStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultButtonStyle.kt index bf2acf398..f45a0f46e 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultButtonStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultButtonStyle.kt @@ -2,11 +2,11 @@ package com.checkout.frames.style.component.default import androidx.annotation.ColorLong import androidx.annotation.StringRes -import com.checkout.frames.model.Shape -import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.BorderStroke -import com.checkout.frames.model.Padding +import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.Margin +import com.checkout.frames.model.Padding +import com.checkout.frames.model.Shape import com.checkout.frames.model.font.FontWeight import com.checkout.frames.style.component.base.ButtonStyle import com.checkout.frames.style.component.base.ContainerStyle @@ -34,13 +34,13 @@ public object DefaultButtonStyle { cornerRadius: CornerRadius = CornerRadius(BorderConstants.radius), borderStroke: BorderStroke? = BorderStroke( BorderConstants.unfocusedBorderThickness, - ButtonStyleConstants.outlineStrokeColor + ButtonStyleConstants.outlineStrokeColor, ), contentPadding: Padding = ButtonStyleConstants.outlineContentPadding, leadingIconStyle: ImageStyle? = null, trailingIconStyle: ImageStyle? = null, margin: Margin? = null, - fontWeight: FontWeight = FontWeight.Normal + fontWeight: FontWeight = FontWeight.Normal, ): ButtonStyle = ButtonStyle( contentColor = contentColor, containerColor = containerColor, @@ -55,9 +55,9 @@ public object DefaultButtonStyle { textId = textId, leadingIconStyle = leadingIconStyle, trailingIconStyle = trailingIconStyle, - fontWeight = fontWeight + fontWeight = fontWeight, ), - containerStyle = ContainerStyle(margin = margin) + containerStyle = ContainerStyle(margin = margin), ) @Suppress("LongParameterList") @@ -80,7 +80,7 @@ public object DefaultButtonStyle { leadingIconStyle: ImageStyle? = null, trailingIconStyle: ImageStyle? = null, margin: Margin? = null, - fontWeight: FontWeight = FontWeight.Normal + fontWeight: FontWeight = FontWeight.Normal, ): ButtonStyle = lightOutline( text = text, textId = textId, @@ -95,6 +95,6 @@ public object DefaultButtonStyle { leadingIconStyle = leadingIconStyle, trailingIconStyle = trailingIconStyle, margin = margin, - fontWeight = fontWeight + fontWeight = fontWeight, ) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCardHolderNameComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCardHolderNameComponentStyle.kt index 90af4167f..eda278f87 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCardHolderNameComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCardHolderNameComponentStyle.kt @@ -12,7 +12,7 @@ public object DefaultCardHolderNameComponentStyle { titleTextId = R.string.cko_card_holder_name_title, infoTextId = if (isOptional) R.string.cko_input_field_optional_info else null, margin = Margin(bottom = marginBottom), - isFieldOptional = isOptional + isFieldOptional = isOptional, ) return CardHolderNameComponentStyle(style) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCardNumberComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCardNumberComponentStyle.kt index 009065240..3dcb7bad3 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCardNumberComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCardNumberComponentStyle.kt @@ -11,7 +11,7 @@ public object DefaultCardNumberComponentStyle { val style = DefaultLightStyle.inputComponentStyle( titleTextId = R.string.cko_card_number_title, withLeadingIcon = true, - margin = Margin(bottom = marginBottom) + margin = Margin(bottom = marginBottom), ) return CardNumberComponentStyle(style) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCountryComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCountryComponentStyle.kt index 12db9975e..47a92c96c 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCountryComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCountryComponentStyle.kt @@ -16,7 +16,7 @@ public object DefaultCountryComponentStyle { unfocusedBorderColor = LightStyleConstants.unfocusedBorderColor, disabledBorderColor = LightStyleConstants.unfocusedBorderColor, ), - trailingIconStyle = ImageStyle(image = R.drawable.cko_ic_caret_right) + trailingIconStyle = ImageStyle(image = R.drawable.cko_ic_caret_right), ) return CountryComponentStyle( @@ -25,10 +25,10 @@ public object DefaultCountryComponentStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding - ) + bottom = LightStyleConstants.inputComponentBottomPadding, + ), ) - .copy(inputFieldStyle = inputFieldStyle) + .copy(inputFieldStyle = inputFieldStyle), ) } } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCvvComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCvvComponentStyle.kt index 5b69a5972..02903df25 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCvvComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultCvvComponentStyle.kt @@ -10,7 +10,7 @@ public object DefaultCvvComponentStyle { DefaultLightStyle.inputComponentStyle( titleTextId = R.string.cko_cvv_component_title, subtitleTextId = R.string.cko_cvv_component_subtitle, - margin = Margin(bottom = PaymentDetailsScreenConstants.marginBottom) - ) + margin = Margin(bottom = PaymentDetailsScreenConstants.marginBottom), + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultExpiryDateComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultExpiryDateComponentStyle.kt index bdedadb3b..1212b493e 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultExpiryDateComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultExpiryDateComponentStyle.kt @@ -11,7 +11,7 @@ public object DefaultExpiryDateComponentStyle { titleTextId = R.string.cko_expiry_date_component_title, subtitleTextId = R.string.cko_expiry_date_component_subtitle, placeholderResourceTextId = R.string.cko_expiry_date_component_placeholder, - margin = Margin(bottom = PaymentDetailsScreenConstants.marginBottom) - ) + margin = Margin(bottom = PaymentDetailsScreenConstants.marginBottom), + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultImageStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultImageStyle.kt index 8fc958b6f..202a8637f 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultImageStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultImageStyle.kt @@ -14,14 +14,14 @@ public object DefaultImageStyle { tinColor: Long? = LightStyleConstants.focusedBorderColor, height: Int? = ButtonStyleConstants.trailingIconHeight, width: Int? = null, - padding: Padding? = ButtonStyleConstants.trailingIconPadding + padding: Padding? = ButtonStyleConstants.trailingIconPadding, ): ImageStyle { return ImageStyle( image = image, tinColor = tinColor, height = height, width = width, - padding = padding + padding = padding, ) } } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultLightStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultLightStyle.kt index b11bf1421..7af2c2c62 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultLightStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultLightStyle.kt @@ -11,17 +11,17 @@ import com.checkout.frames.model.font.Font import com.checkout.frames.model.font.FontWeight import com.checkout.frames.style.component.CardSchemeComponentStyle import com.checkout.frames.style.component.ScreenHeaderStyle -import com.checkout.frames.style.component.base.TextLabelStyle -import com.checkout.frames.style.component.base.TextStyle -import com.checkout.frames.style.component.base.ImageStyle -import com.checkout.frames.style.component.base.ImageContainerStyle import com.checkout.frames.style.component.base.ContainerStyle -import com.checkout.frames.style.component.base.InputFieldIndicatorStyle +import com.checkout.frames.style.component.base.ImageContainerStyle +import com.checkout.frames.style.component.base.ImageStyle import com.checkout.frames.style.component.base.InputComponentStyle +import com.checkout.frames.style.component.base.InputFieldIndicatorStyle import com.checkout.frames.style.component.base.InputFieldStyle -import com.checkout.frames.utils.constants.LightStyleConstants +import com.checkout.frames.style.component.base.TextLabelStyle +import com.checkout.frames.style.component.base.TextStyle import com.checkout.frames.utils.constants.CardSchemeConstants import com.checkout.frames.utils.constants.HeaderTitleConstants +import com.checkout.frames.utils.constants.LightStyleConstants @Suppress("TooManyFunctions", "LongParameterList") public object DefaultLightStyle { @@ -42,7 +42,7 @@ public object DefaultLightStyle { height: Int = HeaderTitleConstants.height, maxLines: Int = HeaderTitleConstants.maxLines, leadingIconSize: Int = HeaderTitleConstants.leadingIconSize, - leadingIconPadding: Padding = Padding() + leadingIconPadding: Padding = Padding(), ): ScreenHeaderStyle = ScreenHeaderStyle( text = text, textId = textId, @@ -51,21 +51,21 @@ public object DefaultLightStyle { color = textColor, font = font, fontWeight = fontWeight, - maxLines = maxLines + maxLines = maxLines, ), backIconStyle = ImageStyle( image = imageId, tinColor = textColor, height = leadingIconSize, width = leadingIconSize, - padding = leadingIconPadding + padding = leadingIconPadding, ), - containerStyle = ContainerStyle(height = height, padding = padding) + containerStyle = ContainerStyle(height = height, padding = padding), ) @JvmOverloads public fun screenTitleTextLabelStyle( - padding: Padding = Padding() + padding: Padding = Padding(), ): TextLabelStyle = DefaultTextLabelStyle.headerTitle(padding = padding) public fun titleTextLabelStyle(): TextLabelStyle = DefaultTextLabelStyle.title() @@ -77,41 +77,41 @@ public object DefaultLightStyle { public fun leadingIconStyle(): ImageStyle = ImageStyle( padding = Padding( start = LightStyleConstants.leadingIconStartPadding, - end = LightStyleConstants.leadingIconEndPadding + end = LightStyleConstants.leadingIconEndPadding, ), height = LightStyleConstants.leadingIconHeight, - width = LightStyleConstants.leadingIconWidth + width = LightStyleConstants.leadingIconWidth, ) public fun supportedCardSchemeIconStyle(): ImageStyle = ImageStyle( height = LightStyleConstants.leadingIconHeight, - width = LightStyleConstants.leadingIconWidth + width = LightStyleConstants.leadingIconWidth, ) public fun supportedCardSchemeImageContainerStyle(): ImageContainerStyle = ImageContainerStyle( crossAxisSpacing = CardSchemeConstants.crossAxisSpacingPadding, mainAxisSpacing = CardSchemeConstants.mainAxisSpacingPadding, - containerStyle = ContainerStyle(margin = Margin(top = CardSchemeConstants.marginTop)) + containerStyle = ContainerStyle(margin = Margin(top = CardSchemeConstants.marginTop)), ) public fun inputFieldTextStyle(): TextStyle = TextStyle( size = LightStyleConstants.fontSize, color = LightStyleConstants.fontColor, font = LightStyleConstants.font, - maxLines = LightStyleConstants.maxLines + maxLines = LightStyleConstants.maxLines, ) public fun indicatorStyle(): InputFieldIndicatorStyle = InputFieldIndicatorStyle.Border( unfocusedBorderColor = LightStyleConstants.unfocusedBorderColor, focusedBorderColor = LightStyleConstants.focusedBorderColor, - errorBorderColor = LightStyleConstants.errorBorderColor + errorBorderColor = LightStyleConstants.errorBorderColor, ) public fun errorTextLabelStyle(): TextLabelStyle = DefaultTextLabelStyle.error() public fun inputFieldStyle( withLeadingIcon: Boolean = false, - keyboardOptions: KeyboardOptions = KeyboardOptions.Default + keyboardOptions: KeyboardOptions = KeyboardOptions.Default, ): InputFieldStyle = InputFieldStyle( textStyle = inputFieldTextStyle(), @@ -119,7 +119,7 @@ public object DefaultLightStyle { placeholderStyle = placeHolderTextStyle(), leadingIconStyle = if (withLeadingIcon) leadingIconStyle() else null, containerStyle = ContainerStyle(margin = Margin(top = LightStyleConstants.marginTop)), - keyboardOptions = keyboardOptions + keyboardOptions = keyboardOptions, ) public fun inputComponentStyle( @@ -139,7 +139,7 @@ public object DefaultLightStyle { padding: Padding = Padding(), margin: Margin = Margin(), isFieldOptional: Boolean = false, - keyboardOptions: KeyboardOptions = KeyboardOptions.Default + keyboardOptions: KeyboardOptions = KeyboardOptions.Default, ): InputComponentStyle = InputComponentStyle( titleStyle = titleTextLabelStyle().apply { text = titleText @@ -159,13 +159,13 @@ public object DefaultLightStyle { }, errorMessageStyle = errorTextLabelStyle(), containerStyle = ContainerStyle(padding = padding, margin = margin), - isInputFieldOptional = isFieldOptional + isInputFieldOptional = isFieldOptional, ) public fun cardSchemeComponentStyle( titleText: String = "", @StringRes - titleTextId: Int? = R.string.cko_accepted_cards_title + titleTextId: Int? = R.string.cko_accepted_cards_title, ): CardSchemeComponentStyle = CardSchemeComponentStyle( titleStyle = subtitleTextLabelStyle().apply { text = titleText @@ -175,9 +175,9 @@ public object DefaultLightStyle { containerStyle = ContainerStyle( margin = Margin( top = CardSchemeConstants.marginTop, - bottom = CardSchemeConstants.marginBottom - ) + bottom = CardSchemeConstants.marginBottom, + ), ), - imageContainerStyle = supportedCardSchemeImageContainerStyle() + imageContainerStyle = supportedCardSchemeImageContainerStyle(), ) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultPayButtonComponentStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultPayButtonComponentStyle.kt index c9d9c96a8..527a80927 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultPayButtonComponentStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultPayButtonComponentStyle.kt @@ -15,7 +15,7 @@ public object DefaultPayButtonComponentStyle { disabledContainerColor = PaymentButtonConstants.disabledContainerColor, contentPadding = PaymentButtonConstants.contentPadding, fontWeight = PaymentButtonConstants.fontWeight, - margin = PaymentButtonConstants.buttonMargin - ) + margin = PaymentButtonConstants.buttonMargin, + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultTextLabelStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultTextLabelStyle.kt index b653fd732..c0e5aee96 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultTextLabelStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultTextLabelStyle.kt @@ -12,10 +12,10 @@ import com.checkout.frames.style.component.base.ImageStyle import com.checkout.frames.style.component.base.TextLabelStyle import com.checkout.frames.style.component.base.TextStyle import com.checkout.frames.utils.constants.ErrorConstants -import com.checkout.frames.utils.constants.TitleConstants -import com.checkout.frames.utils.constants.SubtitleConstants import com.checkout.frames.utils.constants.HeaderTitleConstants +import com.checkout.frames.utils.constants.SubtitleConstants import com.checkout.frames.utils.constants.TextConstants +import com.checkout.frames.utils.constants.TitleConstants public object DefaultTextLabelStyle { @@ -28,21 +28,21 @@ public object DefaultTextLabelStyle { leadingIconSize: Int = ErrorConstants.leadingIconSize, @DrawableRes leadingIconId: Int = R.drawable.cko_ic_error, - padding: Padding = Padding(top = ErrorConstants.errorMessageTopPadding) + padding: Padding = Padding(top = ErrorConstants.errorMessageTopPadding), ): TextLabelStyle = TextLabelStyle( textStyle = TextStyle( size = fontSize, color = color, - font = font + font = font, ), leadingIconStyle = ImageStyle( image = leadingIconId, tinColor = color, height = leadingIconSize, width = leadingIconSize, - padding = Padding(end = ErrorConstants.leadingIconEndPadding) + padding = Padding(end = ErrorConstants.leadingIconEndPadding), ), - containerStyle = ContainerStyle(padding = padding) + containerStyle = ContainerStyle(padding = padding), ) @JvmOverloads @@ -59,7 +59,7 @@ public object DefaultTextLabelStyle { maxLines: Int = TitleConstants.maxLines, lineHeight: Int? = null, leadingIconStyle: ImageStyle? = null, - trailingIconStyle: ImageStyle? = null + trailingIconStyle: ImageStyle? = null, ): TextLabelStyle = TextLabelStyle( text = text, textId = textId, @@ -69,11 +69,11 @@ public object DefaultTextLabelStyle { font = font, fontWeight = fontWeight, maxLines = maxLines, - lineHeight = lineHeight + lineHeight = lineHeight, ), leadingIconStyle = leadingIconStyle, trailingIconStyle = trailingIconStyle, - containerStyle = ContainerStyle(padding = padding) + containerStyle = ContainerStyle(padding = padding), ) @JvmOverloads @@ -87,15 +87,18 @@ public object DefaultTextLabelStyle { color: Long = SubtitleConstants.color, padding: Padding = Padding(), maxLines: Int = Int.MAX_VALUE, - lineHeight: Int? = null + lineHeight: Int? = null, ): TextLabelStyle = TextLabelStyle( text = text, textId = textId, textStyle = TextStyle( - size = fontSize, color = color, font = font, maxLines = maxLines, - lineHeight = lineHeight + size = fontSize, + color = color, + font = font, + maxLines = maxLines, + lineHeight = lineHeight, ), - containerStyle = ContainerStyle(padding = padding) + containerStyle = ContainerStyle(padding = padding), ) @JvmOverloads @@ -108,22 +111,22 @@ public object DefaultTextLabelStyle { padding: Padding = Padding(), maxLines: Int = HeaderTitleConstants.maxLines, leadingIconSize: Int = HeaderTitleConstants.leadingIconSize, - leadingIconPadding: Padding = Padding() + leadingIconPadding: Padding = Padding(), ): TextLabelStyle = TextLabelStyle( textStyle = TextStyle( size = fontSize, color = color, font = font, fontWeight = fontWeight, - maxLines = maxLines + maxLines = maxLines, ), leadingIconStyle = ImageStyle( tinColor = color, height = leadingIconSize, width = leadingIconSize, - padding = leadingIconPadding + padding = leadingIconPadding, ), - containerStyle = ContainerStyle(padding = padding) + containerStyle = ContainerStyle(padding = padding), ) @JvmOverloads @@ -137,7 +140,7 @@ public object DefaultTextLabelStyle { color: Long = TextConstants.color, padding: Padding = Padding(), maxLines: Int = Int.MAX_VALUE, - lineHeight: Int? = null + lineHeight: Int? = null, ): TextLabelStyle = TextLabelStyle( text = text, textId = textId, @@ -146,8 +149,8 @@ public object DefaultTextLabelStyle { color = color, font = font, maxLines = maxLines, - lineHeight = lineHeight + lineHeight = lineHeight, ), - containerStyle = ContainerStyle(padding = padding) + containerStyle = ContainerStyle(padding = padding), ) } diff --git a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultTextStyle.kt b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultTextStyle.kt index fae469936..28d5b9d72 100644 --- a/frames/src/main/java/com/checkout/frames/style/component/default/DefaultTextStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/component/default/DefaultTextStyle.kt @@ -9,6 +9,6 @@ public object DefaultTextStyle { size = PlaceHolderConstants.fontSize, color = PlaceHolderConstants.fontColor, font = PlaceHolderConstants.font, - maxLines = PlaceHolderConstants.maxLines + maxLines = PlaceHolderConstants.maxLines, ) } diff --git a/frames/src/main/java/com/checkout/frames/style/screen/BillingAddressDetailsStyle.kt b/frames/src/main/java/com/checkout/frames/style/screen/BillingAddressDetailsStyle.kt index 05c5d09fa..3943681aa 100644 --- a/frames/src/main/java/com/checkout/frames/style/screen/BillingAddressDetailsStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/screen/BillingAddressDetailsStyle.kt @@ -2,8 +2,8 @@ package com.checkout.frames.style.screen import com.checkout.frames.style.component.CountryComponentStyle import com.checkout.frames.style.component.base.ContainerStyle -import com.checkout.frames.style.component.billingformdetails.InputComponentsContainerStyle import com.checkout.frames.style.component.billingformdetails.HeaderComponentStyle +import com.checkout.frames.style.component.billingformdetails.InputComponentsContainerStyle import com.checkout.frames.style.component.default.DefaultCountryComponentStyle import com.checkout.frames.style.screen.default.DefaultBillingAddressDetailsStyle @@ -12,5 +12,5 @@ public data class BillingAddressDetailsStyle @JvmOverloads constructor( var inputComponentsContainerStyle: InputComponentsContainerStyle = DefaultBillingAddressDetailsStyle.inputComponentsContainerStyle(), var countryComponentStyle: CountryComponentStyle = DefaultCountryComponentStyle.light(), - var containerStyle: ContainerStyle = ContainerStyle(color = 0xFFFFFFFF) + var containerStyle: ContainerStyle = ContainerStyle(color = 0xFFFFFFFF), ) diff --git a/frames/src/main/java/com/checkout/frames/style/screen/BillingFormStyle.kt b/frames/src/main/java/com/checkout/frames/style/screen/BillingFormStyle.kt index d793c94ea..eb1bab02d 100644 --- a/frames/src/main/java/com/checkout/frames/style/screen/BillingFormStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/screen/BillingFormStyle.kt @@ -4,5 +4,5 @@ import com.checkout.frames.style.screen.default.DefaultCountryPickerStyle public data class BillingFormStyle @JvmOverloads constructor( public var billingAddressDetailsStyle: BillingAddressDetailsStyle = BillingAddressDetailsStyle(), - public var countryPickerStyle: CountryPickerStyle = DefaultCountryPickerStyle.light() + public var countryPickerStyle: CountryPickerStyle = DefaultCountryPickerStyle.light(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/screen/CountryPickerStyle.kt b/frames/src/main/java/com/checkout/frames/style/screen/CountryPickerStyle.kt index 0cf5c0f79..318e02336 100644 --- a/frames/src/main/java/com/checkout/frames/style/screen/CountryPickerStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/screen/CountryPickerStyle.kt @@ -9,5 +9,5 @@ public data class CountryPickerStyle @JvmOverloads constructor( var searchFieldStyle: InputFieldStyle = InputFieldStyle(), var searchItemStyle: TextLabelStyle = TextLabelStyle(), var containerStyle: ContainerStyle = ContainerStyle(color = 0xFFFFFFFF), - var withFlag: Boolean = true + var withFlag: Boolean = true, ) diff --git a/frames/src/main/java/com/checkout/frames/style/screen/PaymentDetailsStyle.kt b/frames/src/main/java/com/checkout/frames/style/screen/PaymentDetailsStyle.kt index 3e17d74ce..a509c57d3 100644 --- a/frames/src/main/java/com/checkout/frames/style/screen/PaymentDetailsStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/screen/PaymentDetailsStyle.kt @@ -4,26 +4,26 @@ import com.checkout.frames.R import com.checkout.frames.model.Padding import com.checkout.frames.style.component.CardHolderNameComponentStyle import com.checkout.frames.style.component.CardNumberComponentStyle -import com.checkout.frames.style.component.PayButtonComponentStyle import com.checkout.frames.style.component.CardSchemeComponentStyle import com.checkout.frames.style.component.CvvComponentStyle import com.checkout.frames.style.component.ExpiryDateComponentStyle +import com.checkout.frames.style.component.PayButtonComponentStyle import com.checkout.frames.style.component.ScreenHeaderStyle import com.checkout.frames.style.component.addresssummary.AddressSummaryComponentStyle import com.checkout.frames.style.component.base.ContainerStyle +import com.checkout.frames.style.component.default.DefaultAddressSummaryComponentStyle +import com.checkout.frames.style.component.default.DefaultCardHolderNameComponentStyle import com.checkout.frames.style.component.default.DefaultCardNumberComponentStyle import com.checkout.frames.style.component.default.DefaultCvvComponentStyle import com.checkout.frames.style.component.default.DefaultExpiryDateComponentStyle import com.checkout.frames.style.component.default.DefaultLightStyle -import com.checkout.frames.style.component.default.DefaultAddressSummaryComponentStyle -import com.checkout.frames.style.component.default.DefaultCardHolderNameComponentStyle import com.checkout.frames.style.component.default.DefaultPayButtonComponentStyle import com.checkout.frames.utils.constants.PaymentDetailsScreenConstants public data class PaymentDetailsStyle @JvmOverloads constructor( public var paymentDetailsHeaderStyle: ScreenHeaderStyle = DefaultLightStyle.screenHeader( textId = R.string.cko_payment_details_title, - imageId = R.drawable.cko_ic_arrow_back + imageId = R.drawable.cko_ic_arrow_back, ), public var cardSchemeStyle: CardSchemeComponentStyle = DefaultLightStyle.cardSchemeComponentStyle(), public var cardHolderNameStyle: CardHolderNameComponentStyle? = DefaultCardHolderNameComponentStyle.light(), @@ -36,7 +36,7 @@ public data class PaymentDetailsStyle @JvmOverloads constructor( public var fieldsContainerStyle: ContainerStyle = ContainerStyle( padding = Padding( start = PaymentDetailsScreenConstants.padding, - end = PaymentDetailsScreenConstants.padding - ) - ) + end = PaymentDetailsScreenConstants.padding, + ), + ), ) diff --git a/frames/src/main/java/com/checkout/frames/style/screen/PaymentFormStyle.kt b/frames/src/main/java/com/checkout/frames/style/screen/PaymentFormStyle.kt index 663010751..869f99f57 100644 --- a/frames/src/main/java/com/checkout/frames/style/screen/PaymentFormStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/screen/PaymentFormStyle.kt @@ -2,5 +2,5 @@ package com.checkout.frames.style.screen public data class PaymentFormStyle @JvmOverloads constructor( public var paymentDetailsStyle: PaymentDetailsStyle = PaymentDetailsStyle(), - public var billingFormStyle: BillingFormStyle = BillingFormStyle() + public var billingFormStyle: BillingFormStyle = BillingFormStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/screen/default/DefaultBillingAddressDetailsStyle.kt b/frames/src/main/java/com/checkout/frames/style/screen/default/DefaultBillingAddressDetailsStyle.kt index 9bd8954cd..979375b37 100644 --- a/frames/src/main/java/com/checkout/frames/style/screen/default/DefaultBillingAddressDetailsStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/screen/default/DefaultBillingAddressDetailsStyle.kt @@ -10,10 +10,10 @@ import com.checkout.frames.model.Padding import com.checkout.frames.model.Shape import com.checkout.frames.screen.billingaddress.billingaddressdetails.models.BillingFormFields import com.checkout.frames.style.component.base.InputComponentStyle -import com.checkout.frames.style.component.billingformdetails.InputComponentsContainerStyle -import com.checkout.frames.style.component.default.DefaultLightStyle import com.checkout.frames.style.component.billingformdetails.HeaderComponentStyle +import com.checkout.frames.style.component.billingformdetails.InputComponentsContainerStyle import com.checkout.frames.style.component.default.DefaultButtonStyle +import com.checkout.frames.style.component.default.DefaultLightStyle import com.checkout.frames.utils.constants.BillingAddressDetailsConstants import com.checkout.frames.utils.constants.LightStyleConstants @@ -21,7 +21,7 @@ public object DefaultBillingAddressDetailsStyle { @Suppress("LongMethod") public fun fetchInputComponentStyleValues(isRequestedCardHolderName: Boolean = false): - LinkedHashMap { + LinkedHashMap { val defaultKeyboardOptions = KeyboardOptions(imeAction = ImeAction.Next) val inputComponentsStyles: LinkedHashMap = linkedMapOf() @@ -32,10 +32,10 @@ public object DefaultBillingAddressDetailsStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding + bottom = LightStyleConstants.inputComponentBottomPadding, ), isFieldOptional = true, - keyboardOptions = defaultKeyboardOptions + keyboardOptions = defaultKeyboardOptions, ) } @@ -44,10 +44,10 @@ public object DefaultBillingAddressDetailsStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding + bottom = LightStyleConstants.inputComponentBottomPadding, ), isFieldOptional = false, - keyboardOptions = defaultKeyboardOptions + keyboardOptions = defaultKeyboardOptions, ) inputComponentsStyles[BillingFormFields.AddressLineTwo] = DefaultLightStyle.inputComponentStyle( @@ -56,10 +56,10 @@ public object DefaultBillingAddressDetailsStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding + bottom = LightStyleConstants.inputComponentBottomPadding, ), isFieldOptional = true, - keyboardOptions = defaultKeyboardOptions + keyboardOptions = defaultKeyboardOptions, ) inputComponentsStyles[BillingFormFields.City] = DefaultLightStyle.inputComponentStyle( @@ -67,10 +67,10 @@ public object DefaultBillingAddressDetailsStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding + bottom = LightStyleConstants.inputComponentBottomPadding, ), isFieldOptional = false, - keyboardOptions = defaultKeyboardOptions + keyboardOptions = defaultKeyboardOptions, ) inputComponentsStyles[BillingFormFields.State] = DefaultLightStyle.inputComponentStyle( @@ -79,10 +79,10 @@ public object DefaultBillingAddressDetailsStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding + bottom = LightStyleConstants.inputComponentBottomPadding, ), isFieldOptional = true, - keyboardOptions = defaultKeyboardOptions + keyboardOptions = defaultKeyboardOptions, ) inputComponentsStyles[BillingFormFields.PostCode] = DefaultLightStyle.inputComponentStyle( @@ -90,10 +90,10 @@ public object DefaultBillingAddressDetailsStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding + bottom = LightStyleConstants.inputComponentBottomPadding, ), isFieldOptional = false, - keyboardOptions = defaultKeyboardOptions + keyboardOptions = defaultKeyboardOptions, ) inputComponentsStyles[BillingFormFields.Phone] = DefaultLightStyle.inputComponentStyle( @@ -102,10 +102,10 @@ public object DefaultBillingAddressDetailsStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding + bottom = LightStyleConstants.inputComponentBottomPadding, ), isFieldOptional = false, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done) + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done), ) inputComponentsStyles[BillingFormFields.Country] = DefaultLightStyle.inputComponentStyle( @@ -113,9 +113,9 @@ public object DefaultBillingAddressDetailsStyle { padding = Padding( start = LightStyleConstants.inputComponentLeftPadding, end = LightStyleConstants.inputComponentRightPadding, - bottom = LightStyleConstants.inputComponentBottomPadding + bottom = LightStyleConstants.inputComponentBottomPadding, ), - isFieldOptional = false + isFieldOptional = false, ) return inputComponentsStyles @@ -127,8 +127,8 @@ public object DefaultBillingAddressDetailsStyle { BillingAddressDetailsConstants.titlePaddingTop, BillingAddressDetailsConstants.titlePaddingBottom, BillingAddressDetailsConstants.titlePaddingStart, - BillingAddressDetailsConstants.titlePaddingEnd - ) + BillingAddressDetailsConstants.titlePaddingEnd, + ), ), DefaultButtonStyle.lightSolid( textId = R.string.cko_billing_form_button_save, @@ -142,13 +142,13 @@ public object DefaultBillingAddressDetailsStyle { start = BillingAddressDetailsConstants.buttonContentStartPadding, top = BillingAddressDetailsConstants.buttonContentTopPadding, bottom = BillingAddressDetailsConstants.buttonContentBottomPadding, - end = BillingAddressDetailsConstants.buttonContentEndPadding + end = BillingAddressDetailsConstants.buttonContentEndPadding, ), margin = Margin( top = BillingAddressDetailsConstants.buttonContainerTopPadding, - end = BillingAddressDetailsConstants.buttonContainerEndPadding - ) - ) + end = BillingAddressDetailsConstants.buttonContainerEndPadding, + ), + ), ) /* @@ -156,7 +156,7 @@ public object DefaultBillingAddressDetailsStyle { requested */ public fun inputComponentsContainerStyle(isRequestedCardHolderName: Boolean = false): - InputComponentsContainerStyle = InputComponentsContainerStyle( - fetchInputComponentStyleValues(isRequestedCardHolderName) + InputComponentsContainerStyle = InputComponentsContainerStyle( + fetchInputComponentStyleValues(isRequestedCardHolderName), ) } diff --git a/frames/src/main/java/com/checkout/frames/style/screen/default/DefaultCountryPickerStyle.kt b/frames/src/main/java/com/checkout/frames/style/screen/default/DefaultCountryPickerStyle.kt index f06dcfcb1..1b23f190a 100644 --- a/frames/src/main/java/com/checkout/frames/style/screen/default/DefaultCountryPickerStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/screen/default/DefaultCountryPickerStyle.kt @@ -19,25 +19,25 @@ public object DefaultCountryPickerStyle { CountryPickerScreenConstants.titlePaddingTop, CountryPickerScreenConstants.titlePaddingBottom, CountryPickerScreenConstants.titlePaddingStart, - CountryPickerScreenConstants.titlePaddingEnd - ) + CountryPickerScreenConstants.titlePaddingEnd, + ), ) val searchFieldStyle = DefaultLightStyle.inputFieldStyle(true).copy( indicatorStyle = InputFieldIndicatorStyle.Border( focusedBorderColor = CountryPickerScreenConstants.focusedBorderColor, unfocusedBorderColor = CountryPickerScreenConstants.unfocusedBorderColor, - focusedBorderThickness = CountryPickerScreenConstants.focusedBorderThickness + focusedBorderThickness = CountryPickerScreenConstants.focusedBorderThickness, ), containerStyle = ContainerStyle( margin = Margin( start = CountryPickerScreenConstants.margin, end = CountryPickerScreenConstants.margin, - bottom = CountryPickerScreenConstants.margin - ) + bottom = CountryPickerScreenConstants.margin, + ), ), placeholderTextId = R.string.cko_search_county_placeholder, leadingIconStyle = ImageStyle(), - trailingIconStyle = ImageStyle() + trailingIconStyle = ImageStyle(), ) val searchItemStyle = DefaultTextLabelStyle.title( fontSize = CountryPickerScreenConstants.searchItemFontSize, @@ -46,14 +46,14 @@ public object DefaultCountryPickerStyle { CountryPickerScreenConstants.searchItemPaddingTop, CountryPickerScreenConstants.searchItemPaddingBottom, CountryPickerScreenConstants.searchItemPaddingStart, - CountryPickerScreenConstants.searchItemPaddingEnd + CountryPickerScreenConstants.searchItemPaddingEnd, ), ) return CountryPickerStyle( screenTitleStyle = screenTitleStyle, searchFieldStyle = searchFieldStyle, - searchItemStyle = searchItemStyle + searchItemStyle = searchItemStyle, ) } } diff --git a/frames/src/main/java/com/checkout/frames/style/theme/DefaultPaymentFormTheme.kt b/frames/src/main/java/com/checkout/frames/style/theme/DefaultPaymentFormTheme.kt index 39cd2f585..9a38b3615 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/DefaultPaymentFormTheme.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/DefaultPaymentFormTheme.kt @@ -162,8 +162,8 @@ public object DefaultPaymentFormTheme { postCode: PaymentFormComponent = this.postCode, phone: PaymentFormComponent = this.phone, country: PaymentFormComponent = this.country, - countryPicker: PaymentFormComponent = this.countryPicker - ): List { + countryPicker: PaymentFormComponent = this.countryPicker, + ): List { return listOf( paymentHeaderTitle, cardScheme, @@ -186,7 +186,7 @@ public object DefaultPaymentFormTheme { postCode, phone, country, - countryPicker + countryPicker, ) } diff --git a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponent.kt b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponent.kt index 625dc8065..4a62ad7fa 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponent.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponent.kt @@ -14,5 +14,5 @@ public data class PaymentFormComponent @JvmOverloads constructor( val placeholderResourceTextId: Int? = null, val backIconImageResourceID: Int? = null, val leadingIconImageResourceID: Int? = null, - val trailingIconImageResourceID: Int? = null + val trailingIconImageResourceID: Int? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponentBuilder.kt b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponentBuilder.kt index 674d0a1af..639db832e 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponentBuilder.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponentBuilder.kt @@ -111,6 +111,6 @@ public class PaymentFormComponentBuilder : ObjectBuilder { placeholderResourceTextId = placeholderResourceTextId, backIconImageResourceID = backIconImageID, trailingIconImageResourceID = trailingIconImageID, - leadingIconImageResourceID = leadingIconImageID + leadingIconImageResourceID = leadingIconImageID, ) } diff --git a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponentField.kt b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponentField.kt index 6b9c6a5d8..1210a9eb8 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponentField.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormComponentField.kt @@ -26,5 +26,5 @@ public enum class PaymentFormComponentField { Country, Phone, CountryPicker, - UNKNOWN; + UNKNOWN, } diff --git a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormCornerRadius.kt b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormCornerRadius.kt index 44af0b8f2..a2d544a77 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormCornerRadius.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormCornerRadius.kt @@ -8,5 +8,5 @@ public data class PaymentFormCornerRadius @JvmOverloads constructor( val inputFieldCornerRadius: CornerRadius = CornerRadius(ContainerConstants.radius), val addressSummaryCornerRadius: CornerRadius = CornerRadius(BorderConstants.radius), val buttonCornerRadius: CornerRadius = CornerRadius(), - val screenBackgroundCornerRadius: CornerRadius = CornerRadius(ContainerConstants.radius) + val screenBackgroundCornerRadius: CornerRadius = CornerRadius(ContainerConstants.radius), ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormShape.kt b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormShape.kt index 16cae4717..4a0ad74fe 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormShape.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormShape.kt @@ -6,5 +6,5 @@ public data class PaymentFormShape @JvmOverloads constructor( val inputFieldShape: Shape = Shape.Rectangle, val addressSummaryShape: Shape = Shape.RoundCorner, val buttonShape: Shape = Shape.Rectangle, - val screenBackgroundShape: Shape = Shape.None + val screenBackgroundShape: Shape = Shape.None, ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormThemeColors.kt b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormThemeColors.kt index 471c9c599..6600a83cc 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormThemeColors.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormThemeColors.kt @@ -1,13 +1,13 @@ package com.checkout.frames.style.theme import androidx.annotation.ColorLong -import com.checkout.frames.style.theme.colors.PaymentFormColors -import com.checkout.frames.style.theme.colors.PaymentFormButtonColors import com.checkout.frames.style.theme.colors.CursorColors import com.checkout.frames.style.theme.colors.DividerColor import com.checkout.frames.style.theme.colors.ImageColors -import com.checkout.frames.style.theme.colors.TextColors import com.checkout.frames.style.theme.colors.InputFieldColors +import com.checkout.frames.style.theme.colors.PaymentFormButtonColors +import com.checkout.frames.style.theme.colors.PaymentFormColors +import com.checkout.frames.style.theme.colors.TextColors public data class PaymentFormThemeColors( val paymentFormColors: PaymentFormColors, @@ -16,7 +16,7 @@ public data class PaymentFormThemeColors( val dividerColor: DividerColor, val imageColors: ImageColors, val textColors: TextColors, - val inputFieldColors: InputFieldColors + val inputFieldColors: InputFieldColors, ) { public constructor( @ColorLong @@ -32,7 +32,7 @@ public data class PaymentFormThemeColors( @ColorLong enabledButtonColor: Long, @ColorLong - disabledButtonColor: Long + disabledButtonColor: Long, ) : this( paymentFormColors = PaymentFormColors(background = backgroundColor), buttonColors = PaymentFormButtonColors( @@ -45,7 +45,7 @@ public data class PaymentFormThemeColors( cursorColor = accentColor, errorCursorColor = errorColor, cursorHandleColor = accentColor, - cursorHighlightColor = backgroundColor + cursorHighlightColor = backgroundColor, ), dividerColor = DividerColor(color = backgroundColor), imageColors = ImageColors(tinColor = accentColor), @@ -53,14 +53,14 @@ public data class PaymentFormThemeColors( titleColor = accentColor, subTitleColor = textColor, infoColor = textColor, - errorColor = errorColor + errorColor = errorColor, ), inputFieldColors = InputFieldColors( focusedBorderColor = accentColor, unfocusedBorderColor = textColor, disabledBorderColor = textColor, errorBorderColor = errorColor, - inputFieldBackgroundColor = fieldBackgroundColor - ) + inputFieldBackgroundColor = fieldBackgroundColor, + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormThemeStyle.kt b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormThemeStyle.kt index d6b922dd6..b9876841d 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormThemeStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/PaymentFormThemeStyle.kt @@ -1,9 +1,9 @@ package com.checkout.frames.style.theme -import com.checkout.frames.style.component.base.TextStyle -import com.checkout.frames.style.component.base.InputFieldIndicatorStyle import com.checkout.frames.style.component.base.ButtonStyle import com.checkout.frames.style.component.base.ContainerStyle +import com.checkout.frames.style.component.base.InputFieldIndicatorStyle +import com.checkout.frames.style.component.base.TextStyle internal data class PaymentFormThemeStyle( val titleTextStyle: TextStyle? = null, @@ -17,5 +17,5 @@ internal data class PaymentFormThemeStyle( val editAddressButtonStyle: ButtonStyle = ButtonStyle(), val paymentDetailsButtonStyle: ButtonStyle = ButtonStyle(), val inputFieldContainerStyle: ContainerStyle = ContainerStyle(), - val containerStyle: ContainerStyle = ContainerStyle() + val containerStyle: ContainerStyle = ContainerStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/RequestThemeStyles.kt b/frames/src/main/java/com/checkout/frames/style/theme/RequestThemeStyles.kt index 4b46d91d9..4c832c878 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/RequestThemeStyles.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/RequestThemeStyles.kt @@ -7,5 +7,5 @@ import com.checkout.frames.style.component.base.InputComponentStyle internal data class RequestThemeStyles( val inputComponentStyle: InputComponentStyle? = null, val addressSummaryComponentStyle: AddressSummaryComponentStyle = AddressSummaryComponentStyle(), - val buttonStyle: ButtonStyle = ButtonStyle() + val buttonStyle: ButtonStyle = ButtonStyle(), ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/colors/CursorColors.kt b/frames/src/main/java/com/checkout/frames/style/theme/colors/CursorColors.kt index ca723a81b..0a64749e9 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/colors/CursorColors.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/colors/CursorColors.kt @@ -10,7 +10,7 @@ public data class CursorColors( @ColorLong public val cursorHandleColor: Long, @ColorLong - public val cursorHighlightColor: Long + public val cursorHighlightColor: Long, ) { public constructor(cursorColor: Long) : this(cursorColor, cursorColor, cursorColor, cursorColor) } diff --git a/frames/src/main/java/com/checkout/frames/style/theme/colors/DividerColor.kt b/frames/src/main/java/com/checkout/frames/style/theme/colors/DividerColor.kt index 151319432..58e9f5940 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/colors/DividerColor.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/colors/DividerColor.kt @@ -4,5 +4,5 @@ import androidx.annotation.ColorLong public data class DividerColor( @ColorLong - public val color: Long + public val color: Long, ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/colors/ImageColors.kt b/frames/src/main/java/com/checkout/frames/style/theme/colors/ImageColors.kt index 6b2b09592..b5e9ced3f 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/colors/ImageColors.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/colors/ImageColors.kt @@ -4,5 +4,5 @@ import androidx.annotation.ColorLong public data class ImageColors( @ColorLong - val tinColor: Long? = null + val tinColor: Long? = null, ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/colors/InputFieldColors.kt b/frames/src/main/java/com/checkout/frames/style/theme/colors/InputFieldColors.kt index 4e081bd6a..326db0a1c 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/colors/InputFieldColors.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/colors/InputFieldColors.kt @@ -22,5 +22,5 @@ public data class InputFieldColors @JvmOverloads constructor( @ColorLong val disabledUnderlineColor: Long = UnderlineConstants.disabledUnderlineColor, @ColorLong - val errorUnderlineColor: Long = UnderlineConstants.errorUnderlineColor + val errorUnderlineColor: Long = UnderlineConstants.errorUnderlineColor, ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/colors/PaymentFormColors.kt b/frames/src/main/java/com/checkout/frames/style/theme/colors/PaymentFormColors.kt index f90af8248..6cbbe803d 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/colors/PaymentFormColors.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/colors/PaymentFormColors.kt @@ -5,5 +5,5 @@ import com.checkout.frames.utils.constants.ContainerConstants public data class PaymentFormColors @JvmOverloads constructor( @ColorLong - val background: Long = ContainerConstants.backgroundColor + val background: Long = ContainerConstants.backgroundColor, ) diff --git a/frames/src/main/java/com/checkout/frames/style/theme/paymentform/PaymentFormStyleProvider.kt b/frames/src/main/java/com/checkout/frames/style/theme/paymentform/PaymentFormStyleProvider.kt index ecde64302..b48e70d29 100644 --- a/frames/src/main/java/com/checkout/frames/style/theme/paymentform/PaymentFormStyleProvider.kt +++ b/frames/src/main/java/com/checkout/frames/style/theme/paymentform/PaymentFormStyleProvider.kt @@ -8,6 +8,7 @@ import com.checkout.frames.style.theme.PaymentFormTheme public object PaymentFormStyleProvider { public fun provide(theme: PaymentFormTheme): PaymentFormStyle = PaymentFormMapper( - PaymentDetailsStyleMapper(), BillingFormStyleMapper() + PaymentDetailsStyleMapper(), + BillingFormStyleMapper(), ).map(theme) } diff --git a/frames/src/main/java/com/checkout/frames/style/view/BillingAddressInputComponentViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/BillingAddressInputComponentViewStyle.kt index 7f819df63..def873075 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/BillingAddressInputComponentViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/BillingAddressInputComponentViewStyle.kt @@ -2,5 +2,5 @@ package com.checkout.frames.style.view internal data class BillingAddressInputComponentViewStyle( val addressFieldName: String, - val inputComponentViewStyle: InputComponentViewStyle + val inputComponentViewStyle: InputComponentViewStyle, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/CardSchemeComponentViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/CardSchemeComponentViewStyle.kt index c5887b448..c51b3716d 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/CardSchemeComponentViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/CardSchemeComponentViewStyle.kt @@ -11,5 +11,5 @@ import androidx.compose.ui.Modifier internal data class CardSchemeComponentViewStyle( val titleStyle: TextLabelViewStyle, val containerModifier: Modifier = Modifier, - val flowRowViewStyle: FlowRowViewStyle + val flowRowViewStyle: FlowRowViewStyle, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/DividerViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/DividerViewStyle.kt index da58816fa..b9c3a6fef 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/DividerViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/DividerViewStyle.kt @@ -7,5 +7,5 @@ import androidx.compose.ui.unit.Dp internal data class DividerViewStyle( val thickness: Dp, val color: Color = Color.LightGray, - val modifier: Modifier = Modifier + val modifier: Modifier = Modifier, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/FlowRowViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/FlowRowViewStyle.kt index d2516c3e0..0680dc382 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/FlowRowViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/FlowRowViewStyle.kt @@ -14,5 +14,5 @@ import androidx.compose.ui.unit.dp internal data class FlowRowViewStyle( val mainAxisSpacing: Dp = 0.dp, val crossAxisSpacing: Dp = 0.dp, - val imagesContainerModifier: Modifier = Modifier + val imagesContainerModifier: Modifier = Modifier, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/InputComponentViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/InputComponentViewStyle.kt index cb756fb56..db7afa18b 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/InputComponentViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/InputComponentViewStyle.kt @@ -9,5 +9,5 @@ internal data class InputComponentViewStyle( val inputFieldStyle: InputFieldViewStyle = InputFieldViewStyle(), val errorMessageStyle: TextLabelViewStyle, val containerModifier: Modifier = Modifier, - val isInputFieldOptional: Boolean = false + val isInputFieldOptional: Boolean = false, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/InputFieldViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/InputFieldViewStyle.kt index 7c490fcea..8b06da8f3 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/InputFieldViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/InputFieldViewStyle.kt @@ -65,7 +65,9 @@ import com.checkout.frames.model.InputFieldColors * in focused state. * @param forceLTR force LTR usage even for RTL layout direction. */ -internal data class InputFieldViewStyle @OptIn(ExperimentalMaterial3Api::class) constructor( +internal data class InputFieldViewStyle +@OptIn(ExperimentalMaterial3Api::class) +constructor( var modifier: Modifier = Modifier.fillMaxWidth(), val enabled: Boolean = true, val readOnly: Boolean = false, @@ -82,5 +84,5 @@ internal data class InputFieldViewStyle @OptIn(ExperimentalMaterial3Api::class) val colors: InputFieldColors? = null, val focusedBorderThickness: Dp = TextFieldDefaults.FocusedBorderThickness, val unfocusedBorderThickness: Dp = TextFieldDefaults.UnfocusedBorderThickness, - var forceLTR: Boolean = false + var forceLTR: Boolean = false, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/InternalButtonViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/InternalButtonViewStyle.kt index 96214dbf0..db794e73d 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/InternalButtonViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/InternalButtonViewStyle.kt @@ -27,5 +27,5 @@ internal data class InternalButtonViewStyle( val shape: Shape, val border: BorderStroke? = null, val contentPadding: PaddingValues = ButtonDefaults.ContentPadding, - val textStyle: TextLabelViewStyle + val textStyle: TextLabelViewStyle, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/TextLabelViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/TextLabelViewStyle.kt index 752e14e29..2c9535323 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/TextLabelViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/TextLabelViewStyle.kt @@ -63,5 +63,5 @@ internal data class TextLabelViewStyle( val maxLines: Int = Int.MAX_VALUE, val onTextLayout: (TextLayoutResult) -> Unit = {}, val style: TextStyle? = null, - var textMaxWidth: Boolean = false + var textMaxWidth: Boolean = false, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/addresssummary/AddressSummaryComponentViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/addresssummary/AddressSummaryComponentViewStyle.kt index 2677be136..08805986b 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/addresssummary/AddressSummaryComponentViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/addresssummary/AddressSummaryComponentViewStyle.kt @@ -9,5 +9,5 @@ internal data class AddressSummaryComponentViewStyle( val subTitleStyle: TextLabelViewStyle?, val addAddressButtonStyle: InternalButtonViewStyle, val summarySectionStyle: AddressSummarySectionViewStyle, - val modifier: Modifier + val modifier: Modifier, ) diff --git a/frames/src/main/java/com/checkout/frames/style/view/addresssummary/AddressSummarySectionViewStyle.kt b/frames/src/main/java/com/checkout/frames/style/view/addresssummary/AddressSummarySectionViewStyle.kt index 3c32de553..eec1ea91f 100644 --- a/frames/src/main/java/com/checkout/frames/style/view/addresssummary/AddressSummarySectionViewStyle.kt +++ b/frames/src/main/java/com/checkout/frames/style/view/addresssummary/AddressSummarySectionViewStyle.kt @@ -9,5 +9,5 @@ internal data class AddressSummarySectionViewStyle( val addressTextStyle: TextLabelViewStyle, val dividerStyle: DividerViewStyle? = null, val editAddressButtonStyle: InternalButtonViewStyle, - val modifier: Modifier + val modifier: Modifier, ) diff --git a/frames/src/main/java/com/checkout/frames/usecase/CardTokenizationUseCase.kt b/frames/src/main/java/com/checkout/frames/usecase/CardTokenizationUseCase.kt index da8b4ebb4..09f867762 100644 --- a/frames/src/main/java/com/checkout/frames/usecase/CardTokenizationUseCase.kt +++ b/frames/src/main/java/com/checkout/frames/usecase/CardTokenizationUseCase.kt @@ -13,7 +13,7 @@ internal class CardTokenizationUseCase( /** Success callback from merchant. */ private val onSuccess: (tokenDetails: TokenDetails) -> Unit, /** Failure callback from merchant. */ - private val onFailure: (errorMessage: String) -> Unit + private val onFailure: (errorMessage: String) -> Unit, ) : UseCase { override fun execute(data: InternalCardTokenRequest) { @@ -23,8 +23,8 @@ internal class CardTokenizationUseCase( CardTokenRequest( card = data.card, onSuccess = { handleSuccess(it, data.onSuccess) }, - onFailure = { handleFailure(it, data.onFailure) } - ) + onFailure = { handleFailure(it, data.onFailure) }, + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/usecase/ClosePaymentFlowUseCase.kt b/frames/src/main/java/com/checkout/frames/usecase/ClosePaymentFlowUseCase.kt index cf274ffee..861265af8 100644 --- a/frames/src/main/java/com/checkout/frames/usecase/ClosePaymentFlowUseCase.kt +++ b/frames/src/main/java/com/checkout/frames/usecase/ClosePaymentFlowUseCase.kt @@ -3,7 +3,7 @@ package com.checkout.frames.usecase import com.checkout.base.usecase.UseCase internal class ClosePaymentFlowUseCase( - private val onClose: () -> Unit + private val onClose: () -> Unit, ) : UseCase { override fun execute(data: Unit) = onClose() diff --git a/frames/src/main/java/com/checkout/frames/utils/constants/AddressSummaryConstants.kt b/frames/src/main/java/com/checkout/frames/utils/constants/AddressSummaryConstants.kt index 7369c2efb..7db6d30ef 100644 --- a/frames/src/main/java/com/checkout/frames/utils/constants/AddressSummaryConstants.kt +++ b/frames/src/main/java/com/checkout/frames/utils/constants/AddressSummaryConstants.kt @@ -10,7 +10,7 @@ public object AddressSummaryConstants { start = 24, end = 24, bottom = 16, - top = 16 + top = 16, ) /** Default line height of address summary text in dp. **/ @@ -22,6 +22,7 @@ public object AddressSummaryConstants { /** Default margin before summary section in dp. **/ public const val marginBeforeSummarySection: Int = 8 + /** Default margin after summary section in dp. **/ public const val marginAfterSummarySection: Int = 8 } diff --git a/frames/src/main/java/com/checkout/frames/utils/constants/CardSchemeConstants.kt b/frames/src/main/java/com/checkout/frames/utils/constants/CardSchemeConstants.kt index 0187acb94..b6ee30aef 100644 --- a/frames/src/main/java/com/checkout/frames/utils/constants/CardSchemeConstants.kt +++ b/frames/src/main/java/com/checkout/frames/utils/constants/CardSchemeConstants.kt @@ -3,8 +3,10 @@ package com.checkout.frames.utils.constants public object CardSchemeConstants { /** The main axis spacing in dp between the images of each row */ public const val mainAxisSpacingPadding: Int = 4 + /** The cross axis spacing in dp between the rows of the images */ public const val crossAxisSpacingPadding: Int = 6 + /** Margin in dp. */ public const val marginTop: Int = 8 public const val marginBottom: Int = 24 diff --git a/frames/src/main/java/com/checkout/frames/utils/constants/ContainerConstants.kt b/frames/src/main/java/com/checkout/frames/utils/constants/ContainerConstants.kt index df3389424..171ebc8de 100644 --- a/frames/src/main/java/com/checkout/frames/utils/constants/ContainerConstants.kt +++ b/frames/src/main/java/com/checkout/frames/utils/constants/ContainerConstants.kt @@ -6,6 +6,7 @@ internal object ContainerConstants { const val backgroundColor: Long = 0x00000000 const val radius = 0 val shape = Shape.None + /** Padding in dp. */ const val paddingStart: Int = 6 const val paddingEnd: Int = 6 diff --git a/frames/src/main/java/com/checkout/frames/utils/constants/CountryPickerScreenConstants.kt b/frames/src/main/java/com/checkout/frames/utils/constants/CountryPickerScreenConstants.kt index 92d85403d..999d3960b 100644 --- a/frames/src/main/java/com/checkout/frames/utils/constants/CountryPickerScreenConstants.kt +++ b/frames/src/main/java/com/checkout/frames/utils/constants/CountryPickerScreenConstants.kt @@ -26,8 +26,10 @@ public object CountryPickerScreenConstants { @ColorLong public const val focusedBorderColor: Long = 0xFF000000 + @ColorLong public const val unfocusedBorderColor: Long = 0xFF8A8A8A + /** Focused border thickness in dp. */ public const val focusedBorderThickness: Int = 1 } diff --git a/frames/src/main/java/com/checkout/frames/utils/constants/HeaderTitleConstants.kt b/frames/src/main/java/com/checkout/frames/utils/constants/HeaderTitleConstants.kt index d4e11f873..dfa9b158c 100644 --- a/frames/src/main/java/com/checkout/frames/utils/constants/HeaderTitleConstants.kt +++ b/frames/src/main/java/com/checkout/frames/utils/constants/HeaderTitleConstants.kt @@ -6,6 +6,7 @@ import com.checkout.frames.model.font.Font public object HeaderTitleConstants { @ColorLong public const val textColor: Long = 0xFF141414 + @ColorLong public const val backgroundColor: Long = 0xFFFFFFFF @@ -19,6 +20,7 @@ public object HeaderTitleConstants { /** Leading icon size in dp. */ public const val leadingIconSize: Int = 14 + /** Leading icon margin in dp. */ public const val leadingIconPaddingEnd: Int = 8 public const val leadingIconPaddingStart: Int = 8 diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/BillingAddressDetailsExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/BillingAddressDetailsExtensions.kt index 949416d9c..d047e4ee2 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/BillingAddressDetailsExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/BillingAddressDetailsExtensions.kt @@ -10,7 +10,7 @@ import com.checkout.tokenization.model.Address import com.checkout.tokenization.model.Phone internal fun List.provideBillingAddressDetails( - country: Country? = null + country: Country? = null, ): BillingAddress { val phoneInputComponentState = this.find { it.addressFieldName == BillingFormFields.Phone.name @@ -48,12 +48,12 @@ internal fun List.provideBillingAddressDetail addressLine2 = addressLineTwoInputComponentState?.addressFieldText?.value?.trimEnd() ?: "", state = stateInputComponentState?.addressFieldText?.value?.trimEnd() ?: "", city = cityInputComponentState?.addressFieldText?.value?.trimEnd() ?: "", - zip = zipInputComponentState?.addressFieldText?.value?.trimEnd() ?: "" + zip = zipInputComponentState?.addressFieldText?.value?.trimEnd() ?: "", ), phone = phoneInputComponentState?.let { componentState -> componentState.addressFieldText.value.takeIf { it.isNotEmpty() } ?.let { Phone(componentState.addressFieldText.value, country) } - } + }, ) } @@ -88,7 +88,7 @@ internal fun BillingAddressInputComponentState.getErrorMessage(): Int { } internal fun BillingAddress.provideAddressFieldText( - addressFieldName: String + addressFieldName: String, ): String { return when (addressFieldName) { BillingFormFields.CardHolderName.name -> { diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/BillingAddressExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/BillingAddressExtensions.kt index 628e4367c..8aff57f3d 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/BillingAddressExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/BillingAddressExtensions.kt @@ -28,7 +28,7 @@ internal fun BillingAddress.summary(): String { "\n+${phone.country?.dialingCode} ${phone.number}" } else { "\n${phone.number}" - } + }, ) } } diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/FontExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/FontExtensions.kt index 62e0213bf..c75adb111 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/FontExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/FontExtensions.kt @@ -4,12 +4,12 @@ import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight -import com.checkout.frames.model.font.Font.Default -import com.checkout.frames.model.font.Font.Serif -import com.checkout.frames.model.font.Font.SansSerif -import com.checkout.frames.model.font.Font.Monospace import com.checkout.frames.model.font.Font.Cursive import com.checkout.frames.model.font.Font.Custom +import com.checkout.frames.model.font.Font.Default +import com.checkout.frames.model.font.Font.Monospace +import com.checkout.frames.model.font.Font.SansSerif +import com.checkout.frames.model.font.Font.Serif internal fun com.checkout.frames.model.font.Font.toFontFamily(): FontFamily = when (this) { is Default -> FontFamily.Default diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/FontStyleExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/FontStyleExtensions.kt index e3de25f4c..4ed7d16a6 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/FontStyleExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/FontStyleExtensions.kt @@ -1,8 +1,8 @@ package com.checkout.frames.utils.extensions import androidx.compose.ui.text.font.FontStyle -import com.checkout.frames.model.font.FontStyle.Normal import com.checkout.frames.model.font.FontStyle.Italic +import com.checkout.frames.model.font.FontStyle.Normal internal fun com.checkout.frames.model.font.FontStyle.toComposeFontStyle(): FontStyle = when (this) { Normal -> FontStyle.Normal diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/FontWeightExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/FontWeightExtensions.kt index 0718da157..7fcd23af2 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/FontWeightExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/FontWeightExtensions.kt @@ -1,12 +1,12 @@ package com.checkout.frames.utils.extensions import androidx.compose.ui.text.font.FontWeight +import com.checkout.frames.model.font.FontWeight.Bold +import com.checkout.frames.model.font.FontWeight.ExtraBold import com.checkout.frames.model.font.FontWeight.Light -import com.checkout.frames.model.font.FontWeight.Normal import com.checkout.frames.model.font.FontWeight.Medium +import com.checkout.frames.model.font.FontWeight.Normal import com.checkout.frames.model.font.FontWeight.SemiBold -import com.checkout.frames.model.font.FontWeight.Bold -import com.checkout.frames.model.font.FontWeight.ExtraBold internal fun com.checkout.frames.model.font.FontWeight.toComposeFontWeight(): FontWeight = when (this) { Light -> FontWeight.Light diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/ModifierExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/ModifierExtensions.kt index 315f2d4ca..618b13a81 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/ModifierExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/ModifierExtensions.kt @@ -1,13 +1,13 @@ package com.checkout.frames.utils.extensions import android.view.ViewTreeObserver -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.Composable -import androidx.compose.runtime.produceState +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.State import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.produceState +import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.composed @@ -24,8 +24,9 @@ internal fun Modifier.clearFocusOnKeyboardDismiss(): Modifier = composed { val focusManager = LocalFocusManager.current LaunchedEffect(isKeyboardOpen) { - if (isKeyboardOpen) keyboardAppearedSinceLastFocused = true - else if (keyboardAppearedSinceLastFocused) focusManager.clearFocus() + if (isKeyboardOpen) { + keyboardAppearedSinceLastFocused = true + } else if (keyboardAppearedSinceLastFocused) focusManager.clearFocus() } } diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/PaddingExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/PaddingExtensions.kt index 911f70f6e..3f62282a5 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/PaddingExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/PaddingExtensions.kt @@ -8,5 +8,5 @@ internal fun Padding.toPaddingValues() = PaddingValues( start = this.start.dp, top = this.top.dp, end = this.end.dp, - bottom = this.bottom.dp + bottom = this.bottom.dp, ) diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/PaymentFormStyleMapperExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/PaymentFormStyleMapperExtensions.kt index 6f9901ea9..572a4b527 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/PaymentFormStyleMapperExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/PaymentFormStyleMapperExtensions.kt @@ -1,14 +1,15 @@ @file:Suppress("TooManyFunctions") + package com.checkout.frames.utils.extensions import com.checkout.frames.model.Padding -import com.checkout.frames.style.component.base.TextLabelStyle -import com.checkout.frames.style.component.base.TextStyle -import com.checkout.frames.style.component.base.InputFieldIndicatorStyle +import com.checkout.frames.style.component.base.ButtonStyle +import com.checkout.frames.style.component.base.ContainerStyle import com.checkout.frames.style.component.base.InputComponentStyle +import com.checkout.frames.style.component.base.InputFieldIndicatorStyle import com.checkout.frames.style.component.base.InputFieldStyle -import com.checkout.frames.style.component.base.ContainerStyle -import com.checkout.frames.style.component.base.ButtonStyle +import com.checkout.frames.style.component.base.TextLabelStyle +import com.checkout.frames.style.component.base.TextStyle import com.checkout.frames.style.theme.PaymentFormComponent import com.checkout.frames.style.theme.PaymentFormTheme /** @@ -22,9 +23,9 @@ internal fun TextLabelStyle?.provideTitleStyle( text = text.provideText(component.titleText), textId = textId.provideTextId(component.titleText, component.titleTextId), leadingIconStyle = leadingIconStyle?.copy( - tinColor = from.paymentFormThemeColors.imageColors.tinColor + tinColor = from.paymentFormThemeColors.imageColors.tinColor, ), - textStyle = provideTitleTextStyle(from) + textStyle = provideTitleTextStyle(from), ) } @@ -35,7 +36,7 @@ internal fun TextLabelStyle?.provideSubTitleStyle( return this?.copy( text = text.provideText(component.subTitleText), textId = textId.provideTextId(component.subTitleText, component.subTitleTextId), - textStyle = provideSubTitleTextStyle(from) + textStyle = provideSubTitleTextStyle(from), ) } @@ -46,7 +47,7 @@ internal fun TextLabelStyle?.provideInfoStyle( return this?.copy( text = text.provideText(component.infoText), textId = textId.provideTextId(component.infoText, component.infoTextId), - textStyle = provideInfoTextStyle(from) + textStyle = provideInfoTextStyle(from), ) } @@ -55,8 +56,8 @@ internal fun TextLabelStyle?.provideErrorMessageStyle( ): TextLabelStyle? { return this?.copy( textStyle = this.textStyle.copy( - color = paymentFormTheme.paymentFormThemeColors.textColors.errorColor - ) + color = paymentFormTheme.paymentFormThemeColors.textColors.errorColor, + ), ) } @@ -107,7 +108,7 @@ internal fun PaymentFormTheme.provideIndicatorStyle(): InputFieldIndicatorStyle disabledBorderColor = paymentFormThemeColors.inputFieldColors.disabledBorderColor, errorBorderColor = paymentFormThemeColors.inputFieldColors.errorBorderColor, shape = paymentFormShape.inputFieldShape, - cornerRadius = paymentFormCornerRadius.inputFieldCornerRadius + cornerRadius = paymentFormCornerRadius.inputFieldCornerRadius, ) } @@ -116,15 +117,15 @@ internal fun InputComponentStyle.provideInputFieldStyle(from: PaymentFormTheme): indicatorStyle = from.provideIndicatorStyle(), textStyle = titleStyle.provideTitleTextStyle(from), trailingIconStyle = inputFieldStyle.trailingIconStyle?.copy( - tinColor = from.paymentFormThemeColors.imageColors.tinColor + tinColor = from.paymentFormThemeColors.imageColors.tinColor, ), cursorStyle = inputFieldStyle.cursorStyle?.copy( cursorColor = from.paymentFormThemeColors.cursorColors.cursorColor, cursorHandleColor = from.paymentFormThemeColors.cursorColors.cursorHandleColor, errorCursorColor = from.paymentFormThemeColors.cursorColors.errorCursorColor, - cursorHighlightColor = from.paymentFormThemeColors.cursorColors.cursorHighlightColor + cursorHighlightColor = from.paymentFormThemeColors.cursorColors.cursorHighlightColor, ), - containerStyle = inputFieldStyle.containerStyle.provideInputFieldContainerStyle(from) + containerStyle = inputFieldStyle.containerStyle.provideInputFieldContainerStyle(from), ) } @@ -134,7 +135,7 @@ internal fun ContainerStyle.provideInputFieldContainerStyle( return copy( color = from.paymentFormThemeColors.inputFieldColors.inputFieldBackgroundColor, shape = from.paymentFormShape.inputFieldShape, - cornerRadius = from.paymentFormCornerRadius.inputFieldCornerRadius + cornerRadius = from.paymentFormCornerRadius.inputFieldCornerRadius, ) } @@ -144,7 +145,7 @@ internal fun ContainerStyle.provideInputFieldContainerStyle( internal fun PaymentFormTheme.provideContainerStyle(padding: Padding? = null): ContainerStyle { return ContainerStyle().copy( color = paymentFormThemeColors.paymentFormColors.background, - padding = padding + padding = padding, ) } @@ -166,10 +167,10 @@ internal fun ButtonStyle.provideSolidButtonStyle( text = textStyle.text.provideText(component.titleText), textId = textStyle.textId.provideTextId(component.titleText, component.titleTextId), trailingIconStyle = textStyle.trailingIconStyle?.copy( - tinColor = from.paymentFormThemeColors.buttonColors.contentColor + tinColor = from.paymentFormThemeColors.buttonColors.contentColor, ), - textStyle = textStyle.provideTitleTextStyle(from) - ) + textStyle = textStyle.provideTitleTextStyle(from), + ), ) } @@ -182,7 +183,7 @@ internal fun ButtonStyle.provideOutLinedButtonStyle( disabledContentColor = from.paymentFormThemeColors.buttonColors.disabledContentColor, disabledContainerColor = from.paymentFormThemeColors.buttonColors.disabledContainerColor, borderStroke = borderStroke?.copy( - color = from.paymentFormThemeColors.buttonColors.containerColor + color = from.paymentFormThemeColors.buttonColors.containerColor, ), cornerRadius = from.paymentFormCornerRadius.buttonCornerRadius, shape = from.paymentFormShape.buttonShape, @@ -190,9 +191,9 @@ internal fun ButtonStyle.provideOutLinedButtonStyle( text = textStyle.text.provideText(component?.titleText), textId = textStyle.textId.provideTextId(component?.titleText, component?.titleTextId), trailingIconStyle = textStyle.trailingIconStyle?.copy( - tinColor = from.paymentFormThemeColors.buttonColors.contentColor + tinColor = from.paymentFormThemeColors.buttonColors.contentColor, ), - textStyle = textStyle.provideTitleTextStyle(from) - ) + textStyle = textStyle.provideTitleTextStyle(from), + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/ShapeExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/ShapeExtensions.kt index 35d303705..1167d5337 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/ShapeExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/ShapeExtensions.kt @@ -8,8 +8,8 @@ import androidx.compose.ui.graphics.Shape import androidx.compose.ui.unit.dp import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.Shape.Circle -import com.checkout.frames.model.Shape.RoundCorner import com.checkout.frames.model.Shape.CutCorner +import com.checkout.frames.model.Shape.RoundCorner internal fun com.checkout.frames.model.Shape.toComposeShape(cornerRadius: CornerRadius): Shape = when (this) { Circle -> CircleShape @@ -17,13 +17,13 @@ internal fun com.checkout.frames.model.Shape.toComposeShape(cornerRadius: Corner cornerRadius.topStart.dp, cornerRadius.topEnd.dp, cornerRadius.bottomEnd.dp, - cornerRadius.bottomStart.dp + cornerRadius.bottomStart.dp, ) CutCorner -> CutCornerShape( cornerRadius.topStart.dp, cornerRadius.topEnd.dp, cornerRadius.bottomEnd.dp, - cornerRadius.bottomStart.dp + cornerRadius.bottomStart.dp, ) else -> RectangleShape } diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/StringExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/StringExtensions.kt index 604ecf886..930655a63 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/StringExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/StringExtensions.kt @@ -10,11 +10,11 @@ internal fun String.toExpiryDate(): ExpiryDate { return when (this.length) { shortMonthDateLength -> ExpiryDate( expiryMonth = this[0].toString().toInt(), - expiryYear = this.substring(1..2).toInt() + expiryYear = this.substring(1..2).toInt(), ) fullMonthDateLength -> ExpiryDate( expiryMonth = this.substring(0..1).toInt(), - expiryYear = this.substring(2..3).toInt() + expiryYear = this.substring(2..3).toInt(), ) else -> ExpiryDate(0, 0) } diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/TextAlignExtension.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/TextAlignExtension.kt index 681975310..3f5a03d6e 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/TextAlignExtension.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/TextAlignExtension.kt @@ -1,9 +1,9 @@ package com.checkout.frames.utils.extensions import androidx.compose.ui.text.style.TextAlign -import com.checkout.frames.model.TextAlign.Start import com.checkout.frames.model.TextAlign.Center import com.checkout.frames.model.TextAlign.End +import com.checkout.frames.model.TextAlign.Start internal fun com.checkout.frames.model.TextAlign.toComposeTextAlign(): TextAlign = when (this) { Start -> TextAlign.Start diff --git a/frames/src/main/java/com/checkout/frames/utils/extensions/TextStyleExtensions.kt b/frames/src/main/java/com/checkout/frames/utils/extensions/TextStyleExtensions.kt index 147928646..9a5d270e4 100644 --- a/frames/src/main/java/com/checkout/frames/utils/extensions/TextStyleExtensions.kt +++ b/frames/src/main/java/com/checkout/frames/utils/extensions/TextStyleExtensions.kt @@ -12,5 +12,5 @@ internal fun com.checkout.frames.style.component.base.TextStyle.toComposeTextSty fontFamily = this.font.toFontFamily(), fontStyle = this.fontStyle.toComposeFontStyle(), fontWeight = this.fontWeight.toComposeFontWeight(), - lineHeight = this.lineHeight?.sp ?: TextUnit.Unspecified + lineHeight = this.lineHeight?.sp ?: TextUnit.Unspecified, ) diff --git a/frames/src/main/java/com/checkout/frames/view/InputField.kt b/frames/src/main/java/com/checkout/frames/view/InputField.kt index 06d08eb8a..684736bdd 100644 --- a/frames/src/main/java/com/checkout/frames/view/InputField.kt +++ b/frames/src/main/java/com/checkout/frames/view/InputField.kt @@ -4,9 +4,9 @@ import android.annotation.SuppressLint import androidx.compose.foundation.background import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.defaultMinSize -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CutCornerShape import androidx.compose.foundation.shape.RoundedCornerShape @@ -15,25 +15,25 @@ import androidx.compose.foundation.text.selection.LocalTextSelectionColors import androidx.compose.foundation.text.selection.TextSelectionColors import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.LocalTextStyle -import androidx.compose.material3.TextFieldDefaults -import androidx.compose.material3.TextFieldColors -import androidx.compose.material3.Surface import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.TextFieldColors +import androidx.compose.material3.TextFieldDefaults import androidx.compose.material3.TextFieldDefaults.indicatorLine import androidx.compose.material3.TextFieldDefaults.outlinedTextFieldColors import androidx.compose.material3.TextFieldDefaults.textFieldColors import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.remember import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.focus.onFocusChanged -import androidx.compose.ui.graphics.takeOrElse -import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.RectangleShape +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.graphics.takeOrElse import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.VisualTransformation @@ -44,8 +44,8 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import com.checkout.frames.model.InputFieldColors -import com.checkout.frames.utils.constants.BorderConstants import com.checkout.frames.style.view.InputFieldViewStyle +import com.checkout.frames.utils.constants.BorderConstants import com.checkout.frames.utils.extensions.clearFocusOnKeyboardDismiss @Composable @@ -54,7 +54,7 @@ internal fun InputField( style: InputFieldViewStyle, state: InputFieldState, onValueChange: (String) -> Unit, - onFocusChanged: ((Boolean) -> Unit)? = null + onFocusChanged: ((Boolean) -> Unit)? = null, ) = with(style) { val interactionSource = interactionSource ?: remember { MutableInteractionSource() } val textStyle = provideTextStyle(this) @@ -69,14 +69,16 @@ internal fun InputField( .onFocusChanged { onFocusChanged?.let { onFocusChanged -> onFocusChanged(it.isFocused) } } .defaultMinSize(TextFieldDefaults.MinWidth, TextFieldDefaults.MinHeight) - if (borderShape == null) modifier = modifier.indicatorLine( - enabled, - state.isError.value, - interactionSource, - colors, - focusedIndicatorLineThickness = focusedBorderThickness, - unfocusedIndicatorLineThickness = unfocusedBorderThickness - ) + if (borderShape == null) { + modifier = modifier.indicatorLine( + enabled, + state.isError.value, + interactionSource, + colors, + focusedIndicatorLineThickness = focusedBorderThickness, + unfocusedIndicatorLineThickness = unfocusedBorderThickness, + ) + } CompositionLocalProvider(LocalTextSelectionColors provides textSelectionColors) { BasicTextField( @@ -108,9 +110,9 @@ internal fun InputField( colors = colors, borderShape = borderShape, focusedBorderThickness = focusedBorderThickness, - unfocusedBorderThickness = unfocusedBorderThickness + unfocusedBorderThickness = unfocusedBorderThickness, ) - } + }, ) } } @@ -132,47 +134,50 @@ private fun DecorationBox( colors: TextFieldColors, borderShape: Shape?, focusedBorderThickness: Dp, - unfocusedBorderThickness: Dp + unfocusedBorderThickness: Dp, ) { - if (borderShape == null) TextFieldDefaults.TextFieldDecorationBox( - value = value, - visualTransformation = visualTransformation, - innerTextField = innerTextField, - placeholder = placeholder, - label = null, - leadingIcon = leadingIcon, - trailingIcon = trailingIcon, - singleLine = singleLine, - enabled = enabled, - isError = isError, - interactionSource = interactionSource, - colors = colors - ) - else TextFieldDefaults.OutlinedTextFieldDecorationBox( - value = value, - visualTransformation = visualTransformation, - innerTextField = innerTextField, - placeholder = placeholder, - label = null, - leadingIcon = leadingIcon, - trailingIcon = trailingIcon, - singleLine = singleLine, - enabled = enabled, - isError = isError, - interactionSource = interactionSource, - colors = colors, - container = { - TextFieldDefaults.OutlinedBorderContainerBox( - enabled, - isError, - interactionSource, - colors, - borderShape, - focusedBorderThickness = focusedBorderThickness, - unfocusedBorderThickness = unfocusedBorderThickness - ) - } - ) + if (borderShape == null) { + TextFieldDefaults.TextFieldDecorationBox( + value = value, + visualTransformation = visualTransformation, + innerTextField = innerTextField, + placeholder = placeholder, + label = null, + leadingIcon = leadingIcon, + trailingIcon = trailingIcon, + singleLine = singleLine, + enabled = enabled, + isError = isError, + interactionSource = interactionSource, + colors = colors, + ) + } else { + TextFieldDefaults.OutlinedTextFieldDecorationBox( + value = value, + visualTransformation = visualTransformation, + innerTextField = innerTextField, + placeholder = placeholder, + label = null, + leadingIcon = leadingIcon, + trailingIcon = trailingIcon, + singleLine = singleLine, + enabled = enabled, + isError = isError, + interactionSource = interactionSource, + colors = colors, + container = { + TextFieldDefaults.OutlinedBorderContainerBox( + enabled, + isError, + interactionSource, + colors, + borderShape, + focusedBorderThickness = focusedBorderThickness, + unfocusedBorderThickness = unfocusedBorderThickness, + ) + }, + ) + } } @OptIn(ExperimentalMaterial3Api::class) @@ -181,7 +186,7 @@ private fun DecorationBox( private fun provideInputFieldColors( withBorder: Boolean, withContainerShape: Boolean, - colors: InputFieldColors? + colors: InputFieldColors?, ): TextFieldColors { val textColor = colors?.textColor ?: Color.Black val placeholderColor = colors?.placeholderColor ?: Color.Gray @@ -194,34 +199,38 @@ private fun provideInputFieldColors( val errorCursorColor = colors?.errorCursorColor ?: colors?.errorIndicatorColor ?: Color(BorderConstants.errorBorderColor) - return if (withBorder) outlinedTextFieldColors( - textColor = textColor, - placeholderColor = placeholderColor, - focusedBorderColor = focusedIndicatorColor, - unfocusedBorderColor = unfocusedIndicatorColor, - disabledBorderColor = disabledIndicatorColor, - errorBorderColor = errorIndicatorColor, - containerColor = containerColor, - cursorColor = cursorColor, - errorCursorColor = errorCursorColor - ) else textFieldColors( - textColor = textColor, - placeholderColor = placeholderColor, - focusedIndicatorColor = if (withContainerShape) Color.Transparent else focusedIndicatorColor, - unfocusedIndicatorColor = if (withContainerShape) Color.Transparent else unfocusedIndicatorColor, - disabledIndicatorColor = if (withContainerShape) Color.Transparent else disabledIndicatorColor, - errorIndicatorColor = if (withContainerShape) Color.Transparent else errorIndicatorColor, - containerColor = if (withContainerShape) Color.Transparent else containerColor, - cursorColor = cursorColor, - errorCursorColor = errorCursorColor - ) + return if (withBorder) { + outlinedTextFieldColors( + textColor = textColor, + placeholderColor = placeholderColor, + focusedBorderColor = focusedIndicatorColor, + unfocusedBorderColor = unfocusedIndicatorColor, + disabledBorderColor = disabledIndicatorColor, + errorBorderColor = errorIndicatorColor, + containerColor = containerColor, + cursorColor = cursorColor, + errorCursorColor = errorCursorColor, + ) + } else { + textFieldColors( + textColor = textColor, + placeholderColor = placeholderColor, + focusedIndicatorColor = if (withContainerShape) Color.Transparent else focusedIndicatorColor, + unfocusedIndicatorColor = if (withContainerShape) Color.Transparent else unfocusedIndicatorColor, + disabledIndicatorColor = if (withContainerShape) Color.Transparent else disabledIndicatorColor, + errorIndicatorColor = if (withContainerShape) Color.Transparent else errorIndicatorColor, + containerColor = if (withContainerShape) Color.Transparent else containerColor, + cursorColor = cursorColor, + errorCursorColor = errorCursorColor, + ) + } } @Composable private fun provideTextSelectionColors(inputColors: InputFieldColors?, cursorColor: Color): TextSelectionColors { return TextSelectionColors( handleColor = inputColors?.cursorHandleColor ?: cursorColor, - backgroundColor = inputColors?.cursorHighlightColor ?: cursorColor.copy(alpha = 0.4f) + backgroundColor = inputColors?.cursorHighlightColor ?: cursorColor.copy(alpha = 0.4f), ) } @@ -229,8 +238,9 @@ private fun provideTextSelectionColors(inputColors: InputFieldColors?, cursorCol private fun provideTextStyle(style: InputFieldViewStyle): TextStyle { var textStyle = style.textStyle ?: LocalTextStyle.current - if (style.forceLTR && LocalLayoutDirection.current == LayoutDirection.Rtl) + if (style.forceLTR && LocalLayoutDirection.current == LayoutDirection.Rtl) { textStyle = textStyle.copy(textDirection = TextDirection.Ltr, textAlign = TextAlign.End) + } return textStyle } @@ -262,7 +272,7 @@ private fun InputFieldPreview() { modifier = Modifier .padding(12.dp) .fillMaxWidth(), - color = MaterialTheme.colorScheme.background + color = MaterialTheme.colorScheme.background, ) { InputField( InputFieldViewStyle( @@ -270,10 +280,10 @@ private fun InputFieldPreview() { .fillMaxWidth() .height(56.dp), colors = InputFieldColors(containerColor = Color.Transparent), - placeholder = { Text(text = "Test placeholder") } + placeholder = { Text(text = "Test placeholder") }, ), InputFieldState(text), - { text.value = it } + { text.value = it }, ) } } @@ -288,7 +298,7 @@ private fun RoundInputFieldPreview() { modifier = Modifier .padding(12.dp) .fillMaxWidth(), - color = MaterialTheme.colorScheme.background + color = MaterialTheme.colorScheme.background, ) { InputField( InputFieldViewStyle( @@ -298,13 +308,13 @@ private fun RoundInputFieldPreview() { colors = InputFieldColors( containerColor = Color.Gray, placeholderColor = Color.White, - unfocusedIndicatorColor = Color.Transparent + unfocusedIndicatorColor = Color.Transparent, ), placeholder = { Text(text = "Test placeholder") }, - containerShape = RoundedCornerShape(12.dp) + containerShape = RoundedCornerShape(12.dp), ), InputFieldState(text), - { text.value = it } + { text.value = it }, ) } } @@ -319,7 +329,7 @@ private fun CustomOutlineInputFieldPreview() { modifier = Modifier .padding(12.dp) .fillMaxWidth(), - color = MaterialTheme.colorScheme.background + color = MaterialTheme.colorScheme.background, ) { InputField( InputFieldViewStyle( @@ -327,10 +337,10 @@ private fun CustomOutlineInputFieldPreview() { .fillMaxWidth() .height(56.dp), placeholder = { Text(text = "Test placeholder Outline") }, - borderShape = RectangleShape + borderShape = RectangleShape, ), InputFieldState(text), - { text.value = it } + { text.value = it }, ) } } @@ -345,7 +355,7 @@ private fun CutCornerOutlineInputFieldPreview() { modifier = Modifier .padding(12.dp) .fillMaxWidth(), - color = MaterialTheme.colorScheme.background + color = MaterialTheme.colorScheme.background, ) { InputField( InputFieldViewStyle( @@ -355,10 +365,10 @@ private fun CutCornerOutlineInputFieldPreview() { placeholder = { Text(text = "Test placeholder Outline") }, colors = InputFieldColors(unfocusedIndicatorColor = Color.Blue), borderShape = CutCornerShape(16.dp), - unfocusedBorderThickness = 4.dp + unfocusedBorderThickness = 4.dp, ), InputFieldState(text), - { text.value = it } + { text.value = it }, ) } } @@ -373,7 +383,7 @@ private fun CircleOutlineInputFieldPreview() { modifier = Modifier .padding(12.dp) .fillMaxWidth(), - color = MaterialTheme.colorScheme.background + color = MaterialTheme.colorScheme.background, ) { InputField( InputFieldViewStyle( @@ -383,10 +393,10 @@ private fun CircleOutlineInputFieldPreview() { placeholder = { Text(text = "Test placeholder Outline") }, colors = InputFieldColors(unfocusedIndicatorColor = Color.Magenta), borderShape = CircleShape, - unfocusedBorderThickness = 2.dp + unfocusedBorderThickness = 2.dp, ), InputFieldState(text), - { text.value = it } + { text.value = it }, ) } } diff --git a/frames/src/main/java/com/checkout/frames/view/InputFieldState.kt b/frames/src/main/java/com/checkout/frames/view/InputFieldState.kt index f3b20ae7f..c85a8ba9f 100644 --- a/frames/src/main/java/com/checkout/frames/view/InputFieldState.kt +++ b/frames/src/main/java/com/checkout/frames/view/InputFieldState.kt @@ -17,5 +17,5 @@ internal data class InputFieldState( val maxLength: MutableState = mutableStateOf(null), val leadingIcon: MutableState<@Composable (() -> Unit)?> = mutableStateOf(null), val trailingIcon: MutableState<@Composable (() -> Unit)?> = mutableStateOf(null), - val isError: MutableState = mutableStateOf(false) + val isError: MutableState = mutableStateOf(false), ) diff --git a/frames/src/main/java/com/checkout/frames/view/InternalButton.kt b/frames/src/main/java/com/checkout/frames/view/InternalButton.kt index 5f057099e..7c443c83f 100644 --- a/frames/src/main/java/com/checkout/frames/view/InternalButton.kt +++ b/frames/src/main/java/com/checkout/frames/view/InternalButton.kt @@ -6,23 +6,23 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import com.checkout.frames.R -import com.checkout.frames.mapper.ImageStyleToComposableImageMapper import com.checkout.frames.mapper.ButtonStyleToInternalStateMapper import com.checkout.frames.mapper.ButtonStyleToInternalViewStyleMapper import com.checkout.frames.mapper.ContainerStyleToModifierMapper +import com.checkout.frames.mapper.ImageStyleToComposableImageMapper import com.checkout.frames.mapper.TextLabelStyleToStateMapper import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper -import com.checkout.frames.model.Shape -import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.BorderStroke -import com.checkout.frames.model.Padding import com.checkout.frames.model.ButtonElevation +import com.checkout.frames.model.CornerRadius import com.checkout.frames.model.Margin +import com.checkout.frames.model.Padding +import com.checkout.frames.model.Shape import com.checkout.frames.model.font.Font import com.checkout.frames.style.component.base.ButtonStyle -import com.checkout.frames.style.component.base.TextStyle -import com.checkout.frames.style.component.base.ImageStyle import com.checkout.frames.style.component.base.ContainerStyle +import com.checkout.frames.style.component.base.ImageStyle +import com.checkout.frames.style.component.base.TextStyle import com.checkout.frames.style.component.default.DefaultTextLabelStyle import com.checkout.frames.style.view.InternalButtonViewStyle @@ -30,7 +30,7 @@ import com.checkout.frames.style.view.InternalButtonViewStyle internal fun InternalButton( style: InternalButtonViewStyle, state: InternalButtonState, - onClick: () -> Unit + onClick: () -> Unit, ) = with(style) { style.textStyle.color = Color.Unspecified @@ -42,7 +42,7 @@ internal fun InternalButton( shape = shape, border = border, colors = provideColors(style), - contentPadding = contentPadding + contentPadding = contentPadding, ) { TextLabel(style = style.textStyle, state = state.textState) } @@ -53,7 +53,7 @@ private fun provideButtonElevation(style: InternalButtonViewStyle) = ButtonDefau style.defaultElevation, style.pressedElevation, style.focusedElevation, - style.hoveredElevation + style.hoveredElevation, ) @Composable @@ -61,7 +61,7 @@ private fun provideColors(style: InternalButtonViewStyle) = ButtonDefaults.butto containerColor = style.containerColor, contentColor = style.contentColor, disabledContainerColor = style.disabledContainerColor, - disabledContentColor = style.disabledContentColor + disabledContentColor = style.disabledContentColor, ) @SuppressWarnings("MagicNumber") @@ -71,12 +71,12 @@ private fun OutlineButtonPreview() { val containerMapper = ContainerStyleToModifierMapper() val styleMapper = ButtonStyleToInternalViewStyleMapper( containerMapper, - TextLabelStyleToViewStyleMapper(containerMapper) + TextLabelStyleToViewStyleMapper(containerMapper), ) val stateMapper = ButtonStyleToInternalStateMapper( TextLabelStyleToStateMapper( - imageMapper = ImageStyleToComposableImageMapper() - ) + imageMapper = ImageStyleToComposableImageMapper(), + ), ) val style = ButtonStyle( @@ -95,17 +95,17 @@ private fun OutlineButtonPreview() { image = R.drawable.cko_ic_caret_right, tinColor = 0xFF0B5FF0, height = 12, - padding = Padding(start = 12) - ) + padding = Padding(start = 12), + ), ), - containerStyle = ContainerStyle(margin = Margin(16)) + containerStyle = ContainerStyle(margin = Margin(16)), ) val state = stateMapper.map(style) InternalButton( styleMapper.map(style).apply { textStyle.textMaxWidth = true }, - state + state, ) { state.isEnabled.value = !state.isEnabled.value } } @@ -116,12 +116,12 @@ private fun ButtonPreview() { val containerMapper = ContainerStyleToModifierMapper() val styleMapper = ButtonStyleToInternalViewStyleMapper( containerMapper, - TextLabelStyleToViewStyleMapper(containerMapper) + TextLabelStyleToViewStyleMapper(containerMapper), ) val stateMapper = ButtonStyleToInternalStateMapper( TextLabelStyleToStateMapper( - imageMapper = ImageStyleToComposableImageMapper() - ) + imageMapper = ImageStyleToComposableImageMapper(), + ), ) val style = ButtonStyle( @@ -134,16 +134,16 @@ private fun ButtonPreview() { contentPadding = Padding(start = 16, end = 16, top = 8, bottom = 8), textStyle = DefaultTextLabelStyle.title().copy( textStyle = TextStyle(size = 15, font = Font.SansSerif), - text = "Save" + text = "Save", ), buttonElevation = ButtonElevation(defaultElevation = 8), - containerStyle = ContainerStyle(margin = Margin(16)) + containerStyle = ContainerStyle(margin = Margin(16)), ) val state = stateMapper.map(style) InternalButton( styleMapper.map(style), - state + state, ) { state.isEnabled.value = !state.isEnabled.value } } diff --git a/frames/src/main/java/com/checkout/frames/view/InternalButtonState.kt b/frames/src/main/java/com/checkout/frames/view/InternalButtonState.kt index bc325d52a..015726e14 100644 --- a/frames/src/main/java/com/checkout/frames/view/InternalButtonState.kt +++ b/frames/src/main/java/com/checkout/frames/view/InternalButtonState.kt @@ -5,5 +5,5 @@ import androidx.compose.runtime.mutableStateOf internal data class InternalButtonState( val isEnabled: MutableState = mutableStateOf(false), - val textState: TextLabelState + val textState: TextLabelState, ) diff --git a/frames/src/main/java/com/checkout/frames/view/TextLabel.kt b/frames/src/main/java/com/checkout/frames/view/TextLabel.kt index 15d16ce3f..fce52a051 100644 --- a/frames/src/main/java/com/checkout/frames/view/TextLabel.kt +++ b/frames/src/main/java/com/checkout/frames/view/TextLabel.kt @@ -20,10 +20,10 @@ import com.checkout.frames.style.view.TextLabelViewStyle @Composable internal fun TextLabel( style: TextLabelViewStyle, - state: TextLabelState + state: TextLabelState, ) = Row( modifier = style.modifier, - verticalAlignment = Alignment.CenterVertically + verticalAlignment = Alignment.CenterVertically, ) { val text = state.textId.value?.let { stringResource(id = it) } ?: state.text.value with(style) { @@ -44,7 +44,7 @@ internal fun TextLabel( softWrap, maxLines, onTextLayout, - this.style ?: LocalTextStyle.current + this.style ?: LocalTextStyle.current, ) state.trailingIcon.value?.let { it() } } @@ -62,19 +62,19 @@ private fun TextLabelPreview() { tinColor = 0xFFFF00FF, height = 48, width = 48, - Padding(start = 8, end = 8) + Padding(start = 8, end = 8), ) TextLabel( style = TextLabelViewStyle( style = TextStyle( - color = Color.Gray - ) + color = Color.Gray, + ), ), state = TextLabelState( mutableStateOf("Test label text"), leadingIcon = mutableStateOf(imageMapper.map(imageStyle)), - trailingIcon = mutableStateOf(imageMapper.map(imageStyle)) - ) + trailingIcon = mutableStateOf(imageMapper.map(imageStyle)), + ), ) } diff --git a/frames/src/main/java/com/checkout/frames/view/TextLabelState.kt b/frames/src/main/java/com/checkout/frames/view/TextLabelState.kt index 17bdc2f90..0268ca10f 100644 --- a/frames/src/main/java/com/checkout/frames/view/TextLabelState.kt +++ b/frames/src/main/java/com/checkout/frames/view/TextLabelState.kt @@ -16,5 +16,5 @@ internal data class TextLabelState( val textId: MutableState = mutableStateOf(null), val leadingIcon: MutableState<@Composable (() -> Unit)?> = mutableStateOf(null), val trailingIcon: MutableState<@Composable (() -> Unit)?> = mutableStateOf(null), - val isVisible: MutableState = mutableStateOf(false) + val isVisible: MutableState = mutableStateOf(false), ) diff --git a/frames/src/test/java/com/checkout/frames/component/addresssummary/AddressSummaryViewModelTest.kt b/frames/src/test/java/com/checkout/frames/component/addresssummary/AddressSummaryViewModelTest.kt index 8ec038d87..3306dcd1f 100644 --- a/frames/src/test/java/com/checkout/frames/component/addresssummary/AddressSummaryViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/addresssummary/AddressSummaryViewModelTest.kt @@ -4,13 +4,13 @@ import android.annotation.SuppressLint import com.checkout.base.mapper.Mapper import com.checkout.base.model.Country import com.checkout.frames.mapper.BillingFormAddressToBillingAddressMapper -import com.checkout.frames.mapper.TextLabelStyleToStateMapper -import com.checkout.frames.mapper.ImageStyleToComposableImageMapper -import com.checkout.frames.mapper.ContainerStyleToModifierMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper +import com.checkout.frames.mapper.ButtonStyleToInternalStateMapper import com.checkout.frames.mapper.ButtonStyleToInternalViewStyleMapper +import com.checkout.frames.mapper.ContainerStyleToModifierMapper import com.checkout.frames.mapper.DividerStyleToViewStyleMapper -import com.checkout.frames.mapper.ButtonStyleToInternalStateMapper +import com.checkout.frames.mapper.ImageStyleToComposableImageMapper +import com.checkout.frames.mapper.TextLabelStyleToStateMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mapper.addresssummary.AddressSummaryComponentStyleToStateMapper import com.checkout.frames.mapper.addresssummary.AddressSummaryComponentStyleToViewStyleMapper import com.checkout.frames.mapper.addresssummary.AddressSummarySectionStyleToViewStyleMapper @@ -66,7 +66,7 @@ internal class AddressSummaryViewModelTest { initMappers() spyPaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper + billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper, ) } @@ -75,7 +75,7 @@ internal class AddressSummaryViewModelTest { Dispatchers.setMain(dispatcher) viewModel = AddressSummaryViewModel( - style, spyPaymentStateManager, spyComponentStateMapper, spyComponentStyleMapper + style, spyPaymentStateManager, spyComponentStateMapper, spyComponentStyleMapper, ) } @@ -121,9 +121,9 @@ internal class AddressSummaryViewModelTest { "", "", "ssdfsdf", - country + country, ), - phone = Phone("123", country) + phone = Phone("123", country), ) val expectedAddressPreview = "LINE 1\nLINE 2\nssdfsdf\nUnited Kingdom\n+44 123" spyPaymentStateManager.billingAddress.value = testAddress @@ -161,14 +161,17 @@ internal class AddressSummaryViewModelTest { val buttonStyleMapper: Mapper = ButtonStyleToInternalViewStyleMapper(containerMapper, textLabelStyleMapper) val addressSectionStyleMapper = AddressSummarySectionStyleToViewStyleMapper( - textLabelStyleMapper, DividerStyleToViewStyleMapper(), buttonStyleMapper, containerMapper + textLabelStyleMapper, + DividerStyleToViewStyleMapper(), + buttonStyleMapper, + containerMapper, ) spyComponentStyleMapper = AddressSummaryComponentStyleToViewStyleMapper( - textLabelStyleMapper, buttonStyleMapper, addressSectionStyleMapper, containerMapper + textLabelStyleMapper, buttonStyleMapper, addressSectionStyleMapper, containerMapper, ) spyComponentStateMapper = AddressSummaryComponentStyleToStateMapper( - textLabelStateMapper, ButtonStyleToInternalStateMapper(textLabelStateMapper) + textLabelStateMapper, ButtonStyleToInternalStateMapper(textLabelStateMapper), ) } } diff --git a/frames/src/test/java/com/checkout/frames/component/cardholdername/CardHolderNameViewModelTest.kt b/frames/src/test/java/com/checkout/frames/component/cardholdername/CardHolderNameViewModelTest.kt index abe6faa3c..2b66e3c99 100644 --- a/frames/src/test/java/com/checkout/frames/component/cardholdername/CardHolderNameViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/cardholdername/CardHolderNameViewModelTest.kt @@ -6,13 +6,13 @@ import com.checkout.frames.R import com.checkout.frames.component.base.InputComponentState import com.checkout.frames.mapper.BillingFormAddressToBillingAddressMapper import com.checkout.frames.mapper.ContainerStyleToModifierMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mapper.ImageStyleToComposableImageMapper -import com.checkout.frames.mapper.InputComponentStyleToViewStyleMapper -import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper import com.checkout.frames.mapper.InputComponentStyleToStateMapper +import com.checkout.frames.mapper.InputComponentStyleToViewStyleMapper import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper +import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper import com.checkout.frames.mapper.TextLabelStyleToStateMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.screen.manager.PaymentFormStateManager import com.checkout.frames.screen.manager.PaymentStateManager import com.checkout.frames.style.component.CardHolderNameComponentStyle @@ -22,8 +22,8 @@ import io.mockk.impl.annotations.SpyK import io.mockk.junit5.MockKExtension import io.mockk.verify import org.amshove.kluent.internal.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -185,23 +185,23 @@ internal class CardHolderNameViewModelTest { val imageMapper = ImageStyleToComposableImageMapper() spyInputComponentStyleMapper = InputComponentStyleToViewStyleMapper( - textLabelStyleMapper, InputFieldStyleToViewStyleMapper(textLabelStyleMapper), containerMapper + textLabelStyleMapper, InputFieldStyleToViewStyleMapper(textLabelStyleMapper), containerMapper, ) spyInputComponentStateMapper = InputComponentStyleToStateMapper( - TextLabelStyleToStateMapper(imageMapper), InputFieldStyleToInputFieldStateMapper(imageMapper) + TextLabelStyleToStateMapper(imageMapper), InputFieldStyleToInputFieldStateMapper(imageMapper), ) } private fun initPaymentStateManager() { spyPaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) } private fun initViewModel() { viewModel = CardHolderNameViewModel( - spyPaymentStateManager, spyInputComponentStyleMapper, spyInputComponentStateMapper, style + spyPaymentStateManager, spyInputComponentStyleMapper, spyInputComponentStateMapper, style, ) } } diff --git a/frames/src/test/java/com/checkout/frames/component/cardnumber/CardNumberTransformationTest.kt b/frames/src/test/java/com/checkout/frames/component/cardnumber/CardNumberTransformationTest.kt index 794c282dc..fd7f55bf7 100644 --- a/frames/src/test/java/com/checkout/frames/component/cardnumber/CardNumberTransformationTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/cardnumber/CardNumberTransformationTest.kt @@ -28,14 +28,14 @@ internal class CardNumberTransformationTest { } @ParameterizedTest( - name = "When visual transformation receives {0} then {1} is received" + name = "When visual transformation receives {0} then {1} is received", ) @MethodSource("cardNumberTransformationArguments") fun `when visual transformation receives a string then correctly formatted string is provided`( separator: Char, cardScheme: CardScheme, enteredNumber: String, - transformedNumber: String + transformedNumber: String, ) { // Given setUpVisualTransformation(separator) @@ -73,7 +73,7 @@ internal class CardNumberTransformationTest { Arguments.of(' ', CardScheme.MASTERCARD, "12341234123", "1234 1234 123"), Arguments.of(' ', CardScheme.VISA, "1234123412341111", "1234 1234 1234 1111 "), Arguments.of(' ', CardScheme.VISA, "12341234123", "1234 1234 123"), - Arguments.of(' ', CardScheme.VISA, "4000001234562345678", "4000 0012 3456 2345 678") + Arguments.of(' ', CardScheme.VISA, "4000001234562345678", "4000 0012 3456 2345 678"), ) } } diff --git a/frames/src/test/java/com/checkout/frames/component/cardnumber/CardNumberViewModelTest.kt b/frames/src/test/java/com/checkout/frames/component/cardnumber/CardNumberViewModelTest.kt index 090dff7b8..5886c48c6 100644 --- a/frames/src/test/java/com/checkout/frames/component/cardnumber/CardNumberViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/cardnumber/CardNumberViewModelTest.kt @@ -8,15 +8,15 @@ import com.checkout.base.model.CardScheme import com.checkout.frames.R import com.checkout.frames.component.base.InputComponentState import com.checkout.frames.mapper.BillingFormAddressToBillingAddressMapper -import com.checkout.frames.mapper.ImageStyleToDynamicComposableImageMapper import com.checkout.frames.mapper.ContainerStyleToModifierMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mapper.ImageStyleToComposableImageMapper -import com.checkout.frames.mapper.InputComponentStyleToViewStyleMapper -import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper +import com.checkout.frames.mapper.ImageStyleToDynamicComposableImageMapper import com.checkout.frames.mapper.InputComponentStyleToStateMapper +import com.checkout.frames.mapper.InputComponentStyleToViewStyleMapper import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper +import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper import com.checkout.frames.mapper.TextLabelStyleToStateMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.screen.manager.PaymentFormStateManager import com.checkout.frames.screen.manager.PaymentStateManager import com.checkout.frames.style.component.CardNumberComponentStyle @@ -29,10 +29,9 @@ import io.mockk.impl.annotations.RelaxedMockK import io.mockk.impl.annotations.SpyK import io.mockk.junit5.MockKExtension import io.mockk.verify -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertEquals - +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -60,7 +59,7 @@ internal class CardNumberViewModelTest { @SpyK var spyPaymentStateManager: PaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) private var style: CardNumberComponentStyle = CardNumberComponentStyle() @@ -79,7 +78,7 @@ internal class CardNumberViewModelTest { spyInputComponentStyleMapper, spyInputComponentStateMapper, spyDynamicImageMapper, - style + style, ) every { mockCardValidator.validateCardNumber(any()) } returns ValidationResult.Success(CardScheme.UNKNOWN) @@ -423,12 +422,12 @@ internal class CardNumberViewModelTest { } @ParameterizedTest( - name = "When on card number change invoked with {0} then {1} set to text field state" + name = "When on card number change invoked with {0} then {1} set to text field state", ) @MethodSource("onTextChangedArguments") fun `When on card number change invoked with a string then cleaned string should be set to a text field state`( enteredText: String, - cleanedText: String + cleanedText: String, ) { // When viewModel.onCardNumberChange(enteredText) @@ -446,11 +445,11 @@ internal class CardNumberViewModelTest { spyInputComponentStyleMapper = InputComponentStyleToViewStyleMapper( textLabelStyleMapper, InputFieldStyleToViewStyleMapper(textLabelStyleMapper), - containerMapper + containerMapper, ) spyInputComponentStateMapper = InputComponentStyleToStateMapper( TextLabelStyleToStateMapper(imageMapper), - InputFieldStyleToInputFieldStateMapper(imageMapper) + InputFieldStyleToInputFieldStateMapper(imageMapper), ) } @@ -462,7 +461,7 @@ internal class CardNumberViewModelTest { Arguments.of(" 123", "123"), Arguments.of("12 3", "123"), Arguments.of("123234werw", "123234"), - Arguments.of("42424.2424242_111,11", "42424242424211111") + Arguments.of("42424.2424242_111,11", "42424242424211111"), ) } } diff --git a/frames/src/test/java/com/checkout/frames/component/cardscheme/CardSchemeViewModelTest.kt b/frames/src/test/java/com/checkout/frames/component/cardscheme/CardSchemeViewModelTest.kt index 8455c5a18..1985b0170 100644 --- a/frames/src/test/java/com/checkout/frames/component/cardscheme/CardSchemeViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/cardscheme/CardSchemeViewModelTest.kt @@ -3,12 +3,12 @@ package com.checkout.frames.component.cardscheme import android.annotation.SuppressLint import com.checkout.base.mapper.Mapper import com.checkout.frames.mapper.BillingFormAddressToBillingAddressMapper -import com.checkout.frames.mapper.ImageStyleToComposableImageMapper +import com.checkout.frames.mapper.CardSchemeComponentStyleToStateMapper +import com.checkout.frames.mapper.CardSchemeComponentStyleToViewStyleMapper import com.checkout.frames.mapper.ContainerStyleToModifierMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper +import com.checkout.frames.mapper.ImageStyleToComposableImageMapper import com.checkout.frames.mapper.TextLabelStyleToStateMapper -import com.checkout.frames.mapper.CardSchemeComponentStyleToViewStyleMapper -import com.checkout.frames.mapper.CardSchemeComponentStyleToStateMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.screen.manager.PaymentFormStateManager import com.checkout.frames.screen.manager.PaymentStateManager import com.checkout.frames.style.component.CardSchemeComponentStyle @@ -39,7 +39,7 @@ internal class CardSchemeViewModelTest { @SpyK var spyPaymentStateManager: PaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) private var style: CardSchemeComponentStyle = CardSchemeComponentStyle() @@ -57,7 +57,7 @@ internal class CardSchemeViewModelTest { spyCardSchemeComponentStyleMapper, spyCardSchemeComponentStateMapper, spyImageStyleToComposableImageMapper, - style + style, ) } @@ -101,7 +101,7 @@ internal class CardSchemeViewModelTest { spyImageStyleToComposableImageMapper = ImageStyleToComposableImageMapper() spyCardSchemeComponentStyleMapper = CardSchemeComponentStyleToViewStyleMapper( textLabelStyleMapper, - containerMapper + containerMapper, ) spyCardSchemeComponentStateMapper = CardSchemeComponentStyleToStateMapper(textLabelStateMapper) } diff --git a/frames/src/test/java/com/checkout/frames/component/country/CountryViewModelTest.kt b/frames/src/test/java/com/checkout/frames/component/country/CountryViewModelTest.kt index 6dd205669..ba3c5df7c 100644 --- a/frames/src/test/java/com/checkout/frames/component/country/CountryViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/country/CountryViewModelTest.kt @@ -49,7 +49,7 @@ internal class CountryViewModelTest { @SpyK var spyPaymentStateManager: PaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) private lateinit var viewModel: CountryViewModel @@ -68,7 +68,7 @@ internal class CountryViewModelTest { spyPaymentStateManager, spyInputComponentStyleMapper, spyInputComponentStateMapper, - style + style, ) } @@ -140,11 +140,11 @@ internal class CountryViewModelTest { spyInputComponentStyleMapper = InputComponentStyleToViewStyleMapper( textLabelStyleMapper, InputFieldStyleToViewStyleMapper(textLabelStyleMapper), - containerMapper + containerMapper, ) spyInputComponentStateMapper = InputComponentStyleToStateMapper( TextLabelStyleToStateMapper(imageMapper), - InputFieldStyleToInputFieldStateMapper(imageMapper) + InputFieldStyleToInputFieldStateMapper(imageMapper), ) } } diff --git a/frames/src/test/java/com/checkout/frames/component/cvv/CvvViewModelTest.kt b/frames/src/test/java/com/checkout/frames/component/cvv/CvvViewModelTest.kt index 4f1012d04..06745cc19 100644 --- a/frames/src/test/java/com/checkout/frames/component/cvv/CvvViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/cvv/CvvViewModelTest.kt @@ -9,13 +9,13 @@ import com.checkout.frames.R import com.checkout.frames.component.base.InputComponentState import com.checkout.frames.mapper.BillingFormAddressToBillingAddressMapper import com.checkout.frames.mapper.ContainerStyleToModifierMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mapper.ImageStyleToComposableImageMapper +import com.checkout.frames.mapper.InputComponentStyleToStateMapper import com.checkout.frames.mapper.InputComponentStyleToViewStyleMapper -import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper -import com.checkout.frames.mapper.InputComponentStyleToStateMapper +import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper import com.checkout.frames.mapper.TextLabelStyleToStateMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.screen.manager.PaymentFormStateManager import com.checkout.frames.screen.manager.PaymentStateManager import com.checkout.frames.style.component.CvvComponentStyle @@ -39,7 +39,6 @@ import org.amshove.kluent.internal.assertEquals import org.amshove.kluent.internal.assertFalse import org.junit.After import org.junit.jupiter.api.Assertions.assertTrue - import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -65,7 +64,7 @@ internal class CvvViewModelTest { @SpyK var spyPaymentStateManager: PaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) private var style: CvvComponentStyle = CvvComponentStyle() @@ -87,7 +86,7 @@ internal class CvvViewModelTest { mockCardValidator, spyInputComponentStyleMapper, spyInputComponentStateMapper, - style + style, ) } @@ -129,7 +128,7 @@ internal class CvvViewModelTest { // Then assertEquals( viewModel.componentStyle.inputFieldStyle.keyboardOptions.keyboardType, - KeyboardType.Number + KeyboardType.Number, ) } @@ -341,12 +340,12 @@ internal class CvvViewModelTest { } @ParameterizedTest( - name = "When card scheme is updated to {0} then {1} max length is set for cvv and validation invoked" + name = "When card scheme is updated to {0} then {1} max length is set for cvv and validation invoked", ) @MethodSource("onCardSchemeChangedArguments") fun `when card scheme state in payment state manager is changed then cvv validation is not invoked`( cardScheme: CardScheme, - maxCvvLength: Int + maxCvvLength: Int, ) = runTest { // Given val testCvv = "123" @@ -378,11 +377,11 @@ internal class CvvViewModelTest { spyInputComponentStyleMapper = InputComponentStyleToViewStyleMapper( textLabelStyleMapper, InputFieldStyleToViewStyleMapper(textLabelStyleMapper), - containerMapper + containerMapper, ) spyInputComponentStateMapper = InputComponentStyleToStateMapper( TextLabelStyleToStateMapper(imageMapper), - InputFieldStyleToInputFieldStateMapper(imageMapper) + InputFieldStyleToInputFieldStateMapper(imageMapper), ) } @@ -396,7 +395,7 @@ internal class CvvViewModelTest { Arguments.of(CardScheme.MADA, CardScheme.MADA.cvvLength.max()), Arguments.of(CardScheme.MAESTRO, CardScheme.MAESTRO.cvvLength.max()), Arguments.of(CardScheme.MASTERCARD, CardScheme.MASTERCARD.cvvLength.max()), - Arguments.of(CardScheme.VISA, CardScheme.VISA.cvvLength.max()) + Arguments.of(CardScheme.VISA, CardScheme.VISA.cvvLength.max()), ) } } diff --git a/frames/src/test/java/com/checkout/frames/component/expirydate/ExpiryDateViewModelTest.kt b/frames/src/test/java/com/checkout/frames/component/expirydate/ExpiryDateViewModelTest.kt index bee2efaf6..d75f566c8 100644 --- a/frames/src/test/java/com/checkout/frames/component/expirydate/ExpiryDateViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/expirydate/ExpiryDateViewModelTest.kt @@ -10,13 +10,13 @@ import com.checkout.frames.component.expirydate.model.SmartExpiryDateValidationR import com.checkout.frames.component.expirydate.usecase.SmartExpiryDateValidationUseCase import com.checkout.frames.mapper.BillingFormAddressToBillingAddressMapper import com.checkout.frames.mapper.ContainerStyleToModifierMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mapper.ImageStyleToComposableImageMapper -import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper +import com.checkout.frames.mapper.InputComponentStyleToStateMapper import com.checkout.frames.mapper.InputComponentStyleToViewStyleMapper +import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper -import com.checkout.frames.mapper.InputComponentStyleToStateMapper import com.checkout.frames.mapper.TextLabelStyleToStateMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.screen.manager.PaymentFormStateManager import com.checkout.frames.screen.manager.PaymentStateManager import com.checkout.frames.style.component.ExpiryDateComponentStyle @@ -56,7 +56,7 @@ internal class ExpiryDateViewModelTest { @SpyK var spyPaymentStateManager: PaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) private var style: ExpiryDateComponentStyle = ExpiryDateComponentStyle(InputComponentStyle()) @@ -74,7 +74,7 @@ internal class ExpiryDateViewModelTest { mockSmartExpiryDateValidationUseCase, spyInputComponentStyleMapper, spyInputComponentStateMapper, - style + style, ) } @@ -111,7 +111,7 @@ internal class ExpiryDateViewModelTest { // Then Assertions.assertEquals( viewModel.componentStyle.inputFieldStyle.keyboardOptions.keyboardType, - KeyboardType.Number + KeyboardType.Number, ) } @@ -324,13 +324,13 @@ internal class ExpiryDateViewModelTest { } @ParameterizedTest( - name = "When on expiry date change invoked with {0} then {1} validation (maxLength = {2}) set to field state" + name = "When on expiry date change invoked with {0} then {1} validation (maxLength = {2}) set to field state", ) @MethodSource("onTextChangedArguments") fun `When expiryDate change called with valid input then expected text & maxLength should be set to componentState`( enteredText: String, expectedText: String, - expectedMaxLength: Int + expectedMaxLength: Int, ) { // Given val expectedExpiryDateValidationRequest = SmartExpiryDateValidationRequest(true, expectedText) @@ -367,11 +367,11 @@ internal class ExpiryDateViewModelTest { spyInputComponentStyleMapper = InputComponentStyleToViewStyleMapper( textLabelStyleMapper, InputFieldStyleToViewStyleMapper(textLabelStyleMapper), - containerMapper + containerMapper, ) spyInputComponentStateMapper = InputComponentStyleToStateMapper( TextLabelStyleToStateMapper(imageMapper), - InputFieldStyleToInputFieldStateMapper(imageMapper) + InputFieldStyleToInputFieldStateMapper(imageMapper), ) } } diff --git a/frames/src/test/java/com/checkout/frames/component/expirydate/ExpiryDateVisualTransformationTest.kt b/frames/src/test/java/com/checkout/frames/component/expirydate/ExpiryDateVisualTransformationTest.kt index f5484637f..ca0750376 100644 --- a/frames/src/test/java/com/checkout/frames/component/expirydate/ExpiryDateVisualTransformationTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/expirydate/ExpiryDateVisualTransformationTest.kt @@ -4,16 +4,16 @@ import android.annotation.SuppressLint import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.input.TransformedText import androidx.compose.ui.text.input.VisualTransformation +import com.google.common.truth.Truth.assertThat import io.mockk.junit5.MockKExtension import org.amshove.kluent.internal.assertEquals import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource import java.util.stream.Stream -import com.google.common.truth.Truth.assertThat -import org.junit.jupiter.api.Test @SuppressLint("NewApi") @ExtendWith(MockKExtension::class) @@ -31,7 +31,7 @@ internal class ExpiryDateVisualTransformationTest { } @ParameterizedTest( - name = "When visual transformation receives for expiry date {0} then {1} is received" + name = "When visual transformation receives for expiry date {0} then {1} is received", ) @MethodSource("expiryDateVisualTransformationArguments") fun `when visual transformation receives a string then correctly formatted string is provided`( @@ -44,21 +44,25 @@ internal class ExpiryDateVisualTransformationTest { // Then assertEquals(transformedExpiryDate, result) } + @Test fun `verify offsetMapping for 123`() { val result = expiryDateVisualTransformation.filter(AnnotatedString("123")) assertCorrectMapping(original = "123", result) } + @Test fun `verify offsetMapping for 143`() { val result = expiryDateVisualTransformation.filter(AnnotatedString("143")) assertCorrectMapping(original = "143", result) } + @Test fun `verify offsetMapping for 093`() { val result = expiryDateVisualTransformation.filter(AnnotatedString("093")) assertCorrectMapping(original = "093", result) } + @Test fun `verify offsetMapping for 53`() { val result = expiryDateVisualTransformation.filter(AnnotatedString("53")) diff --git a/frames/src/test/java/com/checkout/frames/component/expirydate/SmartExpiryDateValidationUseCaseTest.kt b/frames/src/test/java/com/checkout/frames/component/expirydate/SmartExpiryDateValidationUseCaseTest.kt index 57bea441c..7ce174795 100644 --- a/frames/src/test/java/com/checkout/frames/component/expirydate/SmartExpiryDateValidationUseCaseTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/expirydate/SmartExpiryDateValidationUseCaseTest.kt @@ -27,7 +27,7 @@ internal class SmartExpiryDateValidationUseCaseTest { lateinit var mockCardValidator: CardValidator private lateinit var expiryDateValidationUseCase: - UseCase> + UseCase> private lateinit var fakeExpiryDate: ExpiryDate @@ -38,7 +38,7 @@ internal class SmartExpiryDateValidationUseCaseTest { } @ParameterizedTest( - name = "Expected success validation result {0} received for OnFocus when valid {1} expiry date requested" + name = "Expected success validation result {0} received for OnFocus when valid {1} expiry date requested", ) @MethodSource("validateSuccessExpiryDateOnFocusBehaviourArguments") fun `when valid expiry date is requested then return success result for On Focus behaviour`( @@ -49,7 +49,8 @@ internal class SmartExpiryDateValidationUseCaseTest { } @ParameterizedTest( - name = "Expected failed validation result {0} received for OnFocus\" + \"when invalid {1} expiry date requested" + name = "Expected failed validation result {0} received for OnFocus\" + \"when invalid {1} expiry date " + + "requested", ) @MethodSource("validateInvalidExpiryDateForOnFocusBehaviourArguments") fun `when invalid expiry date is requested then return failure result for On Focus behaviour`( @@ -60,7 +61,8 @@ internal class SmartExpiryDateValidationUseCaseTest { } @ParameterizedTest( - name = "Expected success validation result {0} received for OnFocusChanged when valid {1} expiry date requested" + name = "Expected success validation result {0} received for OnFocusChanged when valid {1} expiry date " + + "requested", ) @MethodSource("validateSuccessExpiryDateOnFocusChangedBehaviourArguments") fun `when valid expiry date is requested then return success result for On Focus Changed behaviour`( @@ -72,7 +74,7 @@ internal class SmartExpiryDateValidationUseCaseTest { @ParameterizedTest( name = "Expected failed validation result {0} received" + - " for OnFocusChanged when invalid {1} expiry date requested" + " for OnFocusChanged when invalid {1} expiry date requested", ) @MethodSource("validateInvalidExpiryDateOnFocusChangedBehaviourArguments") fun `when invalid expiry date is requested then return failure result for On Focus Changed behaviour`( @@ -91,10 +93,11 @@ internal class SmartExpiryDateValidationUseCaseTest { every { mockCardValidator.validateExpiryDate(any() as String, any() as String) } returns - if (isVerifyingSuccessResult) - ValidationResult.Success(fakeExpiryDate) - else - ValidationResult.Failure(CheckoutError("errorCode")) + if (isVerifyingSuccessResult) { + ValidationResult.Success(fakeExpiryDate) + } else { + ValidationResult.Failure(CheckoutError("errorCode")) + } // When val result = expiryDateValidationUseCase.execute(inputRequest) @@ -106,7 +109,7 @@ internal class SmartExpiryDateValidationUseCaseTest { } is ValidationResult.Failure -> Assertions.assertEquals( expectedExpiryDate.error.message, - (result as? ValidationResult.Failure)?.error?.message + (result as? ValidationResult.Failure)?.error?.message, ) } } @@ -124,10 +127,11 @@ internal class SmartExpiryDateValidationUseCaseTest { every { mockCardValidator.validateExpiryDate(any() as String, any() as String) } returns - if (isVerifyingSuccessResult) - ValidationResult.Success(fakeExpiryDate) - else - ValidationResult.Failure(CheckoutError("errorCode")) + if (isVerifyingSuccessResult) { + ValidationResult.Success(fakeExpiryDate) + } else { + ValidationResult.Failure(CheckoutError("errorCode")) + } // When val result = expiryDateValidationUseCase.execute(inputRequest) @@ -139,7 +143,7 @@ internal class SmartExpiryDateValidationUseCaseTest { } is ValidationResult.Failure -> Assertions.assertEquals( expectedExpiryDate.error.message, - (result as? ValidationResult.Failure)?.error?.message + (result as? ValidationResult.Failure)?.error?.message, ) } } @@ -276,7 +280,7 @@ internal class SmartExpiryDateValidationUseCaseTest { Arguments.of(SmartExpiryDateValidationRequest(false, "78"), provideFailure()), Arguments.of(SmartExpiryDateValidationRequest(false, "89"), provideFailure()), Arguments.of(SmartExpiryDateValidationRequest(false, "91"), provideFailure()), - Arguments.of(SmartExpiryDateValidationRequest(false, "95"), provideFailure()) + Arguments.of(SmartExpiryDateValidationRequest(false, "95"), provideFailure()), ) private fun provideSuccess(inputExpiryDate: String) = ValidationResult.Success(inputExpiryDate) diff --git a/frames/src/test/java/com/checkout/frames/component/paybutton/PayButtonViewModelTest.kt b/frames/src/test/java/com/checkout/frames/component/paybutton/PayButtonViewModelTest.kt index 16b8a7f73..5e6c5f457 100644 --- a/frames/src/test/java/com/checkout/frames/component/paybutton/PayButtonViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/component/paybutton/PayButtonViewModelTest.kt @@ -65,7 +65,7 @@ internal class PayButtonViewModelTest { @SpyK var spyPaymentStateManager: PaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) private val dispatcher = StandardTestDispatcher() @@ -88,7 +88,7 @@ internal class PayButtonViewModelTest { viewModel = PayButtonViewModel( style, spyPaymentStateManager, mockCardTokenizationUseCase, - spyButtonStyleMapper, spyButtonStateMapper, mockLogger + spyButtonStyleMapper, spyButtonStateMapper, mockLogger, ) } @@ -271,11 +271,11 @@ internal class PayButtonViewModelTest { spyButtonStyleMapper = ButtonStyleToInternalViewStyleMapper( containerMapper, - TextLabelStyleToViewStyleMapper(containerMapper) + TextLabelStyleToViewStyleMapper(containerMapper), ) spyButtonStateMapper = ButtonStyleToInternalStateMapper( - TextLabelStyleToStateMapper(ImageStyleToComposableImageMapper()) + TextLabelStyleToStateMapper(ImageStyleToComposableImageMapper()), ) } @@ -283,7 +283,7 @@ internal class PayButtonViewModelTest { private val EDITED_BILLING_ADDRESS = BillingAddress( name = "NAME", address = Address("ADDRESS_LINE_1", "ADDRESS_LINE_2", "", "", "", Country.UNITED_KINGDOM), - phone = Phone("1234", Country.AFGHANISTAN) + phone = Phone("1234", Country.AFGHANISTAN), ) } } diff --git a/frames/src/test/java/com/checkout/frames/countrypicker/CountryPickerViewModelTest.kt b/frames/src/test/java/com/checkout/frames/countrypicker/CountryPickerViewModelTest.kt index a8d903320..a7a6bb218 100644 --- a/frames/src/test/java/com/checkout/frames/countrypicker/CountryPickerViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/countrypicker/CountryPickerViewModelTest.kt @@ -5,13 +5,13 @@ import androidx.compose.ui.Modifier import com.checkout.base.mapper.Mapper import com.checkout.base.model.Country import com.checkout.frames.mapper.BillingFormAddressToBillingAddressMapper -import com.checkout.frames.mapper.ImageStyleToComposableImageMapper import com.checkout.frames.mapper.ContainerStyleToModifierMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper -import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper +import com.checkout.frames.mapper.ImageStyleToComposableImageMapper +import com.checkout.frames.mapper.ImageStyleToDynamicComposableImageMapper import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper +import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper import com.checkout.frames.mapper.TextLabelStyleToStateMapper -import com.checkout.frames.mapper.ImageStyleToDynamicComposableImageMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.screen.countrypicker.CountryPickerViewModel import com.checkout.frames.screen.manager.PaymentFormStateManager import com.checkout.frames.screen.manager.PaymentStateManager @@ -28,8 +28,8 @@ import io.mockk.junit5.MockKExtension import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -60,7 +60,7 @@ internal class CountryPickerViewModelTest { @SpyK var paymentStateManager: PaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) private val style: CountryPickerStyle = CountryPickerStyle() @@ -80,7 +80,7 @@ internal class CountryPickerViewModelTest { spyTextLabelStateMapper, spyContainerMapper, spyDynamicImageMapper, - style + style, ) } @@ -131,7 +131,7 @@ internal class CountryPickerViewModelTest { // Then assertEquals( Country.values().size, - viewModel.searchCountries.value.size + viewModel.searchCountries.value.size, ) } diff --git a/frames/src/test/java/com/checkout/frames/cvvinputfield/InternalCVVComponentApiTest.kt b/frames/src/test/java/com/checkout/frames/cvvinputfield/InternalCVVComponentApiTest.kt index c3800bbf0..d36940548 100644 --- a/frames/src/test/java/com/checkout/frames/cvvinputfield/InternalCVVComponentApiTest.kt +++ b/frames/src/test/java/com/checkout/frames/cvvinputfield/InternalCVVComponentApiTest.kt @@ -35,8 +35,10 @@ internal class InternalCVVComponentApiTest { // Given val internalCVVComponentApi = spyk( InternalCVVComponentApi( - publicKey = "your_public_key", environment = Environment.SANDBOX, context = mockContext - ) + publicKey = "your_public_key", + environment = Environment.SANDBOX, + context = mockContext, + ), ) // When diff --git a/frames/src/test/java/com/checkout/frames/cvvinputfield/usecase/CVVTokenizationUseCaseTest.kt b/frames/src/test/java/com/checkout/frames/cvvinputfield/usecase/CVVTokenizationUseCaseTest.kt index b1760139c..8970bf37d 100644 --- a/frames/src/test/java/com/checkout/frames/cvvinputfield/usecase/CVVTokenizationUseCaseTest.kt +++ b/frames/src/test/java/com/checkout/frames/cvvinputfield/usecase/CVVTokenizationUseCaseTest.kt @@ -11,10 +11,10 @@ import io.mockk.junit5.MockKExtension import io.mockk.just import io.mockk.mockk import io.mockk.runs +import io.mockk.verify import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith -import io.mockk.verify @ExtendWith(MockKExtension::class) internal class CVVTokenizationUseCaseTest { diff --git a/frames/src/test/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModelFactoryTest.kt b/frames/src/test/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModelFactoryTest.kt index cfbaa2aa2..850a313ef 100644 --- a/frames/src/test/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModelFactoryTest.kt +++ b/frames/src/test/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModelFactoryTest.kt @@ -34,8 +34,8 @@ internal class CVVInputFieldViewModelFactoryTest { cvvComponentValidator = CVVComponentValidatorFactory.create() inputFieldStyleMapper = InputFieldStyleToViewStyleMapper( TextLabelStyleToViewStyleMapper( - ContainerStyleToModifierMapper() - ) + ContainerStyleToModifierMapper(), + ), ) inputFieldStateMapper = InputFieldStyleToInputFieldStateMapper(ImageStyleToComposableImageMapper()) } @@ -44,7 +44,7 @@ internal class CVVInputFieldViewModelFactoryTest { fun testCreateCVVInputFieldViewModel() { // Given factory = CVVInputFieldViewModelFactory( - config, cvvComponentValidator, inputFieldStateMapper, inputFieldStyleMapper + config, cvvComponentValidator, inputFieldStateMapper, inputFieldStyleMapper, ) // When diff --git a/frames/src/test/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModelTest.kt b/frames/src/test/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModelTest.kt index c398a0a16..f9190420f 100644 --- a/frames/src/test/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/cvvinputfield/viewmodel/CVVInputFieldViewModelTest.kt @@ -7,10 +7,10 @@ import com.checkout.base.mapper.Mapper import com.checkout.base.model.CardScheme import com.checkout.frames.cvvinputfield.models.CVVComponentConfig import com.checkout.frames.mapper.ContainerStyleToModifierMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mapper.ImageStyleToComposableImageMapper -import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper +import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.style.component.base.InputFieldStyle import com.checkout.frames.style.view.InputFieldViewStyle import com.checkout.frames.view.InputFieldState @@ -69,7 +69,7 @@ internal class CVVInputFieldViewModelTest { every { cvvComponentConfig.cvvInputFieldStyle } returns InputFieldStyle() viewModel = CVVInputFieldViewModel( - spyInputFieldStateMapper, spyInputFieldStyleMapper, cvvComponentConfig, mockCVVComponentValidator + spyInputFieldStateMapper, spyInputFieldStyleMapper, cvvComponentConfig, mockCVVComponentValidator, ) } @@ -116,7 +116,8 @@ internal class CVVInputFieldViewModelTest { fun `when view model is initialised then initial style has correct keyboard type`() { // Then assertEquals( - viewModel.cvvInputFieldStyle.keyboardOptions.keyboardType, KeyboardType.Number + viewModel.cvvInputFieldStyle.keyboardOptions.keyboardType, + KeyboardType.Number, ) } @@ -236,8 +237,8 @@ internal class CVVInputFieldViewModelTest { val containerMapper = ContainerStyleToModifierMapper() spyInputFieldStyleMapper = InputFieldStyleToViewStyleMapper( TextLabelStyleToViewStyleMapper( - containerMapper - ) + containerMapper, + ), ) spyInputFieldStateMapper = InputFieldStyleToInputFieldStateMapper(ImageStyleToComposableImageMapper()) } diff --git a/frames/src/test/java/com/checkout/frames/manager/PaymentFormStateManagerTest.kt b/frames/src/test/java/com/checkout/frames/manager/PaymentFormStateManagerTest.kt index f8ae941de..0c78a01c6 100644 --- a/frames/src/test/java/com/checkout/frames/manager/PaymentFormStateManagerTest.kt +++ b/frames/src/test/java/com/checkout/frames/manager/PaymentFormStateManagerTest.kt @@ -40,7 +40,7 @@ internal class PaymentFormStateManagerTest { // Given paymentFormStateManager = PaymentFormStateManager( supportedCardSchemes = listOf(CardScheme.AMERICAN_EXPRESS, CardScheme.MADA), - billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper + billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper, ) val expectedSupportedSchemes = listOf(CardScheme.AMERICAN_EXPRESS, CardScheme.MADA) @@ -52,7 +52,7 @@ internal class PaymentFormStateManagerTest { fun `when payment form cardHolderName is provided then cardHolderName should updated correctly`() { // Given paymentFormStateManager = PaymentFormStateManager( - emptyList(), paymentFormPrefillData = PrefillData("Test Name"), spyBillingFormAddressToBillingAddressMapper + emptyList(), paymentFormPrefillData = PrefillData("Test Name"), spyBillingFormAddressToBillingAddressMapper, ) val expectedTestName = "Test Name" @@ -67,7 +67,7 @@ internal class PaymentFormStateManagerTest { paymentFormStateManager = PaymentFormStateManager( emptyList(), paymentFormPrefillData = PrefillData(billingFormAddress = givenPrefilledBillingFormAddress), - spyBillingFormAddressToBillingAddressMapper + spyBillingFormAddressToBillingAddressMapper, ) val expectedCountry = Country.UNITED_KINGDOM @@ -80,7 +80,7 @@ internal class PaymentFormStateManagerTest { // Given paymentFormStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper + billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper, ) val expectedSupportedSchemes = CardScheme.fetchAllSupportedCardSchemes() // Then @@ -91,10 +91,10 @@ internal class PaymentFormStateManagerTest { fun `when BillingFormAddress is requested in PrefillData then billingAddress in payment state manager is updated correctly`() { // Given val expectedBillingFormAddress = BillingFormAddress( - address = PaymentFormConfigTestData.address + address = PaymentFormConfigTestData.address, ) val expectedBillingAddress = BillingAddress( - address = PaymentFormConfigTestData.address + address = PaymentFormConfigTestData.address, ) // When @@ -103,9 +103,9 @@ internal class PaymentFormStateManagerTest { billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper, paymentFormPrefillData = PrefillData( billingFormAddress = BillingFormAddress( - address = PaymentFormConfigTestData.address - ) - ) + address = PaymentFormConfigTestData.address, + ), + ), ) // Then @@ -117,7 +117,7 @@ internal class PaymentFormStateManagerTest { fun `when BillingFormAddress is not requested in PrefillData then default billingAddress in payment state manager is updated correctly`() { // Given val expectedBillingFormAddress = BillingFormAddress( - address = PaymentFormConfigTestData.address + address = PaymentFormConfigTestData.address, ) val expectedBillingAddress = BillingAddress() @@ -126,8 +126,8 @@ internal class PaymentFormStateManagerTest { supportedCardSchemes = emptyList(), billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper, paymentFormPrefillData = PrefillData( - cardHolderName = "Test Name" - ) + cardHolderName = "Test Name", + ), ) // Then @@ -137,8 +137,8 @@ internal class PaymentFormStateManagerTest { @ParameterizedTest( name = "When reset of payment state is requested with: " + "isCvvValid = {0} and isBillingAddressValid = {1};" + - " " + "Then default cvv isValid state = {0}, cardholderName isValid state = {1}" + - " " + "address isValid state = {2} and address isEnabled state = {3}" + " " + "Then default cvv isValid state = {0}, cardholderName isValid state = {1}" + + " " + "address isValid state = {2} and address isEnabled state = {3}", ) @MethodSource("resetArguments") fun `when reset of payment state is requested then payment state is returned to a default state`( @@ -152,7 +152,7 @@ internal class PaymentFormStateManagerTest { val cardHolderName = "" paymentFormStateManager = PaymentFormStateManager( supportedCardSchemes = supportedSchemes, - billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper + billingFormAddressToBillingAddressMapper = spyBillingFormAddressToBillingAddressMapper, ) paymentFormStateManager.cvv.value = "123" paymentFormStateManager.isCvvValid.value = !isCvvValid @@ -162,7 +162,7 @@ internal class PaymentFormStateManagerTest { paymentFormStateManager.isExpiryDateValid.value = true paymentFormStateManager.billingAddress.value = BillingAddress( name = "name", - phone = Phone("+4332452452345234", Country.UNITED_KINGDOM) + phone = Phone("+4332452452345234", Country.UNITED_KINGDOM), ) paymentFormStateManager.isBillingAddressValid.value = !isBillingAddressValid paymentFormStateManager.isBillingAddressEnabled.value = !isBillingAddressEnabled @@ -173,7 +173,7 @@ internal class PaymentFormStateManagerTest { isCvvValid, isCardHolderNameValid, isBillingAddressValid, - isBillingAddressEnabled + isBillingAddressEnabled, ) // Then diff --git a/frames/src/test/java/com/checkout/frames/mapper/BillingFormAddressToBillingAddressMapperTest.kt b/frames/src/test/java/com/checkout/frames/mapper/BillingFormAddressToBillingAddressMapperTest.kt index a5e483bbf..c03155697 100644 --- a/frames/src/test/java/com/checkout/frames/mapper/BillingFormAddressToBillingAddressMapperTest.kt +++ b/frames/src/test/java/com/checkout/frames/mapper/BillingFormAddressToBillingAddressMapperTest.kt @@ -29,7 +29,7 @@ internal class BillingFormAddressToBillingAddressMapperTest { } @ParameterizedTest( - name = "When summary of billing address {0} is requested then addressPreview {1} is provided" + name = "When summary of billing address {0} is requested then addressPreview {1} is provided", ) @MethodSource("testBillingAddressSummaryArguments") fun `mapping of BillingFormAddress to BillingAddress data should return correct data`( @@ -63,9 +63,9 @@ internal class BillingFormAddressToBillingAddressMapperTest { city = "city", state = "state", zip = "zipcode", - country = Country.UNITED_KINGDOM + country = Country.UNITED_KINGDOM, ), - phone = Phone("123", Country.UNITED_KINGDOM) + phone = Phone("123", Country.UNITED_KINGDOM), ), BillingAddress( address = Address( @@ -74,15 +74,17 @@ internal class BillingFormAddressToBillingAddressMapperTest { city = "city", state = "state", zip = "zipcode", - country = Country.UNITED_KINGDOM + country = Country.UNITED_KINGDOM, ), - phone = Phone("123", Country.UNITED_KINGDOM) + phone = Phone("123", Country.UNITED_KINGDOM), ), BillingFormAddress( - name = "Test name", phone = Phone("123", Country.UNITED_KINGDOM) + name = "Test name", + phone = Phone("123", Country.UNITED_KINGDOM), ), BillingAddress( - name = "Test name", phone = Phone("123", Country.UNITED_KINGDOM) + name = "Test name", + phone = Phone("123", Country.UNITED_KINGDOM), ), BillingFormAddress(name = "Test name"), BillingAddress(name = "Test name"), BillingFormAddress( @@ -93,8 +95,8 @@ internal class BillingFormAddressToBillingAddressMapperTest { city = "", state = "state", zip = "zipcode", - country = Country.UNITED_KINGDOM - ) + country = Country.UNITED_KINGDOM, + ), ), BillingAddress( name = "Test name", @@ -104,13 +106,13 @@ internal class BillingFormAddressToBillingAddressMapperTest { city = "", state = "state", zip = "zipcode", - country = Country.UNITED_KINGDOM - ) + country = Country.UNITED_KINGDOM, + ), ), BillingFormAddress(), BillingAddress(), BillingFormAddress(name = "Test name", address = null), - BillingAddress(name = "Test name", address = BillingAddress().address) - ) + BillingAddress(name = "Test name", address = BillingAddress().address), + ), ) } } diff --git a/frames/src/test/java/com/checkout/frames/mock/BillingAddressDetailsTestData.kt b/frames/src/test/java/com/checkout/frames/mock/BillingAddressDetailsTestData.kt index 137c6a90e..e5147c719 100644 --- a/frames/src/test/java/com/checkout/frames/mock/BillingAddressDetailsTestData.kt +++ b/frames/src/test/java/com/checkout/frames/mock/BillingAddressDetailsTestData.kt @@ -18,49 +18,49 @@ internal object BillingAddressDetailsTestData { val cardHolderNameState = BillingAddressInputComponentState( addressFieldName = BillingFormFields.CardHolderName.name, isAddressFieldValid = MutableStateFlow(false), - inputComponentState = InputComponentState() + inputComponentState = InputComponentState(), ) val addressLineOneState = BillingAddressInputComponentState( addressFieldName = BillingFormFields.AddressLineOne.name, isAddressFieldValid = MutableStateFlow(false), - inputComponentState = InputComponentState() + inputComponentState = InputComponentState(), ) val addressLineTwoState = BillingAddressInputComponentState( addressFieldName = BillingFormFields.AddressLineTwo.name, isAddressFieldValid = MutableStateFlow(false), - inputComponentState = InputComponentState() + inputComponentState = InputComponentState(), ) val cityState = BillingAddressInputComponentState( addressFieldName = BillingFormFields.City.name, isAddressFieldValid = MutableStateFlow(false), - inputComponentState = InputComponentState() + inputComponentState = InputComponentState(), ) val provinceState = BillingAddressInputComponentState( addressFieldName = BillingFormFields.State.name, isAddressFieldValid = MutableStateFlow(false), - inputComponentState = InputComponentState() + inputComponentState = InputComponentState(), ) val postCodeState = BillingAddressInputComponentState( addressFieldName = BillingFormFields.PostCode.name, isAddressFieldValid = MutableStateFlow(false), - inputComponentState = InputComponentState() + inputComponentState = InputComponentState(), ) val phoneState = BillingAddressInputComponentState( addressFieldName = BillingFormFields.Phone.name, isAddressFieldValid = MutableStateFlow(false), - inputComponentState = InputComponentState() + inputComponentState = InputComponentState(), ) val countryState = BillingAddressInputComponentState( addressFieldName = BillingFormFields.Country.name, isAddressFieldValid = MutableStateFlow(false), - inputComponentState = InputComponentState() + inputComponentState = InputComponentState(), ) // update state text @@ -95,8 +95,8 @@ internal object BillingAddressDetailsTestData { infoStyle = TextLabelViewStyle(), inputFieldStyle = InputFieldViewStyle(), subtitleStyle = TextLabelViewStyle(), - titleStyle = TextLabelViewStyle() - ) + titleStyle = TextLabelViewStyle(), + ), ) val addressLineOneViewStyle = BillingAddressInputComponentViewStyle( @@ -107,8 +107,8 @@ internal object BillingAddressDetailsTestData { infoStyle = TextLabelViewStyle(), inputFieldStyle = InputFieldViewStyle(), subtitleStyle = TextLabelViewStyle(), - titleStyle = TextLabelViewStyle() - ) + titleStyle = TextLabelViewStyle(), + ), ) val addressLineTwoViewStyle = BillingAddressInputComponentViewStyle( @@ -119,8 +119,8 @@ internal object BillingAddressDetailsTestData { infoStyle = TextLabelViewStyle(), inputFieldStyle = InputFieldViewStyle(), subtitleStyle = TextLabelViewStyle(), - titleStyle = TextLabelViewStyle() - ) + titleStyle = TextLabelViewStyle(), + ), ) val phoneViewStyle = BillingAddressInputComponentViewStyle( @@ -131,8 +131,8 @@ internal object BillingAddressDetailsTestData { infoStyle = TextLabelViewStyle(), inputFieldStyle = InputFieldViewStyle(), subtitleStyle = TextLabelViewStyle(), - titleStyle = TextLabelViewStyle() - ) + titleStyle = TextLabelViewStyle(), + ), ) inputComponentStyleList.add(cardHolderNameViewStyle) @@ -160,6 +160,6 @@ internal object BillingAddressDetailsTestData { } fun inputComponentsContainerStyle(): InputComponentsContainerStyle = InputComponentsContainerStyle( - fetchInputComponentStyleValues() + fetchInputComponentStyleValues(), ) } diff --git a/frames/src/test/java/com/checkout/frames/mock/PaymentFormConfigTestData.kt b/frames/src/test/java/com/checkout/frames/mock/PaymentFormConfigTestData.kt index 1429ff710..298b1d321 100644 --- a/frames/src/test/java/com/checkout/frames/mock/PaymentFormConfigTestData.kt +++ b/frames/src/test/java/com/checkout/frames/mock/PaymentFormConfigTestData.kt @@ -20,15 +20,18 @@ internal object PaymentFormConfigTestData { city = "London", state = "London", zip = "W1T 4TJ", - country = country + country = country, ) val phone = Phone("4155552671", country) private val billingFormAddress = BillingFormAddress( - name = "Test Billing Address name", address = address, phone = phone + name = "Test Billing Address name", + address = address, + phone = phone, ) val prefillData = PrefillData( - cardHolderName = "Test Name", billingFormAddress = billingFormAddress + cardHolderName = "Test Name", + billingFormAddress = billingFormAddress, ) val style = PaymentFormStyle() val supportedCardSchemes = listOf(CardScheme.VISA, CardScheme.MAESTRO) diff --git a/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/BillingAddressDetailsViewModelTest.kt b/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/BillingAddressDetailsViewModelTest.kt index e7a03854a..27fdb8d48 100644 --- a/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/BillingAddressDetailsViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/BillingAddressDetailsViewModelTest.kt @@ -66,11 +66,11 @@ internal class BillingAddressDetailsViewModelTest { @RelaxedMockK lateinit var mockBillingAddressDetailsComponentStateUseCase: - UseCase + UseCase @RelaxedMockK lateinit var mockBillingAddressDetailsComponentStyleUseCase: - UseCase + UseCase @RelaxedMockK lateinit var mockLogger: Logger @@ -78,7 +78,7 @@ internal class BillingAddressDetailsViewModelTest { @SpyK var spyPaymentStateManager: PaymentStateManager = PaymentFormStateManager( supportedCardSchemes = emptyList(), - billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper() + billingFormAddressToBillingAddressMapper = BillingFormAddressToBillingAddressMapper(), ) @SpyK @@ -101,7 +101,7 @@ internal class BillingAddressDetailsViewModelTest { private val style: BillingAddressDetailsStyle = BillingAddressDetailsStyle( DefaultBillingAddressDetailsStyle.headerComponentStyle(), - DefaultBillingAddressDetailsStyle.inputComponentsContainerStyle(isRequestedCardHolderName = true) + DefaultBillingAddressDetailsStyle.inputComponentsContainerStyle(isRequestedCardHolderName = true), ) private lateinit var viewModel: BillingAddressDetailsViewModel @@ -137,7 +137,7 @@ internal class BillingAddressDetailsViewModelTest { spyButtonStyleMapper, spyButtonStateMapper, mockLogger, - style + style, ) } @@ -152,7 +152,7 @@ internal class BillingAddressDetailsViewModelTest { // Then verify(exactly = 1) { spyButtonStateMapper.map( - style.headerComponentStyle.headerButtonStyle + style.headerComponentStyle.headerButtonStyle, ) } @@ -161,7 +161,7 @@ internal class BillingAddressDetailsViewModelTest { // Then verify(exactly = 1) { spyTextLabelStateMapper.map( - style.headerComponentStyle.headerTitleStyle + style.headerComponentStyle.headerTitleStyle, ) } @@ -171,7 +171,7 @@ internal class BillingAddressDetailsViewModelTest { // Then verify(exactly = 1) { spyButtonStyleMapper.map( - style.headerComponentStyle.headerButtonStyle + style.headerComponentStyle.headerButtonStyle, ) } @@ -180,7 +180,7 @@ internal class BillingAddressDetailsViewModelTest { // Then verify(exactly = 1) { spyTextLabelStyleMapper.map( - style.headerComponentStyle.headerTitleStyle + style.headerComponentStyle.headerTitleStyle, ) } @@ -202,7 +202,7 @@ internal class BillingAddressDetailsViewModelTest { // Then assertEquals( viewModel.screenButtonState.isEnabled.value, - false + false, ) } @@ -256,7 +256,8 @@ internal class BillingAddressDetailsViewModelTest { testScheduler.advanceUntilIdle() assertEquals(spyPaymentStateManager.selectedCountry.value, expectedBillingAddress.address?.country) assertEquals( - spyPaymentStateManager.selectedCountry.value, spyPaymentStateManager.billingAddress.value.address?.country + spyPaymentStateManager.selectedCountry.value, + spyPaymentStateManager.billingAddress.value.address?.country, ) assertEquals(spyPaymentStateManager.billingAddress.value, expectedBillingAddress) } @@ -284,31 +285,31 @@ internal class BillingAddressDetailsViewModelTest { assertEquals(viewModel.screenButtonState.isEnabled.value, true) assertEquals( viewModel.inputComponentsStateList[0].addressFieldText.value, - expectedBillingAddress.name + expectedBillingAddress.name, ) assertEquals( viewModel.inputComponentsStateList[1].addressFieldText.value, - expectedBillingAddress.address?.addressLine1 + expectedBillingAddress.address?.addressLine1, ) assertEquals( viewModel.inputComponentsStateList[2].addressFieldText.value, - expectedBillingAddress.address?.addressLine2 + expectedBillingAddress.address?.addressLine2, ) assertEquals( viewModel.inputComponentsStateList[3].addressFieldText.value, - expectedBillingAddress.address?.city + expectedBillingAddress.address?.city, ) assertEquals( viewModel.inputComponentsStateList[4].addressFieldText.value, - expectedBillingAddress.address?.state + expectedBillingAddress.address?.state, ) assertEquals( viewModel.inputComponentsStateList[5].addressFieldText.value, - expectedBillingAddress.address?.zip + expectedBillingAddress.address?.zip, ) assertEquals( viewModel.inputComponentsStateList[6].addressFieldText.value, - expectedBillingAddress.phone?.number + expectedBillingAddress.phone?.number, ) } @@ -346,7 +347,7 @@ internal class BillingAddressDetailsViewModelTest { assertEquals(viewModel.inputComponentsStateList[givenPosition].addressFieldText.value, expectedText) assertEquals( viewModel.inputComponentsStateList[givenPosition].isAddressFieldValid.value, - expectedIsAddressFieldValid + expectedIsAddressFieldValid, ) } @@ -365,7 +366,7 @@ internal class BillingAddressDetailsViewModelTest { assertEquals(viewModel.inputComponentsStateList[givenPosition].addressFieldText.value, cleanedText) assertEquals( viewModel.inputComponentsStateList[givenPosition].isAddressFieldValid.value, - expectedIsAddressFieldValid + expectedIsAddressFieldValid, ) } @@ -398,7 +399,7 @@ internal class BillingAddressDetailsViewModelTest { // Given val state = BillingAddressInputComponentState( addressFieldName = BillingFormFields.Country.name, - inputComponentState = InputComponentState(InputFieldState().apply { text.value = Country.JAMAICA.name }) + inputComponentState = InputComponentState(InputFieldState().apply { text.value = Country.JAMAICA.name }), ) // When viewModel.updateCountryComponentState(state, Country.DENMARK) @@ -413,7 +414,7 @@ internal class BillingAddressDetailsViewModelTest { // Given val state = BillingAddressInputComponentState( addressFieldName = BillingFormFields.Country.name, - inputComponentState = InputComponentState(InputFieldState().apply { text.value = Country.DENMARK.name }) + inputComponentState = InputComponentState(InputFieldState().apply { text.value = Country.DENMARK.name }), ) // When viewModel.updateCountryComponentState(state, Country.DENMARK) @@ -428,7 +429,7 @@ internal class BillingAddressDetailsViewModelTest { // Given val state = BillingAddressInputComponentState( addressFieldName = BillingFormFields.Country.name, - inputComponentState = InputComponentState(InputFieldState().apply { text.value = "" }) + inputComponentState = InputComponentState(InputFieldState().apply { text.value = "" }), ) // When diff --git a/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/usecase/BillingAddressInputComponentStateUseCaseTest.kt b/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/usecase/BillingAddressInputComponentStateUseCaseTest.kt index 2e285b301..fb5e8bb49 100644 --- a/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/usecase/BillingAddressInputComponentStateUseCaseTest.kt +++ b/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/usecase/BillingAddressInputComponentStateUseCaseTest.kt @@ -8,8 +8,8 @@ import com.checkout.frames.component.billingaddressfields.BillingAddressInputCom import com.checkout.frames.component.billingaddressfields.BillingAddressInputComponentsContainerState import com.checkout.frames.mapper.ImageStyleToComposableImageMapper import com.checkout.frames.mapper.InputComponentStyleToStateMapper -import com.checkout.frames.mapper.TextLabelStyleToStateMapper import com.checkout.frames.mapper.InputFieldStyleToInputFieldStateMapper +import com.checkout.frames.mapper.TextLabelStyleToStateMapper import com.checkout.frames.mapper.billingaddressdetails.BillingAddressInputComponentStyleToStateMapper import com.checkout.frames.mock.BillingAddressDetailsTestData import com.checkout.frames.screen.billingaddress.billingaddressdetails.models.BillingFormFields @@ -33,11 +33,15 @@ import org.junit.jupiter.api.extension.ExtendWith internal class BillingAddressInputComponentStateUseCaseTest { @SpyK - lateinit var mockBillingAddressInputComponentStateMapper: Mapper + lateinit var mockBillingAddressInputComponentStateMapper: Mapper< + BillingAddressInputComponentStyle, + BillingAddressInputComponentState, + > - private lateinit var billingAddressInputComponentStateUseCase: UseCase + private lateinit var billingAddressInputComponentStateUseCase: UseCase< + BillingAddressDetailsStyle, + BillingAddressInputComponentsContainerState, + > init { initMappers() @@ -48,11 +52,11 @@ internal class BillingAddressInputComponentStateUseCaseTest { every { mockBillingAddressInputComponentStateMapper.map(any()) } returns BillingAddressInputComponentState( addressFieldName = BillingFormFields.CardHolderName.name, inputComponentState = InputComponentState(), - isAddressFieldValid = MutableStateFlow(false) + isAddressFieldValid = MutableStateFlow(false), ) billingAddressInputComponentStateUseCase = BillingAddressInputComponentStateUseCase( - mockBillingAddressInputComponentStateMapper + mockBillingAddressInputComponentStateMapper, ) } @@ -66,20 +70,20 @@ internal class BillingAddressInputComponentStateUseCaseTest { mockBillingAddressInputComponentStateMapper.map( BillingAddressInputComponentStyle( it.key.name, - it.value - ) + it.value, + ), ) } returns BillingAddressInputComponentState( addressFieldName = it.key.name, inputComponentState = InputComponentState(), - isAddressFieldValid = MutableStateFlow(false) + isAddressFieldValid = MutableStateFlow(false), ) } // When val style = BillingAddressDetailsStyle( HeaderComponentStyle(), - BillingAddressDetailsTestData.inputComponentsContainerStyle() + BillingAddressDetailsTestData.inputComponentsContainerStyle(), ) val result = billingAddressInputComponentStateUseCase.execute(style) @@ -98,8 +102,8 @@ internal class BillingAddressInputComponentStateUseCaseTest { mockBillingAddressInputComponentStateMapper = BillingAddressInputComponentStyleToStateMapper( InputComponentStyleToStateMapper( TextLabelStyleToStateMapper(imageStyleToComposableImageMapper), - InputFieldStyleToInputFieldStateMapper(imageStyleToComposableImageMapper) - ) + InputFieldStyleToInputFieldStateMapper(imageStyleToComposableImageMapper), + ), ) } } diff --git a/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/usecase/BillingAddressInputComponentStyleUseCaseTest.kt b/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/usecase/BillingAddressInputComponentStyleUseCaseTest.kt index 353a3a12a..1eb34365d 100644 --- a/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/usecase/BillingAddressInputComponentStyleUseCaseTest.kt +++ b/frames/src/test/java/com/checkout/frames/screen/billingaddressdetails/usecase/BillingAddressInputComponentStyleUseCaseTest.kt @@ -3,10 +3,10 @@ package com.checkout.frames.screen.billingaddressdetails.usecase import android.annotation.SuppressLint import com.checkout.base.mapper.Mapper import com.checkout.base.usecase.UseCase -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mapper.ContainerStyleToModifierMapper import com.checkout.frames.mapper.InputComponentStyleToViewStyleMapper import com.checkout.frames.mapper.InputFieldStyleToViewStyleMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mapper.billingaddressdetails.BillingAddressInputComponentStyleToViewStyleMapper import com.checkout.frames.mock.BillingAddressDetailsTestData import com.checkout.frames.screen.billingaddress.billingaddressdetails.models.BillingFormFields @@ -34,11 +34,15 @@ import org.junit.jupiter.api.extension.ExtendWith internal class BillingAddressInputComponentStyleUseCaseTest { @SpyK - lateinit var mockBillingAddressInputComponentStyleMapper: Mapper + lateinit var mockBillingAddressInputComponentStyleMapper: Mapper< + BillingAddressInputComponentStyle, + BillingAddressInputComponentViewStyle, + > - private lateinit var billingAddressInputComponentStyleUseCase: UseCase + private lateinit var billingAddressInputComponentStyleUseCase: UseCase< + BillingAddressDetailsStyle, + BillingAddressInputComponentsViewContainerStyle, + > init { initMappers() @@ -54,12 +58,12 @@ internal class BillingAddressInputComponentStyleUseCaseTest { infoStyle = TextLabelViewStyle(), inputFieldStyle = InputFieldViewStyle(), subtitleStyle = TextLabelViewStyle(), - titleStyle = TextLabelViewStyle() - ) + titleStyle = TextLabelViewStyle(), + ), ) billingAddressInputComponentStyleUseCase = BillingAddressInputComponentStyleUseCase( - mockBillingAddressInputComponentStyleMapper + mockBillingAddressInputComponentStyleMapper, ) } @@ -73,8 +77,8 @@ internal class BillingAddressInputComponentStyleUseCaseTest { mockBillingAddressInputComponentStyleMapper.map( BillingAddressInputComponentStyle( it.key.name, - it.value - ) + it.value, + ), ) } returns BillingAddressInputComponentViewStyle( addressFieldName = it.key.name, @@ -84,16 +88,15 @@ internal class BillingAddressInputComponentStyleUseCaseTest { infoStyle = TextLabelViewStyle(), inputFieldStyle = InputFieldViewStyle(), subtitleStyle = TextLabelViewStyle(), - titleStyle = TextLabelViewStyle() - ) - + titleStyle = TextLabelViewStyle(), + ), ) } // When val style = BillingAddressDetailsStyle( HeaderComponentStyle(), - BillingAddressDetailsTestData.inputComponentsContainerStyle() + BillingAddressDetailsTestData.inputComponentsContainerStyle(), ) val result = billingAddressInputComponentStyleUseCase.execute(style) @@ -112,8 +115,8 @@ internal class BillingAddressInputComponentStyleUseCaseTest { InputComponentStyleToViewStyleMapper( textLabelStyleMapper, InputFieldStyleToViewStyleMapper(textLabelStyleMapper), - ContainerStyleToModifierMapper() - ) + ContainerStyleToModifierMapper(), + ), ) } } diff --git a/frames/src/test/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsViewModelTest.kt b/frames/src/test/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsViewModelTest.kt index c2026426a..b68005e2c 100644 --- a/frames/src/test/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/screen/paymentdetails/PaymentDetailsViewModelTest.kt @@ -9,11 +9,11 @@ import com.checkout.base.model.Country import com.checkout.base.usecase.UseCase import com.checkout.frames.component.provider.ComponentProvider import com.checkout.frames.logging.PaymentFormEventType +import com.checkout.frames.mapper.ContainerStyleToModifierMapper import com.checkout.frames.mapper.ImageStyleToClickableComposableImageMapper -import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper -import com.checkout.frames.mapper.TextLabelStyleToStateMapper import com.checkout.frames.mapper.ImageStyleToComposableImageMapper -import com.checkout.frames.mapper.ContainerStyleToModifierMapper +import com.checkout.frames.mapper.TextLabelStyleToStateMapper +import com.checkout.frames.mapper.TextLabelStyleToViewStyleMapper import com.checkout.frames.mock.PaymentFormConfigTestData import com.checkout.frames.screen.billingaddress.billingaddressdetails.models.BillingAddress import com.checkout.frames.screen.billingaddress.billingaddressdetails.models.BillingAddress.Companion.isEdited @@ -99,7 +99,7 @@ internal class PaymentDetailsViewModelTest { // Then verify(exactly = 1) { spyTextLabelStyleMapper.map( - eq(TextLabelStyle(text, textId, textStyle, containerStyle = containerStyle)) + eq(TextLabelStyle(text, textId, textStyle, containerStyle = containerStyle)), ) } } @@ -112,7 +112,7 @@ internal class PaymentDetailsViewModelTest { // Then verify(exactly = 1) { spyTextLabelStateMapper.map( - eq(TextLabelStyle(text, textId, textStyle, containerStyle = containerStyle)) + eq(TextLabelStyle(text, textId, textStyle, containerStyle = containerStyle)), ) } } @@ -149,7 +149,7 @@ internal class PaymentDetailsViewModelTest { mockPaymentStateManager.billingAddress.value = BillingAddress( address = PaymentFormConfigTestData.address, name = "Test name", - phone = PaymentFormConfigTestData.phone + phone = PaymentFormConfigTestData.phone, ) // When @@ -168,7 +168,7 @@ internal class PaymentDetailsViewModelTest { every { mockPaymentStateManager.billingAddress.value } returns BillingAddress( address = PaymentFormConfigTestData.address, name = "Test name", - phone = PaymentFormConfigTestData.phone + phone = PaymentFormConfigTestData.phone, ) // When @@ -218,10 +218,10 @@ internal class PaymentDetailsViewModelTest { @ParameterizedTest( name = "When view model initialised with: cvvComponentStyle is null = {0}, " + - "CardHolderNameComponentStyle is null = {1}, \"CardHolderNameComponentStyle is optional = {2} " + - "addressSummaryComponentStyle is null = {3} " + "and addressSummaryComponentStyle is optional = {4}; " + - "Then payment state is reset with: " + - "isCvvValid = {5} isBillingAddressValid = {6} and isCardHolderNameValid = {7}" + "CardHolderNameComponentStyle is null = {1}, \"CardHolderNameComponentStyle is optional = {2} " + + "addressSummaryComponentStyle is null = {3} " + "and addressSummaryComponentStyle is optional = {4}; " + + "Then payment state is reset with: " + + "isCvvValid = {5} isBillingAddressValid = {6} and isCardHolderNameValid = {7}", ) @MethodSource("resetArguments") fun `when view model is initialised then payment state is reset with correct values`( @@ -232,14 +232,17 @@ internal class PaymentDetailsViewModelTest { isAddressOptional: Boolean, isCvvValid: Boolean, isBillingAddressValid: Boolean, - isCardHolderNameValid: Boolean + isCardHolderNameValid: Boolean, ) { // Given val style = PaymentDetailsStyle().apply { if (isCvvStyleNull) cvvStyle = null - cardHolderNameStyle = if (isCardHolderNameStyleNull) null - else DefaultCardHolderNameComponentStyle.light(isOptional = isCardHolderNameOptional) + cardHolderNameStyle = if (isCardHolderNameStyleNull) { + null + } else { + DefaultCardHolderNameComponentStyle.light(isOptional = isCardHolderNameOptional) + } addressSummaryStyle = if (isAddressStyleNull) null else addressSummaryStyle?.copy(isOptional = isAddressOptional) @@ -252,7 +255,10 @@ internal class PaymentDetailsViewModelTest { val isBillingAddressEnabled = !isAddressStyleNull verify { mockPaymentStateManager.resetPaymentState( - isCvvValid, isCardHolderNameValid, isBillingAddressValid, isBillingAddressEnabled + isCvvValid, + isCardHolderNameValid, + isBillingAddressValid, + isBillingAddressEnabled, ) } } @@ -267,7 +273,7 @@ internal class PaymentDetailsViewModelTest { mockClosePaymentFlowUseCase, mockPaymentStateManager, mockLogger, - style + style, ) } @@ -285,7 +291,7 @@ internal class PaymentDetailsViewModelTest { Arguments.of(false, false, false, false, false, false, false, false), Arguments.of(true, true, true, false, false, true, false, true), Arguments.of(true, false, true, true, false, true, true, true), - Arguments.of(true, true, false, false, true, true, true, true) + Arguments.of(true, true, false, false, true, true, true, true), ) } } diff --git a/frames/src/test/java/com/checkout/frames/screen/paymentform/PaymentFormConfigTest.kt b/frames/src/test/java/com/checkout/frames/screen/paymentform/PaymentFormConfigTest.kt index b0ae15f07..fc5ad0bee 100644 --- a/frames/src/test/java/com/checkout/frames/screen/paymentform/PaymentFormConfigTest.kt +++ b/frames/src/test/java/com/checkout/frames/screen/paymentform/PaymentFormConfigTest.kt @@ -44,13 +44,14 @@ internal class PaymentFormConfigTest { city = "London", state = "London", zip = "W1T 4TJ", - country = Country.from(iso3166Alpha2 = "GB") + country = Country.from(iso3166Alpha2 = "GB"), ), phone = Phone( - number = "4155552671", country = Country.from(iso3166Alpha2 = "GB") - ) - ) - ) + number = "4155552671", + country = Country.from(iso3166Alpha2 = "GB"), + ), + ), + ), ) // Then @@ -66,36 +67,38 @@ internal class PaymentFormConfigTest { assertEquals(PaymentFormConfigTestData.prefillData.billingFormAddress?.name, billingFormAddress?.name) assertEquals( PaymentFormConfigTestData.prefillData.billingFormAddress?.phone?.country, - billingFormAddress?.phone?.country + billingFormAddress?.phone?.country, ) assertEquals( PaymentFormConfigTestData.prefillData.billingFormAddress?.phone?.number, - billingFormAddress?.phone?.number + billingFormAddress?.phone?.number, ) val actualAddress = billingFormAddress?.address assertEquals( PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.addressLine1, - actualAddress?.addressLine1 + actualAddress?.addressLine1, ) assertEquals( PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.addressLine2, - actualAddress?.addressLine2 + actualAddress?.addressLine2, ) assertEquals( PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.country?.name, - actualAddress?.country?.name + actualAddress?.country?.name, ) assertEquals( PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.country?.iso3166Alpha2, - actualAddress?.country?.iso3166Alpha2 + actualAddress?.country?.iso3166Alpha2, ) assertEquals(PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.zip, actualAddress?.zip) assertEquals( - PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.city, actualAddress?.city + PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.city, + actualAddress?.city, ) assertEquals( - PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.state, actualAddress?.state + PaymentFormConfigTestData.prefillData.billingFormAddress?.address?.state, + actualAddress?.state, ) } } diff --git a/frames/src/test/java/com/checkout/frames/screen/paymentform/PaymentFormViewModelTest.kt b/frames/src/test/java/com/checkout/frames/screen/paymentform/PaymentFormViewModelTest.kt index e4c8ac7c5..dc3f51f68 100644 --- a/frames/src/test/java/com/checkout/frames/screen/paymentform/PaymentFormViewModelTest.kt +++ b/frames/src/test/java/com/checkout/frames/screen/paymentform/PaymentFormViewModelTest.kt @@ -28,7 +28,7 @@ internal class PaymentFormViewModelTest { environment = Environment.PRODUCTION, paymentFlowHandler = PaymentFormConfigTestData.paymentFlowHandler, supportedCardSchemes = PaymentFormConfigTestData.supportedCardSchemes, - prefillData = PaymentFormConfigTestData.prefillData + prefillData = PaymentFormConfigTestData.prefillData, ) // When diff --git a/frames/src/test/java/com/checkout/frames/style/DefaultCardHolderNameComponentStyleTest.kt b/frames/src/test/java/com/checkout/frames/style/DefaultCardHolderNameComponentStyleTest.kt index 0c4e1b1b0..68158c107 100644 --- a/frames/src/test/java/com/checkout/frames/style/DefaultCardHolderNameComponentStyleTest.kt +++ b/frames/src/test/java/com/checkout/frames/style/DefaultCardHolderNameComponentStyleTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class DefaultCardHolderNameComponentStyleTest { - private lateinit var style: CardHolderNameComponentStyle + private lateinit var style: CardHolderNameComponentStyle @Test fun `when DefaultCardHolderNameComponentStyle is requested with isOptional true then correct style data should load`() { diff --git a/frames/src/test/java/com/checkout/frames/tokenization/CardTokenizationUseCaseTest.kt b/frames/src/test/java/com/checkout/frames/tokenization/CardTokenizationUseCaseTest.kt index d170bd907..55802b776 100644 --- a/frames/src/test/java/com/checkout/frames/tokenization/CardTokenizationUseCaseTest.kt +++ b/frames/src/test/java/com/checkout/frames/tokenization/CardTokenizationUseCaseTest.kt @@ -3,8 +3,8 @@ package com.checkout.frames.tokenization import android.annotation.SuppressLint import com.checkout.api.CheckoutApiService import com.checkout.base.usecase.UseCase -import com.checkout.frames.usecase.CardTokenizationUseCase import com.checkout.frames.model.request.InternalCardTokenRequest +import com.checkout.frames.usecase.CardTokenizationUseCase import com.checkout.tokenization.model.Card import com.checkout.tokenization.model.CardTokenRequest import com.checkout.tokenization.model.ExpiryDate @@ -15,9 +15,8 @@ import io.mockk.slot import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertFalse - +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -42,7 +41,7 @@ internal class CardTokenizationUseCaseTest { mockCheckoutApiService, { merchantOnStart = true }, { merchantResultTokenDetails = it }, - { merchantResultErrorMessage = it } + { merchantResultErrorMessage = it }, ) } @@ -83,13 +82,13 @@ internal class CardTokenizationUseCaseTest { val request = InternalCardTokenRequest( Card(ExpiryDate(2, 24), number = ""), { internalSuccessCallbackInvoked = true }, - { internalFailureCallbackInvoked = true } + { internalFailureCallbackInvoked = true }, ) val capturedCardTokenRequest = slot() val expectedTokenDetails = TokenDetails( "type", "token_token", "02/23", 2, 23, null, "", "", "", null, null, null, null, - null, null, null, null, null + null, null, null, null, null, ) merchantResultTokenDetails = null merchantResultErrorMessage = null @@ -114,7 +113,7 @@ internal class CardTokenizationUseCaseTest { val request = InternalCardTokenRequest( Card(ExpiryDate(2, 24), number = ""), { internalSuccessCallbackInvoked = true }, - { internalFailureCallbackInvoked = true } + { internalFailureCallbackInvoked = true }, ) val capturedCardTokenRequest = slot() val expectedErrorMessage = "Error message. Test." diff --git a/frames/src/test/java/com/checkout/frames/utils/extensions/BillingAddressDetailsExtensionsTest.kt b/frames/src/test/java/com/checkout/frames/utils/extensions/BillingAddressDetailsExtensionsTest.kt index 63396e7a3..ea0cac9f4 100644 --- a/frames/src/test/java/com/checkout/frames/utils/extensions/BillingAddressDetailsExtensionsTest.kt +++ b/frames/src/test/java/com/checkout/frames/utils/extensions/BillingAddressDetailsExtensionsTest.kt @@ -30,9 +30,9 @@ internal class BillingAddressDetailsExtensionsTest { city = "city", country = country, state = "dummy state", - zip = "post code" + zip = "post code", ), - phone = Phone("9426979314", country) + phone = Phone("9426979314", country), ) // When @@ -43,14 +43,13 @@ internal class BillingAddressDetailsExtensionsTest { } @ParameterizedTest( - name = "When getErrorMessage {0} is requested then error message {1} is provided" + name = "When getErrorMessage {0} is requested then error message {1} is provided", ) @MethodSource("testGetErrorMessageArguments") fun `when getErrorMessage is requested then correct error message should return`( inputComponentState: BillingAddressInputComponentState, expectedErrorMessageResourceId: Int, ) { - // When val actualErrorMessageResourceId = inputComponentState.getErrorMessage() @@ -77,7 +76,7 @@ internal class BillingAddressDetailsExtensionsTest { R.string.cko_billing_form_input_field_post_code_error, BillingAddressDetailsTestData.fetchInputComponentStateList()[6], R.string.cko_billing_form_input_field_phone_number_error, - ) + ), ) } } diff --git a/frames/src/test/java/com/checkout/frames/utils/extensions/BillingAddressExtensionsTest.kt b/frames/src/test/java/com/checkout/frames/utils/extensions/BillingAddressExtensionsTest.kt index cb6f6ddf9..021697ba1 100644 --- a/frames/src/test/java/com/checkout/frames/utils/extensions/BillingAddressExtensionsTest.kt +++ b/frames/src/test/java/com/checkout/frames/utils/extensions/BillingAddressExtensionsTest.kt @@ -18,7 +18,7 @@ import java.util.stream.Stream internal class BillingAddressExtensionsTest { @ParameterizedTest( - name = "When summary of billing address {0} is requested then addressPreview {1} is provided" + name = "When summary of billing address {0} is requested then addressPreview {1} is provided", ) @MethodSource("testBillingAddressSummaryArguments") fun `Requested billing address summary should provide correct address preview text`( @@ -33,7 +33,7 @@ internal class BillingAddressExtensionsTest { } @ParameterizedTest( - name = "When summary of billing address {0} is requested then addressPreview {1} is provided" + name = "When summary of billing address {0} is requested then addressPreview {1} is provided", ) @MethodSource("testIsBillingAddressValidArguments") fun `Requested to verify valid billing address should provide correct validation`( @@ -58,18 +58,18 @@ internal class BillingAddressExtensionsTest { city = "city", state = "state", zip = "zipcode", - country = Country.UNITED_KINGDOM + country = Country.UNITED_KINGDOM, ), - phone = Phone("123", Country.UNITED_KINGDOM) + phone = Phone("123", Country.UNITED_KINGDOM), ), "LINE 1\nLINE 2\ncity\nstate\nzipcode\nUnited Kingdom\n+44 123", BillingAddress( name = "Test name", - phone = Phone("123", Country.UNITED_KINGDOM) + phone = Phone("123", Country.UNITED_KINGDOM), ), "Test name\n+44 123", BillingAddress( - name = "Test name" + name = "Test name", ), "Test name", BillingAddress( @@ -80,12 +80,12 @@ internal class BillingAddressExtensionsTest { city = "", state = "state", zip = "zipcode", - country = Country.UNITED_KINGDOM - ) + country = Country.UNITED_KINGDOM, + ), ), "Test name\nstate\nzipcode\nUnited Kingdom", - BillingAddress(), "" - ) + BillingAddress(), "", + ), ) @JvmStatic @@ -98,17 +98,18 @@ internal class BillingAddressExtensionsTest { city = "city", state = "state", zip = "zipcode", - country = Country.UNITED_KINGDOM + country = Country.UNITED_KINGDOM, ), - phone = Phone("123", Country.UNITED_KINGDOM) + phone = Phone("123", Country.UNITED_KINGDOM), ), true, BillingAddress( - name = "Test name", phone = Phone("123", Country.UNITED_KINGDOM) + name = "Test name", + phone = Phone("123", Country.UNITED_KINGDOM), ), false, BillingAddress( - name = "Test name" + name = "Test name", ), false, BillingAddress( @@ -119,8 +120,8 @@ internal class BillingAddressExtensionsTest { city = "", state = "state", zip = "zipcode", - country = null - ) + country = null, + ), ), false, BillingAddress( @@ -131,11 +132,11 @@ internal class BillingAddressExtensionsTest { city = "", state = "state", zip = "zipcode", - country = Country.UNITED_KINGDOM - ) + country = Country.UNITED_KINGDOM, + ), ), - false - ) + false, + ), ) } } diff --git a/frames/src/test/java/com/checkout/frames/utils/extensions/StringExtensionsKtTest.kt b/frames/src/test/java/com/checkout/frames/utils/extensions/StringExtensionsKtTest.kt index 9df96259c..076ab6044 100644 --- a/frames/src/test/java/com/checkout/frames/utils/extensions/StringExtensionsKtTest.kt +++ b/frames/src/test/java/com/checkout/frames/utils/extensions/StringExtensionsKtTest.kt @@ -15,12 +15,12 @@ import java.util.stream.Stream internal class StringExtensionsKtTest { @ParameterizedTest( - name = "When transformation of string {0} is requested then expiry date {1} is provided" + name = "When transformation of string {0} is requested then expiry date {1} is provided", ) @MethodSource("testArguments") fun `Create expiry date data object from string`( inputString: String, - expectedResult: ExpiryDate + expectedResult: ExpiryDate, ) { // When val result = inputString.toExpiryDate() @@ -37,7 +37,7 @@ internal class StringExtensionsKtTest { Arguments.of("0123", ExpiryDate(1, 23)), Arguments.of("0103", ExpiryDate(1, 3)), Arguments.of("01033", ExpiryDate(0, 0)), - Arguments.of("01", ExpiryDate(0, 0)) + Arguments.of("01", ExpiryDate(0, 0)), ) } }