@aptos-scp/scp-component-rn-device-services 0.2.6 → 0.2.7
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/ios/AurusEnterpriseSDK.framework/AurusEnterpriseSDK +0 -0
- package/ios/AurusEnterpriseSDK.framework/Headers/AurusEnterpriseSDK.h +30 -36
- package/ios/SCPRNDeviceServices/AurusPaymentTerminal.m +33 -37
- package/lib/AurusDevice/AurusDevice.d.ts +18 -16
- package/lib/AurusDevice/AurusDevice.js +173 -228
- package/lib/AurusDevice/AurusDevice.js.map +1 -1
- package/lib/AurusDevice/constants.d.ts +6 -5
- package/lib/AurusDevice/constants.js +8 -7
- package/lib/AurusDevice/constants.js.map +1 -1
- package/lib/AurusDevice/sdk-interface/AurusPaymentSupport.d.ts +1 -0
- package/lib/AurusDevice/sdk-interface/AurusPaymentSupport.js +12 -0
- package/lib/AurusDevice/sdk-interface/AurusPaymentSupport.js.map +1 -1
- package/lib/AurusDevice/sdk-interface/Upgrade.d.ts +23 -0
- package/lib/AurusDevice/sdk-interface/Upgrade.js +9 -0
- package/lib/AurusDevice/sdk-interface/Upgrade.js.map +1 -0
- package/lib/constants/constants.d.ts +6 -4
- package/lib/constants/constants.js +6 -4
- package/lib/constants/constants.js.map +1 -1
- package/package.json +1 -1
|
@@ -35,10 +35,14 @@ let AurusDevice = class AurusDevice {
|
|
|
35
35
|
* are created in the constructor, which only accepts JavaScript parameters.
|
|
36
36
|
*/
|
|
37
37
|
constructor() {
|
|
38
|
-
this.
|
|
38
|
+
this._initializeCalled = false;
|
|
39
39
|
this._listenersAdded = false;
|
|
40
|
+
this._registrationInProgress = false; // EMV Config now happens during registration
|
|
41
|
+
this._waitingForDeviceConnected = false;
|
|
40
42
|
this._scannerEnabled = true; //todo: once enable/disable is implemented in client, defaulting to false.
|
|
41
43
|
this._paymentEnvironment = "Aurus"; // string representation of payment environment for trans object
|
|
44
|
+
this._requestInProgress = false;
|
|
45
|
+
this._requestQueue = [];
|
|
42
46
|
const entryMessage = logger.traceEntry("constructor");
|
|
43
47
|
this._devicePaymentTerminal = react_native_1.NativeModules.AurusPaymentTerminal;
|
|
44
48
|
this._nativeEventEmitter = new react_native_1.NativeEventEmitter(react_native_1.NativeModules.AurusPaymentTerminal);
|
|
@@ -101,6 +105,7 @@ let AurusDevice = class AurusDevice {
|
|
|
101
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
106
|
const entryMessage = logger.traceEntry("enableScannerDevice");
|
|
103
107
|
this._scannerEnabled = true;
|
|
108
|
+
this.sendUpgradeRequest(constants_1.UpgradeType.ENABLE_SCANNER);
|
|
104
109
|
logger.traceExit(entryMessage);
|
|
105
110
|
});
|
|
106
111
|
}
|
|
@@ -108,6 +113,7 @@ let AurusDevice = class AurusDevice {
|
|
|
108
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
114
|
const entryMessage = logger.traceEntry("disableScannerDevice");
|
|
110
115
|
this._scannerEnabled = false;
|
|
116
|
+
this.sendUpgradeRequest(constants_1.UpgradeType.DISABLE_SCANNER);
|
|
111
117
|
logger.traceExit(entryMessage);
|
|
112
118
|
});
|
|
113
119
|
}
|
|
@@ -175,9 +181,7 @@ let AurusDevice = class AurusDevice {
|
|
|
175
181
|
processTimeout() {
|
|
176
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
183
|
const entryMessage = logger.traceEntry("processTimeout");
|
|
178
|
-
|
|
179
|
-
sdk_interface_1.AurusSupport.authResponse.status = "TIMEOUT WAITING FOR RESPONSE";
|
|
180
|
-
this._paymentEmitter.emit(_1.EventResponseTypes.Authorization, sdk_interface_1.AurusSupport.authResponse);
|
|
184
|
+
this.emitAuthorizationResponse(_1.ResponseCodes.Timeout, "TIMEOUT WAITING FOR RESPONSE");
|
|
181
185
|
//Send cancel to aurus
|
|
182
186
|
this.sendCancelTranRequest();
|
|
183
187
|
logger.traceExit(entryMessage);
|
|
@@ -188,24 +192,15 @@ let AurusDevice = class AurusDevice {
|
|
|
188
192
|
const entryMessage = logger.traceEntry("authorize", authRequest);
|
|
189
193
|
sdk_interface_1.AurusSupport.authRequest = authRequest;
|
|
190
194
|
sdk_interface_1.AurusSupport.authResponse = Object.assign({ paymentEnvironment: this._paymentEnvironment }, authRequest);
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
195
|
+
if (this._registrationInProgress) {
|
|
196
|
+
logger.debug("Payment is unavailalbe while device registration is in progress. Emitting error response.");
|
|
197
|
+
this.emitAuthorizationResponse(_1.ResponseCodes.Error, "Payment Unavailable. Device Registration in Progress");
|
|
198
|
+
}
|
|
199
|
+
else if (sdk_interface_1.AurusSupport.requireGetCard(authRequest)) {
|
|
200
|
+
this.sendGetCardBin(authRequest);
|
|
198
201
|
}
|
|
199
202
|
else {
|
|
200
|
-
|
|
201
|
-
if (this._initInProgress) {
|
|
202
|
-
sdk_interface_1.AurusSupport.authResponse.status = "EMV INIT IN PROGRESS";
|
|
203
|
-
}
|
|
204
|
-
else if (this._registrationInProgress) {
|
|
205
|
-
sdk_interface_1.AurusSupport.authResponse.status = "DEVICE REGISTRATION IN PROGRESS";
|
|
206
|
-
}
|
|
207
|
-
logger.debug(`Payment not initialized. Sending response: ${JSON.stringify(sdk_interface_1.AurusSupport.authResponse)}`);
|
|
208
|
-
this._paymentEmitter.emit(_1.EventResponseTypes.Authorization, sdk_interface_1.AurusSupport.authResponse);
|
|
203
|
+
this.sendCardTransRequest();
|
|
209
204
|
}
|
|
210
205
|
logger.traceExit(entryMessage);
|
|
211
206
|
});
|
|
@@ -214,17 +209,18 @@ let AurusDevice = class AurusDevice {
|
|
|
214
209
|
return __awaiter(this, void 0, void 0, function* () {
|
|
215
210
|
const entryMessage = logger.traceEntry("initializeNative");
|
|
216
211
|
if (!this._listenersAdded) {
|
|
212
|
+
this._listenersAdded = true;
|
|
217
213
|
let context = {};
|
|
218
214
|
this._nativeSubscriptions = [
|
|
219
215
|
this._nativeEventEmitter.addListener(native_onAESDKResponse, this.onAESDKResponse.bind(this), context),
|
|
220
216
|
this._nativeEventEmitter.addListener(native_onNotificationReceived, this.onNotificationReceived.bind(this), context),
|
|
221
217
|
this._nativeEventEmitter.addListener(native_onAESDKLogResponse, this.onAESDKLogResponse.bind(this), context)
|
|
222
218
|
];
|
|
223
|
-
this._listenersAdded = true;
|
|
224
219
|
}
|
|
225
|
-
if (!this.
|
|
220
|
+
if (!this._initializeCalled) {
|
|
221
|
+
this._initializeCalled = true;
|
|
222
|
+
this._waitingForDeviceConnected = true;
|
|
226
223
|
this._devicePaymentTerminal.initialize();
|
|
227
|
-
this._initialized = true;
|
|
228
224
|
}
|
|
229
225
|
logger.traceExit(entryMessage);
|
|
230
226
|
});
|
|
@@ -252,19 +248,14 @@ let AurusDevice = class AurusDevice {
|
|
|
252
248
|
// of events can be sent or just for safety.
|
|
253
249
|
let withResponse = args[0];
|
|
254
250
|
logger.debug(`In onAESDKResponse, withResponse: ${JSON.stringify(withResponse)}`);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
this._paymentEmitter.emit(_1.EventResponseTypes.PaymentDeviceStatus, sdk_interface_1.AurusSupport.paymentStatus);
|
|
261
|
-
sdk_interface_1.AurusSupport.paymentStatus = { deviceAvailable: false };
|
|
262
|
-
}
|
|
263
|
-
if (returnServer & constants_1.ResponseType.AuthResponse) {
|
|
264
|
-
// If returnServer has AuthResponse, send IAuthorizationResponse to POS.
|
|
265
|
-
logger.debug(`In onAESDKResponse, publishing authResponse: ${JSON.stringify(sdk_interface_1.AurusSupport.authResponse)}`);
|
|
266
|
-
this._paymentEmitter.emit(_1.EventResponseTypes.Authorization, sdk_interface_1.AurusSupport.authResponse);
|
|
251
|
+
if (this._requestInProgress) {
|
|
252
|
+
this._requestInProgress = false;
|
|
253
|
+
if (this._requestQueue.length > 0) {
|
|
254
|
+
this.sendRequest(this._requestQueue.shift());
|
|
255
|
+
}
|
|
267
256
|
}
|
|
257
|
+
// Parse xml and determine next steps. Call back into native if needed.
|
|
258
|
+
this.handleAESDKResponse(withResponse);
|
|
268
259
|
}
|
|
269
260
|
else {
|
|
270
261
|
throw logger.throwing(new Error("Empty event received. withResponse data is missing"), entryMessage);
|
|
@@ -275,28 +266,28 @@ let AurusDevice = class AurusDevice {
|
|
|
275
266
|
const entryMessage = logger.traceEntry("sendCancelTranRequest");
|
|
276
267
|
sdk_interface_1.AurusSupport.requestType = constants_1.RequestTypes.CancelTransaction;
|
|
277
268
|
let xmlreq = sdk_interface_1.AurusSupport.createCancelTranRequest();
|
|
278
|
-
this.
|
|
269
|
+
this.sendRequest(xmlreq);
|
|
279
270
|
logger.traceExit(entryMessage);
|
|
280
271
|
}
|
|
281
272
|
sendCancelLastTranRequest() {
|
|
282
273
|
const entryMessage = logger.traceEntry("sendCancelLastTranRequest");
|
|
283
274
|
sdk_interface_1.AurusSupport.requestType = constants_1.RequestTypes.CancelTransaction;
|
|
284
275
|
let xmlreq = sdk_interface_1.AurusSupport.createCancelLastTranRequest();
|
|
285
|
-
this.
|
|
276
|
+
this.sendRequest(xmlreq);
|
|
286
277
|
logger.traceExit(entryMessage);
|
|
287
278
|
}
|
|
288
279
|
sendTransRequest(getCardBinResp) {
|
|
289
280
|
const entryMessage = logger.traceEntry("sendTransRequest", getCardBinResp);
|
|
290
281
|
sdk_interface_1.AurusSupport.requestType = constants_1.RequestTypes.Transaction;
|
|
291
282
|
let xmlreq = sdk_interface_1.AurusSupport.createCardTranRequest(getCardBinResp);
|
|
292
|
-
this.
|
|
283
|
+
this.sendRequest(xmlreq);
|
|
293
284
|
logger.traceExit(entryMessage);
|
|
294
285
|
}
|
|
295
286
|
sendCardTransRequest() {
|
|
296
287
|
const entryMessage = logger.traceEntry("sendCardTransRequest");
|
|
297
288
|
sdk_interface_1.AurusSupport.requestType = constants_1.RequestTypes.Transaction;
|
|
298
289
|
let xmlreq = sdk_interface_1.AurusSupport.createCardTranRequest();
|
|
299
|
-
this.
|
|
290
|
+
this.sendRequest(xmlreq);
|
|
300
291
|
logger.traceExit(entryMessage);
|
|
301
292
|
}
|
|
302
293
|
/**
|
|
@@ -307,7 +298,7 @@ let AurusDevice = class AurusDevice {
|
|
|
307
298
|
const entryMessage = logger.traceEntry("sendGetCardBin", authRequest);
|
|
308
299
|
sdk_interface_1.AurusSupport.requestType = constants_1.RequestTypes.GetCardBin;
|
|
309
300
|
let xmlreq = sdk_interface_1.AurusSupport.createGetCardBinRequest();
|
|
310
|
-
this.
|
|
301
|
+
this.sendRequest(xmlreq);
|
|
311
302
|
logger.traceExit(entryMessage);
|
|
312
303
|
}
|
|
313
304
|
/**
|
|
@@ -319,32 +310,41 @@ let AurusDevice = class AurusDevice {
|
|
|
319
310
|
sdk_interface_1.AurusSupport.requestType = constants_1.RequestTypes.Registration;
|
|
320
311
|
let xmlreq = sdk_interface_1.AurusSupport.createAESDKRegistrationRequest();
|
|
321
312
|
this._registrationInProgress = true;
|
|
322
|
-
this.
|
|
313
|
+
this.sendRequest(xmlreq);
|
|
314
|
+
logger.traceExit(entryMessage);
|
|
315
|
+
}
|
|
316
|
+
sendUpgradeRequest(upgradeType) {
|
|
317
|
+
const entryMessage = logger.traceEntry("sendUpgradeRequest");
|
|
318
|
+
if (upgradeType !== constants_1.UpgradeType.ENABLE_SCANNER && upgradeType !== constants_1.UpgradeType.DISABLE_SCANNER) {
|
|
319
|
+
// Enable/Disable scanner is fire and forget and may interrupt other calls. Don't update the request type.
|
|
320
|
+
sdk_interface_1.AurusSupport.requestType = constants_1.RequestTypes.Upgrade;
|
|
321
|
+
}
|
|
322
|
+
let xmlreq = sdk_interface_1.AurusSupport.createUpgradeRequest(upgradeType);
|
|
323
|
+
this.sendRequest(xmlreq);
|
|
323
324
|
logger.traceExit(entryMessage);
|
|
324
325
|
}
|
|
325
326
|
handleAESDKResponse(xml) {
|
|
326
327
|
const entryMessage = logger.traceEntry("handleAESDKResponse", xml);
|
|
327
|
-
let returnServer = constants_1.ResponseType.None;
|
|
328
328
|
let xmlResponse = this.convertXmlToJs(xml);
|
|
329
329
|
if (!xmlResponse) {
|
|
330
330
|
logger.warn(`In handleAESDKResponse, unable to convert to JSON: ${xml}`);
|
|
331
331
|
}
|
|
332
332
|
else if (constants_1.AesdkResponseTypes.Registration in xmlResponse) {
|
|
333
|
-
|
|
333
|
+
this.processAESDKRegistration(xmlResponse[constants_1.AesdkResponseTypes.Registration]);
|
|
334
334
|
}
|
|
335
335
|
else if (constants_1.AesdkResponseTypes.GetCardBin in xmlResponse) {
|
|
336
|
-
|
|
336
|
+
this.processGetCardBin(xmlResponse[constants_1.AesdkResponseTypes.GetCardBin]);
|
|
337
337
|
}
|
|
338
338
|
else if (constants_1.AesdkResponseTypes.Transaction in xmlResponse) {
|
|
339
|
-
|
|
339
|
+
this.processTrans(xmlResponse[constants_1.AesdkResponseTypes.Transaction]);
|
|
340
340
|
}
|
|
341
341
|
else if (constants_1.AesdkResponseTypes.AESDK in xmlResponse) {
|
|
342
|
-
|
|
342
|
+
this.processAESDK(xmlResponse[constants_1.AesdkResponseTypes.AESDK]);
|
|
343
343
|
}
|
|
344
344
|
else if (constants_1.AesdkResponseTypes.CancelTransaction in xmlResponse) {
|
|
345
|
-
|
|
345
|
+
this.processCancelTrans(xmlResponse[constants_1.AesdkResponseTypes.CancelTransaction]);
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
logger.traceExit(entryMessage);
|
|
348
348
|
}
|
|
349
349
|
convertXmlToJs(xml) {
|
|
350
350
|
const entryMessage = logger.traceEntry("convertXmlToJs", xml);
|
|
@@ -358,11 +358,9 @@ let AurusDevice = class AurusDevice {
|
|
|
358
358
|
}
|
|
359
359
|
processTrans(response) {
|
|
360
360
|
const entryMessage = logger.traceEntry("processTrans", response);
|
|
361
|
-
let responseType = constants_1.ResponseType.AuthResponse;
|
|
362
361
|
let tranDetails = response.TransDetailsData.TransDetailData;
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (sdk_interface_1.AurusSupport.authResponse.responseCode === _1.ResponseCodes.Approved) {
|
|
362
|
+
const responseCode = this.mapAurusResponseCode(tranDetails.ResponseCode.value);
|
|
363
|
+
if (responseCode === _1.ResponseCodes.Approved) {
|
|
366
364
|
sdk_interface_1.AurusSupport.authResponse.approvedAmount = sdk_interface_1.AurusSupport.stringToMoney(tranDetails.TransactionAmount.value);
|
|
367
365
|
sdk_interface_1.AurusSupport.authResponse.cardNumber = tranDetails.CardNumber.value;
|
|
368
366
|
sdk_interface_1.AurusSupport.authResponse.cardType = this.mapAurusCardType(tranDetails.CardType.value);
|
|
@@ -373,7 +371,7 @@ let AurusDevice = class AurusDevice {
|
|
|
373
371
|
sdk_interface_1.AurusSupport.authResponse.EMVData = this.parseEMVData(tranDetails.EMVData.value);
|
|
374
372
|
sdk_interface_1.AurusSupport.authResponse.EMVData.receiptData = tranDetails.EMVData && tranDetails.EMVData.value &&
|
|
375
373
|
tranDetails.EMVData.value.replace(/~/g, ": ").split("[FS]");
|
|
376
|
-
// FIXME: AdditionalReceiptInfo should be parsed based on the format of the aurus response.
|
|
374
|
+
// FIXME: AdditionalReceiptInfo should be parsed based on the format of the aurus response.
|
|
377
375
|
// Resolve when we receive next sdk with correct format
|
|
378
376
|
sdk_interface_1.AurusSupport.authResponse.receiptData =
|
|
379
377
|
tranDetails.AdditionalReceiptInfo && [tranDetails.AdditionalReceiptInfo.value];
|
|
@@ -382,32 +380,27 @@ let AurusDevice = class AurusDevice {
|
|
|
382
380
|
this.mapAurusSignatureRequired(tranDetails.SignatureReceiptFlag.value);
|
|
383
381
|
sdk_interface_1.AurusSupport.authResponse.pinCaptured = this.mapAurusPinCaptured(tranDetails.SignatureReceiptFlag.value);
|
|
384
382
|
}
|
|
385
|
-
|
|
383
|
+
this.emitAuthorizationResponse(responseCode, tranDetails.TransactionResponseText.value);
|
|
384
|
+
logger.traceExit(entryMessage);
|
|
386
385
|
}
|
|
387
386
|
processGetCardBin(response) {
|
|
388
387
|
const entryMessage = logger.traceEntry("processGetCardBin", response);
|
|
389
|
-
let responseType = constants_1.ResponseType.None;
|
|
390
388
|
if (sdk_interface_1.AurusSupport.requestType === constants_1.RequestTypes.GetCardBin) {
|
|
391
389
|
if (response.ResponseCode.value === constants_1.ResponseCodes.Approved) {
|
|
392
390
|
this.sendTransRequest(response);
|
|
393
391
|
}
|
|
394
392
|
else {
|
|
395
|
-
|
|
396
|
-
sdk_interface_1.AurusSupport.authResponse.responseCode = this.mapAurusResponseCode(response.ResponseCode.value);
|
|
397
|
-
sdk_interface_1.AurusSupport.authResponse.status = response.ResponseText.value;
|
|
393
|
+
this.emitAuthorizationResponse(this.mapAurusResponseCode(response.ResponseCode.value), response.ResponseText.value);
|
|
398
394
|
}
|
|
399
395
|
}
|
|
400
396
|
else {
|
|
401
397
|
//handle additional request types with getcardbinresponses
|
|
402
|
-
|
|
403
|
-
sdk_interface_1.AurusSupport.authResponse.responseCode = _1.ResponseCodes.Error;
|
|
404
|
-
sdk_interface_1.AurusSupport.authResponse.status = response.ResponseText.value;
|
|
398
|
+
this.emitAuthorizationResponse(_1.ResponseCodes.Error, response.ResponseText.value);
|
|
405
399
|
}
|
|
406
|
-
|
|
400
|
+
logger.traceExit(entryMessage);
|
|
407
401
|
}
|
|
408
402
|
processCancelTrans(response) {
|
|
409
403
|
const entryMessage = logger.traceEntry("processCancelTrans", response);
|
|
410
|
-
let responseType = constants_1.ResponseType.None;
|
|
411
404
|
if (response.ResponseCode.value === constants_1.ResponseCodes.Approved) {
|
|
412
405
|
logger.debug(`processCancelTrans success: ${sdk_interface_1.AurusSupport.authResponse.posReference}`);
|
|
413
406
|
}
|
|
@@ -416,44 +409,39 @@ let AurusDevice = class AurusDevice {
|
|
|
416
409
|
logger.debug(`processCancelTrans failed, attempting CancelLastTrans: ${sdk_interface_1.AurusSupport.authRequest.transactionNumber}`);
|
|
417
410
|
this.sendCancelLastTranRequest();
|
|
418
411
|
}
|
|
419
|
-
|
|
412
|
+
logger.traceExit(entryMessage);
|
|
420
413
|
}
|
|
421
414
|
processAESDKRegistration(response) {
|
|
422
415
|
const entryMessage = logger.traceEntry("processAESDKRegistration", response);
|
|
423
|
-
let responseType = constants_1.ResponseType.None;
|
|
424
416
|
if (sdk_interface_1.AurusSupport.requestType === constants_1.RequestTypes.GetCardBin) {
|
|
425
|
-
responseType |= constants_1.ResponseType.AuthResponse;
|
|
426
|
-
sdk_interface_1.AurusSupport.authResponse.responseCode = _1.ResponseCodes.Error;
|
|
427
|
-
sdk_interface_1.AurusSupport.authResponse.status = response.ResponseText.value;
|
|
428
417
|
if (response.ResponseCode.value === constants_1.ResponseCodes.DeviceNotRegistered) {
|
|
429
418
|
this.sendAESDKRegistration(sdk_interface_1.AurusSupport.authRequest);
|
|
430
419
|
}
|
|
420
|
+
this.emitAuthorizationResponse(_1.ResponseCodes.Error, response.ResponseText.value);
|
|
431
421
|
}
|
|
432
422
|
if (sdk_interface_1.AurusSupport.requestType === constants_1.RequestTypes.Registration) {
|
|
433
|
-
responseType |= constants_1.ResponseType.PaymentStatus;
|
|
434
|
-
sdk_interface_1.AurusSupport.paymentStatus.deviceAvailable = true;
|
|
435
|
-
sdk_interface_1.AurusSupport.paymentStatus.status = response.ResponseText.value;
|
|
436
|
-
sdk_interface_1.AurusSupport.paymentStatus.statusCode = _1.StatusCode.InitializationComplete;
|
|
437
423
|
this._registrationInProgress = false;
|
|
424
|
+
this.emitPaymentStatus(true, _1.StatusCode.InitializationComplete);
|
|
425
|
+
//enable/disable scanner
|
|
426
|
+
this._scannerEnabled ? this.enableScannerDevice() : this.disableScannerDevice();
|
|
438
427
|
}
|
|
439
|
-
|
|
428
|
+
logger.traceExit(entryMessage);
|
|
440
429
|
}
|
|
441
430
|
processAESDK(response) {
|
|
442
431
|
const entryMessage = logger.traceEntry("processAESDK", response);
|
|
443
|
-
let responseType = constants_1.ResponseType.None;
|
|
444
432
|
if (sdk_interface_1.AurusSupport.requestType === constants_1.RequestTypes.GetCardBin) {
|
|
445
|
-
|
|
446
|
-
sdk_interface_1.AurusSupport.authResponse.responseCode = _1.ResponseCodes.Error;
|
|
447
|
-
sdk_interface_1.AurusSupport.authResponse.status = response.ResponseText.value;
|
|
433
|
+
this.emitAuthorizationResponse(_1.ResponseCodes.Error, response.ResponseText.value);
|
|
448
434
|
}
|
|
435
|
+
// this scenario could happen if the registration request fails
|
|
449
436
|
if (sdk_interface_1.AurusSupport.requestType === constants_1.RequestTypes.Registration) {
|
|
450
|
-
responseType |= constants_1.ResponseType.PaymentStatus;
|
|
451
|
-
sdk_interface_1.AurusSupport.paymentStatus.deviceAvailable = true;
|
|
452
|
-
sdk_interface_1.AurusSupport.paymentStatus.status = response.ResponseText.value;
|
|
453
|
-
sdk_interface_1.AurusSupport.paymentStatus.statusCode = _1.StatusCode.InitializationComplete;
|
|
454
437
|
this._registrationInProgress = false;
|
|
438
|
+
// enable payment button or it will be permanately disabled without the user knowing why
|
|
439
|
+
// registration can be re-attempted when clicked and/or an error given to the user
|
|
440
|
+
this.emitPaymentStatus(true, _1.StatusCode.InitializationComplete);
|
|
441
|
+
//enable/disable scanner
|
|
442
|
+
this._scannerEnabled ? this.enableScannerDevice() : this.disableScannerDevice();
|
|
455
443
|
}
|
|
456
|
-
|
|
444
|
+
logger.traceExit(entryMessage);
|
|
457
445
|
}
|
|
458
446
|
mapAurusResponseCode(responseCode) {
|
|
459
447
|
const entryMessage = logger.traceEntry("mapAurusResponseCode", responseCode);
|
|
@@ -565,180 +553,137 @@ let AurusDevice = class AurusDevice {
|
|
|
565
553
|
;
|
|
566
554
|
return logger.traceExit(entryMessage, emvData);
|
|
567
555
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
556
|
+
/**
|
|
557
|
+
* This method handles events published by the native components. This is an adapter between the native and JavaScript
|
|
558
|
+
* components for asynchronous events from the native layer.
|
|
559
|
+
*/
|
|
560
|
+
onNotificationReceived(...args) {
|
|
561
|
+
const entryMessage = logger.traceEntry("onNotificationReceived", args);
|
|
562
|
+
if (args.length >= 1 && args[0]) {
|
|
563
|
+
const userInfo = args[0];
|
|
564
|
+
logger.debug(`In onNotificationReceived, userInfo: ${JSON.stringify(userInfo)}`);
|
|
565
|
+
this.handleNotificationEvent(userInfo);
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
throw logger.throwing(new Error("Empty event received. userInfo data is missing"), entryMessage);
|
|
569
|
+
}
|
|
570
|
+
logger.traceExit(entryMessage);
|
|
571
|
+
}
|
|
572
|
+
handleNotificationEvent(userInfo) {
|
|
573
|
+
if (userInfo && userInfo.CODE !== undefined) {
|
|
574
|
+
(({
|
|
575
|
+
[NotificationEvent.BarcodeInformation]: () => { this.handleBarcodeInformationEvent(userInfo.AE_BARCODE_INFO); },
|
|
576
|
+
[NotificationEvent.DeviceNotConnected]: () => { this.handleDeviceNotConnectedEvent(); },
|
|
577
|
+
[NotificationEvent.DeviceConnected]: () => { this.handleDeviceConnectedEvent(); },
|
|
578
|
+
[NotificationEvent.DeviceConfigurationStarted]: () => { this.handleDeviceConfigurationStartedEvent(); },
|
|
579
|
+
[NotificationEvent.DeviceConfigurationCompleted]: () => { this.handleDeviceConfigurationCompletedEvent(); },
|
|
580
|
+
[NotificationEvent.DeviceConfigurationFailed]: () => { this.handleDeviceConfigurationFailedEvent(); },
|
|
581
|
+
[NotificationEvent.DeviceAlreadyConfigured]: () => { this.handleDeviceAlreadyConfiguredEvent(); }
|
|
582
|
+
})[userInfo.CODE] || (() => { this.handleDefaultEvent(userInfo.CODE); }))();
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
handleBarcodeInformationEvent(xmlBarcodeInfo) {
|
|
586
|
+
const entryMessage = logger.traceEntry("handleBarcodeInformationEvent", xmlBarcodeInfo);
|
|
571
587
|
if (!this._scannerEnabled) {
|
|
572
588
|
logger.debug("Scanning is not enabled, not processing the scan.");
|
|
573
589
|
// todo: make a sound to indicate the scan failed due to not being enabled.
|
|
574
590
|
}
|
|
575
591
|
else {
|
|
576
|
-
let xmlResponse = this.convertXmlToJs(
|
|
592
|
+
let xmlResponse = this.convertXmlToJs(xmlBarcodeInfo);
|
|
577
593
|
if (!xmlResponse) {
|
|
578
|
-
logger.warn(`In
|
|
594
|
+
logger.warn(`In handleBarcodeInformationEvent, unable to convert to JSON: ${xmlBarcodeInfo}`);
|
|
579
595
|
}
|
|
580
596
|
else if (constants_1.AesdkResponseTypes.Barcode in xmlResponse) {
|
|
581
|
-
|
|
597
|
+
this.processBarcodeData(xmlResponse[constants_1.AesdkResponseTypes.Barcode]);
|
|
582
598
|
}
|
|
583
599
|
else {
|
|
584
|
-
logger.warn(`In
|
|
600
|
+
logger.warn(`In handleBarcodeInformationEvent, unexpected root element received, ignoring xml: ${xmlBarcodeInfo}`);
|
|
585
601
|
}
|
|
586
602
|
}
|
|
587
|
-
|
|
588
|
-
this._scannerEmitter.emit(_1.EventResponseTypes.Scan, scanDataNotification);
|
|
589
|
-
}
|
|
590
|
-
return logger.traceExit(entryMessage, scanDataNotification);
|
|
603
|
+
logger.traceExit(entryMessage);
|
|
591
604
|
}
|
|
592
605
|
processBarcodeData(barcode) {
|
|
593
606
|
const entryMessage = logger.traceEntry("processBarcodeData", barcode);
|
|
594
|
-
|
|
607
|
+
const scanDataNotification = {
|
|
595
608
|
data: barcode.Barcode.value,
|
|
596
609
|
encoding: sdk_interface_1.AurusSupport.getBarcodeType(barcode.BarcodeType.value)
|
|
597
|
-
}
|
|
610
|
+
};
|
|
611
|
+
logger.debug(`In processBarcodeData, publishing scanDataNotification: ${JSON.stringify(scanDataNotification)}`);
|
|
612
|
+
this._scannerEmitter.emit(_1.EventResponseTypes.Scan, scanDataNotification);
|
|
613
|
+
logger.traceExit(entryMessage);
|
|
598
614
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
const notificationUserInfo = args[0];
|
|
610
|
-
logger.debug(`In onNotificationReceived, notificationUserInfo: ${JSON.stringify(notificationUserInfo)}`);
|
|
611
|
-
switch (notificationUserInfo.CODE) {
|
|
612
|
-
// TODO: Determine if we want to use any the commented out events. (Status messages, logging, etc.)
|
|
613
|
-
// case NotificationEvent.ProcessingRequest: {
|
|
614
|
-
// break;
|
|
615
|
-
// }
|
|
616
|
-
// case NotificationEvent.SwipeOrInsertOrTap: {
|
|
617
|
-
// break;
|
|
618
|
-
// }
|
|
619
|
-
// case NotificationEvent.EnterManualCardEntry: {
|
|
620
|
-
// break;
|
|
621
|
-
// }
|
|
622
|
-
// case NotificationEvent.Processing: {
|
|
623
|
-
// break;
|
|
624
|
-
// }
|
|
625
|
-
// case NotificationEvent.CardAuthorization: {
|
|
626
|
-
// break;
|
|
627
|
-
// }
|
|
628
|
-
// case NotificationEvent.EnterPIN: {
|
|
629
|
-
// break;
|
|
630
|
-
// }
|
|
631
|
-
// case NotificationEvent.EnterZIP: {
|
|
632
|
-
// break;
|
|
633
|
-
// }
|
|
634
|
-
// case NotificationEvent.EnterSSN: {
|
|
635
|
-
// break;
|
|
636
|
-
// }
|
|
637
|
-
// case NotificationEvent.EnterSIN: {
|
|
638
|
-
// break;
|
|
639
|
-
// }
|
|
640
|
-
// case NotificationEvent.EnterAnnualDebitIncome: {
|
|
641
|
-
// break;
|
|
642
|
-
// }
|
|
643
|
-
// case NotificationEvent.EnterMonthlyDebitIncome: {
|
|
644
|
-
// break;
|
|
645
|
-
// }
|
|
646
|
-
// case NotificationEvent.EnterPhoneNumber: {
|
|
647
|
-
// break;
|
|
648
|
-
// }
|
|
649
|
-
// case NotificationEvent.EnterPasscode: {
|
|
650
|
-
// break;
|
|
651
|
-
// }
|
|
652
|
-
// case NotificationEvent.EnterExpiryDate: {
|
|
653
|
-
// break;
|
|
654
|
-
// }
|
|
655
|
-
// case NotificationEvent.EnterCVV: {
|
|
656
|
-
// break;
|
|
657
|
-
// }
|
|
658
|
-
// case NotificationEvent.EnterTIP: {
|
|
659
|
-
// break;
|
|
660
|
-
// }
|
|
661
|
-
// case NotificationEvent.Confirmation: {
|
|
662
|
-
// break;
|
|
663
|
-
// }
|
|
664
|
-
// case NotificationEvent.ProcessingTransaction: {
|
|
665
|
-
// break;
|
|
666
|
-
// }
|
|
667
|
-
case NotificationEvent.BarcodeInformation: {
|
|
668
|
-
//await this.handleBarcodeDataReceived(notificationUserInfo.AE_BARCODE_INFO);
|
|
669
|
-
this.handleBarcodeDataReceived(notificationUserInfo.AE_BARCODE_INFO);
|
|
670
|
-
break;
|
|
671
|
-
}
|
|
672
|
-
// case NotificationEvent.DeviceNotConnected: {
|
|
673
|
-
// break;
|
|
674
|
-
// }
|
|
675
|
-
// case NotificationEvent.DeviceConnecting: {
|
|
676
|
-
// break;
|
|
677
|
-
// }
|
|
678
|
-
// case NotificationEvent.DeviceConnected: {
|
|
679
|
-
// break;
|
|
680
|
-
// }
|
|
681
|
-
case NotificationEvent.DeviceConfigurationStarted: {
|
|
682
|
-
this._initInProgress = true;
|
|
683
|
-
break;
|
|
684
|
-
}
|
|
685
|
-
case NotificationEvent.DeviceConfigurationCompleted: {
|
|
686
|
-
this._initInProgress = false;
|
|
687
|
-
this.sendAESDKRegistration(sdk_interface_1.AurusSupport.authRequest);
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
case NotificationEvent.DeviceConfigurationFailed: {
|
|
691
|
-
logger.debug("In onNotificationReceived, DeviceConfigurationFailed");
|
|
692
|
-
this._initInProgress = false;
|
|
693
|
-
break;
|
|
694
|
-
}
|
|
695
|
-
case NotificationEvent.DeviceAlreadyConfigured: {
|
|
696
|
-
this.sendAESDKRegistration(sdk_interface_1.AurusSupport.authRequest);
|
|
697
|
-
break;
|
|
698
|
-
}
|
|
699
|
-
// case NotificationEvent.FileDownloading: {
|
|
700
|
-
// break;
|
|
701
|
-
// }
|
|
702
|
-
// case NotificationEvent.FileDownloadFailed: {
|
|
703
|
-
// break;
|
|
704
|
-
// }
|
|
705
|
-
// case NotificationEvent.FileDownloadRetrying: {
|
|
706
|
-
// break;
|
|
707
|
-
// }
|
|
708
|
-
// case NotificationEvent.FileUpgradingToPED: {
|
|
709
|
-
// break;
|
|
710
|
-
// }
|
|
711
|
-
// case NotificationEvent.FileUpgradingToPEDFailed: {
|
|
712
|
-
// break;
|
|
713
|
-
// }
|
|
714
|
-
// case NotificationEvent.FileUpgradingToPEDCompleted: {
|
|
715
|
-
// break;
|
|
716
|
-
// }
|
|
717
|
-
// case NotificationEvent.FileTransferToPEDInfo: {
|
|
718
|
-
// break;
|
|
719
|
-
// }
|
|
720
|
-
// case NotificationEvent.FileTransferToPEDProgress: {
|
|
721
|
-
// break;
|
|
722
|
-
// }
|
|
723
|
-
// case NotificationEvent.None: {
|
|
724
|
-
// break;
|
|
725
|
-
// }
|
|
726
|
-
default: {
|
|
727
|
-
// logger.debug(`notificationUserInfo.CODE not handled: ${notificationUserInfo.CODE}`);
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
615
|
+
handleDeviceNotConnectedEvent() {
|
|
616
|
+
const entryMessage = logger.traceEntry("handleDeviceNotConnectedEvent");
|
|
617
|
+
this.emitPaymentStatus(false, _1.StatusCode.DeviceDisconnected);
|
|
618
|
+
logger.traceExit(entryMessage);
|
|
619
|
+
}
|
|
620
|
+
handleDeviceConnectedEvent() {
|
|
621
|
+
const entryMessage = logger.traceEntry("handleDeviceConnectedEvent");
|
|
622
|
+
if (this._waitingForDeviceConnected) {
|
|
623
|
+
this._waitingForDeviceConnected = false;
|
|
624
|
+
this.sendAESDKRegistration(sdk_interface_1.AurusSupport.authRequest);
|
|
731
625
|
}
|
|
732
626
|
else {
|
|
733
|
-
|
|
627
|
+
this.emitPaymentStatus(true, _1.StatusCode.DeviceReconnected);
|
|
628
|
+
//enable/disable scanner
|
|
629
|
+
this._scannerEnabled ? this.enableScannerDevice() : this.disableScannerDevice();
|
|
734
630
|
}
|
|
735
631
|
logger.traceExit(entryMessage);
|
|
736
632
|
}
|
|
633
|
+
handleDeviceConfigurationStartedEvent() {
|
|
634
|
+
const entryMessage = logger.traceEntry("handleDeviceConfigurationStartedEvent");
|
|
635
|
+
logger.traceExit(entryMessage);
|
|
636
|
+
}
|
|
637
|
+
handleDeviceConfigurationCompletedEvent() {
|
|
638
|
+
const entryMessage = logger.traceEntry("handleDeviceConfigurationCompletedEvent");
|
|
639
|
+
logger.traceExit(entryMessage);
|
|
640
|
+
}
|
|
641
|
+
handleDeviceConfigurationFailedEvent() {
|
|
642
|
+
const entryMessage = logger.traceEntry("handleDeviceConfigurationFailedEvent");
|
|
643
|
+
logger.traceExit(entryMessage);
|
|
644
|
+
}
|
|
645
|
+
handleDeviceAlreadyConfiguredEvent() {
|
|
646
|
+
const entryMessage = logger.traceEntry("handleDeviceAlreadyConfiguredEvent");
|
|
647
|
+
logger.traceExit(entryMessage);
|
|
648
|
+
}
|
|
649
|
+
handleDefaultEvent(userInfoCode) {
|
|
650
|
+
// Should we log this? If we do, we should convert the userInfoCode into readable text.
|
|
651
|
+
}
|
|
652
|
+
emitPaymentStatus(deviceAvailable, statusCode) {
|
|
653
|
+
const entryMessage = logger.traceEntry("emitPaymentStatus");
|
|
654
|
+
sdk_interface_1.AurusSupport.paymentStatus.deviceAvailable = deviceAvailable;
|
|
655
|
+
sdk_interface_1.AurusSupport.paymentStatus.statusCode = statusCode;
|
|
656
|
+
logger.debug(`In emitPaymentStatus, publishing paymentStatus: ${JSON.stringify(sdk_interface_1.AurusSupport.paymentStatus)}`);
|
|
657
|
+
this._paymentEmitter.emit(_1.EventResponseTypes.PaymentDeviceStatus, sdk_interface_1.AurusSupport.paymentStatus);
|
|
658
|
+
sdk_interface_1.AurusSupport.paymentStatus = { deviceAvailable: false };
|
|
659
|
+
logger.traceExit(entryMessage);
|
|
660
|
+
}
|
|
661
|
+
emitAuthorizationResponse(responseCode, status) {
|
|
662
|
+
const entryMessage = logger.traceEntry("emitAuthorizationResponse");
|
|
663
|
+
sdk_interface_1.AurusSupport.authResponse.responseCode = responseCode;
|
|
664
|
+
sdk_interface_1.AurusSupport.authResponse.status = status;
|
|
665
|
+
logger.debug(`In emitAuthorizationResponse, publishing authResponse: ${JSON.stringify(sdk_interface_1.AurusSupport.authResponse)}`);
|
|
666
|
+
this._paymentEmitter.emit(_1.EventResponseTypes.Authorization, sdk_interface_1.AurusSupport.authResponse);
|
|
667
|
+
logger.traceExit(entryMessage);
|
|
668
|
+
}
|
|
737
669
|
onAESDKLogResponse(...args) {
|
|
738
670
|
if (args.length >= 1 && args[0]) {
|
|
739
671
|
logger.debug(`onAESDKLogResponse: ${args[0]}`);
|
|
740
672
|
}
|
|
741
673
|
}
|
|
674
|
+
sendRequest(xmlRequest) {
|
|
675
|
+
logger.debug(`sendRequest: _requestInProgress = ${this._requestInProgress}`);
|
|
676
|
+
if (this._requestInProgress) {
|
|
677
|
+
// Note: This is being used to maintain order for rapid requests.
|
|
678
|
+
// It safeguards against enable/disable scanner from POS at the same time as other requests.
|
|
679
|
+
// If additional use cases are added, this should be revisted as well to maintain additional data.
|
|
680
|
+
this._requestQueue.push(xmlRequest);
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
this._requestInProgress = true;
|
|
684
|
+
this._devicePaymentTerminal.OnAESDKProcessRequest(xmlRequest);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
742
687
|
};
|
|
743
688
|
AurusDevice = __decorate([
|
|
744
689
|
inversify_1.injectable(),
|