quivio-transaction-processor 1.23.2 → 1.23.3-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.
Files changed (27) hide show
  1. package/dist/emvPaymentProvider/EMVPaymentProvider.js +144 -63
  2. package/dist/emvPaymentProvider/EMVPaymentProvider.js.map +1 -1
  3. package/dist/emvPaymentProvider/types.d.ts +5 -2
  4. package/dist/example/EMVPaymentScreen.d.ts +4 -1
  5. package/dist/example/EMVPaymentScreen.js +101 -8
  6. package/dist/example/EMVPaymentScreen.js.map +1 -1
  7. package/dist/example/EMVSettingsScreen.js +4 -6
  8. package/dist/example/EMVSettingsScreen.js.map +1 -1
  9. package/dist/example/ExternalSystemsScreen.js +123 -3
  10. package/dist/example/ExternalSystemsScreen.js.map +1 -1
  11. package/dist/example/MainScreen.js +1 -1
  12. package/dist/example/MainScreen.js.map +1 -1
  13. package/dist/example/helper/deviceStore.d.ts +11 -0
  14. package/dist/example/helper/deviceStore.js +37 -0
  15. package/dist/example/helper/deviceStore.js.map +1 -0
  16. package/libs/emvCardReaderLib/src/main/java/com/rohan/emvcardreaderlib/POSTransactionExecutor.kt +29 -25
  17. package/libs/emvCardReaderLib/src/main/java/com/rohan/emvcardreaderlib/builder/DsiEMVRequestBuilder.kt +14 -7
  18. package/libs/emvCardReaderLib/src/main/java/com/rohan/emvcardreaderlib/manager/EMVPaymentManager.kt +28 -20
  19. package/libs/emvNative/src/main/java/com/quivio_transaction_processor/EMVPaymentManagerModule.kt +16 -7
  20. package/package.json +1 -1
  21. package/src/emvPaymentProvider/EMVPaymentProvider.tsx +105 -64
  22. package/src/emvPaymentProvider/types.ts +5 -2
  23. package/src/example/EMVPaymentScreen.tsx +75 -18
  24. package/src/example/EMVSettingsScreen.tsx +3 -5
  25. package/src/example/ExternalSystemsScreen.tsx +116 -27
  26. package/src/example/MainScreen.tsx +1 -1
  27. package/src/example/helper/deviceStore.ts +40 -0
@@ -10,6 +10,7 @@ import {
10
10
  } from 'react-native';
11
11
  import { useEMVPayment } from '../emvPaymentProvider/useEMVPayment';
12
12
  import { EMVConfig } from '../emvPaymentProvider/types';
13
+ import { addDevice } from './helper/deviceStore';
13
14
 
