@aptos-scp/scp-component-rn-device-services 0.1.1 → 0.2.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.
@@ -1,96 +1,93 @@
1
- //
2
- // AurusEnterpriseSDK.h
3
- //
4
- // Created by Vinay Kole on 18/3/16.
5
- // Copyright (c) 2016 Aurus. All rights reserved.
6
- //
7
-
8
- #import <Foundation/Foundation.h>
9
- //#import <UIKit/UIKit.h>
10
-
11
-
12
- @protocol AESDKProtocols <NSObject>
13
-
14
- -(void)onAESDKResponse:(NSString *)withResponse;
15
-
16
- @end
17
-
18
-
19
-
20
- @interface AurusEnterpriseSDK : NSObject
21
-
22
- -(void)OnAESDKProcessRequest:(NSString*)WithRequest;
23
- -(void)OnAESDKSetEncMessage:(NSString*)withMessage;
24
-
25
- @property(nonatomic,retain)id setAESDKDelegateRefference;
26
-
27
- #pragma mark- Utility Methods
28
-
29
- /**
30
- Get application unique ID
31
-
32
- @return NSString applicationUniqueID
33
- */
34
- -(NSString *)getApplicationUniqueID;
35
-
36
- /**
37
- Log file details
38
-
39
- @return NSMutableDictionary log file details
40
- */
41
- -(NSMutableDictionary *)getLogFileDetails;
42
-
43
-
44
- /**
45
- Initialize AurusEnterpriseSDK with blocking mode.
46
- This method should call only once.
47
-
48
- @param isBlockingMode set YES to executes pinpad commands on main thread.
49
- @return AurusEnterpriseSDK instance
50
-
51
- @code
52
- //To execute Pinpad commands in background thread.
53
- AurusEnterpriseSDK *aesdk = [[AurusEnterpriseSDK alloc] initWithPEDBlockingMode:NO];
54
- @endcode
55
-
56
- */
57
- -(id)initWithPEDBlockingMode:(BOOL)isBlockingMode;
58
-
59
-
60
-
61
- /**
62
- Pinpad logs are enabled or not
63
-
64
- @return BOOL YES when Pinpad logs are enabled otherwise returns NO.
65
- */
66
- -(BOOL)isPEDLogEnabled;
67
-
68
-
69
- typedef enum {
70
- EventProcessingRequest = 501,
71
- EventSwipeOrInsertOrTap,
72
- EventEnterManualCardEntry,
73
- EventProcessing,
74
- EventCardAuthorization,
75
- EventEnterPIN,
76
- EventEnterZIP,
77
- EventEnterSSN,
78
- EventEnterSIN,
79
- EventEnterAnnualDebitIncome,
80
- EventEnterMonthlyDebitIncome,
81
- EventEnterPhoneNumber,
82
- EventEnterPasscode,
83
- EventEnterExpiryDate,
84
- EventEnterCVV,
85
- EventEnterTIP,
86
- //EventConfirmProcessAsCredit, //Debit to Credit Confirmation.
87
- EventConfirmation,
88
- EventProcessingTransaction,
89
-
90
-
91
- EventNone = 0
92
-
93
- }NotificationEvent;
94
-
95
-
96
- @end
1
+ //
2
+ // AurusEnterpriseSDK.h
3
+ //
4
+ // Created by Aurus on 18/3/16.
5
+ // Copyright (c) 2016 Aurus. All rights reserved.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+
11
+ @protocol AESDKProtocols <NSObject>
12
+
13
+ -(void)onAESDKResponse:(NSString *)withResponse;
14
+
15
+ @optional
16
+ -(void)onAESDKLogResponse: (NSString *)withResponse;
17
+
18
+ @end
19
+
20
+
21
+ @interface AurusEnterpriseSDK : NSObject
22
+
23
+ typedef void(^onAESDKCompletionResponse)(NSString *xmlResponse);
24
+ @property (atomic,copy) void(^onAESDKCompletionResponse)(NSString *xmlResponse);
25
+
26
+ @property(nonatomic,retain)id setAESDKDelegateRefference;
27
+
28
+ //BY this Method Calling the Response of AESDK will get in onAESDKResponse Delegate Method
29
+ -(void)OnAESDKProcessRequest:(NSString *)xmlRequest;
30
+
31
+ //BY this Method Calling the Response of AESDK will get Completion Handler.
32
+ -(void)OnAESDKProcessRequest:(NSString *)xmlRequest onCompletion:(onAESDKCompletionResponse)completionBlock;
33
+
34
+
35
+ //BY this Method Calling the Response of AESDK will get in onAESDKLogResponse Delegate Method
36
+ -(void)OnAESDKLogProcessRequest;
37
+
38
+ ///
39
+
40
+
41
+ #pragma mark- Utility Methods
42
+
43
+
44
+ /**
45
+ Log file details
46
+
47
+ @return NSMutableDictionary log file details
48
+ */
49
+ -(NSMutableDictionary *)getLogFileDetails;
50
+
51
+ typedef enum {
52
+ EventProcessingRequest = 501,
53
+ EventSwipeOrInsertOrTap,
54
+ EventEnterManualCardEntry,
55
+ EventProcessing,
56
+ EventCardAuthorization,
57
+ EventEnterPIN,
58
+ EventEnterZIP,
59
+ EventEnterSSN,
60
+ EventEnterSIN,
61
+ EventEnterAnnualDebitIncome,
62
+ EventEnterMonthlyDebitIncome,
63
+ EventEnterPhoneNumber,
64
+ EventEnterPasscode,
65
+ EventEnterExpiryDate,
66
+ EventEnterCVV,
67
+ EventEnterTIP,
68
+ //EventConfirmProcessAsCredit, //Debit to Credit Confirmation.
69
+ EventConfirmation,
70
+ EventProcessingTransaction,
71
+ //E355 Device Events
72
+ EventBarcodeInformation,
73
+ EventDeviceNotConnected,
74
+ EventDeviceConnecting,
75
+ EventDeviceConnected,
76
+ EventDeviceConfigurationStarted,
77
+ EventDeviceConfigurationCompleted,
78
+ EventDeviceConfigurationFailed,
79
+ EventDeviceAlreadyConfigured,
80
+ EventFileDownloading,
81
+ EventFileDownloadFailed,
82
+ EventFileDownloadRetrying,
83
+ EventFileUpgradingToPED,
84
+ EventFileUpgradingToPEDFailed,
85
+ EventFileUpgradingToPEDCompleted,
86
+ EventFileTransferToPEDInfo,
87
+ EventFileTransferToPEDProgress,
88
+ EventNone = 0
89
+
90
+ }NotificationEvent;
91
+
92
+
93
+ @end
@@ -12,8 +12,10 @@
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
+ NSString* const native_onNotificationReceived = @"onNotificationReceived";
16
+ NSString* const native_onNotificationReceived_name = @"native_onNotificationReceived";
17
+ NSString* const AURUS_NOTIFICATION = @"AURUS_NOTIFICATION";
18
+ NSString* const USER_INFO_CODE = @"CODE";
17
19
 
