omnipay-reactnative-sdk 1.1.5 → 1.1.7

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/lib/commonjs/components/OmnipayProvider.js +3 -3
  2. package/lib/commonjs/components/OmnipayProvider.js.map +1 -1
  3. package/lib/commonjs/components/OmnipayView.js +4 -0
  4. package/lib/commonjs/components/OmnipayView.js.map +1 -1
  5. package/lib/commonjs/components/views/BvnVerification.js +133 -0
  6. package/lib/commonjs/components/views/BvnVerification.js.map +1 -0
  7. package/lib/commonjs/components/views/PaylaterAgreement.js +132 -0
  8. package/lib/commonjs/components/views/PaylaterAgreement.js.map +1 -0
  9. package/lib/module/components/OmnipayProvider.js +3 -3
  10. package/lib/module/components/OmnipayProvider.js.map +1 -1
  11. package/lib/module/components/OmnipayView.js +4 -0
  12. package/lib/module/components/OmnipayView.js.map +1 -1
  13. package/lib/module/components/views/BvnVerification.js +124 -0
  14. package/lib/module/components/views/BvnVerification.js.map +1 -0
  15. package/lib/module/components/views/PaylaterAgreement.js +123 -0
  16. package/lib/module/components/views/PaylaterAgreement.js.map +1 -0
  17. package/lib/typescript/components/OmnipayView.d.ts +24 -0
  18. package/lib/typescript/components/OmnipayView.d.ts.map +1 -1
  19. package/lib/typescript/components/views/BvnVerification.d.ts +12 -0
  20. package/lib/typescript/components/views/BvnVerification.d.ts.map +1 -0
  21. package/lib/typescript/components/views/PaylaterAgreement.d.ts +19 -0
  22. package/lib/typescript/components/views/PaylaterAgreement.d.ts.map +1 -0
  23. package/package.json +5 -4
  24. package/src/components/OmnipayProvider.tsx +2 -2
  25. package/src/components/OmnipayView.tsx +4 -0
  26. package/src/components/views/BvnVerification.tsx +153 -0
  27. package/src/components/views/PaylaterAgreement.tsx +167 -0