14
15
  type Props = {
15
16
  config: EMVConfig | null;
@@ -17,18 +18,22 @@ type Props = {
17
18
  };
18
19
 
19
20
  const ExternalSystemsScreen = ({ config, onBackPress }: Props) => {
20
- const {
21
+ const {
21
22
  isConfigured,
23
+ deviceSerialNumber,
22
24
  isDeviceConnected,
25
+ getDeviceDetails,
23
26
  isCancellationRunning,
24
27
  cancelOperation,
25
28
  runConfiguration,
26
29
  isConfigurationInProgress,
27
- displayMessage
30
+ displayMessage,
28
31
  } = useEMVPayment();
29
-
32
+
30
33
  const [deviceInfo] = useState('');
31
34
 
35
+ const [isFetchingDeviceDetails, setFetchingDeviceDetails] = useState(false);
36
+
32
37
  const [infoVisible, setInfoVisible] = useState(false);
33
38
 
34
39
  // Auto-close info modal when device connects
@@ -38,8 +43,75 @@ const {
38
43
  }
39
44
  }, [isDeviceConnected, infoVisible]);
40
45
 
46
+ // useEffect(() => {
47
+ // let timer: NodeJS.Timeout;
48
+ // if (isConfigured) {
49
+ // if (deviceSerialNumber?.trim()) {
50
+ // addDevice({
51
+ // isConfigured: true,
52
+ // isSandbox: true,
53
+ // MerchantId: config?.merchantID ?? '',
54
+ // serialNumber: deviceSerialNumber,
55
+ // });
56
+ // } else {
57
+ // setFetchingDeviceDetails(true);
58
+ // timer = setTimeout(() => {
59
+ // getDeviceDetails();
60
+ // }, 3000);
61
+ // }
62
+ // }
63
+ // return () => {
64
+ // if (timer) clearTimeout(timer);
65
+ // };
66
+ // }, [isConfigured]);
67
+
68
+ // useEffect(() => {
69
+ // if (deviceSerialNumber?.trim()) {
70
+ // setFetchingDeviceDetails(false);
71
+ // addDevice({
72
+ // isConfigured: true,
73
+ // isSandbox: true,
74
+ // MerchantId: config?.merchantID ?? '',
75
+ // serialNumber: deviceSerialNumber,
76
+ // });
77
+ // }
78
+ // }, [deviceSerialNumber]);
79
+ useEffect(() => {
80
+ let timer: NodeJS.Timeout;
81
+ const handleSerial = async () => {
82
+ if (isConfigured) {
83
+ const serialNumberToBeStored = !deviceSerialNumber?.trim()
84
+ ? await getDeviceDetails()
85
+ : deviceSerialNumber;
86
+
87
+ if (serialNumberToBeStored) {
88
+ addDevice({
89
+ MerchantId: config?.merchantID ?? '',
90
+ isSandbox: config?.isSandBox ?? true,
91
+ isConfigured: true,
92
+ serialNumber: serialNumberToBeStored,
93
+ });
94
+ }
95
+ }
96
+ setFetchingDeviceDetails(false);
97
+ };
98
+
99
+ timer = setTimeout(() => {
100
+ setFetchingDeviceDetails(true);
101
+ handleSerial();
102
+ }, 3000);
103
+
104
+ return () => {
105
+ if (timer) {
106
+ clearTimeout(timer);
107
+ setFetchingDeviceDetails(false);
108
+ }
109
+ };
110
+ }, [isConfigured, deviceSerialNumber]);
111
+
41
112
  const onConfigureDevice = useCallback(() => {
42
113
  if (!config) return;
114
+
43
115
  runConfiguration(config);
44
116
  }, [config, runConfiguration]);
45
117
 
@@ -89,9 +161,8 @@ const {
89
161
  >
90
162
  <Pressable style={styles.modalContainer}>
91
163
  <Text style={styles.modalText}>
92
- 1. Do not disconnect the device
93
- while configuring. \n2. Do not put app in the background while
94
- configuring. \n
164
+ 1. Do not disconnect the device while configuring. \n2. Do not put
165
+ app in the background while configuring. \n
95
166
  {displayMessage}
96
167
  </Text>
97
168
  <Pressable style={styles.closeButton} onPress={() => {}}>
@@ -102,6 +173,21 @@ const {
102
173
  </Modal>
103
174
  );
104
175
 
176
+ const DeviceDetailsModal = () => (
177
+ <Modal
178
+ visible={isFetchingDeviceDetails}
179
+ transparent
180
+ animationType="fade"
181
+ onRequestClose={() => {}}
182
+ >
183
+ <Pressable style={styles.modalBackground} onPress={() => {}}>
184
+ <Pressable style={styles.modalContainer}>
185
+ <Text style={styles.modalText}>Saving Device Details.....</Text>
186
+ </Pressable>
187
+ </Pressable>
188
+ </Modal>
189
+ );
190
+
105
191
  const CancelModal = () => (
106
192
  <Modal
107
193
  visible={isCancellationRunning}
@@ -126,30 +212,30 @@ const {
126
212
  );
127
213
 
128
214
  const InfoModal = () => (
129
- <Modal
130
- visible={infoVisible}
131
- transparent
132
- animationType="fade"
133
- onRequestClose={() => setInfoVisible(false)}
134
- >
215
+ <Modal
216
+ visible={infoVisible}
217
+ transparent
218
+ animationType="fade"
219
+ onRequestClose={() => setInfoVisible(false)}
220
+ >
221
+ <Pressable
222
+ style={styles.modalBackground}
223
+ onPress={() => setInfoVisible(false)}
224
+ >
225
+ <Pressable style={styles.modalContainer}>
226
+ <Text style={styles.modalText}>
227
+ Connect IDTECH VP3350 device via USB cable
228
+ </Text>
135
229
  <Pressable
136
- style={styles.modalBackground}
230
+ style={styles.closeButton}
137
231
  onPress={() => setInfoVisible(false)}
138
232
  >
139
- <Pressable style={styles.modalContainer}>
140
- <Text style={styles.modalText}>
141
- Connect IDTECH VP3350 device via USB cable
142
- </Text>
143
- <Pressable
144
- style={styles.closeButton}
145
- onPress={() => setInfoVisible(false)}
146
- >
147
- <Text style={styles.closeButtonText}>Close</Text>
148
- </Pressable>
149
- </Pressable>
233
+ <Text style={styles.closeButtonText}>Close</Text>
150
234
  </Pressable>
151
- </Modal>
152
- )
235
+ </Pressable>
236
+ </Pressable>
237
+ </Modal>
238
+ );
153
239
 
154
240
  const ConfigurationDetails = ({
155
241
  merchantId,
@@ -241,11 +327,14 @@ const {
241
327
  {/** Loader Modal */}
242
328
  <LoaderModal />
243
329
 
330
+ {/** Device Fetching Modal */}
331
+ <DeviceDetailsModal />
332
+
244
333
  {/** Cancel Modal */}
245
334
  <CancelModal />
246
335
 
247
336
  {/* Configure CTA */}
248
- {isDeviceConnected && !isConfigured && <ConfigureCTA />}
337
+ {isDeviceConnected && <ConfigureCTA />}
249
338
 
250
339
  <BackCTA />
251
340
  </View>
@@ -7,7 +7,7 @@ const MainScreen: React.FC<{ config: EMVConfig }> = ({ config }) => {
7
7
  const [showEMV, setShowEMV] = useState(false);
8
8
 
9
9
  if (showEMV) {
10
- return <EMVPaymentScreen />;
10
+ return <EMVPaymentScreen posConfig={config}/>;
11
11
  }
12
12
 
13
13
  return (
@@ -0,0 +1,40 @@
1
+ export type DeviceConfig = {
2
+ serialNumber: string;
3
+ MerchantId: string;
4
+ isSandbox: boolean;
5
+ isConfigured: boolean;
6
+ };
7
+
8
+ export let IDTECH_LOCAL_DB: DeviceConfig[] = [
9
+
10
+ ];
11
+
12
+ export const addDevice = (device: DeviceConfig) => {
13
+ console.log('ADDING Device: ', device);
14
+ IDTECH_LOCAL_DB.push(device);
15
+ console.log('After Device ADDED : ', IDTECH_LOCAL_DB);
16
+ };
17
+
18
+ export const updateDevice = (
19
+ serialNumber: string,
20
+ updated: Partial<DeviceConfig>,
21
+ ) => {
22
+ const index = IDTECH_LOCAL_DB.findIndex(d => d.serialNumber === serialNumber);
23
+
24
+ if (index !== -1) {
25
+ IDTECH_LOCAL_DB[index] = {
26
+ ...IDTECH_LOCAL_DB[index],
27
+ ...updated,
28
+ };
29
+ }
30
+ };
31
+
32
+ export const deleteDevice = (serialNumber: string) => {
33
+ IDTECH_LOCAL_DB = IDTECH_LOCAL_DB.filter(
34
+ d => d.serialNumber !== serialNumber,
35
+ );
36
+ };
37
+
38
+ export const getDeviceBySerial = (serialNumber: string) => {
39
+ return IDTECH_LOCAL_DB.find(d => d.serialNumber === serialNumber);
40
+ };