omnipay-reactnative-sdk 1.2.1 → 1.2.2-beta.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.
Files changed (29) hide show
  1. package/README.md +136 -45
  2. package/lib/commonjs/components/FaceVerification.js +755 -0
  3. package/lib/commonjs/components/FaceVerification.js.map +1 -0
  4. package/lib/commonjs/components/OmnipayProvider.js +60 -1
  5. package/lib/commonjs/components/OmnipayProvider.js.map +1 -1
  6. package/lib/commonjs/types/faceVerification.js +2 -0
  7. package/lib/commonjs/types/faceVerification.js.map +1 -0
  8. package/lib/commonjs/types/index.js +17 -0
  9. package/lib/commonjs/types/index.js.map +1 -0
  10. package/lib/module/components/FaceVerification.js +746 -0
  11. package/lib/module/components/FaceVerification.js.map +1 -0
  12. package/lib/module/components/OmnipayProvider.js +60 -1
  13. package/lib/module/components/OmnipayProvider.js.map +1 -1
  14. package/lib/module/types/faceVerification.js +2 -0
  15. package/lib/module/types/faceVerification.js.map +1 -0
  16. package/lib/module/types/index.js +2 -0
  17. package/lib/module/types/index.js.map +1 -0
  18. package/lib/typescript/components/FaceVerification.d.ts +10 -0
  19. package/lib/typescript/components/FaceVerification.d.ts.map +1 -0
  20. package/lib/typescript/components/OmnipayProvider.d.ts.map +1 -1
  21. package/lib/typescript/types/faceVerification.d.ts +18 -0
  22. package/lib/typescript/types/faceVerification.d.ts.map +1 -0
  23. package/lib/typescript/types/index.d.ts +2 -0
  24. package/lib/typescript/types/index.d.ts.map +1 -0
  25. package/package.json +10 -4
  26. package/src/components/FaceVerification.tsx +884 -0
  27. package/src/components/OmnipayProvider.tsx +69 -0
  28. package/src/types/faceVerification.ts +27 -0
  29. package/src/types/index.ts +1 -0
@@ -19,6 +19,7 @@ import WebView, { WebViewMessageEvent } from 'react-native-webview';
19
19
  import { getContact } from '../functions';
20
20
  import Share from 'react-native-share';
21
21
  import AsyncStorage from '@react-native-async-storage/async-storage';
22
+ import FaceVerification from './FaceVerification';
22
23
 
23
24
  const OmnipayActivity = NativeModules.OmnipayActivity || {};
24
25
 
@@ -125,8 +126,16 @@ export const OmnipayProvider = ({
125
126
  const onCloseRef = useRef<(() => void) | undefined>(undefined);
126
127
  const [canUsePos, setCanUsePos] = useState(false);
127
128
 
129
+ // Face verification state
130
+ const [showFaceVerification, setShowFaceVerification] = useState(false);
131
+ const [faceVerificationOptions, setFaceVerificationOptions] =
132
+ useState<any>(null);
133
+
128
134
  useEffect(() => {
129
135
  checkPaymentApp();
136
+ setTimeout(() => {
137
+ setShowFaceVerification(true);
138
+ }, 5000);
130
139
  }, []);
131
140
 
132
141
  useEffect(() => {
@@ -278,6 +287,9 @@ export const OmnipayProvider = ({
278
287
  if (dataKey === 'startPosTransaction') {
279
288
  startPosTransaction(JSON.parse(dataValue));
280
289
  }
290
+ if (dataKey === 'startFaceVerification') {
291
+ startFaceVerification(dataValue ? JSON.parse(dataValue) : {});
292
+ }
281
293
  }
282
294
  } catch (error) {}
283
295
  }
@@ -361,6 +373,44 @@ export const OmnipayProvider = ({
361
373
  }
362
374
  }
363
375
 
376
+ function startFaceVerification(options: any) {
377
+ setFaceVerificationOptions(options);
378
+ setShowFaceVerification(true);
379
+ }
380
+
381
+ function handleFaceVerificationSuccess(base64Image: string) {
382
+ setShowFaceVerification(false);
383
+ postMessage({
384
+ dataKey: 'faceVerificationComplete',
385
+ dataValue: {
386
+ success: true,
387
+ image: base64Image,
388
+ ...(faceVerificationOptions || {}),
389
+ },
390
+ });
391
+ }
392
+
393
+ function handleFaceVerificationFailure() {
394
+ setShowFaceVerification(false);
395
+ postMessage({
396
+ dataKey: 'faceVerificationComplete',
397
+ dataValue: {
398
+ success: false,
399
+ error: 'Face verification failed',
400
+ },
401
+ });
402
+ }
403
+
404
+ function handleFaceVerificationCancel() {
405
+ setShowFaceVerification(false);
406
+ postMessage({
407
+ dataKey: 'faceVerificationCancelled',
408
+ dataValue: {
409
+ cancelled: true,
410
+ },
411
+ });
412
+ }
413
+
364
414
  const webviewStyle = getWebviewStyle();
365
415
  const isPropsValid = isValidColor && !!publicKey && isValidEnv;
366
416
  const isWalletView = webviewUrl.includes('view=wallet');
@@ -453,6 +503,21 @@ export const OmnipayProvider = ({
453
503
  </TouchableOpacity>
454
504
  </Modal>
455
505
  )}
506
+
507
+ {/* Face Verification Modal */}
508
+ <Modal
509
+ visible={showFaceVerification}
510
+ transparent
511
+ animationType="slide"
512
+ >
513
+ <View style={styles.faceVerificationContainer}>
514
+ <FaceVerification
515
+ onSuccess={handleFaceVerificationSuccess}
516
+ onFailure={handleFaceVerificationFailure}
517
+ onCancel={handleFaceVerificationCancel}
518
+ />
519
+ </View>
520
+ </Modal>
456
521
  </>
457
522
  )}
458
523
  {children}
@@ -575,4 +640,8 @@ const styles = StyleSheet.create({
575
640
  justifyContent: 'center',
576
641
  },
577
642
  buttonText: { color: 'white', fontSize: 16, paddingHorizontal: 30 },
643
+ faceVerificationContainer: {
644
+ flex: 1,
645
+ backgroundColor: 'white',
646
+ },
578
647
  });
@@ -0,0 +1,27 @@
1
+ export interface FaceVerificationOptions {
2
+ customData?: Record<string, any>;
3
+ }
4
+
5
+ export interface FaceVerificationResult {
6
+ success: boolean;
7
+ image?: string;
8
+ error?: string;
9
+ customData?: Record<string, any>;
10
+ }
11
+
12
+ export interface FaceVerificationCancelledResult {
13
+ cancelled: boolean;
14
+ }
15
+
16
+ export type FaceVerificationMessageType =
17
+ | 'startFaceVerification'
18
+ | 'faceVerificationComplete'
19
+ | 'faceVerificationCancelled';
20
+
21
+ export interface FaceVerificationMessage {
22
+ dataKey: FaceVerificationMessageType;
23
+ dataValue:
24
+ | FaceVerificationOptions
25
+ | FaceVerificationResult
26
+ | FaceVerificationCancelledResult;
27
+ }
@@ -0,0 +1 @@
1
+ export * from './faceVerification';