pin pad success
This commit is contained in:
parent
bcd5634941
commit
0abf7bc6c9
@ -148,14 +148,22 @@ fun AppNavGraph(
|
|||||||
sharedViewModel = sharedViewModel,
|
sharedViewModel = sharedViewModel,
|
||||||
transProcessViewModel = transProcessViewModel,
|
transProcessViewModel = transProcessViewModel,
|
||||||
onNavigateTransactionResult = {
|
onNavigateTransactionResult = {
|
||||||
navController.navigate(Routes.TransactionResult.route)
|
navController.navigate(Routes.TransactionResult.route) {
|
||||||
|
popUpTo(Routes.Dashboard.route) {
|
||||||
|
inclusive = false
|
||||||
|
}
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onBack = { navController.popBackStack() }
|
onBack = { navController.popBackStack() }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
composable(Routes.TransactionResult.route) {
|
composable(Routes.TransactionResult.route) {
|
||||||
|
val sharedViewModel: SharedViewModel = hiltViewModel(activity)
|
||||||
|
|
||||||
TransactionResultRoute(
|
TransactionResultRoute(
|
||||||
|
sharedViewModel = sharedViewModel,
|
||||||
onNavigateMain = {
|
onNavigateMain = {
|
||||||
navController.navigate(Routes.Dashboard.route) {
|
navController.navigate(Routes.Dashboard.route) {
|
||||||
popUpTo(Routes.Dashboard.route) {
|
popUpTo(Routes.Dashboard.route) {
|
||||||
|
|||||||
@ -6,11 +6,9 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.mob.utsmyanmar.model.PinPadStatus
|
import com.mob.utsmyanmar.model.PinPadStatus
|
||||||
import com.mob.utsmyanmar.model.TransResultStatus
|
|
||||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||||
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
||||||
import com.utsmyanmar.paylibs.Constant
|
import com.utsmyanmar.paylibs.Constant
|
||||||
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PinPadRoute(
|
fun PinPadRoute(
|
||||||
@ -23,22 +21,16 @@ fun PinPadRoute(
|
|||||||
val pinText by pinPadViewModel.pinText.collectAsStateWithLifecycle()
|
val pinText by pinPadViewModel.pinText.collectAsStateWithLifecycle()
|
||||||
val alertMsg by pinPadViewModel.alertMsg.collectAsStateWithLifecycle()
|
val alertMsg by pinPadViewModel.alertMsg.collectAsStateWithLifecycle()
|
||||||
val pinStatus by pinPadViewModel.pinStatus.collectAsStateWithLifecycle()
|
val pinStatus by pinPadViewModel.pinStatus.collectAsStateWithLifecycle()
|
||||||
val transStatus by transProcessViewModel.transResultStatus.collectAsStateWithLifecycle()
|
|
||||||
|
|
||||||
LaunchedEffect(pinStatus) {
|
LaunchedEffect(pinStatus) {
|
||||||
when (pinStatus) {
|
when (pinStatus) {
|
||||||
PinPadStatus.ON_CONFIRM,
|
PinPadStatus.ON_CONFIRM,
|
||||||
PinPadStatus.ON_NEXT_SCREEN,
|
PinPadStatus.ON_NEXT_SCREEN -> {
|
||||||
PinPadStatus.ON_EMPTY -> {
|
val payDetail = pinPadViewModel.getPayDetail()
|
||||||
if (SystemParamsOperation.getInstance().demoStatus) {
|
payDetail?.tradeAnswerCode = Constant.ANSWER_CODE_APPROVED
|
||||||
val payDetail = pinPadViewModel.getPayDetail()
|
sharedViewModel.payDetail.value = payDetail
|
||||||
payDetail?.tradeAnswerCode = Constant.ANSWER_CODE_APPROVED
|
transProcessViewModel.resetTransactionStatus()
|
||||||
sharedViewModel.payDetail.value = payDetail
|
onNavigateTransactionResult()
|
||||||
transProcessViewModel.resetTransactionStatus()
|
|
||||||
onNavigateTransactionResult()
|
|
||||||
} else {
|
|
||||||
transProcessViewModel.startOnlineProcess()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PinPadStatus.ON_CANCEL,
|
PinPadStatus.ON_CANCEL,
|
||||||
@ -51,25 +43,6 @@ fun PinPadRoute(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(transStatus) {
|
|
||||||
when (transStatus) {
|
|
||||||
TransResultStatus.SUCCESS,
|
|
||||||
TransResultStatus.FAIL,
|
|
||||||
TransResultStatus.NETWORK_ERROR,
|
|
||||||
TransResultStatus.ERROR,
|
|
||||||
TransResultStatus.REVERSAL_FAIL,
|
|
||||||
TransResultStatus.REVERSAL_SUCCESS -> {
|
|
||||||
sharedViewModel.payDetail.value =
|
|
||||||
transProcessViewModel.payDetailResult.value
|
|
||||||
?: transProcessViewModel.payDetail
|
|
||||||
transProcessViewModel.resetTransactionStatus()
|
|
||||||
onNavigateTransactionResult()
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
onDispose {
|
onDispose {
|
||||||
pinPadViewModel.cancelPinPad()
|
pinPadViewModel.cancelPinPad()
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class PinPadViewModel @Inject constructor(
|
|||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "PinPadViewModel"
|
private const val TAG = "PinPadViewModel"
|
||||||
|
private const val PIN_CONFIRM_SUCCESS_STATUS = 0
|
||||||
private const val ON_CONFIRM_CLICK = 2
|
private const val ON_CONFIRM_CLICK = 2
|
||||||
private const val ON_CANCEL_CLICK = 3
|
private const val ON_CANCEL_CLICK = 3
|
||||||
private const val ON_ERROR_PIN_PAD = 4
|
private const val ON_ERROR_PIN_PAD = 4
|
||||||
@ -202,7 +203,7 @@ class PinPadViewModel @Inject constructor(
|
|||||||
this.timeout = timeout * 1000
|
this.timeout = timeout * 1000
|
||||||
isOrderNumKey = pinPadOrder
|
isOrderNumKey = pinPadOrder
|
||||||
keySystem = AidlConstants.Security.SEC_MKSK
|
keySystem = AidlConstants.Security.SEC_MKSK
|
||||||
pinKeyIndex = 1
|
pinKeyIndex = PIK_INDEX
|
||||||
pinblockFormat = AidlConstants.PinBlockFormat.SEC_PIN_BLK_ISO_FMT0
|
pinblockFormat = AidlConstants.PinBlockFormat.SEC_PIN_BLK_ISO_FMT0
|
||||||
this.pan = getPanBytes(this@PinPadViewModel.pan)
|
this.pan = getPanBytes(this@PinPadViewModel.pan)
|
||||||
}
|
}
|
||||||
@ -442,53 +443,42 @@ class PinPadViewModel @Inject constructor(
|
|||||||
status: Int,
|
status: Int,
|
||||||
pinBlock: ByteArray?
|
pinBlock: ByteArray?
|
||||||
) {
|
) {
|
||||||
|
|
||||||
LogUtil.e(
|
LogUtil.e(
|
||||||
TAG,
|
TAG,
|
||||||
"onConfirm status:$status"
|
"onConfirm status:$status"
|
||||||
)
|
)
|
||||||
|
if (status != PIN_CONFIRM_SUCCESS_STATUS) {
|
||||||
|
_alertMsg.value = "PinPad confirm failed: $status"
|
||||||
|
_pinStatus.value = PinPadStatus.ON_ERROR
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// if (pinBlock != null) {
|
val isCardValid = SunmiSDK.getInstance().checkCardExist() == 2 ||
|
||||||
//
|
payDetail?.cardType == AidlConstants.CardType.MAGNETIC.getValue() ||
|
||||||
// val hexStr =
|
payDetail?.cardType == -9
|
||||||
// ByteUtil.bytes2HexStr(pinBlock)
|
|
||||||
//
|
if (!isCardValid) {
|
||||||
// if (
|
_pinStatus.value = PinPadStatus.ON_CARD_REMOVED
|
||||||
// SunmiSDK.getInstance().checkCardExist() == 2 ||
|
return
|
||||||
// payDetail?.cardType == AidlConstants.CardType.MAGNETIC.getValue() ||
|
}
|
||||||
// payDetail?.cardType == -9
|
|
||||||
// ) {
|
if (pinBlock != null) {
|
||||||
//
|
payDetail?.pinCipher = ByteUtil.bytes2HexStr(pinBlock)
|
||||||
// payDetail?.pinCipher = hexStr
|
} else {
|
||||||
//
|
payDetail?.pinCipher = ""
|
||||||
// if (
|
}
|
||||||
// transType.value == TransactionsType.PRE_AUTH_COMPLETE ||
|
|
||||||
// transType.value == TransactionsType.PRE_AUTH_VOID ||
|
if (
|
||||||
// transType.value == TransactionsType.REFUND
|
transType.value == TransactionsType.PRE_AUTH_COMPLETE ||
|
||||||
// ) {
|
transType.value == TransactionsType.PRE_AUTH_VOID ||
|
||||||
//
|
transType.value == TransactionsType.REFUND
|
||||||
// _pinStatus.value =
|
) {
|
||||||
// PinPadStatus.ON_NEXT_SCREEN
|
_pinStatus.value = PinPadStatus.ON_NEXT_SCREEN
|
||||||
//
|
} else {
|
||||||
// } else {
|
handler.obtainMessage(
|
||||||
//
|
ON_CONFIRM_CLICK
|
||||||
// handler.obtainMessage(
|
).sendToTarget()
|
||||||
// ON_CONFIRM_CLICK
|
}
|
||||||
// ).sendToTarget()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
//
|
|
||||||
// _pinStatus.value =
|
|
||||||
// PinPadStatus.ON_CARD_REMOVED
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
//
|
|
||||||
// handler.obtainMessage(
|
|
||||||
// ON_EMPTY_PIN_BLOCK
|
|
||||||
// ).sendToTarget()
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCancel() {
|
override fun onCancel() {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
|||||||
@Composable
|
@Composable
|
||||||
fun TransactionResultRoute(
|
fun TransactionResultRoute(
|
||||||
viewModel: TransactionResultViewModel = hiltViewModel(),
|
viewModel: TransactionResultViewModel = hiltViewModel(),
|
||||||
sharedViewModel: SharedViewModel = hiltViewModel(),
|
sharedViewModel: SharedViewModel,
|
||||||
onNavigateMain: () -> Unit,
|
onNavigateMain: () -> Unit,
|
||||||
onNavigatePrintReceipt: () -> Unit,
|
onNavigatePrintReceipt: () -> Unit,
|
||||||
onShowError: (String) -> Unit,
|
onShowError: (String) -> Unit,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user