Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-02 04:30:38 -07:00
parent 6a7391fd73
commit bfeea010d0
12 changed files with 92 additions and 8 deletions

View file

@ -84,15 +84,20 @@ internal class DefaultTangemPayEligibilityManager @Inject constructor(
}
private suspend fun getPossibleWalletsForTangemPay(entryPoint: TangemPayEntryPoint?): List<UserWallet> {
val wallets = userWalletsListRepository.userWallets.value ?: return emptyList()
val candidates = wallets.filter { wallet ->
wallet.isMultiCurrency && !wallet.isLocked && wallet.isCompatible() &&
!onboardingRepository.isTangemPayDeactivated(wallet.walletId)
}
if (candidates.isEmpty()) return emptyList()
if (!checkTangemPayEligibility(entryPoint = entryPoint)) {
return emptyList()
}
val wallets = userWalletsListRepository.userWallets.value ?: return emptyList()
return wallets.filter { wallet ->
wallet.isMultiCurrency && !wallet.isLocked && wallet.isCompatible()
}
return candidates
}
private fun UserWallet.isCompatible(): Boolean = when (this) {

View file

@ -52,6 +52,16 @@ internal class DefaultPaymentAccountStatusFetcher @Inject constructor(
)
}
if (onboardingRepository.isTangemPayDeactivated(params.userWalletId)) {
return@catchOn paymentAccountStatusesStore.store(
userWalletId = params.userWalletId,
status = AccountStatus.Payment(
account = account,
value = PaymentAccountStatusValue.NotCreated,
),
)
}
val status = onboardingRepository.hasTangemPayInWallet(userWalletId = params.userWalletId)
.fold(
ifLeft = { error ->
@ -236,6 +246,7 @@ internal class DefaultPaymentAccountStatusFetcher @Inject constructor(
return when (this) {
is VisaApiError.RefreshTokenExpired -> PaymentAccountStatusValue.Error.NotSynced
is VisaApiError.NotPaeraCustomer -> PaymentAccountStatusValue.NotCreated
is VisaApiError.Deactivated -> PaymentAccountStatusValue.NotCreated
else -> PaymentAccountStatusValue.Error.Unavailable
}
}

View file

@ -1,6 +1,8 @@
package com.tangem.data.pay.repository
import arrow.core.Either
import arrow.core.flatMap
import arrow.core.left
import arrow.core.right
import com.tangem.core.analytics.api.AnalyticsEventHandler
import com.tangem.datasource.api.pay.TangemPayApi
@ -88,7 +90,22 @@ internal class DefaultOnboardingRepository @Inject constructor(
override suspend fun getCustomerInfo(userWalletId: UserWalletId): Either<VisaApiError, CustomerInfo> {
return requestHelper.performRequest(userWalletId) { authHeader -> tangemPayApi.getCustomerMe(authHeader) }
.map { response -> getCustomerInfo(userWalletId = userWalletId, response = response.result) }
.flatMap { response ->
val result = response.result
val status = result?.productInstance?.status
val isDeactivated = status == CustomerMeResponse.ProductInstance.Status.DEACTIVATED
val isBlocked = result?.state?.let { CustomerInfo.State.fromString(it) } == CustomerInfo.State.BLOCKED
if (isDeactivated || isBlocked) {
tangemPayStorage.storeIsTangemPayDeactivated(userWalletId)
VisaApiError.Deactivated.left()
} else {
getCustomerInfo(userWalletId = userWalletId, response = result).right()
}
}
}
override suspend fun isTangemPayDeactivated(userWalletId: UserWalletId): Boolean {
return tangemPayStorage.isTangemPayDeactivated(userWalletId)
}
override suspend fun clearOrderId(userWalletId: UserWalletId) {