-
Notifications
You must be signed in to change notification settings - Fork 77
v6: GooglePay - Add application parameter to factories #2609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,7 @@ internal class SessionsPaymentFacilitatorFactory( | |
| ) | ||
|
|
||
| val paymentComponent = PaymentMethodProvider.get( | ||
| application = applicationContext.applicationContext as android.app.Application, | ||
| paymentMethod = paymentMethod, | ||
| coroutineScope = coroutineScope, | ||
| analyticsManager = analyticsManager, | ||
|
|
@@ -77,25 +78,7 @@ internal class SessionsPaymentFacilitatorFactory( | |
| checkoutCallbacks = checkoutCallbacks, | ||
| ) | ||
|
|
||
| val sessionInteractor = SessionInteractor( | ||
| sessionRepository = SessionRepository( | ||
| sessionService = SessionService( | ||
| httpClient = HttpClientFactory.getHttpClient(checkoutConfiguration.environment), | ||
| ), | ||
| clientKey = checkoutConfiguration.clientKey, | ||
| ), | ||
| sessionSavedStateHandleContainer = sessionSavedStateHandleContainer, | ||
| analyticsManager = analyticsManager, | ||
| sessionResponse = sessionSavedStateHandleContainer.getSessionResponse(), | ||
| isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false, | ||
| ) | ||
|
|
||
| // TODO - Based on txVariant, needs to be abstracted away | ||
| val componentEventHandler = | ||
| SessionsComponentEventHandler<BasePaymentComponentState>( | ||
| sessionInteractor = sessionInteractor, | ||
| componentCallbacks = checkoutCallbacks.toSessionsComponentCallbacks(), | ||
| ) | ||
| val componentEventHandler = createComponentEventHandler(sessionSavedStateHandleContainer, analyticsManager) | ||
|
|
||
| val actionProvider = ActionProvider( | ||
| analyticsManager = analyticsManager, | ||
|
|
@@ -113,4 +96,27 @@ internal class SessionsPaymentFacilitatorFactory( | |
| commonComponentParams = componentParamsBundle.commonComponentParams, | ||
| ) | ||
| } | ||
|
|
||
| private fun createComponentEventHandler( | ||
| sessionSavedStateHandleContainer: SessionSavedStateHandleContainer, | ||
| analyticsManager: com.adyen.checkout.core.analytics.internal.AnalyticsManager, | ||
| ): SessionsComponentEventHandler<BasePaymentComponentState> { | ||
| val sessionInteractor = SessionInteractor( | ||
| sessionRepository = SessionRepository( | ||
| sessionService = SessionService( | ||
| httpClient = HttpClientFactory.getHttpClient(checkoutConfiguration.environment), | ||
| ), | ||
| clientKey = checkoutConfiguration.clientKey, | ||
| ), | ||
| sessionSavedStateHandleContainer = sessionSavedStateHandleContainer, | ||
| analyticsManager = analyticsManager, | ||
| sessionResponse = sessionSavedStateHandleContainer.getSessionResponse(), | ||
| isFlowTakenOver = sessionSavedStateHandleContainer.isFlowTakenOver ?: false, | ||
| ) | ||
|
|
||
| return SessionsComponentEventHandler( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| sessionInteractor = sessionInteractor, | ||
| componentCallbacks = checkoutCallbacks.toSessionsComponentCallbacks(), | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |||||
|
|
||||||
| package com.adyen.checkout.core.components.internal | ||||||
|
|
||||||
| import android.app.Application | ||||||
| import com.adyen.checkout.core.analytics.internal.AnalyticsManager | ||||||
| import com.adyen.checkout.core.analytics.internal.TestAnalyticsManager | ||||||
| import com.adyen.checkout.core.common.Environment | ||||||
|
|
@@ -107,6 +108,7 @@ internal class PaymentMethodProviderTest { | |||||
| PaymentMethodProvider.register("txVariant", secondaryFactory) | ||||||
|
|
||||||
| val actualComponent = PaymentMethodProvider.get( | ||||||
| application = generateApplication(), | ||||||
| paymentMethod = PaymentMethod(type = "txVariant", name = "name"), | ||||||
| coroutineScope = this, | ||||||
| analyticsManager = TestAnalyticsManager(), | ||||||
|
|
@@ -131,6 +133,7 @@ internal class PaymentMethodProviderTest { | |||||
| PaymentMethodProvider.register("txVariant", secondaryFactory) | ||||||
|
|
||||||
| val actualComponent = PaymentMethodProvider.get( | ||||||
| application = generateApplication(), | ||||||
| paymentMethod = StoredPaymentMethod(type = "txVariant", name = "name"), | ||||||
| coroutineScope = this, | ||||||
| analyticsManager = TestAnalyticsManager(), | ||||||
|
|
@@ -165,6 +168,7 @@ internal class PaymentMethodProviderTest { | |||||
| PaymentMethodProvider.register("txVariant", factory) | ||||||
|
|
||||||
| val actualComponent = PaymentMethodProvider.get( | ||||||
| application = generateApplication(), | ||||||
| paymentMethod = PaymentMethod(type = "txVariant", name = "name"), | ||||||
| coroutineScope = this, | ||||||
| analyticsManager = TestAnalyticsManager(), | ||||||
|
|
@@ -182,6 +186,7 @@ internal class PaymentMethodProviderTest { | |||||
| PaymentMethodProvider.register("txVariant", storedFactory) | ||||||
|
|
||||||
| val actualComponent = PaymentMethodProvider.get( | ||||||
| application = generateApplication(), | ||||||
| paymentMethod = StoredPaymentMethod(type = "txVariant", name = "name"), | ||||||
| coroutineScope = this, | ||||||
| analyticsManager = TestAnalyticsManager(), | ||||||
|
|
@@ -197,6 +202,7 @@ internal class PaymentMethodProviderTest { | |||||
| fun `when get is called for an unregistered factory, then an error is thrown`() = runTest { | ||||||
| assertThrows<IllegalStateException> { | ||||||
| PaymentMethodProvider.get( | ||||||
| application = generateApplication(), | ||||||
| paymentMethod = PaymentMethod(type = "unregistered_txVariant", name = "name"), | ||||||
| coroutineScope = this, | ||||||
| analyticsManager = TestAnalyticsManager(), | ||||||
|
|
@@ -211,6 +217,7 @@ internal class PaymentMethodProviderTest { | |||||
| fun `when get is called for an unregistered stored factory, then an error is thrown`() = runTest { | ||||||
| assertThrows<IllegalStateException> { | ||||||
| PaymentMethodProvider.get( | ||||||
| application = generateApplication(), | ||||||
| paymentMethod = StoredPaymentMethod(type = "unregistered_txVariant", name = "name"), | ||||||
| coroutineScope = this, | ||||||
| analyticsManager = TestAnalyticsManager(), | ||||||
|
|
@@ -239,6 +246,7 @@ internal class PaymentMethodProviderTest { | |||||
| object : | ||||||
| PaymentComponentFactory<BasePaymentComponentState, PaymentComponent<BasePaymentComponentState>> { | ||||||
| override fun create( | ||||||
| application: Application, | ||||||
| paymentMethod: PaymentMethod, | ||||||
| coroutineScope: CoroutineScope, | ||||||
| analyticsManager: AnalyticsManager, | ||||||
|
|
@@ -252,6 +260,7 @@ internal class PaymentMethodProviderTest { | |||||
| object : | ||||||
| StoredPaymentComponentFactory<BasePaymentComponentState, PaymentComponent<BasePaymentComponentState>> { | ||||||
| override fun create( | ||||||
| application: Application, | ||||||
| storedPaymentMethod: StoredPaymentMethod, | ||||||
| coroutineScope: CoroutineScope, | ||||||
| analyticsManager: AnalyticsManager, | ||||||
|
|
@@ -261,6 +270,10 @@ internal class PaymentMethodProviderTest { | |||||
| ) = paymentComponent | ||||||
| } | ||||||
|
|
||||||
| private fun generateApplication(): Application { | ||||||
| return org.mockito.Mockito.mock(Application::class.java) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To improve code style, you can add
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| private fun generateCheckoutConfiguration() = CheckoutConfiguration( | ||||||
| shopperLocale = Locale.US, | ||||||
| environment = Environment.TEST, | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability, you could import
com.adyen.checkout.core.analytics.internal.AnalyticsManagerat the top of the file and use the simple nameAnalyticsManagerhere.