NTP-57300 | PS | added error code in send money failure bsheet (#15856)

Co-authored-by: Prakhar Saxena <prakhar.saxena@navi.com>
This commit is contained in:
Mehul Garg
2025-04-18 16:52:56 +05:30
committed by GitHub
parent 7b3cc96fdb
commit 744f0297a5
10 changed files with 60 additions and 11 deletions

View File

@@ -2056,10 +2056,12 @@ class NaviPaymentAnalytics private constructor() {
fun onRetryClicked(
screenName: String,
errorCode: String,
isRetryExperienceEnabled: Boolean = false,
baseAttributes: Map<String, String> = emptyMap(),
) {
val eventAttributes = buildMap {
put("error_code", errorCode)
put("is_retry_experience_enabled", isRetryExperienceEnabled.toString())
putAll(baseAttributes)
}
@@ -2071,10 +2073,12 @@ class NaviPaymentAnalytics private constructor() {
fun onPayViaOtherMethodsClicked(
screenName: String,
errorCode: String,
isRetryExperienceEnabled: Boolean,
baseAttributes: Map<String, String> = emptyMap(),
) {
val eventAttributes = buildMap {
put("error_code", errorCode)
put("is_retry_experience_enabled", isRetryExperienceEnabled.toString())
putAll(baseAttributes)
}
@@ -2086,11 +2090,13 @@ class NaviPaymentAnalytics private constructor() {
fun onCheckBalanceClicked(
screenName: String,
errorCode: String,
selectedBankAccountId: String,
isRetryExperienceEnabled: Boolean = false,
baseAttributes: Map<String, String> = emptyMap(),
) {
val eventAttributes = buildMap {
put("error_code", errorCode)
put("selected_bank_account_id", selectedBankAccountId)
put("is_retry_experience_enabled", isRetryExperienceEnabled.toString())
putAll(baseAttributes)
@@ -2103,11 +2109,13 @@ class NaviPaymentAnalytics private constructor() {
fun onResetUpiPinClicked(
screenName: String,
errorCode: String,
selectedBankAccountId: String,
isRetryExperienceEnabled: Boolean,
baseAttributes: Map<String, String> = emptyMap(),
) {
val eventAttributes = buildMap {
put("error_code", errorCode)
put("selected_bank_account_id", selectedBankAccountId)
put("is_retry_experience_enabled", isRetryExperienceEnabled.toString())
putAll(baseAttributes)
@@ -2120,11 +2128,13 @@ class NaviPaymentAnalytics private constructor() {
fun onPayButtonClicked(
screenName: String,
errorCode: String,
selectedBankAccountId: String,
isRetryExperienceEnabled: Boolean,
baseAttributes: Map<String, String> = emptyMap(),
) {
val eventAttributes = buildMap {
put("error_code", errorCode)
put("selected_bank_account_id", selectedBankAccountId)
put("is_retry_experience_enabled", isRetryExperienceEnabled.toString())
putAll(baseAttributes)

View File

@@ -18,6 +18,7 @@ sealed class OneClickScreenBottomSheetUiState {
data object Hidden : OneClickScreenBottomSheetUiState()
data class PaymentFailedRetryBottomSheet(
val errorCode: String,
val errorBucket: PaymentRetryErrorBucket,
val isPaymentThroughLite: Boolean,
) : OneClickScreenBottomSheetUiState()

View File

@@ -156,6 +156,7 @@ sealed class NPSBottomSheetType {
) : NPSBottomSheetType()
data class PaymentFailedRetryBottomSheet(
val errorCode: String,
val errorBucket: PaymentRetryErrorBucket,
val isPaymentThroughLite: Boolean,
) : NPSBottomSheetType()

View File

@@ -754,6 +754,7 @@ fun MPSScreen(
sendMoneyErrorAnalytics.onRetryClicked(
screenName =
NaviPaymentAnalyticScreenName.MINI_PAYMENT_SCREEN.screenName,
errorCode = bottomSheetType.errorCode,
isRetryExperienceEnabled = true,
baseAttributes = mpsViewModel.getAnalyticsParams(),
)
@@ -764,6 +765,7 @@ fun MPSScreen(
sendMoneyErrorAnalytics.onPayViaOtherMethodsClicked(
screenName =
NaviPaymentAnalyticScreenName.MINI_PAYMENT_SCREEN.screenName,
errorCode = bottomSheetType.errorCode,
isRetryExperienceEnabled = true,
baseAttributes = mpsViewModel.getAnalyticsParams(),
)
@@ -774,6 +776,7 @@ fun MPSScreen(
screenName =
NaviPaymentAnalyticScreenName.ONE_CLICK_CHECKOUT_SCREEN
.screenName,
errorCode = bottomSheetType.errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId = selectedBankAccount?.accountId.orEmpty(),
baseAttributes = mpsViewModel.getAnalyticsParams(),
@@ -784,6 +787,7 @@ fun MPSScreen(
sendMoneyErrorAnalytics.onResetUpiPinClicked(
screenName =
NaviPaymentAnalyticScreenName.MINI_PAYMENT_SCREEN.screenName,
errorCode = bottomSheetType.errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId = selectedBankAccount?.accountId.orEmpty(),
baseAttributes = mpsViewModel.getAnalyticsParams(),
@@ -794,6 +798,7 @@ fun MPSScreen(
sendMoneyErrorAnalytics.onPayButtonClicked(
screenName =
NaviPaymentAnalyticScreenName.MINI_PAYMENT_SCREEN.screenName,
errorCode = bottomSheetType.errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId = selectedBankAccount?.accountId.orEmpty(),
baseAttributes = mpsViewModel.getAnalyticsParams(),

View File

@@ -598,6 +598,7 @@ private fun NpsBottomSheetContent(
onDismissClicked = {
sendMoneyErrorAnalytics.onRetryClicked(
screenName = NaviPaymentAnalyticScreenName.FULL_PAYMENT_SCREEN.screenName,
errorCode = npsBottomSheetType.errorCode,
isRetryExperienceEnabled = true,
)
coroutineScope
@@ -612,6 +613,7 @@ private fun NpsBottomSheetContent(
onPayViaOtherMethodsClicked = {
sendMoneyErrorAnalytics.onPayViaOtherMethodsClicked(
screenName = NaviPaymentAnalyticScreenName.FULL_PAYMENT_SCREEN.screenName,
errorCode = npsBottomSheetType.errorCode,
isRetryExperienceEnabled = true,
)
coroutineScope
@@ -626,6 +628,7 @@ private fun NpsBottomSheetContent(
onCheckBalanceClicked = {
sendMoneyErrorAnalytics.onCheckBalanceClicked(
screenName = NaviPaymentAnalyticScreenName.FULL_PAYMENT_SCREEN.screenName,
errorCode = npsBottomSheetType.errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId =
screenState.naviUpiPaymentState.selectedBankAccount?.accountId.orEmpty(),
@@ -642,6 +645,7 @@ private fun NpsBottomSheetContent(
onResetUpiPinClicked = {
sendMoneyErrorAnalytics.onResetUpiPinClicked(
screenName = NaviPaymentAnalyticScreenName.FULL_PAYMENT_SCREEN.screenName,
errorCode = npsBottomSheetType.errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId =
screenState.naviUpiPaymentState.selectedBankAccount?.accountId.orEmpty(),
@@ -654,6 +658,7 @@ private fun NpsBottomSheetContent(
onPayButtonClick = {
sendMoneyErrorAnalytics.onPayButtonClicked(
screenName = NaviPaymentAnalyticScreenName.FULL_PAYMENT_SCREEN.screenName,
errorCode = npsBottomSheetType.errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId =
screenState.naviUpiPaymentState.selectedBankAccount?.accountId.orEmpty(),

View File

@@ -252,6 +252,7 @@ fun OneClickCheckoutScreen(
screenName =
NaviPaymentAnalyticScreenName.ONE_CLICK_CHECKOUT_SCREEN
.screenName,
errorCode = bottomSheetType.errorCode,
isRetryExperienceEnabled = true,
baseAttributes = oneClickCheckoutViewModel.getAnalyticsParams(),
)
@@ -275,6 +276,7 @@ fun OneClickCheckoutScreen(
screenName =
NaviPaymentAnalyticScreenName.ONE_CLICK_CHECKOUT_SCREEN
.screenName,
errorCode = bottomSheetType.errorCode,
isRetryExperienceEnabled = true,
baseAttributes = oneClickCheckoutViewModel.getAnalyticsParams(),
)
@@ -293,16 +295,21 @@ fun OneClickCheckoutScreen(
onResetUpiPinClicked = {
oneClickCheckoutViewModel.onResetPinCLick(
activity = naviPaymentActivity,
errorCode = bottomSheetType.errorCode,
upiResultLauncher = upiResultLauncher,
)
},
checkBalanceStateMap = checkBalanceStateMap,
onCheckBalanceClicked = {
oneClickCheckoutViewModel.onCheckBalanceClicked()
oneClickCheckoutViewModel.onCheckBalanceClicked(
bottomSheetType.errorCode
)
},
showPayButtonLoader = isBottomSheetRetryCtaLoaderEnabled,
onPayButtonClick = {
oneClickCheckoutViewModel.onBottomSheetPayButtonClicked()
oneClickCheckoutViewModel.onBottomSheetPayButtonClicked(
bottomSheetType.errorCode
)
},
)
}

View File

@@ -35,6 +35,7 @@ object MPSScreenUtils {
data class Feedback(val feedbackConfig: FeedbackConfig? = null) : MPSScreenType()
data class PaymentFailedRetryBottomSheet(
val errorCode: String,
val errorBucket: PaymentRetryErrorBucket,
val isPaymentThroughLite: Boolean,
) : MPSScreenType()

View File

@@ -80,6 +80,7 @@ import com.navi.payment.nativepayment.usecase.PmsLinkedAccountUseCase
import com.navi.payment.nativepayment.usecase.PmsSendMoneyUseCase
import com.navi.payment.nativepayment.utils.MPSScreenUtils
import com.navi.payment.nativepayment.utils.NaviPaymentErrorConfig
import com.navi.payment.nativepayment.utils.NaviPaymentEventHandler
import com.navi.payment.nativepayment.utils.NaviPaymentRewardsEventBus
import com.navi.payment.nativepayment.utils.PaymentCancelSource
import com.navi.payment.nativepayment.utils.PaymentRewardsEvent
@@ -134,6 +135,7 @@ constructor(
private val naviPayManager: NaviPayManager,
private val resourceProvider: ResourceProvider,
private val paymentDataProvider: PaymentDataProvider,
private val paymentEventHandler: NaviPaymentEventHandler,
private val pmsLinkedAccountUseCase: PmsLinkedAccountUseCase,
private val naviPaymentRewardsEventBus: NaviPaymentRewardsEventBus,
private val transactionStatusUseCase: TransactionStatusUseCase,
@@ -370,10 +372,10 @@ constructor(
}
private suspend fun sendMoneyErrorListener() {
eventHandler.get().sendMoneyErrorEvent.collectLatest { event ->
paymentEventHandler.sendMoneyErrorEvent.collectLatest { event ->
if (event.sourceDestination == NaviPaymentScreenType.MINI_PAYMENT_SCREEN.name) {
isDismissAllowed = false
eventHandler.get().naviPaymentsEventBus.resetEventBus()
paymentEventHandler.naviPaymentsEventBus.resetEventBus()
val errorCode = event.response.errors?.firstOrNull()?.code.orEmpty()
val errorBucket =
paymentErrorHelper.getErrorBucket(
@@ -399,6 +401,7 @@ constructor(
showBottomSheet = true,
bottomSheetUIState =
MPSScreenUtils.MPSScreenType.PaymentFailedRetryBottomSheet(
errorCode = errorCode,
errorBucket = errorBucket,
isPaymentThroughLite = event.isPaymentThroughLiteAccount.orFalse(),
),

View File

@@ -102,6 +102,7 @@ import com.navi.payment.nativepayment.repository.PaymentRepository
import com.navi.payment.nativepayment.usecase.NetBankingUseCase
import com.navi.payment.nativepayment.usecase.PmsLinkedAccountUseCase
import com.navi.payment.nativepayment.usecase.PmsSendMoneyUseCase
import com.navi.payment.nativepayment.utils.NaviPaymentEventHandler
import com.navi.payment.nativepayment.utils.NaviPaymentRewardsEventBus
import com.navi.payment.nativepayment.utils.PaymentRewardsEvent
import com.navi.payment.nativepayment.utils.getDiscountAdjustedAmount
@@ -169,6 +170,7 @@ constructor(
naviPayConfigUseCase: NaviPayConfigUseCase,
private val naviPayManager: NaviPayManager,
@PaymentsSdkRetrofit private val deserializer: Gson,
private val paymentEventHandler: NaviPaymentEventHandler,
private val pmsSendMoneyUseCase: PmsSendMoneyUseCase,
private val arcNudgeUseCase: ArcNudgeUseCase,
private val naviPaymentRewardsEventBus: NaviPaymentRewardsEventBus,
@@ -329,9 +331,9 @@ constructor(
}
private suspend fun sendMoneyErrorListener() {
eventHandler.get().sendMoneyErrorEvent.collectLatest { event ->
paymentEventHandler.sendMoneyErrorEvent.collectLatest { event ->
if (event.sourceDestination == NaviPaymentScreenType.FULL_PAYMENT_SCREEN.name) {
eventHandler.get().naviPaymentsEventBus.resetEventBus()
paymentEventHandler.naviPaymentsEventBus.resetEventBus()
val errorCode = event.response.errors?.firstOrNull()?.code.orEmpty()
val errorBucket =
paymentErrorHelper.getErrorBucket(
@@ -359,6 +361,7 @@ constructor(
bottomSheetStateChange = true,
bottomSheetUIState =
NPSBottomSheetType.PaymentFailedRetryBottomSheet(
errorCode = errorCode,
errorBucket = errorBucket,
isPaymentThroughLite = event.isPaymentThroughLiteAccount,
),

View File

@@ -16,6 +16,7 @@ import androidx.activity.result.ActivityResult
import androidx.lifecycle.viewModelScope
import com.navi.base.utils.EMPTY
import com.navi.base.utils.isNotNullAndNotEmpty
import com.navi.base.utils.orFalse
import com.navi.base.utils.orZero
import com.navi.common.network.models.isSuccessWithData
import com.navi.common.upi.PIN_ACTION
@@ -27,6 +28,7 @@ import com.navi.pay.common.model.view.NaviPayErrorConfig
import com.navi.pay.common.model.view.PspType
import com.navi.pay.common.setup.NaviPayManager
import com.navi.pay.common.usecase.AccountListCheckBalanceUseCase
import com.navi.pay.common.usecase.ArcNudgeUseCase
import com.navi.pay.common.usecase.LinkedAccountsUseCase
import com.navi.pay.common.usecase.NaviPayConfigUseCase
import com.navi.pay.management.common.sendmoney.model.view.PMSSendMoneyStatus
@@ -54,6 +56,7 @@ import com.navi.payment.nativepayment.model.transactionStatusRequest.Transaction
import com.navi.payment.nativepayment.model.transactionStatusRequest.TransactionStatusRequest
import com.navi.payment.nativepayment.repository.PaymentRepository
import com.navi.payment.nativepayment.usecase.PmsSendMoneyUseCase
import com.navi.payment.nativepayment.utils.NaviPaymentEventHandler
import com.navi.payment.nativepayment.utils.PaymentCancelSource
import com.navi.payment.nativepayment.utils.toGenericErrorResponse
import com.navi.payment.nativepayment.utils.toPaymentNaviPaymentErrorConfig
@@ -90,8 +93,10 @@ constructor(
private val linkedAccountUseCase: LinkedAccountsUseCase,
private val paymentDataProvider: PaymentDataProvider,
private val paymentRepository: PaymentRepository,
private val paymentEventHandler: NaviPaymentEventHandler,
private val transactionStatusUseCase: TransactionStatusUseCase,
private val pmsSendMoneyUseCase: PmsSendMoneyUseCase,
private val arcNudgeUseCase: ArcNudgeUseCase,
private val naviPayManager: NaviPayManager,
private val accountListCheckBalanceUseCase: AccountListCheckBalanceUseCase,
) :
@@ -141,9 +146,9 @@ constructor(
}
private suspend fun sendMoneyErrorListener() {
eventHandler.get().sendMoneyErrorEvent.collectLatest { event ->
paymentEventHandler.sendMoneyErrorEvent.collectLatest { event ->
if (event.sourceDestination == NaviPaymentScreenType.ONE_CLICK_CHECKOUT_SCREEN.name) {
eventHandler.get().naviPaymentsEventBus.resetEventBus()
paymentEventHandler.naviPaymentsEventBus.resetEventBus()
val errorCode = event.response.errors?.firstOrNull()?.code.orEmpty()
val errorBucket =
paymentErrorHelper.getErrorBucket(
@@ -173,6 +178,7 @@ constructor(
showBottomSheet = true,
bottomSheetUIState =
OneClickScreenBottomSheetUiState.PaymentFailedRetryBottomSheet(
errorCode = errorCode,
errorBucket = errorBucket,
isPaymentThroughLite = event.isPaymentThroughLiteAccount,
),
@@ -220,6 +226,9 @@ constructor(
val accounts = linkedAccountUseCase.execute(includeAllDetails = true).first()
linkedAccountEntity = accounts.firstOrNull { it.accountId == selectedAccountId }
linkedAccountEntity?.let {
if (paymentSdkInitParams?.isArcProtected.orFalse()) {
arcNudgeUseCase.updateAccountArcStatusForLinkedAccount(it)
}
accountListCheckBalanceUseCase.updateCheckBalanceStateForLinkedAccount(
linkedAccountEntity = it,
isAccountEligible = it.eligibilityState.isAccountEligible,
@@ -332,10 +341,11 @@ constructor(
return isAmountReadOnly.not() && errorBucket == PaymentRetryErrorBucket.INSUFFICIENT_BALANCE
}
fun onBottomSheetPayButtonClicked() {
fun onBottomSheetPayButtonClicked(errorCode: String) {
viewModelScope.safeLaunch(Dispatchers.IO) {
sendMoneyErrorAnalytics.onPayButtonClicked(
screenName = NaviPaymentScreenType.ONE_CLICK_CHECKOUT_SCREEN.name,
screenName = NaviPaymentAnalyticScreenName.ONE_CLICK_CHECKOUT_SCREEN.name,
errorCode = errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId = linkedAccountEntity!!.accountId,
baseAttributes = getAnalyticsParams(),
@@ -430,12 +440,13 @@ constructor(
)
}
fun onCheckBalanceClicked() {
fun onCheckBalanceClicked(errorCode: String) {
viewModelScope.safeLaunch {
linkedAccountEntity?.let {
_isCheckBalanceInProgress.update { true }
sendMoneyErrorAnalytics.onCheckBalanceClicked(
screenName = NaviPaymentAnalyticScreenName.ONE_CLICK_CHECKOUT_SCREEN.screenName,
errorCode = errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId = linkedAccountEntity!!.accountId,
baseAttributes = getAnalyticsParams(),
@@ -472,10 +483,12 @@ constructor(
fun onResetPinCLick(
activity: Activity,
errorCode: String,
upiResultLauncher: ManagedActivityResultLauncher<Intent, ActivityResult>,
) {
sendMoneyErrorAnalytics.onResetUpiPinClicked(
screenName = NaviPaymentAnalyticScreenName.ONE_CLICK_CHECKOUT_SCREEN.screenName,
errorCode = errorCode,
isRetryExperienceEnabled = true,
selectedBankAccountId = linkedAccountEntity!!.accountId,
baseAttributes = getAnalyticsParams(),