@haroldtran/react-native-pax 1.0.12 → 1.0.14
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/
|
|
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,
|
|
@@ -67,13 +66,15 @@ class PaxPosLinkModule(
|
|
|
67
66
|
@ReactMethod
|
|
68
67
|
fun initPOSLink(
|
|
69
68
|
ip: String,
|
|
69
|
+
port: String?,
|
|
70
|
+
timeout: Int?,
|
|
70
71
|
promise: Promise,
|
|
71
72
|
) {
|
|
72
73
|
val tcpSetting =
|
|
73
74
|
TcpSetting().apply {
|
|
74
75
|
this.ip = ip
|
|
75
|
-
this.port = PaxPosConstant.PORT
|
|
76
|
-
this.timeout = PaxPosConstant.TIMEOUT
|
|
76
|
+
this.port = port ?: PaxPosConstant.PORT
|
|
77
|
+
this.timeout = timeout ?: PaxPosConstant.TIMEOUT
|
|
77
78
|
}
|
|
78
79
|
Log.i("TcpSetting", "tcpSetting info: ip=$ip, port=${tcpSetting.port}, timeout=${tcpSetting.timeout}")
|
|
79
80
|
val map = Arguments.createMap()
|
|
@@ -84,7 +85,7 @@ class PaxPosLinkModule(
|
|
|
84
85
|
Log.d("Success Init", "Create terminal success")
|
|
85
86
|
map.putString("message", "Create terminal success")
|
|
86
87
|
map.putBoolean("status", true)
|
|
87
|
-
map.
|
|
88
|
+
map.putMap("serialNumber", getTerminalInfo())
|
|
88
89
|
promise.resolve(map)
|
|
89
90
|
} else {
|
|
90
91
|
Log.d("Failed Init", "Create terminal failed!")
|
|
@@ -151,7 +152,7 @@ class PaxPosLinkModule(
|
|
|
151
152
|
map.putString("tipAmount", this.tipAmount)
|
|
152
153
|
map.putString("surcharge", this.surcharge)
|
|
153
154
|
map.putString("cardType", this.cardType)
|
|
154
|
-
map.
|
|
155
|
+
map.putMap("sn", this.sn)
|
|
155
156
|
return map
|
|
156
157
|
}
|
|
157
158
|
|
|
@@ -181,18 +182,22 @@ class PaxPosLinkModule(
|
|
|
181
182
|
|
|
182
183
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
183
184
|
@ReactMethod
|
|
184
|
-
fun checkVoidOrRefundTransaction(
|
|
185
|
+
fun checkVoidOrRefundTransaction(
|
|
186
|
+
ercRefNum: String?,
|
|
187
|
+
promise: Promise,
|
|
188
|
+
) {
|
|
185
189
|
try {
|
|
186
|
-
val transaction =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
val transaction =
|
|
191
|
+
LocalDetailReportRequest().apply {
|
|
192
|
+
this.ecrReferenceNumber = ercRefNum
|
|
193
|
+
this.edcType = EdcType.ALL
|
|
194
|
+
}
|
|
195
|
+
val result = terminal?.report?.localDetailReport(transaction)
|
|
191
196
|
val map: WritableMap = Arguments.createMap()
|
|
192
|
-
map.putString("code",result?.code().toString()
|
|
197
|
+
map.putString("code", result?.code().toString())
|
|
193
198
|
map.putString("message", result?.message().toString())
|
|
194
199
|
map.putString("status", result?.response()?.responseMessage())
|
|
195
|
-
map.
|
|
200
|
+
map.putMap("serialNumber", getTerminalInfo())
|
|
196
201
|
promise.resolve(map)
|
|
197
202
|
} catch (e: Exception) {
|
|
198
203
|
return promise.resolve("Error to check void or refund")
|
|
@@ -298,14 +303,13 @@ class PaxPosLinkModule(
|
|
|
298
303
|
@ReactMethod
|
|
299
304
|
fun cancelInit(promise: Promise) {
|
|
300
305
|
try {
|
|
301
|
-
terminal?.cancel()
|
|
302
|
-
promise.resolve("Cancel Init Success"
|
|
306
|
+
terminal?.cancel()
|
|
307
|
+
promise.resolve("Cancel Init Success")
|
|
303
308
|
} catch (e: Exception) {
|
|
304
309
|
promise.reject("Failed", "Batch close error")
|
|
305
310
|
}
|
|
306
311
|
}
|
|
307
312
|
|
|
308
|
-
|
|
309
313
|
// fun voidOrRefundTransaction(startDate: Int, serialNumber: String): String {
|
|
310
314
|
// if (startDate == 0) return ""
|
|
311
315
|
// val batchStartDate = getBatchStartDate()
|
|
@@ -466,7 +470,7 @@ class PaxPosLinkModule(
|
|
|
466
470
|
.toString()
|
|
467
471
|
.uppercase()
|
|
468
472
|
refNum = rsp?.traceInformation()?.referenceNumber().toString()
|
|
469
|
-
ecrRefNum = rsp?.traceInformation()?.ecrReferenceNumber().toString()
|
|
473
|
+
ecrRefNum = rsp?.traceInformation()?.ecrReferenceNumber().toString()
|
|
470
474
|
transactionId = rsp?.paymentTransactionInformation()?.globalUid().toString()
|
|
471
475
|
transactionDateTime = rsp?.traceInformation()?.timeStamp().toString()
|
|
472
476
|
entryMethod =
|
|
@@ -548,14 +552,15 @@ class PaxPosLinkModule(
|
|
|
548
552
|
// }
|
|
549
553
|
|
|
550
554
|
private fun getTerminalInfo(): WritableMap {
|
|
551
|
-
val rs =
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
555
|
+
val rs =
|
|
556
|
+
terminal?.manage?.init()?.let {
|
|
557
|
+
PaxTerminalInfoModel(
|
|
558
|
+
serialNumber = it.response().sn(),
|
|
559
|
+
modelName = it.response().modelName(),
|
|
560
|
+
appName = it.response().appName(),
|
|
561
|
+
)
|
|
562
|
+
}
|
|
563
|
+
return rs?.toWritableMap() ?: PaxTerminalInfoModel().toWritableMap()
|
|
559
564
|
}
|
|
560
565
|
|
|
561
566
|
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.
|
|
3
|
+
"version": "1.0.14",
|
|
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": "
|
|
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": "
|
|
39
|
-
"example": "
|
|
38
|
+
"release": "bun prebuild && release-it",
|
|
39
|
+
"example": "bun --cwd example"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"react-native",
|
package/src/index.ts
CHANGED
|
@@ -38,10 +38,16 @@ const PaxPosLink = isAndroid
|
|
|
38
38
|
/**
|
|
39
39
|
* Initializes the POSLink connection.
|
|
40
40
|
* @param {string} [ip] - The IP address of the POS device.
|
|
41
|
+
* @param {object} [options] - Optional parameters.
|
|
42
|
+
* @param {string} [options.port] - The port number of the POS device.
|
|
43
|
+
* @param {number} [options.timeout] - The timeout value for the connection.
|
|
41
44
|
* @returns {Promise<PaxInitModel>} A promise resolving to the initPOSLink result.
|
|
42
45
|
*/
|
|
43
|
-
export function initPOSLink(
|
|
44
|
-
|
|
46
|
+
export function initPOSLink(
|
|
47
|
+
ip: string,
|
|
48
|
+
options?: { port?: string; timeout?: number }
|
|
49
|
+
): Promise<PaxInitModel> {
|
|
50
|
+
return PaxPosLink.initPOSLink(ip, options?.port, options?.timeout);
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
/**
|