@haroldtran/react-native-pax 1.0.11 → 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 +2 -6
- package/android/src/main/java/com/paxposlink/PaxPosLinkModule.kt +26 -23
- package/package.json +4 -4
- package/src/index.ts +3 -3
- package/src/type.ts +10 -1
- package/.yarnrc.yml +0 -1
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,
|
|
@@ -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.
|
|
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.
|
|
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(
|
|
183
|
+
fun checkVoidOrRefundTransaction(
|
|
184
|
+
ercRefNum: String?,
|
|
185
|
+
promise: Promise,
|
|
186
|
+
) {
|
|
185
187
|
try {
|
|
186
|
-
val transaction =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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.
|
|
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 =
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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.
|
|
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": "
|
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NativeModules, Platform } from 'react-native';
|
|
2
|
-
import { PaxResponseModel } from './type';
|
|
2
|
+
import { PaxInitModel, PaxResponseModel } from './type';
|
|
3
3
|
export * from './type';
|
|
4
4
|
// This package is Android-only. Provide clear errors on non-Android platforms
|
|
5
5
|
const ANDROID_ONLY_ERROR =
|
|
@@ -38,9 +38,9 @@ const PaxPosLink = isAndroid
|
|
|
38
38
|
/**
|
|
39
39
|
* Initializes the POSLink connection.
|
|
40
40
|
* @param {string} [ip] - The IP address of the POS device.
|
|
41
|
-
* @returns {
|
|
41
|
+
* @returns {Promise<PaxInitModel>} A promise resolving to the initPOSLink result.
|
|
42
42
|
*/
|
|
43
|
-
export function initPOSLink(ip: string) {
|
|
43
|
+
export function initPOSLink(ip: string): Promise<PaxInitModel> {
|
|
44
44
|
return PaxPosLink.initPOSLink(ip);
|
|
45
45
|
}
|
|
46
46
|
|
package/src/type.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export interface PaxInitModel {
|
|
2
|
+
serialNumber?: {
|
|
3
|
+
modelName: string;
|
|
4
|
+
appName: string;
|
|
5
|
+
serialNumber: string;
|
|
6
|
+
};
|
|
7
|
+
status: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
export interface PaxRequestModel {
|
|
2
11
|
id?: string;
|
|
3
12
|
amount?: number;
|
|
@@ -24,7 +33,7 @@ export interface PaxResponseModel {
|
|
|
24
33
|
tipAmount?: string;
|
|
25
34
|
surcharge?: string;
|
|
26
35
|
entryMethod?: string;
|
|
27
|
-
sn
|
|
36
|
+
sn: PaxTerminalInfoModel;
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
export interface PaxTerminalInfoModel {
|
package/.yarnrc.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
nodeLinker: node-modules
|