omnipay-reactnative-sdk 1.0.4 → 1.0.6
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/README.md +41 -0
- package/lib/commonjs/components/OmnipayProvider.js +2 -2
- package/lib/commonjs/components/OmnipayProvider.js.map +1 -1
- package/lib/commonjs/components/OmnipayView.js +27 -6
- package/lib/commonjs/components/OmnipayView.js.map +1 -1
- package/lib/commonjs/components/views/Registration.js +135 -0
- package/lib/commonjs/components/views/Registration.js.map +1 -0
- package/lib/commonjs/index.js +5 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/lib/colors.js +35 -0
- package/lib/commonjs/lib/colors.js.map +1 -0
- package/lib/commonjs/lib/config.js +17 -0
- package/lib/commonjs/lib/config.js.map +1 -0
- package/lib/module/components/OmnipayProvider.js +2 -2
- package/lib/module/components/OmnipayProvider.js.map +1 -1
- package/lib/module/components/OmnipayView.js +27 -6
- package/lib/module/components/OmnipayView.js.map +1 -1
- package/lib/module/components/views/Registration.js +126 -0
- package/lib/module/components/views/Registration.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/lib/colors.js +28 -0
- package/lib/module/lib/colors.js.map +1 -0
- package/lib/module/lib/config.js +9 -0
- package/lib/module/lib/config.js.map +1 -0
- package/lib/typescript/components/OmnipayView.d.ts +16 -3
- package/lib/typescript/components/OmnipayView.d.ts.map +1 -1
- package/lib/typescript/components/views/Registration.d.ts +15 -0
- package/lib/typescript/components/views/Registration.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/lib/colors.d.ts +28 -0
- package/lib/typescript/lib/colors.d.ts.map +1 -0
- package/lib/typescript/lib/config.d.ts +9 -0
- package/lib/typescript/lib/config.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/OmnipayProvider.tsx +2 -2
- package/src/components/OmnipayView.tsx +31 -7
- package/src/components/views/Registration.tsx +163 -0
- package/src/index.tsx +3 -1
- package/src/lib/colors.ts +27 -0
- package/src/lib/config.ts +9 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { Fragment, useRef, useState } from 'react';
|
|
2
2
|
import { StyleSheet, View, Platform, ActivityIndicator, Text, Linking } from 'react-native';
|
|
3
3
|
import { WebView } from 'react-native-webview';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { clientSdkBaseUrl, serverSdkBaseUrl } from 'src/lib/config';
|
|
5
|
+
import { getContact } from '../functions';
|
|
6
|
+
import { Registration } from './views/Registration';
|
|
7
|
+
const Omnipay = _ref => {
|
|
6
8
|
let {
|
|
7
9
|
color,
|
|
8
10
|
env,
|
|
@@ -14,12 +16,29 @@ export const Omnipay = _ref => {
|
|
|
14
16
|
} = _ref;
|
|
15
17
|
const webviewRef = useRef(null);
|
|
16
18
|
const [webviewStatus, setWebviewStatus] = useState('loading');
|
|
17
|
-
const webHost = getWebHost(
|
|
18
|
-
const webUrl =
|
|
19
|
+
const webHost = getWebHost();
|
|
20
|
+
const webUrl = getWebUrl();
|
|
19
21
|
const onWebviewMount = `
|
|
20
22
|
window.nativeOs = ${Platform.OS};
|
|
21
23
|
true;
|
|
22
24
|
`;
|
|
25
|
+
function getWebHost() {
|
|
26
|
+
/**
|
|
27
|
+
* use client rendered app url for bills sdk,
|
|
28
|
+
* else use server rendered app url
|
|
29
|
+
*/
|
|
30
|
+
if (view === 'bills') {
|
|
31
|
+
return clientSdkBaseUrl[env];
|
|
32
|
+
}
|
|
33
|
+
return serverSdkBaseUrl[env];
|
|
34
|
+
}
|
|
35
|
+
function getWebUrl() {
|
|
36
|
+
const themeColor = color.includes('#') ? color.split('#')[1] : color;
|
|
37
|
+
if (view === 'bills') {
|
|
38
|
+
return `${webHost}?theme=${themeColor}&view=${view}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
39
|
+
}
|
|
40
|
+
return `${webHost}auth/register?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
41
|
+
}
|
|
23
42
|
function postMessage(data) {
|
|
24
43
|
if (!webviewRef.current) {
|
|
25
44
|
return;
|
|
@@ -59,13 +78,13 @@ export const Omnipay = _ref => {
|
|
|
59
78
|
}
|
|
60
79
|
} catch (error) {}
|
|
61
80
|
}
|
|
62
|
-
if (view !== 'bills') {
|
|
81
|
+
if (view !== 'bills' && view !== 'registration') {
|
|
63
82
|
return /*#__PURE__*/React.createElement(Text, null, "Invalid view");
|
|
64
83
|
}
|
|
65
84
|
if (!publicKey.includes('OMNIPUBKEY_')) {
|
|
66
85
|
return /*#__PURE__*/React.createElement(Text, null, "Invalid public key");
|
|
67
86
|
}
|
|
68
|
-
if (phoneNumber.length
|
|
87
|
+
if (phoneNumber.length < 10) {
|
|
69
88
|
return /*#__PURE__*/React.createElement(Text, null, "Invalid phone number");
|
|
70
89
|
}
|
|
71
90
|
if (color.length < 3) {
|
|
@@ -119,4 +138,6 @@ const styles = StyleSheet.create({
|
|
|
119
138
|
left: 0
|
|
120
139
|
}
|
|
121
140
|
});
|
|
141
|
+
Omnipay.Registration = Registration;
|
|
142
|
+
export default Omnipay;
|
|
122
143
|
//# sourceMappingURL=OmnipayView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Fragment","useRef","useState","StyleSheet","View","Platform","ActivityIndicator","Text","Linking","WebView","getContact","
|
|
1
|
+
{"version":3,"names":["React","Fragment","useRef","useState","StyleSheet","View","Platform","ActivityIndicator","Text","Linking","WebView","clientSdkBaseUrl","serverSdkBaseUrl","getContact","Registration","Omnipay","color","env","publicKey","phoneNumber","view","onEnterFullScreen","onExitFullScreen","webviewRef","webviewStatus","setWebviewStatus","webHost","getWebHost","webUrl","getWebUrl","onWebviewMount","OS","themeColor","includes","split","postMessage","data","current","JSON","stringify","error","onWebviewMessage","e","nativeEvent","eventData","parse","dataKey","dataValue","contactDetails","openURL","length","styles","full","uri","webview","webviewLoader","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"sourceRoot":"../../src","sources":["OmnipayView.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzD,SACEC,UAAU,EACVC,IAAI,EACJC,QAAQ,EACRC,iBAAiB,EACjBC,IAAI,EACJC,OAAO,QACF,cAAc;AACrB,SAASC,OAAO,QAA6B,sBAAsB;AACnE,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,gBAAgB;AACnE,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,sBAAsB;AAkBnD,MAAMC,OAAO,GAAG,QAQiB;EAAA,IARhB;IACfC,KAAK;IACLC,GAAG;IACHC,SAAS;IACTC,WAAW;IACXC,IAAI;IACJC,iBAAiB;IACjBC;EACY,CAAC;EACb,MAAMC,UAAU,GAAGrB,MAAM,CAAU,IAAI,CAAC;EACxC,MAAM,CAACsB,aAAa,EAAEC,gBAAgB,CAAC,GAAGtB,QAAQ,CAAS,SAAS,CAAC;EACrE,MAAMuB,OAAO,GAAGC,UAAU,EAAE;EAC5B,MAAMC,MAAM,GAAGC,SAAS,EAAE;EAE1B,MAAMC,cAAc,GAAI;AAC1B,0BAA0BxB,QAAQ,CAACyB,EAAG;AACtC;AACA,KAAK;EAEH,SAASJ,UAAU,GAAG;IACpB;AACJ;AACA;AACA;IACI,IAAIP,IAAI,KAAK,OAAO,EAAE;MACpB,OAAOT,gBAAgB,CAACM,GAAG,CAAC;IAC9B;IACA,OAAOL,gBAAgB,CAACK,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,IAAII,IAAI,KAAK,OAAO,EAA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ACPK,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;AAEFrD,OAAO,CAACD,YAAY,GAAGA,YAAY;AACnC,eAAeC,OAAO"}
|
|
@@ -0,0 +1,126 @@
|
|
|
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 'src/lib/config';
|
|
5
|
+
export const Registration = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
color,
|
|
8
|
+
env,
|
|
9
|
+
publicKey,
|
|
10
|
+
phoneNumber,
|
|
11
|
+
onRegistrationSuccessful,
|
|
12
|
+
onClose
|
|
13
|
+
} = _ref;
|
|
14
|
+
const webviewRef = useRef(null);
|
|
15
|
+
const [webviewStatus, setWebviewStatus] = useState('loading');
|
|
16
|
+
const webHost = getWebHost();
|
|
17
|
+
const webUrl = getWebUrl();
|
|
18
|
+
const onWebviewMount = `
|
|
19
|
+
window.nativeOs = ${Platform.OS};
|
|
20
|
+
true;
|
|
21
|
+
`;
|
|
22
|
+
function getWebHost() {
|
|
23
|
+
return serverSdkBaseUrl[env];
|
|
24
|
+
}
|
|
25
|
+
function getWebUrl() {
|
|
26
|
+
const themeColor = color.includes('#') ? color.split('#')[1] : color;
|
|
27
|
+
return `${webHost}auth/register?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// function postMessage(data: PostMessage) {
|
|
31
|
+
// if (!webviewRef.current) {
|
|
32
|
+
// return;
|
|
33
|
+
// }
|
|
34
|
+
// try {
|
|
35
|
+
// webviewRef.current.postMessage(JSON.stringify(data));
|
|
36
|
+
// } catch (error) {}
|
|
37
|
+
// }
|
|
38
|
+
|
|
39
|
+
async function onWebviewMessage(e) {
|
|
40
|
+
try {
|
|
41
|
+
if (e.nativeEvent && e.nativeEvent.data) {
|
|
42
|
+
const eventData = JSON.parse(e.nativeEvent.data);
|
|
43
|
+
const {
|
|
44
|
+
dataKey,
|
|
45
|
+
dataValue
|
|
46
|
+
} = eventData;
|
|
47
|
+
const {
|
|
48
|
+
action,
|
|
49
|
+
details
|
|
50
|
+
} = JSON.parse(dataValue);
|
|
51
|
+
if (dataKey === 'customer.registered') {
|
|
52
|
+
if (onRegistrationSuccessful) {
|
|
53
|
+
onRegistrationSuccessful({
|
|
54
|
+
customerRef: details.customerRef,
|
|
55
|
+
walletId: details.walletId
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (action === 'close.registration') {
|
|
61
|
+
if (onClose) {
|
|
62
|
+
onClose();
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} catch (error) {}
|
|
68
|
+
}
|
|
69
|
+
if (!publicKey.includes('OMNIPUBKEY_')) {
|
|
70
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid public key");
|
|
71
|
+
}
|
|
72
|
+
if (phoneNumber.length < 10) {
|
|
73
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid phone number");
|
|
74
|
+
}
|
|
75
|
+
if (color.length < 3) {
|
|
76
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid color");
|
|
77
|
+
}
|
|
78
|
+
if (!['dev', 'prod'].includes(env)) {
|
|
79
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid environment");
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
82
|
+
style: styles.full
|
|
83
|
+
}, /*#__PURE__*/React.createElement(WebView, {
|
|
84
|
+
source: {
|
|
85
|
+
uri: webUrl
|
|
86
|
+
},
|
|
87
|
+
style: styles.webview,
|
|
88
|
+
injectedJavaScriptBeforeContentLoaded: onWebviewMount,
|
|
89
|
+
onMessage: onWebviewMessage,
|
|
90
|
+
ref: webviewRef,
|
|
91
|
+
onLoadEnd: () => setWebviewStatus('success')
|
|
92
|
+
}), webviewStatus === 'loading' && /*#__PURE__*/React.createElement(View, {
|
|
93
|
+
style: styles.webviewLoader
|
|
94
|
+
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
95
|
+
size: "small",
|
|
96
|
+
color: color
|
|
97
|
+
}))));
|
|
98
|
+
};
|
|
99
|
+
const styles = StyleSheet.create({
|
|
100
|
+
hide: {
|
|
101
|
+
display: 'none'
|
|
102
|
+
},
|
|
103
|
+
full: {
|
|
104
|
+
flex: 1,
|
|
105
|
+
width: '100%',
|
|
106
|
+
height: '100%'
|
|
107
|
+
},
|
|
108
|
+
webview: {
|
|
109
|
+
flex: 1,
|
|
110
|
+
width: '100%',
|
|
111
|
+
height: '100%'
|
|
112
|
+
},
|
|
113
|
+
webviewLoader: {
|
|
114
|
+
zIndex: 3,
|
|
115
|
+
backgroundColor: 'white',
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
justifyContent: 'center',
|
|
118
|
+
flex: 1,
|
|
119
|
+
width: '100%',
|
|
120
|
+
height: '100%',
|
|
121
|
+
position: 'absolute',
|
|
122
|
+
top: 0,
|
|
123
|
+
left: 0
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=Registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Fragment","useRef","useState","ActivityIndicator","Platform","StyleSheet","Text","View","WebView","serverSdkBaseUrl","Registration","color","env","publicKey","phoneNumber","onRegistrationSuccessful","onClose","webviewRef","webviewStatus","setWebviewStatus","webHost","getWebHost","webUrl","getWebUrl","onWebviewMount","OS","themeColor","includes","split","onWebviewMessage","e","nativeEvent","data","eventData","JSON","parse","dataKey","dataValue","action","details","customerRef","walletId","error","length","styles","full","uri","webview","webviewLoader","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"sourceRoot":"../../src","sources":["Registration.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,gBAAgB;AAyBjD,OAAO,MAAMC,YAAY,GAAG,QAOK;EAAA,IAPJ;IAC3BC,KAAK;IACLC,GAAG;IACHC,SAAS;IACTC,WAAW;IACXC,wBAAwB;IACxBC;EACY,CAAC;EACb,MAAMC,UAAU,GAAGhB,MAAM,CAAU,IAAI,CAAC;EACxC,MAAM,CAACiB,aAAa,EAAEC,gBAAgB,CAAC,GAAGjB,QAAQ,CAAS,SAAS,CAAC;EACrE,MAAMkB,OAAO,GAAGC,UAAU,EAAE;EAC5B,MAAMC,MAAM,GAAGC,SAAS,EAAE;EAE1B,MAAMC,cAAc,GAAI;AAC1B,4BAA4BpB,QAAQ,CAACqB,EAAG;AACxC;AACA,OAAO;EAEL,SAASJ,UAAU,GAAG;IACpB,OAAOZ,gBAAgB,CAACG,GAAG,CAAC;EAC9B;EAEA,SAASW,SAAS,GAAG;IACnB,MAAMG,UAAU,GAAGf,KAAK,CAACgB,QAAQ,CAAC,GAAG,CAAC,GAAGhB,KAAK,CAACiB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAGjB,KAAK;IACpE,OAAQ,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C;EAEA,oBACE,oBAAC,QAAQ,qBACP,oBAAC,IAAI;IAAC,KAAK,EAAEgC,MAAM,CAACC;EAAK,gBACvB,oBAAC,OAAO;IACN,MAAM,EAAE;MACNC,GAAG,EAAExB;IACP,CAAE;IACF,KAAK,EAAEsB,MAAM,CAACG,OAAQ;IACtB,qCAAqC,EAAEvB,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,EAAE0B,MAAM,CAACI;EAAc,gBAChC,oBAAC,iBAAiB;IAAC,IAAI,EAAC,OAAO;IAAC,KAAK,EAAErC;EAAM,EAAG,CAEnD,CACI,CACE;AAEf,CAAC;AAED,MAAMiC,MAAM,GAAGvC,UAAU,CAAC4C,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"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import Omnipay from './components/OmnipayView';
|
|
1
2
|
export { OmnipayProvider } from './components/OmnipayProvider';
|
|
2
3
|
export { useOmnipay } from './hooks/useOmnipay';
|
|
3
|
-
export
|
|
4
|
+
export default Omnipay;
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Omnipay","OmnipayProvider","useOmnipay"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,OAAOA,OAAO,MAAM,0BAA0B;AAE9C,SAASC,eAAe,QAAQ,8BAA8B;AAC9D,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,eAAeF,OAAO"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const colors = {
|
|
2
|
+
10: 'rgba(166, 130, 255, 0.1)',
|
|
3
|
+
20: 'rgba(166, 130, 255, 0.2)',
|
|
4
|
+
30: 'rgba(166, 130, 255, 0.3)',
|
|
5
|
+
40: 'rgba(166, 130, 255, 0.4)',
|
|
6
|
+
50: 'rgba(166, 130, 255, 0.10)',
|
|
7
|
+
100: '#F0E6FF',
|
|
8
|
+
200: '#DFCDFF',
|
|
9
|
+
300: '#CEB3FF',
|
|
10
|
+
400: '#BFA1FF',
|
|
11
|
+
500: '#A682FF',
|
|
12
|
+
600: '#a27dff',
|
|
13
|
+
700: '#5C41B7',
|
|
14
|
+
800: '#3E2993',
|
|
15
|
+
900: '#29187A',
|
|
16
|
+
1500: '#FF9900',
|
|
17
|
+
black: '#1E3565',
|
|
18
|
+
secondary: '#E06900',
|
|
19
|
+
light: 'rgb(83, 100, 113)',
|
|
20
|
+
iconColor: 'rgba(35, 47, 73, 0.6)',
|
|
21
|
+
bgColor: '#D7EEEB',
|
|
22
|
+
grey: '#61728F',
|
|
23
|
+
danger: '#E32828',
|
|
24
|
+
black500: '#1A1D1F',
|
|
25
|
+
black600: '#3E4554',
|
|
26
|
+
darkGrey: '#6F767E'
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["colors","black","secondary","light","iconColor","bgColor","grey","danger","black500","black600","darkGrey"],"sourceRoot":"../../src","sources":["colors.ts"],"mappings":"AAAA,OAAO,MAAMA,MAAM,GAAG;EACpB,EAAE,EAAE,0BAA0B;EAC9B,EAAE,EAAE,0BAA0B;EAC9B,EAAE,EAAE,0BAA0B;EAC9B,EAAE,EAAE,0BAA0B;EAC9B,EAAE,EAAE,2BAA2B;EAC/B,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,GAAG,EAAE,SAAS;EACd,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,SAAS;EAChBC,SAAS,EAAE,SAAS;EACpBC,KAAK,EAAE,mBAAmB;EAC1BC,SAAS,EAAE,uBAAuB;EAClCC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,SAAS;EACfC,MAAM,EAAE,SAAS;EACjBC,QAAQ,EAAE,SAAS;EACnBC,QAAQ,EAAE,SAAS;EACnBC,QAAQ,EAAE;AACZ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const serverSdkBaseUrl = {
|
|
2
|
+
dev: 'https://dev.omnipay-sdk.pages.dev/',
|
|
3
|
+
prod: 'https://omnipay-sdk.pages.dev/'
|
|
4
|
+
};
|
|
5
|
+
export const clientSdkBaseUrl = {
|
|
6
|
+
dev: 'https://omnipay-websdk.vercel.app/',
|
|
7
|
+
prod: 'https://sdk.omnipay.ng/'
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["serverSdkBaseUrl","dev","prod","clientSdkBaseUrl"],"sourceRoot":"../../src","sources":["config.ts"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAG;EAC9BC,GAAG,EAAE,oCAAoC;EACzCC,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG;EAC9BF,GAAG,EAAE,oCAAoC;EACzCC,IAAI,EAAE;AACR,CAAC"}
|
|
@@ -3,10 +3,23 @@ declare type OmnipayProps = {
|
|
|
3
3
|
env: 'dev' | 'prod';
|
|
4
4
|
publicKey: string;
|
|
5
5
|
phoneNumber: string;
|
|
6
|
-
view: 'bills';
|
|
6
|
+
view: 'bills' | 'registration';
|
|
7
7
|
onEnterFullScreen?: () => void;
|
|
8
8
|
onExitFullScreen?: () => void;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
declare const Omnipay: {
|
|
11
|
+
({ color, env, publicKey, phoneNumber, view, onEnterFullScreen, onExitFullScreen, }: OmnipayProps): JSX.Element;
|
|
12
|
+
Registration: ({ color, env, publicKey, phoneNumber, onRegistrationSuccessful, onClose, }: {
|
|
13
|
+
color: string;
|
|
14
|
+
env: "prod" | "dev";
|
|
15
|
+
publicKey: string;
|
|
16
|
+
phoneNumber: string;
|
|
17
|
+
onRegistrationSuccessful?: (({ customerRef, walletId, }: {
|
|
18
|
+
customerRef: string;
|
|
19
|
+
walletId: string;
|
|
20
|
+
}) => void) | undefined;
|
|
21
|
+
onClose?: (() => void) | undefined;
|
|
22
|
+
}) => JSX.Element;
|
|
23
|
+
};
|
|
24
|
+
export default Omnipay;
|
|
12
25
|
//# sourceMappingURL=OmnipayView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OmnipayView.d.ts","sourceRoot":"","sources":["../../../src/components/OmnipayView.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare type RegisterSuccessType = {
|
|
2
|
+
customerRef: string;
|
|
3
|
+
walletId: string;
|
|
4
|
+
};
|
|
5
|
+
declare type OmnipayProps = {
|
|
6
|
+
color: string;
|
|
7
|
+
env: 'dev' | 'prod';
|
|
8
|
+
publicKey: string;
|
|
9
|
+
phoneNumber: string;
|
|
10
|
+
onRegistrationSuccessful?: ({ customerRef, walletId, }: RegisterSuccessType) => void;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const Registration: ({ color, env, publicKey, phoneNumber, onRegistrationSuccessful, onClose, }: OmnipayProps) => JSX.Element;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=Registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Registration.d.ts","sourceRoot":"","sources":["../../../../src/components/views/Registration.tsx"],"names":[],"mappings":"AAWA,aAAK,mBAAmB,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,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,wBAAwB,CAAC,EAAE,CAAC,EAC1B,WAAW,EACX,QAAQ,GACT,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAQF,eAAO,MAAM,YAAY,+EAOtB,YAAY,KAAG,WA6FjB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import Omnipay from './components/OmnipayView';
|
|
1
2
|
export { OmnipayProvider } from './components/OmnipayProvider';
|
|
2
3
|
export { useOmnipay } from './hooks/useOmnipay';
|
|
3
|
-
export
|
|
4
|
+
export default Omnipay;
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const colors: {
|
|
2
|
+
10: string;
|
|
3
|
+
20: string;
|
|
4
|
+
30: string;
|
|
5
|
+
40: string;
|
|
6
|
+
50: string;
|
|
7
|
+
100: string;
|
|
8
|
+
200: string;
|
|
9
|
+
300: string;
|
|
10
|
+
400: string;
|
|
11
|
+
500: string;
|
|
12
|
+
600: string;
|
|
13
|
+
700: string;
|
|
14
|
+
800: string;
|
|
15
|
+
900: string;
|
|
16
|
+
1500: string;
|
|
17
|
+
black: string;
|
|
18
|
+
secondary: string;
|
|
19
|
+
light: string;
|
|
20
|
+
iconColor: string;
|
|
21
|
+
bgColor: string;
|
|
22
|
+
grey: string;
|
|
23
|
+
danger: string;
|
|
24
|
+
black500: string;
|
|
25
|
+
black600: string;
|
|
26
|
+
darkGrey: string;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/lib/colors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -288,7 +288,7 @@ export const OmnipayProvider = ({
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
const _initiateBills = ({ phoneNumber, onClose }: InitiateBillsType) => {
|
|
291
|
-
if (typeof phoneNumber === 'string' && phoneNumber.length
|
|
291
|
+
if (typeof phoneNumber === 'string' && phoneNumber.length >= 10) {
|
|
292
292
|
const webUrl = `${webHost}?theme=${color}&view=bills&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
293
293
|
setWebviewUrl(webUrl);
|
|
294
294
|
setIsVisible(true);
|
|
@@ -320,7 +320,7 @@ export const OmnipayProvider = ({
|
|
|
320
320
|
if (visibilityRef.current) {
|
|
321
321
|
return;
|
|
322
322
|
}
|
|
323
|
-
const isPhoneNumberValid = !!phoneNumber && phoneNumber.length
|
|
323
|
+
const isPhoneNumberValid = !!phoneNumber && phoneNumber.length >= 10;
|
|
324
324
|
const isValidCustomerRef = !!customerRef && !!customerRef.trim();
|
|
325
325
|
const isValidUserRef = !!userRef && !!userRef.trim();
|
|
326
326
|
const usesNativeShare = true;
|
|
@@ -8,14 +8,16 @@ import {
|
|
|
8
8
|
Linking,
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import { WebView, WebViewMessageEvent } from 'react-native-webview';
|
|
11
|
-
import {
|
|
11
|
+
import { clientSdkBaseUrl, serverSdkBaseUrl } from 'src/lib/config';
|
|
12
|
+
import { getContact } from '../functions';
|
|
13
|
+
import { Registration } from './views/Registration';
|
|
12
14
|
|
|
13
15
|
type OmnipayProps = {
|
|
14
16
|
color: string;
|
|
15
17
|
env: 'dev' | 'prod';
|
|
16
18
|
publicKey: string;
|
|
17
19
|
phoneNumber: string;
|
|
18
|
-
view: 'bills';
|
|
20
|
+
view: 'bills' | 'registration';
|
|
19
21
|
onEnterFullScreen?: () => void;
|
|
20
22
|
onExitFullScreen?: () => void;
|
|
21
23
|
};
|
|
@@ -26,7 +28,7 @@ type PostMessage = {
|
|
|
26
28
|
|
|
27
29
|
type Status = 'error' | 'loading' | 'success';
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
const Omnipay = ({
|
|
30
32
|
color,
|
|
31
33
|
env,
|
|
32
34
|
publicKey,
|
|
@@ -37,14 +39,33 @@ export const Omnipay = ({
|
|
|
37
39
|
}: OmnipayProps): JSX.Element => {
|
|
38
40
|
const webviewRef = useRef<WebView>(null);
|
|
39
41
|
const [webviewStatus, setWebviewStatus] = useState<Status>('loading');
|
|
40
|
-
const webHost = getWebHost(
|
|
41
|
-
const webUrl =
|
|
42
|
+
const webHost = getWebHost();
|
|
43
|
+
const webUrl = getWebUrl();
|
|
42
44
|
|
|
43
45
|
const onWebviewMount = `
|
|
44
46
|
window.nativeOs = ${Platform.OS};
|
|
45
47
|
true;
|
|
46
48
|
`;
|
|
47
49
|
|
|
50
|
+
function getWebHost() {
|
|
51
|
+
/**
|
|
52
|
+
* use client rendered app url for bills sdk,
|
|
53
|
+
* else use server rendered app url
|
|
54
|
+
*/
|
|
55
|
+
if (view === 'bills') {
|
|
56
|
+
return clientSdkBaseUrl[env];
|
|
57
|
+
}
|
|
58
|
+
return serverSdkBaseUrl[env];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getWebUrl() {
|
|
62
|
+
const themeColor = color.includes('#') ? color.split('#')[1] : color;
|
|
63
|
+
if (view === 'bills') {
|
|
64
|
+
return `${webHost}?theme=${themeColor}&view=${view}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
65
|
+
}
|
|
66
|
+
return `${webHost}auth/register?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
48
69
|
function postMessage(data: PostMessage) {
|
|
49
70
|
if (!webviewRef.current) {
|
|
50
71
|
return;
|
|
@@ -83,7 +104,7 @@ export const Omnipay = ({
|
|
|
83
104
|
} catch (error) {}
|
|
84
105
|
}
|
|
85
106
|
|
|
86
|
-
if (view !== 'bills') {
|
|
107
|
+
if (view !== 'bills' && view !== 'registration') {
|
|
87
108
|
return <Text>Invalid view</Text>;
|
|
88
109
|
}
|
|
89
110
|
|
|
@@ -91,7 +112,7 @@ export const Omnipay = ({
|
|
|
91
112
|
return <Text>Invalid public key</Text>;
|
|
92
113
|
}
|
|
93
114
|
|
|
94
|
-
if (phoneNumber.length
|
|
115
|
+
if (phoneNumber.length < 10) {
|
|
95
116
|
return <Text>Invalid phone number</Text>;
|
|
96
117
|
}
|
|
97
118
|
|
|
@@ -153,3 +174,6 @@ const styles = StyleSheet.create({
|
|
|
153
174
|
left: 0,
|
|
154
175
|
},
|
|
155
176
|
});
|
|
177
|
+
|
|
178
|
+
Omnipay.Registration = Registration;
|
|
179
|
+
export default Omnipay;
|