From fe3b35379b9d0a4b274ffb332445eb0f963d1a57 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 2 Dec 2025 19:55:36 +0700 Subject: [PATCH] Updated on 2026-08-14 --- .../tangem/data/pay/di/TangemPayDataModule.kt | 2 ++ .../TangemPayMainScreenCustomerInfoUseCase.kt | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/di/TangemPayDataModule.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/di/TangemPayDataModule.kt index 7ebe23b51d..49bc15d0db 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/pay/di/TangemPayDataModule.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/di/TangemPayDataModule.kt @@ -66,10 +66,12 @@ internal interface TangemPayDataModule { fun provideTangemPayMainScreenCustomerInfoUseCase( repository: OnboardingRepository, customerOrderRepository: CustomerOrderRepository, + tangemPayOnboardingRepository: OnboardingRepository, ): TangemPayMainScreenCustomerInfoUseCase { return TangemPayMainScreenCustomerInfoUseCase( repository = repository, customerOrderRepository = customerOrderRepository, + tangemPayOnboardingRepository = tangemPayOnboardingRepository, ) } diff --git a/domain/visa/src/main/kotlin/com/tangem/domain/pay/usecase/TangemPayMainScreenCustomerInfoUseCase.kt b/domain/visa/src/main/kotlin/com/tangem/domain/pay/usecase/TangemPayMainScreenCustomerInfoUseCase.kt index 2629eb6fa3..bc5924b911 100644 --- a/domain/visa/src/main/kotlin/com/tangem/domain/pay/usecase/TangemPayMainScreenCustomerInfoUseCase.kt +++ b/domain/visa/src/main/kotlin/com/tangem/domain/pay/usecase/TangemPayMainScreenCustomerInfoUseCase.kt @@ -23,16 +23,22 @@ private const val TAG = "TangemPayMainScreenCustomerInfoUseCase" class TangemPayMainScreenCustomerInfoUseCase( private val repository: OnboardingRepository, private val customerOrderRepository: CustomerOrderRepository, + private val tangemPayOnboardingRepository: OnboardingRepository, ) { suspend operator fun invoke( userWalletId: UserWalletId, ): Either = catch( block = { + Timber.tag(TAG).d("checkCustomerWallet") repository.checkCustomerWallet(userWalletId) .fold( - ifLeft = { TangemPayCustomerInfoError.UnknownError.left() }, + ifLeft = { error -> + Timber.tag(TAG).e("Failed to check customer wallet ${error.javaClass.simpleName}") + TangemPayCustomerInfoError.UnknownError.left() + }, ifRight = { hasTangemPay -> + Timber.tag(TAG).i("checkCustomerWallet $hasTangemPay") if (hasTangemPay) { proceedWithPaeraCustomerResult(userWalletId) } else { @@ -50,6 +56,9 @@ class TangemPayMainScreenCustomerInfoUseCase( private suspend fun proceedWithPaeraCustomerResult( userWalletId: UserWalletId, ): Either { + if (!tangemPayOnboardingRepository.isTangemPayInitialDataProduced(userWalletId)) { + return TangemPayCustomerInfoError.RefreshNeededError.left() + } val orderId = repository.getOrderId(userWalletId) return if (orderId != null) { proceedWithOrderId(userWalletId = userWalletId, orderId = orderId) @@ -61,9 +70,14 @@ class TangemPayMainScreenCustomerInfoUseCase( private suspend fun proceedWithoutOrder( userWalletId: UserWalletId, ): Either { + Timber.tag(TAG).d("proceedWithoutOrder") return repository.getCustomerInfo(userWalletId) - .mapLeft { error -> error.mapErrorForCustomer() } + .mapLeft { error -> + Timber.tag(TAG).e("mapErrorForCustomer: $error") + error.mapErrorForCustomer() + } .map { customerInfo -> + Timber.tag(TAG).d("customerInfo") if (customerInfo.cardInfo == null && customerInfo.isKycApproved) { // If order id wasn't saved -> start order creation and get customer info repository.createOrder(userWalletId)