Compare commits

..

No commits in common. "fc4b8173089480a25a81b7568bd02c78e6399c2b" and "7c0e9c4e66bda46d915e00d1fbbcc7b20f216404" have entirely different histories.

55 changed files with 665 additions and 888 deletions

View File

@ -5,6 +5,9 @@ plugins {
id("com.google.dagger.hilt.android")
}
// Set default build variant
project.ext.set("android.defaultPublishConfig", "uatDebug")
android {
namespace = "com.mob.utsmyanmar"
compileSdk {
@ -40,8 +43,8 @@ android {
dimension = "env"
applicationIdSuffix = ".uat"
versionNameSuffix = "-UAT"
versionCode = 12
versionName = "3.0"
versionCode = 3
versionName = "2.1"
buildConfigField("String", "ENV", "\"UAT\"")
resValue("string", "app_name", "MOB-UAT")
}
@ -59,14 +62,6 @@ android {
"proguard-rules.pro"
)
}
debug {
isMinifyEnabled = false
isDebuggable = true
// proguardFiles(
// getDefaultProguardFile("proguard-android-optimize.txt"),
// "proguard-rules.pro"
// )
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
@ -125,6 +120,4 @@ dependencies {
implementation(project(":ecr"))
implementation(project(":xpay"))
implementation(project(":cmhl"))
implementation("se.warting.signature:signature-pad:0.2.0")
}

View File

@ -29,8 +29,6 @@
<application
android:name="com.mob.utsmyanmar.MyApplication"
android:allowBackup="true"
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"

View File

@ -2,7 +2,6 @@ package com.mob.utsmyanmar.ui.cardwaiting
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
@ -39,9 +38,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@ -137,16 +134,16 @@ private fun CardWaitingScreenContent(
Text(
text = "AMOUNT TO PAY",
color = Color.Black,
style = MaterialTheme.typography.titleMedium,
style = MaterialTheme.typography.labelSmall
)
Spacer(modifier = Modifier.height(6.dp))
// Row(verticalAlignment = Alignment.Bottom) {
Row(verticalAlignment = Alignment.Bottom) {
Text(
text = amount,
color = Color.LegacyRed,
style = MaterialTheme.typography.displayLarge
style = MaterialTheme.typography.displayMedium
)
Spacer(modifier = Modifier.width(6.dp))
@ -154,16 +151,16 @@ private fun CardWaitingScreenContent(
Text(
text = "MMK",
color = Color.LegacyRed,
style = MaterialTheme.typography.displaySmall.copy(fontWeight = FontWeight.Medium),
style = MaterialTheme.typography.labelSmall,
modifier = Modifier.padding(bottom = 6.dp)
)
// }
}
// Spacer(modifier = Modifier.height(32.dp))
Spacer(modifier = Modifier.height(32.dp))
ContactlessCircle(isLoading = uiState.isLoading)
// Spacer(modifier = Modifier.height(24.dp))
Spacer(modifier = Modifier.height(24.dp))
Text(
text = when {
@ -209,9 +206,12 @@ private fun CardWaitingScreenContent(
)
}
Spacer(modifier = Modifier.height(10.dp))
Spacer(modifier = Modifier.height(12.dp))
InsertCardRow(onMockClick = onMockClick)
Spacer(modifier = Modifier.height(10.dp))
Spacer(modifier = Modifier.height(18.dp))
Text(
text = uiState.alertMessage,
color = Color.Black,
@ -219,13 +219,23 @@ private fun CardWaitingScreenContent(
textAlign = TextAlign.Center,
lineHeight = 16.sp
)
Spacer(modifier = Modifier.height(10.dp))
Spacer(modifier = Modifier.height(18.dp))
// StatusPanel(uiState = uiState)
Spacer(modifier = Modifier.weight(1f))
ManualEntryAction(onManualEntryClick = onManualEntryClick)
Spacer(modifier = Modifier.height(10.dp))
Spacer(modifier = Modifier.height(18.dp))
CardLogoRow()
Spacer(modifier = Modifier.height(34.dp))
PoweredByMob()
Spacer(modifier = Modifier.height(12.dp))
}
}
@ -291,8 +301,7 @@ private fun InsertCardRow(onMockClick: () -> Unit) {
painter = painterResource(id = R.drawable.ic_insert_card),
contentDescription = null,
tint = Color.LegacyRed,
modifier = Modifier
.size(28.dp)
modifier = Modifier.size(28.dp)
.clickable(onClick = onMockClick)
)
@ -386,49 +395,13 @@ private fun CardLogoRow() {
.fillMaxWidth()
.height(42.dp)
.padding(horizontal = 14.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
CardLogo(
icon = painterResource(R.drawable.logo_visa),
name = "visa",
)
CardLogo(
icon = painterResource(R.drawable.logo_master),
name = "master",
)
CardLogo(
icon = painterResource(R.drawable.logo_mpu),
name = "master",
)
CardLogo(
icon = painterResource(R.drawable.logo_union_pay),
name = "master",
)
}
}
}
@Composable
private fun CardLogo(
icon: Painter,
name: String,
modifier: Modifier = Modifier
) {
Surface(
modifier = modifier,
shape = RoundedCornerShape(4.dp),
color = Color.White
) {
Box(
modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp),
contentAlignment = Alignment.Center
) {
Image(
painter = icon,
contentDescription = name,
modifier = Modifier.height(30.dp)
)
Text("VISA", style = MaterialTheme.typography.titleLarge)
Text("MC", style = MaterialTheme.typography.titleMedium)
Text("MPU", style = MaterialTheme.typography.titleLarge)
Text("UnionPay", style = MaterialTheme.typography.labelMedium)
}
}
}

View File

@ -16,13 +16,14 @@ import com.utsmyanmar.ecr.ECRHelper
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.delay
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import sunmi.sunmiui.utils.LogUtil
class CardWaitingViewModel(
private val cardReadViewModel: CardReaderViewModel,

View File

@ -5,14 +5,14 @@ import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.compose.dropUnlessResumed
import com.mob.utsmyanmar.ui.theme.Color
import com.mob.utsmyanmar.ui.theme.Primary
import com.mob.utsmyanmar.ui.theme.White
@OptIn(ExperimentalMaterial3Api::class)
@ -35,7 +35,7 @@ fun AppBar(
navigationIcon = {
if (icon != null && onIconClick != null) {
IconButton(
onClick = dropUnlessResumed { onIconClick() }
onClick = onIconClick
) {
Icon(
imageVector = icon,

View File

@ -104,9 +104,7 @@ fun SummaryCard(
onClickLastSync: () -> Unit,
lastSyncTime: Long?,
totalSaleCount: Int,
totalSaleAmount: Long,
settlementStatusText: String,
settlementDateTimeText: String
totalSaleAmount: Long
) {
var now by remember { mutableLongStateOf(System.currentTimeMillis()) }
LaunchedEffect(Unit) {
@ -147,8 +145,8 @@ fun SummaryCard(
SummaryItem(
title = "Settlement",
value = settlementStatusText,
subtitle = settlementDateTimeText,
value = "Completed",
subtitle = "Today 11:00 PM",
icon = Icons.Default.Check,
iconBg = Color.CrimsonRed
)

View File

@ -1,8 +1,5 @@
package com.mob.utsmyanmar.ui.dashboard
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountBalanceWallet
import androidx.compose.material.icons.filled.CreditCard
@ -10,6 +7,7 @@ import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.LockOpen
import androidx.compose.material.icons.filled.Replay
import androidx.compose.material.icons.filled.SwapHoriz
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@ -17,7 +15,6 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.mob.utsmyanmar.R
import com.mob.utsmyanmar.ui.theme.Color
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
class DashboardMenuItem(
val title: String,
@ -25,26 +22,13 @@ class DashboardMenuItem(
val onClick: () -> Unit
)
val settlementEnabled = false
val voidEnabled = true
val refundEnabled = true
val preAuthEnabled = true
val preAuthVoidEnabled = true
val preAuthCompleteEnabled = true
val preAuthCompleteVoidEnabled = true
val cashAdvEnabled = true
fun buildMenuItems(
onNavigateAmount: (String) -> Unit,
onNavigateSignOn: () -> Unit,
onNavigateSettlement: () -> Unit,
onNavigateHistory: () -> Unit,
onNavigateAction: (String) -> Unit
): List<DashboardMenuItem> = buildList {
val mmqrEnabled = SystemParamsOperation.getInstance().mmqrStatus
add(
): List<DashboardMenuItem> = listOf(
DashboardMenuItem(
"Sale",
{
@ -54,26 +38,7 @@ fun buildMenuItems(
modifier = Modifier.size(40.dp),
tint = Color.LegacyRed
)
}
) { onNavigateAmount("Sale") }
)
if (mmqrEnabled) {
add(
DashboardMenuItem(
"MMQR",
{
Image(
painter = painterResource(R.drawable.ic_mmqr_logo),
contentDescription = null,
modifier = Modifier.height(48.dp)
)
}
) { }
)
}
add(
}) { onNavigateAmount("Sale") },
DashboardMenuItem(
"History",
{
@ -83,11 +48,7 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateHistory() }
)
add(
}) { onNavigateHistory() },
DashboardMenuItem(
"Sign On",
{
@ -97,12 +58,7 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateSignOn() }
)
if (settlementEnabled) {
add(
}) { onNavigateSignOn() },
DashboardMenuItem(
"Settlement",
{
@ -112,13 +68,7 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateSettlement() }
)
}
if (voidEnabled) {
add(
}) { onNavigateSettlement() },
DashboardMenuItem(
"Void",
{
@ -128,13 +78,7 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateAction("Void") }
)
}
if (refundEnabled) {
add(
}) { onNavigateAction("Void") },
DashboardMenuItem(
"Refund",
{
@ -144,13 +88,7 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateAction("Refund") }
)
}
if (preAuthEnabled) {
add(
}) { onNavigateAction("Refund") },
DashboardMenuItem(
"Pre-Auth",
{
@ -160,13 +98,7 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateAmount("Pre-Auth") }
)
}
if (preAuthVoidEnabled) {
add(
}) { onNavigateAmount("Pre-Auth") },
DashboardMenuItem(
"Pre-Auth Void",
{
@ -176,13 +108,7 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateAction("Pre-Auth Void") }
)
}
if (preAuthCompleteEnabled) {
add(
}) { onNavigateAction("Pre-Auth Void") },
DashboardMenuItem(
"Pre-Auth Complete",
{
@ -192,13 +118,7 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateAction("Pre-Auth Complete") }
)
}
if (preAuthCompleteVoidEnabled) {
add(
}) { onNavigateAction("Pre-Auth Complete") },
DashboardMenuItem(
"Pre-Auth Comp Void",
{
@ -208,15 +128,9 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateAction("Pre-Auth Complete Void") }
)
}
if (cashAdvEnabled) {
add(
}) { onNavigateAction("Pre-Auth Complete Void") },
DashboardMenuItem(
"Cash Adv",
"Cash Out",
{
Icon(
Icons.Default.AccountBalanceWallet,
@ -224,10 +138,5 @@ fun buildMenuItems(
modifier = Modifier.size(32.dp),
tint = Color.LegacyRed
)
}
) { onNavigateAmount("Cash Adv") }
}) { onNavigateAmount("Cash Out") },
)
}
}