@@ -0,0 +1,124 @@
1
+ import React, { Fragment, useRef, useState } from 'react';
2
+ import { ActivityIndicator, Platform, StyleSheet, Text, View } from 'react-native';
3
+ import { WebView } from 'react-native-webview';
4
+ import { serverSdkBaseUrl } from '../../lib/config';
5
+ export const BvnVerification = _ref => {
6
+ let {
7
+ color,
8
+ env,
9
+ publicKey,
10
+ phoneNumber,
11
+ onVerificationSuccessful,
12
+ onClose,
13
+ customerRef
14
+ } = _ref;
15
+ const webviewRef = useRef(null);
16
+ const [webviewStatus, setWebviewStatus] = useState('loading');
17
+ const webHost = getWebHost();
18
+ const webUrl = getWebUrl();
19
+ const onWebviewMount = `
20
+ window.nativeOs = ${Platform.OS};
21
+ true;
22
+ `;
23
+ function getWebHost() {
24
+ return serverSdkBaseUrl[env];
25
+ }
26
+ function getWebUrl() {
27
+ const themeColor = color.includes('#') ? color.split('#')[1] : color;
28
+ return `${webHost}auth/register?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
29
+ }
30
+
31
+ // function postMessage(data: PostMessage) {
32
+ // if (!webviewRef.current) {
33
+ // return;
34
+ // }
35
+ // try {
36
+ // webviewRef.current.postMessage(JSON.stringify(data));
37
+ // } catch (error) {}
38
+ // }
39
+
40
+ async function onWebviewMessage(e) {
41
+ try {
42
+ if (e.nativeEvent && e.nativeEvent.data) {
43
+ const eventData = JSON.parse(e.nativeEvent.data);
44
+ const {
45
+ dataKey
46
+ } = eventData;
47
+ if (dataKey === 'bvn.verified') {
48
+ if (onVerificationSuccessful) {
49
+ onVerificationSuccessful();
50
+ }
51
+ return;
52
+ }
53
+ if (dataKey === 'close.bvnverification') {
54
+ if (onClose) {
55
+ onClose();
56
+ }
57
+ return;
58
+ }
59
+ }
60
+ } catch (error) {}
61
+ }
62
+ if (!publicKey.includes('OMNIPUBKEY_')) {
63
+ return /*#__PURE__*/React.createElement(Text, null, "Invalid public key");
64
+ }
65
+ if (color.length < 3) {
66
+ return /*#__PURE__*/React.createElement(Text, null, "Invalid color");
67
+ }
68
+ if (!['dev', 'prod'].includes(env)) {
69
+ return /*#__PURE__*/React.createElement(Text, null, "Invalid environment");
70
+ }
71
+ if (!customerRef) {
72
+ if (!phoneNumber) {
73
+ return /*#__PURE__*/React.createElement(Text, null, "Phone number is required");
74
+ }
75
+ if ((phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.length) < 10) {
76
+ return /*#__PURE__*/React.createElement(Text, null, "Invalid phone number");
77
+ }
78
+ }
79
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
80
+ style: styles.full
81
+ }, /*#__PURE__*/React.createElement(WebView, {
82
+ source: {
83
+ uri: webUrl
84
+ },
85
+ style: styles.webview,
86
+ injectedJavaScriptBeforeContentLoaded: onWebviewMount,
87
+ onMessage: onWebviewMessage,
88
+ ref: webviewRef,
89
+ onLoadEnd: () => setWebviewStatus('success')
90
+ }), webviewStatus === 'loading' && /*#__PURE__*/React.createElement(View, {
91
+ style: styles.webviewLoader
92
+ }, /*#__PURE__*/React.createElement(ActivityIndicator, {
93
+ size: "small",
94
+ color: color
95
+ }))));
96
+ };
97
+ const styles = StyleSheet.create({
98
+ hide: {
99
+ display: 'none'
100
+ },
101
+ full: {
102
+ flex: 1,
103
+ width: '100%',
104
+ height: '100%'
105
+ },
106
+ webview: {
107
+ flex: 1,
108
+ width: '100%',
109
+ height: '100%'
110
+ },
111
+ webviewLoader: {
112
+ zIndex: 3,
113
+ backgroundColor: 'white',
114
+ alignItems: 'center',
115
+ justifyContent: 'center',
116
+ flex: 1,
117
+ width: '100%',
118
+ height: '100%',
119
+ position: 'absolute',
120
+ top: 0,
121
+ left: 0
122
+ }
123
+ });
124
+ //# sourceMappingURL=BvnVerification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Fragment","useRef","useState","ActivityIndicator","Platform","StyleSheet","Text","View","WebView","serverSdkBaseUrl","BvnVerification","color","env","publicKey","phoneNumber","onVerificationSuccessful","onClose","customerRef","webviewRef","webviewStatus","setWebviewStatus","webHost","getWebHost","webUrl","getWebUrl","onWebviewMount","OS","themeColor","includes","split","onWebviewMessage","e","nativeEvent","data","eventData","JSON","parse","dataKey","error","length","styles","full","uri","webview","webviewLoader","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"sourceRoot":"../../src","sources":["BvnVerification.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzD,SACEC,iBAAiB,EACjBC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,IAAI,QACC,cAAc;AACrB,SAASC,OAAO,QAA6B,sBAAsB;AACnE,SAASC,gBAAgB,QAAQ,kBAAkB;AAcnD,OAAO,MAAMC,eAAe,GAAG,QAQE;EAAA,IARD;IAC9BC,KAAK;IACLC,GAAG;IACHC,SAAS;IACTC,WAAW;IACXC,wBAAwB;IACxBC,OAAO;IACPC;EACY,CAAC;EACb,MAAMC,UAAU,GAAGjB,MAAM,CAAU,IAAI,CAAC;EACxC,MAAM,CAACkB,aAAa,EAAEC,gBAAgB,CAAC,GAAGlB,QAAQ,CAAS,SAAS,CAAC;EACrE,MAAMmB,OAAO,GAAGC,UAAU,EAAE;EAC5B,MAAMC,MAAM,GAAGC,SAAS,EAAE;EAE1B,MAAMC,cAAc,GAAI;AAC1B,4BAA4BrB,QAAQ,CAACsB,EAAG;AACxC;AACA,OAAO;EAEL,SAASJ,UAAU,GAAG;IACpB,OAAOb,gBAAgB,CAACG,GAAG,CAAC;EAC9B;EAEA,SAASY,SAAS,GAAG;IACnB,MAAMG,UAAU,GAAGhB,KAAK,CAACiB,QAAQ,CAAC,GAAG,CAAC,GAAGjB,KAAK,CAACkB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAGlB,KAAK;IACpE,OAAQ,GAAEU,OAAQ,uBAAsBM,UAAW,cAAad,SAAU,gBAAeC,WAAY,EAAC;EACxG;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,eAAegB,gBAAgB,CAACC,CAAsB,EAAE;IACtD,IAAI;MACF,IAAIA,CAAC,CAACC,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AEK,gBAAiB;IAC5B,GAAG,EAAEZ,UAAW;IAChB,SAAS,EAAE,MAAME,gBAAgB,CAAC,SAAS;EAAE,EAC7C,EACDD,aAAa,KAAK,SAAS,iBAC1B,oBAAC,IAAI;IAAC,KAAK,EAAEqB,MAAM,CAACI;EAAc,gBAChC,oBAAC,iBAAiB;IAAC,IAAI,EAAC,OAAO;IAAC,KAAK,EAAEjC;EAAM,EAAG,CAEnD,CACI,CACE;AAEf,CAAC;AAED,MAAM6B,MAAM,GAAGnC,UAAU,CAACwC,MAAM,CAAC;EAC/BC,IAAI,EAAE;IACJC,OAAO,EAAE;EACX,CAAC;EACDN,IAAI,EAAE;IACJO,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDP,OAAO,EAAE;IACPK,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDN,aAAa,EAAE;IACbO,MAAM,EAAE,CAAC;IACTC,eAAe,EAAE,OAAO;IACxBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBN,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,MAAM;IACdK,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE;EACR;AACF,CAAC,CAAC"}
@@ -0,0 +1,123 @@
1
+ import React, { Fragment, useRef, useState } from 'react';
2
+ import { ActivityIndicator, Platform, StyleSheet, Text, View } from 'react-native';
3
+ import { WebView } from 'react-native-webview';
4
+ import { serverSdkBaseUrl } from '../../lib/config';
5
+ export const PaylaterAgreement = _ref => {
6
+ let {
7
+ color,
8
+ env,
9
+ publicKey,
10
+ phoneNumber,
11
+ onAgreementAccepted,
12
+ customerRef,
13
+ amount,
14
+ lenderId,
15
+ feesId,
16
+ sublimitId,
17
+ onClose
18
+ } = _ref;
19
+ const webviewRef = useRef(null);
20
+ const [webviewStatus, setWebviewStatus] = useState('loading');
21
+ const webHost = getWebHost();
22
+ const webUrl = getWebUrl();
23
+ const onWebviewMount = `
24
+ window.nativeOs = ${Platform.OS};
25
+ true;
26
+ `;
27
+ function getWebHost() {
28
+ return serverSdkBaseUrl[env];
29
+ }
30
+ function getWebUrl() {
31
+ const themeColor = color.includes('#') ? color.split('#')[1] : color;
32
+ return `${webHost}paylater/agreement?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${phoneNumber || ''}&customerRef=${customerRef || ''}&amount=${amount}&lenderId=${lenderId || ''}&feesId=${feesId || ''}&sublimitId=${sublimitId || ''}`;
33
+ }
34
+ async function onWebviewMessage(e) {
35
+ try {
36
+ if (e.nativeEvent && e.nativeEvent.data) {
37
+ const eventData = JSON.parse(e.nativeEvent.data);
38
+ const {
39
+ dataKey,
40
+ dataValue
41
+ } = eventData;
42
+ if (dataKey === 'agreement.accepted') {
43
+ onAgreementAccepted({
44
+ agreementId: dataValue.agreementId
45
+ });
46
+ return;
47
+ }
48
+ if (dataKey === 'close.agreement') {
49
+ if (onClose) {
50
+ onClose();
51
+ }
52
+ return;
53
+ }
54
+ return;
55
+ }
56
+ } catch (error) {}
57
+ }
58
+ if (!publicKey.includes('OMNIPUBKEY_')) {
59
+ return /*#__PURE__*/React.createElement(Text, null, "Invalid public key");
60
+ }
61
+ if (color.length < 3) {
62
+ return /*#__PURE__*/React.createElement(Text, null, "Invalid color");
63
+ }
64
+ if (!['dev', 'prod'].includes(env)) {
65
+ return /*#__PURE__*/React.createElement(Text, null, "Invalid environment");
66
+ }
67
+ if (!customerRef) {
68
+ if (!phoneNumber) {
69
+ return /*#__PURE__*/React.createElement(Text, null, "Phone number is required");
70
+ }
71
+ if ((phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.length) < 10) {
72
+ return /*#__PURE__*/React.createElement(Text, null, "Invalid phone number");
73
+ }
74
+ }
75
+ if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
76
+ return /*#__PURE__*/React.createElement(Text, null, "Amount is required and should be greater than 0");
77
+ }
78
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
79
+ style: styles.full
80
+ }, /*#__PURE__*/React.createElement(WebView, {
81
+ source: {
82
+ uri: webUrl
83
+ },
84
+ style: styles.webview,
85
+ injectedJavaScriptBeforeContentLoaded: onWebviewMount,
86
+ onMessage: onWebviewMessage,
87
+ ref: webviewRef,
88
+ onLoadEnd: () => setWebviewStatus('success')
89
+ }), webviewStatus === 'loading' && /*#__PURE__*/React.createElement(View, {
90
+ style: styles.webviewLoader
91
+ }, /*#__PURE__*/React.createElement(ActivityIndicator, {
92
+ size: "small",
93
+ color: color
94
+ }))));
95
+ };
96
+ const styles = StyleSheet.create({
97
+ hide: {
98
+ display: 'none'
99
+ },
100
+ full: {
101
+ flex: 1,
102
+ width: '100%',
103
+ height: '100%'
104
+ },
105
+ webview: {
106
+ flex: 1,
107
+ width: '100%',
108
+ height: '100%'
109
+ },
110
+ webviewLoader: {
111
+ zIndex: 3,
112
+ backgroundColor: 'white',
113
+ alignItems: 'center',
114
+ justifyContent: 'center',
115
+ flex: 1,
116
+ width: '100%',
117
+ height: '100%',
118
+ position: 'absolute',
119
+ top: 0,
120
+ left: 0
121
+ }
122
+ });
123
+ //# sourceMappingURL=PaylaterAgreement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Fragment","useRef","useState","ActivityIndicator","Platform","StyleSheet","Text","View","WebView","serverSdkBaseUrl","PaylaterAgreement","color","env","publicKey","phoneNumber","onAgreementAccepted","customerRef","amount","lenderId","feesId","sublimitId","onClose","webviewRef","webviewStatus","setWebviewStatus","webHost","getWebHost","webUrl","getWebUrl","onWebviewMount","OS","themeColor","includes","split","onWebviewMessage","e","nativeEvent","data","eventData","JSON","parse","dataKey","dataValue","agreementId","error","length","isNaN","Number","styles","full","uri","webview","webviewLoader","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"s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3D,oBAAO,oBAAC,IAAI,0DAAuD;EACrE;EAEA,oBACE,oBAAC,QAAQ,qBACP,oBAAC,IAAI;IAAC,KAAK,EAAE+B,MAAM,CAACC;EAAK,gBACvB,oBAAC,OAAO;IACN,MAAM,EAAE;MACNC,GAAG,EAAEvB;IACP,CAAE;IACF,KAAK,EAAEqB,MAAM,CAACG,OAAQ;IACtB,qCAAqC,EAAEtB,cAAe;IACtD,SAAS,EAAEK,gBAAiB;IAC5B,GAAG,EAAEZ,UAAW;IAChB,SAAS,EAAE,MAAME,gBAAgB,CAAC,SAAS;EAAE,EAC7C,EACDD,aAAa,KAAK,SAAS,iBAC1B,oBAAC,IAAI;IAAC,KAAK,EAAEyB,MAAM,CAACI;EAAc,gBAChC,oBAAC,iBAAiB;IAAC,IAAI,EAAC,OAAO;IAAC,KAAK,EAAEzC;EAAM,EAAG,CAEnD,CACI,CACE;AAEf,CAAC;AAED,MAAMqC,MAAM,GAAG3C,UAAU,CAACgD,MAAM,CAAC;EAC/BC,IAAI,EAAE;IACJC,OAAO,EAAE;EACX,CAAC;EACDN,IAAI,EAAE;IACJO,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDP,OAAO,EAAE;IACPK,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDN,aAAa,EAAE;IACbO,MAAM,EAAE,CAAC;IACTC,eAAe,EAAE,OAAO;IACxBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBN,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,MAAM;IACdK,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE;EACR;AACF,CAAC,CAAC"}
@@ -20,6 +20,30 @@ declare const Omnipay: {
20
20
  }) => void) | undefined;
21
21
  onClose?: (() => void) | undefined;
22
22
  }) => JSX.Element;
23
+ BvnVerification: ({ color, env, publicKey, phoneNumber, onVerificationSuccessful, onClose, customerRef, }: {
24
+ color: string;
25
+ env: "prod" | "dev";
26
+ publicKey: string;
27
+ phoneNumber?: string | undefined;
28
+ customerRef?: string | undefined;
29
+ onVerificationSuccessful?: (() => void) | undefined;
30
+ onClose?: (() => void) | undefined;
31
+ }) => JSX.Element;
32
+ PaylaterAgreement: ({ color, env, publicKey, phoneNumber, onAgreementAccepted, customerRef, amount, lenderId, feesId, sublimitId, onClose, }: {
33
+ color: string;
34
+ env: "prod" | "dev";
35
+ publicKey: string;
36
+ phoneNumber?: string | undefined;
37
+ customerRef?: string | undefined;
38
+ amount: number;
39
+ lenderId?: string | undefined;
40
+ feesId?: string | undefined;
41
+ sublimitId?: string | undefined;
42
+ onAgreementAccepted: ({ agreementId }: {
43
+ agreementId: string;
44
+ }) => void;
45
+ onClose?: (() => void) | undefined;
46
+ }) => JSX.Element;
23
47
  };
24
48
  export default Omnipay;
25
49
  //# sourceMappingURL=OmnipayView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OmnipayView.d.ts","sourceRoot":"","sources":["../../../src/components/OmnipayView.tsx"],"names":[],"mappings":"AAcA,aAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,KAAK,GAAG,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,GAAG,cAAc,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B,CAAC;AAQF,QAAA,MAAM,OAAO;yFAQV,YAAY,GAAG,WAAW;;;;;;;;;;;;CA6G5B,CAAC;AA+BF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"OmnipayView.d.ts","sourceRoot":"","sources":["../../../src/components/OmnipayView.tsx"],"names":[],"mappings":"AAgBA,aAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,KAAK,GAAG,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,GAAG,cAAc,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B,CAAC;AAQF,QAAA,MAAM,OAAO;yFAQV,YAAY,GAAG,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6G5B,CAAC;AAiCF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,12 @@
1
+ declare type OmnipayProps = {
2
+ color: string;
3
+ env: 'dev' | 'prod';
4
+ publicKey: string;
5
+ phoneNumber?: string;
6
+ customerRef?: string;
7
+ onVerificationSuccessful?: () => void;
8
+ onClose?: () => void;
9
+ };
10
+ export declare const BvnVerification: ({ color, env, publicKey, phoneNumber, onVerificationSuccessful, onClose, customerRef, }: OmnipayProps) => JSX.Element;
11
+ export {};
12
+ //# sourceMappingURL=BvnVerification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BvnVerification.d.ts","sourceRoot":"","sources":["../../../../src/components/views/BvnVerification.tsx"],"names":[],"mappings":"AAWA,aAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,KAAK,GAAG,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAIF,eAAO,MAAM,eAAe,4FAQzB,YAAY,KAAG,WA6FjB,CAAC"}
@@ -0,0 +1,19 @@
1
+ declare type AgreementSubmittedType = {
2
+ agreementId: string;
3
+ };
4
+ declare type OmnipayProps = {
5
+ color: string;
6
+ env: 'dev' | 'prod';
7
+ publicKey: string;
8
+ phoneNumber?: string;
9
+ customerRef?: string;
10
+ amount: number;
11
+ lenderId?: string;
12
+ feesId?: string;
13
+ sublimitId?: string;
14
+ onAgreementAccepted: ({ agreementId }: AgreementSubmittedType) => void;
15
+ onClose?: () => void;
16
+ };
17
+ export declare const PaylaterAgreement: ({ color, env, publicKey, phoneNumber, onAgreementAccepted, customerRef, amount, lenderId, feesId, sublimitId, onClose, }: OmnipayProps) => JSX.Element;
18
+ export {};
19
+ //# sourceMappingURL=PaylaterAgreement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaylaterAgreement.d.ts","sourceRoot":"","sources":["../../../../src/components/views/PaylaterAgreement.tsx"],"names":[],"mappings":"AAWA,aAAK,sBAAsB,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,aAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,KAAK,GAAG,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACvE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAIF,eAAO,MAAM,iBAAiB,6HAY3B,YAAY,KAAG,WA+FjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnipay-reactnative-sdk",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Omnipay react native sdk",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -70,16 +70,17 @@
70
70
  "react": "18.1.0",
71
71
  "react-native": "0.70.3",
72
72
  "react-native-builder-bob": "^0.20.0",
73
+ "react-native-share": "^10.2.1",
73
74
  "release-it": "^15.0.0",
74
- "typescript": "^4.5.2",
75
- "react-native-share": "^10.2.1"
75
+ "typescript": "^4.5.2"
76
76
  },
77
77
  "resolutions": {
78
78
  "@types/react": "17.0.21"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "react": "*",
82
- "react-native": "*"
82
+ "react-native": "*",
83
+ "react-native-share": "^10.2.1"
83
84
  },
84
85
  "jest": {
85
86
  "preset": "react-native",
@@ -152,7 +152,6 @@ export const OmnipayProvider = ({
152
152
  async function startPosTransaction({
153
153
  amount,
154
154
  purchaseType,
155
- color,
156
155
  print,
157
156
  rrn,
158
157
  stan,
@@ -281,7 +280,7 @@ export const OmnipayProvider = ({
281
280
  try {
282
281
  const { fileName = '', image = '' } = JSON.parse(receiptData);
283
282
  await Share.open({
284
- url: `data:image/jpeg;base64,${image}`,
283
+ url: image,
285
284
  filename: Platform.OS === 'android' ? fileName : `${fileName}.jpg`,
286
285
  });
287
286
  } catch (error) {
@@ -371,6 +370,7 @@ export const OmnipayProvider = ({
371
370
  <View
372
371
  style={[
373
372
  styles.container,
373
+ /* eslint-disable react-native/no-inline-styles */
374
374
  { paddingTop: isWalletView ? 0 : containerOffset },
375
375
  ]}
376
376
  >
@@ -11,6 +11,8 @@ import { WebView, WebViewMessageEvent } from 'react-native-webview';
11
11
  import { clientSdkBaseUrl, serverSdkBaseUrl } from '../lib/config';
12
12
  import { getContact } from '../functions';
13
13
  import { Registration } from './views/Registration';
14
+ import { BvnVerification } from './views/BvnVerification';
15
+ import { PaylaterAgreement } from './views/PaylaterAgreement';
14
16
 
15
17
  type OmnipayProps = {
16
18
  color: string;
@@ -176,4 +178,6 @@ const styles = StyleSheet.create({
176
178
  });
177
179
 
178
180
  Omnipay.Registration = Registration;
181
+ Omnipay.BvnVerification = BvnVerification;
182
+ Omnipay.PaylaterAgreement = PaylaterAgreement;
179
183
  export default Omnipay;
@@ -0,0 +1,153 @@
1
+ import React, { Fragment, useRef, useState } from 'react';
2
+ import {
3
+ ActivityIndicator,
4
+ Platform,
5
+ StyleSheet,
6
+ Text,
7
+ View,
8
+ } from 'react-native';
9
+ import { WebView, WebViewMessageEvent } from 'react-native-webview';
10
+ import { serverSdkBaseUrl } from '../../lib/config';
11
+
12
+ type OmnipayProps = {
13
+ color: string;
14
+ env: 'dev' | 'prod';
15
+ publicKey: string;
16
+ phoneNumber?: string;
17
+ customerRef?: string;
18
+ onVerificationSuccessful?: () => void;
19
+ onClose?: () => void;
20
+ };
21
+
22
+ type Status = 'error' | 'loading' | 'success';
23
+
24
+ export const BvnVerification = ({
25
+ color,
26
+ env,
27
+ publicKey,
28
+ phoneNumber,
29
+ onVerificationSuccessful,
30
+ onClose,
31
+ customerRef,
32
+ }: OmnipayProps): JSX.Element => {
33
+ const webviewRef = useRef<WebView>(null);
34
+ const [webviewStatus, setWebviewStatus] = useState<Status>('loading');
35
+ const webHost = getWebHost();
36
+ const webUrl = getWebUrl();
37
+
38
+ const onWebviewMount = `
39
+ window.nativeOs = ${Platform.OS};
40
+ true;
41
+ `;
42
+
43
+ function getWebHost() {
44
+ return serverSdkBaseUrl[env];
45
+ }
46
+
47
+ function getWebUrl() {
48
+ const themeColor = color.includes('#') ? color.split('#')[1] : color;
49
+ return `${webHost}auth/register?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
50
+ }
51
+
52
+ // function postMessage(data: PostMessage) {
53
+ // if (!webviewRef.current) {
54
+ // return;
55
+ // }
56
+ // try {
57
+ // webviewRef.current.postMessage(JSON.stringify(data));
58
+ // } catch (error) {}
59
+ // }
60
+
61
+ async function onWebviewMessage(e: WebViewMessageEvent) {
62
+ try {
63
+ if (e.nativeEvent && e.nativeEvent.data) {
64
+ const eventData = JSON.parse(e.nativeEvent.data);
65
+ const { dataKey } = eventData;
66
+
67
+ if (dataKey === 'bvn.verified') {
68
+ if (onVerificationSuccessful) {
69
+ onVerificationSuccessful();
70
+ }
71
+ return;
72
+ }
73
+ if (dataKey === 'close.bvnverification') {
74
+ if (onClose) {
75
+ onClose();
76
+ }
77
+ return;
78
+ }
79
+ }
80
+ } catch (error) {}
81
+ }
82
+
83
+ if (!publicKey.includes('OMNIPUBKEY_')) {
84
+ return <Text>Invalid public key</Text>;
85
+ }
86
+
87
+ if (color.length < 3) {
88
+ return <Text>Invalid color</Text>;
89
+ }
90
+
91
+ if (!['dev', 'prod'].includes(env)) {
92
+ return <Text>Invalid environment</Text>;
93
+ }
94
+
95
+ if (!customerRef) {
96
+ if (!phoneNumber) {
97
+ return <Text>Phone number is required</Text>;
98
+ }
99
+ if (phoneNumber?.length < 10) {
100
+ return <Text>Invalid phone number</Text>;
101
+ }
102
+ }
103
+
104
+ return (
105
+ <Fragment>
106
+ <View style={styles.full}>
107
+ <WebView
108
+ source={{
109
+ uri: webUrl,
110
+ }}
111
+ style={styles.webview}
112
+ injectedJavaScriptBeforeContentLoaded={onWebviewMount}
113
+ onMessage={onWebviewMessage}
114
+ ref={webviewRef}
115
+ onLoadEnd={() => setWebviewStatus('success')}
116
+ />
117
+ {webviewStatus === 'loading' && (
118
+ <View style={styles.webviewLoader}>
119
+ <ActivityIndicator size="small" color={color} />
120
+ </View>
121
+ )}
122
+ </View>
123
+ </Fragment>
124
+ );
125
+ };
126
+
127
+ const styles = StyleSheet.create({
128
+ hide: {
129
+ display: 'none',
130
+ },
131
+ full: {
132
+ flex: 1,
133
+ width: '100%',
134
+ height: '100%',
135
+ },
136
+ webview: {
137
+ flex: 1,
138
+ width: '100%',
139
+ height: '100%',
140
+ },
141
+ webviewLoader: {
142
+ zIndex: 3,
143
+ backgroundColor: 'white',
144
+ alignItems: 'center',
145
+ justifyContent: 'center',
146
+ flex: 1,
147
+ width: '100%',
148
+ height: '100%',
149
+ position: 'absolute',
150
+ top: 0,
151
+ left: 0,
152
+ },
153
+ });