@haroldtran/react-native-pax 0.1.8 → 1.0.1

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.
Files changed (34) hide show
  1. package/.gitignore +4 -0
  2. package/README.md +118 -160
  3. package/android/build.gradle +15 -4
  4. package/android/gradle.properties +8 -5
  5. package/android/libs/POSLink_Admin_Android_Plugin_V2.00.00_20230828.jar +0 -0
  6. package/android/libs/POSLink_Core_Android_V2.00.03_20230828.jar +0 -0
  7. package/android/libs/POSLink_Semi_Android_Plugin_V2.00.00_20230828.jar +0 -0
  8. package/android/libs/PaxLog_1.0.11_20220921.jar +0 -0
  9. package/android/src/main/java/com/paxposlink/PaxPosConstant.kt +57 -0
  10. package/android/src/main/java/com/paxposlink/PaxPosLinkModule.kt +711 -0
  11. package/android/src/main/java/com/paxposlink/PaxPosLinkPackage.kt +12 -0
  12. package/android/src/main/java/com/paxposlink/Utils.kt +99 -0
  13. package/lib/commonjs/index.js +57 -26
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/type.js +13 -0
  16. package/lib/commonjs/type.js.map +1 -0
  17. package/lib/module/index.js +54 -20
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/type.js +9 -0
  20. package/lib/module/type.js.map +1 -0
  21. package/lib/typescript/commonjs/index.d.ts +34 -8
  22. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  23. package/lib/typescript/commonjs/type.d.ts +37 -0
  24. package/lib/typescript/commonjs/type.d.ts.map +1 -0
  25. package/lib/typescript/module/index.d.ts +34 -8
  26. package/lib/typescript/module/index.d.ts.map +1 -1
  27. package/lib/typescript/module/type.d.ts +37 -0
  28. package/lib/typescript/module/type.d.ts.map +1 -0
  29. package/package.json +4 -2
  30. package/src/index.tsx +45 -49
  31. package/src/type.ts +39 -0
  32. package/android/libs/POSLink_Core.jar +0 -0
  33. package/android/src/main/java/com/paxposlink/PaxPoslinkModule.java +0 -355
  34. package/android/src/main/java/com/paxposlink/PaxPoslinkPackage.java +0 -28
