NTP-44548 | UPI LITE - OC error code handling - revert (#16212)

This commit is contained in:
Balrambhai Sharma
2025-05-16 14:38:43 +05:30
committed by GitHub
parent bbcd38c9ea
commit a0d7e22a71
4 changed files with 8 additions and 112 deletions

View File

@@ -43,7 +43,6 @@ import com.navi.pay.onboarding.account.common.repository.AccountsRepository
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
import com.navi.pay.onboarding.binding.model.view.NaviPayCustomerOnboardingEntity
import com.navi.pay.utils.KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO
import com.navi.pay.utils.LRN_MISMATCH_ERROR
import com.navi.pay.utils.UPI_LITE_DEREGISTRATION
import com.navi.pay.utils.UPI_LITE_TOPUP
import com.navi.pay.utils.getFormattedAmountWithDecimal
@@ -73,7 +72,6 @@ constructor(
private val naviCacheRepository: NaviCacheRepository,
private val naviPayCustomerStatusHandler: NaviPayCustomerStatusHandler,
private val upiRequestIdUseCase: UpiRequestIdUseCase,
private val accountsRepository: AccountsRepository,
) {
private val INITIAL_TOPUP_POLLING_INTERVAL = 5.seconds
@@ -629,7 +627,6 @@ constructor(
selectedBankAccount = linkedAccountEntity,
lrn = lrn,
customerOnboardingEntity = customerOnboardingEntity,
pspType = pspType,
)
}
else -> {}
@@ -642,7 +639,6 @@ constructor(
selectedBankAccount: LinkedAccountEntity,
lrn: String?,
customerOnboardingEntity: NaviPayCustomerOnboardingEntity,
pspType: PspType,
) {
naviPayAnalytics.onDevGenericEvent(
event = "LiteAccountSyncUseCase_onClSuccessCallback",
@@ -671,46 +667,11 @@ constructor(
)
if (liteRegistrationResponse.isSuccessWithData()) {
val isLrnDifferentFromRemoteLrn =
!lrn.isNullOrBlank() && lrn != liteRegistrationResponse.data?.lrn
if (isLrnDifferentFromRemoteLrn) {
/**
* If the local lrn differs from the network LRN, mark the local lrn as DEREGISTERED
* in the database and mark network lrn as PENDING_ACTIVATION.
*/
naviPayAnalytics.onDevGenericEvent(
event = LRN_MISMATCH_ERROR,
params =
mapOf(
"localLrn" to lrn.orEmpty(),
"remoteLrn" to liteRegistrationResponse.data?.lrn.orEmpty(),
"func" to "LiteAccountSyncUseCase.execute()",
),
)
accountsRepository.updateLiteAccountStatusByAccountIdAndLrn(
upiLiteAccountStatus = UPILiteAccountStatus.DEREGISTERED,
accountId = selectedBankAccount.accountId,
lrn = lrn.orEmpty(),
upiRequestId = upiRequestId,
)
accountsRepository.updateLiteInfoListAfterRegistrationByAccountIdAndStatus(
lrn = liteRegistrationResponse.data?.lrn.orEmpty(),
upiLiteAccountStatus = UPILiteAccountStatus.PENDING_ACTIVATION,
initialTopUpStatus = InitialTopUpStatus.NOT_INITIATED,
lastUpdatedOn = getDateTimeStringWithYearOffset(),
accountId = selectedBankAccount.accountId,
rotation = liteRegistrationResponse.data?.rotation.orEmpty(),
deviceId = deviceInfoProvider.getDeviceData().deviceId,
pspType = pspType,
)
naviCacheRepository.clear(KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO)
} else {
upiLiteClHelper.registerUpiLiteWithCl(
xmlPayLoad = liteRegistrationResponse.data!!.xmlPayload,
buid = buid,
)
checkIfClIsBoundUpdateBalance(buid = buid)
}
upiLiteClHelper.registerUpiLiteWithCl(
xmlPayLoad = liteRegistrationResponse.data!!.xmlPayload,
buid = buid,
)
checkIfClIsBoundUpdateBalance(buid = buid)
}
}

View File

@@ -155,7 +155,6 @@ import com.navi.pay.utils.DEFAULT_UPI_MODE
import com.navi.pay.utils.KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO
import com.navi.pay.utils.KEY_UPI_LITE_MANDATE_INFO
import com.navi.pay.utils.LITE_MANDATE
import com.navi.pay.utils.LRN_MISMATCH_ERROR
import com.navi.pay.utils.MONEY_ADDED_TO_UPI_LITE
import com.navi.pay.utils.NAVI_PAY_DEFAULT_MCC
import com.navi.pay.utils.NAVI_PAY_PURPLE_CTA_LOADER_LOTTIE
@@ -3009,9 +3008,9 @@ constructor(
}
processLiteRegistrationResponse(
localLrn = lrn.orEmpty(),
linkedAccountEntity = linkedAccountEntity,
liteRegistrationResponse = liteRegistrationResponse.data!!,
lrn = lrn,
upiRequestId = upiRequestId,
shouldAutoInitTopUp = shouldAutoInitTopUp,
initCreateAndExecuteMandate = initCreateAndExecuteMandate,
@@ -3053,42 +3052,14 @@ constructor(
}
private suspend fun processLiteRegistrationResponse(
localLrn: String,
linkedAccountEntity: LinkedAccountEntity,
liteRegistrationResponse: LiteRegistrationResponse,
lrn: String?,
upiRequestId: String,
shouldAutoInitTopUp: Boolean,
initCreateAndExecuteMandate: Boolean,
pspType: PspType,
) {
/**
* If the local lrn differs from the network LRN, mark the local lrn as DEREGISTERED in the
* database.
*/
if (localLrn.isNotBlank() && localLrn != liteRegistrationResponse.lrn) {
naviPayAnalytics.onDevGenericEvent(
event = LRN_MISMATCH_ERROR,
params =
mapOf(
"localLrn" to localLrn,
"remoteLrn" to liteRegistrationResponse.lrn,
"func" to "UpiLiteViewmodel.processLiteRegistrationResponse()",
),
)
accountsRepository.updateLiteAccountStatusByAccountIdAndLrn(
upiLiteAccountStatus = UPILiteAccountStatus.DEREGISTERED,
accountId = linkedAccountEntity.accountId,
lrn = localLrn,
upiRequestId = upiRequestId,
)
handleRegistrationFailedCase(
liteRegistrationResponse = liteRegistrationResponse,
linkedAccountEntity = linkedAccountEntity,
pspType = pspType,
)
return
}
val clRegistration =
upiLiteClHelper.registerUpiLiteWithCl(
xmlPayLoad = liteRegistrationResponse.xmlPayload,
@@ -3107,7 +3078,7 @@ constructor(
// Lite registration is successful
handleRegistrationSuccessCase(
linkedAccountEntity = linkedAccountEntity,
lrn = liteRegistrationResponse.lrn,
lrn = lrn,
liteRegistrationResponse = liteRegistrationResponse,
upiRequestId = upiRequestId,
initCreateAndExecuteMandate = initCreateAndExecuteMandate,

View File

@@ -181,39 +181,6 @@ constructor(
}
}
suspend fun updateLiteAccountStatusByAccountIdAndLrn(
upiLiteAccountStatus: UPILiteAccountStatus,
accountId: String,
lrn: String,
upiRequestId: String?,
) {
val activeAccountsForAccountId =
accountDao.getAccountByAccountIdAndStatus(
accountId = accountId,
status = AccountStatus.ACTIVE,
)
val upiLiteInfoList = activeAccountsForAccountId.upiLiteInfo.toMutableList()
// Updating the account status for the lrn
upiLiteInfoList
.indexOfFirst { it.lrn == lrn }
.let {
if (it != -1) {
upiLiteInfoList[it] =
upiLiteInfoList[it].copy(
accountStatus = upiLiteAccountStatus,
initialTopUpUpiRequestId = upiRequestId ?: "",
)
accountDao.updateLiteInfoListByAccountIdAndStatus(
accountId = accountId,
accountStatus = AccountStatus.ACTIVE,
upiLiteInfo = upiLiteInfoList,
)
}
}
}
suspend fun updateLiteAccountStatusAndDeregistrationUpiRequestIdByAccountIdAndLrn(
upiLiteAccountStatus: UPILiteAccountStatus,
accountId: String,

View File

@@ -608,6 +608,3 @@ const val GOLD_ROUND_OFF_AMOUNT = "Round-off amount"
// External id error
const val ERR_FAILED_TO_FETCH_EXTERNAL_CUSTOMER_ID = "ERR_FAILED_TO_FETCH_EXTERNAL_CUSTOMER_ID"
// Lrn mismatch error
const val LRN_MISMATCH_ERROR = "lrn_mismatch_error"