@adsesugh/monnify-react-native
Version:
A React Native component for integrating Monnify payment gateway using WebView for both React Native CLI and Expo.
20 lines (19 loc) • 2.5 kB
JavaScript
export var generateHtml = function (paymentParams) {
var apiKey = paymentParams.apiKey, contractCode = paymentParams.contractCode, mode = paymentParams.mode, amount = paymentParams.amount, currency = paymentParams.currency, reference = paymentParams.reference, customerFullName = paymentParams.customerFullName, customerEmail = paymentParams.customerEmail, customerMobileNumber = paymentParams.customerMobileNumber, paymentDescription = paymentParams.paymentDescription, redirectUrl = paymentParams.redirectUrl, metadata = paymentParams.metadata, incomeSplitConfig = paymentParams.incomeSplitConfig;
var config = {
apiKey: apiKey,
contractCode: contractCode,
mode: mode,
amount: amount,
currency: currency,
reference: reference,
customerFullName: customerFullName,
customerEmail: customerEmail,
customerMobileNumber: customerMobileNumber,
paymentDescription: paymentDescription,
redirectUrl: redirectUrl,
metadata: metadata,
incomeSplitConfig: incomeSplitConfig,
};
return "\n \n <html>\n <head>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <script type=\"text/javascript\" src=\"https://sdk.monnify.com/plugin/monnify.js\"></script>\n <script>\n function payWithMonnify() {\n MonnifySDK.initialize({\n ...".concat(JSON.stringify(config), ",\n onLoadStart: () => {\n window.ReactNativeWebView.postMessage(JSON.stringify({ event: 'onLoadStart' }));\n },\n onLoadComplete: () => {\n window.ReactNativeWebView.postMessage(JSON.stringify({ event: 'onLoadComplete' }));\n },\n onComplete: function(response) {\n window.ReactNativeWebView.postMessage(JSON.stringify({ event: 'onComplete', response }));\n },\n onClose: function(data) {\n window.ReactNativeWebView.postMessage(JSON.stringify({ event: 'onClose', data }));\n }\n });\n }\n </script>\n </head>\n <body>\n <script>\n payWithMonnify();\n </script>\n </body>\n </html>\n ");
};