omnipay-reactnative-sdk 0.2.7 → 0.2.9

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.
@@ -1,176 +1,15 @@
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
- export const OmnipayView = _ref => {
1
+ import React, { Fragment, useEffect } from 'react';
2
+ import { useOmnipay } from '../hooks/useOmnipay';
3
+ export const Omnipay = _ref => {
6
4
  let {
7
- color,
8
- env,
9
- publicKey,
10
- phoneNumber,
11
- view,
12
- onEnterFullScreen,
13
- onExitFullScreen
5
+ phoneNumber
14
6
  } = _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
- }))));
7
+ const {
8
+ initiateBills
9
+ } = useOmnipay();
10
+ useEffect(() => {
11
+ initiateBills(phoneNumber);
12
+ }, [phoneNumber]);
13
+ return /*#__PURE__*/React.createElement(Fragment, null);
148
14
  };
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
15
  //# sourceMappingURL=OmnipayView.js.map
@@ -1 +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,EACJC,QAAQ,EACRC,kBAAkB,EAClBC,iBAAiB,EACjBC,IAAI,EACJC,OAAO,QACJ,cAAc;AACrB,SAASC,OAAO,QAA6B,sBAAsB;AACnE,SAASC,kBAAkB,QAAQ,6BAA6B;AAkBhE,OAAO,MAAMC,WAAW,GAAG,QAQM;EAAA,IARL;IACxBC,KAAK;IACLC,GAAG;IACHC,SAAS;IACTC,WAAW;IACXC,IAAI;IACJC,iBAAiB;IACjBC;EACU,CAAC;EACX,MAAMC,UAAU,GAAGnB,MAAM,CAAU,IAAI,CAAC;EACxC,MAAM,CAACoB,aAAa,EAAEC,gBAAgB,CAAC,GAAGpB,QAAQ,CAAS,SAAS,CAAC;EACrE,MAAMqB,OAAO,GAAGC,UAAU,EAAE;EAC5B,MAAMC,MAAM,GAAI,GAAEF,OAAQ,UAASV,KAAM,SAAQI,IAAK,cAAaF,SAAU,gBAAeC,WAAY,EAAC;EAEzG,SAASQ,UAAU,GAAG;IAClB,IAAIV,GAAG,KAAK,KAAK,EAAE;MACf,OAAO,oCAAoC;IAC/C;IACA,OAAO,yBAAyB;EACpC;EAEA,MAAMY,cAAc,GAAI;AAC5B,0BAA0BrB,QAAQ,CAACsB,EAAG;AACtC;AACA,KAAK;EAED,SAASC,WAAW,CAACC,IAAiB,EAAE;IACpC,IAAI,CAACT,UAAU,CAACU,OAAO,EAAE;MACrB;IACJ;IACA,IAAI;MACAV,UAAU,CAACU,OAAO,CAACF,WAAW,CAACG,IAAI,CAACC,SAAS,CAACH,IAAI,CAAC,CAAC;IACxD,CAAC,CAAC,OAAOI,KAAK,EAAE,CAAE;EACtB;EAEA,eAAeC,gBAAgB,C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AACC;EAAK,gBACrB,oBAAC,OAAO;IACJ,MAAM,EAAE;MACJC,GAAG,EAAExC;IACT,CAAE;IACF,KAAK,EAAEsC,MAAM,CAACG,OAAQ;IACtB,qCAAqC,EAAExC,cAAe;IACtD,SAAS,EAAEQ,gBAAiB;IAC5B,GAAG,EAAEd,UAAW;IAChB,SAAS,EAAE,MAAME,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"}
1
+ {"version":3,"names":["React","Fragment","useEffect","useOmnipay","Omnipay","phoneNumber","initiateBills"],"sourceRoot":"../../src","sources":["OmnipayView.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,SAASC,UAAU,QAAQ,qBAAqB;AAOhD,OAAO,MAAMC,OAAO,GAAG,QAEU;EAAA,IAFT;IACpBC;EACU,CAAC;EACX,MAAM;IAAEC;EAAc,CAAC,GAAGH,UAAU,EAAE;EAEtCD,SAAS,CAAC,MAAM;IACZI,aAAa,CAACD,WAAW,CAAC;EAC9B,CAAC,EAAE,CAACA,WAAW,CAAC,CAAC;EAIjB,oBACI,oBAAC,QAAQ,OAEE;AAEnB,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { PermissionsAndroid, Platform } from "react-native";
2
+ import { selectContactPhone } from "react-native-select-contact";
3
+ export async function checkPermisionStatus() {
4
+ if (Platform.OS === 'ios') {
5
+ return true;
6
+ }
7
+ if (PermissionsAndroid.PERMISSIONS.READ_CONTACTS) {
8
+ const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_CONTACTS, {
9
+ title: 'Allow us access your contact list',
10
+ message: 'This will enable you choose a phone number to buy airtime or data for from your contact list',
11
+ buttonNegative: 'Cancel',
12
+ buttonPositive: 'OK'
13
+ });
14
+ if (granted === PermissionsAndroid.RESULTS.GRANTED) {
15
+ return true;
16
+ }
17
+ }
18
+ return false;
19
+ }
20
+ export async function getContact() {
21
+ try {
22
+ const isPermissionGranted = await checkPermisionStatus();
23
+ if (!isPermissionGranted) {
24
+ return {
25
+ name: '',
26
+ phoneNumber: ''
27
+ };
28
+ }
29
+ const result = await selectContactPhone();
30
+ if (!result) {
31
+ return {
32
+ name: '',
33
+ phoneNumber: ''
34
+ };
35
+ }
36
+ let {
37
+ contact,
38
+ selectedPhone
39
+ } = result;
40
+ return {
41
+ name: contact.name,
42
+ phoneNumber: selectedPhone.number
43
+ };
44
+ } catch (error) {
45
+ return {
46
+ name: '',
47
+ phoneNumber: ''
48
+ };
49
+ }
50
+ }
51
+ export function getWebHost(env) {
52
+ if (env === 'dev') {
53
+ return 'https://omnipay-websdk.vercel.app/';
54
+ }
55
+ return 'https://sdk.omnipay.ng/';
56
+ }
57
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PermissionsAndroid","Platform","selectContactPhone","checkPermisionStatus","OS","PERMISSIONS","READ_CONTACTS","granted","request","title","message","buttonNegative","buttonPositive","RESULTS","GRANTED","getContact","isPermissionGranted","name","phoneNumber","result","contact","selectedPhone","number","error","getWebHost","env"],"sourceRoot":"../../src","sources":["functions.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,SAASC,kBAAkB,QAAQ,6BAA6B;AAEhE,OAAO,eAAeC,oBAAoB,GAAG;EACzC,IAAIF,QAAQ,CAACG,EAAE,KAAK,KAAK,EAAE;IACvB,OAAO,IAAI;EACf;EACA,IAAIJ,kBAAkB,CAACK,WAAW,CAACC,aAAa,EAAE;IAC9C,MAAMC,OAAO,GAAG,MAAMP,kBAAkB,CAACQ,OAAO,CAC5CR,kBAAkB,CAACK,WAAW,CAACC,aAAa,EAC5C;MACIG,KAAK,EAAE,mCAAmC;MAC1CC,OAAO,EACH,8FAA8F;MAClGC,cAAc,EAAE,QAAQ;MACxBC,cAAc,EAAE;IACpB,CAAC,CACJ;IACD,IAAIL,OAAO,KAAKP,kBAAkB,CAACa,OAAO,CAACC,OAAO,EAAE;MAChD,OAAO,IAAI;IACf;EACJ;EACA,OAAO,KAAK;AAChB;AAEA,OAAO,eAAeC,UAAU,GAAG;EAC/B,IAAI;IACA,MAAMC,mBAAmB,GAAG,MAAMb,oBAAoB,EAAE;IACxD,IAAI,CAACa,mBAAmB,EAAE;MACtB,OAAO;QAAEC,IAAI,EAAE,EAAE;QAAEC,WAAW,EAAE;MAAG,CAAC;IACxC;IACA,MAAMC,MAAM,GAAG,MAAMjB,kBAAkB,EAAE;IACzC,IAAI,CAACiB,MAAM,EAAE;MACT,OAAO;QAAEF,IAAI,EAAE,EAAE;QAAEC,WAAW,EAAE;MAAG,CAAC;IACxC;IACA,IAAI;MAAEE,OAAO;MAAEC;IAAc,CAAC,GAAGF,MAAM;IACvC,OAAO;MAAEF,IAAI,EAAEG,OAAO,CAACH,IAAI;MAAEC,WAAW,EAAEG,aAAa,CAACC;IAAO,CAAC;EACpE,CAAC,CAAC,OAAOC,KAAK,EAAE;IACZ,OAAO;MAAEN,IAAI,EAAE,EAAE;MAAEC,WAAW,EAAE;IAAG,CAAC;EACxC;AACJ;AAEA,OAAO,SAASM,UAAU,CAACC,GAAmB,EAAE;EAC5C,IAAIA,GAAG,KAAK,KAAK,EAAE;IACf,OAAO,oCAAoC;EAC/C;EACA,OAAO,yBAAyB;AACpC"}
@@ -1,4 +1,4 @@
1
1
  export { OmnipayProvider } from "./components/OmnipayProvider";
2
2
  export { useOmnipay } from './hooks/useOmnipay';
3
- export { OmnipayView } from "./components/OmnipayView";
3
+ export { Omnipay } from "./components/OmnipayView";
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OmnipayProvider","useOmnipay","OmnipayView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,eAAe,QAAQ,8BAA8B;AAC9D,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,WAAW,QAAQ,0BAA0B"}
1
+ {"version":3,"names":["OmnipayProvider","useOmnipay","Omnipay"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,eAAe,QAAQ,8BAA8B;AAC9D,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,OAAO,QAAQ,0BAA0B"}
@@ -6,7 +6,8 @@ declare type OmnipayProviderProps = {
6
6
  children: React.ReactElement | React.ReactElement[];
7
7
  };
8
8
  export declare type OmnipayContextType = {
9
- initiateBills: (color: string, phoneNumber: string) => void;
9
+ initiateBills: (phoneNumber: string) => void;
10
+ container?: JSX.Element;
10
11
  };
11
12
  export declare const OmnipayContext: React.Context<OmnipayContextType | null>;
12
13
  export declare const OmnipayProvider: ({ children, publicKey, env, color }: OmnipayProviderProps) => JSX.Element;
@@ -1 +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,gBA6IxF,CAAC"}
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,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,cAAc,0CAAuD,CAAC;AAEnF,eAAO,MAAM,eAAe,wCAAyC,oBAAoB,gBAiHxF,CAAC"}
@@ -1,12 +1,6 @@
1
1
  declare type OmnipayProps = {
2
- color: string;
3
- env: 'dev' | 'prod';
4
- publicKey: string;
5
2
  phoneNumber: string;
6
- view: 'bills';
7
- onEnterFullScreen?: () => void;
8
- onExitFullScreen?: () => void;
9
3
  };
10
- export declare const OmnipayView: ({ color, env, publicKey, phoneNumber, view, onEnterFullScreen, onExitFullScreen, }: OmnipayProps) => JSX.Element;
4
+ export declare const Omnipay: ({ phoneNumber, }: OmnipayProps) => JSX.Element;
11
5
  export {};
12
6
  //# sourceMappingURL=OmnipayView.d.ts.map
@@ -1 +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,eAAO,MAAM,WAAW,uFAQrB,YAAY,KAAG,WAwIjB,CAAC"}
1
+ {"version":3,"file":"OmnipayView.d.ts","sourceRoot":"","sources":["../../../src/components/OmnipayView.tsx"],"names":[],"mappings":"AAGA,aAAK,YAAY,GAAG;IAChB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAGF,eAAO,MAAM,OAAO,qBAEjB,YAAY,KAAG,WAcjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function checkPermisionStatus(): Promise<boolean>;
2
+ export declare function getContact(): Promise<{
3
+ name: string;
4
+ phoneNumber: string;
5
+ }>;
6
+ export declare function getWebHost(env: "prod" | "dev"): "https://omnipay-websdk.vercel.app/" | "https://sdk.omnipay.ng/";
7
+ //# sourceMappingURL=functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":"AAGA,wBAAsB,oBAAoB,qBAoBzC;AAED,wBAAsB,UAAU;;;GAe/B;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,oEAK7C"}
@@ -1,4 +1,4 @@
1
1
  export declare function useOmnipay(): {
2
- initiateBills: (color: string, phoneNumber: string) => void;
2
+ initiateBills: (phoneNumber: string) => void;
3
3
  };
4
4
  //# sourceMappingURL=useOmnipay.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export { OmnipayProvider } from "./components/OmnipayProvider";
2
2
  export { useOmnipay } from './hooks/useOmnipay';
3
- export { OmnipayView } from "./components/OmnipayView";
3
+ export { Omnipay } from "./components/OmnipayView";
4
4
  //# 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,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
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,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnipay-reactnative-sdk",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Omnipay react native sdk",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useRef, useState } from 'react';
2
- import { ActivityIndicator, Linking, PermissionsAndroid, Platform, StyleSheet, View } from 'react-native';
2
+ import { ActivityIndicator, Linking, Platform, StyleSheet, View } from 'react-native';
3
3
  import WebView, { WebViewMessageEvent } from 'react-native-webview';
4
- import { selectContactPhone } from 'react-native-select-contact';
4
+ import { getContact } from '../functions';
5
5
 
6
6
  type OmnipayProviderProps = {
7
7
  publicKey: string
@@ -17,7 +17,8 @@ type PostMessage = {
17
17
  type Status = 'error' | 'loading' | 'success';
18
18
 
19
19
  export type OmnipayContextType = {
20
- initiateBills: (color: string, phoneNumber: string) => void;
20
+ initiateBills: (phoneNumber: string) => void;
21
+ container?: JSX.Element
21
22
  }
22
23
 
23
24
  export const OmnipayContext = React.createContext<OmnipayContextType | null>(null);
@@ -33,6 +34,7 @@ export const OmnipayProvider = ({ children, publicKey, env, color }: OmnipayProv
33
34
 
34
35
  console.log(useFullscreen)
35
36
 
37
+
36
38
  function getWebviewStyle() {
37
39
  if (isNoviewLoaded) {
38
40
  return { opacity: 0, height: 0, width: 0, flex: 0 };
@@ -88,49 +90,13 @@ export const OmnipayProvider = ({ children, publicKey, env, color }: OmnipayProv
88
90
  } catch (error) { }
89
91
  }
90
92
 
91
- async function getContact() {
92
- try {
93
- const isPermissionGranted = await checkPermisionStatus();
94
- if (!isPermissionGranted) {
95
- return { name: '', phoneNumber: '' };
96
- }
97
- const result = await selectContactPhone();
98
- if (!result) {
99
- return { name: '', phoneNumber: '' };
100
- }
101
- let { contact, selectedPhone } = result;
102
- return { name: contact.name, phoneNumber: selectedPhone.number };
103
- } catch (error) {
104
- return { name: '', phoneNumber: '' };
105
- }
106
- }
107
93
 
108
- async function checkPermisionStatus() {
109
- if (Platform.OS === 'ios') {
110
- return true;
111
- }
112
- if (PermissionsAndroid.PERMISSIONS.READ_CONTACTS) {
113
- const granted = await PermissionsAndroid.request(
114
- PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
115
- {
116
- title: 'Allow us access your contact list',
117
- message:
118
- 'This will enable you choose a phone number to buy airtime or data for from your contact list',
119
- buttonNegative: 'Cancel',
120
- buttonPositive: 'OK',
121
- }
122
- );
123
- if (granted === PermissionsAndroid.RESULTS.GRANTED) {
124
- return true;
125
- }
126
- }
127
- return false;
128
- }
129
94
 
130
95
  const _initiateBills = useCallback(
131
96
  (
132
97
  phoneNumber: string
133
98
  ) => {
99
+ console.log(phoneNumber)
134
100
  if (phoneNumber) {
135
101
  if (phoneNumber.length === 11) {
136
102
  const webUrl = `${webHost}?theme=${color}&view=bills&publicKey=${publicKey}&phoneNumber=${phoneNumber}`;
@@ -141,10 +107,8 @@ export const OmnipayProvider = ({ children, publicKey, env, color }: OmnipayProv
141
107
  []
142
108
  );
143
109
 
144
-
145
- return (
146
- <OmnipayContext.Provider value={{ initiateBills: _initiateBills }}>
147
- {children}
110
+ function WebviewContainer() {
111
+ return <View style={{ flex: 1, height: "100%" }}>
148
112
  <WebView
149
113
  source={{
150
114
  uri: webviewUrl,
@@ -161,6 +125,15 @@ export const OmnipayProvider = ({ children, publicKey, env, color }: OmnipayProv
161
125
  <ActivityIndicator size="small" color={color} />
162
126
  </View>
163
127
  )}
128
+ </View>;
129
+ }
130
+
131
+
132
+ return (
133
+ <OmnipayContext.Provider value={{ initiateBills: _initiateBills, container: WebviewContainer() }}>
134
+ <View style={{ flex: 1, height: "100%" }}>
135
+ {children}
136
+ </View>
164
137
  </OmnipayContext.Provider>
165
138
  );
166
139
  };
@@ -177,7 +150,10 @@ const styles = StyleSheet.create({
177
150
  webview: {
178
151
  flex: 1,
179
152
  width: '100%',
180
- height: '100%',
153
+ height: 900,
154
+ // position: "absolute",
155
+ // top: 0,
156
+ // left: 0
181
157
  },
182
158
  webviewLoader: {
183
159
  zIndex: 3,