omnipay-reactnative-sdk 1.2.4 → 1.2.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 +57 -14
- package/lib/commonjs/components/OmnipayView.js +2 -0
- package/lib/commonjs/components/OmnipayView.js.map +1 -1
- package/lib/commonjs/components/views/PaymentLinking.js +127 -0
- package/lib/commonjs/components/views/PaymentLinking.js.map +1 -0
- package/lib/module/components/OmnipayView.js +2 -0
- package/lib/module/components/OmnipayView.js.map +1 -1
- package/lib/module/components/views/PaymentLinking.js +119 -0
- package/lib/module/components/views/PaymentLinking.js.map +1 -0
- package/lib/typescript/components/OmnipayView.d.ts +12 -0
- package/lib/typescript/components/OmnipayView.d.ts.map +1 -1
- package/lib/typescript/components/views/PaymentLinking.d.ts +16 -0
- package/lib/typescript/components/views/PaymentLinking.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/OmnipayView.tsx +2 -0
- package/src/components/views/PaymentLinking.tsx +159 -0
package/README.md
CHANGED
|
@@ -78,8 +78,8 @@ function onWalletClosed() {
|
|
|
78
78
|
initiateBills({
|
|
79
79
|
phoneNumber: '08020001111',
|
|
80
80
|
onClose: onBillsClosed,
|
|
81
|
-
metadata: { userId: '12345', source: 'app' },
|
|
82
81
|
});
|
|
82
|
+
|
|
83
83
|
initiateWallet({
|
|
84
84
|
phoneNumber: '08020001111',
|
|
85
85
|
customerRef: '9ab6790',
|
|
@@ -100,7 +100,7 @@ initiateWallet({
|
|
|
100
100
|
sessionId: 'session123',
|
|
101
101
|
kycStatus: 'verified', // 'verified' | 'unverified'
|
|
102
102
|
launchPage: 'wallet',
|
|
103
|
-
metadata: {
|
|
103
|
+
metadata: { usesPinReset: false, usesPinUpdate: false },
|
|
104
104
|
});
|
|
105
105
|
```
|
|
106
106
|
|
|
@@ -108,20 +108,19 @@ initiateWallet({
|
|
|
108
108
|
|
|
109
109
|
#### OmnipayProvider Props
|
|
110
110
|
|
|
111
|
-
| Name | Type | Description
|
|
112
|
-
| --------- | ------ |
|
|
113
|
-
| color | String | color of primary buttons and links
|
|
114
|
-
| env | String | dev or prod
|
|
115
|
-
| publicKey | String | public key of the company on omnipay
|
|
116
|
-
|
|
111
|
+
| Name | Type | Description |
|
|
112
|
+
| --------- | ------ | ------------------------------------ |
|
|
113
|
+
| color | String | color of primary buttons and links |
|
|
114
|
+
| env | String | dev or prod |
|
|
115
|
+
| publicKey | String | public key of the company on omnipay |
|
|
117
116
|
|
|
118
117
|
#### initiateBills Props
|
|
119
118
|
|
|
120
|
-
| Name | Type | Description
|
|
121
|
-
| ----------- | -------- |
|
|
122
|
-
| phoneNumber | String | phone number of the customer
|
|
123
|
-
| onClose | Function | this is used to notify you when the sdk closes
|
|
124
|
-
| metadata
|
|
119
|
+
| Name | Type | Description |
|
|
120
|
+
| ----------- | -------- | -------------------------------------------------------- |
|
|
121
|
+
| phoneNumber | String | phone number of the customer |
|
|
122
|
+
| onClose | Function | this is used to notify you when the sdk closes |
|
|
123
|
+
| metadata | Object | optional object to pass additional properties to the SDK |
|
|
125
124
|
|
|
126
125
|
#### initiateWallet Props
|
|
127
126
|
|
|
@@ -146,7 +145,7 @@ initiateWallet({
|
|
|
146
145
|
| sessionId | String | unique session identifier |
|
|
147
146
|
| kycStatus | String | KYC status of the user ('verified', 'unverified') |
|
|
148
147
|
| launchPage | String | page to launch in the wallet |
|
|
149
|
-
| metadata | Object | optional object to pass additional properties to the SDK
|
|
148
|
+
| metadata | Object | optional object to pass additional properties to the SDK |
|
|
150
149
|
|
|
151
150
|
## Registration Sdk
|
|
152
151
|
|
|
@@ -187,3 +186,47 @@ import { Omnipay } from 'omnipay-reactnative-sdk';
|
|
|
187
186
|
| phoneNumber | String | phone number of the customer |
|
|
188
187
|
| publicKey | String | public key of the company on omnipay |
|
|
189
188
|
| view | String | the view to render on the sdk |
|
|
189
|
+
|
|
190
|
+
## Payment Linking Sdk
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
import { Omnipay } from 'omnipay-reactnative-sdk';
|
|
194
|
+
|
|
195
|
+
//render it anywhere on your page where you want to display the payment linking sdk
|
|
196
|
+
<Omnipay.PaymentLinking
|
|
197
|
+
env="dev"
|
|
198
|
+
color="#42a99b"
|
|
199
|
+
publicKey="OMNIPUBKEY_K0VUJN0JAJZIXUGKAG6XNBXR-RH5YNRS"
|
|
200
|
+
phoneNumber="09031234571"
|
|
201
|
+
customerRef="010019ddh"
|
|
202
|
+
amount={5000}
|
|
203
|
+
sessionId="session123"
|
|
204
|
+
orderId="order456"
|
|
205
|
+
onPaymentLinkingSuccessful={() => {
|
|
206
|
+
/**
|
|
207
|
+
* payment linking has been completed successfully
|
|
208
|
+
*/
|
|
209
|
+
}}
|
|
210
|
+
onClose={() => {
|
|
211
|
+
/**
|
|
212
|
+
* the user is done with payment linking.
|
|
213
|
+
* you can navigate them else where at this point
|
|
214
|
+
*/
|
|
215
|
+
}}
|
|
216
|
+
/>;
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Properties
|
|
220
|
+
|
|
221
|
+
| Name | Type | Description |
|
|
222
|
+
| -------------------------- | -------- | ------------------------------------------------------------------------- |
|
|
223
|
+
| color | String | color of primary buttons and links |
|
|
224
|
+
| env | String | dev or prod |
|
|
225
|
+
| publicKey | String | public key of the company on omnipay |
|
|
226
|
+
| phoneNumber | String | phone number of the customer (required if customerRef not provided) |
|
|
227
|
+
| customerRef | String | customer reference of the customer (required if phoneNumber not provided) |
|
|
228
|
+
| amount | Number | amount to be linked for payment in kobo |
|
|
229
|
+
| sessionId | String | unique session identifier |
|
|
230
|
+
| orderId | String | order identifier |
|
|
231
|
+
| onPaymentLinkingSuccessful | Function | callback when payment linking is successful |
|
|
232
|
+
| onClose | Function | callback when the payment linking modal is closed |
|
|
@@ -12,6 +12,7 @@ var _functions = require("../functions");
|
|
|
12
12
|
var _Registration = require("./views/Registration");
|
|
13
13
|
var _BvnVerification = require("./views/BvnVerification");
|
|
14
14
|
var _PaylaterAgreement = require("./views/PaylaterAgreement");
|
|
15
|
+
var _PaymentLinking = require("./views/PaymentLinking");
|
|
15
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
17
|
const Omnipay = ({
|
|
17
18
|
color,
|
|
@@ -149,5 +150,6 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
149
150
|
Omnipay.Registration = _Registration.Registration;
|
|
150
151
|
Omnipay.BvnVerification = _BvnVerification.BvnVerification;
|
|
151
152
|
Omnipay.PaylaterAgreement = _PaylaterAgreement.PaylaterAgreement;
|
|
153
|
+
Omnipay.PaymentLinking = _PaymentLinking.PaymentLinking;
|
|
152
154
|
var _default = exports.default = Omnipay;
|
|
153
155
|
//# sourceMappingURL=OmnipayView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_config","_functions","_Registration","_BvnVerification","_PaylaterAgreement","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Omnipay","color","env","publicKey","phoneNumber","view","onEnterFullScreen","onExitFullScreen","webviewRef","useRef","webviewStatus","setWebviewStatus","useState","webHost","getWebHost","webUrl","getWebUrl","onWebviewMount","Platform","OS","clientSdkBaseUrl","serverSdkBaseUrl","themeColor","includes","split","postMessage","data","current","JSON","stringify","error","onWebviewMessage","nativeEvent","eventData","parse","dataKey","dataValue","contactDetails","getContact","Linking","openURL","createElement","Text","length","Fragment","View","style","styles","full","WebView","source","uri","webview","injectedJavaScriptBeforeContentLoaded","onMessage","ref","onLoadEnd","webviewLoader","ActivityIndicator","size","StyleSheet","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left","Registration","BvnVerification","PaylaterAgreement","_default","exports"],"sourceRoot":"../../../src","sources":["components/OmnipayView.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_config","_functions","_Registration","_BvnVerification","_PaylaterAgreement","_PaymentLinking","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Omnipay","color","env","publicKey","phoneNumber","view","onEnterFullScreen","onExitFullScreen","webviewRef","useRef","webviewStatus","setWebviewStatus","useState","webHost","getWebHost","webUrl","getWebUrl","onWebviewMount","Platform","OS","clientSdkBaseUrl","serverSdkBaseUrl","themeColor","includes","split","postMessage","data","current","JSON","stringify","error","onWebviewMessage","nativeEvent","eventData","parse","dataKey","dataValue","contactDetails","getContact","Linking","openURL","createElement","Text","length","Fragment","View","style","styles","full","WebView","source","uri","webview","injectedJavaScriptBeforeContentLoaded","onMessage","ref","onLoadEnd","webviewLoader","ActivityIndicator","size","StyleSheet","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left","Registration","BvnVerification","PaylaterAgreement","PaymentLinking","_default","exports"],"sourceRoot":"../../../src","sources":["components/OmnipayView.tsx"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AC,OAAO;IAAC1D,KAAK,EAAEA;EAAM,CAAE,CAC3C,CAEJ,CACE,CAAC;AAEf,CAAC;AAED,MAAM8C,MAAM,GAAGa,uBAAU,CAACC,MAAM,CAAC;EAC/BC,IAAI,EAAE;IACJC,OAAO,EAAE;EACX,CAAC;EACDf,IAAI,EAAE;IACJgB,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDd,OAAO,EAAE;IACPY,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDT,aAAa,EAAE;IACbU,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;AAEFzE,OAAO,CAAC0E,YAAY,GAAGA,0BAAY;AACnC1E,OAAO,CAAC2E,eAAe,GAAGA,gCAAe;AACzC3E,OAAO,CAAC4E,iBAAiB,GAAGA,oCAAiB;AAC7C5E,OAAO,CAAC6E,cAAc,GAAGA,8BAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxF,OAAA,GACzBS,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PaymentLinking = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeWebview = require("react-native-webview");
|
|
10
|
+
var _config = require("../../lib/config");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
const PaymentLinking = ({
|
|
13
|
+
color,
|
|
14
|
+
env,
|
|
15
|
+
publicKey,
|
|
16
|
+
phoneNumber,
|
|
17
|
+
customerRef,
|
|
18
|
+
amount,
|
|
19
|
+
sessionId,
|
|
20
|
+
orderId,
|
|
21
|
+
onClose,
|
|
22
|
+
onPaymentLinkingSuccessful
|
|
23
|
+
}) => {
|
|
24
|
+
const webviewRef = (0, _react.useRef)(null);
|
|
25
|
+
const [webviewStatus, setWebviewStatus] = (0, _react.useState)('loading');
|
|
26
|
+
const webHost = getWebHost();
|
|
27
|
+
const webUrl = getWebUrl();
|
|
28
|
+
const onWebviewMount = `
|
|
29
|
+
window.nativeOs = ${_reactNative.Platform.OS};
|
|
30
|
+
true;
|
|
31
|
+
`;
|
|
32
|
+
function getWebHost() {
|
|
33
|
+
return _config.serverSdkBaseUrl[env];
|
|
34
|
+
}
|
|
35
|
+
function getWebUrl() {
|
|
36
|
+
const themeColor = color.includes('#') ? color.split('#')[1] : color;
|
|
37
|
+
return `${webHost}order/create?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${phoneNumber || ''}&customerRef=${customerRef || ''}&amountPending=${amount}&sessionId=${sessionId || ''}&orderId=${orderId || ''}`;
|
|
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
|
+
} = eventData;
|
|
46
|
+
if (dataKey === 'payment.linked') {
|
|
47
|
+
if (onPaymentLinkingSuccessful) {
|
|
48
|
+
onPaymentLinkingSuccessful();
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (dataKey === 'close.payment') {
|
|
53
|
+
if (onClose) {
|
|
54
|
+
onClose();
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {}
|
|
60
|
+
}
|
|
61
|
+
if (!publicKey.includes('OMNIPUBKEY_')) {
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, "Invalid public key");
|
|
63
|
+
}
|
|
64
|
+
if (color.length < 3) {
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, "Invalid color");
|
|
66
|
+
}
|
|
67
|
+
if (!['dev', 'prod'].includes(env)) {
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, "Invalid environment");
|
|
69
|
+
}
|
|
70
|
+
if (!customerRef) {
|
|
71
|
+
if (!phoneNumber) {
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, "Phone number is required");
|
|
73
|
+
}
|
|
74
|
+
if ((phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.length) < 10) {
|
|
75
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, "Invalid phone number");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
|
|
79
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, "Amount is required and should be greater than 0");
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
82
|
+
style: styles.full
|
|
83
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeWebview.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.default.createElement(_reactNative.View, {
|
|
93
|
+
style: styles.webviewLoader
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, {
|
|
95
|
+
size: "small",
|
|
96
|
+
color: color
|
|
97
|
+
}))));
|
|
98
|
+
};
|
|
99
|
+
exports.PaymentLinking = PaymentLinking;
|
|
100
|
+
const styles = _reactNative.StyleSheet.create({
|
|
101
|
+
hide: {
|
|
102
|
+
display: 'none'
|
|
103
|
+
},
|
|
104
|
+
full: {
|
|
105
|
+
flex: 1,
|
|
106
|
+
width: '100%',
|
|
107
|
+
height: '100%'
|
|
108
|
+
},
|
|
109
|
+
webview: {
|
|
110
|
+
flex: 1,
|
|
111
|
+
width: '100%',
|
|
112
|
+
height: '100%'
|
|
113
|
+
},
|
|
114
|
+
webviewLoader: {
|
|
115
|
+
zIndex: 3,
|
|
116
|
+
backgroundColor: 'white',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
justifyContent: 'center',
|
|
119
|
+
flex: 1,
|
|
120
|
+
width: '100%',
|
|
121
|
+
height: '100%',
|
|
122
|
+
position: 'absolute',
|
|
123
|
+
top: 0,
|
|
124
|
+
left: 0
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
//# sourceMappingURL=PaymentLinking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_config","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PaymentLinking","color","env","publicKey","phoneNumber","customerRef","amount","sessionId","orderId","onClose","onPaymentLinkingSuccessful","webviewRef","useRef","webviewStatus","setWebviewStatus","useState","webHost","getWebHost","webUrl","getWebUrl","onWebviewMount","Platform","OS","serverSdkBaseUrl","themeColor","includes","split","onWebviewMessage","nativeEvent","data","eventData","JSON","parse","dataKey","error","createElement","Text","length","isNaN","Number","Fragment","View","style","styles","full","WebView","source","uri","webview","injectedJavaScriptBeforeContentLoaded","onMessage","ref","onLoadEnd","webviewLoader","ActivityIndicator","size","exports","StyleSheet","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"sourceRoot":"../../../../src","sources":["components/views/PaymentLinking.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAAoD,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,c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K,EAAEA;EAAM,CAAE,CAC3C,CAEJ,CACE,CAAC;AAEf,CAAC;AAACuD,OAAA,CAAAxD,cAAA,GAAAA,cAAA;AAEF,MAAM2C,MAAM,GAAGc,uBAAU,CAACC,MAAM,CAAC;EAC/BC,IAAI,EAAE;IACJC,OAAO,EAAE;EACX,CAAC;EACDhB,IAAI,EAAE;IACJiB,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDf,OAAO,EAAE;IACPa,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDV,aAAa,EAAE;IACbW,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","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ import { getContact } from '../functions';
|
|
|
6
6
|
import { Registration } from './views/Registration';
|
|
7
7
|
import { BvnVerification } from './views/BvnVerification';
|
|
8
8
|
import { PaylaterAgreement } from './views/PaylaterAgreement';
|
|
9
|
+
import { PaymentLinking } from './views/PaymentLinking';
|
|
9
10
|
const Omnipay = ({
|
|
10
11
|
color,
|
|
11
12
|
env,
|
|
@@ -142,5 +143,6 @@ const styles = StyleSheet.create({
|
|
|
142
143
|
Omnipay.Registration = Registration;
|
|
143
144
|
Omnipay.BvnVerification = BvnVerification;
|
|
144
145
|
Omnipay.PaylaterAgreement = PaylaterAgreement;
|
|
146
|
+
Omnipay.PaymentLinking = PaymentLinking;
|
|
145
147
|
export default Omnipay;
|
|
146
148
|
//# sourceMappingURL=OmnipayView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Fragment","useRef","useState","StyleSheet","View","Platform","ActivityIndicator","Text","Linking","WebView","clientSdkBaseUrl","serverSdkBaseUrl","getContact","Registration","BvnVerification","PaylaterAgreement","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","createElement","length","style","styles","full","source","uri","webview","injectedJavaScriptBeforeContentLoaded","onMessage","ref","onLoadEnd","webviewLoader","size","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"sourceRoot":"../../../src","sources":["components/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,QAAkC,sBAAsB;AACxE,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,eAAe;AAClE,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,iBAAiB,QAAQ,2BAA2B;
|
|
1
|
+
{"version":3,"names":["React","Fragment","useRef","useState","StyleSheet","View","Platform","ActivityIndicator","Text","Linking","WebView","clientSdkBaseUrl","serverSdkBaseUrl","getContact","Registration","BvnVerification","PaylaterAgreement","PaymentLinking","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","createElement","length","style","styles","full","source","uri","webview","injectedJavaScriptBeforeContentLoaded","onMessage","ref","onLoadEnd","webviewLoader","size","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"sourceRoot":"../../../src","sources":["components/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,QAAkC,sBAAsB;AACxE,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,eAAe;AAClE,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,iBAAiB,QAAQ,2BAA2B;AAC7D,SAASC,cAAc,QAAQ,wBAAwB;AAkBvD,MAAMC,OAAO,GAAGA,CAAC;EACfC,KAAK;EACLC,GAAG;EACHC,SAAS;EACTC,WAAW;EACXC,IAAI;EACJC,iBAAiB;EACjBC;AACY,CAAC,KAAwB;EACrC,MAAMC,UAAU,GAAGxB,MAAM,CAAU,IAAI,CAAC;EACxC,MAAM,CAACyB,aAAa,EAAEC,gBAAgB,CAAC,GAAGzB,QAAQ,CAAS,SAAS,CAAC;EACrE,MAAM0B,OAAO,GAAGC,UAAU,CAAC,CAAC;EAC5B,MAAMC,MAAM,GAAGC,SAAS,CAAC,CAAC;EAE1B,MAAMC,cAAc,GAAG;AACzB,0BAA0B3B,QAAQ,CAAC4B,EAAE;AACrC;AACA,KAAK;EAEH,SAASJ,UAAUA,CAAA,EAAG;IACpB;AACJ;AACA;AACA;IACI,IAAIP,IAAI,KAAK,OAAO,EAAE;MACpB,OAAOZ,gBAAgB,CAACS,GAAG,CAAC;IAC9B;IACA,OAAOR,gBAAgB,CAACQ,GAAG,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;IAC5BmB,GAAG,EAAErC,UAAW;IAChBsC,SAAS,EAAEA,CAAA,KAAMpC,gBAAgB,CAAC,SAAS;EAAE,CAC9C,CAAC,EACDD,aAAa,KAAK,SAAS,iBAC1B3B,KAAA,CAAAqD,aAAA,CAAChD,IAAI;IAACkD,KAAK,EAAEC,MAAM,CAACS;EAAc,gBAChCjE,KAAA,CAAAqD,aAAA,CAAC9C,iBAAiB;IAAC2D,IAAI,EAAC,OAAO;IAAC/C,KAAK,EAAEA;EAAM,CAAE,CAC3C,CAEJ,CACE,CAAC;AAEf,CAAC;AAED,MAAMqC,MAAM,GAAGpD,UAAU,CAAC+D,MAAM,CAAC;EAC/BC,IAAI,EAAE;IACJC,OAAO,EAAE;EACX,CAAC;EACDZ,IAAI,EAAE;IACJa,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDZ,OAAO,EAAE;IACPU,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDP,aAAa,EAAE;IACbQ,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;AAEF7D,OAAO,CAACJ,YAAY,GAAGA,YAAY;AACnCI,OAAO,CAACH,eAAe,GAAGA,eAAe;AACzCG,OAAO,CAACF,iBAAiB,GAAGA,iBAAiB;AAC7CE,OAAO,CAACD,cAAc,GAAGA,cAAc;AACvC,eAAeC,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 PaymentLinking = ({
|
|
6
|
+
color,
|
|
7
|
+
env,
|
|
8
|
+
publicKey,
|
|
9
|
+
phoneNumber,
|
|
10
|
+
customerRef,
|
|
11
|
+
amount,
|
|
12
|
+
sessionId,
|
|
13
|
+
orderId,
|
|
14
|
+
onClose,
|
|
15
|
+
onPaymentLinkingSuccessful
|
|
16
|
+
}) => {
|
|
17
|
+
const webviewRef = useRef(null);
|
|
18
|
+
const [webviewStatus, setWebviewStatus] = useState('loading');
|
|
19
|
+
const webHost = getWebHost();
|
|
20
|
+
const webUrl = getWebUrl();
|
|
21
|
+
const onWebviewMount = `
|
|
22
|
+
window.nativeOs = ${Platform.OS};
|
|
23
|
+
true;
|
|
24
|
+
`;
|
|
25
|
+
function getWebHost() {
|
|
26
|
+
return serverSdkBaseUrl[env];
|
|
27
|
+
}
|
|
28
|
+
function getWebUrl() {
|
|
29
|
+
const themeColor = color.includes('#') ? color.split('#')[1] : color;
|
|
30
|
+
return `${webHost}order/create?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${phoneNumber || ''}&customerRef=${customerRef || ''}&amountPending=${amount}&sessionId=${sessionId || ''}&orderId=${orderId || ''}`;
|
|
31
|
+
}
|
|
32
|
+
async function onWebviewMessage(e) {
|
|
33
|
+
try {
|
|
34
|
+
if (e.nativeEvent && e.nativeEvent.data) {
|
|
35
|
+
const eventData = JSON.parse(e.nativeEvent.data);
|
|
36
|
+
const {
|
|
37
|
+
dataKey
|
|
38
|
+
} = eventData;
|
|
39
|
+
if (dataKey === 'payment.linked') {
|
|
40
|
+
if (onPaymentLinkingSuccessful) {
|
|
41
|
+
onPaymentLinkingSuccessful();
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (dataKey === 'close.payment') {
|
|
46
|
+
if (onClose) {
|
|
47
|
+
onClose();
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {}
|
|
53
|
+
}
|
|
54
|
+
if (!publicKey.includes('OMNIPUBKEY_')) {
|
|
55
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid public key");
|
|
56
|
+
}
|
|
57
|
+
if (color.length < 3) {
|
|
58
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid color");
|
|
59
|
+
}
|
|
60
|
+
if (!['dev', 'prod'].includes(env)) {
|
|
61
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid environment");
|
|
62
|
+
}
|
|
63
|
+
if (!customerRef) {
|
|
64
|
+
if (!phoneNumber) {
|
|
65
|
+
return /*#__PURE__*/React.createElement(Text, null, "Phone number is required");
|
|
66
|
+
}
|
|
67
|
+
if ((phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.length) < 10) {
|
|
68
|
+
return /*#__PURE__*/React.createElement(Text, null, "Invalid phone number");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
|
|
72
|
+
return /*#__PURE__*/React.createElement(Text, null, "Amount is required and should be greater than 0");
|
|
73
|
+
}
|
|
74
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
75
|
+
style: styles.full
|
|
76
|
+
}, /*#__PURE__*/React.createElement(WebView, {
|
|
77
|
+
source: {
|
|
78
|
+
uri: webUrl
|
|
79
|
+
},
|
|
80
|
+
style: styles.webview,
|
|
81
|
+
injectedJavaScriptBeforeContentLoaded: onWebviewMount,
|
|
82
|
+
onMessage: onWebviewMessage,
|
|
83
|
+
ref: webviewRef,
|
|
84
|
+
onLoadEnd: () => setWebviewStatus('success')
|
|
85
|
+
}), webviewStatus === 'loading' && /*#__PURE__*/React.createElement(View, {
|
|
86
|
+
style: styles.webviewLoader
|
|
87
|
+
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
88
|
+
size: "small",
|
|
89
|
+
color: color
|
|
90
|
+
}))));
|
|
91
|
+
};
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
hide: {
|
|
94
|
+
display: 'none'
|
|
95
|
+
},
|
|
96
|
+
full: {
|
|
97
|
+
flex: 1,
|
|
98
|
+
width: '100%',
|
|
99
|
+
height: '100%'
|
|
100
|
+
},
|
|
101
|
+
webview: {
|
|
102
|
+
flex: 1,
|
|
103
|
+
width: '100%',
|
|
104
|
+
height: '100%'
|
|
105
|
+
},
|
|
106
|
+
webviewLoader: {
|
|
107
|
+
zIndex: 3,
|
|
108
|
+
backgroundColor: 'white',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
justifyContent: 'center',
|
|
111
|
+
flex: 1,
|
|
112
|
+
width: '100%',
|
|
113
|
+
height: '100%',
|
|
114
|
+
position: 'absolute',
|
|
115
|
+
top: 0,
|
|
116
|
+
left: 0
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=PaymentLinking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Fragment","useRef","useState","ActivityIndicator","Platform","StyleSheet","Text","View","WebView","serverSdkBaseUrl","PaymentLinking","color","env","publicKey","phoneNumber","customerRef","amount","sessionId","orderId","onClose","onPaymentLinkingSuccessful","webviewRef","webviewStatus","setWebviewStatus","webHost","getWebHost","webUrl","getWebUrl","onWebviewMount","OS","themeColor","includes","split","onWebviewMessage","e","nativeEvent","data","eventData","JSON","parse","dataKey","error","createElement","length","isNaN","Number","style","styles","full","source","uri","webview","injectedJavaScriptBeforeContentLoaded","onMessage","ref","onLoadEnd","webviewLoader","size","create","hide","display","flex","width","height","zIndex","backgroundColor","alignItems","justifyContent","position","top","left"],"sourceRoot":"../../../../src","sources":["components/views/PaymentLinking.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,QA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ACbC,MAAM,EAAE,MAAM;IACdK,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -45,6 +45,18 @@ declare const Omnipay: {
|
|
|
45
45
|
}) => void;
|
|
46
46
|
onClose?: () => void;
|
|
47
47
|
}) => React.JSX.Element;
|
|
48
|
+
PaymentLinking: ({ color, env, publicKey, phoneNumber, customerRef, amount, sessionId, orderId, onClose, onPaymentLinkingSuccessful, }: {
|
|
49
|
+
color: string;
|
|
50
|
+
env: "dev" | "prod";
|
|
51
|
+
publicKey: string;
|
|
52
|
+
phoneNumber?: string;
|
|
53
|
+
customerRef?: string;
|
|
54
|
+
amount: number;
|
|
55
|
+
sessionId: string;
|
|
56
|
+
orderId: string;
|
|
57
|
+
onClose?: () => void;
|
|
58
|
+
onPaymentLinkingSuccessful?: () => void;
|
|
59
|
+
}) => React.JSX.Element;
|
|
48
60
|
};
|
|
49
61
|
export default Omnipay;
|
|
50
62
|
//# sourceMappingURL=OmnipayView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OmnipayView.d.ts","sourceRoot":"","sources":["../../../src/components/OmnipayView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"OmnipayView.d.ts","sourceRoot":"","sources":["../../../src/components/OmnipayView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAiB1D,KAAK,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,KAAK,CAAC,GAAG,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6GlC,CAAC;AAkCF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type OmnipayProps = {
|
|
3
|
+
color: string;
|
|
4
|
+
env: 'dev' | 'prod';
|
|
5
|
+
publicKey: string;
|
|
6
|
+
phoneNumber?: string;
|
|
7
|
+
customerRef?: string;
|
|
8
|
+
amount: number;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
orderId: string;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
onPaymentLinkingSuccessful?: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const PaymentLinking: ({ color, env, publicKey, phoneNumber, customerRef, amount, sessionId, orderId, onClose, onPaymentLinkingSuccessful, }: OmnipayProps) => React.JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=PaymentLinking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentLinking.d.ts","sourceRoot":"","sources":["../../../../src/components/views/PaymentLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAW1D,KAAK,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,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;CACzC,CAAC;AAIF,eAAO,MAAM,cAAc,GAAI,uHAW5B,YAAY,KAAG,KAAK,CAAC,GAAG,CAAC,OA6F3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import { getContact } from '../functions';
|
|
|
13
13
|
import { Registration } from './views/Registration';
|
|
14
14
|
import { BvnVerification } from './views/BvnVerification';
|
|
15
15
|
import { PaylaterAgreement } from './views/PaylaterAgreement';
|
|
16
|
+
import { PaymentLinking } from './views/PaymentLinking';
|
|
16
17
|
|
|
17
18
|
type OmnipayProps = {
|
|
18
19
|
color: string;
|
|
@@ -180,4 +181,5 @@ const styles = StyleSheet.create({
|
|
|
180
181
|
Omnipay.Registration = Registration;
|
|
181
182
|
Omnipay.BvnVerification = BvnVerification;
|
|
182
183
|
Omnipay.PaylaterAgreement = PaylaterAgreement;
|
|
184
|
+
Omnipay.PaymentLinking = PaymentLinking;
|
|
183
185
|
export default Omnipay;
|
|
@@ -0,0 +1,159 @@
|
|
|
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, type 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
|
+
amount: number;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
orderId: string;
|
|
21
|
+
onClose?: () => void;
|
|
22
|
+
onPaymentLinkingSuccessful?: () => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type Status = 'error' | 'loading' | 'success';
|
|
26
|
+
|
|
27
|
+
export const PaymentLinking = ({
|
|
28
|
+
color,
|
|
29
|
+
env,
|
|
30
|
+
publicKey,
|
|
31
|
+
phoneNumber,
|
|
32
|
+
customerRef,
|
|
33
|
+
amount,
|
|
34
|
+
sessionId,
|
|
35
|
+
orderId,
|
|
36
|
+
onClose,
|
|
37
|
+
onPaymentLinkingSuccessful,
|
|
38
|
+
}: OmnipayProps): React.JSX.Element => {
|
|
39
|
+
const webviewRef = useRef<WebView>(null);
|
|
40
|
+
const [webviewStatus, setWebviewStatus] = useState<Status>('loading');
|
|
41
|
+
const webHost = getWebHost();
|
|
42
|
+
const webUrl = getWebUrl();
|
|
43
|
+
|
|
44
|
+
const onWebviewMount = `
|
|
45
|
+
window.nativeOs = ${Platform.OS};
|
|
46
|
+
true;
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
function getWebHost() {
|
|
50
|
+
return serverSdkBaseUrl[env];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getWebUrl() {
|
|
54
|
+
const themeColor = color.includes('#') ? color.split('#')[1] : color;
|
|
55
|
+
return `${webHost}order/create?theme=${themeColor}&publicKey=${publicKey}&phoneNumber=${
|
|
56
|
+
phoneNumber || ''
|
|
57
|
+
}&customerRef=${customerRef || ''}&amountPending=${amount}&sessionId=${
|
|
58
|
+
sessionId || ''
|
|
59
|
+
}&orderId=${orderId || ''}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function onWebviewMessage(e: WebViewMessageEvent) {
|
|
63
|
+
try {
|
|
64
|
+
if (e.nativeEvent && e.nativeEvent.data) {
|
|
65
|
+
const eventData = JSON.parse(e.nativeEvent.data);
|
|
66
|
+
const { dataKey } = eventData;
|
|
67
|
+
|
|
68
|
+
if (dataKey === 'payment.linked') {
|
|
69
|
+
if (onPaymentLinkingSuccessful) {
|
|
70
|
+
onPaymentLinkingSuccessful();
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (dataKey === 'close.payment') {
|
|
76
|
+
if (onClose) {
|
|
77
|
+
onClose();
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!publicKey.includes('OMNIPUBKEY_')) {
|
|
86
|
+
return <Text>Invalid public key</Text>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (color.length < 3) {
|
|
90
|
+
return <Text>Invalid color</Text>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!['dev', 'prod'].includes(env)) {
|
|
94
|
+
return <Text>Invalid environment</Text>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!customerRef) {
|
|
98
|
+
if (!phoneNumber) {
|
|
99
|
+
return <Text>Phone number is required</Text>;
|
|
100
|
+
}
|
|
101
|
+
if (phoneNumber?.length < 10) {
|
|
102
|
+
return <Text>Invalid phone number</Text>;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
|
|
107
|
+
return <Text>Amount is required and should be greater than 0</Text>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<Fragment>
|
|
112
|
+
<View style={styles.full}>
|
|
113
|
+
<WebView
|
|
114
|
+
source={{
|
|
115
|
+
uri: webUrl,
|
|
116
|
+
}}
|
|
117
|
+
style={styles.webview}
|
|
118
|
+
injectedJavaScriptBeforeContentLoaded={onWebviewMount}
|
|
119
|
+
onMessage={onWebviewMessage}
|
|
120
|
+
ref={webviewRef}
|
|
121
|
+
onLoadEnd={() => setWebviewStatus('success')}
|
|
122
|
+
/>
|
|
123
|
+
{webviewStatus === 'loading' && (
|
|
124
|
+
<View style={styles.webviewLoader}>
|
|
125
|
+
<ActivityIndicator size="small" color={color} />
|
|
126
|
+
</View>
|
|
127
|
+
)}
|
|
128
|
+
</View>
|
|
129
|
+
</Fragment>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const styles = StyleSheet.create({
|
|
134
|
+
hide: {
|
|
135
|
+
display: 'none',
|
|
136
|
+
},
|
|
137
|
+
full: {
|
|
138
|
+
flex: 1,
|
|
139
|
+
width: '100%',
|
|
140
|
+
height: '100%',
|
|
141
|
+
},
|
|
142
|
+
webview: {
|
|
143
|
+
flex: 1,
|
|
144
|
+
width: '100%',
|
|
145
|
+
height: '100%',
|
|
146
|
+
},
|
|
147
|
+
webviewLoader: {
|
|
148
|
+
zIndex: 3,
|
|
149
|
+
backgroundColor: 'white',
|
|
150
|
+
alignItems: 'center',
|
|
151
|
+
justifyContent: 'center',
|
|
152
|
+
flex: 1,
|
|
153
|
+
width: '100%',
|
|
154
|
+
height: '100%',
|
|
155
|
+
position: 'absolute',
|
|
156
|
+
top: 0,
|
|
157
|
+
left: 0,
|
|
158
|
+
},
|
|
159
|
+
});
|