18
20
  @interface AurusPaymentTerminal ()
19
21
 
@@ -25,34 +27,74 @@ NSString* const native_onBarcodeDataReceived_name = @"native_onBarcodeDataReceiv
25
27
 
26
28
  @implementation AurusPaymentTerminal
27
29
 
30
+ - (void) dealloc {
31
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:AURUS_NOTIFICATION object:nil];
32
+ observer = nil;
33
+ }
34
+
28
35
  RCT_EXPORT_MODULE();
29
36
 
30
37
  - (NSDictionary *)constantsToExport {
31
38
  return @{
32
39
  native_onAESDKResponse_name: native_onAESDKResponse,
33
- native_onBarcodeDataReceived_name: native_onBarcodeDataReceived
40
+ native_onNotificationReceived_name: native_onNotificationReceived,
41
+ @"NotificationEvent": @{ @"ProcessingRequest" : @(EventProcessingRequest),
42
+ @"SwipeOrInsertOrTap" : @(EventSwipeOrInsertOrTap),
43
+ @"EnterManualCardEntry" : @(EventEnterManualCardEntry),
44
+ @"Processing" : @(EventProcessing),
45
+ @"CardAuthorization" : @(EventCardAuthorization),
46
+ @"EnterPIN" : @(EventEnterPIN),
47
+ @"EnterZIP" : @(EventEnterZIP),
48
+ @"EnterSSN" : @(EventEnterSSN),
49
+ @"EnterSIN" : @(EventEnterSIN),
50
+ @"EnterAnnualDebitIncome" : @(EventEnterAnnualDebitIncome),
51
+ @"EnterMonthlyDebitIncome" : @(EventEnterMonthlyDebitIncome),
52
+ @"EnterPhoneNumber" : @(EventEnterPhoneNumber),
53
+ @"EnterPasscode" : @(EventEnterPasscode),
54
+ @"EnterExpiryDate" : @(EventEnterExpiryDate),
55
+ @"EnterCVV" : @(EventEnterCVV),
56
+ @"EnterTIP" : @(EventEnterTIP),
57
+ @"Confirmation" : @(EventConfirmation),
58
+ @"ProcessingTransaction" : @(EventProcessingTransaction),
59
+ @"BarcodeInformation" : @(EventBarcodeInformation), //519
60
+ @"DeviceNotConnected" : @(EventDeviceNotConnected), //520
61
+ @"DeviceConnecting" : @(EventDeviceConnecting), //521
62
+ @"DeviceConnected" : @(EventDeviceConnected), //522
63
+ @"DeviceConfigurationStarted" : @(EventDeviceConfigurationStarted), //523
64
+ @"DeviceConfigurationCompleted" : @(EventDeviceConfigurationCompleted), //524
65
+ @"DeviceConfigurationFailed" : @(EventDeviceConfigurationFailed), //525
66
+ @"DeviceAlreadyConfigured" : @(EventDeviceAlreadyConfigured), //526
67
+ @"FileDownloading" : @(EventFileDownloading),
68
+ @"FileDownloadFailed" : @(EventFileDownloadFailed),
69
+ @"FileDownloadRetrying" : @(EventFileDownloadRetrying),
70
+ @"FileUpgradingToPED" : @(EventFileUpgradingToPED),
71
+ @"FileUpgradingToPEDFailed" : @(EventFileUpgradingToPEDFailed),
72
+ @"FileUpgradingToPEDCompleted" : @(EventFileUpgradingToPEDCompleted),
73
+ @"FileTransferToPEDInfo" : @(EventFileTransferToPEDInfo),
74
+ @"FileTransferToPEDProgress" : @(EventFileTransferToPEDProgress),
75
+ @"None" : @(EventNone)
76
+ }
34
77
  };
35
78
  }
