From 7e2b441ee73b76ed41d88bb4ebd6486e38bcfed3 Mon Sep 17 00:00:00 2001 From: Mohit Rajput Date: Thu, 19 Sep 2024 09:50:07 -0700 Subject: [PATCH] NTP-3108 | fixed bbps status polling and coin banner (#12643) --- .../com/navi/bbps/common/NaviBbpsConstants.kt | 1 + .../model/config/NaviBbpsDefaultConfig.kt | 9 +++--- .../feature/billerlist/BillerListViewModel.kt | 8 +++--- .../category/ui/RenderBillCategoriesScreen.kt | 4 +-- .../CustomerDataInputViewModel.kt | 4 +-- .../ui/CustomerDataInputScreen.kt | 4 ++- .../ui/PayBillCoinUtilisationComposables.kt | 27 ++++++++++++++---- .../bbps/feature/paybill/ui/PayBillScreen.kt | 8 ++++-- .../BbpsTransactionDetailsViewModel.kt | 28 +++++++++++++------ .../navi-bbps/src/main/res/values/strings.xml | 4 ++- .../java/com/navi/common/utils/Constants.kt | 9 +++--- 11 files changed, 72 insertions(+), 34 deletions(-) diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/NaviBbpsConstants.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/NaviBbpsConstants.kt index 69f7d1a508..4c6dd546ca 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/NaviBbpsConstants.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/NaviBbpsConstants.kt @@ -127,6 +127,7 @@ const val NAVI_BBPS_BILL_CATEGORY_MAX_COIN_EARN_FLOW = 100 const val NAVI_BBPS_PAY_BILL_MIN_COIN_EARN_FLOW = 10 const val CASH_REWARDS = "\${cashReward}" const val COINS = "\${coins}" +const val CREDIT_CARD_DISCOUNT_PERCENTAGE = "1%" // datastore constants const val NAVI_BBPS_COINS = "navi_bbps_coins" diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/model/config/NaviBbpsDefaultConfig.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/model/config/NaviBbpsDefaultConfig.kt index cbe6f1876b..bd3c535c04 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/model/config/NaviBbpsDefaultConfig.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/model/config/NaviBbpsDefaultConfig.kt @@ -52,9 +52,10 @@ data class CoinUtilisationConfig( data class InJourneyRewardsNudgeConfig( @SerializedName("rechargeNudgeSuffix") val rechargeNudgeSuffix: String = "on every recharge", @SerializedName("billPaymentNudgeSuffix") val billPaymentNudgeSuffix: String = "on every bill", - @SerializedName("creditCardNudgeSuffix") val creditCardNudgeSuffix: String = "on every bill", + @SerializedName("creditCardNudgeSuffix") + val creditCardNudgeSuffix: String = "on credit card bill payments", @SerializedName("billPaymentNudgePrefix") val billPaymentNudgePrefix: String = "Win up to", - @SerializedName("creditCardNudgePrefix") val creditCardNudgePrefix: String = "Win up to", - @SerializedName("billPaymentAmount") val billPaymentAmount: String = "1,000", - @SerializedName("creditCardAmount") val creditCardAmount: String = "1,000", + @SerializedName("creditCardNudgePrefix") val creditCardNudgePrefix: String = "Flat", + @SerializedName("billPaymentAmount") val billPaymentFormattedAmount: String = "1,000", + @SerializedName("creditCardAmount") val creditCardFormattedAmount: String = "1%", ) diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/billerlist/BillerListViewModel.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/billerlist/BillerListViewModel.kt index 9dee6b0688..736b684f13 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/billerlist/BillerListViewModel.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/billerlist/BillerListViewModel.kt @@ -669,15 +669,15 @@ constructor( val prefixText = if (isCreditCardCategory) nudgeConfig.creditCardNudgePrefix else nudgeConfig.billPaymentNudgePrefix - val amount = - if (isCreditCardCategory) nudgeConfig.creditCardAmount - else nudgeConfig.billPaymentAmount + val formattedAmount = + if (isCreditCardCategory) nudgeConfig.creditCardFormattedAmount + else nudgeConfig.billPaymentFormattedAmount val updatedNudgeDetailEntity = nudgeDetailEntity?.copy( suffixText = suffixText, prefixText = prefixText, - amount = amount + formattedAmount = formattedAmount ) _rewardsNudgeDetailEntity.update { updatedNudgeDetailEntity } diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/ui/RenderBillCategoriesScreen.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/ui/RenderBillCategoriesScreen.kt index 4a300b4591..7c45f2fdb2 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/ui/RenderBillCategoriesScreen.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/ui/RenderBillCategoriesScreen.kt @@ -301,8 +301,8 @@ private fun PendingBillItem( ), color = NaviBbpsColor.textPrimary, fontFamily = ttComposeFontFamily, - fontSize = 14.sp, - fontWeight = getFontWeight(FontWeightEnum.NAVI_HEADLINE_REGULAR), + fontSize = 12.sp, + fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD), overflow = TextOverflow.Ellipsis ) Spacer(modifier = Modifier.width(4.dp)) diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/customerinput/CustomerDataInputViewModel.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/customerinput/CustomerDataInputViewModel.kt index dff0f6523b..1ae232a26a 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/customerinput/CustomerDataInputViewModel.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/customerinput/CustomerDataInputViewModel.kt @@ -541,8 +541,8 @@ constructor( if (isCreditCardCategory) nudgeConfig.creditCardNudgePrefix else nudgeConfig.billPaymentNudgePrefix val amount = - if (isCreditCardCategory) nudgeConfig.creditCardAmount - else nudgeConfig.billPaymentAmount + if (isCreditCardCategory) nudgeConfig.creditCardFormattedAmount + else nudgeConfig.billPaymentFormattedAmount val updatedNudgeDetailEntity = nudgeDetailEntity?.copy( diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/customerinput/ui/CustomerDataInputScreen.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/customerinput/ui/CustomerDataInputScreen.kt index 7257977685..d26d1ec9de 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/customerinput/ui/CustomerDataInputScreen.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/customerinput/ui/CustomerDataInputScreen.kt @@ -324,7 +324,9 @@ fun CustomerDataInputScreen( ) { Column(horizontalAlignment = Alignment.CenterHorizontally) { Spacer(Modifier.height(16.dp)) - CoinUtilisationBottomNudge() + CoinUtilisationBottomNudge( + categoryId = billCategoryEntity.categoryId + ) } } else if (billCategoryEntity.categoryId != CATEGORY_ID_CREDIT_CARD) { Column( diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/paybill/ui/PayBillCoinUtilisationComposables.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/paybill/ui/PayBillCoinUtilisationComposables.kt index 9864ffc4e0..f9373fbbfa 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/paybill/ui/PayBillCoinUtilisationComposables.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/paybill/ui/PayBillCoinUtilisationComposables.kt @@ -36,6 +36,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.navi.bbps.R import com.navi.bbps.common.CATEGORY_ID_CREDIT_CARD +import com.navi.bbps.common.CREDIT_CARD_DISCOUNT_PERCENTAGE import com.navi.bbps.common.NAVI_BBPS_MAX_COIN_EARN import com.navi.bbps.common.theme.NaviBbpsColor import com.navi.bbps.common.ui.NaviBbpsLottieAnimation @@ -50,14 +51,17 @@ import com.navi.design.theme.ttComposeFontFamily import com.navi.naviwidgets.extensions.NaviText @Composable -fun CoinUtilisationBottomNudge() { +fun CoinUtilisationBottomNudge(categoryId: String) { + val isCreditCardCategory = categoryId == CATEGORY_ID_CREDIT_CARD Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) { Row( horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically ) { NaviText( - text = stringResource(id = R.string.bbps_win_up_to), + text = + if (isCreditCardCategory) stringResource(id = R.string.bbps_flat) + else stringResource(id = R.string.bbps_win_up_to), fontSize = 12.sp, lineHeight = 18.sp, fontFamily = ttComposeFontFamily, @@ -71,7 +75,7 @@ fun CoinUtilisationBottomNudge() { modifier = Modifier.size(12.dp) ) Spacer(modifier = Modifier.width(2.dp)) - val descriptionText = coinUtilisationBottomText() + val descriptionText = coinUtilisationBottomText(isCreditCardCategory) NaviText( text = descriptionText, fontSize = 12.sp, @@ -97,11 +101,22 @@ fun CoinUtilisationBottomNudge() { } @Composable -fun coinUtilisationBottomText(): AnnotatedString { +fun coinUtilisationBottomText(isCreditCardCategory: Boolean): AnnotatedString { val descriptionText = buildAnnotatedString { val fullText = - stringResource(id = R.string.bbps_coin_utilisation_description, NAVI_BBPS_MAX_COIN_EARN) - val wordToHighlight = NAVI_BBPS_MAX_COIN_EARN + if (isCreditCardCategory) { + stringResource( + id = R.string.bbps_credit_card_bill_coin_utilisation_description, + CREDIT_CARD_DISCOUNT_PERCENTAGE + ) + } else { + stringResource( + id = R.string.bbps_coin_utilisation_description, + NAVI_BBPS_MAX_COIN_EARN + ) + } + val wordToHighlight = + if (isCreditCardCategory) CREDIT_CARD_DISCOUNT_PERCENTAGE else NAVI_BBPS_MAX_COIN_EARN append(fullText) addStyle( diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/paybill/ui/PayBillScreen.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/paybill/ui/PayBillScreen.kt index 1e21b48d4b..ff914cc45f 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/paybill/ui/PayBillScreen.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/paybill/ui/PayBillScreen.kt @@ -470,11 +470,15 @@ fun PayBillScreen( if ( isCoinUtilisationExperimentEnabled && - billCategoryEntity.categoryId != CATEGORY_ID_CREDIT_CARD + !(isCreditCardV2Enabled && + billCategoryEntity.categoryId == + CATEGORY_ID_CREDIT_CARD) ) { Spacer(Modifier.weight(1f)) Spacer(modifier = Modifier.height(32.dp)) - CoinUtilisationBottomNudge() + CoinUtilisationBottomNudge( + categoryId = billCategoryEntity.categoryId + ) } } } diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/transactiondetails/viewmodel/BbpsTransactionDetailsViewModel.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/transactiondetails/viewmodel/BbpsTransactionDetailsViewModel.kt index 9d830e9d15..e92ead46f2 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/transactiondetails/viewmodel/BbpsTransactionDetailsViewModel.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/transactiondetails/viewmodel/BbpsTransactionDetailsViewModel.kt @@ -154,7 +154,10 @@ constructor( } private fun prepareRefundStatusWidgetProperties() { - if (billTransactionItemEntity.value.acknowledgementStatus !is TransactionStatus.Failed) { + if ( + billTransactionItemEntity.value.txnStatus is TransactionStatus.Failed || + billTransactionItemEntity.value.acknowledgementStatus !is TransactionStatus.Failed + ) { return } @@ -333,12 +336,17 @@ constructor( _navigateToNextScreenFromHelpCta.emit(ctaData) } + private fun isBillAcknowledgmentPollingRequired(): Boolean { + return billTransactionItemEntity.value.txnStatus is TransactionStatus.Success && + isBillAcknowledgmentStatusPending() + } + private suspend fun startTransactionStatusPolling() { // If transaction status is pending, then start transaction status polling // If not, check if bill acknowledgment status is pending, then start bill acknowledgment // status if (!isTransactionStatusPending()) { - if (isBillAcknowledgmentStatusPending()) { + if (isBillAcknowledgmentPollingRequired()) { startBillAcknowledgmentStatusPolling() } return @@ -423,7 +431,7 @@ constructor( } private suspend fun startBillAcknowledgmentStatusPolling() { - if (!isBillAcknowledgmentStatusPending()) { + if (!isBillAcknowledgmentPollingRequired()) { return } @@ -448,7 +456,7 @@ constructor( it.copy(acknowledgementStatus = acknowledgementStatus) } - if (!isBillAcknowledgmentStatusPending()) { + if (!isBillAcknowledgmentPollingRequired()) { acknowledgmentStatusPoller.stopPolling() } @@ -560,14 +568,18 @@ constructor( val billAndPaymentStatus = billTransactionItemEntity?.billTransactionStatus() - val displayPaymentStatusMessage = - billTransactionItemEntity?.acknowledgementStatus == TransactionStatus.Pending + val displayPaymentStatusSuccessMessage = + billTransactionItemEntity?.txnStatus == TransactionStatus.Success && + billTransactionItemEntity.acknowledgementStatus == TransactionStatus.Pending + + val displayPaymentStatusFailureMessage = + billTransactionItemEntity?.txnStatus == TransactionStatus.Failed return when (billAndPaymentStatus) { TransactionStatus.Success -> TransactionHistoryDetailItemProperty( bannerTransactionStatusTextId = - if (displayPaymentStatusMessage) { + if (displayPaymentStatusSuccessMessage) { R.string.bbps_payment_successful } else { when (isRechargeCategory(myBillEntity.categoryId)) { @@ -604,7 +616,7 @@ constructor( null -> TransactionHistoryDetailItemProperty( bannerTransactionStatusTextId = - if (displayPaymentStatusMessage) { + if (displayPaymentStatusFailureMessage) { R.string.bbps_payment_failed } else { when (isRechargeCategory(myBillEntity.categoryId)) { diff --git a/android/navi-bbps/src/main/res/values/strings.xml b/android/navi-bbps/src/main/res/values/strings.xml index d4b9c59429..c75fbf1412 100644 --- a/android/navi-bbps/src/main/res/values/strings.xml +++ b/android/navi-bbps/src/main/res/values/strings.xml @@ -205,8 +205,10 @@ Pay & win upto Win upto Win up to + Flat on every payment %s on paying via Navi UPI + %s on credit card bill payments 10= ₹1 on every bill payment ZERO @@ -217,7 +219,7 @@ Get ₹%s OFF on any bill using ₹%s OFF ₹%s off - >to get up to ₹%s OFF on the next step + to get up to ₹%s OFF on the next step to get ₹%s OFF on the next step Use your to pay diff --git a/android/navi-common/src/main/java/com/navi/common/utils/Constants.kt b/android/navi-common/src/main/java/com/navi/common/utils/Constants.kt index a34a097453..749723a617 100644 --- a/android/navi-common/src/main/java/com/navi/common/utils/Constants.kt +++ b/android/navi-common/src/main/java/com/navi/common/utils/Constants.kt @@ -360,6 +360,9 @@ object Constants { const val RETRY_COUNT = "retry_count" const val INSURANCE_TAB_URL = "HOME/DASHBOARD/Insurance_tab_page" + // navi bbps litmus experiments keys + const val LITMUS_EXPERIMENT_BBPS_REWARD_NUDGES = "NaviBBPS-exp-reward-callout" + // navi pay litmus experiments keys const val NAVI_PAY_LITMUS_EXPERIMENTS_CACHE_KEY = "NAVI_PAY_LITMUS_EXPERIMENTS_CACHE_KEY" const val LITMUS_EXPERIMENT_NAVIPAY_PPS_TDS = "NaviPay-exp-pps_tds" @@ -370,7 +373,8 @@ object Constants { listOf( LITMUS_EXPERIMENT_NAVIPAY_PPS_TDS, LITMUS_EXPERIMENT_NAVIPAY_REWARD_NUDGES, - LITMUS_EXPERIMENT_NAVIPAY_SEND_MONEY + LITMUS_EXPERIMENT_NAVIPAY_SEND_MONEY, + LITMUS_EXPERIMENT_BBPS_REWARD_NUDGES ) const val COMPOSABLE_ID = "COMPOSABLE_ID" @@ -386,7 +390,4 @@ object Constants { const val TOGGLE_SWITCH_CHECKED_STATE = "checked" const val AUTHENTICATION_SESSION_TIME_OUT_THRESHOLD = 5 * 60 * 1000L // 5 mins } - - // navi bbps litmus experiments keys - const val LITMUS_EXPERIMENT_BBPS_REWARD_NUDGES = "NaviBBPS-exp-reward-callout" }