TP-72671 | PS | fixed NPS to loader redirection issue in upi collect flow (#11708)

This commit is contained in:
Prakhar Saxena
2024-07-04 17:26:56 +05:30
committed by GitHub
parent 6f5ed2073a
commit d6ad94e670
2 changed files with 15 additions and 3 deletions

View File

@@ -547,6 +547,9 @@ class PaymentMethodFragment :
activity
)
}
viewModel.juspayEventResponse.observeNonNull(viewLifecycleOwner) {
openPaymentLoaderScreen(event = Gson().toJson(it))
}
}
private fun handleAsyncMethod(requestId: String?) {
@@ -1019,10 +1022,10 @@ class PaymentMethodFragment :
}
}
private fun handleResponseByMethodName(data: JSONObject?) {
private fun handleResponseByMethodName(data: JSONObject) {
try {
if (PaymentScreenUtil.isValidJuspayResponse(data)) {
openPaymentLoaderScreen(event = Gson().toJson(data))
viewModel.onJuspayEventReceived(data)
}
} catch (e: Exception) {
FirebaseCrashlytics.getInstance().recordException(e)
@@ -1163,7 +1166,7 @@ class PaymentMethodFragment :
methodName: String,
pollingConfiguration: RequestConfig?
) {
handleResponseByMethodName(data)
data?.let { handleResponseByMethodName(data) }
}
}
)

View File

@@ -63,6 +63,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import org.json.JSONObject
@HiltViewModel
class PaymentMethodViewModel
@@ -130,6 +131,10 @@ constructor(
val feedbackResponse: LiveData<Boolean>
get() = _feedbackResponse
private val _juspayEventResponse = MutableLiveData<JSONObject>()
val juspayEventResponse: LiveData<JSONObject>
get() = _juspayEventResponse
fun postPayNow(requestObj: Any?) {
paymentsToken?.let { token ->
viewModelScope.launch {
@@ -395,6 +400,10 @@ constructor(
}
}
}
fun onJuspayEventReceived(jsonObject: JSONObject) {
_juspayEventResponse.postValue(jsonObject)
}
}
sealed class NaviPaymentScreenUiState {