Updated on 2026-08-14
This commit is contained in:
parent
370d902dad
commit
9efe573323
22 changed files with 360 additions and 39 deletions
|
|
@ -35,6 +35,7 @@ interface OnboardingRepository {
|
|||
suspend fun createVirtualAccountOrder(
|
||||
userWalletId: UserWalletId,
|
||||
paymentAccountAddress: String,
|
||||
idempotencyKey: String,
|
||||
): Either<VisaApiError, String>
|
||||
|
||||
suspend fun getVirtualAccountOrderId(userWalletId: UserWalletId): String?
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.tangem.domain.pay.model.OrderStatus
|
|||
import com.tangem.domain.pay.model.TangemPayOrderInfo
|
||||
import com.tangem.domain.pay.repository.OnboardingRepository
|
||||
import com.tangem.domain.visa.error.VisaApiError
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* Creates the Virtual Account on-ramp order (VA MVP0, TWI-1638) and persists the returned id as `vaOrderId`.
|
||||
|
|
@ -29,6 +30,7 @@ class CreateVirtualAccountOrderUseCase(
|
|||
val vaOrderId = onboardingRepository.createVirtualAccountOrder(
|
||||
userWalletId = userWalletId,
|
||||
paymentAccountAddress = paymentAccountAddress,
|
||||
idempotencyKey = UUID.randomUUID().toString(),
|
||||
).bind()
|
||||
onboardingRepository.storeVirtualAccountOrderId(userWalletId = userWalletId, vaOrderId = vaOrderId)
|
||||
pollingUseCase.invoke(
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ internal class CreateVirtualAccountOrderUseCaseTest {
|
|||
val result = useCase(userWalletId, paymentAccountAddress)
|
||||
|
||||
assertThat(result.isRight()).isTrue()
|
||||
coVerify(exactly = 0) { onboardingRepository.createVirtualAccountOrder(any(), any()) }
|
||||
coVerify(exactly = 0) { onboardingRepository.createVirtualAccountOrder(any(), any(), any()) }
|
||||
coVerify(exactly = 0) { onboardingRepository.storeVirtualAccountOrderId(any(), any()) }
|
||||
coVerify(exactly = 0) { pollingUseCase.invoke(any(), any()) }
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ internal class CreateVirtualAccountOrderUseCaseTest {
|
|||
fun `GIVEN no stored id and create succeeds WHEN invoke THEN stores id and starts polling`() = runTest {
|
||||
coEvery { onboardingRepository.getVirtualAccountOrderId(userWalletId) } returns null
|
||||
coEvery {
|
||||
onboardingRepository.createVirtualAccountOrder(userWalletId, paymentAccountAddress)
|
||||
onboardingRepository.createVirtualAccountOrder(userWalletId, paymentAccountAddress, any())
|
||||
} returns "new-id".right()
|
||||
|
||||
val result = useCase(userWalletId, paymentAccountAddress)
|
||||
|
|
@ -51,7 +51,7 @@ internal class CreateVirtualAccountOrderUseCaseTest {
|
|||
fun `GIVEN no stored id and create fails WHEN invoke THEN returns error and does not store or poll`() = runTest {
|
||||
coEvery { onboardingRepository.getVirtualAccountOrderId(userWalletId) } returns null
|
||||
coEvery {
|
||||
onboardingRepository.createVirtualAccountOrder(userWalletId, paymentAccountAddress)
|
||||
onboardingRepository.createVirtualAccountOrder(userWalletId, paymentAccountAddress, any())
|
||||
} returns VisaApiError.Unspecified.left()
|
||||
|
||||
val result = useCase(userWalletId, paymentAccountAddress)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue