quivio-transaction-processor 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ package com.rohan.emvcardreaderlib
2
2
 
3
3
  // Interface for EMV transaction callback communication
4
4
  interface EMVTransactionCommunicator {
5
- fun onError(errorMessage: String)
5
+ fun onError(error: ErrorResponse)
6
6
  fun onCardReadSuccessfully(cardData: CardData)
7
7
  fun onSaleTransactionCompleted(saleDetails: SaleTransactionResponse)
8
8
  fun onRecurringSaleCompleted(recurringDetails: RecurringTransactionResponse)
@@ -5,6 +5,7 @@ sealed interface CrState {
5
5
  object Reset: CrState
6
6
  object PingConfig: CrState
7
7
  object RunConfig: CrState
8
+ object DownloadingConfig: CrState
8
9
  object PrePaidCardDataCollect: CrState
9
10
  object EmvSale: CrState
10
11
  object SetupRecurringSale: CrState
@@ -57,6 +57,7 @@ class DsiEMVManager(
57
57
  private suspend fun downloadConfigParams() = withContext(Dispatchers.IO) {
58
58
  Log.d(PRINT_TAG, "Download Config Initiated: $currentPosState")
59
59
  posTransactionExecutor.downloadConfig()
60
+ currentPosState = CrState.DownloadingConfig
60
61
  }
61
62
 
62
63
  suspend fun cancelTransaction(){
@@ -133,15 +134,15 @@ class DsiEMVManager(
133
134
  CrState.RunConfig -> {
134
135
  if (errorRes.dsixReturnCode == ErrorCode.PSCS_ERROR.code) {
135
136
  downloadConfigParams()
137
+ return
136
138
  } else {
137
139
  configCommunicator?.onConfigError(errorRes.textResponse)
138
140
  }
139
141
  }
140
142
  CrState.PingConfig -> configCommunicator?.onConfigPingFailed()
141
143
  else -> {
142
- communicator?.onError(error.textResponse)
144
+ communicator?.onError(error)
143
145
  }
144
-
145
146
  }
146
147
  }
147
148
  currentPosState = CrState.IDLE
@@ -149,6 +150,9 @@ class DsiEMVManager(
149
150
 
150
151
  private fun checkSuccessResponse(xml: String) {
151
152
  when (currentPosState) {
153
+ CrState.DownloadingConfig -> {
154
+ configCommunicator?.onConfigPingSuccess()
155
+ }
152
156
  CrState.PingConfig -> {
153
157
  configCommunicator?.onConfigPingSuccess()
154
158
  }
@@ -7,6 +7,7 @@ import com.rohan.emvcardreaderlib.manager.DsiEMVManager
7
7
  import com.rohan.emvcardreaderlib.EMVTransactionCommunicator
8
8
  import com.rohan.emvcardreaderlib.ConfigurationCommunicator
9
9
  import com.rohan.emvcardreaderlib.CardData
10
+ import com.rohan.emvcardreaderlib.ErrorResponse
10
11
  import com.rohan.emvcardreaderlib.SaleTransactionResponse
11
12
  import com.rohan.emvcardreaderlib.RecurringTransactionResponse
12
13
  import com.rohan.emvcardreaderlib.ZeroAuthTransactionResponse
@@ -137,9 +138,17 @@ class DsiEMVManagerModule(private val reactContext: ReactApplicationContext) :
137
138
  }
138
139
 
139
140
  // EMVTransactionCommunicator callbacks
140
- override fun onError(errorMessage: String) {
141
- Log.d("DsiEMVManagerModule", "onError: $errorMessage")
142
- sendEvent("onError", errorMessage)
141
+ override fun onError(errorResponse: ErrorResponse) {
142
+ Log.d("DsiEMVManagerModule", "onError: $errorResponse")
143
+ val map = Arguments.createMap().apply {
144
+ putString("responseOrigin", errorResponse.responseOrigin)
145
+ putString("dsixReturnCode", errorResponse.dsixReturnCode)
146
+ putString("cmdStatus", errorResponse.cmdStatus)
147
+ putString("textResponse", errorResponse.textResponse)
148
+ putString("sequenceNo", errorResponse.sequenceNo)
149
+ putString("userTrace", errorResponse.userTrace)
150
+ }
151
+ sendEvent("onError", map)
143
152
  }
144
153
 
145
154
  override fun onCardReadSuccessfully(cardData: CardData) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quivio-transaction-processor",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "React Native hook for Card payment integration with DataCap",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",