diff --git a/build.gradle.kts b/build.gradle.kts index ba5b4c8..526c725 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,9 +28,9 @@ dependencies { implementation("io.ktor:ktor-server-netty-jvm") implementation("ch.qos.logback:logback-classic:$logback_version") implementation("com.oracle.database.jdbc:ojdbc8:21.1.0.0") + implementation("org.json:json:20240303") implementation("com.squareup.okhttp3:okhttp:4.12.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") - implementation("redis.clients:jedis:5.1.2") implementation("org.slf4j:slf4j-api:2.0.16") testImplementation("io.ktor:ktor-server-test-host-jvm") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") diff --git a/src/main/kotlin/net/ipksindia/Application.kt b/src/main/kotlin/net/ipksindia/Application.kt index f267697..ee2dfe0 100644 --- a/src/main/kotlin/net/ipksindia/Application.kt +++ b/src/main/kotlin/net/ipksindia/Application.kt @@ -6,7 +6,7 @@ import io.ktor.server.netty.* import net.ipksindia.plugins.* fun main() { - embeddedServer(Netty, port = 8082, host = "0.0.0.0", module = Application::module) + embeddedServer(Netty, port = 8083, host = "0.0.0.0", module = Application::module) .start(wait = true) } diff --git a/src/main/kotlin/net/ipksindia/NeftRequestProcessor.kt b/src/main/kotlin/net/ipksindia/NeftRequestProcessor.kt index 4d4f984..75a7493 100644 --- a/src/main/kotlin/net/ipksindia/NeftRequestProcessor.kt +++ b/src/main/kotlin/net/ipksindia/NeftRequestProcessor.kt @@ -11,11 +11,11 @@ class NeftRequestProcessor { companion object { private val logger: Logger = LoggerFactory.getLogger(NeftRequestProcessor::class.java) - private val migratedDCCBCodes = listOf("0003","0015", "0016") + private val migratedDCCBCodes = listOf("0003","0015") val bankDccbToSftpMap = mutableMapOf( "0015" to "0005", //Tamluk "0003" to "0021", //Balageria - "0016" to "0001", //WBSCB +// "0016" to "0001", //WBSCB ) fun process(transactionNumber: String): Pair? { @@ -39,7 +39,9 @@ class NeftRequestProcessor { logger.error("TXN: #{} FAILED REASON: Teller not found", transactionNumber) return null } + val transactionPair = TransactionFactory(outwardTransaction, makerTeller).createTransactionPair() + logger.info("TXN: #{} TRANSFER RRN: {} NEFT RRN: {}", transactionNumber, transactionPair.first.rrn, transactionPair.second.rrn) val (transferResponse, neftResponse) = try { TransactionExecutor().executePair(transactionPair) } catch (e: Exception) { diff --git a/src/main/kotlin/net/ipksindia/TransactionExecutor.kt b/src/main/kotlin/net/ipksindia/TransactionExecutor.kt index 0b50e80..86aa5eb 100644 --- a/src/main/kotlin/net/ipksindia/TransactionExecutor.kt +++ b/src/main/kotlin/net/ipksindia/TransactionExecutor.kt @@ -19,7 +19,7 @@ import javax.net.ssl.HostnameVerifier class TransactionExecutor() { private val protocol = "https" - private val host = "180.179.119.227" + private val host = "180.179.110.185" private val port = "443" private val rootRoute = "IPKS_Queue_Generation" private val remoteUrl = "$protocol://$host:$port/$rootRoute" @@ -28,14 +28,15 @@ class TransactionExecutor() { val transferTransaction = transactionPair.first val neftTransaction = transactionPair.second + val transferResponse = execute(Json.encodeToString(transferTransaction)) val neftResponse = execute(Json.encodeToString(neftTransaction)) return Pair(transferResponse, neftResponse) } private fun execute(postBody: String): TransactionResponse { - - val transferRoute = "Ipks" +// println(postBody) + val transferRoute = "IpksApi" val transferURL = "$remoteUrl/$transferRoute" val jsonMediaType = "application/json; charset=utf-8".toMediaType() @@ -52,9 +53,9 @@ class TransactionExecutor() { val responseBody = httpClient.newCall(request).execute().use { response -> if (!response.isSuccessful) { - throw IOException("Unexpected code $response") + throw IOException("Unexpected response: ${response.body}") } - response.body!!.string() + response.body?.string() ?: throw IOException("no response body") } val responseObj = JSONObject(responseBody) @@ -66,7 +67,7 @@ class TransactionExecutor() { val queueNo = try { responseObj.getJSONObject("response").getString("QueueId") } catch(_: JSONException) { "" } return TransactionSuccessResponse(status, message, queueNo, error) } else { - val errorMsg = try { responseObj.getJSONObject("response").getString("errorMsg") } catch(_: JSONException) { "no error message provided" } + val errorMsg = try { responseObj.getJSONObject("response").getString("errorMsg") } catch(_: JSONException) { responseBody } return TransactionFailureResponse(status, message, errorMsg, error) } return response diff --git a/src/main/kotlin/net/ipksindia/TransactionFactory.kt b/src/main/kotlin/net/ipksindia/TransactionFactory.kt index 817770b..9316a53 100644 --- a/src/main/kotlin/net/ipksindia/TransactionFactory.kt +++ b/src/main/kotlin/net/ipksindia/TransactionFactory.kt @@ -17,6 +17,7 @@ class TransactionFactory(private val transactionRequest: TransactionRequest, pri return TransferTransaction( bankCode = bankDccbToSftpMap[transactionRequest.dccbCode.padStart(4, '0')]!!, branchCode = transactionRequest.branchCode.padStart(3,'0'), +// branchCode = "99999", for UAT cbsTellerId = teller.tellerId, cbsTellerUserType = teller.userType, queIdType = "5", @@ -44,6 +45,7 @@ class TransactionFactory(private val transactionRequest: TransactionRequest, pri return NeftTransaction( bankCode = bankDccbToSftpMap[transactionRequest.dccbCode.padStart(4, '0')]!!, branchCode = transactionRequest.branchCode.padStart(3,'0'), +// branchCode = "99999", for UAT cbsTellerId = teller.tellerId, cbsTellerUserType = teller.userType, queIdType = "5", diff --git a/src/main/kotlin/net/ipksindia/dao/TellerDao.kt b/src/main/kotlin/net/ipksindia/dao/TellerDao.kt index 1d689fa..c52f08f 100644 --- a/src/main/kotlin/net/ipksindia/dao/TellerDao.kt +++ b/src/main/kotlin/net/ipksindia/dao/TellerDao.kt @@ -7,39 +7,48 @@ class TellerDao { private val tellerMap = mapOf( "0003" to mapOf( - "00008" to "8", - "00022" to "22", - "00012" to "12", - "00014" to "14", - "00003" to "1003", - "00015" to "15", - "00013" to "13", - "00018" to "18", - "00001" to "1001", - "00004" to "4", - "00017" to "1234", - "00005" to "5", - "00011" to "11", - "00020" to "1234", - "00021" to "1234", - "00016" to "016", - "00009" to "9", - "00010" to "10", - "00007" to "7", - "00006" to "6", + "00012" to "312", + "00017" to "317", + "00013" to "313", + "00014" to "314", + "00015" to "315", + "00016" to "316", + "00019" to "319", + "00020" to "320", + "00026" to "11126", + "00010" to "310" ), "0015" to mapOf( - "00008" to "118", - "00002" to "249", + "00006" to "11106", + "00005" to "11105", + "00002" to "11102", + "00004" to "11104", + "00023" to "1234", + "00008" to "11108", + "00017" to "11117", + "00011" to "10111", + "00021" to "1234", + "00001" to "1234", + "00018" to "11118", + "00012" to "11112", + "00019" to "11119", + "00003" to "11103", + "00009" to "11109", + "00015" to "11115", + "00020" to "11120", + "00013" to "11113", + "00014" to "1234", + "00016" to "11116", + "00010" to "11110", + "00007" to "11107", + "00022" to "1234", + "00026" to "11126" ), - "0016" to mapOf( - "00001" to "249", - "00002" to "249" - ) ) + fun getTeller(dccbCode: String, branchCode: String): Teller? { val branchList = tellerMap[dccbCode] ?: return null - val tellerId = branchList[branchCode] ?: "249" + val tellerId = branchList[branchCode] ?: return null val teller = Teller( tellerId, dccbCode, diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a1d2e27..dacec2e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,7 @@ -DB_NAME=IPKSDB -DB_HOST=testipksdb.c7q7defafeea.ap-south-1.rds.amazonaws.com +DB_NAME=IPKS +#DB_HOST=testipksdb.c7q7defafeea.ap-south-1.rds.amazonaws.com #DB_HOST=localhost +DB_HOST=ipksprod3.c7q7defafeea.ap-south-1.rds.amazonaws.com DB_PORT=1521 DB_USER=pacs_db DB_PASSWORD=pacs_db