quivio-transaction-processor 1.22.2-beta → 1.22.4-beta
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/dist/emvPaymentProvider/EMVPaymentProvider.js +28 -51
- package/dist/emvPaymentProvider/EMVPaymentProvider.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/libs/emvCardReaderLib/src/main/AndroidManifest.xml +5 -2
- package/libs/emvCardReaderLib/src/main/java/com/rohan/emvcardreaderlib/PosTransResponse.kt +2 -4
- package/libs/emvCardReaderLib/src/main/java/com/rohan/emvcardreaderlib/builder/DsiEMVRequestBuilder.kt +1 -1
- package/libs/emvCardReaderLib/src/main/java/com/rohan/emvcardreaderlib/usb/UsbDeviceReceiver.kt +3 -0
- package/libs/emvCardReaderLib/src/main/res/xml/device_filter.xml +4 -0
- package/libs/emvNative/src/main/java/com/quivio_transaction_processor/EMVPaymentManagerModule.kt +1 -1
- package/package.json +1 -1
- package/src/emvPaymentProvider/EMVPaymentProvider.tsx +40 -78
- package/src/index.ts +0 -2
|
@@ -39,6 +39,8 @@ var types_1 = require("./types");
|
|
|
39
39
|
var useUSBDevice_1 = require("../usb/useUSBDevice");
|
|
40
40
|
var EMVPaymentContext = (0, react_1.createContext)(undefined);
|
|
41
41
|
exports.EMVPaymentContext = EMVPaymentContext;
|
|
42
|
+
var DsiEMVManagerBridge = react_native_1.NativeModules.DsiEMVManagerBridge;
|
|
43
|
+
var emvEmitter = new react_native_1.NativeEventEmitter(DsiEMVManagerBridge);
|
|
42
44
|
var EMVPaymentProvider = function (_a) {
|
|
43
45
|
var children = _a.children;
|
|
44
46
|
var TRANSACTION_RESPONSE_EVENTS = [
|
|
@@ -49,9 +51,6 @@ var EMVPaymentProvider = function (_a) {
|
|
|
49
51
|
'onReplaceCardCompleted',
|
|
50
52
|
'onTransactionCancelled',
|
|
51
53
|
];
|
|
52
|
-
var DsiEMVManagerBridge = react_native_1.NativeModules.DsiEMVManagerBridge;
|
|
53
|
-
var eventEmitterRef = (0, react_1.useRef)(null);
|
|
54
|
-
var listenersRef = (0, react_1.useRef)({}); // Now it's an array of listeners for each event
|
|
55
54
|
// Device Connected State
|
|
56
55
|
var isDeviceConnected = (0, useUSBDevice_1.useUSBDevice)().isDeviceConnected;
|
|
57
56
|
// Show Display Message Cache
|
|
@@ -66,6 +65,8 @@ var EMVPaymentProvider = function (_a) {
|
|
|
66
65
|
var _f = (0, react_1.useState)(false), isConfigurationInProgress = _f[0], setConfigurationInProgress = _f[1];
|
|
67
66
|
// Logs DataStructure
|
|
68
67
|
var _g = (0, react_1.useState)([]), logs = _g[0], setLogs = _g[1];
|
|
68
|
+
// Ref to maintain subscription
|
|
69
|
+
var subscriptionsRef = (0, react_1.useRef)(new Map());
|
|
69
70
|
// Ref to maintain timeout during configuration
|
|
70
71
|
// Because after a successfull EMVParamDownload
|
|
71
72
|
// Device reboots which leads to USB disconnection
|
|
@@ -109,50 +110,37 @@ var EMVPaymentProvider = function (_a) {
|
|
|
109
110
|
};
|
|
110
111
|
// Native to Provider EMV event listening
|
|
111
112
|
(0, react_1.useEffect)(function () {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
var emitter = eventEmitterRef.current ||
|
|
117
|
-
new react_native_1.NativeEventEmitter(react_native_1.Platform.OS === 'android' ? DsiEMVManagerBridge : undefined);
|
|
118
|
-
eventEmitterRef.current = emitter;
|
|
119
|
-
types_1.EVENT_NAMES.forEach(function (event) {
|
|
120
|
-
var listener = emitter.addListener(event, function (payload) {
|
|
121
|
-
console.log("React Native received event: ".concat(event), payload);
|
|
122
|
-
pushLog(event, payload);
|
|
123
|
-
if (event === 'onShowDisplayMessage') {
|
|
113
|
+
var nativeSubs = types_1.EVENT_NAMES.map(function (eventName) {
|
|
114
|
+
return emvEmitter.addListener(eventName, function (payload) {
|
|
115
|
+
pushLog(eventName, payload);
|
|
116
|
+
if (eventName === 'onShowDisplayMessage') {
|
|
124
117
|
setDisplayMessage(payload);
|
|
125
118
|
}
|
|
126
|
-
if (
|
|
119
|
+
if (eventName === 'onConfigCompleted') {
|
|
127
120
|
setConfigurationInProgress(false);
|
|
128
121
|
setCancellationRunning(false);
|
|
129
122
|
setIsConfigured(true);
|
|
130
123
|
}
|
|
131
|
-
if (
|
|
124
|
+
if (eventName === 'onConfigError') {
|
|
132
125
|
setConfigurationInProgress(false);
|
|
133
126
|
setCancellationRunning(false);
|
|
134
127
|
setIsConfigured(false);
|
|
135
128
|
}
|
|
136
|
-
if (
|
|
129
|
+
if (eventName === 'onProcessAlreadyRunning') {
|
|
137
130
|
setCancellationRunning(false);
|
|
138
131
|
setTransactionCurrentlyRunning(true);
|
|
139
132
|
}
|
|
140
|
-
if (TRANSACTION_RESPONSE_EVENTS.includes(
|
|
133
|
+
if (TRANSACTION_RESPONSE_EVENTS.includes(eventName)) {
|
|
141
134
|
setTransactionCurrentlyRunning(false);
|
|
142
135
|
setCancellationRunning(false);
|
|
143
136
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
listenersRef.current[event] = [];
|
|
147
|
-
}
|
|
148
|
-
listenersRef.current[event].push(listener);
|
|
137
|
+
var callbacks = subscriptionsRef.current.get(eventName);
|
|
138
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.forEach(function (cb) { return cb(payload); });
|
|
149
139
|
});
|
|
150
140
|
});
|
|
151
141
|
return function () {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
});
|
|
155
|
-
listenersRef.current = {};
|
|
142
|
+
nativeSubs.forEach(function (s) { return s.remove(); });
|
|
143
|
+
subscriptionsRef.current.clear();
|
|
156
144
|
};
|
|
157
145
|
}, []);
|
|
158
146
|
// Exposed method to run EMV configuration
|
|
@@ -220,32 +208,21 @@ var EMVPaymentProvider = function (_a) {
|
|
|
220
208
|
};
|
|
221
209
|
// Exposed method to remove all attached listener
|
|
222
210
|
var removeAllListeners = function () {
|
|
211
|
+
subscriptionsRef.current.clear();
|
|
223
212
|
DsiEMVManagerBridge.clearTransactionListener();
|
|
224
|
-
listenersRef.current = {};
|
|
225
213
|
};
|
|
226
|
-
//
|
|
227
|
-
var subscribeToEvent =
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
// Store listener in the ref object
|
|
231
|
-
if (!listenersRef.current[eventName]) {
|
|
232
|
-
listenersRef.current[eventName] = [];
|
|
233
|
-
}
|
|
234
|
-
listenersRef.current[eventName].push(listener);
|
|
235
|
-
return listener; // Return listener for potential removal later
|
|
214
|
+
// Exposed method to subscribe to an event
|
|
215
|
+
var subscribeToEvent = function (eventName, callback) {
|
|
216
|
+
if (!subscriptionsRef.current.has(eventName)) {
|
|
217
|
+
subscriptionsRef.current.set(eventName, new Set());
|
|
236
218
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
// Remove the listener from the stored list
|
|
245
|
-
listenersRef.current[eventName] = listeners.filter(function (l) { return l !== listener_1; });
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}, []);
|
|
219
|
+
subscriptionsRef.current.get(eventName).add(callback);
|
|
220
|
+
};
|
|
221
|
+
// Exposed method to unsubscribe Event
|
|
222
|
+
var unsubscribeFromEvent = function (eventName, callback) {
|
|
223
|
+
var _a;
|
|
224
|
+
(_a = subscriptionsRef.current.get(eventName)) === null || _a === void 0 ? void 0 : _a.delete(callback);
|
|
225
|
+
};
|
|
249
226
|
// EVENTS Memoization
|
|
250
227
|
var EVENTS = (0, react_1.useMemo)(function () {
|
|
251
228
|
return types_1.EVENT_NAMES.reduce(function (acc, e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EMVPaymentProvider.js","sourceRoot":"","sources":["../../src/emvPaymentProvider/EMVPaymentProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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B,+BAAA;QAC7B,yBAAyB,2BAAA;QACzB,qBAAqB,uBAAA;QACrB,cAAc,gBAAA;QACd,iBAAiB,mBAAA;QACjB,cAAc,gBAAA;QACd,eAAe,iBAAA;QACf,uBAAuB,yBAAA;QACvB,mBAAmB,qBAAA;QACnB,gBAAgB,kBAAA;QAChB,gBAAgB,kBAAA;QAChB,kBAAkB,oBAAA;QAClB,eAAe,iBAAA;QAEf,MAAM,QAAA;QACN,gBAAgB,kBAAA;QAChB,oBAAoB,sBAAA;KACrB,CAAC;IAEF,OAAO,CACL,8BAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACrC,QAAQ,CACkB,CAC9B,CAAC;AACJ,CAAC,CAAC;AAEO,gDAAkB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ import { USBDeviceProvider } from './usb/USBDeviceContext';
|
|
|
4
4
|
import { useUSBDevice } from './usb/useUSBDevice';
|
|
5
5
|
export type { EMVEventName, CallbackLog, EMVPaymentHook, EMVConfig } from './emvPaymentProvider/types';
|
|
6
6
|
export { EMVPaymentProvider, useEMVPayment, USBDeviceProvider, useUSBDevice };
|
|
7
|
-
export default EMVPaymentProvider;
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,4 @@ var USBDeviceContext_1 = require("./usb/USBDeviceContext");
|
|
|
9
9
|
Object.defineProperty(exports, "USBDeviceProvider", { enumerable: true, get: function () { return USBDeviceContext_1.USBDeviceProvider; } });
|
|
10
10
|
var useUSBDevice_1 = require("./usb/useUSBDevice");
|
|
11
11
|
Object.defineProperty(exports, "useUSBDevice", { enumerable: true, get: function () { return useUSBDevice_1.useUSBDevice; } });
|
|
12
|
-
exports.default = EMVPaymentProvider_1.EMVPaymentProvider;
|
|
13
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8EAA6E;AASzE,mGATK,uCAAkB,OASL;AARtB,oEAAmE;AAS/D,8FATK,6BAAa,OASL;AAPjB,2DAA2D;AAQvD,kGARK,oCAAiB,OAQL;AAPrB,mDAAkD;AAQ9C,6FARK,2BAAY,OAQL
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8EAA6E;AASzE,mGATK,uCAAkB,OASL;AARtB,oEAAmE;AAS/D,8FATK,6BAAa,OASL;AAPjB,2DAA2D;AAQvD,kGARK,oCAAiB,OAQL;AAPrB,mDAAkD;AAQ9C,6FARK,2BAAY,OAQL"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
xmlns:tools="http://schemas.android.com/tools">
|
|
4
4
|
|
|
5
5
|
<!-- optional: advertise USB host feature but don't force Play Store filtering -->
|
|
6
|
-
<uses-feature android:name="android.hardware.usb.host"
|
|
6
|
+
<uses-feature android:name="android.hardware.usb.host"/>
|
|
7
7
|
|
|
8
8
|
<!-- any permissions your receiver/native code needs -->
|
|
9
9
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
@@ -13,13 +13,16 @@
|
|
|
13
13
|
<application>
|
|
14
14
|
<!-- BroadcastReceiver that listens for USB attach/detach -->
|
|
15
15
|
<receiver
|
|
16
|
-
android:name=".usb.UsbDeviceReceiver"
|
|
16
|
+
android:name="com.rohan.emvcardreaderlib.usb.UsbDeviceReceiver"
|
|
17
17
|
android:exported="true"
|
|
18
18
|
android:enabled="true">
|
|
19
19
|
<intent-filter>
|
|
20
20
|
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
|
21
21
|
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
|
|
22
22
|
</intent-filter>
|
|
23
|
+
<meta-data
|
|
24
|
+
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
|
|
25
|
+
android:resource="@xml/device_filter" />
|
|
23
26
|
</receiver>
|
|
24
27
|
</application>
|
|
25
28
|
</manifest>
|
|
@@ -40,15 +40,13 @@ enum class ErrorCode(val code: String) {
|
|
|
40
40
|
data class SaleTransactionResponse(
|
|
41
41
|
// CmdResponse section
|
|
42
42
|
val responseOrigin: String,
|
|
43
|
-
|
|
44
|
-
val expiryMonth: String,
|
|
45
|
-
|
|
46
|
-
val expiryYear: String,
|
|
47
43
|
val dsixReturnCode: String,
|
|
48
44
|
val cmdStatus: String,
|
|
49
45
|
val textResponse: String,
|
|
50
46
|
|
|
51
47
|
// TranResponse section
|
|
48
|
+
val expiryMonth: String,
|
|
49
|
+
val expiryYear: String,
|
|
52
50
|
val merchantID: String,
|
|
53
51
|
val payAPIId: String,
|
|
54
52
|
val acctNo: String,
|
|
@@ -129,9 +129,9 @@ class DsiEMVRequestBuilder(val config: ConfigFactory) {
|
|
|
129
129
|
<TranCode>${TransType.EMVZeroAuth.name}</TranCode>
|
|
130
130
|
<ProcessorToken>TokenRequested</ProcessorToken>
|
|
131
131
|
<SecureDevice>${secureDevice}</SecureDevice>
|
|
132
|
+
<ReturnClearExpDate>Allow</ReturnClearExpDate>
|
|
132
133
|
<InvoiceNo>${createUniqueInvoiceNo()}</InvoiceNo>
|
|
133
134
|
<RefNo>${createUniqueInvoiceNo()}</RefNo>
|
|
134
|
-
<ReturnClearExpDate>Allow</ReturnClearExpDate>
|
|
135
135
|
<Amount>
|
|
136
136
|
<Purchase>0.00</Purchase>
|
|
137
137
|
</Amount>
|
package/libs/emvCardReaderLib/src/main/java/com/rohan/emvcardreaderlib/usb/UsbDeviceReceiver.kt
CHANGED
|
@@ -5,10 +5,13 @@ import android.content.Context
|
|
|
5
5
|
import android.content.Intent
|
|
6
6
|
import android.hardware.usb.UsbDevice
|
|
7
7
|
import android.hardware.usb.UsbManager
|
|
8
|
+
import android.util.Log
|
|
9
|
+
import com.rohan.emvcardreaderlib.PRINT_TAG
|
|
8
10
|
|
|
9
11
|
class UsbDeviceReceiver : BroadcastReceiver() {
|
|
10
12
|
|
|
11
13
|
override fun onReceive(context: Context, intent: Intent) {
|
|
14
|
+
Log.d(PRINT_TAG, "Receiver triggered: ${intent.action}")
|
|
12
15
|
val device: UsbDevice? =
|
|
13
16
|
intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
|
|
14
17
|
|
package/libs/emvNative/src/main/java/com/quivio_transaction_processor/EMVPaymentManagerModule.kt
CHANGED
|
@@ -298,7 +298,7 @@ class EMVPaymentManagerModule(private val reactContext: ReactApplicationContext)
|
|
|
298
298
|
putString("date", zeroAuthData.date)
|
|
299
299
|
putString("time", zeroAuthData.time)
|
|
300
300
|
putString("applicationLabel", zeroAuthData.applicationLabel)
|
|
301
|
-
|
|
301
|
+
|
|
302
302
|
// EMV specific fields
|
|
303
303
|
putString("aid", zeroAuthData.aid)
|
|
304
304
|
putString("tvr", zeroAuthData.tvr)
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
createContext,
|
|
3
|
-
useCallback,
|
|
4
3
|
useEffect,
|
|
5
4
|
useMemo,
|
|
6
5
|
useRef,
|
|
7
6
|
useState,
|
|
8
7
|
} from 'react';
|
|
9
|
-
import { NativeEventEmitter, NativeModules
|
|
8
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
10
9
|
import {
|
|
11
10
|
EMVPaymentContextType,
|
|
12
11
|
EMVEventName,
|
|
@@ -20,6 +19,9 @@ const EMVPaymentContext = createContext<EMVPaymentContextType | undefined>(
|
|
|
20
19
|
undefined,
|
|
21
20
|
);
|
|
22
21
|
|
|
22
|
+
const { DsiEMVManagerBridge } = NativeModules;
|
|
23
|
+
const emvEmitter = new NativeEventEmitter(DsiEMVManagerBridge);
|
|
24
|
+
|
|
23
25
|
const EMVPaymentProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
24
26
|
children,
|
|
25
27
|
}) => {
|
|
@@ -31,9 +33,6 @@ const EMVPaymentProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
31
33
|
'onReplaceCardCompleted',
|
|
32
34
|
'onTransactionCancelled',
|
|
33
35
|
];
|
|
34
|
-
const { DsiEMVManagerBridge } = NativeModules;
|
|
35
|
-
const eventEmitterRef = useRef<NativeEventEmitter | null>(null);
|
|
36
|
-
const listenersRef = useRef<{ [event: string]: any[] }>({}); // Now it's an array of listeners for each event
|
|
37
36
|
|
|
38
37
|
// Device Connected State
|
|
39
38
|
const { isDeviceConnected } = useUSBDevice();
|
|
@@ -58,6 +57,10 @@ const EMVPaymentProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
58
57
|
// Logs DataStructure
|
|
59
58
|
const [logs, setLogs] = useState<CallbackLog[]>([]);
|
|
60
59
|
|
|
60
|
+
// Ref to maintain subscription
|
|
61
|
+
const subscriptionsRef = useRef<
|
|
62
|
+
Map<EMVEventName, Set<(payload: any) => void>>
|
|
63
|
+
>(new Map());
|
|
61
64
|
|
|
62
65
|
// Ref to maintain timeout during configuration
|
|
63
66
|
// Because after a successfull EMVParamDownload
|
|
@@ -111,63 +114,44 @@ const EMVPaymentProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
111
114
|
|
|
112
115
|
// Native to Provider EMV event listening
|
|
113
116
|
useEffect(() => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const emitter =
|
|
120
|
-
eventEmitterRef.current ||
|
|
121
|
-
new NativeEventEmitter(
|
|
122
|
-
Platform.OS === 'android' ? DsiEMVManagerBridge : undefined,
|
|
123
|
-
);
|
|
124
|
-
eventEmitterRef.current = emitter;
|
|
125
|
-
|
|
126
|
-
EVENT_NAMES.forEach(event => {
|
|
127
|
-
const listener = emitter.addListener(event, (payload: any) => {
|
|
128
|
-
console.log(`React Native received event: ${event}`, payload);
|
|
117
|
+
const nativeSubs = EVENT_NAMES.map(eventName =>
|
|
118
|
+
emvEmitter.addListener(eventName, payload => {
|
|
119
|
+
pushLog(eventName, payload);
|
|
129
120
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (event === 'onShowDisplayMessage') {
|
|
121
|
+
if (eventName === 'onShowDisplayMessage') {
|
|
133
122
|
setDisplayMessage(payload);
|
|
134
123
|
}
|
|
135
124
|
|
|
136
|
-
if (
|
|
125
|
+
if (eventName === 'onConfigCompleted') {
|
|
137
126
|
setConfigurationInProgress(false);
|
|
138
127
|
setCancellationRunning(false);
|
|
139
128
|
setIsConfigured(true);
|
|
140
129
|
}
|
|
141
130
|
|
|
142
|
-
if (
|
|
131
|
+
if (eventName === 'onConfigError') {
|
|
143
132
|
setConfigurationInProgress(false);
|
|
144
133
|
setCancellationRunning(false);
|
|
145
134
|
setIsConfigured(false);
|
|
146
135
|
}
|
|
147
136
|
|
|
148
|
-
if (
|
|
137
|
+
if (eventName === 'onProcessAlreadyRunning') {
|
|
149
138
|
setCancellationRunning(false);
|
|
150
139
|
setTransactionCurrentlyRunning(true);
|
|
151
140
|
}
|
|
152
141
|
|
|
153
|
-
if (TRANSACTION_RESPONSE_EVENTS.includes(
|
|
142
|
+
if (TRANSACTION_RESPONSE_EVENTS.includes(eventName)) {
|
|
154
143
|
setTransactionCurrentlyRunning(false);
|
|
155
144
|
setCancellationRunning(false);
|
|
156
145
|
}
|
|
157
146
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
listenersRef.current[event].push(listener);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
147
|
+
const callbacks = subscriptionsRef.current.get(eventName);
|
|
148
|
+
callbacks?.forEach(cb => cb(payload));
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
165
151
|
|
|
166
152
|
return () => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
170
|
-
listenersRef.current = {};
|
|
153
|
+
nativeSubs.forEach(s => s.remove());
|
|
154
|
+
subscriptionsRef.current.clear();
|
|
171
155
|
};
|
|
172
156
|
}, []);
|
|
173
157
|
|
|
@@ -249,50 +233,28 @@ const EMVPaymentProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
249
233
|
|
|
250
234
|
// Exposed method to remove all attached listener
|
|
251
235
|
const removeAllListeners = () => {
|
|
236
|
+
subscriptionsRef.current.clear();
|
|
252
237
|
DsiEMVManagerBridge.clearTransactionListener();
|
|
253
|
-
listenersRef.current = {};
|
|
254
238
|
};
|
|
255
239
|
|
|
256
|
-
//
|
|
257
|
-
const subscribeToEvent =
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if (!listenersRef.current[eventName]) {
|
|
267
|
-
listenersRef.current[eventName] = [];
|
|
268
|
-
}
|
|
269
|
-
listenersRef.current[eventName].push(listener);
|
|
270
|
-
|
|
271
|
-
return listener; // Return listener for potential removal later
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
[],
|
|
275
|
-
);
|
|
240
|
+
// Exposed method to subscribe to an event
|
|
241
|
+
const subscribeToEvent = (
|
|
242
|
+
eventName: EMVEventName,
|
|
243
|
+
callback: (payload: any) => void,
|
|
244
|
+
) => {
|
|
245
|
+
if (!subscriptionsRef.current.has(eventName)) {
|
|
246
|
+
subscriptionsRef.current.set(eventName, new Set());
|
|
247
|
+
}
|
|
248
|
+
subscriptionsRef.current.get(eventName)!.add(callback);
|
|
249
|
+
};
|
|
276
250
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if (listener) {
|
|
285
|
-
listener.remove();
|
|
286
|
-
|
|
287
|
-
// Remove the listener from the stored list
|
|
288
|
-
listenersRef.current[eventName] = listeners.filter(
|
|
289
|
-
l => l !== listener,
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
[],
|
|
295
|
-
);
|
|
251
|
+
// Exposed method to unsubscribe Event
|
|
252
|
+
const unsubscribeFromEvent = (
|
|
253
|
+
eventName: EMVEventName,
|
|
254
|
+
callback: (payload: any) => void,
|
|
255
|
+
) => {
|
|
256
|
+
subscriptionsRef.current.get(eventName)?.delete(callback);
|
|
257
|
+
};
|
|
296
258
|
|
|
297
259
|
// EVENTS Memoization
|
|
298
260
|
const EVENTS = useMemo(
|