36
79
 
37
80
  #pragma mark - Exported to JavaScript methods
38
81
 
39
82
  static BOOL configurationComplete = NO;
83
+ static id observer;
40
84
 
41
85
  RCT_EXPORT_METHOD(initialize) {
42
86
  if (!self.aesdk) {
87
+ RCTLog(@"In AurusPaymentTerminal.initialize, adding %@ observer.", AURUS_NOTIFICATION);
88
+ if (observer) {
89
+ [[NSNotificationCenter defaultCenter] removeObserver:observer name:AURUS_NOTIFICATION object:nil];
90
+ }
91
+ observer = self;
92
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onNotificationReceived:) name:AURUS_NOTIFICATION object:nil];
93
+
43
94
  RCTLog(@"In AurusPaymentTerminal.initialize, creating AurusEnterpriseSDK.");
44
95
  self.aesdk = [[AurusEnterpriseSDK alloc] init];
45
96
  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
- }
97
+ [self.aesdk OnAESDKLogProcessRequest];
56
98
 
57
99
  if (!configurationComplete) {
58
100
  RCTLog(@"In AurusPaymentTerminal.initialize, EMV configuration should be starting.");
@@ -61,7 +103,8 @@ RCT_EXPORT_METHOD(initialize) {
61
103
  RCTLog(@"In AurusPaymentTerminal.initialize, app was reloaded and EMV is already configured.");
62
104
  dispatch_async(dispatch_get_main_queue(), ^{
63
105
  // sending on main thread to prevent UI timing issues
64
- [self onAESDKResponse:@"DEVICE_ALREADY_CONFIGURED"];
106
+ NSDictionary *userInfo = @{ USER_INFO_CODE : @(EventDeviceAlreadyConfigured) };
107
+ [[NSNotificationCenter defaultCenter] postNotificationName:AURUS_NOTIFICATION object:nil userInfo:userInfo];
65
108
  });
66
109
  }
67
110
  } else {
@@ -78,15 +121,22 @@ RCT_EXPORT_METHOD(OnAESDKProcessRequest:(NSString*)WithRequest) {
78
121
 
79
122
  - (void)onAESDKResponse:(NSString *)withResponse {
80
123
  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
- }
84
124
  [self sendEventWithName:native_onAESDKResponse body:withResponse];
85
125
  }
86
126
 
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];
127
+ - (void)onAESDKLogResponse:(NSString *)withResponse {
128
+ RCTLog(@"AurusLogging: %@", withResponse);
129
+ }
130
+
131
+ - (void)onNotificationReceived:(NSNotification *)notification {
132
+ RCTLog(@"%@", [NSString stringWithFormat:@"In AurusPaymentTerminal.onNotificationReceived, calling sendEventWithName:%@ body:%@", native_onNotificationReceived, notification.userInfo]);
133
+ if (!configurationComplete && notification && notification.userInfo) {
134
+ int code = [notification.userInfo[USER_INFO_CODE] intValue];
135
+ if (code == EventDeviceConfigurationCompleted || code == EventDeviceAlreadyConfigured) {
136
+ configurationComplete = YES;
137
+ }
138
+ }
139
+ [self sendEventWithName:native_onNotificationReceived body:notification.userInfo];
90
140
  }
