tmsSetupsImpl
This commit is contained in:
parent
68dd5eebd7
commit
86998e1fe2
@ -0,0 +1,14 @@
|
|||||||
|
package com.mob.utsmyanmar.model.sirius
|
||||||
|
|
||||||
|
import com.utsmyanmar.baselib.network.model.sirius.SiriusHost
|
||||||
|
import com.utsmyanmar.baselib.network.model.sirius.SiriusMerchant
|
||||||
|
import com.utsmyanmar.baselib.network.model.sirius.SiriusProperty
|
||||||
|
|
||||||
|
data class SiriusResponse (
|
||||||
|
var serial: String,
|
||||||
|
var ecrKey: String,
|
||||||
|
var address: String,
|
||||||
|
var merchant : SiriusMerchant,
|
||||||
|
var hosts : List<SiriusHost>,
|
||||||
|
var properties: List<SiriusProperty>
|
||||||
|
)
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.mob.utsmyanmar.model.sirius
|
||||||
|
|
||||||
|
enum class TMSUpdate {
|
||||||
|
UPDATE,
|
||||||
|
CHECK
|
||||||
|
}
|
||||||
@ -37,6 +37,8 @@ import com.mob.utsmyanmar.ui.pinpad.PinPadViewModel
|
|||||||
import com.mob.utsmyanmar.ui.settlement.SettlementViewModel
|
import com.mob.utsmyanmar.ui.settlement.SettlementViewModel
|
||||||
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultEvent
|
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultEvent
|
||||||
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultViewModel
|
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultViewModel
|
||||||
|
import com.mob.utsmyanmar.ui.tms_setup.TmsSetupRoute
|
||||||
|
import com.mob.utsmyanmar.ui.tms_setup.TmsSetupViewModel
|
||||||
import com.mob.utsmyanmar.ui.version.VersionScreen
|
import com.mob.utsmyanmar.ui.version.VersionScreen
|
||||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||||
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
||||||
@ -52,8 +54,23 @@ fun AppNavGraph(
|
|||||||
|
|
||||||
NavHost(
|
NavHost(
|
||||||
navController = navController,
|
navController = navController,
|
||||||
startDestination = Routes.Dashboard.route
|
startDestination = Routes.TmsSetup.route
|
||||||
) {
|
) {
|
||||||
|
composable(Routes.TmsSetup.route) {
|
||||||
|
val tmsSetupViewModel: TmsSetupViewModel = hiltViewModel()
|
||||||
|
TmsSetupRoute(
|
||||||
|
viewModel = tmsSetupViewModel,
|
||||||
|
onNavigateDashboard = {
|
||||||
|
navController.navigate(Routes.Dashboard.route) {
|
||||||
|
popUpTo(Routes.TmsSetup.route) {
|
||||||
|
inclusive = true
|
||||||
|
}
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
composable(Routes.Dashboard.route) {
|
composable(Routes.Dashboard.route) {
|
||||||
val sharedViewModel: SharedViewModel = hiltViewModel(activity);
|
val sharedViewModel: SharedViewModel = hiltViewModel(activity);
|
||||||
DashboardScreen2(
|
DashboardScreen2(
|
||||||
|
|||||||
25
app/src/main/java/com/mob/utsmyanmar/utils/tms/TMSSetups.kt
Normal file
25
app/src/main/java/com/mob/utsmyanmar/utils/tms/TMSSetups.kt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.mob.utsmyanmar.utils.tms
|
||||||
|
|
||||||
|
import com.mob.utsmyanmar.model.sirius.SiriusResponse
|
||||||
|
import com.mob.utsmyanmar.model.sirius.TMSUpdate
|
||||||
|
import com.utsmyanmar.baselib.emv.EmvParamOperation
|
||||||
|
|
||||||
|
interface TMSSetups {
|
||||||
|
|
||||||
|
fun initParams(
|
||||||
|
siriusResponse: SiriusResponse,
|
||||||
|
tmsUpdate: TMSUpdate,
|
||||||
|
emvParamOperation: EmvParamOperation
|
||||||
|
)
|
||||||
|
|
||||||
|
fun initParams(json: String)
|
||||||
|
|
||||||
|
fun convertToArray(string: String): ArrayList<String>
|
||||||
|
|
||||||
|
fun getPayHardwareVersion(): String
|
||||||
|
|
||||||
|
fun getRomVersion(): String
|
||||||
|
|
||||||
|
fun generateFinalVersion(): String
|
||||||
|
|
||||||
|
}
|
||||||
255
app/src/main/java/com/mob/utsmyanmar/utils/tms/TMSSetupsImpl.kt
Normal file
255
app/src/main/java/com/mob/utsmyanmar/utils/tms/TMSSetupsImpl.kt
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
package com.mob.utsmyanmar.utils.tms
|
||||||
|
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.mob.utsmyanmar.model.sirius.SiriusResponse
|
||||||
|
import com.mob.utsmyanmar.model.sirius.TMSUpdate
|
||||||
|
import com.utsmyanmar.baselib.emv.EmvParamOperation
|
||||||
|
import com.utsmyanmar.baselib.network.model.sirius.SiriusHost
|
||||||
|
import com.utsmyanmar.baselib.network.model.sirius.SiriusMerchant
|
||||||
|
import com.utsmyanmar.baselib.network.model.sirius.SiriusProperty
|
||||||
|
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
|
||||||
|
import com.utsmyanmar.paylibs.utils.enums.CurrencyType
|
||||||
|
import sunmi.sunmiui.utils.LogUtil
|
||||||
|
|
||||||
|
class TMSSetupsImpl : TMSSetups {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val TAG = "TMSSetupsImpl"
|
||||||
|
private const val UPI = "UPI"
|
||||||
|
private const val JCB = "JCB"
|
||||||
|
private const val VISA = "VISA"
|
||||||
|
private const val MASTERCARD = "MASTERCARD"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun currencyTextToCurrencyType(currencyText: String): CurrencyType {
|
||||||
|
return try {
|
||||||
|
CurrencyType.valueOf(currencyText)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
CurrencyType.MMK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun currencyTextToCode(currencyText: String): String {
|
||||||
|
return when (currencyText) {
|
||||||
|
"USD" -> "804"
|
||||||
|
"CNY" -> "156"
|
||||||
|
"THB" -> "764"
|
||||||
|
"RUB" -> "643"
|
||||||
|
else -> "104"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun currencyCodeToText(currencyCode: String): String {
|
||||||
|
return when (currencyCode) {
|
||||||
|
"804" -> "USD"
|
||||||
|
"156" -> "CNY"
|
||||||
|
"764" -> "THB"
|
||||||
|
"643" -> "RUB"
|
||||||
|
else -> "MMK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun init() {
|
||||||
|
SystemParamsOperation.getInstance().apply {
|
||||||
|
hostName = ""
|
||||||
|
terminalId = ""
|
||||||
|
merchantId = ""
|
||||||
|
ipAddress = ""
|
||||||
|
secIpAddress = ""
|
||||||
|
|
||||||
|
secHostName = ""
|
||||||
|
secHostTerminalId = ""
|
||||||
|
secHostMerchantId = ""
|
||||||
|
secHostIpAddress = ""
|
||||||
|
secHostSecIpAddress = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun initParams(
|
||||||
|
siriusResponse: SiriusResponse,
|
||||||
|
tmsUpdate: TMSUpdate,
|
||||||
|
emvParamOperation: EmvParamOperation
|
||||||
|
) {
|
||||||
|
val siriusMerchant: SiriusMerchant = siriusResponse.merchant
|
||||||
|
val siriusHosts: List<SiriusHost> = siriusResponse.hosts
|
||||||
|
val siriusProperty: List<SiriusProperty> = siriusResponse.properties
|
||||||
|
val imgUrls = mutableListOf<String>()
|
||||||
|
val ops = SystemParamsOperation.getInstance()
|
||||||
|
|
||||||
|
if (tmsUpdate == TMSUpdate.UPDATE) ops.isNeedSettlement = false
|
||||||
|
|
||||||
|
siriusResponse.address.takeIf { it.isEmpty() }?.let { ops.merchantAddress = "" }
|
||||||
|
|
||||||
|
init()
|
||||||
|
|
||||||
|
siriusMerchant.let { m ->
|
||||||
|
ops.merchantName = m.name
|
||||||
|
ops.merchantAddress = m.address
|
||||||
|
ops.merchantPhoneNo = m.phone
|
||||||
|
}
|
||||||
|
|
||||||
|
siriusResponse.address.takeIf { it.isNotEmpty() }?.let { ops.merchantAddress = it }
|
||||||
|
//host
|
||||||
|
if (siriusHosts.isNotEmpty()) {
|
||||||
|
for (host in siriusHosts) {
|
||||||
|
val isMMQR = listOf(host.name, host.description).any {
|
||||||
|
it.lowercase().run { contains("mmqr") }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMMQR) {
|
||||||
|
ops.secHostName = host.name
|
||||||
|
ops.secHostTerminalId = host.tid
|
||||||
|
ops.secHostMerchantId = host.mid
|
||||||
|
|
||||||
|
host.secondaryIP.trim().let { ip ->
|
||||||
|
ops.secHostIpAddress = if (ip.contains(":")) "$ip/" else ""
|
||||||
|
}
|
||||||
|
host.currency.takeIf { it.isNotEmpty() }?.let {
|
||||||
|
ops.secHostCurrency = currencyTextToCode(it)
|
||||||
|
}
|
||||||
|
if (host.tid.isEmpty()) ops.secHostTerminalId = ""
|
||||||
|
if (host.mid.isEmpty()) ops.secHostTerminalId = ""
|
||||||
|
} else {
|
||||||
|
ops.hostName = host.name
|
||||||
|
ops.terminalId = host.tid
|
||||||
|
ops.merchantId = host.mid
|
||||||
|
|
||||||
|
host.primaryIP.trim().let { ip ->
|
||||||
|
ops.ipAddress = if (ip.contains(":")) ip else ""
|
||||||
|
}
|
||||||
|
host.secondaryIP.trim().let { ip ->
|
||||||
|
ops.secIpAddress = if (ip.contains(":")) ip else ""
|
||||||
|
}
|
||||||
|
host.currency.takeIf { it.isNotEmpty() }?.let {
|
||||||
|
ops.currencyType = currencyTextToCurrencyType(it)
|
||||||
|
}
|
||||||
|
if (host.tid.isEmpty()) ops.terminalId = ""
|
||||||
|
if (host.mid.isEmpty()) ops.merchantId = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Properties
|
||||||
|
for (prop in siriusProperty) {
|
||||||
|
val name = prop.name
|
||||||
|
val data = prop.property
|
||||||
|
|
||||||
|
when (name) {
|
||||||
|
//image
|
||||||
|
"carousel_img_1",
|
||||||
|
"carousel_img_2",
|
||||||
|
"carousel_img_3",
|
||||||
|
"carousel_img_4",
|
||||||
|
"carousel_img_5",
|
||||||
|
"carousel_img_6" -> imgUrls.add(data)
|
||||||
|
|
||||||
|
//host
|
||||||
|
"host_timeout",
|
||||||
|
"host_connect_timeout" -> ops.hostResponseTimeout = data
|
||||||
|
|
||||||
|
"host_read_timeout" -> ops.hostReadTimeout = data
|
||||||
|
"reversal_delay" -> ops.reversalDelay = data
|
||||||
|
"key_index" -> ops.tmkIndex = data
|
||||||
|
"receipt_footer" -> ops.receiptFooter = data
|
||||||
|
"time_out" -> ops.setTmsTimeout(data)
|
||||||
|
"manual_update" -> ops.manualUpdate = parseBoolean(data)
|
||||||
|
"emv_enable" -> ops.setEmvEnable(parseBoolean(data))
|
||||||
|
"hostport" -> ops.portAddress = data.toInt()
|
||||||
|
"pre_auth_enable" -> ops.preAuthStatus = parseBoolean(data)
|
||||||
|
"void_enable" -> ops.voidStatus = parseBoolean(data)
|
||||||
|
"cash_advance_enable" -> ops.cashAdvanceStatus = parseBoolean(data)
|
||||||
|
"refund_enable" -> ops.refundStatus = parseBoolean(data)
|
||||||
|
"settlement_enable" -> ops.settlementStatus = parseBoolean(data)
|
||||||
|
"system_password" -> ops.systemPassword = data.take(6).ifEmpty { data }
|
||||||
|
"settlement_password" -> ops.settlementPassword = data.take(6).ifEmpty { data }
|
||||||
|
"setting_password" -> ops.settingPassword = data.take(6).ifEmpty { data }
|
||||||
|
"terminal_enable" -> ops.isActive = parseBoolean(data)
|
||||||
|
"terminal_enable_msg" -> ops.disabledMsg = data
|
||||||
|
"ssl_enable" -> ops.setSslSwitchStatus(parseBoolean(data))
|
||||||
|
"wave_pay_inquiry_status_enable" -> ops.wavePayInquiryStatus = parseBoolean(data)
|
||||||
|
"tips_adjustment_enable" -> ops.tipsAdjustmentStatus = parseBoolean(data)
|
||||||
|
"wave_enable" -> ops.wavePayStatus = parseBoolean(data)
|
||||||
|
"print_iso_enable" -> ops.printISOStatus = parseBoolean(data)
|
||||||
|
"receipt_header" -> ops.receiptHeader = data
|
||||||
|
"random_pin_pad_enable" -> ops.isRandomPinPad = parseBoolean(data)
|
||||||
|
"clear_batch_time" -> ops.clearBatchTime = data
|
||||||
|
"alert_sound_enable" -> ops.isAlertSound = parseBoolean(data)
|
||||||
|
"auto_print_enable" -> ops.isAutoPrintCustomerCopy = parseBoolean(data)
|
||||||
|
"ecr_enable" -> ops.ecrStatus = parseBoolean(data)
|
||||||
|
"manual_entry_enable" -> ops.setManualEntyrStatus(parseBoolean(data))
|
||||||
|
"mmqr_interval_waiting_time" -> ops.waveIntervalTime = data
|
||||||
|
"full_void_preauth_enable" -> ops.fullVoidPreauthStatus = parseBoolean(data)
|
||||||
|
"partial_void_preauth_enable" -> ops.partialVoidPreauthStatus = parseBoolean(data)
|
||||||
|
"clear_batch_day" -> ops.clearBatchDay = data
|
||||||
|
"qr_min_amount" -> ops.minAmount = data
|
||||||
|
"qr_max_amount" -> ops.maxAmount = data
|
||||||
|
"mmqr_auth_token" -> ops.authToken = data
|
||||||
|
"mmqr_grant_type" -> ops.grantType = data
|
||||||
|
"mmqr_token_host_address" -> ops.tokenHostAddress = "${data.trim()}/"
|
||||||
|
"mmpay_enable" -> ops.isMMPayEnabled = parseBoolean(data)
|
||||||
|
"fallback_enable" -> ops.fallbackEnabled = parseBoolean(data)
|
||||||
|
"magstripe_enable" -> ops.isMagStripeEnabled = parseBoolean(data)
|
||||||
|
"nfc_enable" -> ops.isNfcEnabled = parseBoolean(data)
|
||||||
|
"cvv_bypass_enable" -> ops.cvvBypassStatus = parseBoolean(data)
|
||||||
|
"upi_chip_cvm" -> emvParamOperation.updateChipCVM(UPI, data.toLong())
|
||||||
|
"upi_contactless_cvm" -> {
|
||||||
|
val limit = data.toLong()
|
||||||
|
ops.upiCvmLimit = limit
|
||||||
|
emvParamOperation.updateUpiCVM(limit)
|
||||||
|
}
|
||||||
|
|
||||||
|
"upi_currency_code" -> emvParamOperation.updateUpiCurrencyCode(data)
|
||||||
|
"jcb_chip_cvm" -> emvParamOperation.updateChipCVM(JCB, data.toLong())
|
||||||
|
"visa_chip_cvm" -> emvParamOperation.updateChipCVM(VISA, data.toLong())
|
||||||
|
"visa_contactless_cvm" -> emvParamOperation.updatePayWaveCVM(data.toLong())
|
||||||
|
"visa_currency_code" -> emvParamOperation.updatePayWaveCurrencyCode(data)
|
||||||
|
"master_chip_cvm" -> emvParamOperation.updateChipCVM(MASTERCARD, data.toLong())
|
||||||
|
"master_contactless_cvm" -> emvParamOperation.updatePayPassCVM(data.toLong())
|
||||||
|
"master_currency_code" -> emvParamOperation.updatePayPassCurrencyCode(data)
|
||||||
|
"terminal_capability" -> {
|
||||||
|
if (data.isNotEmpty()) ops.setTerminalCapability(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
"upi_ttq" -> emvParamOperation.updateQuickPassTTQ(data)
|
||||||
|
"visa_ttq" -> emvParamOperation.updatePayWaveTTQ(data)
|
||||||
|
"master_ttq" -> emvParamOperation.updatePayPassTTQ(data)
|
||||||
|
"upi_tc_enabled" -> ops.setUpiTCEnabled(parseBoolean(data))
|
||||||
|
"debug_feature_enable" -> ops.setDebugFeatureEnabled(parseBoolean(data))
|
||||||
|
"master_terminal_capability" -> {
|
||||||
|
if (data.isNotEmpty()) emvParamOperation.updatePayPassTerminalCapability(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
"speedup_contactless_enable" -> ops.setSpeedUpContactless(parseBoolean(data))
|
||||||
|
"manual_entry_pin_enable" -> ops.isManualEntryPinEnable = parseBoolean(data)
|
||||||
|
"cmhl_enabled" -> ops.setCMHLEnable(parseBoolean(data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ops.carouselUrls = imgUrls.joinToString(",")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun initParams(json: String) {
|
||||||
|
val response = Gson().fromJson<SiriusResponse>(json, SiriusResponse::class.java)
|
||||||
|
response.properties.forEach { prop ->
|
||||||
|
LogUtil.d(TAG, "name : ${prop.name}")
|
||||||
|
LogUtil.d(TAG, "value: ${prop.property}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun convertToArray(string: String): ArrayList<String> {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getPayHardwareVersion(): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getRomVersion(): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun generateFinalVersion(): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
private fun parseBoolean(data: String): Boolean =
|
||||||
|
data.toIntOrNull()?.let { it == 1 } ?: data.toBoolean();
|
||||||
|
}
|
||||||
@ -38,7 +38,7 @@ public class SystemParamsSettings implements Serializable {
|
|||||||
|
|
||||||
private boolean checkExpSwitch = false;
|
private boolean checkExpSwitch = false;
|
||||||
|
|
||||||
private String tmsAddress = "https://tms.smile-mm.com";
|
private String tmsAddress = "https://sirius-nest.utsmyanmar.com";
|
||||||
// private String tmsAddress = "http://128.199.170.203";
|
// private String tmsAddress = "http://128.199.170.203";
|
||||||
|
|
||||||
private String terminalCapability = "E0E8C8";
|
private String terminalCapability = "E0E8C8";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user