From 1bb825744eaa708bb9b97f4f4c363094548ba674 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 4 Feb 2026 21:38:15 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../pay/DefaultTangemPayEligibilityManager.kt | 23 +++++---- .../domain/pay/TangemPayEligibilityManager.kt | 10 ++++ .../model/TangemPayOnboardingModel.kt | 48 ++++++++++--------- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/DefaultTangemPayEligibilityManager.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/DefaultTangemPayEligibilityManager.kt index 106cda734f..c9171fd5f3 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/pay/DefaultTangemPayEligibilityManager.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/DefaultTangemPayEligibilityManager.kt @@ -3,6 +3,7 @@ package com.tangem.data.pay import com.tangem.common.card.FirmwareVersion import com.tangem.domain.common.wallets.UserWalletsListRepository import com.tangem.domain.models.wallet.UserWallet +import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.isLocked import com.tangem.domain.models.wallet.isMultiCurrency import com.tangem.domain.pay.TangemPayEligibilityManager @@ -40,6 +41,12 @@ internal class DefaultTangemPayEligibilityManager @Inject constructor( } } + override suspend fun getPossibleWalletsIds(shouldExcludePaeraCustomers: Boolean): List { + return getPossibleWalletsForTangemPay().addPaeraCustomersData().mapNotNull { + if (!it.isPaeraCustomer || !shouldExcludePaeraCustomers) it.userWallet.walletId else null + } + } + override suspend fun getTangemPayAvailability(): Boolean { return onboardingRepository.checkCustomerEligibility() .also { isEligible -> if (!isEligible) reset() } @@ -58,9 +65,13 @@ internal class DefaultTangemPayEligibilityManager @Inject constructor( coroutineScope { val deferred = async { - getPossibleWalletsForTangemPay() - .addPaeraCustomersData() - .also { cachedEligibleWallets = it } + if (!checkTangemPayEligibility()) { + emptyList() + } else { + getPossibleWalletsForTangemPay() + .addPaeraCustomersData() + .also { cachedEligibleWallets = it } + } } eligibleWalletsDeferred = deferred try { @@ -72,11 +83,7 @@ internal class DefaultTangemPayEligibilityManager @Inject constructor( } } - private suspend fun getPossibleWalletsForTangemPay(): List { - if (!checkTangemPayEligibility()) { - return emptyList() - } - + private fun getPossibleWalletsForTangemPay(): List { val wallets = if (hotWalletFeatureToggles.isHotWalletEnabled) { userWalletsListRepository.userWallets.value } else { diff --git a/domain/visa/src/main/kotlin/com/tangem/domain/pay/TangemPayEligibilityManager.kt b/domain/visa/src/main/kotlin/com/tangem/domain/pay/TangemPayEligibilityManager.kt index 462dbd6e6f..b028029e06 100644 --- a/domain/visa/src/main/kotlin/com/tangem/domain/pay/TangemPayEligibilityManager.kt +++ b/domain/visa/src/main/kotlin/com/tangem/domain/pay/TangemPayEligibilityManager.kt @@ -1,11 +1,21 @@ package com.tangem.domain.pay import com.tangem.domain.models.wallet.UserWallet +import com.tangem.domain.models.wallet.UserWalletId interface TangemPayEligibilityManager { suspend fun getEligibleWallets(shouldExcludePaeraCustomers: Boolean): List + + /** + * Returns all compatible user wallets without checking Tangem Pay eligibility, only used when opening deeplink + * Remove after removing [TangemPayOnboardingComponent.Params.Deeplink] + * */ + suspend fun getPossibleWalletsIds(shouldExcludePaeraCustomers: Boolean): List + suspend fun getTangemPayAvailability(): Boolean + suspend fun isPaeraCustomerForAnyWallet(): Boolean + fun reset() } \ No newline at end of file diff --git a/features/tangempay/onboarding/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayOnboardingModel.kt b/features/tangempay/onboarding/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayOnboardingModel.kt index b8ce2a6fac..d2b0d915e1 100644 --- a/features/tangempay/onboarding/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayOnboardingModel.kt +++ b/features/tangempay/onboarding/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayOnboardingModel.kt @@ -116,37 +116,41 @@ internal class TangemPayOnboardingModel @Inject constructor( private fun onGetCardClick() { analytics.send(TangemPayAnalyticsEvents.GetCardClicked()) - // if user came from deeplink or banner in settings and already is a paera customer -> exclude this wallet - val shouldExcludePaeraCustomers = params is TangemPayOnboardingComponent.Params.FromBannerInSettings || - params is TangemPayOnboardingComponent.Params.Deeplink - modelScope.launch { - val eligibleWalletsIds = eligibilityManager - .getEligibleWallets(shouldExcludePaeraCustomers = shouldExcludePaeraCustomers) - .map { it.walletId } - if (eligibleWalletsIds.isEmpty()) { - back() - return@launch + if (params is TangemPayOnboardingComponent.Params.Deeplink) { + modelScope.launch { + openWalletSelectorIfNeeds( + walletsIds = eligibilityManager.getPossibleWalletsIds(shouldExcludePaeraCustomers = true), + ) } - when (params) { - is TangemPayOnboardingComponent.Params.ContinueOnboarding -> { - checkCustomerInfo(params.userWalletId) + } else { + // if user came from banner in settings and already is a paera customer -> exclude this wallet + val shouldExcludePaeraCustomers = params is TangemPayOnboardingComponent.Params.FromBannerInSettings + modelScope.launch { + val eligibleWalletsIds = eligibilityManager + .getEligibleWallets(shouldExcludePaeraCustomers = shouldExcludePaeraCustomers) + .map { it.walletId } + if (eligibleWalletsIds.isEmpty()) { + back() + return@launch } - is TangemPayOnboardingComponent.Params.FromBannerOnMain, - is TangemPayOnboardingComponent.Params.Deeplink, - is TangemPayOnboardingComponent.Params.FromBannerInSettings, - -> { - openWalletSelectorIfNeeds(eligibleWalletsIds) + when (params) { + is TangemPayOnboardingComponent.Params.ContinueOnboarding -> { + checkCustomerInfo(params.userWalletId) + } + else -> { + openWalletSelectorIfNeeds(eligibleWalletsIds) + } } } } } - private fun openWalletSelectorIfNeeds(eligibleWalletsIds: List) { - if (eligibleWalletsIds.size == 1) { - checkCustomerInfo(userWalletId = eligibleWalletsIds[0]) + private fun openWalletSelectorIfNeeds(walletsIds: List) { + if (walletsIds.size == 1) { + checkCustomerInfo(userWalletId = walletsIds[0]) } else { analytics.send(TangemPayAnalyticsEvents.ChooseWalletPopup()) - bottomSheetNavigation.activate(TangemPayOnboardingNavigation.WalletSelector(eligibleWalletsIds)) + bottomSheetNavigation.activate(TangemPayOnboardingNavigation.WalletSelector(walletsIds)) } }