NTP-33304 | Shiv | db insertion logic for empty txn id (#14915)

This commit is contained in:
Shiv Natani
2025-02-10 18:27:25 +05:30
committed by GitHub
parent 596a246a0f
commit a19987cbe0
6 changed files with 103 additions and 29 deletions

View File

@@ -460,9 +460,16 @@ fun MPSScreen(
baseAttributes = mpsViewModel.getAnalyticsParams(),
)
mpsViewModel.updateBottomSheetUIState(false)
val addAccountType = mpsViewModel.addAccountType
val addAccountTypeString =
if (addAccountType?.contains(CREDIT_ACCOUNT_TYPE).orFalse()) {
ALL_ENABLED_ACCOUNTS
} else {
SAVINGS_ONLY_ENABLED_ACCOUNTS
}
naviPaymentActivity.launchOnboardingSDK(
action = NaviPayOnboardingActionsType.E2E_ONBOARDING.name,
enabledAccountTypes = SAVINGS_ONLY_ENABLED_ACCOUNTS,
enabledAccountTypes = addAccountTypeString,
launcher = upiResultLauncher,
source = NaviPaymentScreenType.MINI_PAYMENT_SCREEN.name,
selectedAccountId = selectedBankAccount?.accountId,
@@ -555,7 +562,7 @@ fun MPSScreen(
mpsViewModel.updateBottomSheetUIState(false)
val addAccountType = mpsViewModel.addAccountType
val addAccountTypeString =
if (addAccountType?.contains("CREDIT").orFalse()) {
if (addAccountType?.contains(CREDIT_ACCOUNT_TYPE).orFalse()) {
ALL_ENABLED_ACCOUNTS
} else {
SAVINGS_ONLY_ENABLED_ACCOUNTS

View File

@@ -53,6 +53,7 @@ import com.navi.payment.nativepayment.NaviPaymentAnalytics.Companion.SOURCE
import com.navi.payment.nativepayment.NaviPaymentAnalytics.Companion.TOKEN
import com.navi.payment.nativepayment.common.usecase.TransactionStatusUseCase
import com.navi.payment.nativepayment.dataprovider.PaymentDataProvider
import com.navi.payment.nativepayment.db.model.TransactionStatusRequestEntity
import com.navi.payment.nativepayment.model.AvailableCardTypes
import com.navi.payment.nativepayment.model.BasePaymentInstrument
import com.navi.payment.nativepayment.model.CardPaymentInstrument
@@ -530,6 +531,17 @@ constructor(
),
)
if (response.isSuccessWithData()) {
response.data?.transactionReferenceId?.let {
insertTransactionStatusRequest(
transactionReferenceId = it,
token = internalState.paymentSdkInitParams?.token.orEmpty(),
screenType = NaviPaymentScreenType.FULL_PAYMENT_SCREEN.name,
event = EMPTY,
status =
com.navi.payment.nativepayment.db.model.TransactionStatus.INITTIATED
.name,
)
}
savePayNowResponse(response)
val providerPayload = (response.data as? ExternalPayNowResponse)?.providerPayload
val updatedPayload = replaceCardDetailsInPaymentPayload(providerPayload)
@@ -1066,6 +1078,26 @@ constructor(
}
}
}
private fun insertTransactionStatusRequest(
transactionReferenceId: String,
token: String,
event: String,
screenType: String,
status: String,
) {
coroutineScope.safeLaunch(Dispatchers.IO) {
transactionStatusUseCase.insertTransactionStatusRequest(
TransactionStatusRequestEntity(
transactionReferenceId = transactionReferenceId,
token = token,
status = status,
event = event,
screenType = screenType,
)
)
}
}
}
enum class ValidationKeys(val key: String) {

View File

@@ -475,13 +475,15 @@ constructor(
PAYMENT_ORDER_REFERENCE_ID,
response.data?.paymentOrderReferenceId.orEmpty(),
)
insertTransactionStatusRequest(
transactionReferenceId = response.data?.transactionReferenceId.orEmpty(),
token = paymentSdkInitParams?.token.orEmpty(),
screenType = NaviPaymentScreenType.MINI_PAYMENT_SCREEN.name,
event = EMPTY,
status = TransactionStatus.INITTIATED.name,
)
response.data?.transactionReferenceId?.let { transactionReferenceId ->
insertTransactionStatusRequest(
transactionReferenceId = transactionReferenceId,
token = paymentSdkInitParams?.token.orEmpty(),
screenType = NaviPaymentScreenType.MINI_PAYMENT_SCREEN.name,
event = EMPTY,
status = TransactionStatus.INITTIATED.name,
)
}
payNowResponse = response.data
(response.data as? InternalPayNowResponse)?.let {
startNaviUpiPayment(payNowResponse = it)

View File

@@ -439,6 +439,7 @@ constructor(
)
val paymentAmount = npsScreenState.npsBaseState.paymentAmount
// Rewards info v2 ??
val discountedAmount =
npsScreenState.naviCoinState.coinBurnDetails?.redeemableCoinsValue?.value.orZero()
val discountAdjustedAmount =
@@ -1096,7 +1097,17 @@ constructor(
response.data?.paymentOrderReferenceId.orEmpty(),
)
payNowResponse = response.data
payNowResponse?.transactionReferenceId?.let {
insertTransactionStatusRequest(
transactionReferenceId = it,
token = paymentSdkInitParams?.token.orEmpty(),
screenType = NaviPaymentScreenType.FULL_PAYMENT_SCREEN.name,
event = EMPTY,
status =
com.navi.payment.nativepayment.db.model.TransactionStatus.INITTIATED
.name,
)
}
when (val responseData = response.data) {
is IntentUriPayNowResponse -> {
responseData.providerPayload?.let {
@@ -1115,16 +1126,6 @@ constructor(
}
is InternalPayNowResponse -> {
startNaviUpiPayment(responseData)
insertTransactionStatusRequest(
transactionReferenceId =
response.data?.transactionReferenceId.orEmpty(),
token = paymentSdkInitParams?.token.orEmpty(),
screenType = NaviPaymentScreenType.FULL_PAYMENT_SCREEN.name,
event = EMPTY,
status =
com.navi.payment.nativepayment.db.model.TransactionStatus.INITTIATED
.name,
)
}
}
} else {

View File

@@ -25,6 +25,7 @@ import com.navi.payment.nativepayment.NaviPaymentAnalyticScreenName
import com.navi.payment.nativepayment.NaviPaymentAnalytics
import com.navi.payment.nativepayment.common.usecase.TransactionStatusUseCase
import com.navi.payment.nativepayment.db.model.BankEntity
import com.navi.payment.nativepayment.db.model.TransactionStatusRequestEntity
import com.navi.payment.nativepayment.model.NaviPaymentScreenType
import com.navi.payment.nativepayment.model.NetBankingPaymentInstrument
import com.navi.payment.nativepayment.presentation.reducer.NetBankingScreenContract
@@ -302,6 +303,16 @@ constructor(
private suspend fun handlePayNowResponse(response: RepoResult<PayNowResponse>) {
if (response.isSuccessWithData()) {
payNowResponse = response.data
payNowResponse?.transactionReferenceId?.let {
insertTransactionStatusRequest(
transactionReferenceId = it,
token = token,
screenType = NaviPaymentScreenType.FULL_PAYMENT_SCREEN.name,
event = EMPTY,
status =
com.navi.payment.nativepayment.db.model.TransactionStatus.INITTIATED.name,
)
}
when (val payNowResponseData = response.data) {
is ExternalPayNowResponse -> {
payNowResponseData.providerPayload?.let {
@@ -345,4 +356,24 @@ constructor(
private fun updateState(newState: NetBankingScreenState) {
_state.update { newState }
}
private fun insertTransactionStatusRequest(
transactionReferenceId: String,
token: String,
event: String,
screenType: String,
status: String,
) {
coroutineScope.safeLaunch(Dispatchers.IO) {
transactionStatusUseCase.insertTransactionStatusRequest(
TransactionStatusRequestEntity(
transactionReferenceId = transactionReferenceId,
token = token,
status = status,
event = event,
screenType = screenType,
)
)
}
}
}

View File

@@ -350,6 +350,16 @@ constructor(
PAYMENT_ORDER_REFERENCE_ID,
response.data?.paymentOrderReferenceId.orEmpty(),
)
payNowResponse?.transactionReferenceId?.let {
insertTransactionStatusRequest(
transactionReferenceId = it,
token = paymentSdkInitParams?.token.orEmpty(),
screenType = NaviPaymentScreenType.FULL_PAYMENT_SCREEN.name,
event = EMPTY,
status =
com.navi.payment.nativepayment.db.model.TransactionStatus.INITTIATED.name,
)
}
when (val payNowResponseData = response.data) {
is IntentUriPayNowResponse -> {
payNowResponseData.providerPayload?.let {
@@ -368,15 +378,6 @@ constructor(
}
}
is InternalPayNowResponse -> {
insertTransactionStatusRequest(
transactionReferenceId = response.data?.transactionReferenceId.orEmpty(),
token = paymentSdkInitParams?.token.orEmpty(),
screenType = NaviPaymentScreenType.FULL_PAYMENT_SCREEN.name,
event = EMPTY,
status =
com.navi.payment.nativepayment.db.model.TransactionStatus.INITTIATED
.name,
)
startNaviUpiPayment(payNowResponse = payNowResponseData)
}
}