TP-74818 | remove lite-sync call after send money (#11889)
This commit is contained in:
@@ -290,7 +290,7 @@ constructor(
|
||||
lrn = liteAccount.lrn,
|
||||
linkedAccountEntity = linkedAccountEntity
|
||||
)
|
||||
checkIfClIsBoundUpdateBalance(linkedAccountEntity = linkedAccountEntity)
|
||||
checkIfClIsBoundUpdateBalance(accountId = linkedAccountEntity.accountId)
|
||||
} else {
|
||||
naviPayAnalytics.onDevGenericEvent(
|
||||
event = "Sync_CL_For_Upi_Lite_Failed",
|
||||
@@ -307,7 +307,7 @@ constructor(
|
||||
event = "Sync_CL_For_Upi_Lite_Bound_False",
|
||||
params = mapOf("func" to ::syncClForUpiLite.name)
|
||||
)
|
||||
checkIfClIsBoundUpdateBalance(linkedAccountEntity = linkedAccountEntity)
|
||||
checkIfClIsBoundUpdateBalance(accountId = linkedAccountEntity.accountId)
|
||||
isProcessRunning.set(false)
|
||||
}
|
||||
}
|
||||
@@ -411,7 +411,7 @@ constructor(
|
||||
event = "Initial_TopUp_Success",
|
||||
params = mapOf("func" to ::handleTerminalStateOfInitialTopUp.name)
|
||||
)
|
||||
checkIfClIsBoundUpdateBalance(linkedAccountEntity = linkedAccountEntity)
|
||||
checkIfClIsBoundUpdateBalance(accountId = linkedAccountEntity.accountId)
|
||||
}
|
||||
else -> { // Failed case
|
||||
accountRepository.updateLiteAccountStatusAndInitialTopUpStatusByAccountIdAndLrn(
|
||||
@@ -509,7 +509,7 @@ constructor(
|
||||
event = "Lite_Deregistration_Failed",
|
||||
params = mapOf("func" to ::handleTerminalStateOfLiteDeregistration.name)
|
||||
)
|
||||
checkIfClIsBoundUpdateBalance(linkedAccountEntity = linkedAccountEntity)
|
||||
checkIfClIsBoundUpdateBalance(accountId = linkedAccountEntity.accountId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -611,22 +611,20 @@ constructor(
|
||||
xmlPayLoad = liteRegistrationResponse.data!!.xmlPayload,
|
||||
accountId = selectedBankAccount.accountId
|
||||
)
|
||||
checkIfClIsBoundUpdateBalance(linkedAccountEntity = selectedBankAccount)
|
||||
checkIfClIsBoundUpdateBalance(accountId = selectedBankAccount.accountId)
|
||||
}
|
||||
isProcessRunning.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun checkIfClIsBoundUpdateBalance(linkedAccountEntity: LinkedAccountEntity) {
|
||||
val upiLiteBoundStatus =
|
||||
upiLiteClHelper.checkUpiLiteBoundStatus(accountId = linkedAccountEntity.accountId)
|
||||
suspend fun checkIfClIsBoundUpdateBalance(accountId: String) {
|
||||
val upiLiteBoundStatus = upiLiteClHelper.checkUpiLiteBoundStatus(accountId = accountId)
|
||||
|
||||
if (
|
||||
upiLiteBoundStatus.status == UpiLiteBoundStatus.BOUND.name &&
|
||||
upiLiteBoundStatus.syncRequired == "false"
|
||||
) {
|
||||
val balance =
|
||||
upiLiteClHelper.getUpiLiteBalance(accountId = linkedAccountEntity.accountId)
|
||||
val balance = upiLiteClHelper.getUpiLiteBalance(accountId = accountId)
|
||||
|
||||
val liteAccountInfoFromSharedPrefString =
|
||||
sharedPreferenceRepository.getStringValueOnSameThread(
|
||||
@@ -643,7 +641,7 @@ constructor(
|
||||
"balance" to balance,
|
||||
"liteAccountInfoFromSharedPrefString" to
|
||||
liteAccountInfoFromSharedPrefString,
|
||||
"linkedAccountEntity" to linkedAccountEntity.accountId
|
||||
"linkedAccountEntity" to accountId
|
||||
)
|
||||
)
|
||||
val gson = Gson()
|
||||
@@ -652,7 +650,7 @@ constructor(
|
||||
value =
|
||||
gson.toJson(
|
||||
UpiLiteActiveAccountInfo(
|
||||
accountId = linkedAccountEntity.accountId,
|
||||
accountId = accountId,
|
||||
balance = balance.getFormattedAmountWithDecimal(),
|
||||
isClBound = true
|
||||
)
|
||||
|
||||
@@ -2013,7 +2013,7 @@ constructor(
|
||||
|
||||
if (source == SendMoneyScreenSource.PMS) {
|
||||
if (isPaymentThroughLiteAccount) {
|
||||
liteAccountSyncUseCase.execute()
|
||||
syncLiteBalance(arpc = sendMoneyResponse.arpc)
|
||||
naviPayAnalytics.onPaymentCompleted(
|
||||
source = source,
|
||||
transactionType = transactionType,
|
||||
@@ -2067,7 +2067,7 @@ constructor(
|
||||
event = ::processPaymentSuccess.name,
|
||||
params = mapOf("isPaymentThroughLite" to "true")
|
||||
)
|
||||
liteAccountSyncUseCase.execute()
|
||||
syncLiteBalance(arpc = sendMoneyResponse.arpc)
|
||||
}
|
||||
val upiLiteBalance = upiLiteBalanceUseCase.execute()
|
||||
updateScreenState(
|
||||
@@ -2085,6 +2085,22 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun syncLiteBalance(arpc: String?) {
|
||||
if (arpc.isNullOrBlank()) {
|
||||
liteAccountSyncUseCase.execute()
|
||||
return
|
||||
}
|
||||
val accountId =
|
||||
getBankAccountUniqueId(buid = selectedBankAccount.value?.accountId.orEmpty())
|
||||
val isClSyncSuccessful =
|
||||
upiLiteClHelper.registerUpiLiteState(accountId = accountId, riskParams = arpc)
|
||||
if (isClSyncSuccessful) {
|
||||
liteAccountSyncUseCase.checkIfClIsBoundUpdateBalance(accountId = accountId)
|
||||
} else { // fallback, in-case lite doesn't get sync with arpc from send money response
|
||||
liteAccountSyncUseCase.execute()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun processPaymentFailure(
|
||||
response: RepoResult<TransactionResponse>,
|
||||
accountId: String,
|
||||
@@ -2095,7 +2111,7 @@ constructor(
|
||||
) {
|
||||
if (source == SendMoneyScreenSource.PMS) {
|
||||
if (isPaymentThroughLite) {
|
||||
liteAccountSyncUseCase.execute()
|
||||
syncLiteBalance(arpc = response.data?.arpc)
|
||||
val errorConfig = getError(response, false)
|
||||
naviPayAnalytics.onPaymentCompleted(
|
||||
source = source,
|
||||
@@ -2122,7 +2138,7 @@ constructor(
|
||||
event = ::processPaymentFailure.name,
|
||||
params = mapOf("isPaymentThroughLite" to "true")
|
||||
)
|
||||
liteAccountSyncUseCase.execute()
|
||||
syncLiteBalance(arpc = response.data?.arpc)
|
||||
}
|
||||
|
||||
processValidateVpaCacheForFailedTransaction(vpa = payeeVpa, response = response)
|
||||
|
||||
Reference in New Issue
Block a user