@@ -0,0 +1,711 @@
1
+ package com.paxposlink
2
+
3
+ import android.util.Log
4
+ import com.facebook.react.bridge.Arguments
5
+ import com.facebook.react.bridge.Promise
6
+ import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
8
+ import com.facebook.react.bridge.ReactMethod
9
+ import com.facebook.react.bridge.ReadableMap
10
+ import com.facebook.react.bridge.WritableMap
11
+ import com.pax.poscore.commsetting.TcpSetting
12
+ import com.pax.poscore.internal.ExecutionCode
13
+ import com.pax.poslinkadmin.ExecutionResult
14
+ import com.pax.poslinkadmin.constant.ContinuousScreen
15
+ import com.pax.poslinkadmin.constant.EntryMode
16
+ import com.pax.poslinkadmin.constant.ReceiptPrintFlag
17
+ import com.pax.poslinkadmin.constant.TransactionType
18
+ import com.pax.poslinkadmin.util.AmountRequest
19
+ import com.pax.poslinkadmin.util.MultiMerchant
20
+ import com.pax.poslinksemiintegration.POSLinkSemi
21
+ import com.pax.poslinksemiintegration.Terminal
22
+ import com.pax.poslinksemiintegration.batch.BatchCloseRequest
23
+ import com.pax.poslinksemiintegration.batch.BatchCloseResponse
24
+ import com.pax.poslinksemiintegration.constant.CardPresentIndicator
25
+ import com.pax.poslinksemiintegration.constant.TipRequestFlag
26
+ import com.pax.poslinksemiintegration.constant.VehicleClassId
27
+ import com.pax.poslinksemiintegration.transaction.DoCreditRequest
28
+ import com.pax.poslinksemiintegration.transaction.DoCreditResponse
29
+ import com.pax.poslinksemiintegration.util.AccountRequest
30
+ import com.pax.poslinksemiintegration.util.AccountResponse
31
+ import com.pax.poslinksemiintegration.util.AutoRental
32
+ import com.pax.poslinksemiintegration.util.AvsRequest
33
+ import com.pax.poslinksemiintegration.util.CashierRequest
34
+ import com.pax.poslinksemiintegration.util.CheckRequest
35
+ import com.pax.poslinksemiintegration.util.CommercialRequest
36
+ import com.pax.poslinksemiintegration.util.FleetCardRequest
37
+ import com.pax.poslinksemiintegration.util.HostGateway
38
+ import com.pax.poslinksemiintegration.util.Lodging
39
+ import com.pax.poslinksemiintegration.util.MotoECommerceRequest
40
+ import com.pax.poslinksemiintegration.util.Original
41
+ import com.pax.poslinksemiintegration.util.PaymentEmvTag
42
+ import com.pax.poslinksemiintegration.util.Restaurant
43
+ import com.pax.poslinksemiintegration.util.TraceRequest
44
+ import com.pax.poslinksemiintegration.util.TransactionBehavior
45
+ import com.paxposlink.Utils
46
+
47
+ class PaxPosLinkModule(
48
+ reactApplicationContext: ReactApplicationContext,
49
+ ) : ReactContextBaseJavaModule() {
50
+ private var reactContext: ReactApplicationContext? = reactApplicationContext
51
+ private var posLink: POSLinkSemi? = POSLinkSemi.getInstance()
52
+ private var salesRequest: PaxRequestModel? = null
53
+ private var terminal: Terminal? = null
54
+
55
+ override fun getName(): String = "PaxPoslink"
56
+
57
+ @ReactMethod
58
+ fun logEvent(message: String) {
59
+ Log.d("PaxPosLinkModule", "Log event: $message")
60
+ }
61
+
62
+ @ReactMethod
63
+ fun initPOSLink(
64
+ ip: String,
65
+ promise: Promise,
66
+ ) {
67
+ val tcpSetting =
68
+ TcpSetting().apply {
69
+ this.ip = ip
70
+ this.port = PaxPosConstant.PORT
71
+ this.timeout = PaxPosConstant.TIMEOUT
72
+ }
73
+ Log.i("TcpSetting", "tcpSetting info: ip=$ip, port=${tcpSetting.port}, timeout=${tcpSetting.timeout}")
74
+ val map = Arguments.createMap()
75
+
76
+ terminal = posLink?.getTerminal(reactContext, tcpSetting)
77
+ Log.e("terminal", terminal.toString())
78
+ return if (terminal != null) {
79
+ Log.d("Success Init", "Create terminal success")
80
+ map.putString("message", "Create terminal success")
81
+ map.putBoolean("status", true)
82
+ promise.resolve(map)
83
+ } else {
84
+ Log.d("Failed Init", "Create terminal failed!")
85
+ map.putString("message", "Create terminal failed!")
86
+ map.putBoolean("status", false)
87
+ promise.resolve(map)
88
+ }
89
+ }
90
+
91
+ @ReactMethod
92
+ fun payment(
93
+ data: ReadableMap,
94
+ promise: Promise,
95
+ ) {
96
+ val salesRequest =
97
+ PaxRequestModel(
98
+ id = data.getString("id"),
99
+ amount = data.takeIf { it.hasKey("amount") && !it.isNull("amount") }?.getInt("amount") ?: 0,
100
+ tip = data.takeIf { it.hasKey("tip") && !it.isNull("tip") }?.getInt("tip"),
101
+ paymentType = data.takeIf { it.hasKey("paymentType") && !it.isNull("paymentType") }?.getInt("paymentType"),
102
+ ecrRefNum = data.getString("ecrRefNum") ?: "",
103
+ )
104
+
105
+ this.salesRequest = salesRequest
106
+ if (terminal !== null) {
107
+ try {
108
+ when (salesRequest.paymentType) {
109
+ CreditTransactionType.Credit.code -> {
110
+ val result = paymentCredit(salesRequest)
111
+ promise.resolve(result.toWritableMap())
112
+ }
113
+ CreditTransactionType.Debit.code -> {
114
+ val result = paymentDebit(salesRequest)
115
+ promise.resolve(result.toWritableMap())
116
+ }
117
+ else -> {
118
+ promise.reject("INVALID_TYPE", "Please select transaction command (credit/ debit)!")
119
+ return
120
+ }
121
+ }
122
+ } catch (e: Exception) {
123
+ Log.d("Error", e.toString())
124
+ }
125
+ } else {
126
+ Log.d("Error", "Don't connect")
127
+ promise.reject("NO_TERMINAL", "Please connect PAX terminal first")
128
+ }
129
+ }
130
+
131
+ private fun PaxResponseModel.toWritableMap(): WritableMap {
132
+ val map = Arguments.createMap()
133
+ map.putBoolean("status", this.status)
134
+ map.putString("message", this.message)
135
+ map.putMap("data", Utils.toWritableMap(this.data))
136
+ map.putBoolean("isPaymentSuccess", this.isPaymentSuccess)
137
+ map.putString("cardHolder", this.cardHolder)
138
+ map.putString("cardNumber", this.cardNumber)
139
+ map.putString("refNum", this.refNum)
140
+ map.putString("transactionId", this.transactionId)
141
+ map.putString("transactionDateTime", this.transactionDateTime)
142
+ map.putString("entryMethod", this.entryMethod)
143
+ map.putString("amount", this.amount)
144
+ map.putString("tipAmount", this.tipAmount)
145
+ map.putString("surcharge", this.surcharge)
146
+ map.putString("cardType", this.cardType)
147
+ return map
148
+ }
149
+
150
+ private fun paymentCredit(request: PaxRequestModel): PaxResponseModel {
151
+ this.salesRequest = request
152
+ val req = setCreditRequest(TransactionType.SALE)
153
+ val rsp = DoCreditResponse()
154
+ val result = terminal?.transaction?.doCredit(req)
155
+ return buildTransactionResponse(rsp, result)
156
+ }
157
+
158
+ private fun paymentDebit(request: PaxRequestModel): PaxResponseModel {
159
+ this.salesRequest = request
160
+ val req = setCreditRequest(TransactionType.SALE)
161
+ val rsp = DoCreditResponse()
162
+ val result = terminal?.transaction?.doCredit(req)
163
+ return buildTransactionResponse(rsp, result)
164
+ }
165
+
166
+ @ReactMethod
167
+ fun void(
168
+ data: ReadableMap,
169
+ promise: Promise,
170
+ ) {
171
+ try {
172
+ val salesRequest =
173
+ PaxRequestModel(
174
+ id = data.getString("id"),
175
+ amount = data.takeIf { it.hasKey("amount") && !it.isNull("amount") }?.getInt("amount") ?: 0,
176
+ tip = data.takeIf { it.hasKey("tip") && !it.isNull("tip") }?.getInt("tip"),
177
+ paymentType = data.takeIf { it.hasKey("paymentType") && !it.isNull("paymentType") }?.getInt("paymentType"),
178
+ ecrRefNum = data.getString("ecrRefNum") ?: "",
179
+ )
180
+ this.salesRequest = salesRequest
181
+ val req = setCreditRequest(TransactionType.VOID_SALE)
182
+ val rsp = DoCreditResponse()
183
+ val result = terminal?.transaction?.doCredit(req)
184
+ val data = buildTransactionResponse(rsp, result)
185
+ promise.resolve(data)
186
+ } catch (e: Exception) {
187
+ return promise.resolve("Error to void transaction")
188
+ }
189
+ }
190
+
191
+ @ReactMethod
192
+ fun refund(
193
+ data: ReadableMap,
194
+ promise: Promise,
195
+ ) {
196
+ try {
197
+ val salesRequest =
198
+ PaxRequestModel(
199
+ id = data.getString("id"),
200
+ amount = data.takeIf { it.hasKey("amount") && !it.isNull("amount") }?.getInt("amount") ?: 0,
201
+ tip = data.takeIf { it.hasKey("tip") && !it.isNull("tip") }?.getInt("tip"),
202
+ paymentType = data.takeIf { it.hasKey("paymentType") && !it.isNull("paymentType") }?.getInt("paymentType"),
203
+ ecrRefNum = data.getString("ecrRefNum") ?: "",
204
+ )
205
+ this.salesRequest = salesRequest
206
+ val req = setCreditRequest(TransactionType.RETURN)
207
+ val rsp = DoCreditResponse()
208
+ val result = terminal?.transaction?.doCredit(req)
209
+ val data = buildTransactionResponse(rsp, result)
210
+ promise.resolve(data)
211
+ } catch (e: Exception) {
212
+ return promise.resolve("Error to return transaction")
213
+ }
214
+ }
215
+
216
+ @ReactMethod
217
+ fun batchCloseout(promise: Promise) {
218
+ try {
219
+ val batchCloseReq = BatchCloseRequest()
220
+ val batchCloseRsp = BatchCloseResponse()
221
+ val result = terminal?.batch?.batchClose(batchCloseReq)
222
+ if (result?.code() == ExecutionCode.OK) {
223
+ promise.resolve("Batch close successfully")
224
+ }
225
+ } catch (e: Exception) {
226
+ promise.reject("Failed", "Batch close error")
227
+ }
228
+ }
229
+
230
+ // fun voidOrRefundTransaction(startDate: Int, serialNumber: String): String {
231
+ // if (startDate == 0) return ""
232
+ // val batchStartDate = getBatchStartDate()
233
+ // if (batchStartDate == 0 || startDate < batchStartDate) return "Refund"
234
+ // return if (getTerminalInfo()?.serialNumber != serialNumber) "" else "Void"
235
+ // }
236
+
237
+ private fun setCreditRequest(type: TransactionType): DoCreditRequest =
238
+ DoCreditRequest().apply {
239
+ transactionType = type
240
+ amountInformation = getAmountReq(type)
241
+ accountInformation = getAccountReq()
242
+ traceInformation = getTraceReq(type)
243
+ avsInformation = getAvsReq()
244
+ cashierInformation = getCashierReq()
245
+ commercialInformation = getCommercialReq()
246
+ motoECommerceInformation = getMotoECommerceReq()
247
+ restaurant = getRestaurantReq()
248
+ hostGateway = getHostGatewayReq()
249
+ transactionBehavior = getTransactionBehaviorReq()
250
+ original = getOriginalReq()
251
+ multiMerchant = getMultiMerchantReq()
252
+ fleetCard = getFleetCardReq()
253
+ lodging = getLodgingInfoReq()
254
+ autoRental = getAutoRentalInfoReq()
255
+ posEchoData = ""
256
+ continuousScreen = ContinuousScreen.NOT_SET
257
+ }
258
+
259
+ private fun convertDoCreditResponseToMap(rsp: DoCreditResponse?): WritableMap {
260
+ val map = Arguments.createMap()
261
+ if (rsp == null) return map
262
+
263
+ map.putString("responseCode", rsp.responseCode())
264
+ map.putString("responseMessage", rsp.responseMessage())
265
+ map.putString(
266
+ "entryMethod",
267
+ rsp.paymentEmvTag()?.let { emv ->
268
+ rsp.accountInformation()?.let { getEntryMethod(it, emv) }
269
+ },
270
+ )
271
+
272
+ // accountInformation
273
+ val acc = rsp.accountInformation()
274
+ val accMap =
275
+ Arguments.createMap().apply {
276
+ putString("account", acc?.account())
277
+ putString("cardHolder", acc?.cardHolder())
278
+ putString("cardExpireDate", acc?.expireDate())
279
+ }
280
+ map.putMap("accountInformation", accMap)
281
+
282
+ // traceInformation
283
+ val trace = rsp.traceInformation()
284
+ val traceMap =
285
+ Arguments.createMap().apply {
286
+ putString("referenceNumber", trace?.referenceNumber())
287
+ putString("timeStamp", trace?.timeStamp())
288
+ putString("authorizationCode", trace?.authorizationResponse())
289
+ }
290
+ map.putMap("traceInformation", traceMap)
291
+
292
+ // amountInformation
293
+ val amount = rsp.amountInformation()
294
+ val amountMap =
295
+ Arguments.createMap().apply {
296
+ putString("transactionAmount", amount?.transactionRemainingAmount())
297
+ putString("tipAmount", amount?.tipAmount())
298
+ putString("merchantFee", amount?.merchantFee())
299
+ }
300
+ map.putMap("amountInformation", amountMap)
301
+
302
+ // transactionId
303
+ val trans = rsp.paymentTransactionInformation()
304
+ map.putString("transactionId", trans?.globalUid())
305
+
306
+ // avsInformation
307
+ val avs = rsp.avsInformation()
308
+ val avsMap =
309
+ Arguments.createMap().apply {
310
+ putString("zipCode", avs?.zipCode())
311
+ putString("address", avs?.address1())
312
+ }
313
+ map.putMap("avsInformation", avsMap)
314
+
315
+ // cardInformation
316
+ val card = rsp.cardInformation()
317
+ val cardMap =
318
+ Arguments.createMap().apply {
319
+ putString("cardType", card?.cardBin())
320
+ }
321
+ map.putMap("cardInformation", cardMap)
322
+
323
+ // commercialInformation
324
+ val commercial = rsp.commercialInformation()
325
+ val commMap =
326
+ Arguments.createMap().apply {
327
+ putString("poNumber", commercial?.poNumber())
328
+ }
329
+ map.putMap("commercialInformation", commMap)
330
+
331
+ // fleetCard
332
+ val fleet = rsp.fleetCard()
333
+ val fleetMap =
334
+ Arguments.createMap().apply {
335
+ putString("vehicleNumber", fleet?.vehicleNumber)
336
+ }
337
+ map.putMap("fleetCard", fleetMap)
338
+
339
+ // multiMerchant
340
+ val multi = rsp.multiMerchant()
341
+ val multiMap =
342
+ Arguments.createMap().apply {
343
+ putString("multiMerchantId", multi?.multiMerchantId)
344
+ putString("multiMerchantName", multi?.multiMerchantName)
345
+ }
346
+ map.putMap("multiMerchant", multiMap)
347
+
348
+ // restaurant
349
+ val restaurant = rsp.restaurant()
350
+ val restMap =
351
+ Arguments.createMap().apply {
352
+ putString("tableNumber", restaurant?.tableNumber)
353
+ putString("ticketNumber", restaurant?.ticketNumber)
354
+ }
355
+ map.putMap("restaurant", restMap)
356
+
357
+ // emv
358
+ val emv = rsp.paymentEmvTag()
359
+ val emvMap =
360
+ Arguments.createMap().apply {
361
+ putString("emvLabel", emv.appLabel())
362
+ putString("emvPreferName", emv.appPreferName())
363
+ }
364
+ map.putMap("emv", emvMap)
365
+
366
+ return map
367
+ }
368
+
369
+ private fun buildTransactionResponse(
370
+ response: DoCreditResponse,
371
+ result: ExecutionResult<DoCreditResponse>?,
372
+ ): PaxResponseModel {
373
+ val rsp = result?.response()
374
+ return if (result?.code() == ExecutionCode.OK) {
375
+ PaxResponseModel().apply {
376
+ status = true
377
+ data = convertDoCreditResponseToMap(rsp)
378
+ message = rsp?.responseMessage().toString()
379
+ isPaymentSuccess = true
380
+ cardHolder = rsp?.accountInformation()?.cardHolder().toString()
381
+ cardNumber = rsp?.accountInformation()?.account().toString()
382
+ cardType =
383
+ rsp
384
+ ?.paymentEmvTag()
385
+ ?.appLabel()
386
+ .toString()
387
+ .uppercase()
388
+ refNum = rsp?.traceInformation()?.referenceNumber().toString()
389
+ transactionId = rsp?.paymentTransactionInformation()?.globalUid().toString()
390
+ transactionDateTime = rsp?.traceInformation()?.timeStamp().toString()
391
+ entryMethod =
392
+ rsp
393
+ ?.paymentEmvTag()
394
+ ?.let { rsp.accountInformation()?.let { it1 -> getEntryMethod(it1, it) } }
395
+ .toString()
396
+ tipAmount = rsp?.amountInformation()?.tipAmount().toString()
397
+ amount = salesRequest?.amount.toString()
398
+ id = salesRequest?.id.toString()
399
+ surcharge = rsp?.amountInformation()?.merchantFee().toString()
400
+ }
401
+ } else {
402
+ PaxResponseModel().apply {
403
+ status = false
404
+ data = null
405
+ message = DoCreditResponse().responseMessage()
406
+ }
407
+ }
408
+ }
409
+
410
+ private fun getEntryMethod(
411
+ accountRsp: AccountResponse,
412
+ paymentEmvTag: PaymentEmvTag,
413
+ ): String {
414
+ val temp = accountRsp.entryMode() ?: return ""
415
+
416
+ return when (temp) {
417
+ EntryMode.MANUAL -> {
418
+ if (accountRsp.cardPresentIndicator() === CardPresentIndicator.CARD_NOT_PRESENT) {
419
+ "KEYED_CNP"
420
+ } else {
421
+ "KEYED_CP"
422
+ }
423
+ }
424
+ EntryMode.SWIPE -> "SWIPED_MSD"
425
+ EntryMode.CONTACTLESS -> {
426
+ if (!paymentEmvTag.tc().isNullOrEmpty()) {
427
+ "CONTACTLESS_CHIP"
428
+ } else {
429
+ "CONTACTLESS_MSD"
430
+ }
431
+ }
432
+ EntryMode.LASER_SCANNER -> "SCANNER"
433
+ EntryMode.CHIP -> "CONTACT_CHIP"
434
+ EntryMode.CHIP_FALL_BACK_SWIPE -> "FALLBACK_SWIPED"
435
+ else -> ""
436
+ }
437
+ }
438
+
439
+ // private fun getTotalTransactionCount(): Int {
440
+ // val request = LocalDetailReportRequest().apply { edcType = EdcType.ALL }
441
+ // val response = LocalDetailReportResponse()
442
+ // val result = terminal?.report?.localDetailReport(request)
443
+ // return if (result?.code() == ExecutionCode.OK) {
444
+ // response.totalRecord()?.toIntOrNull() ?: 0
445
+ // } else 0
446
+ // }
447
+ //
448
+ // private fun getTotalTransactionAmount(): Int {
449
+ // val request = LocalTotalReportRequest().apply { edcType = EdcType.ALL }
450
+ // val response = LocalTotalReportResponse()
451
+ // val result = terminal?.report?.localTotalReport(request)
452
+ // return if (result?.code() == ExecutionCode.OK) {
453
+ // val sale = response.totals().creditTotals().returnAmount().toIntOrNull() ?: 0
454
+ // val refund = response.totals().creditTotals().returnAmount().toIntOrNull() ?: 0
455
+ // sale - refund
456
+ // } else 0
457
+ // }
458
+ //
459
+ // private fun getBatchStartDate(): Int {
460
+ // val request = LocalDetailReportRequest().apply { edcType = EdcType.ALL }
461
+ // val response = LocalDetailReportResponse()
462
+ // val result = terminal?.report?.localDetailReport(request)
463
+ // return if (result?.code() == ExecutionCode.OK) {
464
+ // response.traceInformation().ecrReferenceNumber().toIntOrNull() ?: 0
465
+ // } else 0
466
+ // }
467
+
468
+ // private fun getTerminalInfo(): PaxTerminalInfoModel? {
469
+ // return terminal?.manage?.init()?.let {
470
+ // PaxTerminalInfoModel(
471
+ // serialNumber = "",
472
+ // modelName = it.modelName,
473
+ // appName = it.appName
474
+ // )
475
+ //
476
+ // }
477
+ // }
478
+
479
+ private fun getAmountReq(transType: TransactionType?): AmountRequest =
480
+ AmountRequest().apply {
481
+ transactionAmount = salesRequest?.amount?.toString()
482
+ tipAmount = salesRequest?.tip.toString()
483
+ cashBackAmount = null
484
+ merchantFee = null
485
+ taxAmount = null
486
+ fuelAmount = null
487
+ serviceFee = null
488
+ }
489
+
490
+ private fun getAccountReq() =
491
+ AccountRequest().apply {
492
+ account = null
493
+ cardExpireDate = null
494
+ cvvCode = null
495
+ ebtType = null
496
+ voucherNumber = null
497
+ firstName = null
498
+ lastName = null
499
+ countryCode = null
500
+ stateCode = null
501
+ cityName = null
502
+ emailAddress = null
503
+ giftCardType = null
504
+ cvvBypassReason = null
505
+ giftTenderType = null
506
+ }
507
+
508
+ private fun getCheckReq() =
509
+ CheckRequest().apply {
510
+ saleType = null
511
+ routingNumber = null
512
+ account = null
513
+ number = null
514
+ type = null
515
+ idType = null
516
+ idValue = null
517
+ birth = null
518
+ phoneNumber = null
519
+ zipCode = null
520
+ }
521
+
522
+ private fun getTraceReq(transType: TransactionType): TraceRequest =
523
+ TraceRequest().apply {
524
+ val ecrRefNum = salesRequest?.ecrRefNum?.split("-")?.firstOrNull()
525
+ ecrRefNum?.let {
526
+ this.ecrReferenceNumber =
527
+ if (transType in listOf(TransactionType.SALE, TransactionType.VOID_SALE, TransactionType.RETURN)) it else null
528
+ this.originalEcrReferenceNumber = if (transType == TransactionType.VOID_SALE) it else null
529
+ }
530
+ invoiceNumber = null
531
+ authorizationCode = null
532
+ originalReferenceNumber = null
533
+ timeStamp = null
534
+ ecrTransactionId = null
535
+ originalTraceNumber = null
536
+ originalTransactionIdentifier = null
537
+ }
538
+
539
+ private fun getAvsReq() =
540
+ AvsRequest().apply {
541
+ zipCode = null
542
+ address = null
543
+ address2 = null
544
+ }
545
+
546
+ private fun getCashierReq() =
547
+ CashierRequest().apply {
548
+ clerkId = null
549
+ shiftId = null
550
+ }
551
+
552
+ private fun getCommercialReq() =
553
+ CommercialRequest().apply {
554
+ poNumber = null
555
+ customerCode = null
556
+ taxExempt = null
557
+ taxExemptId = null
558
+ merchantTaxId = null
559
+ destinationZipCode = null
560
+ productDescription = null
561
+ shipFromZipCode = null
562
+ destinationCountryCode = null
563
+ summaryCommodityCode = null
564
+ discountAmount = null
565
+ freightAmount = null
566
+ dutyAmount = null
567
+ orderDate = null
568
+ taxDetails = null
569
+ lineItemDetails = null
570
+ }
571
+
572
+ private fun getMotoECommerceReq() =
573
+ MotoECommerceRequest().apply {
574
+ mode = null
575
+ transactionType = null
576
+ secureType = null
577
+ orderNumber = null
578
+ installments = null
579
+ currentInstallment = null
580
+ }
581
+
582
+ private fun getRestaurantReq() =
583
+ Restaurant().apply {
584
+ tableNumber = null
585
+ guestNumber = null
586
+ ticketNumber = null
587
+ }
588
+
589
+ private fun getHostGatewayReq() =
590
+ HostGateway().apply {
591
+ hostReferenceNumber = null
592
+ gatewayId = null
593
+ tokenRequestFlag = null
594
+ token = null
595
+ cardType = null
596
+ passThruData = null
597
+ returnReason = null
598
+ stationId = null
599
+ globalUid = null
600
+ customizeData1 = null
601
+ customizeData2 = null
602
+ customizeData3 = null
603
+ ewicDiscountAmount = null
604
+ tokenSerialNumber = null
605
+ }
606
+
607
+ private fun getTransactionBehaviorReq() =
608
+ TransactionBehavior().apply {
609
+ val tip = salesRequest?.tip
610
+ signatureCaptureFlag = null
611
+ tipRequestFlag =
612
+ if (tip != null && tip > 0) TipRequestFlag.NOT_NEED_ENTER_TIP_ON_TERMINAL else TipRequestFlag.NEED_ENTER_TIP_ON_TERMINAL
613
+ signatureUploadFlag = null
614
+ statusReportFlag = null
615
+ acceptedCardType = null
616
+ programPromptsFlag = null
617
+ signatureAcquireFlag = null
618
+ entryMode = null
619
+ receiptPrintFlag = ReceiptPrintFlag.NO_RECEIPT
620
+ cardPresentMode = null
621
+ debitNetwork = null
622
+ userLanguage = null
623
+ additionalResponseDataFlag = null
624
+ forceCc = null
625
+ forceFsa = null
626
+ forceDuplicate = "1"
627
+ accessibilityPinPad = null
628
+ cofIndicator = null
629
+ cofInitiator = null
630
+ // giftCardIndicator = null
631
+ transactionPromptBitmap = null
632
+ }
633
+
634
+ private fun getOriginalReq() =
635
+ Original().apply {
636
+ transactionDate = null
637
+ pan = null
638
+ expiryDate = null
639
+ transactionTime = null
640
+ settlementDate = null
641
+ amount = null
642
+ batchNumber = null
643
+ paymentService2000 = null
644
+ authorizationResponse = null
645
+ transactionType = TransactionType.NOT_SET
646
+ }
647
+
648
+ private fun getMultiMerchantReq() =
649
+ MultiMerchant().apply {
650
+ multiMerchantId = null
651
+ multiMerchantName = null
652
+ }
653
+
654
+ private fun getFleetCardReq() =
655
+ FleetCardRequest().apply {
656
+ odometer = null
657
+ vehicleNumber = null
658
+ jobNumber = null
659
+ driverId = null
660
+ employeeNumber = null
661
+ licenseNumber = null
662
+ jobId = null
663
+ departmentNumber = null
664
+ customerData = null
665
+ userId = null
666
+ vehicleId = null
667
+ fleetPromptCode = null
668
+ }
669
+
670
+ private fun getLodgingInfoReq() =
671
+ Lodging().apply {
672
+ roomNumber = null
673
+ folioNumber = null
674
+ chargeType = null
675
+ noShowFlag = null
676
+ checkInDate = null
677
+ checkOutDate = null
678
+ specialProgramCode = null
679
+ departureAdjustedAmount = null
680
+ roomRates = null
681
+ lodgingItems = null
682
+ }
683
+
684
+ private fun getAutoRentalInfoReq() =
685
+ AutoRental().apply {
686
+ agreementNumber = null
687
+ dailyRate = null
688
+ rentalDuration = null
689
+ insuranceAmount = null
690
+ milesAllocated = null
691
+ mileRate = null
692
+ name = null
693
+ driverLicenseNumber = null
694
+ rentalProgramType = null
695
+ pickupLocationName = null
696
+ pickupCity = null
697
+ pickupState = null
698
+ pickupCountryCode = null
699
+ pickupDatetime = null
700
+ returnLocation = null
701
+ returnCity = null
702
+ returnState = null
703
+ returnCountryCode = null
704
+ returnDatetime = null
705
+ totalMiles = null
706
+ customerTaxId = null
707
+ extraChargesAmount = null
708
+ vehicleClassId = VehicleClassId.NOT_SET
709
+ extraChargeItems = null
710
+ }
711
+ }