Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-02 19:38:44 +07:00
parent 09c5d0f4bc
commit c925d7cf61
3 changed files with 15 additions and 2 deletions

View file

@ -24,7 +24,7 @@ data class OrderResponse(
data class Data(
@Json(name = "type") val type: String?,
@Json(name = "specification_name") val specificationName: String?,
@Json(name = "customer_wallet_address") val customerWalletAddress: String,
@Json(name = "customer_wallet_address") val customerWalletAddress: String?,
@Json(name = "emboss_name") val embossName: String?,
@Json(name = "product_instance_id") val productInstanceId: String?,
@Json(name = "payment_account_id") val paymentAccountId: String?,

View file

@ -115,7 +115,8 @@ internal class DefaultOnboardingRepository @Inject constructor(
tangemPayApi.createOrder(authHeader, body = OrderRequest(walletAddress))
}.result ?: error("Create order result is null")
tangemPayStorage.storeOrderId(result.data.customerWalletAddress, result.id)
val customerWalletAddress = requireNotNull(result.data.customerWalletAddress)
tangemPayStorage.storeOrderId(customerWalletAddress, result.id)
}
}
}

View file

@ -211,6 +211,7 @@ internal class DefaultTangemPayCardDetailsRepository @Inject constructor(
if (pollingJobs.containsKey(orderId)) return
val pollingJob = pollingScope.launch {
try {
var retryCount = 0
while (isActive && pollingJobs.containsKey(orderId)) {
delay(duration = 5.seconds)
@ -235,7 +236,14 @@ internal class DefaultTangemPayCardDetailsRepository @Inject constructor(
cardFrozenStateStore.store(cardId, finalState)
}
}.onLeft { error ->
Timber.e("error ${error.errorCode}")
// stop retrying after 3 errors
if (retryCount > MAX_POLLING_RETRIES) {
pollingJobs.remove(key = orderId)
}
}
retryCount++
}
} catch (e: Exception) {
Timber.e(e)
@ -268,4 +276,8 @@ internal class DefaultTangemPayCardDetailsRepository @Inject constructor(
ApiEnvironment.PROD -> visaLibLoader.getOrCreateConfig().rainRSAPublicKey.prod
}
}
private companion object {
const val MAX_POLLING_RETRIES = 3
}
}