@aptos-scp/scp-component-rn-device-services 0.0.2 → 0.1.0
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/SCPRNDeviceServices/AurusPaymentTerminal.m +41 -10
- package/lib/AurusDevice/AurusDevice.d.ts +94 -0
- package/lib/AurusDevice/{AurusPaymentDevice.js → AurusDevice.js} +226 -97
- package/lib/AurusDevice/AurusDevice.js.map +1 -0
- package/lib/AurusDevice/constants.d.ts +1 -0
- package/lib/AurusDevice/constants.js +1 -0
- package/lib/AurusDevice/constants.js.map +1 -1
- package/lib/AurusDevice/index.d.ts +1 -1
- package/lib/AurusDevice/index.js +1 -1
- package/lib/AurusDevice/index.js.map +1 -1
- package/lib/AurusDevice/sdk-interface/AurusPaymentSupport.js +59 -41
- package/lib/AurusDevice/sdk-interface/AurusPaymentSupport.js.map +1 -1
- package/lib/AurusDevice/sdk-interface/Barcode.d.ts +15 -0
- package/lib/AurusDevice/sdk-interface/Barcode.js +9 -0
- package/lib/AurusDevice/sdk-interface/Barcode.js.map +1 -0
- package/lib/AurusDevice/sdk-interface/index.d.ts +1 -0
- package/lib/PaymentDeviceFactory.d.ts +3 -3
- package/lib/PaymentDeviceFactory.js +14 -20
- package/lib/PaymentDeviceFactory.js.map +1 -1
- package/lib/PaymentDeviceService.d.ts +12 -12
- package/lib/PaymentDeviceService.js +99 -70
- package/lib/PaymentDeviceService.js.map +1 -1
- package/lib/ScannerDeviceFactory.d.ts +11 -0
- package/lib/ScannerDeviceFactory.js +27 -0
- package/lib/ScannerDeviceFactory.js.map +1 -0
- package/lib/ScannerDeviceService.d.ts +13 -0
- package/lib/ScannerDeviceService.js +110 -0
- package/lib/ScannerDeviceService.js.map +1 -0
- package/lib/configs/inversify/inversify.config.d.ts +3 -0
- package/lib/configs/inversify/inversify.config.js +18 -0
- package/lib/configs/inversify/inversify.config.js.map +1 -0
- package/lib/constants/constants.d.ts +4 -3
- package/lib/constants/constants.js +5 -4
- package/lib/constants/constants.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/interfaces/index.d.ts +1 -0
- package/lib/interfaces/payment/IPayment.d.ts +20 -16
- package/lib/interfaces/scanner/IScanner.d.ts +29 -0
- package/lib/interfaces/scanner/IScanner.js +3 -0
- package/lib/interfaces/scanner/IScanner.js.map +1 -0
- package/lib/interfaces/scanner/index.d.ts +1 -0
- package/lib/interfaces/scanner/index.js +3 -0
- package/lib/interfaces/scanner/index.js.map +1 -0
- package/package.json +1 -1
- package/types/es-symbol/index.d.ts +4 -0
- package/types/react-native-xml2js/index.d.ts +5 -0
- package/lib/AurusDevice/AurusPaymentDevice.d.ts +0 -77
- package/lib/AurusDevice/AurusPaymentDevice.js.map +0 -1
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
NSString* const native_onAESDKResponse = @"onAESDKResponse";
|
|
14
14
|
NSString* const native_onAESDKResponse_name = @"native_onAESDKResponse";
|
|
15
|
+
NSString* const native_onBarcodeDataReceived = @"onBarcodeDataReceived";
|
|
16
|
+
NSString* const native_onBarcodeDataReceived_name = @"native_onBarcodeDataReceived";
|
|
15
17
|
|
|
16
18
|
@interface AurusPaymentTerminal ()
|
|
17
19
|
|
|
18
|
-
@property
|
|
20
|
+
@property AurusEnterpriseSDK* aesdk;
|
|
19
21
|
|
|
20
22
|
@end
|
|
21
23
|
|
|
@@ -27,27 +29,48 @@ RCT_EXPORT_MODULE();
|
|
|
27
29
|
|
|
28
30
|
- (NSDictionary *)constantsToExport {
|
|
29
31
|
return @{
|
|
30
|
-
native_onAESDKResponse_name: native_onAESDKResponse
|
|
32
|
+
native_onAESDKResponse_name: native_onAESDKResponse,
|
|
33
|
+
native_onBarcodeDataReceived_name: native_onBarcodeDataReceived
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
#pragma mark - Exported to JavaScript methods
|
|
35
38
|
|
|
39
|
+
static BOOL configurationComplete = NO;
|
|
40
|
+
|
|
36
41
|
RCT_EXPORT_METHOD(initialize) {
|
|
37
|
-
RCTLog(@"In AurusPaymentTerminal.initialize, creating AurusEnterpriseSDK. This starts the connection and EMV configuration.");
|
|
38
42
|
if (!self.aesdk) {
|
|
43
|
+
RCTLog(@"In AurusPaymentTerminal.initialize, creating AurusEnterpriseSDK.");
|
|
39
44
|
self.aesdk = [[AurusEnterpriseSDK alloc] init];
|
|
40
|
-
}
|
|
41
|
-
if (!self.aesdk.setAESDKDelegateRefference) {
|
|
42
45
|
self.aesdk.setAESDKDelegateRefference = self;
|
|
46
|
+
|
|
47
|
+
static BOOL observersAdded = NO;
|
|
48
|
+
if (!observersAdded) {
|
|
49
|
+
RCTLog(@"In AurusPaymentTerminal.initialize, adding IPC_BARCODE_DATA observer.");
|
|
50
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onBarcodeDataReceived:) name:@"IPC_BARCODE_DATA" object:nil];
|
|
51
|
+
observersAdded = YES;
|
|
52
|
+
} else {
|
|
53
|
+
// prevents multiple observers from being added when the app is reloaded
|
|
54
|
+
RCTLog(@"In AurusPaymentTerminal.initialize, app was reloaded and observers are already added.");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!configurationComplete) {
|
|
58
|
+
RCTLog(@"In AurusPaymentTerminal.initialize, EMV configuration should be starting.");
|
|
59
|
+
} else {
|
|
60
|
+
// allows payment to function as normal when app is reloaded
|
|
61
|
+
RCTLog(@"In AurusPaymentTerminal.initialize, app was reloaded and EMV is already configured.");
|
|
62
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
63
|
+
// sending on main thread to prevent UI timing issues
|
|
64
|
+
[self onAESDKResponse:@"DEVICE_ALREADY_CONFIGURED"];
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
RCTLog(@"In AurusPaymentTerminal.initialize, already initialized.");
|
|
43
69
|
}
|
|
44
70
|
}
|
|
45
71
|
|
|
46
72
|
RCT_EXPORT_METHOD(OnAESDKProcessRequest:(NSString*)WithRequest) {
|
|
47
73
|
RCTLog(@"%@", [NSString stringWithFormat:@"In AurusPaymentTerminal.OnAESDKProcessRequest, calling OnAESDKProcessRequest:%@", WithRequest]);
|
|
48
|
-
if (!self.aesdk || !self.aesdk.setAESDKDelegateRefference) {
|
|
49
|
-
[self initialize];
|
|
50
|
-
}
|
|
51
74
|
[self.aesdk OnAESDKProcessRequest:WithRequest];
|
|
52
75
|
}
|
|
53
76
|
|
|
@@ -55,18 +78,26 @@ RCT_EXPORT_METHOD(OnAESDKProcessRequest:(NSString*)WithRequest) {
|
|
|
55
78
|
|
|
56
79
|
- (void)onAESDKResponse:(NSString *)withResponse {
|
|
57
80
|
RCTLog(@"%@", [NSString stringWithFormat:@"In AurusPaymentTerminal.onAESDKResponse, calling sendEventWithName:%@ body:%@", native_onAESDKResponse, withResponse]);
|
|
81
|
+
if ([withResponse isEqualToString:@"EMV_CONFIGURATION_COMPLETED"] || [withResponse isEqualToString:@"DEVICE_ALREADY_CONFIGURED"]) {
|
|
82
|
+
configurationComplete = YES;
|
|
83
|
+
}
|
|
58
84
|
[self sendEventWithName:native_onAESDKResponse body:withResponse];
|
|
59
85
|
}
|
|
60
86
|
|
|
87
|
+
- (void)onBarcodeDataReceived:(NSNotification *)notification {
|
|
88
|
+
RCTLog(@"%@", [NSString stringWithFormat:@"In AurusPaymentTerminal.onBarcodeDataReceived, calling sendEventWithName:%@ body:%@", native_onBarcodeDataReceived, notification.object]);
|
|
89
|
+
[self sendEventWithName:native_onBarcodeDataReceived body:notification.object];
|
|
90
|
+
}
|
|
91
|
+
|
|
61
92
|
#pragma mark - RCTEventEmitter implementation
|
|
62
93
|
|
|
63
94
|
- (NSArray<NSString *> *)supportedEvents {
|
|
64
95
|
return @[
|
|
65
|
-
native_onAESDKResponse
|
|
96
|
+
native_onAESDKResponse,
|
|
97
|
+
native_onBarcodeDataReceived
|
|
66
98
|
];
|
|
67
99
|
}
|
|
68
100
|
|
|
69
101
|
@end
|
|
70
102
|
|
|
71
103
|
//AurusPaymentTerminal
|
|
72
|
-
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { EventEmitter } from "fbemitter";
|
|
2
|
+
import { IBankCardRequest, IGiftCardRequest, IPaymentDeviceConfiguration, IScannerDeviceConfiguration } from "../";
|
|
3
|
+
import { IVendorPaymentDevice } from "../interfaces/payment/IPayment";
|
|
4
|
+
import { IVendorScannerDevice } from "../interfaces/scanner/IScanner";
|
|
5
|
+
/**
|
|
6
|
+
* This is the interface that the native (bridge) class implements.
|
|
7
|
+
*
|
|
8
|
+
* Note: any changes to the native API must be reflected here and vice-versa.
|
|
9
|
+
*/
|
|
10
|
+
export interface INativeAurusPaymentTerminal {
|
|
11
|
+
initialize(): void;
|
|
12
|
+
OnAESDKProcessRequest(WithRequest: string): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class AurusDevice implements IVendorPaymentDevice, IVendorScannerDevice {
|
|
15
|
+
private _paymentConfig;
|
|
16
|
+
private _scannerConfig;
|
|
17
|
+
private _devicePaymentTerminal;
|
|
18
|
+
private _paymentSubscriptions;
|
|
19
|
+
private _scannerSubscriptions;
|
|
20
|
+
private _paymentEmitter;
|
|
21
|
+
private _scannerEmitter;
|
|
22
|
+
private _initInProgress;
|
|
23
|
+
private _initialized;
|
|
24
|
+
private _nativeEventEmitter;
|
|
25
|
+
private _registrationInProgress;
|
|
26
|
+
private _scannerEnabled;
|
|
27
|
+
/**
|
|
28
|
+
* To avoid pushing native component awareness onto the rest of the app, the native objects
|
|
29
|
+
* are created in the constructor, which only accepts JavaScript parameters.
|
|
30
|
+
*/
|
|
31
|
+
constructor();
|
|
32
|
+
configurePaymentDevice(emitter: EventEmitter, config: IPaymentDeviceConfiguration): Promise<void>;
|
|
33
|
+
configureScannerDevice(emitter: EventEmitter, config: IScannerDeviceConfiguration): Promise<void>;
|
|
34
|
+
startPaymentDevice(): Promise<void>;
|
|
35
|
+
startScannerDevice(): Promise<void>;
|
|
36
|
+
captureSale(authRequest: IBankCardRequest): Promise<void>;
|
|
37
|
+
captureRefund(authRequest: IBankCardRequest): Promise<void>;
|
|
38
|
+
enableScannerDevice(): Promise<void>;
|
|
39
|
+
disableScannerDevice(): Promise<void>;
|
|
40
|
+
giftcardActivate(authRequest: IGiftCardRequest): Promise<void>;
|
|
41
|
+
giftcardBalance(authRequest: IGiftCardRequest): Promise<void>;
|
|
42
|
+
giftcardIssue(authRequest: IGiftCardRequest): Promise<void>;
|
|
43
|
+
giftcardRedeem(authRequest: IGiftCardRequest): Promise<void>;
|
|
44
|
+
void(authRequest: IBankCardRequest): Promise<void>;
|
|
45
|
+
stopPaymentDevice(): Promise<void>;
|
|
46
|
+
stopScannerDevice(): Promise<void>;
|
|
47
|
+
tearDownPaymentDevice(): Promise<void>;
|
|
48
|
+
tearDownScannerDevice(): Promise<void>;
|
|
49
|
+
processTimeout(): Promise<void>;
|
|
50
|
+
private authorize(authRequest);
|
|
51
|
+
private initializeNative();
|
|
52
|
+
/**
|
|
53
|
+
* This method handles events published by the native components. This is an adapter between the native and JavaScript
|
|
54
|
+
* components for asynchronous events from the native layer.
|
|
55
|
+
*/
|
|
56
|
+
private onAESDKResponse(...args);
|
|
57
|
+
private sendCancelTranRequest();
|
|
58
|
+
private sendCancelLastTranRequest();
|
|
59
|
+
private sendTransRequest(getCardBinResp);
|
|
60
|
+
private sendCardTransRequest();
|
|
61
|
+
/**
|
|
62
|
+
* Sends a GetCardBinRequest to request card data from teh device
|
|
63
|
+
* @param authRequest
|
|
64
|
+
*/
|
|
65
|
+
private sendGetCardBin(authRequest);
|
|
66
|
+
/**
|
|
67
|
+
* Sends an AESDKRegistrationRequest to register the device
|
|
68
|
+
* @param authRequest
|
|
69
|
+
*/
|
|
70
|
+
private sendAESDKRegistration(authRequest);
|
|
71
|
+
private handleAESDKResponse(xml);
|
|
72
|
+
private convertXmlToJs(xml);
|
|
73
|
+
private processResponse(response);
|
|
74
|
+
private processTrans(response);
|
|
75
|
+
private processGetCardBin(response);
|
|
76
|
+
private processCancelTrans(response);
|
|
77
|
+
private processAESDKRegistration(response);
|
|
78
|
+
private processAESDK(response);
|
|
79
|
+
private mapAurusResponseCode(responseCode);
|
|
80
|
+
private mapAurusCardType(aurusCardType);
|
|
81
|
+
private mapAurusTenderType(aurusCardType);
|
|
82
|
+
private parseEMVData(data);
|
|
83
|
+
private parseEMVField(field, emvData);
|
|
84
|
+
/**
|
|
85
|
+
* This method handles events published by the native components. This is an adapter between the native and JavaScript
|
|
86
|
+
* components for asynchronous events from the native layer.
|
|
87
|
+
*
|
|
88
|
+
* @param args
|
|
89
|
+
* @return {any}
|
|
90
|
+
*/
|
|
91
|
+
private onBarcodeDataReceived(...args);
|
|
92
|
+
private handleBarcodeDataReceived(xml);
|
|
93
|
+
private processBarcodeData(barcode);
|
|
94
|
+
}
|