diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index 52b409ad..72b804f7 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -36,7 +36,7 @@ object Versions { const val moshi = "1.15.1" // Risk SDK Dependencies - const val riskSdk = "1.0.6" + const val riskSdk = "2.0.0" // Unit Testing Dependencies const val junit5Jupiter = "5.8.0" diff --git a/checkout/src/main/java/com/checkout/CheckoutApiServiceFactory.kt b/checkout/src/main/java/com/checkout/CheckoutApiServiceFactory.kt index 4d9aa148..f2ae1952 100644 --- a/checkout/src/main/java/com/checkout/CheckoutApiServiceFactory.kt +++ b/checkout/src/main/java/com/checkout/CheckoutApiServiceFactory.kt @@ -8,6 +8,7 @@ import com.checkout.logging.EventLoggerProvider import com.checkout.logging.Logger import com.checkout.logging.model.LoggingEvent import com.checkout.network.OkHttpProvider +import com.checkout.risk.FramesOptions import com.checkout.threedsecure.Executor import com.checkout.threedsecure.ThreeDSExecutor import com.checkout.threedsecure.logging.ThreeDSEventLogger @@ -32,6 +33,7 @@ import com.squareup.moshi.Moshi public object CheckoutApiServiceFactory { private lateinit var correlationId: String + private lateinit var riskSDKFramesOptions: FramesOptions @JvmStatic public fun create( @@ -40,9 +42,13 @@ public object CheckoutApiServiceFactory { context: Context, ): CheckoutApiService { val logger = EventLoggerProvider.provide() - logger.setup(context, environment) correlationId = logger.correlationId + riskSDKFramesOptions = FramesOptions( + version = BuildConfig.PRODUCT_VERSION, + productIdentifier = BuildConfig.PRODUCT_IDENTIFIER, + correlationId, + ) return CheckoutApiClient( provideTokenRepository(context, publicKey, environment), @@ -71,7 +77,7 @@ public object CheckoutApiServiceFactory { logger = TokenizationEventLogger(EventLoggerProvider.provide()), publicKey = publicKey, cvvTokenizationNetworkDataMapper = CVVTokenizationNetworkDataMapper(), - riskSdkUseCase = RiskSdkUseCase(environment, context, publicKey, correlationId, RiskInstanceProvider), + riskSdkUseCase = RiskSdkUseCase(environment, context, publicKey, riskSDKFramesOptions, RiskInstanceProvider), ) private fun provideNetworkApiClient( diff --git a/checkout/src/main/java/com/checkout/tokenization/usecase/RiskInstanceProvider.kt b/checkout/src/main/java/com/checkout/tokenization/usecase/RiskInstanceProvider.kt index a75cd1a0..42aa0d5b 100644 --- a/checkout/src/main/java/com/checkout/tokenization/usecase/RiskInstanceProvider.kt +++ b/checkout/src/main/java/com/checkout/tokenization/usecase/RiskInstanceProvider.kt @@ -2,6 +2,7 @@ package com.checkout.tokenization.usecase import android.content.Context import com.checkout.base.model.Environment +import com.checkout.risk.FramesOptions import com.checkout.risk.Risk import com.checkout.risk.RiskConfig import com.checkout.risk.RiskEnvironment @@ -13,7 +14,7 @@ internal object RiskInstanceProvider { context: Context, publicKey: String, environment: Environment, - correlationId: String, + framesOptions: FramesOptions, ): Risk? { if (riskInstance != null) { return riskInstance @@ -31,8 +32,7 @@ internal object RiskInstanceProvider { RiskConfig( publicKey = publicKey, environment = riskEnvironment, - framesMode = true, - correlationId = correlationId, + framesOptions = framesOptions, ), ) return riskInstance diff --git a/checkout/src/main/java/com/checkout/tokenization/usecase/RiskSdkUseCase.kt b/checkout/src/main/java/com/checkout/tokenization/usecase/RiskSdkUseCase.kt index 39cefac2..ccf0dac0 100644 --- a/checkout/src/main/java/com/checkout/tokenization/usecase/RiskSdkUseCase.kt +++ b/checkout/src/main/java/com/checkout/tokenization/usecase/RiskSdkUseCase.kt @@ -2,17 +2,18 @@ package com.checkout.tokenization.usecase import android.content.Context import com.checkout.base.model.Environment +import com.checkout.risk.FramesOptions import com.checkout.tokenization.model.TokenResult internal class RiskSdkUseCase( private val environment: Environment, private val context: Context, private val publicKey: String, - private val correlationId: String, + private val framesOptions: FramesOptions, private val riskInstanceProvider: RiskInstanceProvider, ) { suspend fun execute(data: TokenResult) { - val riskInstance = riskInstanceProvider.provide(context, publicKey, environment, correlationId) + val riskInstance = riskInstanceProvider.provide(context, publicKey, environment, framesOptions) when (data) { is TokenResult.Success -> riskInstance?.publishData(cardToken = data.result) is TokenResult.Failure -> {} diff --git a/checkout/src/test/java/com/checkout/tokenization/RiskSdkUseCaseTest.kt b/checkout/src/test/java/com/checkout/tokenization/RiskSdkUseCaseTest.kt index 47faeb79..a3b78550 100644 --- a/checkout/src/test/java/com/checkout/tokenization/RiskSdkUseCaseTest.kt +++ b/checkout/src/test/java/com/checkout/tokenization/RiskSdkUseCaseTest.kt @@ -3,6 +3,7 @@ package com.checkout.tokenization import android.content.Context import com.checkout.base.error.CheckoutError import com.checkout.base.model.Environment +import com.checkout.risk.FramesOptions import com.checkout.risk.Risk import com.checkout.tokenization.model.TokenDetails import com.checkout.tokenization.model.TokenResult @@ -18,6 +19,9 @@ import org.junit.jupiter.api.Test public class RiskSdkUseCaseTest { private val correlationId: String = "testCorrelationId" + private val version: String = "1.0.0" + private val productIdentifier: String = "productIdentifier" + private val framesOptions: FramesOptions = FramesOptions(version, productIdentifier, correlationId) private val environment: Environment = Environment.SANDBOX private val riskInstanceProvider: RiskInstanceProvider = mockk() private val riskInstance: Risk = mockk() @@ -28,7 +32,7 @@ public class RiskSdkUseCaseTest { @BeforeEach public fun setup() { coEvery { tokenDetails.token } returns TOKEN - coEvery { riskInstanceProvider.provide(context, PUBLIC_KEY, environment, correlationId) } returns riskInstance + coEvery { riskInstanceProvider.provide(context, PUBLIC_KEY, environment, framesOptions) } returns riskInstance coEvery { riskInstance.publishData(any()) } returns mockk() useCase = RiskSdkUseCase( @@ -36,7 +40,7 @@ public class RiskSdkUseCaseTest { context = context, publicKey = PUBLIC_KEY, riskInstanceProvider = riskInstanceProvider, - correlationId = correlationId, + framesOptions = framesOptions, ) } @@ -44,7 +48,7 @@ public class RiskSdkUseCaseTest { public fun `Success result should trigger publishData`() { runBlocking { useCase.execute(TokenResult.Success(tokenDetails.token)) - coVerify { riskInstanceProvider.provide(context, PUBLIC_KEY, environment, correlationId) } + coVerify { riskInstanceProvider.provide(context, PUBLIC_KEY, environment, framesOptions) } coVerify { riskInstance.publishData(TOKEN) } } }