Updated on 2026-08-14
This commit is contained in:
parent
6a7391fd73
commit
bfeea010d0
12 changed files with 92 additions and 8 deletions
|
|
@ -57,6 +57,7 @@ sealed class VisaApiError(
|
|||
data object CustomerIsBlocked : VisaApiError(104110210)
|
||||
data object UnknownWithoutCode : VisaApiError(104110999)
|
||||
data class Unknown(override val errorCode: Int) : VisaApiError(errorCode)
|
||||
data object Deactivated : VisaApiError(0)
|
||||
|
||||
fun isUnknown() = this is UnknownWithoutCode || this is Unknown
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,24 @@ data class CustomerInfo(
|
|||
val kycStatus: KycStatus,
|
||||
val cardInfo: CardInfo?,
|
||||
) {
|
||||
enum class State {
|
||||
NEW,
|
||||
ACTIVE,
|
||||
BLOCKED,
|
||||
IN_PROGRESS,
|
||||
UNDEFINED,
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromString(value: String) = when (value.uppercase()) {
|
||||
"NEW" -> NEW
|
||||
"ACTIVE" -> ACTIVE
|
||||
"BLOCKED" -> BLOCKED
|
||||
"IN_PROGRESS" -> IN_PROGRESS
|
||||
else -> UNDEFINED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class ProductInstance(
|
||||
val id: String,
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ sealed interface TangemPayCustomerInfoError {
|
|||
data object RefreshNeededError : TangemPayCustomerInfoError
|
||||
data object UnknownError : TangemPayCustomerInfoError
|
||||
data object ExposedDeviceError : TangemPayCustomerInfoError
|
||||
data object DeactivatedError : TangemPayCustomerInfoError
|
||||
}
|
||||
|
|
@ -35,4 +35,6 @@ interface OnboardingRepository {
|
|||
suspend fun setHideMainOnboardingBanner(userWalletId: UserWalletId)
|
||||
|
||||
suspend fun disableTangemPay(userWalletId: UserWalletId): Either<VisaApiError, Unit>
|
||||
|
||||
suspend fun isTangemPayDeactivated(userWalletId: UserWalletId): Boolean
|
||||
}
|
||||
|
|
@ -29,6 +29,11 @@ class TangemPayMainScreenCustomerInfoUseCase(
|
|||
suspend fun fetch(userWalletId: UserWalletId) {
|
||||
logger.i("fetch: ${userWalletId.stringValue}")
|
||||
|
||||
if (onboardingRepository.isTangemPayDeactivated(userWalletId)) {
|
||||
updateState(userWalletId, MainCustomerInfoContentState.Empty.right())
|
||||
return
|
||||
}
|
||||
|
||||
if (deviceSecurity.isSecurityExposed()) {
|
||||
logger.i("fetch security info: rooted: ${deviceSecurity.isRooted}")
|
||||
logger.i("fetch security info: xposed: ${deviceSecurity.isXposed}")
|
||||
|
|
@ -57,8 +62,11 @@ class TangemPayMainScreenCustomerInfoUseCase(
|
|||
}
|
||||
|
||||
val result = proceedWithPaeraCustomerResult(userWalletId)
|
||||
.map(MainCustomerInfoContentState::Content)
|
||||
updateState(userWalletId, result)
|
||||
if (result.leftOrNull() is TangemPayCustomerInfoError.DeactivatedError) {
|
||||
updateState(userWalletId, MainCustomerInfoContentState.Empty.right())
|
||||
return
|
||||
}
|
||||
updateState(userWalletId, result.map(MainCustomerInfoContentState::Content))
|
||||
} else {
|
||||
// if there's no tangem pay, check eligibility and show onboarding banner
|
||||
showOnboardingBannerIfEligible(userWalletId)
|
||||
|
|
@ -164,6 +172,7 @@ class TangemPayMainScreenCustomerInfoUseCase(
|
|||
return when (this) {
|
||||
is VisaApiError.RefreshTokenExpired -> TangemPayCustomerInfoError.RefreshNeededError
|
||||
is VisaApiError.NotPaeraCustomer -> TangemPayCustomerInfoError.UnknownError
|
||||
is VisaApiError.Deactivated -> TangemPayCustomerInfoError.DeactivatedError
|
||||
else -> TangemPayCustomerInfoError.UnavailableError
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue