@haroldtran/react-native-pax 1.0.12 → 1.0.13

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.
package/.gitignore CHANGED
@@ -35,15 +35,11 @@ yarn-error.*
35
35
 
36
36
  # typescript
37
37
  *.tsbuildinfo
38
-
38
+ .idea
39
39
  app-example
40
40
  .yarn/
41
41
  android/.idea/*
42
42
  android/.gradle/*
43
43
  android/gradle/wrapper/gradle-wrapper.jar
44
44
  android/local.properties
45
- android/src/.idea/.gitignore
46
- android/src/.idea/misc.xml
47
- android/src/.idea/modules.xml
48
- android/src/.idea/vcs.xml
49
- android/src/.idea/caches/deviceStreaming.xml
45
+ android/build/reports/
@@ -47,7 +47,6 @@ import com.pax.poslinksemiintegration.util.Restaurant
47
47
  import com.pax.poslinksemiintegration.util.TraceRequest
48
48
  import com.pax.poslinksemiintegration.util.TransactionBehavior
49
49
  import com.paxposlink.Utils
50
- import java.time.Instant
51
50
 
52
51
  class PaxPosLinkModule(
53
52
  reactApplicationContext: ReactApplicationContext,
@@ -84,7 +83,7 @@ class PaxPosLinkModule(
84
83
  Log.d("Success Init", "Create terminal success")
85
84
  map.putString("message", "Create terminal success")
86
85
  map.putBoolean("status", true)
87
- map.putString("serialNumber", getTerminalInfo().toString())
86
+ map.putMap("serialNumber", getTerminalInfo())
88
87
  promise.resolve(map)
89
88
  } else {
90
89
  Log.d("Failed Init", "Create terminal failed!")
@@ -151,7 +150,7 @@ class PaxPosLinkModule(
151
150
  map.putString("tipAmount", this.tipAmount)
152
151
  map.putString("surcharge", this.surcharge)
153
152
  map.putString("cardType", this.cardType)
154
- map.putString("sn", this.sn.toString())
153
+ map.putMap("sn", this.sn)
155
154
  return map
156
155
  }
157
156
 
@@ -181,18 +180,22 @@ class PaxPosLinkModule(
181
180
 
182
181
  @RequiresApi(Build.VERSION_CODES.O)
183
182
  @ReactMethod
184
- fun checkVoidOrRefundTransaction(ercRefNum: String?, promise: Promise) {
183
+ fun checkVoidOrRefundTransaction(
184
+ ercRefNum: String?,
185
+ promise: Promise,
186
+ ) {
185
187
  try {
186
- val transaction = LocalDetailReportRequest().apply {
187
- this.ecrReferenceNumber = ercRefNum
188
- this.edcType = EdcType.ALL
189
- }
190
- val result = terminal?.report?.localDetailReport(transaction);
188
+ val transaction =
189
+ LocalDetailReportRequest().apply {
190
+ this.ecrReferenceNumber = ercRefNum
191
+ this.edcType = EdcType.ALL
192
+ }
193
+ val result = terminal?.report?.localDetailReport(transaction)
191
194
  val map: WritableMap = Arguments.createMap()
192
- map.putString("code",result?.code().toString() )
195
+ map.putString("code", result?.code().toString())
193
196
  map.putString("message", result?.message().toString())
194
197
  map.putString("status", result?.response()?.responseMessage())
195
- map.putString("serialNumber", getTerminalInfo().toString())
198
+ map.putMap("serialNumber", getTerminalInfo())
196
199
  promise.resolve(map)
197
200
  } catch (e: Exception) {
198
201
  return promise.resolve("Error to check void or refund")
@@ -298,14 +301,13 @@ class PaxPosLinkModule(
298
301
  @ReactMethod
299
302
  fun cancelInit(promise: Promise) {
300
303
  try {
301
- terminal?.cancel();
302
- promise.resolve("Cancel Init Success" )
304
+ terminal?.cancel()
305
+ promise.resolve("Cancel Init Success")
303
306
  } catch (e: Exception) {
304
307
  promise.reject("Failed", "Batch close error")
305
308
  }
306
309
  }
307
310
 
308
-
309
311
  // fun voidOrRefundTransaction(startDate: Int, serialNumber: String): String {
310
312
  // if (startDate == 0) return ""
311
313
  // val batchStartDate = getBatchStartDate()
@@ -466,7 +468,7 @@ class PaxPosLinkModule(
466
468
  .toString()
467
469
  .uppercase()
468
470
  refNum = rsp?.traceInformation()?.referenceNumber().toString()
469
- ecrRefNum = rsp?.traceInformation()?.ecrReferenceNumber().toString();
471
+ ecrRefNum = rsp?.traceInformation()?.ecrReferenceNumber().toString()
470
472
  transactionId = rsp?.paymentTransactionInformation()?.globalUid().toString()
471
473
  transactionDateTime = rsp?.traceInformation()?.timeStamp().toString()
472
474
  entryMethod =
@@ -548,14 +550,15 @@ class PaxPosLinkModule(
548
550
  // }
549
551
 
550
552
  private fun getTerminalInfo(): WritableMap {
551
- val rs = terminal?.manage?.init()?.let {
552
- PaxTerminalInfoModel(
553
- serialNumber = it.response().sn(),
554
- modelName = it.response().modelName(),
555
- appName = it.response().appName(),
556
- )
557
- }
558
- return rs!!.toWritableMap();
553
+ val rs =
554
+ terminal?.manage?.init()?.let {
555
+ PaxTerminalInfoModel(
556
+ serialNumber = it.response().sn(),
557
+ modelName = it.response().modelName(),
558
+ appName = it.response().appName(),
559
+ )
560
+ }
561
+ return rs?.toWritableMap() ?: PaxTerminalInfoModel().toWritableMap()
559
562
  }
560
563
 
561
564
  private fun getAmountReq(transType: TransactionType?): AmountRequest =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haroldtran/react-native-pax",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "React Native native module for PAX devices",
5
5
  "main": "./src/index.ts",
6
6
  "files": [
@@ -31,12 +31,12 @@
31
31
  "react-native.config.mjs"
32
32
  ],
33
33
  "scripts": {
34
- "prebuild": "yarn && yarn typecheck && yarn lint",
34
+ "prebuild": "bun i && bun typecheck && bun lint",
35
35
  "test": "jest",
36
36
  "typecheck": "tsc --noEmit",
37
37
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
38
- "release": "yarn prebuild && release-it",
39
- "example": "yarn --cwd example"
38
+ "release": "bun prebuild && release-it",
39
+ "example": "bun --cwd example"
40
40
  },
41
41
  "keywords": [
42
42
  "react-native",
package/src/type.ts CHANGED
@@ -33,7 +33,7 @@ export interface PaxResponseModel {
33
33
  tipAmount?: string;
34
34
  surcharge?: string;
35
35
  entryMethod?: string;
36
- sn?: string;
36
+ sn: PaxTerminalInfoModel;
37
37
  }
38
38
 
39
39
  export interface PaxTerminalInfoModel {