NTP-14642 | lite vm scope fix v1 (#14606)
This commit is contained in:
@@ -41,7 +41,6 @@ import com.navi.pay.npcicl.NpciResult
|
||||
import com.navi.pay.npcicl.UpiLiteBoundStatus
|
||||
import com.navi.pay.onboarding.account.common.repository.AccountsRepository
|
||||
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
|
||||
import com.navi.pay.utils.KEY_UPI_LITE_ACTIVE
|
||||
import com.navi.pay.utils.KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO
|
||||
import com.navi.pay.utils.UPI_LITE_DEREGISTRATION
|
||||
import com.navi.pay.utils.UPI_LITE_TOPUP
|
||||
@@ -528,7 +527,6 @@ constructor(
|
||||
key = KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO,
|
||||
encrypt = true,
|
||||
)
|
||||
sharedPreferenceRepository.removeKey(key = KEY_UPI_LITE_ACTIVE, encrypt = true)
|
||||
upiLiteClHelper.unBindDeviceForUpiLite(accountId = linkedAccountEntity.accountId)
|
||||
naviPayAnalytics.onDevGenericEvent(
|
||||
event = "Lite_Deregistration_Success",
|
||||
|
||||
@@ -102,7 +102,6 @@ import com.navi.pay.utils.HEX_FORMAT
|
||||
import com.navi.pay.utils.HYPHEN
|
||||
import com.navi.pay.utils.KEY_CUSTOMER_STATUS
|
||||
import com.navi.pay.utils.KEY_DEVICE_FINGERPRINT
|
||||
import com.navi.pay.utils.KEY_UPI_LITE_ACTIVE
|
||||
import com.navi.pay.utils.KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO
|
||||
import com.navi.pay.utils.NAVI_PAY_ENCRYPT_SHARED_PREF_DATA_KEYS
|
||||
import com.navi.pay.utils.NAVI_PAY_INTENT_ACTIVITY_ENABLE
|
||||
@@ -837,7 +836,7 @@ fun getFormattedCreditCardNumber(accountNumber: String): String {
|
||||
|
||||
fun removeUpiLiteSharedPrefData() {
|
||||
PreferenceManager.clearKeyBasedSecuredSessionPreference(
|
||||
keys = listOf(KEY_UPI_LITE_ACTIVE, KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO)
|
||||
keys = listOf(KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,6 @@ import com.navi.pay.utils.DEFAULT_MANDATE_AMOUNT_RULE
|
||||
import com.navi.pay.utils.DEFAULT_UPI_CURRENCY
|
||||
import com.navi.pay.utils.DEFAULT_UPI_MODE
|
||||
import com.navi.pay.utils.DS_KEY_NAVI_PAY_CUSTOMER_STATUS
|
||||
import com.navi.pay.utils.KEY_UPI_LITE_ACTIVE
|
||||
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
|
||||
@@ -1486,9 +1485,6 @@ constructor(
|
||||
// Fire UPI Lite screen landed event
|
||||
fireUpiLiteScreenLandEvent()
|
||||
|
||||
// Update shared pref values
|
||||
updateSharedPrefValues()
|
||||
|
||||
// Check if Lite account is active on iOS
|
||||
if (isLiteActiveOnIos()) {
|
||||
return@collect
|
||||
@@ -1539,36 +1535,6 @@ constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateSharedPrefValues() {
|
||||
viewModelScope.launch(coroutineDispatcherProvider.io) {
|
||||
val isAnyActiveLiteAccountPresent = isActiveLiteAccountPresent()
|
||||
sharedPreferenceRepository.saveBooleanValue(
|
||||
key = KEY_UPI_LITE_ACTIVE,
|
||||
value = isAnyActiveLiteAccountPresent,
|
||||
)
|
||||
val isAnyDeregisteredOrNonTerminalLiteAccountPresent =
|
||||
linkedAccounts.value.any { linkedAccountEntity ->
|
||||
linkedAccountEntity.upiLiteInfo
|
||||
.any {
|
||||
it.accountStatus == UPILiteAccountStatus.DEREGISTERED &&
|
||||
it.os == OS_ANDROID ||
|
||||
it.accountStatus == UPILiteAccountStatus.PENDING_DEREGISTRATION &&
|
||||
it.os == OS_ANDROID
|
||||
}
|
||||
.orFalse()
|
||||
}
|
||||
naviPayAnalytics.onDevGenericEvent(
|
||||
event = ::updateSharedPrefValues.name,
|
||||
params =
|
||||
mapOf(
|
||||
"isAnyActiveLiteAccountPresent" to isAnyActiveLiteAccountPresent.toString(),
|
||||
"isAnyDeregisteredOrNonTerminalLiteAccountPresent" to
|
||||
isAnyDeregisteredOrNonTerminalLiteAccountPresent.toString(),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isLiteAccountActiveOnIos(): Boolean =
|
||||
linkedAccounts.value
|
||||
.any { linkedAccountEntity ->
|
||||
@@ -2935,7 +2901,7 @@ constructor(
|
||||
isUPILiteSetupDone = isUpiLiteSetupDone.value,
|
||||
naviPaySessionAttributes = getNaviPaySessionAttributes(),
|
||||
)
|
||||
registrationUnsuccessful(lrn = lrn, accountId = linkedAccountEntity.accountId)
|
||||
onRegistrationUnsuccessful(lrn = lrn, accountId = linkedAccountEntity.accountId)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3062,7 +3028,7 @@ constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun UpiLiteViewModel.handleRegistrationFailedCase(
|
||||
private suspend fun handleRegistrationFailedCase(
|
||||
liteRegistrationResponse: LiteRegistrationResponse,
|
||||
linkedAccountEntity: LinkedAccountEntity,
|
||||
) {
|
||||
@@ -3073,7 +3039,7 @@ constructor(
|
||||
naviPaySessionAttributes = getNaviPaySessionAttributes(),
|
||||
)
|
||||
updateBottomSheetUiState(showBottomSheet = false)
|
||||
registrationUnsuccessful(
|
||||
onRegistrationUnsuccessful(
|
||||
lrn = liteRegistrationResponse.lrn,
|
||||
accountId = linkedAccountEntity.accountId,
|
||||
rotation = liteRegistrationResponse.rotation,
|
||||
@@ -3419,7 +3385,6 @@ constructor(
|
||||
|
||||
val balance = upiLiteClHelper.getUpiLiteBalance(accountId = linkedAccountEntity.accountId)
|
||||
|
||||
sharedPreferenceRepository.saveBooleanValue(key = KEY_UPI_LITE_ACTIVE, value = true)
|
||||
updateIsUserOnboarded(isUserOnboarded = true)
|
||||
updateUpiLiteBalance(balance = balance)
|
||||
updateLiteAccountInfoSharedPrefState(
|
||||
@@ -3786,7 +3751,7 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun registrationUnsuccessful(
|
||||
private suspend fun onRegistrationUnsuccessful(
|
||||
lrn: String? = null,
|
||||
accountId: String,
|
||||
rotation: String? = null,
|
||||
@@ -4489,20 +4454,18 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun startFirstExecution(
|
||||
private suspend fun startFirstExecution(
|
||||
linkedAccountEntity: LinkedAccountEntity,
|
||||
lrn: String,
|
||||
executionAmount: String,
|
||||
) {
|
||||
viewModelScope.launch(coroutineDispatcherProvider.io) {
|
||||
val upiRequestId = upiRequestIdUseCase.execute()
|
||||
initiateMandateExecution(
|
||||
upiRequestId = upiRequestId,
|
||||
linkedAccountEntity = linkedAccountEntity,
|
||||
lrn = lrn,
|
||||
executionAmount = executionAmount,
|
||||
)
|
||||
}
|
||||
val upiRequestId = upiRequestIdUseCase.execute()
|
||||
initiateMandateExecution(
|
||||
upiRequestId = upiRequestId,
|
||||
linkedAccountEntity = linkedAccountEntity,
|
||||
lrn = lrn,
|
||||
executionAmount = executionAmount,
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun initiateMandateExecution(
|
||||
@@ -4623,7 +4586,6 @@ constructor(
|
||||
|
||||
val balance = upiLiteClHelper.getUpiLiteBalance(accountId = accountId)
|
||||
|
||||
sharedPreferenceRepository.saveBooleanValue(key = KEY_UPI_LITE_ACTIVE, value = true)
|
||||
updateIsUserOnboarded(isUserOnboarded = true)
|
||||
updateUpiLiteBalance(balance = balance)
|
||||
updateLiteInfoInSharedPref(
|
||||
@@ -4733,31 +4695,29 @@ constructor(
|
||||
refreshScreenContent()
|
||||
}
|
||||
|
||||
private fun startStatusPollingForNonTerminalMandateStatus() {
|
||||
viewModelScope.launch(coroutineDispatcherProvider.io) {
|
||||
val mandateInfo = upiLiteMandateInfo.value
|
||||
private suspend fun startStatusPollingForNonTerminalMandateStatus() {
|
||||
val mandateInfo = upiLiteMandateInfo.value
|
||||
|
||||
naviPayAnalytics.onDevGenericEvent(
|
||||
event = ::startStatusPollingForNonTerminalMandateStatus.name,
|
||||
params = mapOf("mandateInfo" to mandateInfo.toString()),
|
||||
)
|
||||
naviPayAnalytics.onDevGenericEvent(
|
||||
event = ::startStatusPollingForNonTerminalMandateStatus.name,
|
||||
params = mapOf("mandateInfo" to mandateInfo.toString()),
|
||||
)
|
||||
|
||||
mandateInfo?.let { liteMandateInfo ->
|
||||
// Poll only, if either of creation or execution is pending
|
||||
val nonTerminalMandateStatuses =
|
||||
listOf(MandateStatus.PENDING.name, MandateStatus.PENDING_ACTIVATION.name)
|
||||
mandateInfo?.let { liteMandateInfo ->
|
||||
// Poll only, if either of creation or execution is pending
|
||||
val nonTerminalMandateStatuses =
|
||||
listOf(MandateStatus.PENDING.name, MandateStatus.PENDING_ACTIVATION.name)
|
||||
|
||||
if (liteMandateInfo.status !in nonTerminalMandateStatuses) {
|
||||
return@launch
|
||||
}
|
||||
if (liteMandateInfo.status !in nonTerminalMandateStatuses) {
|
||||
return
|
||||
}
|
||||
|
||||
if (liteMandateInfo.status == MandateStatus.PENDING_ACTIVATION.name) {
|
||||
// initiate polling for mandate execution
|
||||
initiatePollForMandateExecution(liteMandateInfo = liteMandateInfo)
|
||||
} else {
|
||||
// initiate polling for mandate creation
|
||||
initiatePollForMandateCreation(liteMandateInfo = liteMandateInfo)
|
||||
}
|
||||
if (liteMandateInfo.status == MandateStatus.PENDING_ACTIVATION.name) {
|
||||
// initiate polling for mandate execution
|
||||
initiatePollForMandateExecution(liteMandateInfo = liteMandateInfo)
|
||||
} else {
|
||||
// initiate polling for mandate creation
|
||||
initiatePollForMandateCreation(liteMandateInfo = liteMandateInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ const val KEY_CUSTOMER_STATUS = "customerStatus"
|
||||
const val KEY_UPI_LITE_ACTIVE_ACCOUNT_INFO = "upiLiteActiveAccountInfo"
|
||||
const val KEY_IS_FIRST_TRANSACTION_SUCCESSFUL = "naviPayIsFirstTransactionSuccessful"
|
||||
const val KEY_DB_ENCRYPTION = "naviPayKeyDbEncryption"
|
||||
const val KEY_UPI_LITE_ACTIVE = "upiLiteActive"
|
||||
const val KEY_UPI_PRIMARY_ACCOUNT_VPA = "upiPrimaryAccountVpa"
|
||||
const val PENDING_REQUEST_REFRESHED_REQUIRED = "pendingRequestRefreshRequired"
|
||||
const val KEY_NPCI_TOKEN = "npciToken"
|
||||
@@ -105,7 +104,7 @@ const val KEY_NPCI_TOKEN_EXPIRY_IN_DAYS = "npciTokenExpriyInDays"
|
||||
const val KEY_BANK_LIST_DB_LAST_REFRESHED_TIMESTAMP = "bankListLastRefreshedTimestamp"
|
||||
|
||||
val NAVI_PAY_NON_ENCRYPT_SHARED_PREF_DATA_KEYS =
|
||||
listOf(KEY_BANK_LIST_DB_LAST_REFRESHED_TIMESTAMP, KEY_UPI_LITE_ACTIVE, KEY_CUSTOMER_STATUS)
|
||||
listOf(KEY_BANK_LIST_DB_LAST_REFRESHED_TIMESTAMP, KEY_CUSTOMER_STATUS)
|
||||
// Shared Preference constants ends here
|
||||
|
||||
const val INTENT_ACTION_SMS_SENT = "smsSent"
|
||||
|
||||
Reference in New Issue
Block a user