View File

@ -23,9 +23,6 @@ import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.Notifications
import androidx.compose.material.icons.filled.Sync
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@ -50,7 +47,6 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import com.mob.utsmyanmar.R
import com.mob.utsmyanmar.ui.components.appbar.AppBar
import com.mob.utsmyanmar.ui.device_info.DeviceInfoUiState
@ -180,29 +176,6 @@ fun DashboardScreen2(
)
}
if (dashboardUiState.isSyncing) {
Dialog(onDismissRequest = {}) {
Card(
shape = RoundedCornerShape(16.dp),
colors = CardDefaults.cardColors(containerColor = Color.White),
elevation = CardDefaults.cardElevation(8.dp)
) {
Column(
modifier = Modifier.padding(32.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
CircularProgressIndicator(color = Color.LegacyRed)
Spacer(Modifier.height(16.dp))
Text(
text = dashboardUiState.syncStatusText,
style = MaterialTheme.typography.bodyMedium,
color = Color.Black
)
}
}
}
}
ModalNavigationDrawer(
drawerState = drawerState,
drawerContent = {
@ -421,9 +394,7 @@ fun DashboardScreen2(
onClickLastSync = onClickLastSync,
lastSyncTime = dashboardUiState.lastSyncTime,
totalSaleCount = dashboardUiState.totalSaleCount,
totalSaleAmount = dashboardUiState.totalSaleAmount,
settlementStatusText = dashboardUiState.settlementStatusText,
settlementDateTimeText = dashboardUiState.settlementDateTimeText
totalSaleAmount = dashboardUiState.totalSaleAmount
)
Spacer(Modifier.height(12.dp))
}

View File

@ -15,9 +15,5 @@ data class DashboardUiState(
val lastSyncTime: Long? = null,
val carouselUrls: List<String> = emptyList(),
val totalSaleCount: Int = 0,
val totalSaleAmount: Long = 0L,
val settlementStatusText: String = "Pending",
val settlementDateTimeText: String = "--/-- --:--",
val isSyncing: Boolean = false,
val syncStatusText: String = "Connecting to TMS server..."
val totalSaleAmount: Long = 0L
)

View File

@ -6,7 +6,6 @@ import androidx.lifecycle.asFlow
import androidx.lifecycle.viewModelScope
import com.utsmyanmar.baselib.repo.Repository
import com.utsmyanmar.paylibs.model.PayDetail
import com.utsmyanmar.paylibs.system.SystemDateTime
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
import dagger.hilt.android.lifecycle.HiltViewModel
@ -18,7 +17,6 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import java.math.BigDecimal
import java.text.DecimalFormat
import java.util.Calendar
import javax.inject.Inject
@HiltViewModel
@ -33,23 +31,11 @@ class DashboardViewModel @Inject constructor(
init {
viewModelScope.launch {
repository.getLastTenTransactions().asFlow().collect { payDetails ->
val latestSettlement = payDetails.lastOrNull {
it.transactionType == TransactionsType.SETTLEMENT.value
}
val isCurrentBusinessSettlement = latestSettlement?.isCurrentBusinessSettlement() == true
_uiState.update {
it.copy(
recentTransactions = payDetails.map { pd -> pd.toRecord() },
totalSaleCount = payDetails.totalSaleCount(),
totalSaleAmount = payDetails.totalSaleAmount(),
settlementStatusText = if (isCurrentBusinessSettlement) {
"Completed"
} else {
"Pending"
},
settlementDateTimeText = latestSettlement
?.let { buildDateTime(it.TradeDate, it.TradeTime) }
?: "--/-- --:--"
totalSaleAmount = payDetails.totalSaleAmount()
)
}
}
@ -72,18 +58,6 @@ class DashboardViewModel @Inject constructor(
.takeIf { it > 0L }
_uiState.update { it.copy(lastSyncTime = time) }
}
fun startSync() {
_uiState.update { it.copy(isSyncing = true, syncStatusText = "Connecting to TMS server...") }
}
fun finishSync(message: String) {
_uiState.update { it.copy(syncStatusText = message) }
viewModelScope.launch {
kotlinx.coroutines.delay(1500)
_uiState.update { it.copy(isSyncing = false) }
}
}
}
private fun PayDetail.toRecord(): TrnxRecord {
@ -127,7 +101,7 @@ private fun formatTypeLabel(raw: String): String = when {
raw.contains("REFUND", ignoreCase = true) -> "Refund"
raw.contains("SETTLEMENT", ignoreCase = true) -> "Settlement"
raw.contains("PRE", ignoreCase = true) -> "Pre-Auth"
raw.contains("CASH", ignoreCase = true) -> "Cash Adv"
raw.contains("CASH", ignoreCase = true) -> "Cash Out"
raw.contains("WAVE", ignoreCase = true) -> "Wave Pay"
else -> raw.lowercase().replaceFirstChar { it.uppercaseChar() }
}
@ -138,18 +112,3 @@ private fun buildDateTime(date: String?, time: String?): String {
val t = (time ?: "").padStart(6, '0')
return "${d.take(2)}/${d.drop(2).take(2)} ${t.take(2)}:${t.drop(2).take(2)}"
}
private fun PayDetail.isCurrentBusinessSettlement(): Boolean {
if (transactionType != TransactionsType.SETTLEMENT.value) return false
if (TradeDate != SystemDateTime.getMMDD()) return false
val now = Calendar.getInstance()
val cutoff = Calendar.getInstance().apply {
set(Calendar.HOUR_OF_DAY, 23)
set(Calendar.MINUTE, 0)
set(Calendar.SECOND, 0)
set(Calendar.MILLISECOND, 0)
}
return now.before(cutoff)
}

View File

@ -51,7 +51,7 @@ fun SeeMoreScreen(
SeeMoreItem("Pre-Auth Void", Icons.Default.LockOpen),
SeeMoreItem("Pre-Auth Complete", Icons.Default.CreditCard),
SeeMoreItem("Pre-Auth Complete Void", Icons.Default.SwapHoriz),
SeeMoreItem("Cash Adv", Icons.Default.AccountBalanceWallet)
SeeMoreItem("Cash Out", Icons.Default.AccountBalanceWallet)
)
Scaffold(

View File

@ -32,7 +32,7 @@ fun EmvTransactionRoute(
onNavigateTransactionResult: () -> Unit,
onNavigateInputRrn: () -> Unit,
onNavigateCardWaiting: () -> Unit,
onNavigateError: (isSuccess:Boolean, messsage:String) -> Unit,
onNavigateError: (String) -> Unit,
onNavigateMain: () -> Unit
) {
val emvResultStatus by emvViewModel.emvResultStatus.observeAsState()
@ -69,7 +69,7 @@ fun EmvTransactionRoute(
val tradeData = emvViewModel.getTradeData()
if (tradeData == null) {
onNavigateError(false,"Please try again")
onNavigateError("Please try again")
return
}
@ -115,12 +115,12 @@ fun EmvTransactionRoute(
EmvResultStatus.TRY_AGAIN -> {
sharedViewModel.set_errorFragmentMsg("Card Not Supported!")
onNavigateError(false,"Card Not Supported!")
onNavigateError("Card Not Supported!")
}
EmvResultStatus.OFFLINE_DECLINE -> {
sharedViewModel.set_errorFragmentMsg("Offline Denial")
onNavigateError(false,"Offline Denial")
onNavigateError("Offline Denial")
}
EmvResultStatus.CONFIRM_CODE_VERIFY -> onNavigateCardWaiting()
@ -131,7 +131,7 @@ fun EmvTransactionRoute(
EmvResultStatus.PIN_MISMATCH -> {
sharedViewModel.set_errorFragmentMsg("PIN MISMATCH!")
onNavigateError(false,"PIN MISMATCH!")
onNavigateError("PIN MISMATCH!")
}
EmvResultStatus.PIN_EMPTY -> {
@ -164,27 +164,27 @@ fun EmvTransactionRoute(
EmvResultStatus.REVERSAL_FAIL -> {
sharedViewModel.set_errorFragmentMsg("Reversal failed!")
onNavigateError(false,"Reversal failed!")
onNavigateError("Reversal failed!")
}
EmvResultStatus.REVERSAL_SUCCESS -> {
sharedViewModel.set_successFragmentMsg("Reversal success!")
onNavigateError(true,"Reversal success!")
onNavigateMain()
}
EmvResultStatus.FAIL -> {
onNavigateError(false,"Transaction failed")
onNavigateError("Transaction failed")
}
EmvResultStatus.NETWORK_ERROR -> {
onNavigateError(false,"Com Error!")
onNavigateError("Com Error!")
}
EmvResultStatus.ERROR -> {
loadingMessage = null
val mapped = mapEmvError(errorCodeMsg)
sharedViewModel.set_errorFragmentMsg(mapped)
onNavigateError(false,mapped)
onNavigateError(mapped)
}
else -> LogUtil.d(TAG, "Unhandled EmvResult Status : $status")

View File

@ -1,139 +0,0 @@
package com.mob.utsmyanmar.ui.error
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Check
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.mob.utsmyanmar.ui.preview.P2Preview
import com.mob.utsmyanmar.ui.theme.Color
import kotlinx.coroutines.delay
private const val AUTO_DISMISS_DELAY_MS = 3000L
@Composable
fun TransactionErrorScreen(
isSuccess: Boolean,
message: String,
onDone: () -> Unit
) {
BackHandler(enabled = true) {
onDone()
}
LaunchedEffect(Unit) {
delay(AUTO_DISMISS_DELAY_MS)
onDone()
}
TransactionErrorContent(isSuccess= isSuccess, message = message)
}
@Composable
private fun TransactionErrorContent(isSuccess: Boolean,message: String) {
Scaffold(
containerColor = Color.IvoryBeige
) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.background(Color.IvoryBeige)
.padding(paddingValues)
.statusBarsPadding()
.navigationBarsPadding()
.padding(horizontal = 20.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.height(72.dp))
FailIcon(isSuccess)
Spacer(modifier = Modifier.height(24.dp))
Text(
text = "Transaction Failed",
color = Color.LegacyRed,
style = MaterialTheme.typography.headlineLarge
)
Spacer(modifier = Modifier.height(10.dp))
Text(
text = message.ifBlank { "Something went wrong. Please try again." },
color = Color.Gray,
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center
)
}
}
}
@Composable
private fun FailIcon(isSuccess: Boolean) {
Box(
modifier = Modifier.size(132.dp),
contentAlignment = Alignment.Center
) {
Box(
modifier = Modifier
.size(132.dp)
.background(
color = if (isSuccess) Color.Success.copy(alpha = 0.12f) else Color.Error.copy(alpha = 0.12f),
shape = CircleShape
)
)
Box(
modifier = Modifier
.size(96.dp)
.background(
color = if (isSuccess) Color.Success else Color.Error,
shape = CircleShape
),
contentAlignment = Alignment.Center
) {
if(isSuccess) {
Icon(
imageVector = Icons.Rounded.Check,
contentDescription = "Success",
tint = Color.White,
modifier = Modifier.size(64.dp)
)
} else {
Icon(
imageVector = Icons.Rounded.Close,
contentDescription = "Failed",
tint = Color.White,
modifier = Modifier.size(64.dp)
)
}
}
}
}
@P2Preview
@Composable
private fun PreviewTransactionErrorScreen() {
TransactionErrorContent(isSuccess = true, message = "Reversal Success")
}

View File

@ -74,7 +74,7 @@ private fun String.toTransactionConfig(): TransactionConfig {
processCode = ProcessCode.PRE_AUTH_COMPLETE_VOID + ProcessCode.SMART + ProcessCode.TO_ACCOUNT
)
"cash adv" -> TransactionConfig(
"cash out" -> TransactionConfig(
transactionName = "CASH_OUT",
transactionType = TransactionsType.CASH_OUT,
processCode = ProcessCode.CASH_ADVANCE + ProcessCode.SMART + ProcessCode.TO_ACCOUNT

View File

@ -56,13 +56,7 @@ fun InputAmount(
val supportingText = "Enter the amount to continue"
Scaffold(
topBar = {
AppBar(
title = "Amount",
icon = Icons.AutoMirrored.Rounded.ArrowBack,
onIconClick = onBackClick
)
},
topBar = { AppBar(title = "Amount", icon = Icons.AutoMirrored.Rounded.ArrowBack, onIconClick = onBackClick) },
containerColor = Color.IvoryBeige
) {paddingValues ->
@ -80,8 +74,7 @@ fun InputAmount(
.weight(2f),
){
Card(
modifier = Modifier
.align(Alignment.CenterEnd)
modifier = Modifier.align(Alignment.CenterEnd)
.clickable(enabled = true) {
amount = amount.dropLast(1)
},
@ -108,21 +101,29 @@ fun InputAmount(
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(modifier = Modifier.height(8.dp))
Row(
modifier = Modifier.align(Alignment.CenterHorizontally),
verticalAlignment = Alignment.Bottom
) {
if (prefixLabel.isNotBlank()) {
Text(
text = prefixLabel,
color = Color.LegacyRed,
style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Medium),
modifier = Modifier.padding(end = 10.dp, bottom = 6.dp)
)
}
Text(
text = formatAmount(amount.ifEmpty { "0" }),
color = Color.LegacyRed,
style = MaterialTheme.typography.displayLarge
)
if (prefixLabel.isNotBlank()) {
Text(
text = prefixLabel,
color = Color.LegacyRed,
style = MaterialTheme.typography.displaySmall.copy(fontWeight = FontWeight.Medium),
modifier = Modifier.padding(end = 10.dp, bottom = 6.dp)
)
}
Spacer(modifier = Modifier.height(14.dp))
Text(
text = supportingText,
color = Color.Gray,
@ -131,6 +132,8 @@ fun InputAmount(
)
}
}
//second container
Column(
modifier = Modifier
.fillMaxWidth()
@ -175,8 +178,7 @@ fun InputAmount(
onClick = {
if (amount.isNotEmpty()) {
onChargeClick(amount)
}
},
} },
modifier = Modifier
.weight(1f)
.height(56.dp),
@ -234,15 +236,14 @@ private fun formatAmount(value: String): String {
val groupedWholePart = "%,d".format(wholePart.toLongOrNull() ?: 0L)
if (!normalized.contains(".")) {
return "$groupedWholePart.00"
return groupedWholePart
}
val decimalPart = normalized.substringAfter(".", "")
return if (normalized.endsWith(".")) {
"$groupedWholePart.00"
"$groupedWholePart."
} else {
val padded = decimalPart.padEnd(2, '0').take(2)
"$groupedWholePart.$padded"
"$groupedWholePart.$decimalPart"
}
}

View File

@ -39,6 +39,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
@ -232,7 +233,8 @@ private fun ManualCardEntryScreen(
singleLine = true,
modifier = Modifier.fillMaxWidth(),
textStyle = MaterialTheme.typography.bodyLarge.copy(
letterSpacing = 2.sp
letterSpacing = 2.sp,
fontFamily = FontFamily.Monospace
)
)
@ -261,7 +263,8 @@ private fun ManualCardEntryScreen(
.width(160.dp)
.focusRequester(expiryFocusRequester),
textStyle = MaterialTheme.typography.bodyLarge.copy(
letterSpacing = 2.sp
letterSpacing = 2.sp,
fontFamily = FontFamily.Monospace
)
)
}
@ -281,6 +284,7 @@ private fun ManualCardEntryScreen(
Text(
text = "**** **** **** ${pan.takeLast(4)}",
style = MaterialTheme.typography.bodyMedium,
fontFamily = FontFamily.Monospace,
letterSpacing = 1.5.sp
)
if (expiry.length == 4) {

View File

@ -91,7 +91,7 @@ fun AppNavGraph(
val sharedViewModel: SharedViewModel = hiltViewModel(activity)
SignaturePad(
onBack = { navController.popBackStack() },
onConfirm = { bitmap, signatureBlob ->
onConfirm = { _, bitmap, signatureBlob ->
sharedViewModel.signBitmap = bitmap
sharedViewModel.updateSignatureBlob(signatureBlob)
navController.navigate(Routes.TransactionResult.route) {
@ -592,9 +592,9 @@ fun AppNavGraph(
launchSingleTop = true
}
},
onNavigateError = { isSuccess,message ->
navController.navigate(Routes.TransactionError.createRoute(isSuccess,message)) {
popUpTo(Routes.Processing.route) {
onNavigateError = { message ->
navController.navigate(Routes.TransactionError.createRoute(message)) {
popUpTo(Routes.ProcessingCard.route) {
inclusive = true
}
launchSingleTop = true
@ -681,8 +681,8 @@ fun AppNavGraph(
launchSingleTop = true
}
},
onNavigateError = { isSuccess,message ->
navController.navigate(Routes.TransactionError.createRoute(isSuccess,message)) {
onNavigateError = { message ->
navController.navigate(Routes.TransactionError.createRoute(message)) {
popUpTo(Routes.EmvTransaction.route) {
inclusive = true
}
@ -764,8 +764,8 @@ fun AppNavGraph(
launchSingleTop = true
}
},
onNavigateError = { isSuccess,message ->
navController.navigate(Routes.TransactionError.createRoute(isSuccess,message)) {
onNavigateError = { message ->
navController.navigate(Routes.TransactionError.createRoute(message)) {
popUpTo(Routes.Processing.route) {
inclusive = true
}
@ -819,11 +819,9 @@ fun AppNavGraph(
}
)
) { backStackEntry ->
val isSuccess = backStackEntry.arguments?.getBoolean("isSuccess") ?: false
val message = backStackEntry.arguments?.getString("message").orEmpty()
val message = backStackEntry.arguments?.getString("message").orEmpty().trim()
TransactionErrorScreen(
isSuccess = isSuccess,
message = message,
onDone = {
navController.navigate(Routes.Dashboard.route) {

View File

@ -31,7 +31,10 @@ sealed class Routes(val route: String) {
data object TransactionResult : Routes("transaction_result")
data object TransactionError : Routes("transaction_error/{message}") {
fun createRoute(message: String): String =
"transaction_error/${Uri.encode(message.ifBlank { " " })}"
}
data object PrintReceipt : Routes("print_receipt")
data object Version : Routes("version")
data object Functions : Routes("functions")
@ -47,7 +50,4 @@ sealed class Routes(val route: String) {
data object Disable : Routes("disable/{message}") {
fun createRoute(message: String): String = "disable/${Uri.encode(message)}"
}
data object TransactionError : Routes("transaction_error/{isSuccess}/{message}") {
fun createRoute(isSuccess: Boolean, message: String): String = "transaction_error/$isSuccess/${Uri.encode(message)}"
}
}

View File

@ -2,29 +2,27 @@ package com.mob.utsmyanmar.ui.print_receipt
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@ -32,7 +30,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
@ -43,15 +44,15 @@ import com.mob.utsmyanmar.ui.transaction_result.TransactionResultState
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultViewModel
import com.mob.utsmyanmar.viewmodel.SharedViewModel
import com.utsmyanmar.paylibs.utils.POSUtil
import com.utsmyanmar.paylibs.utils.PrintStatus
import kotlin.math.abs
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.milliseconds
private enum class ReceiptCopy(val label: String) {
MERCHANT("MERCHANT COPY"),
CUSTOMER("CUSTOMER COPY")
}
private const val PRINT_ANIMATION_DURATION_MS = 2300
private const val RESET_ANIMATION_DURATION_MS = 350
private const val PRINTED_HOLD_DELAY_MS = 500L
private const val OFFSCREEN_BUFFER_PX = 120f
@Composable
fun PrintReceiptScreen(
@ -63,58 +64,9 @@ fun PrintReceiptScreen(
val state by transactionResultViewModel.state.collectAsStateWithLifecycle()
val scope = rememberCoroutineScope()
val receiptOffsetY = remember { Animatable(0f) }
val animationDuration = 5000
val merchant_copy_autoprint = true
val customer_copy_autoprint = false
var currentCopy by remember { mutableStateOf(ReceiptCopy.MERCHANT) }
var nextCopy by remember { mutableStateOf(ReceiptCopy.CUSTOMER) }
var slotHeightPx by remember { mutableFloatStateOf(0f) }
var isPrinting by remember { mutableStateOf(false) }
suspend fun animatePrint() {
receiptOffsetY.animateTo(
targetValue = -1500f,
animationSpec = tween(durationMillis = animationDuration, easing = FastOutSlowInEasing)
)
delay(1000.milliseconds)
receiptOffsetY.animateTo(
targetValue = 0f,
animationSpec = tween(durationMillis = 0, easing = FastOutSlowInEasing)
)
}
fun isReprintMode() = sharedViewModel.isReprint.value == true
fun doPrint(copy: ReceiptCopy, onFinished: () -> Unit) {
val reprint = isReprintMode()
val actualCopy = if (reprint && copy == ReceiptCopy.MERCHANT) ReceiptCopy.CUSTOMER else copy
currentCopy = actualCopy
sharedViewModel.setPrintStatus(
if (actualCopy == ReceiptCopy.MERCHANT) PrintStatus.FIRST_PRINT else PrintStatus.SECOND_PRINT
)
onPrint()
scope.launch {
isPrinting = true
animatePrint()
isPrinting = false
nextCopy = if (reprint) ReceiptCopy.CUSTOMER
else if (actualCopy == ReceiptCopy.MERCHANT) ReceiptCopy.CUSTOMER else ReceiptCopy.MERCHANT
onFinished()
}
}
LaunchedEffect(Unit) {
val reprint = isReprintMode()
if (reprint) {
currentCopy = ReceiptCopy.CUSTOMER
nextCopy = ReceiptCopy.CUSTOMER
}
sharedViewModel.isReprint.value = false
when {
merchant_copy_autoprint && !reprint -> doPrint(ReceiptCopy.MERCHANT) { }
customer_copy_autoprint -> doPrint(ReceiptCopy.CUSTOMER) { }
}
}
Scaffold(
topBar = {
AppBar(title = "Receipt")
@ -130,16 +82,41 @@ fun PrintReceiptScreen(
horizontalAlignment = Alignment.CenterHorizontally,
) {
ReceiptPreview(
state = state,
copyLabel = currentCopy.label,
Box(
modifier = Modifier
.weight(1f)
.fillMaxWidth()
.onSizeChanged { slotHeightPx = it.height.toFloat() }
) {
Box(
modifier = Modifier
.fillMaxSize()
.clipToBounds()
) {
ReceiptPreview(
state = state,
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
.graphicsLayer {
translationY = receiptOffsetY.value
val travel = slotHeightPx + OFFSCREEN_BUFFER_PX
alpha = if (travel > 0f) {
1f - (abs(receiptOffsetY.value) / travel).coerceIn(0f, 1f)
} else {
1f
}
}
)
}
PrinterSlot(
isActive = isPrinting,
modifier = Modifier
.align(Alignment.TopCenter)
.fillMaxWidth()
)
}
Spacer(modifier = Modifier.height(16.dp))
@ -150,6 +127,7 @@ fun PrintReceiptScreen(
OutlinedButton(
onClick = onDone,
enabled = !isPrinting,
modifier = Modifier
.weight(1f)
.height(50.dp),
@ -170,15 +148,50 @@ fun PrintReceiptScreen(
containerColor = Color.LegacyRed,
contentColor = Color.White,
disabledContainerColor = Color.LegacyRed.copy(alpha = 0.5f),
disabledContentColor = Color.White.copy(alpha = 0.5f),
disabledContentColor = Color.White.copy(alpha = 0.7f),
),
shape = RoundedCornerShape(12.dp),
onClick = {
doPrint(nextCopy) { }
if (isPrinting) return@Button
isPrinting = true
onPrint()
scope.launch {
val targetOffset = -(slotHeightPx + OFFSCREEN_BUFFER_PX)
receiptOffsetY.animateTo(
targetValue = targetOffset,
animationSpec = tween(
durationMillis = PRINT_ANIMATION_DURATION_MS,
easing = FastOutSlowInEasing
)
)
delay(PRINTED_HOLD_DELAY_MS)
receiptOffsetY.animateTo(
targetValue = 0f,
animationSpec = tween(
durationMillis = RESET_ANIMATION_DURATION_MS,
easing = FastOutSlowInEasing
)
)
isPrinting = false
}
}
) {
if (isPrinting) {
CircularProgressIndicator(
modifier = Modifier.size(18.dp),
color = Color.White,
strokeWidth = 2.dp
)
Spacer(modifier = Modifier.width(8.dp))
}
Text(
text = "Print",
text = if (isPrinting) "Printing..." else "Print",
style = MaterialTheme.typography.titleMedium
)
}
@ -188,11 +201,52 @@ fun PrintReceiptScreen(
}
}
/**
* Visual "exit slot" pinned to the top of the receipt preview. The receipt
* appears to feed upward through this slot and out of frame while printing,
* mimicking a physical thermal printer.
*/
@Composable
private fun PrinterSlot(
isActive: Boolean,
modifier: Modifier = Modifier
) {
val infiniteTransition = rememberInfiniteTransition(label = "printerSlotGlow")
val glow by infiniteTransition.animateFloat(
initialValue = 0.35f,
targetValue = 1f,
animationSpec = infiniteRepeatable(
animation = tween(durationMillis = 550, easing = FastOutSlowInEasing),
repeatMode = RepeatMode.Reverse
),
label = "glow"
)
Column(
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = Modifier
.padding(horizontal = 40.dp)
.fillMaxWidth()
.height(6.dp)
.clip(RoundedCornerShape(50))
.background(
if (isActive) {
Color.LegacyRed.copy(alpha = glow)
} else {
Color.Gray.copy(alpha = 0.25f)
}
)
)
}
}
@Composable
fun ReceiptPreview(
state: TransactionResultState,
copyLabel: String,
modifier: Modifier = Modifier
) {
Column(
@ -210,18 +264,12 @@ fun ReceiptPreview(
) {
Text(
text = "MOB POS",
style = MaterialTheme.typography.headlineLarge
style = MaterialTheme.typography.headlineLarge.copy(fontFamily = FontFamily.Monospace)
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "Transaction Receipt",
style = MaterialTheme.typography.bodyMedium
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = copyLabel,
style = MaterialTheme.typography.labelLarge,
color = Color.Gray
style = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace)
)
Spacer(modifier = Modifier.height(16.dp))
ReceiptDivider()
@ -240,14 +288,14 @@ fun ReceiptPreview(
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "Thank You",
style = MaterialTheme.typography.titleMedium
style = MaterialTheme.typography.titleMedium.copy(fontFamily = FontFamily.Monospace)
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = "Please keep this receipt",
style = MaterialTheme.typography.bodySmall
style = MaterialTheme.typography.bodySmall.copy(fontFamily = FontFamily.Monospace)
)
}
}
@ -265,13 +313,13 @@ fun ReceiptRow(
) {
Text(
text = label,
style = MaterialTheme.typography.bodyMedium,
style = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace),
color = Color.Gray
)
Text(
text = value,
style = MaterialTheme.typography.titleSmall
style = MaterialTheme.typography.titleSmall.copy(fontFamily = FontFamily.Monospace)
)
}
}
@ -283,6 +331,7 @@ fun ReceiptDivider() {
.fillMaxWidth()
.padding(vertical = 10.dp),
text = "--------------------------------",
fontFamily = FontFamily.Monospace,
color = Color.Gray
)
}

View File

@ -13,7 +13,7 @@ fun ProcessingCardRoute(
onNavigateInputAmount: () -> Unit,
onNavigateProcessing: () -> Unit,
onNavigateEmvTransaction: () -> Unit,
onNavigateError: (isSuccess: Boolean, message: String) -> Unit,
onNavigateError: (String) -> Unit,
onBack: () -> Unit,
onShowDecline: (String) -> Unit
) {
@ -31,7 +31,7 @@ fun ProcessingCardRoute(
ProcessingCardUiEvent.NavigateToInputAmount -> onNavigateInputAmount()
ProcessingCardUiEvent.NavigateToProcessing -> onNavigateProcessing()
ProcessingCardUiEvent.NavigateToEmvTransaction -> onNavigateEmvTransaction()
is ProcessingCardUiEvent.NavigateToError -> onNavigateError(false,event.message)
is ProcessingCardUiEvent.NavigateToError -> onNavigateError(event.message)
is ProcessingCardUiEvent.ShowDeclineAndBack -> {
onShowDecline(event.message)
onBack()

View File

@ -7,6 +7,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.mob.utsmyanmar.model.CardTransactionType
import com.mob.utsmyanmar.ui.pinpad.PinPadViewModel
import com.mob.utsmyanmar.utils.MockCardData
import com.mob.utsmyanmar.utils.MockData
import com.mob.utsmyanmar.utils.TransactionUtil
import com.mob.utsmyanmar.viewmodel.CardReaderViewModel

View File

@ -25,7 +25,7 @@ fun ProcessingRoute(
settlementViewModel: SettlementViewModel,
onNavigateTransactionResult: () -> Unit,
onNavigateSignature: () -> Unit,
onNavigateError: (Boolean,String) -> Unit,
onNavigateError: (String) -> Unit,
onNavigateMain: ()-> Unit
) {
@ -105,7 +105,7 @@ private fun EmvProcessingContent(
sharedViewModel: SharedViewModel,
emvTransactionViewModel: EmvTransactionProcessViewModel,
onNavigateTransactionResult: () -> Unit,
onNavigateError: (Boolean,String) -> Unit,
onNavigateError: (String) -> Unit,
onNavigateMain: () -> Unit
) {
val emvTransStatus by emvTransactionViewModel.getTransStatus().observeAsState()
@ -134,13 +134,13 @@ private fun EmvProcessingContent(
TransResultStatus.REVERSAL_SUCCESS -> {
sharedViewModel.payDetail.value = emvTransactionViewModel.payDetailResult.value
sharedViewModel.set_successFragmentMsg("Reversal success!")
onNavigateError(true,"Reversal success!")
onNavigateMain()
}
TransResultStatus.REVERSAL_FAIL -> {
sharedViewModel.payDetail.value = emvTransactionViewModel.payDetailResult.value
sharedViewModel.set_errorFragmentMsg("Reversal failed!")
onNavigateError(false,"Reversal failed!")
onNavigateError("Reversal failed!")
}
TransResultStatus.ERROR,
@ -149,7 +149,7 @@ private fun EmvProcessingContent(
?.substringAfter(":")
?.takeIf { it.isNotBlank() }
?: "Transaction error"
onNavigateError(false,message)
onNavigateError(message)
}
else -> {}

View File

@ -1,10 +1,15 @@
package com.mob.utsmyanmar.ui.signature_pad
import android.graphics.Bitmap
import androidx.compose.foundation.border
import android.graphics.Paint
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@ -19,31 +24,84 @@ import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.graphics.createBitmap
import com.mob.utsmyanmar.ui.components.appbar.AppBar
import com.mob.utsmyanmar.ui.theme.MOBPOSTheme
import se.warting.signaturepad.SignaturePadAdapter
import se.warting.signaturepad.SignaturePadView
import java.io.ByteArrayOutputStream
import android.graphics.Canvas as AndroidCanvas
import android.graphics.Path as AndroidPath
import com.mob.utsmyanmar.ui.theme.Color as AppColor
@Composable
fun SignaturePad(
modifier: Modifier = Modifier,
signatureColor: Color = Color.Black,
onBack: () -> Unit = {},
onConfirm: (Bitmap?, ByteArray?) -> Unit = { _, _ -> }
// signatureBlob is null for Digital mode (using stored signature) or when nothing was drawn
onConfirm: (SignatureMode, Bitmap?, signatureBlob: ByteArray?) -> Unit = { _, _, _ -> }
) {
var signaturePadAdapter: SignaturePadAdapter? = null
val paths = remember { mutableStateListOf<List<Offset>>() }
val currentPath = remember { mutableStateListOf<Offset>() }
var selectedMode by remember { mutableStateOf(SignatureMode.Manual) }
var canvasSize by remember { mutableStateOf(Size.Zero) }
var strokeWidth = 6f
val scaledWidth = 300
fun clearSignature() {
paths.clear()
currentPath.clear()
}
fun scaleBitmap(source: Bitmap): Bitmap {
val ratio = scaledWidth.toFloat() / source.width
val height = (source.height * ratio).toInt()
return Bitmap.createScaledBitmap(source, scaledWidth, height, true)
fun buildBitmap(): Bitmap? {
if (selectedMode == SignatureMode.Digital) return null
if (paths.isEmpty() && currentPath.isEmpty()) return null
if (canvasSize.width <= 0f || canvasSize.height <= 0f) return null
val bitmap =
createBitmap(canvasSize.width.toInt(), canvasSize.height.toInt(), Bitmap.Config.RGB_565)
val canvas = AndroidCanvas(bitmap)
canvas.drawColor(android.graphics.Color.WHITE) // fill white background first
val paint = Paint().apply {
color = android.graphics.Color.BLACK
style = Paint.Style.STROKE
isAntiAlias = true
strokeCap = Paint.Cap.ROUND
strokeJoin = Paint.Join.ROUND
strokeWidth = 10f
}
fun drawStroke(points: List<Offset>) {
if (points.size < 2) return
val path = AndroidPath().apply {
moveTo(points.first().x, points.first().y)
for (index in 1 until points.size) {
lineTo(points[index].x, points[index].y)
}
}
canvas.drawPath(path, paint)
}
paths.forEach(::drawStroke)
drawStroke(currentPath)
return bitmap
}
fun bitmapToBlob(bitmap: Bitmap): ByteArray {
@ -69,20 +127,95 @@ fun SignaturePad(
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
SignaturePadView(
onReady = { signaturePadAdapter = it },
Box(
modifier = Modifier
.fillMaxWidth(0.85f) // narrower than full width, adjust as needed
.height(180.dp) // fixed height instead of weight(1f)
.align(Alignment.CenterHorizontally)
.background(Color.White, RoundedCornerShape(16.dp))
.padding(12.dp)
.onSizeChanged { size ->
canvasSize = Size(size.width.toFloat(), size.height.toFloat())
}
.pointerInput(Unit) {
detectDragGestures(
onDragStart = { startOffset ->
currentPath.add(startOffset)
},
onDrag = { change, _ ->
change.consume()
currentPath.add(change.position)
},
onDragEnd = {
paths.add(currentPath.toList())
currentPath.clear()
}
)
}
) {
Canvas(modifier = Modifier.fillMaxSize()) {
paths.forEach { points ->
if (points.size > 1) {
val path = Path().apply {
moveTo(points.first().x, points.first().y)
for (i in 1 until points.size) {
lineTo(points[i].x, points[i].y)
}
}
drawPath(
path = path,
color = signatureColor,
style = Stroke(width = strokeWidth)
)
}
}
if (currentPath.size > 1) {
val path = Path().apply {
moveTo(currentPath.first().x, currentPath.first().y)
for (i in 1 until currentPath.size) {
lineTo(currentPath[i].x, currentPath[i].y)
}
}
drawPath(
path = path,
color = signatureColor,
style = Stroke(width = strokeWidth)
)
}
}
}
Column(
modifier = Modifier
.fillMaxWidth()
.height(200.dp)
.border(width = 1.dp, color = AppColor.LegacyRed)
.height(150.dp)
) {
SignatureModeOption(
title = "Manual Sign",
subtitle = "Customer signs on screen",
selected = selectedMode == SignatureMode.Manual,
onClick = { selectedMode = SignatureMode.Manual },
modifier = Modifier.fillMaxWidth()
)
Spacer(Modifier.height(12.dp))
SignatureModeOption(
title = "Digital Sign",
subtitle = "Use stored signature",
selected = selectedMode == SignatureMode.Digital,
onClick = { selectedMode = SignatureMode.Digital },
modifier = Modifier.fillMaxWidth()
)
}
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
OutlinedButton(
onClick = { signaturePadAdapter?.clear() },
onClick = { clearSignature() },
modifier = Modifier
.weight(1f)
.height(50.dp)
@ -92,10 +225,13 @@ fun SignaturePad(
Button(
onClick = {
val rawBitmap = signaturePadAdapter?.getSignatureBitmap()
val bitmap = rawBitmap?.let { scaleBitmap(it) }
val bitmap = buildBitmap()
if (selectedMode == SignatureMode.Manual && bitmap == null) {
// nothing drawn yet on Manual mode — block confirm
return@Button
}
val signatureBlob = bitmap?.let { bitmapToBlob(it) }
onConfirm(bitmap, signatureBlob)
onConfirm(selectedMode, bitmap, signatureBlob)
},
modifier = Modifier
.weight(1f)

View File

@ -1,93 +1,74 @@
package com.mob.utsmyanmar.ui.theme
import androidx.compose.ui.text.font.Font
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.mob.utsmyanmar.R
private val LibreBaskerville = FontFamily(
Font(R.font.libre_baskerville_regular, FontWeight.Normal)
)
val Typography = Typography(
displayLarge = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Bold,
fontSize = 32.sp,
lineHeight = 40.sp,
),
displayMedium = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Bold,
fontSize = 30.sp,
lineHeight = 38.sp,
),
headlineLarge = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
lineHeight = 32.sp,
),
headlineMedium = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Bold,
fontSize = 20.sp,
lineHeight = 28.sp,
),
titleLarge = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.SemiBold,
fontSize = 22.sp,
lineHeight = 28.sp,
),
titleMedium = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.SemiBold,
fontSize = 18.sp,
lineHeight = 26.sp,
),
titleSmall = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Medium,
fontSize = 14.sp,
lineHeight = 20.sp,
),
bodyLarge = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
),
bodyMedium = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
lineHeight = 20.sp,
),
bodySmall = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Normal,
fontSize = 12.sp,
lineHeight = 16.sp,
),
labelLarge = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Medium,
fontSize = 14.sp,
lineHeight = 20.sp,
),
labelMedium = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Medium,
fontSize = 12.sp,
lineHeight = 16.sp,
),
labelSmall = TextStyle(
fontFamily = LibreBaskerville,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,

View File

@ -2,7 +2,6 @@ package com.mob.utsmyanmar.ui.tms_setup
import android.annotation.SuppressLint
import android.content.Context
import androidx.core.content.edit
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.mob.utsmyanmar.model.sirius.SiriusResponse
@ -49,7 +48,7 @@ class TmsSetupViewModel @Inject constructor(
private val emvParamOperation: EmvParamOperation,
@ApplicationContext private val context: Context
) : ViewModel() {
private val TAG = TmsSetupViewModel::class.simpleName;
private val _uiState = MutableStateFlow(TmsSetupUiState())
private val _dashboardUiState = MutableStateFlow(DashboardUiState())
val uiState: StateFlow<TmsSetupUiState> = _uiState.asStateFlow()
@ -145,27 +144,19 @@ class TmsSetupViewModel @Inject constructor(
val ops = SystemParamsOperation.getInstance()
if (!ops.isActive) {
LogUtil.d(TAG, "isActive ${ops.isActive}")
val msg = ops.disabledMsg.takeIf { it.isNotEmpty() }
?: "This terminal has been disabled. Please contact your administrator."
_uiState.update {
it.copy(
isLoading = false,
isError = true,
isTerminalDisabled = true,
statusText = "Terminal Disabled",
errorMessage = msg
)
}
_uiState.update { it.copy(isLoading = false) }
viewModelScope.launch { _navigateToDisable.emit(msg) }
return
}
val validity = TMSUtil.getInstance().checkParams()
if (validity.status == ValidityStatus.SUCCESS) {
context.getSharedPreferences("mobpos_prefs", Context.MODE_PRIVATE)
.edit {
putLong("last_sync_time", System.currentTimeMillis())
}
.edit()
.putLong("last_sync_time", System.currentTimeMillis())
.apply()
_uiState.update { it.copy(isLoading = false, statusText = "Ready.") }
viewModelScope.launch {
_onSyncCompleted.emit(Unit)

View File

@ -24,8 +24,6 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.mob.utsmyanmar.ui.preview.P2Preview
import com.mob.utsmyanmar.ui.theme.Color
import com.mob.utsmyanmar.utils.toFormattedDate
import com.mob.utsmyanmar.utils.toFormattedTime
import com.utsmyanmar.paylibs.model.PayDetail
import com.utsmyanmar.paylibs.print.PrintReceipt
import com.utsmyanmar.paylibs.utils.POSUtil
@ -84,8 +82,8 @@ fun TransactionResultScreen(
Spacer(modifier = Modifier.height(16.dp))
InfoCard(
date = "${state.payDetail?.transDate?.toFormattedDate()}",
time = "${state.payDetail?.transTime?.toFormattedTime()}",
date = "26 May 2026",
time = "12:06 PM",
transactionId = state.payDetail?.referNo.toString()
)

View File

@ -6,6 +6,7 @@ import com.mob.utsmyanmar.model.ecr.ECRResultStatus
import com.mob.utsmyanmar.utils.CoreUtils
import com.mob.utsmyanmar.viewmodel.SharedViewModel
import com.utsmyanmar.baselib.emv.EmvParamOperation
import com.utsmyanmar.baselib.network.model.sirius.SiriusRequest
import com.utsmyanmar.ecr.ECRHelper
import com.utsmyanmar.ecr.ECRProcess
import com.utsmyanmar.ecr.data.model.TransactionsResp

View File

@ -1,18 +0,0 @@
package com.mob.utsmyanmar.utils
import java.text.SimpleDateFormat
import java.util.Locale
fun String.toFormattedDate(): String {
val inputFormat = SimpleDateFormat("dd/MM/yy", Locale.ENGLISH)
val outputFormat = SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH)
val date = inputFormat.parse(this)
return outputFormat.format(date!!)
}
fun String.toFormattedTime(): String {
val inputFormat = SimpleDateFormat("HH:mm:ss", Locale.ENGLISH)
val outputFormat = SimpleDateFormat("hh:mm a", Locale.ENGLISH)
val time = inputFormat.parse(this)
return outputFormat.format(time!!)
}

View File

@ -131,7 +131,7 @@ class TMSSetupsImpl : TMSSetups {
}
//Properties
for (prop in siriusProperty) {
for (prop in siriusProperty.orEmpty()) {
val name = prop.name
val data = prop.property
@ -221,7 +221,6 @@ class TMSSetupsImpl : TMSSetups {
"speedup_contactless_enable" -> ops.setSpeedUpContactless(parseBoolean(data))
"manual_entry_pin_enable" -> ops.isManualEntryPinEnable = parseBoolean(data)
"cmhl_enabled" -> ops.setCMHLEnable(parseBoolean(data))
"mmqr_enable" -> ops.setMmqrStatus(parseBoolean(data))
}
}
ops.carouselUrls = imgUrls.joinToString(",")

View File

@ -4,7 +4,6 @@ import android.os.Handler
import android.os.Looper
import android.os.Message
import android.text.TextUtils
import com.mob.utsmyanmar.model.TransResultStatus
import com.utsmyanmar.baselib.emv.EmvParamOperation
import com.utsmyanmar.baselib.repo.Repository
import com.utsmyanmar.baselib.util.enums.EmvResultStatus
@ -25,6 +24,7 @@ import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
import dagger.hilt.android.lifecycle.HiltViewModel
import sunmi.sunmiui.utils.LogUtil
import javax.inject.Inject
import com.mob.utsmyanmar.model.TransResultStatus
@HiltViewModel
class EmvTransactionProcessViewModel @Inject constructor(

View File

@ -3,7 +3,6 @@ package com.mob.utsmyanmar.viewmodel
import android.content.Context
import android.text.TextUtils
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.mob.utsmyanmar.model.TransResultStatus
import com.mob.utsmyanmar.ui.sending_to_host.ProcessingState
import com.utsmyanmar.baselib.repo.Repository
@ -20,10 +19,8 @@ import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
@HiltViewModel
@ -213,11 +210,8 @@ class TransProcessViewModel @Inject constructor(
TransResultStatus.REVERSAL_PREPARE
_state.value = _state.value.copy("Preparing Reversal")
viewModelScope.launch {
delay(10_000L)
callReversal(tradeData)
}
}
override fun onError(message: String) {

View File

@ -1,15 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="152.4dp"
android:height="108dp"
android:viewportWidth="152.4"
android:viewportHeight="108">
<path
android:pathData="M60.4,25.7h31.5v56.6h-31.5z"
android:fillColor="#FF5F00"/>
<path
android:pathData="M62.4,54c0,-11 5.1,-21.5 13.7,-28.3c-15.6,-12.3 -38.3,-9.6 -50.6,6.1C13.3,47.4 16,70 31.7,82.3c13.1,10.3 31.4,10.3 44.5,0C67.5,75.5 62.4,65 62.4,54z"
android:fillColor="#EB001B"/>
<path
android:pathData="M134.4,54c0,19.9 -16.1,36 -36,36c-8.1,0 -15.9,-2.7 -22.2,-7.7c15.6,-12.3 18.3,-34.9 6,-50.6c-1.8,-2.2 -3.8,-4.3 -6,-6c15.6,-12.3 38.3,-9.6 50.5,6.1C131.7,38.1 134.4,45.9 134.4,54z"
android:fillColor="#F79E1B"/>
</vector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

File diff suppressed because one or more lines are too long

View File

@ -1,18 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="800dp"
android:height="800dp"
android:viewportWidth="750"
android:viewportHeight="471">
<path
android:pathData="M278.2,334.23l33.36,-195.76h53.36l-33.38,195.76H278.2L278.2,334.23z"
android:fillColor="#0E4595"/>
<path
android:pathData="M524.31,142.69c-10.57,-3.97 -27.14,-8.22 -47.82,-8.22c-52.72,0 -89.86,26.55 -90.18,64.6c-0.3,28.13 26.51,43.82 46.75,53.19c20.77,9.6 27.75,15.72 27.65,24.28c-0.13,13.12 -16.59,19.12 -31.92,19.12c-21.35,0 -32.7,-2.97 -50.22,-10.27l-6.88,-3.11l-7.49,43.82c12.46,5.47 35.51,10.2 59.44,10.44c56.09,0 92.5,-26.25 92.92,-66.88c0.2,-22.27 -14.02,-39.22 -44.8,-53.19c-18.65,-9.06 -30.07,-15.1 -29.95,-24.27c0,-8.14 9.67,-16.84 30.56,-16.84c17.45,-0.27 30.09,3.53 39.94,7.5l4.78,2.26L524.31,142.69"
android:fillColor="#0E4595"/>
<path
android:pathData="M661.61,138.46h-41.23c-12.77,0 -22.33,3.49 -27.94,16.23l-79.24,179.4h56.03c0,0 9.16,-24.12 11.23,-29.42c6.12,0 60.56,0.08 68.34,0.08c1.6,6.85 6.49,29.33 6.49,29.33h49.51L661.61,138.46L661.61,138.46zM596.2,264.87c4.41,-11.28 21.26,-54.72 21.26,-54.72c-0.31,0.52 4.38,-11.33 7.07,-18.68l3.61,16.88c0,0 10.22,46.73 12.35,56.53h-44.29V264.87L596.2,264.87z"
android:fillColor="#0E4595"/>
<path
android:pathData="M45.88,138.46L45.2,142.54C66.29,147.64 85.13,155.03 101.62,164.23L148.97,333.91L205.42,333.85L289.43,138.46L232.9,138.46L180.66,271.96L175.1,244.83C174.84,243.99 174.56,243.15 174.27,242.31L156.11,154.99C152.88,142.6 143.51,138.9 131.92,138.46L45.88,138.46z"
android:fillColor="#0e4595"/>
</vector>

View File

@ -1,7 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MOBPOS" parent="android:style/Theme.Material.Light.NoActionBar">
<item name="fontFamily">@font/libre_baskerville_regular</item>
<item name="android:fontFamily">@font/libre_baskerville_regular</item>
</style>
<style name="Theme.MOBPOS" parent="android:style/Theme.Material.Light.NoActionBar"/>
</resources>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">posuat.myanmarorientalbank.com:5033</domain>
</domain-config>
</network-security-config>

View File

@ -1,12 +1,17 @@
package com.utsmyanmar.ecr
import androidx.annotation.Keep
import com.google.gson.Gson
import com.utsmyanmar.ecr.data.ResultOf
import com.utsmyanmar.ecr.data.TransType
import com.utsmyanmar.ecr.data.mapper.RequestTransMapper
import com.utsmyanmar.ecr.data.mapper.ResponseTransMapper
import com.utsmyanmar.ecr.data.model.RequestTrans
import com.utsmyanmar.ecr.data.model.ResponseTrans
import com.utsmyanmar.ecr.data.model.Transactions
import com.utsmyanmar.ecr.data.model.TransactionsResp
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
import java.lang.Exception
//@Keep
object ECRProcess {

View File

@ -503,7 +503,7 @@ public class ISOSocket {
LogUtil.e(Constant.TAG, "E:" + e.toString());
// closeSocket();
closeSocket();
if (isReversal) {
listener.onError(Constant.REVERSAL);
// listener.onError(new ReversalException());
@ -519,7 +519,7 @@ public class ISOSocket {
@Override
public void onComplete() {
LogUtil.d(Constant.TAG, "onComplete");
// closeSocket();
closeSocket();
isReversal = false;
listener.onComplete();
}

View File

@ -1189,11 +1189,10 @@ public class PrintReceipt {
private void printSignature(Bitmap signatureBitmap) {
try {
sunmiPrinterService.setAlignment(1, null);
int targetHeight = 200;
if (signatureBitmap.getHeight() > targetHeight) {
double ratio = 1.0 * targetHeight / signatureBitmap.getHeight();
int newWidth = (int) (signatureBitmap.getWidth() * ratio);
signatureBitmap = BitmapUtils.scale(signatureBitmap, newWidth, targetHeight);
if (signatureBitmap.getWidth() > 130) {
double size = 1.0 * signatureBitmap.getHeight() * 130 / signatureBitmap.getWidth();
int newHeight = (int) size;
signatureBitmap = BitmapUtils.scale(signatureBitmap, 130, newHeight);
}
sunmiPrinterService.printBitmap(signatureBitmap, null);
sunmiPrinterService.printText("\n", null);

View File

@ -50,7 +50,7 @@ public abstract class BaseXPrint {
protected String currentTime;
protected static final String typeface_name = "jetBrainsMonoRegular.ttf";
protected static final String typeface_name = "jbm_semibold.ttf";
protected static final String MPU_AID = "A0000004820000000001";
protected static final String HOST_NAME_VM = "VISA/ MASTERCARD";
@ -954,12 +954,6 @@ public abstract class BaseXPrint {
if (signatureBlob != null && signatureBlob.length > 0) {
Bitmap signatureBitmap = android.graphics.BitmapFactory.decodeByteArray(signatureBlob, 0, signatureBlob.length);
if (signatureBitmap != null) {
int targetHeight = 200;
if (signatureBitmap.getHeight() > targetHeight) {
double ratio = 1.0 * targetHeight / signatureBitmap.getHeight();
int newWidth = (int) (signatureBitmap.getWidth() * ratio);
signatureBitmap = BitmapUtils.scale(signatureBitmap, newWidth, targetHeight);
}
sunmiPrinterService.printBitmap(signatureBitmap, innerResultCallback);
}
}

View File

@ -368,7 +368,7 @@ public class TransactionsOperation {
}
}
} else if (transactionsType == TransactionsType.PRE_AUTH_VOID) {
// newPay.setCardType(oldPay.getCardType());
newPay.setCardType(oldPay.getCardType());
newPay.setCustomOrderNo(oldPay.getVoucherNo());
newPay.setReferNo(oldPay.getReferNo());
newPay.setCardInfo(oldPay.getCardInfo());

View File

@ -1,16 +1,16 @@
package com.utsmyanmar.paylibs.utils.core_utils;
import static com.utsmyanmar.paylibs.utils.core_utils.SystemParamsSettings.TRANSACTION_MANAGER_KEY;
import android.text.TextUtils;
import com.utsmyanmar.paylibs.utils.enums.CurrencyType;
import java.util.ArrayList;
import java.util.Locale;
import sunmi.sunmiui.utils.LogUtil;
import static com.utsmyanmar.paylibs.utils.core_utils.SystemParamsSettings.TRANSACTION_MANAGER_KEY;
import com.utsmyanmar.paylibs.utils.enums.CurrencyType;
public class SystemParamsOperation {
public static final String TAG = "SystemParamsOperation";
@ -33,6 +33,54 @@ public class SystemParamsOperation {
return instance;
}
/* public void init(String serialNumStart,
String batchNumStart,
int purchaseOrderStyle,
int correctFrequency,
int transactionNumber,
boolean printNegative,
int nonConnection,
boolean stateSecret,
boolean shieldAuthorizationCard,
int nonConnectionChoice,
boolean eCashVisaExemption) {
SystemParamsSettings bean = getSystemParamsSettings();
bean.setSerialNum(serialNumStart);
bean.setBatchNumStart(batchNumStart);
bean.setPurchaseOrderStyle(purchaseOrderStyle);
bean.setCorrectFrequency(correctFrequency);
bean.setTransactionNumber(transactionNumber);
bean.setPrintNegative(printNegative);
bean.setNonConnection(nonConnection);
bean.setStateSecret(stateSecret);
bean.setShieldAuthorizationCard(shieldAuthorizationCard);
bean.setNonConnectionChoice(nonConnectionChoice);
bean.setCashVisaExemption(eCashVisaExemption);
saveSystemParamsSettings(bean);
}*/
/*public boolean isDownloadParamsOnce() {
SystemParamsSettings params = getSystemParamsSettings();
return params.isDownloadParamsOnce();
}
public void saveDownloadParamsOnce(boolean downloadParamsOnce) {
SystemParamsSettings params = getSystemParamsSettings();
params.setDownloadParamsOnce(downloadParamsOnce);
saveSystemParamsSettings(params);
}
public boolean isNeedDownLoadICParams() {
SystemParamsSettings params = getSystemParamsSettings();
return params.isNeedDownLoadICParams();
}
public void saveNeedDownLoadICParams(boolean needDownLoadICParams) {
SystemParamsSettings params = getSystemParamsSettings();
params.setNeedDownLoadICParams(needDownLoadICParams);
saveSystemParamsSettings(params);
}*/
public boolean isInjectOnce(){
SystemParamsSettings params = getSystemParamsSettings();
return params.isInjectOnce();
@ -43,6 +91,13 @@ public class SystemParamsOperation {
params.setInjectOnce(injectOnce);
saveSystemParamsSettings(params);
}
/**
* Set serial number
*
* @param serialNumber Starting serial number
*/
public void saveSerialNumber(String serialNumber) {
if (TextUtils.isEmpty(serialNumber)) {
return;
@ -51,6 +106,12 @@ public class SystemParamsOperation {
params.setSerialNum(serialNumber);
saveSystemParamsSettings(params);
}
/**
* Set invoice number
*
* @param invoiceNumber Starting invoice number
*/
public void saveInvoiceNumber(String invoiceNumber) {
if (TextUtils.isEmpty(invoiceNumber)) {
return;
@ -59,6 +120,13 @@ public class SystemParamsOperation {
params.setInvoiceNum(invoiceNumber);
saveSystemParamsSettings(params);
}
/**
* Set batch number
*
* @param batchNumber Starting batch number
*/
public void saveBatchNumber(String batchNumber) {
if (TextUtils.isEmpty(batchNumber)) {
return;
@ -68,6 +136,11 @@ public class SystemParamsOperation {
saveSystemParamsSettings(params);
}
/**
* Serial number increment
*/
private void incrementSerialNum() {
SystemParamsSettings params = getSystemParamsSettings();
String currentSerialNum = params.getCurrentSerialNum();
@ -99,6 +172,10 @@ public class SystemParamsOperation {
params.setSerialNum(transNumFormat);
saveSystemParamsSettings(params);
}
/**
* Invoice number increment
*/
private void incrementInvoiceNum() {
SystemParamsSettings params = getSystemParamsSettings();
String currentInvoiceNum = params.getCurrentInvoiceNum();
@ -875,17 +952,6 @@ public class SystemParamsOperation {
saveSystemParamsSettings(params);
}
public void setMmqrStatus(boolean status) {
SystemParamsSettings params = getSystemParamsSettings();
params.setMmqrEnabled(status);
saveSystemParamsSettings(params);
}
public boolean getMmqrStatus(){
SystemParamsSettings params = getSystemParamsSettings();
return params.getMmqrEnabled();
}
public boolean isCMHLEnabled(){
SystemParamsSettings params = getSystemParamsSettings();
return params.isCmhlEnabled();

View File

@ -38,7 +38,7 @@ public class SystemParamsSettings implements Serializable {
private boolean checkExpSwitch = false;
// private String tmsAddress = "https://posmgmt.myanmarorientalbank.com/api/v1";
// private String tmsAddress = "http://posuat.myanmarorientalbank.com:5033";
private String tmsAddress = "https://sirius-nest.utsmyanmar.com/api/v1";
// private String tmsAddress = "http://128.199.170.203";
@ -55,7 +55,6 @@ public class SystemParamsSettings implements Serializable {
private String merchantName = "";
private String receiptHeader = "";
private String merchantAddress = "";
@ -233,7 +232,6 @@ public class SystemParamsSettings implements Serializable {
private byte[] pik_value;
private byte[] pik_kcv;
private boolean mmqrEnabled;
protected String getSecHostName() {
return secHostName;
@ -903,14 +901,6 @@ public class SystemParamsSettings implements Serializable {
this.emvEnabled = emvEnabled;
}
public void setMmqrEnabled(boolean status) {
this.mmqrEnabled = status;
}
public boolean getMmqrEnabled(){
return mmqrEnabled;
}
/* // 流水号起始
private String serialNum = Configs.getInstance().SERIAL_NUM();
// 批次号起始

View File

@ -117,10 +117,7 @@ public class HostUtils {
msgType = MessageType.AUTHORIZATION;
}
break;
case PRE_AUTH_VOID:
case PRE_AUTH_COMPLETE:
if (hostName == HostName.BPC) {
msgType = MessageType.FINANCIAL;
@ -145,11 +142,11 @@ public class HostUtils {
break;
case VOID:
case PRE_AUTH_VOID:
if(isVisaMaster) {
msgType = MessageType.REVERSAL;
break;
}
default:
msgType = MessageType.FINANCIAL;
break;

View File

@ -198,8 +198,7 @@ public class BitmapConfig {
public static final String CZ_REVERSAL="7020078000C08000";
public static final String CZ_BATCH_UPLOAD="703805800CC00010";
public static final String CZ_PRE_AUTH="7020058020C09000";
// public static final String CZ_PRE_AUTH_VOID="7038058028C08000";
public static final String CZ_PRE_AUTH_VOID="703C058008C08000";
public static final String CZ_PRE_AUTH_VOID="7038058028C08000";
public static final String CZ_PRE_AUTH_COMP="703805802CC08000";
public static final String CZ_PRE_AUTH_COMP_VOID="7038058008C00000";

View File

@ -361,12 +361,7 @@ public class FieldUtils {
// } else {
// iterator.remove();
// }
if(payDetail.getTransactionType() == REVERSAL.value) {
field.setDataStr("001");
} else {
field.setDataStr("000");
}
break;
case 24: //Network International Identifier NII
@ -381,10 +376,10 @@ public class FieldUtils {
08 – mail order/telephone order
* */
// Service point condition code Fill in 00 for ordinary consumer transactions and mobile phone chip transactions, fill in 08 for order consumer transactions, fill in 64 for installment transactions, fill in 65 for points consumption transactions, fill in 67 for mobile phone card-free reservations
// do not remove double check for preauth, it's control for reversal
if (payDetail.getTransactionType() == PRE_AUTH_SALE.value || payDetail.getTransType().equals(PRE_AUTH_SALE.name)) {
if (payDetail.getTransactionType() == PRE_AUTH_SALE.value) {
field.setDataStr("06");
} else if(payDetail.getTransactionType() == REFUND.value || payDetail.getTransType().equals(REFUND.name) ) {
}
else if(payDetail.getTransactionType() == REFUND.value || payDetail.getTransactionType() == REVERSAL.value) {
// field.setDataStr("00"); // MPU
field.setDataStr("61"); // CZ
} else if(payDetail.getCardType() == -1) {