omnipay-reactnative-sdk 0.2.3 → 0.2.4
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/lib/commonjs/components/OmnipayProvider.js +191 -0
- package/lib/commonjs/components/OmnipayProvider.js.map +1 -0
- package/lib/commonjs/components/OmnipayView.js +186 -0
- package/lib/commonjs/components/OmnipayView.js.map +1 -0
- package/lib/commonjs/hooks/useOmnipay.js +18 -0
- package/lib/commonjs/hooks/useOmnipay.js.map +1 -0
- package/lib/commonjs/index.js +12 -177
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/OmnipayProvider.js +180 -0
- package/lib/module/components/OmnipayProvider.js.map +1 -0
- package/lib/module/components/OmnipayView.js +177 -0
- package/lib/module/components/OmnipayView.js.map +1 -0
- package/lib/module/hooks/useOmnipay.js +12 -0
- package/lib/module/hooks/useOmnipay.js.map +1 -0
- package/lib/module/index.js +4 -176
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/OmnipayProvider.d.ts +14 -0
- package/lib/typescript/components/OmnipayProvider.d.ts.map +1 -0
- package/lib/typescript/components/OmnipayView.d.ts +12 -0
- package/lib/typescript/components/OmnipayView.d.ts.map +1 -0
- package/lib/typescript/hooks/useOmnipay.d.ts +4 -0
- package/lib/typescript/hooks/useOmnipay.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +4 -11
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/OmnipayProvider.tsx +193 -0
- package/src/components/OmnipayView.tsx +204 -0
- package/src/hooks/useOmnipay.tsx +9 -0
- package/src/index.tsx +4 -203
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { ActivityIndicator, Linking, PermissionsAndroid, Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import WebView from 'react-native-webview';
|
|
4
|
+
import { selectContactPhone } from 'react-native-select-contact';
|
|
5
|
+
export const OmnipayContext = /*#__PURE__*/React.createContext(null);
|
|
6
|
+
export const OmnipayProvider = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
publicKey,
|
|
10
|
+
env,
|
|
11
|
+
color
|
|
12
|
+
} = _ref;
|
|
13
|
+
const [webviewUrl, setWebviewUrl] = useState("");
|
|
14
|
+
const [webviewStatus, setWebviewStatus] = useState('loading');
|
|
15
|
+
const [useFullscreen, setUseFullScreen] = useState(false);
|
|
16
|
+
const webviewRef = useRef(null);
|
|
17
|
+
const webHost = getWebHost();
|
|
18
|
+
const webviewStyle = getWebviewStyle();
|
|
19
|
+
console.log(useFullscreen);
|
|
20
|
+
function getWebviewStyle() {
|
|
21
|
+
if (webviewUrl === "") {
|
|
22
|
+
return {
|
|
23
|
+
opacity: 0,
|
|
24
|
+
height: 0,
|
|
25
|
+
width: 0,
|
|
26
|
+
flex: 0
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return styles.webview;
|
|
30
|
+
}
|
|
31
|
+
function getWebHost() {
|
|
32
|
+
if (env === 'dev') {
|
|
33
|
+
return 'https://omnipay-websdk.vercel.app/';
|
|
34
|
+
}
|
|
35
|
+
return 'https://sdk.omnipay.ng/';
|
|
36
|
+
}
|
|
37
|
+
const onWebviewMount = `
|
|
38
|
+
window.nativeOs = ${Platform.OS};
|
|
39
|
+
true;
|
|
40
|
+
`;
|
|
41
|
+
function postMessage(data) {
|
|
42
|
+
if (!webviewRef.current) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
webviewRef.current.postMessage(JSON.stringify(data));
|
|
47
|
+
} catch (error) {}
|
|
48
|
+
}
|
|
49
|
+
async function onWebviewMessage(e) {
|
|
50
|
+
try {
|
|
51
|
+
if (e.nativeEvent && e.nativeEvent.data) {
|
|
52
|
+
const eventData = JSON.parse(e.nativeEvent.data);
|
|
53
|
+
const {
|
|
54
|
+
dataKey,
|
|
55
|
+
dataValue
|
|
56
|
+
} = eventData;
|
|
57
|
+
if (dataKey === 'chooseContact') {
|
|
58
|
+
const contactDetails = await getContact();
|
|
59
|
+
postMessage({
|
|
60
|
+
dataKey: 'contactSelected',
|
|
61
|
+
dataValue: contactDetails
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (dataKey === 'openLink') {
|
|
65
|
+
Linking.openURL(dataValue);
|
|
66
|
+
}
|
|
67
|
+
if (dataKey === 'modalOpen') {
|
|
68
|
+
setUseFullScreen(true);
|
|
69
|
+
}
|
|
70
|
+
if (dataKey === 'modalClosed') {
|
|
71
|
+
setUseFullScreen(false);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {}
|
|
75
|
+
}
|
|
76
|
+
async function getContact() {
|
|
77
|
+
try {
|
|
78
|
+
const isPermissionGranted = await checkPermisionStatus();
|
|
79
|
+
if (!isPermissionGranted) {
|
|
80
|
+
return {
|
|
81
|
+
name: '',
|
|
82
|
+
phoneNumber: ''
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const result = await selectContactPhone();
|
|
86
|
+
if (!result) {
|
|
87
|
+
return {
|
|
88
|
+
name: '',
|
|
89
|
+
phoneNumber: ''
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
let {
|
|
93
|
+
contact,
|
|
94
|
+
selectedPhone
|
|
95
|
+
} = result;
|
|
96
|
+
return {
|
|
97
|
+
name: contact.name,
|
|
98
|
+
phoneNumber: selectedPhone.number
|
|
99
|
+
};
|
|
100
|
+
} catch (error) {
|
|
101
|
+
return {
|
|
102
|
+
name: '',
|
|
103
|
+
phoneNumber: ''
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function checkPermisionStatus() {
|
|
108
|
+
if (Platform.OS === 'ios') {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
if (PermissionsAndroid.PERMISSIONS.READ_CONTACTS) {
|
|
112
|
+
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_CONTACTS, {
|
|
113
|
+
title: 'Allow us access your contact list',
|
|
114
|
+
message: 'This will enable you choose a phone number to buy airtime or data for from your contact list',
|
|
115
|
+
buttonNegative: 'Cancel',
|
|
116
|
+
buttonPositive: 'OK'
|
|
117
|
+
});
|
|
118
|
+
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
const _initiateBills = useCallback(phoneNumber => {
|
|
125
|
+
if (phoneNumber) {
|
|
126
|
+
if (phoneNumber.length === 11) {
|
|
127
|
+
const webUrl = `${webHost}?theme=${color}&view=bills&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
128
|
+
setWebviewUrl(webUrl);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}, []);
|
|
132
|
+
return /*#__PURE__*/React.createElement(OmnipayContext.Provider, {
|
|
133
|
+
value: {
|
|
134
|
+
initiateBills: _initiateBills
|
|
135
|
+
}
|
|
136
|
+
}, children, /*#__PURE__*/React.createElement(WebView, {
|
|
137
|
+
source: {
|
|
138
|
+
uri: webviewUrl
|
|
139
|
+
},
|
|
140
|
+
style: webviewStyle,
|
|
141
|
+
injectedJavaScriptBeforeContentLoaded: onWebviewMount,
|
|
142
|
+
onMessage: onWebviewMessage,
|
|
143
|
+
ref: webviewRef,
|
|
144
|
+
onLoadStart: () => setWebviewStatus("loading"),
|
|
145
|
+
onLoadEnd: () => setWebviewStatus('success')
|
|
146
|
+
}), webviewStatus === 'loading' && webviewUrl !== "" && /*#__PURE__*/React.createElement(View, {
|
|
147
|
+
style: styles.webviewLoader
|
|
148
|
+
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
149
|
+
size: "small",
|
|
150
|
+
color: color
|
|
151
|
+
})));
|
|
152
|
+
};
|
|
153
|
+
const styles = StyleSheet.create({
|
|
154
|
+
hide: {
|
|
155
|
+
display: 'none'
|
|
156
|
+
},
|
|
157
|
+
full: {
|
|
158
|
+
flex: 1,
|
|
159
|
+
width: '100%',
|
|
160
|
+
height: '100%'
|
|
161
|
+
},
|
|
162
|
+
webview: {
|
|
163
|
+
flex: 1,
|
|
164
|
+
width: '100%',
|
|
165
|
+
height: '100%'
|
|
166
|
+
},
|
|
167
|
+
webviewLoader: {
|
|
168
|
+
zIndex: 3,
|
|
169
|
+
backgroundColor: 'white',
|
|
170
|
+
alignItems: 'center',
|
|
171
|
+
justifyContent: 'center',
|
|
172
|
+
flex: 1,
|
|
173
|
+
width: '100%',
|
|
174
|
+
height: '100%',
|
|
175
|
+
position: 'absolute',
|
|
176
|
+
top: 0,
|
|
177
|
+
left: 0
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=OmnipayProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useRef","useState","ActivityIndicator","Linking","PermissionsAndroid","Platform","StyleSheet","View","WebView","selectContactPhone","OmnipayContext","createContext","OmnipayProvider","children","publicKey","env","color","webviewUrl","setWebviewUrl","webviewStatus","setWebviewStatus","useFullscreen","setUseFullScreen","webviewRef","webHost","getWebHost","webviewStyle","getWebviewStyle","console","log","opacity","height","width","flex","styles","webview","onWebviewMount","OS","postMessage","data","current","JSON","stringify","error","onWebviewMessage","e","nativeEvent","eventData","parse","dataKey","dataValue","contactDetails","getContact","openURL","isPermissionGranted","checkPermisionStatus","name","phoneNumber","result","contact","selectedPhone","number","PERMISSIONS","READ_CONTACTS","granted","request","title","message","buttonNegative","buttonPositive","RESULTS","GRANTED","_initiateBills","length","webUrl","initiateBills","uri","webviewLoader","create","hide","display","full","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"sourceRoot":"../../src","sources":["OmnipayProvider.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,SAASC,iBAAiB,E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J,MAAM,EAAE;MACJ+D,GAAG,EAAE3D;IACT,CAAE;IACF,KAAK,EAAES,YAAa;IACpB,qCAAqC,EAAEU,cAAe;IACtD,SAAS,EAAEQ,gBAAiB;IAC5B,GAAG,EAAErB,UAAW;IAChB,WAAW,EAAE,MAAMH,gBAAgB,CAAC,SAAS,CAAE;IAC/C,SAAS,EAAE,MAAMA,gBAAgB,CAAC,SAAS;EAAE,EAC/C,EACDD,aAAa,KAAK,SAAS,IAAIF,UAAU,KAAK,EAAE,iBAC7C,oBAAC,IAAI;IAAC,KAAK,EAAEiB,MAAM,CAAC2C;EAAc,gBAC9B,oBAAC,iBAAiB;IAAC,IAAI,EAAC,OAAO;IAAC,KAAK,EAAE7D;EAAM,EAAG,CAEvD,CACqB;AAElC,CAAC;AAED,MAAMkB,MAAM,GAAG5B,UAAU,CAACwE,MAAM,CAAC;EAC7BC,IAAI,EAAE;IACFC,OAAO,EAAE;EACb,CAAC;EACDC,IAAI,EAAE;IACFhD,IAAI,EAAE,CAAC;IACPD,KAAK,EAAE,MAAM;IACbD,MAAM,EAAE;EACZ,CAAC;EACDI,OAAO,EAAE;IACLF,IAAI,EAAE,CAAC;IACPD,KAAK,EAAE,MAAM;IACbD,MAAM,EAAE;EACZ,CAAC;EACD8C,aAAa,EAAE;IACXK,MAAM,EAAE,CAAC;IACTC,eAAe,EAAE,OAAO;IACxBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBpD,IAAI,EAAE,CAAC;IACPD,KAAK,EAAE,MAAM;IACbD,MAAM,EAAE,MAAM;IACduD,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE;EACV;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import React, { Fragment, useRef, useState } from 'react';
|
|
2
|
+
import { StyleSheet, View, Platform, PermissionsAndroid, ActivityIndicator, Text, Linking } from 'react-native';
|
|
3
|
+
import { WebView } from 'react-native-webview';
|
|
4
|
+
import { selectContactPhone } from 'react-native-select-contact';
|
|
5
|
+
const OmnipayView = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
color,
|
|
8
|
+
env,
|
|
9
|
+
publicKey,
|
|
10
|
+
phoneNumber,
|
|
11
|
+
view,
|
|
12
|
+
onEnterFullScreen,
|
|
13
|
+
onExitFullScreen
|
|
14
|
+
} = _ref;
|
|
15
|
+
const webviewRef = useRef(null);
|
|
16
|
+
const [webviewStatus, setWebviewStatus] = useState('loading');
|
|
17
|
+
const webHost = getWebHost();
|
|
18
|
+
const webUrl = `${webHost}?theme=${color}&view=${view}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
19
|
+
function getWebHost() {
|
|
20
|
+
if (env === 'dev') {
|
|
21
|
+
return 'https://omnipay-websdk.vercel.app/';
|
|
22
|
+
}
|
|
23
|
+
return 'https://sdk.omnipay.ng/';
|
|
24
|
+
}
|
|
25
|
+
const onWebviewMount = `
|
|
26
|
+
window.nativeOs = ${Platform.OS};
|
|
27
|
+
true;
|
|
28
|
+
`;
|
|
29
|
+
function postMessage(data) {
|
|
30
|
+
if (!webviewRef.current) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
webviewRef.current.postMessage(JSON.stringify(data));
|
|
35
|
+
} catch (error) {}
|
|
36
|
+
}
|
|
37
|
+
async function onWebviewMessage(e) {
|
|
38
|
+
try {
|
|
39
|
+
if (e.nativeEvent && e.nativeEvent.data) {
|
|
40
|
+
const eventData = JSON.parse(e.nativeEvent.data);
|
|
41
|
+
const {
|
|
42
|
+
dataKey,
|
|
43
|
+
dataValue
|
|
44
|
+
} = eventData;
|
|
45
|
+
if (dataKey === 'chooseContact') {
|
|
46
|
+
const contactDetails = await getContact();
|
|
47
|
+
postMessage({
|
|
48
|
+
dataKey: 'contactSelected',
|
|
49
|
+
dataValue: contactDetails
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (dataKey === 'modalOpen') {
|
|
53
|
+
if (onEnterFullScreen) {
|
|
54
|
+
onEnterFullScreen();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (dataKey === 'modalClosed') {
|
|
58
|
+
if (onExitFullScreen) {
|
|
59
|
+
onExitFullScreen();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (dataKey === 'openLink') {
|
|
63
|
+
Linking.openURL(dataValue);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {}
|
|
67
|
+
}
|
|
68
|
+
async function getContact() {
|
|
69
|
+
try {
|
|
70
|
+
const isPermissionGranted = await checkPermisionStatus();
|
|
71
|
+
if (!isPermissionGranted) {
|
|
72
|
+
return {
|
|
73
|
+
name: '',
|
|
74
|
+
phoneNumber: ''
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const result = await selectContactPhone();
|
|
78
|
+
if (!result) {
|
|
79
|
+
return {
|
|
80
|
+
name: '',
|
|
81
|
+
phoneNumber: ''
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
let {
|
|
85
|
+
contact,
|
|
86
|
+
selectedPhone
|
|
87
|
+
} = result;
|
|
88
|
+
return {
|
|
89
|
+
name: contact.name,
|
|
90
|
+
phoneNumber: selectedPhone.number
|
|
91
|
+
};
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
name: '',
|
|
95
|
+
phoneNumber: ''
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function checkPermisionStatus() {
|
|
100
|
+
if (Platform.OS === 'ios') {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
if (PermissionsAndroid.PERMISSIONS.READ_CONTACTS) {
|
|
104
|
+
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_CONTACTS, {
|
|
105
|
+
title: 'Allow us access your contact list',
|
|
106
|
+
message: 'This will enable you choose a phone number to buy airtime or data for from your contact list',
|
|
107
|
+
buttonNegative: 'Cancel',
|
|
108
|
+
buttonPositive: 'OK'
|
|
109
|
+
});
|
|
110
|
+
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (view !== 'bills') {
|
|
117
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid view");
|
|
118
|
+
}
|
|
119
|
+
if (!publicKey.includes('OMNIPUBKEY_')) {
|
|
120
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid public key");
|
|
121
|
+
}
|
|
122
|
+
if (phoneNumber.length !== 11) {
|
|
123
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid phone number");
|
|
124
|
+
}
|
|
125
|
+
if (color.length < 3) {
|
|
126
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid color");
|
|
127
|
+
}
|
|
128
|
+
if (!['dev', 'prod'].includes(env)) {
|
|
129
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid environment");
|
|
130
|
+
}
|
|
131
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
132
|
+
style: styles.full
|
|
133
|
+
}, /*#__PURE__*/React.createElement(WebView, {
|
|
134
|
+
source: {
|
|
135
|
+
uri: webUrl
|
|
136
|
+
},
|
|
137
|
+
style: styles.webview,
|
|
138
|
+
injectedJavaScriptBeforeContentLoaded: onWebviewMount,
|
|
139
|
+
onMessage: onWebviewMessage,
|
|
140
|
+
ref: webviewRef,
|
|
141
|
+
onLoadEnd: () => setWebviewStatus('success')
|
|
142
|
+
}), webviewStatus === 'loading' && /*#__PURE__*/React.createElement(View, {
|
|
143
|
+
style: styles.webviewLoader
|
|
144
|
+
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
145
|
+
size: "small",
|
|
146
|
+
color: color
|
|
147
|
+
}))));
|
|
148
|
+
};
|
|
149
|
+
const styles = StyleSheet.create({
|
|
150
|
+
hide: {
|
|
151
|
+
display: 'none'
|
|
152
|
+
},
|
|
153
|
+
full: {
|
|
154
|
+
flex: 1,
|
|
155
|
+
width: '100%',
|
|
156
|
+
height: '100%'
|
|
157
|
+
},
|
|
158
|
+
webview: {
|
|
159
|
+
flex: 1,
|
|
160
|
+
width: '100%',
|
|
161
|
+
height: '100%'
|
|
162
|
+
},
|
|
163
|
+
webviewLoader: {
|
|
164
|
+
zIndex: 3,
|
|
165
|
+
backgroundColor: 'white',
|
|
166
|
+
alignItems: 'center',
|
|
167
|
+
justifyContent: 'center',
|
|
168
|
+
flex: 1,
|
|
169
|
+
width: '100%',
|
|
170
|
+
height: '100%',
|
|
171
|
+
position: 'absolute',
|
|
172
|
+
top: 0,
|
|
173
|
+
left: 0
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
export default OmnipayView;
|
|
177
|
+
//# sourceMappingURL=OmnipayView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Fragment","useRef","useState","StyleSheet","View","Platform","PermissionsAndroid","ActivityIndicator","Text","Linking","WebView","selectContactPhone","OmnipayView","color","env","publicKey","phoneNumber","view","onEnterFullScreen","onExitFullScreen","webviewRef","webviewStatus","setWebviewStatus","webHost","getWebHost","webUrl","onWebviewMount","OS","postMessage","data","current","JSON","stringify","error","onWebviewMessage","e","nativeEvent","eventData","parse","dataKey","dataValue","contactDetails","getContact","openURL","isPermissionGranted","checkPermisionStatus","name","result","contact","selectedPhone","number","PERMISSIONS","READ_CONTACTS","granted","request","title","message","buttonNegative","buttonPositive","RESULTS","GRANTED","includes","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,SACIC,UAAU,EACVC,IAAI,EACJ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AME,gBAAgB,CAAC,SAAS;EAAE,EAC/C,EACDD,aAAa,KAAK,SAAS,iBACxB,oBAAC,IAAI;IAAC,KAAK,EAAE0C,MAAM,CAACI;EAAc,gBAC9B,oBAAC,iBAAiB;IAAC,IAAI,EAAC,OAAO;IAAC,KAAK,EAAEtD;EAAM,EAAG,CAEvD,CACE,CACA;AAEnB,CAAC;AAED,MAAMkD,MAAM,GAAG5D,UAAU,CAACiE,MAAM,CAAC;EAC7BC,IAAI,EAAE;IACFC,OAAO,EAAE;EACb,CAAC;EACDN,IAAI,EAAE;IACFO,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACZ,CAAC;EACDP,OAAO,EAAE;IACLK,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACZ,CAAC;EACDN,aAAa,EAAE;IACXO,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;EACV;AACJ,CAAC,CAAC;AAEF,eAAepE,WAAW"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { OmnipayContext } from 'src/components/OmnipayProvider';
|
|
3
|
+
export function useOmnipay() {
|
|
4
|
+
const {
|
|
5
|
+
initiateBills
|
|
6
|
+
} = useContext(OmnipayContext);
|
|
7
|
+
return {
|
|
8
|
+
initiateBills: initiateBills
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
;
|
|
12
|
+
//# sourceMappingURL=useOmnipay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContext","OmnipayContext","useOmnipay","initiateBills"],"sourceRoot":"../../src","sources":["useOmnipay.tsx"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,cAAc,QAA4B,gCAAgC;AAEnF,OAAO,SAASC,UAAU,GAAG;EACzB,MAAM;IAAEC;EAAc,CAAC,GAAGH,UAAU,CAACC,cAAc,CAAuB;EAC1E,OAAO;IACHE,aAAa,EAAEA;EACnB,CAAC;AACL;AAAC"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,177 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Omnipay = _ref => {
|
|
6
|
-
let {
|
|
7
|
-
color,
|
|
8
|
-
env,
|
|
9
|
-
publicKey,
|
|
10
|
-
phoneNumber,
|
|
11
|
-
view,
|
|
12
|
-
onEnterFullScreen,
|
|
13
|
-
onExitFullScreen
|
|
14
|
-
} = _ref;
|
|
15
|
-
const webviewRef = useRef(null);
|
|
16
|
-
const [webviewStatus, setWebviewStatus] = useState('loading');
|
|
17
|
-
const webHost = getWebHost();
|
|
18
|
-
const webUrl = `${webHost}?theme=${color}&view=${view}&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
|
|
19
|
-
function getWebHost() {
|
|
20
|
-
if (env === 'dev') {
|
|
21
|
-
return 'https://omnipay-websdk.vercel.app/';
|
|
22
|
-
}
|
|
23
|
-
return 'https://sdk.omnipay.ng/';
|
|
24
|
-
}
|
|
25
|
-
const onWebviewMount = `
|
|
26
|
-
window.nativeOs = ${Platform.OS};
|
|
27
|
-
true;
|
|
28
|
-
`;
|
|
29
|
-
function postMessage(data) {
|
|
30
|
-
if (!webviewRef.current) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
webviewRef.current.postMessage(JSON.stringify(data));
|
|
35
|
-
} catch (error) {}
|
|
36
|
-
}
|
|
37
|
-
async function onWebviewMessage(e) {
|
|
38
|
-
try {
|
|
39
|
-
if (e.nativeEvent && e.nativeEvent.data) {
|
|
40
|
-
const eventData = JSON.parse(e.nativeEvent.data);
|
|
41
|
-
const {
|
|
42
|
-
dataKey,
|
|
43
|
-
dataValue
|
|
44
|
-
} = eventData;
|
|
45
|
-
if (dataKey === 'chooseContact') {
|
|
46
|
-
const contactDetails = await getContact();
|
|
47
|
-
postMessage({
|
|
48
|
-
dataKey: 'contactSelected',
|
|
49
|
-
dataValue: contactDetails
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (dataKey === 'modalOpen') {
|
|
53
|
-
if (onEnterFullScreen) {
|
|
54
|
-
onEnterFullScreen();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (dataKey === 'modalClosed') {
|
|
58
|
-
if (onExitFullScreen) {
|
|
59
|
-
onExitFullScreen();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (dataKey === 'openLink') {
|
|
63
|
-
Linking.openURL(dataValue);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
} catch (error) {}
|
|
67
|
-
}
|
|
68
|
-
async function getContact() {
|
|
69
|
-
try {
|
|
70
|
-
const isPermissionGranted = await checkPermisionStatus();
|
|
71
|
-
if (!isPermissionGranted) {
|
|
72
|
-
return {
|
|
73
|
-
name: '',
|
|
74
|
-
phoneNumber: ''
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
const result = await selectContactPhone();
|
|
78
|
-
if (!result) {
|
|
79
|
-
return {
|
|
80
|
-
name: '',
|
|
81
|
-
phoneNumber: ''
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
let {
|
|
85
|
-
contact,
|
|
86
|
-
selectedPhone
|
|
87
|
-
} = result;
|
|
88
|
-
return {
|
|
89
|
-
name: contact.name,
|
|
90
|
-
phoneNumber: selectedPhone.number
|
|
91
|
-
};
|
|
92
|
-
} catch (error) {
|
|
93
|
-
return {
|
|
94
|
-
name: '',
|
|
95
|
-
phoneNumber: ''
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async function checkPermisionStatus() {
|
|
100
|
-
if (Platform.OS === 'ios') {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
if (PermissionsAndroid.PERMISSIONS.READ_CONTACTS) {
|
|
104
|
-
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_CONTACTS, {
|
|
105
|
-
title: 'Allow us access your contact list',
|
|
106
|
-
message: 'This will enable you choose a phone number to buy airtime or data for from your contact list',
|
|
107
|
-
buttonNegative: 'Cancel',
|
|
108
|
-
buttonPositive: 'OK'
|
|
109
|
-
});
|
|
110
|
-
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
if (view !== 'bills') {
|
|
117
|
-
return /*#__PURE__*/React.createElement(Text, null, "Invalid view");
|
|
118
|
-
}
|
|
119
|
-
if (!publicKey.includes('OMNIPUBKEY_')) {
|
|
120
|
-
return /*#__PURE__*/React.createElement(Text, null, "Invalid public key");
|
|
121
|
-
}
|
|
122
|
-
if (phoneNumber.length !== 11) {
|
|
123
|
-
return /*#__PURE__*/React.createElement(Text, null, "Invalid phone number");
|
|
124
|
-
}
|
|
125
|
-
if (color.length < 3) {
|
|
126
|
-
return /*#__PURE__*/React.createElement(Text, null, "Invalid color");
|
|
127
|
-
}
|
|
128
|
-
if (!['dev', 'prod'].includes(env)) {
|
|
129
|
-
return /*#__PURE__*/React.createElement(Text, null, "Invalid environment");
|
|
130
|
-
}
|
|
131
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
132
|
-
style: styles.full
|
|
133
|
-
}, /*#__PURE__*/React.createElement(WebView, {
|
|
134
|
-
source: {
|
|
135
|
-
uri: webUrl
|
|
136
|
-
},
|
|
137
|
-
style: styles.webview,
|
|
138
|
-
injectedJavaScriptBeforeContentLoaded: onWebviewMount,
|
|
139
|
-
onMessage: onWebviewMessage,
|
|
140
|
-
ref: webviewRef,
|
|
141
|
-
onLoadEnd: () => setWebviewStatus('success')
|
|
142
|
-
}), webviewStatus === 'loading' && /*#__PURE__*/React.createElement(View, {
|
|
143
|
-
style: styles.webviewLoader
|
|
144
|
-
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
145
|
-
size: "small",
|
|
146
|
-
color: color
|
|
147
|
-
}))));
|
|
148
|
-
};
|
|
149
|
-
const styles = StyleSheet.create({
|
|
150
|
-
hide: {
|
|
151
|
-
display: 'none'
|
|
152
|
-
},
|
|
153
|
-
full: {
|
|
154
|
-
flex: 1,
|
|
155
|
-
width: '100%',
|
|
156
|
-
height: '100%'
|
|
157
|
-
},
|
|
158
|
-
webview: {
|
|
159
|
-
flex: 1,
|
|
160
|
-
width: '100%',
|
|
161
|
-
height: '100%'
|
|
162
|
-
},
|
|
163
|
-
webviewLoader: {
|
|
164
|
-
zIndex: 3,
|
|
165
|
-
backgroundColor: 'white',
|
|
166
|
-
alignItems: 'center',
|
|
167
|
-
justifyContent: 'center',
|
|
168
|
-
flex: 1,
|
|
169
|
-
width: '100%',
|
|
170
|
-
height: '100%',
|
|
171
|
-
position: 'absolute',
|
|
172
|
-
top: 0,
|
|
173
|
-
left: 0
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
export default Omnipay;
|
|
1
|
+
import { OmnipayProvider } from "./components/OmnipayProvider";
|
|
2
|
+
import OmnipayView from "./components/OmnipayView";
|
|
3
|
+
export { OmnipayProvider };
|
|
4
|
+
export { OmnipayView };
|
|
177
5
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["OmnipayProvider","OmnipayView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,eAAe,QAAQ,8BAA8B;AAC9D,OAAOC,WAAW,MAAM,0BAA0B;AAElD,SAASD,eAAe;AACxB,SAASC,WAAW"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type OmnipayProviderProps = {
|
|
3
|
+
publicKey: string;
|
|
4
|
+
env: 'dev' | 'prod';
|
|
5
|
+
color: string;
|
|
6
|
+
children: React.ReactElement | React.ReactElement[];
|
|
7
|
+
};
|
|
8
|
+
export declare type OmnipayContextType = {
|
|
9
|
+
initiateBills: (color: string, phoneNumber: string) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const OmnipayContext: React.Context<OmnipayContextType | null>;
|
|
12
|
+
export declare const OmnipayProvider: ({ children, publicKey, env, color }: OmnipayProviderProps) => JSX.Element;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=OmnipayProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OmnipayProvider.d.ts","sourceRoot":"","sources":["../../../src/components/OmnipayProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAK7D,aAAK,oBAAoB,GAAG;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,KAAK,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,EAAE,CAAA;CACtD,CAAA;AAQD,oBAAY,kBAAkB,GAAG;IAC7B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D,CAAA;AAED,eAAO,MAAM,cAAc,0CAAuD,CAAC;AAEnF,eAAO,MAAM,eAAe,wCAAyC,oBAAoB,gBA4IxF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare type OmnipayProps = {
|
|
2
|
+
color: string;
|
|
3
|
+
env: 'dev' | 'prod';
|
|
4
|
+
publicKey: string;
|
|
5
|
+
phoneNumber: string;
|
|
6
|
+
view: 'bills';
|
|
7
|
+
onEnterFullScreen?: () => void;
|
|
8
|
+
onExitFullScreen?: () => void;
|
|
9
|
+
};
|
|
10
|
+
declare const OmnipayView: ({ color, env, publicKey, phoneNumber, view, onEnterFullScreen, onExitFullScreen, }: OmnipayProps) => JSX.Element;
|
|
11
|
+
export default OmnipayView;
|
|
12
|
+
//# sourceMappingURL=OmnipayView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OmnipayView.d.ts","sourceRoot":"","sources":["../../../src/components/OmnipayView.tsx"],"names":[],"mappings":"AAaA,aAAK,YAAY,GAAG;IAChB,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,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC,CAAC;AAQF,QAAA,MAAM,WAAW,uFAQd,YAAY,KAAG,WAwIjB,CAAC;AA8BF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOmnipay.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOmnipay.tsx"],"names":[],"mappings":"AAGA,wBAAgB,UAAU;;EAKzB"}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
phoneNumber: string;
|
|
6
|
-
view: 'bills';
|
|
7
|
-
onEnterFullScreen?: () => void;
|
|
8
|
-
onExitFullScreen?: () => void;
|
|
9
|
-
};
|
|
10
|
-
declare const Omnipay: ({ color, env, publicKey, phoneNumber, view, onEnterFullScreen, onExitFullScreen, }: OmnipayProps) => JSX.Element;
|
|
11
|
-
export default Omnipay;
|
|
1
|
+
import { OmnipayProvider } from "./components/OmnipayProvider";
|
|
2
|
+
import OmnipayView from "./components/OmnipayView";
|
|
3
|
+
export { OmnipayProvider };
|
|
4
|
+
export { OmnipayView };
|
|
12
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
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,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAA"}
|