Updated on 2026-08-14
This commit is contained in:
parent
46cf9b8b08
commit
210ba5ca59
22 changed files with 303 additions and 90 deletions
|
|
@ -3,7 +3,11 @@ package com.tangem.domain.pay.model
|
|||
import java.math.BigDecimal
|
||||
|
||||
private const val APPROVED_KYC_STATUS = "APPROVED"
|
||||
private const val ACTIVE_PI_STATUS = "active"
|
||||
|
||||
data class MainScreenCustomerInfo(
|
||||
val info: CustomerInfo,
|
||||
val orderStatus: OrderStatus,
|
||||
)
|
||||
|
||||
data class CustomerInfo(
|
||||
val productInstance: ProductInstance?,
|
||||
|
|
@ -23,6 +27,4 @@ data class CustomerInfo(
|
|||
)
|
||||
|
||||
fun isKycApproved() = kycStatus == APPROVED_KYC_STATUS
|
||||
|
||||
fun isProductInstanceActive() = productInstance?.status == ACTIVE_PI_STATUS
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.domain.pay.model
|
||||
|
||||
enum class OrderStatus(val apiName: String) {
|
||||
NOT_ISSUED(""),
|
||||
NEW("NEW"),
|
||||
PROCESSING("PROCESSING"),
|
||||
COMPLETED("COMPLETED"),
|
||||
CANCELED("CANCELED"),
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.domain.pay.repository
|
|||
import arrow.core.Either
|
||||
import com.tangem.core.error.UniversalError
|
||||
import com.tangem.domain.pay.model.CustomerInfo
|
||||
import com.tangem.domain.pay.model.MainScreenCustomerInfo
|
||||
|
||||
interface OnboardingRepository {
|
||||
|
||||
|
|
@ -10,8 +11,10 @@ interface OnboardingRepository {
|
|||
|
||||
suspend fun getCustomerInfo(): Either<UniversalError, CustomerInfo>
|
||||
|
||||
suspend fun createOrder(): Either<UniversalError, Unit>
|
||||
|
||||
/**
|
||||
* Returns only if the user already authorised at least once
|
||||
*/
|
||||
suspend fun getMainScreenCustomerInfo(): Either<UniversalError, CustomerInfo>
|
||||
suspend fun getMainScreenCustomerInfo(): Either<UniversalError, MainScreenCustomerInfo>
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.tangem.domain.pay.usecase
|
||||
|
||||
import com.tangem.domain.pay.repository.OnboardingRepository
|
||||
|
||||
class TangemPayIssueOrderUseCase(
|
||||
private val repository: OnboardingRepository,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(): Unit? = repository.createOrder().getOrNull()
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.domain.pay.usecase
|
||||
|
||||
import com.tangem.domain.pay.model.CustomerInfo
|
||||
import com.tangem.domain.pay.model.MainScreenCustomerInfo
|
||||
import com.tangem.domain.pay.repository.OnboardingRepository
|
||||
|
||||
/**
|
||||
|
|
@ -11,5 +11,5 @@ class TangemPayMainScreenCustomerInfoUseCase(
|
|||
private val repository: OnboardingRepository,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(): CustomerInfo? = repository.getMainScreenCustomerInfo().getOrNull()
|
||||
suspend operator fun invoke(): MainScreenCustomerInfo? = repository.getMainScreenCustomerInfo().getOrNull()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue