Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-07 03:05:46 -07:00
parent e3868e3ecd
commit 576332d67d
24 changed files with 250 additions and 17 deletions

View file

@ -14,6 +14,18 @@ internal object TangemPayTariffPlanConverter {
name = name,
descriptionItems = value.descriptionItems.orEmpty().mapNotNull(::convertDescriptionItem),
images = value.images.orEmpty().mapNotNull(::convertImage),
fees = value.fees.orEmpty().mapNotNull(::convertFee),
)
}
private fun convertFee(fee: CustomerMeResponse.Fee): TangemPayTariffPlan.Fee? {
val amount = fee.amount ?: return null
return TangemPayTariffPlan.Fee(
type = TangemPayTariffPlan.Fee.Type.fromString(fee.type),
amount = amount,
currency = fee.currency.orEmpty(),
description = fee.description.orEmpty(),
period = fee.period?.let(TangemPayTariffPlan.Fee.Period::fromString),
)
}

View file

@ -139,6 +139,17 @@ internal interface TangemPayDataModule {
return GetTangemPayTariffPlanTransitionsUseCase(repository)
}
@Provides
fun provideGetTangemPayTariffPlanStateUseCase(
customerOrderRepository: CustomerOrderRepository,
getTangemPayTariffPlanTransitionsUseCase: GetTangemPayTariffPlanTransitionsUseCase,
): GetTangemPayTariffPlanStateUseCase {
return GetTangemPayTariffPlanStateUseCase(
customerOrderRepository = customerOrderRepository,
getTariffPlanTransitions = getTangemPayTariffPlanTransitionsUseCase,
)
}
@Provides
@Singleton
fun providePaymentAccountStatusesStore(

View file

@ -17,6 +17,7 @@ import com.tangem.domain.pay.model.CustomerInfo.ProductInstance.SpecificationDat
import com.tangem.domain.pay.model.OrderData
import com.tangem.domain.pay.model.OrderStatus
import com.tangem.domain.pay.model.TangemPayEntryPoint
import com.tangem.domain.pay.usecase.GetTangemPayTariffPlanStateUseCase
import com.tangem.domain.pay.repository.*
import com.tangem.domain.quotes.single.SingleQuoteStatusProducer
import com.tangem.domain.quotes.single.SingleQuoteStatusSupplier
@ -63,6 +64,7 @@ internal class DefaultPaymentAccountStatusFetcher @Inject constructor(
private val cardDetailsRepository: TangemPayCardDetailsRepository,
private val issueCardRepository: TangemPayIssueCardRepository,
private val virtualAccountFeatureToggles: VirtualAccountFeatureToggles,
private val getTangemPayTariffPlanStateUseCase: GetTangemPayTariffPlanStateUseCase,
) : PaymentAccountStatusFetcher {
private val logger = TangemLogger.withTag(TAG)
@ -395,7 +397,12 @@ internal class DefaultPaymentAccountStatusFetcher @Inject constructor(
),
error = null,
virtualAccount = virtualAccount,
tariffPlan = tariffPlan,
tariffPlan = tariffPlan?.let { tariff ->
getTangemPayTariffPlanStateUseCase(
userWalletId = userWalletId,
tariff = tariff,
)
},
)
}

View file

@ -5,6 +5,7 @@ import com.tangem.data.pay.util.OrderConverter
import com.tangem.data.pay.util.OrderStatusConverter
import com.tangem.datasource.api.pay.TangemPayApi
import com.tangem.datasource.api.pay.models.request.OrderRequest
import com.tangem.domain.models.account.TangemPayTariffPlanTransition
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.pay.model.Order
import com.tangem.domain.pay.model.OrderData
@ -53,8 +54,10 @@ internal class DefaultCustomerOrderRepository @Inject constructor(
override suspend fun createOrder(
userWalletId: UserWalletId,
type: OrderType,
specificationName: String,
specificationName: String?,
idempotencyKey: String,
targetTariffPlanId: String?,
transitionType: TangemPayTariffPlanTransition.Type?,
): Either<VisaApiError, Order> {
val walletAddress = requestHelper.getCustomerWalletAddress(userWalletId)
return requestHelper.performRequest(userWalletId) { authHeader ->
@ -65,6 +68,8 @@ internal class DefaultCustomerOrderRepository @Inject constructor(
customerWalletAddress = walletAddress,
specificationName = specificationName,
type = type.wireValue,
targetTariffPlanId = targetTariffPlanId,
tariffPlanTransitionType = transitionType?.name,
),
idempotencyKey = idempotencyKey,
),

View file

@ -29,6 +29,7 @@ import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.pay.datasource.TangemPayAuthDataSource
import com.tangem.domain.pay.model.CustomerInfo
import com.tangem.domain.pay.model.OrderType
import com.tangem.domain.pay.repository.OnboardingRepository
import com.tangem.domain.tangempay.TangemPayAnalyticsEvents
import com.tangem.domain.visa.error.VisaApiError
@ -161,7 +162,11 @@ internal class DefaultOnboardingRepository @Inject constructor(
val walletAddress = requestHelper.getCustomerWalletAddress(userWalletId)
requestHelper.performRequest(userWalletId) { authHeader ->
val data = OrderRequest.Data(customerWalletAddress = walletAddress)
val data = OrderRequest.Data(
customerWalletAddress = walletAddress,
specificationName = "SP_000004",
type = OrderType.CARD_ISSUE_VIRTUAL_RAIN_KYC.wireValue,
)
tangemPayApi.createOrder(
authHeader = authHeader,
body = OrderRequest(data = data, idempotencyKey = UUID.randomUUID().toString()),

View file

@ -2,6 +2,7 @@ package com.tangem.data.pay.util
import com.tangem.datasource.api.pay.models.response.OrderResponse
import com.tangem.domain.pay.model.Order
import com.tangem.domain.pay.model.OrderStep
import com.tangem.domain.pay.model.OrderType
/** Maps a wire `OrderResponse.Result` into the domain [Order] model. */
@ -15,11 +16,12 @@ internal object OrderConverter {
customerId = value.customerId,
type = type,
status = status,
step = value.step,
step = OrderStep.fromString(value.step),
stepChangeCode = value.stepChangeCode,
productInstanceId = value.data.productInstanceId,
paymentAccountId = value.data.paymentAccountId,
cardId = null, // Card id not in v1 response shape; resolved via productInstanceId.
toTariffPlanId = value.data.targetTariffPlanId,
withdrawTxHash = value.data.transactionHash?.ifEmpty { null },
createdAt = value.createdAt,
updatedAt = value.updatedAt,

View file

@ -19,6 +19,7 @@ import com.tangem.domain.pay.TangemPayEligibilityManager
import com.tangem.domain.pay.flow.PaymentAccountStatusFetcher
import com.tangem.domain.pay.model.CustomerInfo
import com.tangem.domain.pay.repository.*
import com.tangem.domain.pay.usecase.GetTangemPayTariffPlanStateUseCase
import com.tangem.domain.quotes.single.SingleQuoteStatusSupplier
import com.tangem.domain.visa.error.VisaApiError
import com.tangem.features.virtualaccount.VirtualAccountFeatureToggles
@ -48,6 +49,7 @@ internal class DefaultPaymentAccountStatusFetcherTest {
private val cardDetailsRepository: TangemPayCardDetailsRepository = mockk()
private val issueCardRepository: TangemPayIssueCardRepository = mockk()
private val virtualAccountFeatureToggles: VirtualAccountFeatureToggles = mockk()
private val getTangemPayTariffPlanStateUseCase: GetTangemPayTariffPlanStateUseCase = mockk()
private val fetcher = DefaultPaymentAccountStatusFetcher(
paymentAccountStatusesStore = paymentAccountStatusesStore,
@ -63,6 +65,7 @@ internal class DefaultPaymentAccountStatusFetcherTest {
cardDetailsRepository = cardDetailsRepository,
issueCardRepository = issueCardRepository,
virtualAccountFeatureToggles = virtualAccountFeatureToggles,
getTangemPayTariffPlanStateUseCase = getTangemPayTariffPlanStateUseCase,
)
private val userWalletId = UserWalletId("011")