91
141
 
92
142
  #pragma mark - RCTEventEmitter implementation
@@ -94,7 +144,7 @@ RCT_EXPORT_METHOD(OnAESDKProcessRequest:(NSString*)WithRequest) {
94
144
  - (NSArray<NSString *> *)supportedEvents {
95
145
  return @[
96
146
  native_onAESDKResponse,
97
- native_onBarcodeDataReceived
147
+ native_onNotificationReceived
98
148
  ];
99
149
  }
100
150
 
@@ -15,8 +15,7 @@ export declare class AurusDevice implements IVendorPaymentDevice, IVendorScanner
15
15
  private _paymentConfig;
16
16
  private _scannerConfig;
17
17
  private _devicePaymentTerminal;
18
- private _paymentSubscriptions;
19
- private _scannerSubscriptions;
18
+ private _nativeSubscriptions;
20
19
  private _paymentEmitter;
21
20
  private _scannerEmitter;
22
21
  private _initInProgress;
@@ -24,6 +23,7 @@ export declare class AurusDevice implements IVendorPaymentDevice, IVendorScanner
24
23
  private _nativeEventEmitter;
25
24
  private _registrationInProgress;
26
25
  private _scannerEnabled;
26
+ private _paymentEnvironment;
27
27
  /**
28
28
  * To avoid pushing native component awareness onto the rest of the app, the native objects
29
29
  * are created in the constructor, which only accepts JavaScript parameters.
@@ -49,6 +49,7 @@ export declare class AurusDevice implements IVendorPaymentDevice, IVendorScanner
49
49
  processTimeout(): Promise<void>;
50
50
  private authorize(authRequest);
51
51
  private initializeNative();
52
+ private tearDownNative();
52
53
  /**
53
54
  * This method handles events published by the native components. This is an adapter between the native and JavaScript
54
55
  * components for asynchronous events from the native layer.
@@ -70,7 +71,6 @@ export declare class AurusDevice implements IVendorPaymentDevice, IVendorScanner
70
71
  private sendAESDKRegistration(authRequest);
71
72
  private handleAESDKResponse(xml);
72
73
  private convertXmlToJs(xml);
73
- private processResponse(response);
74
74
  private processTrans(response);
75
75
  private processGetCardBin(response);
76
76
  private processCancelTrans(response);
@@ -81,6 +81,8 @@ export declare class AurusDevice implements IVendorPaymentDevice, IVendorScanner
81
81
  private mapAurusTenderType(aurusCardType);
82
82
  private parseEMVData(data);
83
83
  private parseEMVField(field, emvData);
84
+ private handleBarcodeDataReceived(xml);
85
+ private processBarcodeData(barcode);
84
86
  /**
85
87
  * This method handles events published by the native components. This is an adapter between the native and JavaScript
86
88
  * components for asynchronous events from the native layer.
@@ -88,7 +90,5 @@ export declare class AurusDevice implements IVendorPaymentDevice, IVendorScanner
88
90
  * @param args
89
91
  * @return {any}
90
92
  */
91
- private onBarcodeDataReceived(...args);
92
- private handleBarcodeDataReceived(xml);
93
- private processBarcodeData(barcode);
93
+ private onNotificationReceived(...args);
94
94
  }