Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import java.util.UUID

/** @suppress */
@ProcessOutInternalApi
object POEventDispatcher {
class POEventDispatcher {

companion object {
val instance: POEventDispatcher by lazy {
POEventDispatcher()
}
}

interface Request {
val uuid: UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PODefaultProxy3DSService(
) : POProxy3DSService {

private val uuid = UUID.randomUUID()
private val eventDispatcher = POEventDispatcher
private val eventDispatcher = POEventDispatcher.instance

private var authenticationCallback: ((ProcessOutResult<PO3DS2AuthenticationRequest>) -> Unit)? = null
private var challengeCallback: ((ProcessOutResult<Boolean>) -> Unit)? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal class CardTokenizationInteractor(
private val cardsRepository: POCardsRepository,
private val cardSchemeProvider: CardSchemeProvider,
private val addressSpecificationProvider: AddressSpecificationProvider,
private val eventDispatcher: POEventDispatcher = POEventDispatcher
private val eventDispatcher: POEventDispatcher
) : BaseInteractor() {

private companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.processout.sdk.R
import com.processout.sdk.api.ProcessOut
import com.processout.sdk.api.dispatcher.POEventDispatcher
import com.processout.sdk.ui.card.tokenization.CardTokenizationInteractorState.*
import com.processout.sdk.ui.card.tokenization.CardTokenizationViewModelState.*
import com.processout.sdk.ui.core.shared.image.PODrawableImage
Expand Down Expand Up @@ -40,7 +41,8 @@ internal class CardTokenizationViewModel private constructor(

class Factory(
private val app: Application,
private val configuration: POCardTokenizationConfiguration
private val configuration: POCardTokenizationConfiguration,
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance
) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T =
Expand All @@ -52,7 +54,8 @@ internal class CardTokenizationViewModel private constructor(
configuration = configuration,
cardsRepository = ProcessOut.instance.cards,
cardSchemeProvider = CardSchemeProvider(),
addressSpecificationProvider = AddressSpecificationProvider(app)
addressSpecificationProvider = AddressSpecificationProvider(app),
eventDispatcher = eventDispatcher
)
) as T
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class POCardTokenizationLauncher private constructor(
private val launcher: ActivityResultLauncher<POCardTokenizationConfiguration>,
private val activityOptions: ActivityOptionsCompat,
private val delegate: POCardTokenizationDelegate,
private val eventDispatcher: POEventDispatcher = POEventDispatcher
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance
) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class POCardTokenizationViewComponent private constructor(
private val cardScannerLauncher: POCardScannerLauncher,
private val delegate: POCardTokenizationDelegate,
private val callback: (ProcessOutResult<POCard>) -> Unit,
private val eventDispatcher: POEventDispatcher = POEventDispatcher
private val eventDispatcher: POEventDispatcher
) {

private val scope = lifecycleOwner.lifecycleScope
Expand All @@ -78,10 +78,12 @@ class POCardTokenizationViewComponent private constructor(
callback: (ProcessOutResult<POCard>) -> Unit
): POCardTokenizationViewComponent {
val configuration = configuration.map()
val eventDispatcher = POEventDispatcher()
val viewModel: CardTokenizationViewModel by from.viewModels {
CardTokenizationViewModel.Factory(
app = from.requireActivity().application,
configuration = configuration
configuration = configuration,
eventDispatcher = eventDispatcher
)
}
return POCardTokenizationViewComponent(
Expand All @@ -100,7 +102,8 @@ class POCardTokenizationViewComponent private constructor(
}
),
delegate = delegate,
callback = callback
callback = callback,
eventDispatcher = eventDispatcher
)
}

Expand All @@ -115,10 +118,12 @@ class POCardTokenizationViewComponent private constructor(
callback: (ProcessOutResult<POCard>) -> Unit
): POCardTokenizationViewComponent {
val configuration = configuration.map()
val eventDispatcher = POEventDispatcher()
val viewModel: CardTokenizationViewModel by from.viewModels {
CardTokenizationViewModel.Factory(
app = from.application,
configuration = configuration
configuration = configuration,
eventDispatcher = eventDispatcher
)
}
return POCardTokenizationViewComponent(
Expand All @@ -137,7 +142,8 @@ class POCardTokenizationViewComponent private constructor(
}
),
delegate = delegate,
callback = callback
callback = callback,
eventDispatcher = eventDispatcher
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal class CardUpdateViewModel private constructor(
app = app,
configuration = configuration,
cardsRepository = ProcessOut.instance.cards,
eventDispatcher = POEventDispatcher,
eventDispatcher = POEventDispatcher.instance,
logAttributes = mapOf(POLogAttribute.CARD_ID to configuration.cardId)
) as T
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class POCardUpdateLauncher private constructor(
private val launcher: ActivityResultLauncher<POCardUpdateConfiguration>,
private val activityOptions: ActivityOptionsCompat,
private val delegate: POCardUpdateDelegate,
private val eventDispatcher: POEventDispatcher = POEventDispatcher
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance
) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal class DynamicCheckoutInteractor(
private val googlePayService: POGooglePayService,
private val cardTokenization: CardTokenizationViewModel,
private val nativeAlternativePayment: NativeAlternativePaymentViewModel,
private val eventDispatcher: POEventDispatcher = POEventDispatcher,
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance,
private var logAttributes: Map<String, String> = logAttributes(
invoiceId = configuration.invoiceRequest.invoiceId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.lifecycle.lifecycleScope
import com.processout.sdk.R
import com.processout.sdk.api.dispatcher.POEventDispatcher
import com.processout.sdk.api.model.event.POCardTokenizationEvent
import com.processout.sdk.api.model.request.*
import com.processout.sdk.api.model.request.POCardTokenizationPreferredSchemeRequest
import com.processout.sdk.api.model.response.toResponse
import com.processout.sdk.api.service.PO3DSService
import com.processout.sdk.api.service.proxy3ds.POProxy3DSServiceRequest
Expand All @@ -24,7 +24,8 @@ import com.processout.sdk.ui.checkout.delegate.*
import com.processout.sdk.ui.core.annotation.ProcessOutInternalApi
import com.processout.sdk.ui.napm.delegate.PONativeAlternativePaymentEvent
import com.processout.sdk.ui.savedpaymentmethods.delegate.POSavedPaymentMethodsEvent
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

/**
* Launcher that starts [PODynamicCheckoutActivity] and provides the result.
Expand All @@ -37,7 +38,7 @@ class PODynamicCheckoutLauncher private constructor(
private val activityOptions: ActivityOptionsCompat,
private val threeDSService: PO3DSService,
private val delegate: PODynamicCheckoutDelegate,
private val eventDispatcher: POEventDispatcher = POEventDispatcher
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance
) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal class NativeAlternativePaymentInteractor(
private val barcodeBitmapProvider: BarcodeBitmapProvider,
private val mediaStorageProvider: MediaStorageProvider,
private val captureRetryStrategy: PORetryStrategy,
private val eventDispatcher: POEventDispatcher = POEventDispatcher,
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance,
private var logAttributes: Map<String, String> = logAttributes(configuration.flow)
) : BaseInteractor() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PONativeAlternativePaymentLauncher private constructor(
private val launcher: ActivityResultLauncher<PONativeAlternativePaymentConfiguration>,
private val activityOptions: ActivityOptionsCompat,
private val delegate: PONativeAlternativePaymentDelegate,
private val eventDispatcher: POEventDispatcher = POEventDispatcher
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance
) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class POSavedPaymentMethodsLauncher private constructor(
private val launcher: ActivityResultLauncher<POSavedPaymentMethodsConfiguration>,
private val activityOptions: ActivityOptionsCompat,
private val delegate: POSavedPaymentMethodsDelegate,
private val eventDispatcher: POEventDispatcher = POEventDispatcher
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance
) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal class SavedPaymentMethodsInteractor(
private val configuration: POSavedPaymentMethodsConfiguration,
private val invoicesService: POInvoicesService,
private val customerTokensService: POCustomerTokensService,
private val eventDispatcher: POEventDispatcher = POEventDispatcher,
private val eventDispatcher: POEventDispatcher = POEventDispatcher.instance,
private var logAttributes: Map<String, String> = logAttributes(
invoiceId = configuration.invoiceRequest.invoiceId
)
Expand Down