Updated on 2026-08-14
This commit is contained in:
parent
09c5d0f4bc
commit
c925d7cf61
3 changed files with 15 additions and 2 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue