├── .DS_Store ├── .github └── workflows │ └── versioning.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── _config.yml ├── babel.config.js ├── example ├── .DS_Store ├── .expo │ ├── README.md │ ├── packager-info.json │ └── settings.json ├── app.json ├── babel.config.js ├── index.js ├── metro.config.js ├── package.json ├── src │ └── App.tsx ├── tsconfig.json ├── webpack.config.js └── yarn.lock ├── lib ├── commonjs │ ├── build-with-options.js │ ├── build-with-options.js.map │ ├── build-with-short-url.js │ ├── build-with-short-url.js.map │ ├── index.js │ ├── index.js.map │ ├── types.js │ ├── types.js.map │ ├── webview-config.js │ └── webview-config.js.map ├── module │ ├── build-with-options.js │ ├── build-with-options.js.map │ ├── build-with-short-url.js │ ├── build-with-short-url.js.map │ ├── index.js │ ├── index.js.map │ ├── types.js │ ├── types.js.map │ ├── webview-config.js │ └── webview-config.js.map └── typescript │ ├── __tests__ │ └── index.test.d.ts │ ├── build-with-options.d.ts │ ├── build-with-short-url.d.ts │ ├── index.d.ts │ ├── types.d.ts │ └── webview-config.d.ts ├── package.json ├── scripts └── bootstrap.js ├── src ├── __tests__ │ └── index.test.tsx ├── build-with-options.tsx ├── build-with-short-url.tsx ├── index.tsx ├── types.ts └── webview-config.ts ├── tsconfig.build.json ├── tsconfig.json └── yarn.lock /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/just1and0/React-Native-Okra-Webview/0362345de72adaff1445e1ba9652f52eb0275bdc/.DS_Store -------------------------------------------------------------------------------- /.github/workflows/versioning.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - dev 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | strategy: 13 | matrix: 14 | node-version: [12.x, 14.x, 16.x] 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v1 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | 24 | - name: Install packages 25 | run: npm install 26 | 27 | 28 | - name: Release new version 29 | run: npm run release 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. 4 | 5 | ## Development workflow 6 | 7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 8 | 9 | ```sh 10 | yarn 11 | ``` 12 | 13 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development. 14 | 15 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app. 16 | 17 | To start the packager: 18 | 19 | ```sh 20 | yarn example start 21 | ``` 22 | 23 | To run the example app on Android: 24 | 25 | ```sh 26 | yarn example android 27 | ``` 28 | 29 | To run the example app on iOS: 30 | 31 | ```sh 32 | yarn example ios 33 | ``` 34 | 35 | To run the example app on Web: 36 | 37 | ```sh 38 | yarn example web 39 | ``` 40 | 41 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 42 | 43 | ```sh 44 | yarn typescript 45 | yarn lint 46 | ``` 47 | 48 | To fix formatting errors, run the following: 49 | 50 | ```sh 51 | yarn lint --fix 52 | ``` 53 | 54 | Remember to add tests for your change if possible. Run the unit tests by: 55 | 56 | ```sh 57 | yarn test 58 | ``` 59 | 60 | ### Commit message convention 61 | 62 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 63 | 64 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 65 | - `feat`: new features, e.g. add new method to the module. 66 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 67 | - `docs`: changes into documentation, e.g. add usage example for the module.. 68 | - `test`: adding or updating tests, e.g. add integration tests using detox. 69 | - `chore`: tooling changes, e.g. change CI config. 70 | 71 | Our pre-commit hooks verify that your commit message matches this format when committing. 72 | 73 | ### Linting and tests 74 | 75 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 76 | 77 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 78 | 79 | Our pre-commit hooks verify that the linter and tests pass when committing. 80 | 81 | ### Publishing to npm 82 | 83 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc. 84 | 85 | To publish new versions, run the following: 86 | 87 | ```sh 88 | yarn release 89 | ``` 90 | 91 | ### Scripts 92 | 93 | The `package.json` file contains various scripts for common tasks: 94 | 95 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 96 | - `yarn typescript`: type-check files with TypeScript. 97 | - `yarn lint`: lint files with ESLint. 98 | - `yarn test`: run unit tests with Jest. 99 | - `yarn example start`: start the Metro server for the example app. 100 | - `yarn example android`: run the example app on Android. 101 | - `yarn example ios`: run the example app on iOS. 102 | 103 | ### Sending a pull request 104 | 105 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github). 106 | 107 | When you're sending a pull request: 108 | 109 | - Prefer small pull requests focused on one change. 110 | - Verify that linters and tests are passing. 111 | - Review the documentation to make sure it looks good. 112 | - Follow the pull request template when opening a pull request. 113 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 114 | 115 | ## Code of Conduct 116 | 117 | ### Our Pledge 118 | 119 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 120 | 121 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 122 | 123 | ### Our Standards 124 | 125 | Examples of behavior that contributes to a positive environment for our community include: 126 | 127 | - Demonstrating empathy and kindness toward other people 128 | - Being respectful of differing opinions, viewpoints, and experiences 129 | - Giving and gracefully accepting constructive feedback 130 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 131 | - Focusing on what is best not just for us as individuals, but for the overall community 132 | 133 | Examples of unacceptable behavior include: 134 | 135 | - The use of sexualized language or imagery, and sexual attention or 136 | advances of any kind 137 | - Trolling, insulting or derogatory comments, and personal or political attacks 138 | - Public or private harassment 139 | - Publishing others' private information, such as a physical or email 140 | address, without their explicit permission 141 | - Other conduct which could reasonably be considered inappropriate in a 142 | professional setting 143 | 144 | ### Enforcement Responsibilities 145 | 146 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 147 | 148 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 149 | 150 | ### Scope 151 | 152 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 153 | 154 | ### Enforcement 155 | 156 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. 157 | 158 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 159 | 160 | ### Enforcement Guidelines 161 | 162 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 163 | 164 | #### 1. Correction 165 | 166 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 167 | 168 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 169 | 170 | #### 2. Warning 171 | 172 | **Community Impact**: A violation through a single incident or series of actions. 173 | 174 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 175 | 176 | #### 3. Temporary Ban 177 | 178 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 179 | 180 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 181 | 182 | #### 4. Permanent Ban 183 | 184 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 185 | 186 | **Consequence**: A permanent ban from any sort of public interaction within the community. 187 | 188 | ### Attribution 189 | 190 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, 191 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 192 | 193 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 194 | 195 | [homepage]: https://www.contributor-covenant.org 196 | 197 | For answers to common questions about this code of conduct, see the FAQ at 198 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 199 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Oluwatobi Shokunbi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React-Native-Okra-Webview 2 | Official Okra SDK for React Native/Expo applications. Don't forget to star ✨ 3 | 4 | ### About Okra 5 | Okra’s API empowers companies and developers to build products with seamless access to inclusive financial data and secure payments. 6 | 7 | 8 | ![alt text](https://files.readme.io/41dcda7-react-native-black.svg) 9 | 10 | React Native SDK for implementing the OkraJS widget - OkraJS is a safe and secure web drop-in module and this library provides a front-end web (also available in [iOS](https://github.com/okraHQ/okra-ios-sdk) and [Android](https://github.com/okraHQ/okra-android-sdk)) SDK for [account authentication](https://docs.okra.ng/docs/widget-properties) and [payment initiation](https://docs.okra.ng/docs/creating-a-charge) for each bank that Okra [supports](https://docs.okra.ng/docs/bank-coverage). 11 | 12 | ## Try the demo 13 | Checkout the [widget flow](https://okra.ng/) to view how the Okra Widget works. *Click "See How it Works"* 14 | 15 | ## Before getting started 16 | - Checkout our [get started guide](https://docs.okra.ng/docs/get-started-with-okra) to create your developer account and retrieve your Client Token, API Keys, and Private Keys. 17 | - Create a [sandbox customer](https://docs.okra.ng/docs/creating-sandbox-customers), so you can get connecting immediately. 18 | 19 | ## buildWithShortURL 20 | - If you are using the `buildWithShortURL` version, you will first need to [create a link](https://docs.okra.ng/docs/widget-customization) on your dashboard, and use the `short url` returend at the end of the creation flow. 21 | 22 | *Bonus Points* 23 | - Setup [Slack Notifications](https://docs.okra.ng/docs/slack-integration) so you can see your API call statuses and re-run calls in real-time! 24 | 25 | ## Installing 26 | 27 | Using npm: 28 | 29 | ```bash 30 | $ npm install react-native-okra-webview 31 | ``` 32 | 33 | Using yarn: 34 | 35 | ```bash 36 | $ yarn add react-native-okra-webview 37 | ``` 38 | ### you'll also need to install `react-native-webview`, to install run ; 39 | 40 | ```bash 41 | $ yarn add react-native-webview 42 | ``` 43 | 44 | ## Usuage 45 | For React Native based application import it and use 46 | ```js 47 | /** 48 | * Sample React Native App 49 | * https://github.com/facebook/react-native 50 | * 51 | * Generated with the TypeScript template 52 | * https://github.com/react-native-community/react-native-template-typescript 53 | * 54 | * @format 55 | */ 56 | 57 | import React from 'react'; 58 | import { 59 | Alert, 60 | SafeAreaView, 61 | StatusBar, 62 | useColorScheme, 63 | View, 64 | } from 'react-native'; 65 | 66 | import { Okra } from 'react-native-okra-webview'; 67 | 68 | const App = () => { 69 | const isDarkMode = useColorScheme() === 'dark'; 70 | 71 | return ( 72 | 73 | 74 | 75 | 76 | { 79 | Alert.alert('Success!', JSON.stringify(response)) 80 | }} 81 | onClose={(response: any) => { 82 | Alert.alert('error!', JSON.stringify(response)) 83 | }} 84 | /> 85 | 86 | 87 | 88 | ); 89 | }; 90 | 91 | export default App; 92 | ``` 93 | For others, just use 94 | ```js 95 | /** 96 | * Sample React Native App 97 | * https://github.com/facebook/react-native 98 | * 99 | * Generated with the TypeScript template 100 | * https://github.com/react-native-community/react-native-template-typescript 101 | * 102 | * @format 103 | */ 104 | 105 | import React, { useState } from 'react'; 106 | import { 107 | Alert, 108 | SafeAreaView, 109 | StatusBar, 110 | useColorScheme, 111 | View, 112 | } from 'react-native'; 113 | 114 | import { Okra } from 'react-native-okra-webview'; 115 | 116 | const App = () => { 117 | const isDarkMode = useColorScheme() === 'dark'; 118 | 119 | return ( 120 | 121 | 122 | 123 | { 130 | Alert.alert('Success!', JSON.stringify(response)) 131 | }} 132 | onClose={(response: any) => { 133 | Alert.alert('error!', JSON.stringify(response)) 134 | }} 135 | /> 136 | 137 | 138 | ); 139 | }; 140 | 141 | export default App; 142 | ``` 143 | 144 | 145 | ## Okra.buildWithOptions Options 146 | 147 | |Name | Type | Required | Default Value | Description | 148 | |-----------------------|----------------|---------------------|---------------------|---------------------| 149 | | `app_id ` | `String` | true | | Your app id from your Okra Dashboard. 150 | | `okraKey ` | `String` | true | | Your public key from your Okra Dashboard. 151 | | `token ` | `String` | true | | Your token from your Okra Dashboard. 152 | | `env ` | `String` | false |`production` | production(live)/production-sandbox (test) 153 | | `products` | `Array` | true | `['Auth']` | The Okra products you want to use with the widget. 154 | | `payment` | `Booelan` | false | | Whether you want to initiate a payment (https://docs.okra.ng/docs/payments) 155 | | `charge ` | `Object` | false | | Payment charge opject (https://docs.okra.ng/docs/creating-a-charge) 156 | | `products` | `Array` | true | `['Auth']` | The Okra products you want to use with the widget. 157 | | `logo ` | `String(URL)` | false | Okra's Logo | 158 | | `name ` | `String` | false | Your Company's name | Name on the widget 159 | | `color` | `HEX ` | false | #3AB795 | Theme on the widget 160 | | `limit` | `Number` | false | 24 | Statement length 161 | | `filter` | `Object` | false | | Filter for widget 162 | | `isCorporate` | `Boolen` | false | `false` | Corporate or Individual account 163 | | `connectMessage` | `String` | false | | Instruction to connnect account 164 | | `widget_success` | `String` | false | | Widget Success Message 165 | | `widget_failed` | `String` | false | | Widget Failed Message 166 | | `callback_url` | `String(Url)` | false | | 167 | | `currency` | `String` | false | NGN | Wallet to bill 168 | | `exp` | `Date` | false | Won't expire | Expirary date of widget 169 | | `options` | `Object` | false | | You can pass a object custom values eg id 170 | | `onSuccess` | `Function` | false | | Action to perform after widget is successful 171 | | `onClose` | `Function` | false | | Action to perform if widget is closed 172 | | `onError` | `Function` | false | | Action to perform on widget Error 173 | | `BeforeClose` | `Function` | false | | Action to perform before widget close 174 | | `onEvent` | `Function` | false | | Action to perform on widget event 175 | 176 | 177 | View a complete list of customizable options [here](https://docs.okra.ng/docs/widget-properties) 178 | 179 | ## Okra.buildWithShortUrl Options 180 | 181 | |Name | Type | Required | Description | 182 | |-----------------------|----------------|---------------------|---------------------| 183 | | `short_url` | `String` | true | Your generated url from our [App builder](https://docs.okra.ng/docs/widget-customization). 184 | | `onSuccess` | `Function` | false | Action to perform after widget is successful 185 | | `onClose` | `Function` | false | Action to perform if widget is closed 186 | | `onError` | `Function` | false | Action to perform on widget Error 187 | | `BeforeClose` | `Function` | false | Action to perform before widget close 188 | | `onEvent` | `Function` | false | | Action to perform on widget event 189 | 190 | ## Done connecting? 191 | Checkout our [API Overiview](https://docs.okra.ng/docs/api-overview) and see how to use the data you've received and [other products](https://docs.okra.ng/docs/selfie-verification) you can use to create more personalized experiences for your customers! 192 | 193 | ## Not a developer? 194 | Get started without writing a single line of code, Try our App Builder! [Click here to get started](https://dash.okra.ng/link-builder) 195 | 196 | ## Thanks & Credits 197 | - (Bob RN package template)[https://github.com/callstack/react-native-builder-bob] 198 | - (okraHQ/okra-react-native docs)[https://github.com/okraHQ/okra-react-native/blob/master/README.md] 199 | 200 | ## Contributions 201 | 202 | Want to help make this package even more awesome? feel free to send in your PR to dev branch and we'd review it and ensure it gets added to the next release 😊 203 | 204 | ## Licensing 205 | 206 | This project is licensed under MIT license. 207 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/just1and0/React-Native-Okra-Webview/0362345de72adaff1445e1ba9652f52eb0275bdc/example/.DS_Store -------------------------------------------------------------------------------- /example/.expo/README.md: -------------------------------------------------------------------------------- 1 | > Why do I have a folder named ".expo" in my project? 2 | 3 | The ".expo" folder is created when an Expo project is started using "expo start" command. 4 | 5 | > What does the "packager-info.json" file contain? 6 | 7 | The "packager-info.json" file contains port numbers and process PIDs that are used to serve the application to the mobile device/simulator. 8 | 9 | > What does the "settings.json" file contain? 10 | 11 | The "settings.json" file contains the server configuration that is used to serve the application manifest. 12 | 13 | > Should I commit the ".expo" folder? 14 | 15 | No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine. 16 | 17 | Upon project creation, the ".expo" folder is already added to your ".gitignore" file. 18 | -------------------------------------------------------------------------------- /example/.expo/packager-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "devToolsPort": 19002, 3 | "expoServerPort": null, 4 | "packagerPort": 19000, 5 | "packagerPid": null, 6 | "expoServerNgrokUrl": null, 7 | "packagerNgrokUrl": null, 8 | "ngrokPid": null, 9 | "webpackServerPort": null 10 | } 11 | -------------------------------------------------------------------------------- /example/.expo/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "hostType": "lan", 3 | "lanType": "ip", 4 | "dev": true, 5 | "minify": false, 6 | "urlRandomness": null, 7 | "https": false, 8 | "scheme": null, 9 | "devClient": false 10 | } 11 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-okra-webview-example", 3 | "displayName": "OkraWebview Example", 4 | "expo": { 5 | "name": "react-native-okra-webview-example", 6 | "slug": "react-native-okra-webview-example", 7 | "description": "Example app for react-native-okra-webview", 8 | "privacy": "public", 9 | "version": "1.0.0", 10 | "platforms": [ 11 | "ios", 12 | "android", 13 | "web" 14 | ], 15 | "ios": { 16 | "supportsTablet": true 17 | }, 18 | "assetBundlePatterns": [ 19 | "**/*" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = function (api) { 5 | api.cache(true); 6 | 7 | return { 8 | presets: ['babel-preset-expo'], 9 | plugins: [ 10 | [ 11 | 'module-resolver', 12 | { 13 | extensions: ['.tsx', '.ts', '.js', '.json'], 14 | alias: { 15 | // For development, we want to alias the library to the source 16 | [pak.name]: path.join(__dirname, '..', pak.source), 17 | }, 18 | }, 19 | ], 20 | ], 21 | }; 22 | }; 23 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | import { registerRootComponent } from 'expo'; 2 | 3 | import App from './src/App'; 4 | 5 | // registerRootComponent calls AppRegistry.registerComponent('main', () => App); 6 | // It also ensures that whether you load the app in the Expo client or in a native build, 7 | // the environment is set up appropriately 8 | registerRootComponent(App); 9 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const blacklist = require('metro-config/src/defaults/blacklist'); 3 | const escape = require('escape-string-regexp'); 4 | const pak = require('../package.json'); 5 | 6 | const root = path.resolve(__dirname, '..'); 7 | 8 | const modules = Object.keys({ 9 | ...pak.peerDependencies, 10 | }); 11 | 12 | module.exports = { 13 | projectRoot: __dirname, 14 | watchFolders: [root], 15 | 16 | // We need to make sure that only one version is loaded for peerDependencies 17 | // So we blacklist them at the root, and alias them to the versions in example's node_modules 18 | resolver: { 19 | blacklistRE: blacklist( 20 | modules.map( 21 | (m) => 22 | new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) 23 | ) 24 | ), 25 | 26 | extraNodeModules: modules.reduce((acc, name) => { 27 | acc[name] = path.join(__dirname, 'node_modules', name); 28 | return acc; 29 | }, {}), 30 | }, 31 | 32 | transformer: { 33 | getTransformOptions: async () => ({ 34 | transform: { 35 | experimentalImportSupport: false, 36 | inlineRequires: true, 37 | }, 38 | }), 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-okra-webview-example", 3 | "description": "Example app for react-native-okra-webview", 4 | "version": "0.0.1", 5 | "private": true, 6 | "main": "index", 7 | "scripts": { 8 | "android": "expo start --android", 9 | "ios": "expo start --ios", 10 | "web": "expo start --web", 11 | "start": "expo start", 12 | "test": "jest" 13 | }, 14 | "dependencies": { 15 | "expo": "^42.0.0", 16 | "expo-splash-screen": "~0.11.2", 17 | "react": "16.13.1", 18 | "react-dom": "16.13.1", 19 | "react-native": "0.63.4", 20 | "react-native-okra-webview": "^0.0.9", 21 | "react-native-unimodules": "~0.14.5", 22 | "react-native-web": "~0.13.12", 23 | "react-native-webview": "^11.17.1" 24 | }, 25 | "devDependencies": { 26 | "@babel/core": "~7.9.0", 27 | "@babel/runtime": "^7.9.6", 28 | "babel-plugin-module-resolver": "^4.0.0", 29 | "babel-preset-expo": "8.3.0", 30 | "expo-cli": "^4.0.13" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | import { StyleSheet, View, Text, Alert } from 'react-native'; 4 | import { Okra } from 'react-native-okra-webview'; 5 | 6 | 7 | export default function App() { 8 | const handleResponse = (response:any, type:'success' | 'error') => { 9 | Alert.alert(type, JSON.stringify(response)) 10 | console.log(type, JSON.stringify(response)) 11 | } 12 | 13 | return ( 14 | 15 | Demo: Build with ShortUrl 16 | '} 18 | onSuccess={(response: any) => handleResponse(response, 'success')} 19 | onClose={(response: any) => { 20 | handleResponse(response, 'error') 21 | }} 22 | /> 23 | 24 | ); 25 | } 26 | 27 | const styles = StyleSheet.create({ 28 | container: { 29 | flex: 1, 30 | alignItems: 'center', 31 | justifyContent: 'center', 32 | }, 33 | box: { 34 | width: 60, 35 | height: 60, 36 | marginVertical: 20, 37 | }, 38 | }); 39 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": {}, 3 | "extends": "expo/tsconfig.base" 4 | } 5 | -------------------------------------------------------------------------------- /example/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const createExpoWebpackConfigAsync = require('@expo/webpack-config'); 3 | const { resolver } = require('./metro.config'); 4 | 5 | const root = path.resolve(__dirname, '..'); 6 | const node_modules = path.join(__dirname, 'node_modules'); 7 | 8 | module.exports = async function (env, argv) { 9 | const config = await createExpoWebpackConfigAsync(env, argv); 10 | 11 | config.module.rules.push({ 12 | test: /\.(js|jsx|ts|tsx)$/, 13 | include: path.resolve(root, 'src'), 14 | use: 'babel-loader', 15 | }); 16 | 17 | // We need to make sure that only one version is loaded for peerDependencies 18 | // So we alias them to the versions in example's node_modules 19 | Object.assign(config.resolve.alias, { 20 | ...resolver.extraNodeModules, 21 | 'react-native-web': path.join(node_modules, 'react-native-web'), 22 | }); 23 | 24 | return config; 25 | }; 26 | -------------------------------------------------------------------------------- /lib/commonjs/build-with-options.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = void 0; 7 | 8 | var _react = _interopRequireWildcard(require("react")); 9 | 10 | var _reactNative = require("react-native"); 11 | 12 | var _reactNativeWebview = require("react-native-webview"); 13 | 14 | var _webviewConfig = require("./webview-config"); 15 | 16 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 17 | 18 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 19 | 20 | const BuildWithOptions = props => { 21 | const { 22 | name, 23 | env, 24 | okraKey, 25 | token, 26 | products, 27 | color, 28 | logo, 29 | payment, 30 | filter, 31 | isCorporate, 32 | limit, 33 | callback_url, 34 | connectMessage, 35 | currency, 36 | widget_success, 37 | widget_failed, 38 | exp, 39 | onSuccess, 40 | onClose, 41 | onError, 42 | BeforeClose, 43 | onEvent 44 | } = props; 45 | const [toggleModal, setToggleModal] = (0, _react.useState)(true); 46 | const [isLoading, setisLoading] = (0, _react.useState)(true); 47 | 48 | const onTransactionSuccess = res => { 49 | onSuccess({ 50 | status: 'options success', 51 | res 52 | }); 53 | }; 54 | 55 | const onTransactionCloseConfirmation = () => { 56 | _reactNative.Alert.alert("End Transaction", "You are about to end this transaction, Are you sure you want to do this?", [{ 57 | text: "No", 58 | onPress: () => onTransactionClose() 59 | }, { 60 | text: "Yes", 61 | onPress: () => { 62 | onTransactionClose(), setToggleModal(false); 63 | }, 64 | style: "cancel" 65 | }], { 66 | cancelable: true 67 | }); 68 | }; 69 | 70 | const onTransactionClose = () => { 71 | onClose({ 72 | status: 'options close' 73 | }); 74 | }; 75 | 76 | const onTransactionError = res => { 77 | onError && onError({ 78 | status: 'options error', 79 | res 80 | }); 81 | }; 82 | 83 | const onTransactionBeforeClose = () => { 84 | BeforeClose && BeforeClose(); 85 | }; 86 | 87 | const messageReceived = data => { 88 | const webResponse = JSON.parse(data); 89 | 90 | switch (webResponse.event) { 91 | case 'option success': 92 | onTransactionSuccess(webResponse); 93 | break; 94 | 95 | case 'option close': 96 | onTransactionClose(); 97 | break; 98 | 99 | case 'option error': 100 | onTransactionError(webResponse); 101 | break; 102 | 103 | case 'option before close': 104 | onTransactionBeforeClose(); 105 | break; 106 | 107 | case 'option event': 108 | onEvent && onEvent(webResponse); 109 | break; 110 | 111 | default: 112 | onTransactionClose(); 113 | break; 114 | } 115 | }; 116 | 117 | const onNavigationStateChange = state => { 118 | const { 119 | url 120 | } = state; 121 | if (!url) return; 122 | 123 | if (url.includes('shouldClose=true')) { 124 | onTransactionClose(); 125 | } 126 | }; 127 | 128 | return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Modal, { 129 | visible: toggleModal, 130 | animationType: 'slide' 131 | }, /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, { 132 | style: { 133 | flex: 1 134 | } 135 | }, /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, { 136 | source: { 137 | html: (0, _webviewConfig.OptionWebViewConfig)({ 138 | name, 139 | env, 140 | okraKey, 141 | token, 142 | products, 143 | color, 144 | logo, 145 | payment, 146 | filter, 147 | isCorporate, 148 | limit, 149 | callback_url, 150 | connectMessage, 151 | currency, 152 | widget_success, 153 | widget_failed, 154 | exp 155 | }) 156 | }, 157 | onMessage: e => { 158 | var _e$nativeEvent; 159 | 160 | messageReceived((_e$nativeEvent = e.nativeEvent) === null || _e$nativeEvent === void 0 ? void 0 : _e$nativeEvent.data); 161 | }, 162 | onLoadStart: () => setisLoading(true), 163 | onLoadEnd: () => setisLoading(false), 164 | onNavigationStateChange: onNavigationStateChange, 165 | cacheEnabled: false, 166 | cacheMode: 'LOAD_NO_CACHE' 167 | }), /*#__PURE__*/_react.default.createElement(_reactNative.View, { 168 | style: { 169 | backgroundColor: color ? color : 'rgb(58, 183, 149)', 170 | justifyContent: 'space-between', 171 | alignItems: 'center', 172 | paddingVertical: 15, 173 | flexDirection: 'row' 174 | } 175 | }, /*#__PURE__*/_react.default.createElement(_reactNative.View, { 176 | style: { 177 | flex: 1 178 | } 179 | }, isLoading && /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, { 180 | size: "large", 181 | color: 'white' 182 | }))), /*#__PURE__*/_react.default.createElement(_reactNative.View, { 183 | style: { 184 | flex: 3, 185 | paddingHorizontal: 15 186 | } 187 | }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, { 188 | onPress: () => onTransactionCloseConfirmation() 189 | }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, { 190 | style: { 191 | color: 'white', 192 | fontWeight: 'bold', 193 | alignSelf: 'flex-end' 194 | } 195 | }, "close"))))))); 196 | }; 197 | 198 | var _default = BuildWithOptions; 199 | exports.default = _default; 200 | //# sourceMappingURL=build-with-options.js.map -------------------------------------------------------------------------------- /lib/commonjs/build-with-options.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["build-with-options.tsx"],"names":["BuildWithOptions","props","name","env","okraKey","token","products","color","logo","payment","filter","isCorporate","limit","callback_url","connectMessage","currency","widget_success","widget_failed","exp","onSuccess","onClose","onError","BeforeClose","onEvent","toggleModal","setToggleModal","isLoading","setisLoading","onTransactionSuccess","res","status","onTransactionCloseConfirmation","Alert","alert","text","onPress","onTransactionClose","style","cancelable","onTransactionError","onTransactionBeforeClose","messageReceived","data","webResponse","JSON","parse","event","onNavigationStateChange","state","url","includes","flex","html","e","nativeEvent","backgroundColor","justifyContent","alignItems","paddingVertical","flexDirection","paddingHorizontal","fontWeight","alignSelf"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAEA,MAAMA,gBAAgB,GAAIC,KAAD,IAAsC;AAC3D,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,GAAR;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,KAAtB;AAA6BC,IAAAA,QAA7B;AAAuCC,IAAAA,KAAvC;AAA8CC,IAAAA,IAA9C;AAAoDC,IAAAA,OAApD;AAA6DC,IAAAA,MAA7D;AAAqEC,IAAAA,WAArE;AAAkFC,IAAAA,KAAlF;AAAyFC,IAAAA,YAAzF;AAAuGC,IAAAA,cAAvG;AAAuHC,IAAAA,QAAvH;AAAiIC,IAAAA,cAAjI;AAAiJC,IAAAA,aAAjJ;AAAgKC,IAAAA,GAAhK;AAAqKC,IAAAA,SAArK;AAAgLC,IAAAA,OAAhL;AAAyLC,IAAAA,OAAzL;AAAkMC,IAAAA,WAAlM;AAA+MC,IAAAA;AAA/M,MAA2NtB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0He9D,gB","sourcesContent":["import React, { useState } from 'react';\nimport { View, Modal, Text, TouchableOpacity, SafeAreaView, ActivityIndicator, Alert } from 'react-native'\nimport { OkraBuildWithOptionsProps } from './types';\nimport { WebView, WebViewNavigation } from 'react-native-webview';\nimport { OptionWebViewConfig } from './webview-config';\n\nconst BuildWithOptions = (props: OkraBuildWithOptionsProps) => {\n const { name, env, okraKey, token, products, color, logo, payment, filter, isCorporate, limit, callback_url, connectMessage, currency, widget_success, widget_failed, exp, onSuccess, onClose, onError, BeforeClose, onEvent } = props;\n\n const [toggleModal, setToggleModal] = useState(true)\n const [isLoading, setisLoading] = useState(true);\n\n const onTransactionSuccess = (res: any) => {\n onSuccess({ status: 'options success', res })\n }\n\n const onTransactionCloseConfirmation = () => {\n Alert.alert(\n \"End Transaction\",\n \"You are about to end this transaction, Are you sure you want to do this?\",\n [\n {\n text: \"No\",\n onPress: () => onTransactionClose()\n },\n {\n text: \"Yes\",\n onPress: () => { onTransactionClose(), setToggleModal(false) },\n style: \"cancel\",\n },\n ],\n {\n cancelable: true\n }\n );\n }\n\n const onTransactionClose = () => {\n onClose({ status: 'options close' })\n }\n\n\n const onTransactionError = (res: any) => {\n onError && onError({ status: 'options error', res })\n }\n\n const onTransactionBeforeClose = () => {\n BeforeClose && BeforeClose()\n }\n\n const messageReceived = (data: string) => {\n const webResponse = JSON.parse(data);\n\n switch (webResponse.event) {\n case 'option success':\n onTransactionSuccess(webResponse)\n break;\n\n case 'option close':\n onTransactionClose()\n break;\n\n case 'option error':\n onTransactionError(webResponse)\n break;\n\n case 'option before close':\n onTransactionBeforeClose()\n break;\n\n case 'option event':\n onEvent && onEvent(webResponse);\n break\n\n\n default:\n onTransactionClose()\n break;\n }\n };\n\n const onNavigationStateChange = (state: WebViewNavigation) => {\n const { url } = state;\n if (!url) return;\n if (url.includes('shouldClose=true')) {\n onTransactionClose()\n }\n };\n\n return (\n \n \n \n {\n messageReceived(e.nativeEvent?.data);\n }}\n onLoadStart={() => setisLoading(true)}\n onLoadEnd={() => setisLoading(false)}\n onNavigationStateChange={onNavigationStateChange}\n cacheEnabled={false}\n cacheMode={'LOAD_NO_CACHE'}\n />\n\n \n \n {isLoading && (\n \n \n \n )}\n \n \n onTransactionCloseConfirmation()}>\n \n close\n \n \n \n \n\n \n \n \n )\n}\n\nexport default BuildWithOptions;\n"]} -------------------------------------------------------------------------------- /lib/commonjs/build-with-short-url.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.default = void 0; 7 | 8 | var _react = _interopRequireWildcard(require("react")); 9 | 10 | var _reactNative = require("react-native"); 11 | 12 | var _reactNativeWebview = require("react-native-webview"); 13 | 14 | var _webviewConfig = require("./webview-config"); 15 | 16 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } 17 | 18 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 19 | 20 | const BuildWithShortUrl = props => { 21 | const { 22 | short_url, 23 | onSuccess, 24 | onClose, 25 | onError, 26 | BeforeClose, 27 | onEvent 28 | } = props; 29 | const [toggleModal, setToggleModal] = (0, _react.useState)(true); 30 | const [isLoading, setIsLoading] = (0, _react.useState)(true); 31 | 32 | const onTransactionSuccess = res => { 33 | onSuccess({ 34 | status: 'options success', 35 | res 36 | }); 37 | }; 38 | 39 | const onTransactionCloseConfirmation = () => { 40 | _reactNative.Alert.alert("End Transaction", "You are about to end this transaction, Are you sure you want to do this?", [{ 41 | text: "No", 42 | onPress: () => onTransactionClose() 43 | }, { 44 | text: "Yes", 45 | onPress: () => { 46 | onTransactionClose(), setToggleModal(false); 47 | }, 48 | style: "cancel" 49 | }], { 50 | cancelable: true 51 | }); 52 | }; 53 | 54 | const onTransactionClose = () => { 55 | onClose({ 56 | status: 'options close' 57 | }); 58 | }; 59 | 60 | const onTransactionError = res => { 61 | onError && onError({ 62 | status: 'options error', 63 | res 64 | }); 65 | }; 66 | 67 | const onTransactionBeforeClose = () => { 68 | BeforeClose && BeforeClose(); 69 | }; 70 | 71 | const messageReceived = data => { 72 | const webResponse = JSON.parse(data); 73 | 74 | switch (webResponse.event) { 75 | case 'option success': 76 | onTransactionSuccess(webResponse); 77 | break; 78 | 79 | case 'option close': 80 | onTransactionClose(); 81 | break; 82 | 83 | case 'option error': 84 | onTransactionError(webResponse); 85 | break; 86 | 87 | case 'option before close': 88 | onTransactionBeforeClose(); 89 | break; 90 | 91 | case 'option event': 92 | onEvent && onEvent(webResponse); 93 | break; 94 | 95 | default: 96 | onTransactionClose(); 97 | break; 98 | } 99 | }; 100 | 101 | const onNavigationStateChange = state => { 102 | const { 103 | url 104 | } = state; 105 | if (!url) return; 106 | 107 | if (url.includes('shouldClose=true')) { 108 | onTransactionClose(); 109 | } 110 | }; 111 | 112 | return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Modal, { 113 | visible: toggleModal, 114 | animationType: 'slide' 115 | }, /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, { 116 | style: { 117 | flex: 1 118 | } 119 | }, /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, { 120 | source: { 121 | html: (0, _webviewConfig.ShortUrlWebViewConfig)({ 122 | short_url 123 | }) 124 | }, 125 | onMessage: e => { 126 | var _e$nativeEvent; 127 | 128 | messageReceived((_e$nativeEvent = e.nativeEvent) === null || _e$nativeEvent === void 0 ? void 0 : _e$nativeEvent.data); 129 | }, 130 | onLoadStart: () => setIsLoading(true), 131 | onLoadEnd: () => setIsLoading(false), 132 | onNavigationStateChange: onNavigationStateChange, 133 | cacheEnabled: false, 134 | cacheMode: 'LOAD_NO_CACHE' 135 | }), /*#__PURE__*/_react.default.createElement(_reactNative.View, { 136 | style: { 137 | backgroundColor: 'rgb(58, 183, 149)', 138 | justifyContent: 'space-between', 139 | alignItems: 'center', 140 | paddingVertical: 15, 141 | flexDirection: 'row' 142 | } 143 | }, /*#__PURE__*/_react.default.createElement(_reactNative.View, { 144 | style: { 145 | flex: 1 146 | } 147 | }, isLoading && /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, { 148 | size: "large", 149 | color: 'white' 150 | }))), /*#__PURE__*/_react.default.createElement(_reactNative.View, { 151 | style: { 152 | flex: 3, 153 | paddingHorizontal: 15 154 | } 155 | }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, { 156 | onPress: () => onTransactionCloseConfirmation() 157 | }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, { 158 | style: { 159 | color: 'white', 160 | fontWeight: 'bold', 161 | alignSelf: 'flex-end' 162 | } 163 | }, "close"))))))); 164 | }; 165 | 166 | var _default = BuildWithShortUrl; 167 | exports.default = _default; 168 | //# sourceMappingURL=build-with-short-url.js.map -------------------------------------------------------------------------------- /lib/commonjs/build-with-short-url.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["build-with-short-url.tsx"],"names":["BuildWithShortUrl","props","short_url","onSuccess","onClose","onError","BeforeClose","onEvent","toggleModal","setToggleModal","isLoading","setIsLoading","onTransactionSuccess","res","status","onTransactionCloseConfirmation","Alert","alert","text","onPress","onTransactionClose","style","cancelable","onTransactionError","onTransactionBeforeClose","messageReceived","data","webResponse","JSON","parse","event","onNavigationStateChange","state","url","includes","flex","html","e","nativeEvent","backgroundColor","justifyContent","alignItems","paddingVertical","flexDirection","paddingHorizontal","color","fontWeight","alignSelf"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAEA,MAAMA,iBAAiB,GAAIC,KAAD,IAAuC;AAC7D,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,SAAb;AAAwBC,IAAAA,OAAxB;AAAiCC,IAAAA,OAAjC;AAA0CC,IAAAA,WAA1C;AAAuDC,IAAAA;AAAvD,MAAmEN,KAAzE;AAEA,QAAM,CAACO,WAAD,EAAcC,cAAd,IAAgC,qBAAS,IAAT,CAAtC;AACA,QAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4B,qBAAS,IAAT,CAAlC;;AAEA,QAAMC,oBAAoB,GAAIC,GAAD,IAAc;AAEvCV,IAAAA,SAAS,CAAC;AAAEW,MAAAA,MAAM,EAAE,iBAAV;AAA6BD,MAAAA;AAA7B,KAAD,CAAT;AAEH,GAJD;;AAMA,QAAME,8BAA8B,GAAG,MAAM;AACzCC,uBAAMC,KAAN,CACI,iBADJ,EAEI,0EAFJ,EAGI,CACI;AACIC,MAAAA,IAAI,EAAE,IADV;AAEIC,MAAAA,OAAO,EAAE,MAAMC,kBAAkB;AAFrC,KADJ,EAKI;AACIF,MAAAA,IAAI,EAAE,KADV;AAEIC,MAAAA,OAAO,EAAE,MAAM;AAAEC,QAAAA,kBAAkB,IAAIX,cAAc,CAAC,KAAD,CAApC;AAA6C,OAFlE;AAGIY,MAAAA,KAAK,EAAE;AAHX,KALJ,CAHJ,EAcI;AACIC,MAAAA,UAAU,EAAE;AADhB,KAdJ;AAkBH,GAnBD;;AAqBA,QAAMF,kBAAkB,GAAG,MAAM;AAC7BhB,IAAAA,OAAO,CAAC;AAAEU,MAAAA,M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J,CADJ,CARJ,CAZJ,CADJ,CADJ,CADJ;AAoCH,CA1HD;;eA4He/C,iB","sourcesContent":["import React, { useState } from 'react';\nimport { View, Modal, SafeAreaView, ActivityIndicator, TouchableOpacity, Text, Alert } from 'react-native'\nimport { OkraBuildWithShortUrlProps } from './types';\nimport { WebView, WebViewNavigation } from 'react-native-webview';\nimport { ShortUrlWebViewConfig } from './webview-config';\n\nconst BuildWithShortUrl = (props: OkraBuildWithShortUrlProps) => {\n const { short_url, onSuccess, onClose, onError, BeforeClose, onEvent } = props;\n\n const [toggleModal, setToggleModal] = useState(true)\n const [isLoading, setIsLoading] = useState(true);\n\n const onTransactionSuccess = (res: any) => {\n\n onSuccess({ status: 'options success', res })\n\n }\n\n const onTransactionCloseConfirmation = () => {\n Alert.alert(\n \"End Transaction\",\n \"You are about to end this transaction, Are you sure you want to do this?\",\n [\n {\n text: \"No\",\n onPress: () => onTransactionClose()\n },\n {\n text: \"Yes\",\n onPress: () => { onTransactionClose(), setToggleModal(false) },\n style: \"cancel\",\n },\n ],\n {\n cancelable: true\n }\n );\n }\n\n const onTransactionClose = () => {\n onClose({ status: 'options close' })\n\n }\n\n const onTransactionError = (res: any) => {\n onError && onError({ status: 'options error', res })\n\n }\n\n const onTransactionBeforeClose = () => {\n BeforeClose && BeforeClose()\n\n }\n\n const messageReceived = (data: string) => {\n const webResponse = JSON.parse(data);\n\n switch (webResponse.event) {\n case 'option success':\n onTransactionSuccess(webResponse)\n break;\n\n case 'option close':\n onTransactionClose()\n break;\n\n case 'option error':\n onTransactionError(webResponse)\n break;\n\n case 'option before close':\n onTransactionBeforeClose()\n break;\n\n case 'option event':\n onEvent && onEvent(webResponse);\n break\n\n default:\n onTransactionClose()\n break;\n }\n };\n\n const onNavigationStateChange = (state: WebViewNavigation) => {\n const { url } = state;\n if (!url) return;\n if (url.includes('shouldClose=true')) {\n onTransactionClose()\n }\n };\n\n return (\n \n \n \n {\n messageReceived(e.nativeEvent?.data);\n }}\n onLoadStart={() => setIsLoading(true)}\n onLoadEnd={() => setIsLoading(false)}\n onNavigationStateChange={onNavigationStateChange}\n cacheEnabled={false}\n cacheMode={'LOAD_NO_CACHE'}\n />\n \n \n {isLoading && (\n \n \n \n )}\n \n \n onTransactionCloseConfirmation()}>\n \n close\n \n \n \n \n \n \n\n \n )\n}\n\nexport default BuildWithShortUrl;\n"]} -------------------------------------------------------------------------------- /lib/commonjs/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.Okra = void 0; 7 | 8 | var _buildWithShortUrl = _interopRequireDefault(require("./build-with-short-url")); 9 | 10 | var _buildWithOptions = _interopRequireDefault(require("./build-with-options")); 11 | 12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 13 | 14 | const Okra = { 15 | BuildWithShortUrl: _buildWithShortUrl.default, 16 | BuildWithOptions: _buildWithOptions.default 17 | }; 18 | exports.Okra = Okra; 19 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /lib/commonjs/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["index.tsx"],"names":["Okra","BuildWithShortUrl","BuildWithOptions"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEA,MAAMA,IAAI,GAAG;AACXC,EAAAA,iBAAiB,EAAjBA,0BADW;AAEXC,EAAAA,gBAAgB,EAAhBA;AAFW,CAAb","sourcesContent":["import BuildWithShortUrl from './build-with-short-url'\nimport BuildWithOptions from './build-with-options';\n\nconst Okra = {\n BuildWithShortUrl,\n BuildWithOptions\n}\nexport { Okra }\n"]} -------------------------------------------------------------------------------- /lib/commonjs/types.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | let product; 4 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /lib/commonjs/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["types.ts"],"names":["product"],"mappings":";;AAAA,IAAIA,OAAJ","sourcesContent":["let product: string[];\n\nexport interface OkraBuildWithOptionsProps {\n name: string;\n env: string;\n app_id?: string;\n okraKey: string;\n token: string;\n products: typeof product;\n exp?:Date;\n currency?:string;\n callback_url?:string;\n widget_failed?:string;\n widget_success?:string;\n connectMessage?:string;\n isCorporate?:boolean;\n filter?:any[];\n limit?:number;\n color?:string;\n logo?:string;\n charge?:string[];\n payment?:boolean\n onSuccess: (e: any) => void;\n onClose: (e: any) => void;\n BeforeClose?: () => void;\n onError?: (e:any) => void;\n onEvent?: (e:any) => void;\n\n}\n\nexport interface OkraBuildWithShortUrlProps {\n short_url: string;\n onSuccess: (e: any) => void;\n onClose: (e: any) => void;\n BeforeClose?: () => void;\n onError?: (e:any) => void;\n onEvent?: (e:any) => void;\n}\n\nexport interface ShortUrlWebViewConfigProps {\n short_url: string;\n}\n\nexport interface OptionWebViewConfigProps {\n name: string;\n env: string;\n app_id?: string;\n okraKey: string;\n token: string;\n products: typeof product;\n exp?:Date;\n currency?:string;\n callback_url?:string;\n widget_failed?:string;\n widget_success?:string;\n connectMessage?:string;\n isCorporate?:boolean;\n filter?:any[];\n limit?:number;\n color?:string;\n logo?:string;\n charge?:chargeProps;\n payment?:boolean\n}\n\ninterface chargeProps {\n type:type;\n amount:number | null;\n note?:string;\n currency?:string;\n account:string;\n}\n\ntype type = 'one-time' | 'recurring';"]} -------------------------------------------------------------------------------- /lib/commonjs/webview-config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.ShortUrlWebViewConfig = exports.OptionWebViewConfig = void 0; 7 | 8 | const ShortUrlWebViewConfig = props => ` 9 | 10 | 11 | 12 | 13 | 14 | 15 | Okra React Native SDK 16 | 17 | 18 | 19 | 20 | 52 | 53 | 54 | 55 | `; 56 | 57 | exports.ShortUrlWebViewConfig = ShortUrlWebViewConfig; 58 | 59 | const OptionWebViewConfig = props => { 60 | const { 61 | color 62 | } = props; 63 | let setLogo = props.logo ? props.logo : `https://media-exp1.licdn.com/dms/image/C4D0BAQHC76UBZ4sKVQ/company-logo_200_200/0/1573671434447?e=1644451200&v=beta&t=roLpHuqKsAsFGpfP39Ne5bqWKOWsBc0pB3Una1fK0WU`; 64 | let setColor = color ? color : 'rgb(58, 183, 149)'; 65 | let setPayment = props.payment ? `${props.payment}` : 'false'; 66 | let setProducts = props.products && `products:${JSON.stringify(props.products)},`; 67 | let setFilter = props.filter ? `filter:${JSON.stringify(props.filter)},` : `filter:${JSON.stringify([])},`; 68 | let setCharge = props.charge ? `charge:${JSON.stringify(props.charge)},` : `filter:${JSON.stringify([])},`; 69 | let setIsCorporate = props.isCorporate ? `${props.isCorporate}` : 'false'; 70 | let setcallback_url = props.callback_url ? `${props.callback_url}` : null; 71 | let setConnectMessage = props.connectMessage ? `${props.connectMessage}` : null; 72 | let setwidget_success = props.widget_success ? `${props.widget_success}` : `Your account was linked successfully with ${props.name}`; 73 | let setwidget_failed = props.widget_failed ? `${props.widget_failed}` : `Something went wrong while linking your account to ${props.name}`; 74 | let setExp = props.exp ? `${props.exp}` : null; 75 | let setCurrency = props.currency ? `${props.currency}` : 'NGN'; 76 | let setLimit = props.limit ? `${props.limit}` : null; 77 | return ` 78 | 79 | 80 | 81 | 82 | 83 | 84 | Okra React Native SDK 85 | 86 | 87 | 88 | 89 | 137 | 138 | 139 | 140 | `; 141 | }; 142 | 143 | exports.OptionWebViewConfig = OptionWebViewConfig; 144 | //# sourceMappingURL=webview-config.js.map -------------------------------------------------------------------------------- /lib/commonjs/webview-config.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webview-config.ts"],"names":["ShortUrlWebViewConfig","props","short_url","OptionWebViewConfig","color","setLogo","logo","setColor","setPayment","payment","setProducts","products","JSON","stringify","setFilter","filter","setCharge","charge","setIsCorporate","isCorporate","setcallback_url","callback_url","setConnectMessage","connectMessage","setwidget_success","widget_success","name","setwidget_failed","widget_failed","setExp","exp","setCurrency","currency","setLimit","limit","env","app_id","ok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,gBAAiB;AAClD,4BAA4BI,WAAY;AACxC,kBAAkBjB,SAAU;AAC5B,0BAA0BP,QAAS;AACnC,yBAAyB0B,QAAS;AAClC,kBAAkBvB,WAAY;AAC9B,kBAAkBM,SAAU;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA/DE;AAgED,CArFD","sourcesContent":["import { OptionWebViewConfigProps, ShortUrlWebViewConfigProps } from './types';\n\nconst ShortUrlWebViewConfig = (props: ShortUrlWebViewConfigProps) => ` \n \n \n \n \n \n \n Okra React Native SDK\n \n \n\n \n \n \n\n \n`;\n\nconst OptionWebViewConfig = (props: OptionWebViewConfigProps) => {\n const { color } = props;\n\n\n let setLogo = props.logo\n ? props.logo\n : `https://media-exp1.licdn.com/dms/image/C4D0BAQHC76UBZ4sKVQ/company-logo_200_200/0/1573671434447?e=1644451200&v=beta&t=roLpHuqKsAsFGpfP39Ne5bqWKOWsBc0pB3Una1fK0WU`;\n let setColor = color ? color : 'rgb(58, 183, 149)';\n let setPayment = props.payment ? `${props.payment}` : 'false';\n let setProducts = props.products && `products:${JSON.stringify(props.products)},`;\n let setFilter = props.filter ? `filter:${JSON.stringify(props.filter)},` : `filter:${JSON.stringify([])},`;\n let setCharge = props.charge ? `charge:${JSON.stringify(props.charge)},` : `filter:${JSON.stringify([])},`;\n let setIsCorporate = props.isCorporate ? `${props.isCorporate}` : 'false';\n let setcallback_url = props.callback_url ? `${props.callback_url}` : null;\n let setConnectMessage = props.connectMessage ? `${props.connectMessage}` : null;\n let setwidget_success = props.widget_success ? `${props.widget_success}` : `Your account was linked successfully with ${props.name}`;\n let setwidget_failed = props.widget_failed ? `${props.widget_failed}` : `Something went wrong while linking your account to ${props.name}`;\n let setExp = props.exp ? `${props.exp}` : null;\n let setCurrency = props.currency ? `${props.currency}` : 'NGN';\n let setLimit = props.limit ? `${props.limit}` : null;\n\n return ` \n\n\n \n \n \n \n Okra React Native SDK\n \n \n\n \n \n \n\n \n`;\n};\n\nexport { ShortUrlWebViewConfig, OptionWebViewConfig };"]} -------------------------------------------------------------------------------- /lib/module/build-with-options.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { View, Modal, Text, TouchableOpacity, SafeAreaView, ActivityIndicator, Alert } from 'react-native'; 3 | import { WebView } from 'react-native-webview'; 4 | import { OptionWebViewConfig } from './webview-config'; 5 | 6 | const BuildWithOptions = props => { 7 | const { 8 | name, 9 | env, 10 | okraKey, 11 | token, 12 | products, 13 | color, 14 | logo, 15 | payment, 16 | filter, 17 | isCorporate, 18 | limit, 19 | callback_url, 20 | connectMessage, 21 | currency, 22 | widget_success, 23 | widget_failed, 24 | exp, 25 | onSuccess, 26 | onClose, 27 | onError, 28 | BeforeClose, 29 | onEvent 30 | } = props; 31 | const [toggleModal, setToggleModal] = useState(true); 32 | const [isLoading, setisLoading] = useState(true); 33 | 34 | const onTransactionSuccess = res => { 35 | onSuccess({ 36 | status: 'options success', 37 | res 38 | }); 39 | }; 40 | 41 | const onTransactionCloseConfirmation = () => { 42 | Alert.alert("End Transaction", "You are about to end this transaction, Are you sure you want to do this?", [{ 43 | text: "No", 44 | onPress: () => onTransactionClose() 45 | }, { 46 | text: "Yes", 47 | onPress: () => { 48 | onTransactionClose(), setToggleModal(false); 49 | }, 50 | style: "cancel" 51 | }], { 52 | cancelable: true 53 | }); 54 | }; 55 | 56 | const onTransactionClose = () => { 57 | onClose({ 58 | status: 'options close' 59 | }); 60 | }; 61 | 62 | const onTransactionError = res => { 63 | onError && onError({ 64 | status: 'options error', 65 | res 66 | }); 67 | }; 68 | 69 | const onTransactionBeforeClose = () => { 70 | BeforeClose && BeforeClose(); 71 | }; 72 | 73 | const messageReceived = data => { 74 | const webResponse = JSON.parse(data); 75 | 76 | switch (webResponse.event) { 77 | case 'option success': 78 | onTransactionSuccess(webResponse); 79 | break; 80 | 81 | case 'option close': 82 | onTransactionClose(); 83 | break; 84 | 85 | case 'option error': 86 | onTransactionError(webResponse); 87 | break; 88 | 89 | case 'option before close': 90 | onTransactionBeforeClose(); 91 | break; 92 | 93 | case 'option event': 94 | onEvent && onEvent(webResponse); 95 | break; 96 | 97 | default: 98 | onTransactionClose(); 99 | break; 100 | } 101 | }; 102 | 103 | const onNavigationStateChange = state => { 104 | const { 105 | url 106 | } = state; 107 | if (!url) return; 108 | 109 | if (url.includes('shouldClose=true')) { 110 | onTransactionClose(); 111 | } 112 | }; 113 | 114 | return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Modal, { 115 | visible: toggleModal, 116 | animationType: 'slide' 117 | }, /*#__PURE__*/React.createElement(SafeAreaView, { 118 | style: { 119 | flex: 1 120 | } 121 | }, /*#__PURE__*/React.createElement(WebView, { 122 | source: { 123 | html: OptionWebViewConfig({ 124 | name, 125 | env, 126 | okraKey, 127 | token, 128 | products, 129 | color, 130 | logo, 131 | payment, 132 | filter, 133 | isCorporate, 134 | limit, 135 | callback_url, 136 | connectMessage, 137 | currency, 138 | widget_success, 139 | widget_failed, 140 | exp 141 | }) 142 | }, 143 | onMessage: e => { 144 | var _e$nativeEvent; 145 | 146 | messageReceived((_e$nativeEvent = e.nativeEvent) === null || _e$nativeEvent === void 0 ? void 0 : _e$nativeEvent.data); 147 | }, 148 | onLoadStart: () => setisLoading(true), 149 | onLoadEnd: () => setisLoading(false), 150 | onNavigationStateChange: onNavigationStateChange, 151 | cacheEnabled: false, 152 | cacheMode: 'LOAD_NO_CACHE' 153 | }), /*#__PURE__*/React.createElement(View, { 154 | style: { 155 | backgroundColor: color ? color : 'rgb(58, 183, 149)', 156 | justifyContent: 'space-between', 157 | alignItems: 'center', 158 | paddingVertical: 15, 159 | flexDirection: 'row' 160 | } 161 | }, /*#__PURE__*/React.createElement(View, { 162 | style: { 163 | flex: 1 164 | } 165 | }, isLoading && /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(ActivityIndicator, { 166 | size: "large", 167 | color: 'white' 168 | }))), /*#__PURE__*/React.createElement(View, { 169 | style: { 170 | flex: 3, 171 | paddingHorizontal: 15 172 | } 173 | }, /*#__PURE__*/React.createElement(TouchableOpacity, { 174 | onPress: () => onTransactionCloseConfirmation() 175 | }, /*#__PURE__*/React.createElement(Text, { 176 | style: { 177 | color: 'white', 178 | fontWeight: 'bold', 179 | alignSelf: 'flex-end' 180 | } 181 | }, "close"))))))); 182 | }; 183 | 184 | export default BuildWithOptions; 185 | //# sourceMappingURL=build-with-options.js.map -------------------------------------------------------------------------------- /lib/module/build-with-options.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["build-with-options.tsx"],"names":["React","useState","View","Modal","Text","TouchableOpacity","SafeAreaView","ActivityIndicator","Alert","WebView","OptionWebViewConfig","BuildWithOptions","props","name","env","okraKey","token","products","color","logo","payment","filter","isCorporate","limit","callback_url","connectMessage","currency","widget_success","widget_failed","exp","onSuccess","onClose","onError","BeforeClose","onEvent","toggleModal","setToggleModal","isLoading","setisLoading","onTransactionSuccess","res","status","onTransactionCloseConfirmation","alert","text","onPress","onTransactionClose","style","cancelable","onTransactionError","onTransactionBeforeClose","messageReceived","data","webResponse","JSON","parse","event","onNavigationStateChange","state","url","includes","flex","html","e","nativeEvent","backgroundColor","justifyContent","alignItems","paddingVertical","flexDirection","paddingHorizontal","fontWeight","alignSelf"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,IAAtB,EAA4BC,gBAA5B,EAA8CC,YAA9C,EAA4DC,iBAA5D,EAA+EC,KAA/E,QAA4F,cAA5F;AAEA,SAASC,OAAT,QAA2C,sBAA3C;AACA,SAASC,mBAAT,QAAoC,kBAApC;;AAEA,MAAMC,gBAAgB,GAAIC,KAAD,IAAsC;AAC3D,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,GAAR;AAAaC,IAAA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,IAAA,IAAI,EAAC,OAAxB;AAAgC,IAAA,KAAK,EAAE;AAAvC,IADJ,CAFR,CADJ,eAQI,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAE;AAAEwB,MAAAA,IAAI,EAAE,CAAR;AAAWS,MAAAA,iBAAiB,EAAE;AAA9B;AAAb,kBACI,oBAAC,gBAAD;AAAkB,IAAA,OAAO,EAAE,MAAM5B,8BAA8B;AAA/D,kBACI,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAE;AAAExB,MAAAA,KAAK,EAAE,OAAT;AAAkBqD,MAAAA,UAAU,EAAE,MAA9B;AAAsCC,MAAAA,SAAS,EAAE;AAAjD;AAAb,aADJ,CADJ,CARJ,CAbJ,CADJ,CADJ,CADJ;AAqCH,CAxHD;;AA0HA,eAAe7D,gBAAf","sourcesContent":["import React, { useState } from 'react';\nimport { View, Modal, Text, TouchableOpacity, SafeAreaView, ActivityIndicator, Alert } from 'react-native'\nimport { OkraBuildWithOptionsProps } from './types';\nimport { WebView, WebViewNavigation } from 'react-native-webview';\nimport { OptionWebViewConfig } from './webview-config';\n\nconst BuildWithOptions = (props: OkraBuildWithOptionsProps) => {\n const { name, env, okraKey, token, products, color, logo, payment, filter, isCorporate, limit, callback_url, connectMessage, currency, widget_success, widget_failed, exp, onSuccess, onClose, onError, BeforeClose, onEvent } = props;\n\n const [toggleModal, setToggleModal] = useState(true)\n const [isLoading, setisLoading] = useState(true);\n\n const onTransactionSuccess = (res: any) => {\n onSuccess({ status: 'options success', res })\n }\n\n const onTransactionCloseConfirmation = () => {\n Alert.alert(\n \"End Transaction\",\n \"You are about to end this transaction, Are you sure you want to do this?\",\n [\n {\n text: \"No\",\n onPress: () => onTransactionClose()\n },\n {\n text: \"Yes\",\n onPress: () => { onTransactionClose(), setToggleModal(false) },\n style: \"cancel\",\n },\n ],\n {\n cancelable: true\n }\n );\n }\n\n const onTransactionClose = () => {\n onClose({ status: 'options close' })\n }\n\n\n const onTransactionError = (res: any) => {\n onError && onError({ status: 'options error', res })\n }\n\n const onTransactionBeforeClose = () => {\n BeforeClose && BeforeClose()\n }\n\n const messageReceived = (data: string) => {\n const webResponse = JSON.parse(data);\n\n switch (webResponse.event) {\n case 'option success':\n onTransactionSuccess(webResponse)\n break;\n\n case 'option close':\n onTransactionClose()\n break;\n\n case 'option error':\n onTransactionError(webResponse)\n break;\n\n case 'option before close':\n onTransactionBeforeClose()\n break;\n\n case 'option event':\n onEvent && onEvent(webResponse);\n break\n\n\n default:\n onTransactionClose()\n break;\n }\n };\n\n const onNavigationStateChange = (state: WebViewNavigation) => {\n const { url } = state;\n if (!url) return;\n if (url.includes('shouldClose=true')) {\n onTransactionClose()\n }\n };\n\n return (\n \n \n \n {\n messageReceived(e.nativeEvent?.data);\n }}\n onLoadStart={() => setisLoading(true)}\n onLoadEnd={() => setisLoading(false)}\n onNavigationStateChange={onNavigationStateChange}\n cacheEnabled={false}\n cacheMode={'LOAD_NO_CACHE'}\n />\n\n \n \n {isLoading && (\n \n \n \n )}\n \n \n onTransactionCloseConfirmation()}>\n \n close\n \n \n \n \n\n \n \n \n )\n}\n\nexport default BuildWithOptions;\n"]} -------------------------------------------------------------------------------- /lib/module/build-with-short-url.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { View, Modal, SafeAreaView, ActivityIndicator, TouchableOpacity, Text, Alert } from 'react-native'; 3 | import { WebView } from 'react-native-webview'; 4 | import { ShortUrlWebViewConfig } from './webview-config'; 5 | 6 | const BuildWithShortUrl = props => { 7 | const { 8 | short_url, 9 | onSuccess, 10 | onClose, 11 | onError, 12 | BeforeClose, 13 | onEvent 14 | } = props; 15 | const [toggleModal, setToggleModal] = useState(true); 16 | const [isLoading, setIsLoading] = useState(true); 17 | 18 | const onTransactionSuccess = res => { 19 | onSuccess({ 20 | status: 'options success', 21 | res 22 | }); 23 | }; 24 | 25 | const onTransactionCloseConfirmation = () => { 26 | Alert.alert("End Transaction", "You are about to end this transaction, Are you sure you want to do this?", [{ 27 | text: "No", 28 | onPress: () => onTransactionClose() 29 | }, { 30 | text: "Yes", 31 | onPress: () => { 32 | onTransactionClose(), setToggleModal(false); 33 | }, 34 | style: "cancel" 35 | }], { 36 | cancelable: true 37 | }); 38 | }; 39 | 40 | const onTransactionClose = () => { 41 | onClose({ 42 | status: 'options close' 43 | }); 44 | }; 45 | 46 | const onTransactionError = res => { 47 | onError && onError({ 48 | status: 'options error', 49 | res 50 | }); 51 | }; 52 | 53 | const onTransactionBeforeClose = () => { 54 | BeforeClose && BeforeClose(); 55 | }; 56 | 57 | const messageReceived = data => { 58 | const webResponse = JSON.parse(data); 59 | 60 | switch (webResponse.event) { 61 | case 'option success': 62 | onTransactionSuccess(webResponse); 63 | break; 64 | 65 | case 'option close': 66 | onTransactionClose(); 67 | break; 68 | 69 | case 'option error': 70 | onTransactionError(webResponse); 71 | break; 72 | 73 | case 'option before close': 74 | onTransactionBeforeClose(); 75 | break; 76 | 77 | case 'option event': 78 | onEvent && onEvent(webResponse); 79 | break; 80 | 81 | default: 82 | onTransactionClose(); 83 | break; 84 | } 85 | }; 86 | 87 | const onNavigationStateChange = state => { 88 | const { 89 | url 90 | } = state; 91 | if (!url) return; 92 | 93 | if (url.includes('shouldClose=true')) { 94 | onTransactionClose(); 95 | } 96 | }; 97 | 98 | return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Modal, { 99 | visible: toggleModal, 100 | animationType: 'slide' 101 | }, /*#__PURE__*/React.createElement(SafeAreaView, { 102 | style: { 103 | flex: 1 104 | } 105 | }, /*#__PURE__*/React.createElement(WebView, { 106 | source: { 107 | html: ShortUrlWebViewConfig({ 108 | short_url 109 | }) 110 | }, 111 | onMessage: e => { 112 | var _e$nativeEvent; 113 | 114 | messageReceived((_e$nativeEvent = e.nativeEvent) === null || _e$nativeEvent === void 0 ? void 0 : _e$nativeEvent.data); 115 | }, 116 | onLoadStart: () => setIsLoading(true), 117 | onLoadEnd: () => setIsLoading(false), 118 | onNavigationStateChange: onNavigationStateChange, 119 | cacheEnabled: false, 120 | cacheMode: 'LOAD_NO_CACHE' 121 | }), /*#__PURE__*/React.createElement(View, { 122 | style: { 123 | backgroundColor: 'rgb(58, 183, 149)', 124 | justifyContent: 'space-between', 125 | alignItems: 'center', 126 | paddingVertical: 15, 127 | flexDirection: 'row' 128 | } 129 | }, /*#__PURE__*/React.createElement(View, { 130 | style: { 131 | flex: 1 132 | } 133 | }, isLoading && /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(ActivityIndicator, { 134 | size: "large", 135 | color: 'white' 136 | }))), /*#__PURE__*/React.createElement(View, { 137 | style: { 138 | flex: 3, 139 | paddingHorizontal: 15 140 | } 141 | }, /*#__PURE__*/React.createElement(TouchableOpacity, { 142 | onPress: () => onTransactionCloseConfirmation() 143 | }, /*#__PURE__*/React.createElement(Text, { 144 | style: { 145 | color: 'white', 146 | fontWeight: 'bold', 147 | alignSelf: 'flex-end' 148 | } 149 | }, "close"))))))); 150 | }; 151 | 152 | export default BuildWithShortUrl; 153 | //# sourceMappingURL=build-with-short-url.js.map -------------------------------------------------------------------------------- /lib/module/build-with-short-url.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["build-with-short-url.tsx"],"names":["React","useState","View","Modal","SafeAreaView","ActivityIndicator","TouchableOpacity","Text","Alert","WebView","ShortUrlWebViewConfig","BuildWithShortUrl","props","short_url","onSuccess","onClose","onError","BeforeClose","onEvent","toggleModal","setToggleModal","isLoading","setIsLoading","onTransactionSuccess","res","status","onTransactionCloseConfirmation","alert","text","onPress","onTransactionClose","style","cancelable","onTransactionError","onTransactionBeforeClose","messageReceived","data","webResponse","JSON","parse","event","onNavigationStateChange","state","url","includes","flex","html","e","nativeEvent","backgroundColor","justifyContent","alignItems","paddingVertical","flexDirection","paddingHorizontal","color","fontWeight","alignSelf"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,YAAt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9C,iBAAf","sourcesContent":["import React, { useState } from 'react';\nimport { View, Modal, SafeAreaView, ActivityIndicator, TouchableOpacity, Text, Alert } from 'react-native'\nimport { OkraBuildWithShortUrlProps } from './types';\nimport { WebView, WebViewNavigation } from 'react-native-webview';\nimport { ShortUrlWebViewConfig } from './webview-config';\n\nconst BuildWithShortUrl = (props: OkraBuildWithShortUrlProps) => {\n const { short_url, onSuccess, onClose, onError, BeforeClose, onEvent } = props;\n\n const [toggleModal, setToggleModal] = useState(true)\n const [isLoading, setIsLoading] = useState(true);\n\n const onTransactionSuccess = (res: any) => {\n\n onSuccess({ status: 'options success', res })\n\n }\n\n const onTransactionCloseConfirmation = () => {\n Alert.alert(\n \"End Transaction\",\n \"You are about to end this transaction, Are you sure you want to do this?\",\n [\n {\n text: \"No\",\n onPress: () => onTransactionClose()\n },\n {\n text: \"Yes\",\n onPress: () => { onTransactionClose(), setToggleModal(false) },\n style: \"cancel\",\n },\n ],\n {\n cancelable: true\n }\n );\n }\n\n const onTransactionClose = () => {\n onClose({ status: 'options close' })\n\n }\n\n const onTransactionError = (res: any) => {\n onError && onError({ status: 'options error', res })\n\n }\n\n const onTransactionBeforeClose = () => {\n BeforeClose && BeforeClose()\n\n }\n\n const messageReceived = (data: string) => {\n const webResponse = JSON.parse(data);\n\n switch (webResponse.event) {\n case 'option success':\n onTransactionSuccess(webResponse)\n break;\n\n case 'option close':\n onTransactionClose()\n break;\n\n case 'option error':\n onTransactionError(webResponse)\n break;\n\n case 'option before close':\n onTransactionBeforeClose()\n break;\n\n case 'option event':\n onEvent && onEvent(webResponse);\n break\n\n default:\n onTransactionClose()\n break;\n }\n };\n\n const onNavigationStateChange = (state: WebViewNavigation) => {\n const { url } = state;\n if (!url) return;\n if (url.includes('shouldClose=true')) {\n onTransactionClose()\n }\n };\n\n return (\n \n \n \n {\n messageReceived(e.nativeEvent?.data);\n }}\n onLoadStart={() => setIsLoading(true)}\n onLoadEnd={() => setIsLoading(false)}\n onNavigationStateChange={onNavigationStateChange}\n cacheEnabled={false}\n cacheMode={'LOAD_NO_CACHE'}\n />\n \n \n {isLoading && (\n \n \n \n )}\n \n \n onTransactionCloseConfirmation()}>\n \n close\n \n \n \n \n \n \n\n \n )\n}\n\nexport default BuildWithShortUrl;\n"]} -------------------------------------------------------------------------------- /lib/module/index.js: -------------------------------------------------------------------------------- 1 | import BuildWithShortUrl from './build-with-short-url'; 2 | import BuildWithOptions from './build-with-options'; 3 | const Okra = { 4 | BuildWithShortUrl, 5 | BuildWithOptions 6 | }; 7 | export { Okra }; 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /lib/module/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["index.tsx"],"names":["BuildWithShortUrl","BuildWithOptions","Okra"],"mappings":"AAAA,OAAOA,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,MAAMC,IAAI,GAAG;AACXF,EAAAA,iBADW;AAEXC,EAAAA;AAFW,CAAb;AAIA,SAASC,IAAT","sourcesContent":["import BuildWithShortUrl from './build-with-short-url'\nimport BuildWithOptions from './build-with-options';\n\nconst Okra = {\n BuildWithShortUrl,\n BuildWithOptions\n}\nexport { Okra }\n"]} -------------------------------------------------------------------------------- /lib/module/types.js: -------------------------------------------------------------------------------- 1 | let product; 2 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /lib/module/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["types.ts"],"names":["product"],"mappings":"AAAA,IAAIA,OAAJ","sourcesContent":["let product: string[];\n\nexport interface OkraBuildWithOptionsProps {\n name: string;\n env: string;\n app_id?: string;\n okraKey: string;\n token: string;\n products: typeof product;\n exp?:Date;\n currency?:string;\n callback_url?:string;\n widget_failed?:string;\n widget_success?:string;\n connectMessage?:string;\n isCorporate?:boolean;\n filter?:any[];\n limit?:number;\n color?:string;\n logo?:string;\n charge?:string[];\n payment?:boolean\n onSuccess: (e: any) => void;\n onClose: (e: any) => void;\n BeforeClose?: () => void;\n onError?: (e:any) => void;\n onEvent?: (e:any) => void;\n\n}\n\nexport interface OkraBuildWithShortUrlProps {\n short_url: string;\n onSuccess: (e: any) => void;\n onClose: (e: any) => void;\n BeforeClose?: () => void;\n onError?: (e:any) => void;\n onEvent?: (e:any) => void;\n}\n\nexport interface ShortUrlWebViewConfigProps {\n short_url: string;\n}\n\nexport interface OptionWebViewConfigProps {\n name: string;\n env: string;\n app_id?: string;\n okraKey: string;\n token: string;\n products: typeof product;\n exp?:Date;\n currency?:string;\n callback_url?:string;\n widget_failed?:string;\n widget_success?:string;\n connectMessage?:string;\n isCorporate?:boolean;\n filter?:any[];\n limit?:number;\n color?:string;\n logo?:string;\n charge?:chargeProps;\n payment?:boolean\n}\n\ninterface chargeProps {\n type:type;\n amount:number | null;\n note?:string;\n currency?:string;\n account:string;\n}\n\ntype type = 'one-time' | 'recurring';"]} -------------------------------------------------------------------------------- /lib/module/webview-config.js: -------------------------------------------------------------------------------- 1 | const ShortUrlWebViewConfig = props => ` 2 | 3 | 4 | 5 | 6 | 7 | 8 | Okra React Native SDK 9 | 10 | 11 | 12 | 13 | 45 | 46 | 47 | 48 | `; 49 | 50 | const OptionWebViewConfig = props => { 51 | const { 52 | color 53 | } = props; 54 | let setLogo = props.logo ? props.logo : `https://media-exp1.licdn.com/dms/image/C4D0BAQHC76UBZ4sKVQ/company-logo_200_200/0/1573671434447?e=1644451200&v=beta&t=roLpHuqKsAsFGpfP39Ne5bqWKOWsBc0pB3Una1fK0WU`; 55 | let setColor = color ? color : 'rgb(58, 183, 149)'; 56 | let setPayment = props.payment ? `${props.payment}` : 'false'; 57 | let setProducts = props.products && `products:${JSON.stringify(props.products)},`; 58 | let setFilter = props.filter ? `filter:${JSON.stringify(props.filter)},` : `filter:${JSON.stringify([])},`; 59 | let setCharge = props.charge ? `charge:${JSON.stringify(props.charge)},` : `filter:${JSON.stringify([])},`; 60 | let setIsCorporate = props.isCorporate ? `${props.isCorporate}` : 'false'; 61 | let setcallback_url = props.callback_url ? `${props.callback_url}` : null; 62 | let setConnectMessage = props.connectMessage ? `${props.connectMessage}` : null; 63 | let setwidget_success = props.widget_success ? `${props.widget_success}` : `Your account was linked successfully with ${props.name}`; 64 | let setwidget_failed = props.widget_failed ? `${props.widget_failed}` : `Something went wrong while linking your account to ${props.name}`; 65 | let setExp = props.exp ? `${props.exp}` : null; 66 | let setCurrency = props.currency ? `${props.currency}` : 'NGN'; 67 | let setLimit = props.limit ? `${props.limit}` : null; 68 | return ` 69 | 70 | 71 | 72 | 73 | 74 | 75 | Okra React Native SDK 76 | 77 | 78 | 79 | 80 | 128 | 129 | 130 | 131 | `; 132 | }; 133 | 134 | export { ShortUrlWebViewConfig, OptionWebViewConfig }; 135 | //# sourceMappingURL=webview-config.js.map -------------------------------------------------------------------------------- /lib/module/webview-config.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webview-config.ts"],"names":["ShortUrlWebViewConfig","props","short_url","OptionWebViewConfig","color","setLogo","logo","setColor","setPayment","payment","setProducts","products","JSON","stringify","setFilter","filter","setCharge","charge","setIsCorporate","isCorporate","setcallback_url","callback_url","setConnectMessage","connectMessage","setwidget_success","widget_success","name","setwidget_failed","widget_failed","setExp","exp","setCurrency","currency","setLimit","limit","env","app_id","okraKey","token"],"mappings":"AAEA,MAAMA,qBAAqB,GAAIC,KAAD,IAAwC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsCA,KAAK,CAACC,SAAU;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA/CA;;AAiDA,MAAMC,mBAAmB,GAAIF,KAAD,IAAqC;AAC/D,QAAM;AAAEG,IAAAA;AAAF,MAAYH,KAAlB;AAGA,MAAII,OAAO,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qD3B,KAAK,CAACyB,IAAK,EAAzI;AACA,MAAIG,MAAM,GAAG5B,KAAK,CAAC6B,GAAN,GAAa,GAAE7B,KAAK,CAAC6B,GAAI,EAAzB,GAA6B,IAA1C;AACA,MAAIC,WAAW,GAAG9B,KAAK,CAAC+B,QAAN,GAAkB,GAAE/B,KAAK,CAAC+B,QAAS,EAAnC,GAAuC,KAAzD;AACA,MAAIC,QAAQ,GAAGhC,KAAK,CAACiC,KAAN,GAAe,GAAEjC,KAAK,CAACiC,KAAM,EAA7B,GAAiC,IAAhD;AAEA,SAAQ;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyBjC,KAAK,CAACyB,IAAK;AACpC,wBAAwBzB,KAAK,CAACkC,GAAI;AAClC,2BAA2BlC,KAAK,CAACmC,MAAO;AACxC,wBAAwBnC,KAAK,CAACoC,OAAQ;AACtC,0BAA0BpC,KAAK,CAACqC,KAAM;AACtC,0BAA0B9B,UAAW;AACrC,8BAA8BU,cAAe;AAC7C,wBAAwBb,OAAQ;AAChC,gCAAgCe,eAAgB;AAChD,uBAAuBS,MAAO;AAC9B,kCAAkCP,iBAAkB;AACpD,kCAAkCE,iBAAkB;AACpD,iCAAiCG,gBAAiB;AAClD,4BAA4BI,WAAY;AACxC,kBAAkBjB,SAAU;AAC5B,0BAA0BP,QAAS;AACnC,yBAAyB0B,QAAS;AAClC,kBAAkBvB,WAAY;AAC9B,kBAAkBM,SAAU;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA/DE;AAgED,CArFD;;AAuFA,SAAShB,qBAAT,EAAgCG,mBAAhC","sourcesContent":["import { OptionWebViewConfigProps, ShortUrlWebViewConfigProps } from './types';\n\nconst ShortUrlWebViewConfig = (props: ShortUrlWebViewConfigProps) => ` \n \n \n \n \n \n \n Okra React Native SDK\n \n \n\n \n \n \n\n \n`;\n\nconst OptionWebViewConfig = (props: OptionWebViewConfigProps) => {\n const { color } = props;\n\n\n let setLogo = props.logo\n ? props.logo\n : `https://media-exp1.licdn.com/dms/image/C4D0BAQHC76UBZ4sKVQ/company-logo_200_200/0/1573671434447?e=1644451200&v=beta&t=roLpHuqKsAsFGpfP39Ne5bqWKOWsBc0pB3Una1fK0WU`;\n let setColor = color ? color : 'rgb(58, 183, 149)';\n let setPayment = props.payment ? `${props.payment}` : 'false';\n let setProducts = props.products && `products:${JSON.stringify(props.products)},`;\n let setFilter = props.filter ? `filter:${JSON.stringify(props.filter)},` : `filter:${JSON.stringify([])},`;\n let setCharge = props.charge ? `charge:${JSON.stringify(props.charge)},` : `filter:${JSON.stringify([])},`;\n let setIsCorporate = props.isCorporate ? `${props.isCorporate}` : 'false';\n let setcallback_url = props.callback_url ? `${props.callback_url}` : null;\n let setConnectMessage = props.connectMessage ? `${props.connectMessage}` : null;\n let setwidget_success = props.widget_success ? `${props.widget_success}` : `Your account was linked successfully with ${props.name}`;\n let setwidget_failed = props.widget_failed ? `${props.widget_failed}` : `Something went wrong while linking your account to ${props.name}`;\n let setExp = props.exp ? `${props.exp}` : null;\n let setCurrency = props.currency ? `${props.currency}` : 'NGN';\n let setLimit = props.limit ? `${props.limit}` : null;\n\n return ` \n\n\n \n \n \n \n Okra React Native SDK\n \n \n\n \n \n \n\n \n`;\n};\n\nexport { ShortUrlWebViewConfig, OptionWebViewConfig };"]} -------------------------------------------------------------------------------- /lib/typescript/__tests__/index.test.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/just1and0/React-Native-Okra-Webview/0362345de72adaff1445e1ba9652f52eb0275bdc/lib/typescript/__tests__/index.test.d.ts -------------------------------------------------------------------------------- /lib/typescript/build-with-options.d.ts: -------------------------------------------------------------------------------- 1 | import { OkraBuildWithOptionsProps } from './types'; 2 | declare const BuildWithOptions: (props: OkraBuildWithOptionsProps) => JSX.Element; 3 | export default BuildWithOptions; 4 | -------------------------------------------------------------------------------- /lib/typescript/build-with-short-url.d.ts: -------------------------------------------------------------------------------- 1 | import { OkraBuildWithShortUrlProps } from './types'; 2 | declare const BuildWithShortUrl: (props: OkraBuildWithShortUrlProps) => JSX.Element; 3 | export default BuildWithShortUrl; 4 | -------------------------------------------------------------------------------- /lib/typescript/index.d.ts: -------------------------------------------------------------------------------- 1 | declare const Okra: { 2 | BuildWithShortUrl: (props: import("./types").OkraBuildWithShortUrlProps) => JSX.Element; 3 | BuildWithOptions: (props: import("./types").OkraBuildWithOptionsProps) => JSX.Element; 4 | }; 5 | export { Okra }; 6 | -------------------------------------------------------------------------------- /lib/typescript/types.d.ts: -------------------------------------------------------------------------------- 1 | declare let product: string[]; 2 | export interface OkraBuildWithOptionsProps { 3 | name: string; 4 | env: string; 5 | app_id?: string; 6 | okraKey: string; 7 | token: string; 8 | products: typeof product; 9 | exp?: Date; 10 | currency?: string; 11 | callback_url?: string; 12 | widget_failed?: string; 13 | widget_success?: string; 14 | connectMessage?: string; 15 | isCorporate?: boolean; 16 | filter?: any[]; 17 | limit?: number; 18 | color?: string; 19 | logo?: string; 20 | charge?: string[]; 21 | payment?: boolean; 22 | onSuccess: (e: any) => void; 23 | onClose: (e: any) => void; 24 | BeforeClose?: () => void; 25 | onError?: (e: any) => void; 26 | onEvent?: (e: any) => void; 27 | } 28 | export interface OkraBuildWithShortUrlProps { 29 | short_url: string; 30 | onSuccess: (e: any) => void; 31 | onClose: (e: any) => void; 32 | BeforeClose?: () => void; 33 | onError?: (e: any) => void; 34 | onEvent?: (e: any) => void; 35 | } 36 | export interface ShortUrlWebViewConfigProps { 37 | short_url: string; 38 | } 39 | export interface OptionWebViewConfigProps { 40 | name: string; 41 | env: string; 42 | app_id?: string; 43 | okraKey: string; 44 | token: string; 45 | products: typeof product; 46 | exp?: Date; 47 | currency?: string; 48 | callback_url?: string; 49 | widget_failed?: string; 50 | widget_success?: string; 51 | connectMessage?: string; 52 | isCorporate?: boolean; 53 | filter?: any[]; 54 | limit?: number; 55 | color?: string; 56 | logo?: string; 57 | charge?: chargeProps; 58 | payment?: boolean; 59 | } 60 | interface chargeProps { 61 | type: type; 62 | amount: number | null; 63 | note?: string; 64 | currency?: string; 65 | account: string; 66 | } 67 | declare type type = 'one-time' | 'recurring'; 68 | export {}; 69 | -------------------------------------------------------------------------------- /lib/typescript/webview-config.d.ts: -------------------------------------------------------------------------------- 1 | import { OptionWebViewConfigProps, ShortUrlWebViewConfigProps } from './types'; 2 | declare const ShortUrlWebViewConfig: (props: ShortUrlWebViewConfigProps) => string; 3 | declare const OptionWebViewConfig: (props: OptionWebViewConfigProps) => string; 4 | export { ShortUrlWebViewConfig, OptionWebViewConfig }; 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-okra-webview", 3 | "version": "0.1.9", 4 | "description": "Official Okra SDK for React Native/Expo applications. Don't forget to star ✨", 5 | "main": "lib/commonjs/index", 6 | "module": "lib/module/index", 7 | "types": "lib/typescript/index.d.ts", 8 | "react-native": "src/index", 9 | "source": "src/index", 10 | "files": [ 11 | "src", 12 | "lib", 13 | "android", 14 | "ios", 15 | "cpp", 16 | "react-native-okra-webview.podspec", 17 | "!lib/typescript/example", 18 | "!android/build", 19 | "!ios/build", 20 | "!**/__tests__", 21 | "!**/__fixtures__", 22 | "!**/__mocks__" 23 | ], 24 | "scripts": { 25 | "test": "jest", 26 | "typescript": "tsc --noEmit", 27 | "lint": "eslint \"**/*.{js,ts,tsx}\"", 28 | "prepare": "bob build", 29 | "release": "release-it", 30 | "example": "yarn --cwd example", 31 | "pods": "cd example && pod-install --quiet", 32 | "bootstrap": "yarn example && yarn && yarn pods" 33 | }, 34 | "keywords": [ 35 | "react-native", 36 | "ios", 37 | "android" 38 | ], 39 | "publishConfig": { 40 | "access": "public", 41 | "registry": "https://registry.npmjs.org" 42 | }, 43 | "repository": "https://github.com/just1and0/react-native-okra-webview", 44 | "author": "Oluwatobi Shokunbi (https://github.com/just1and0)", 45 | "license": "MIT", 46 | "bugs": { 47 | "url": "https://github.com/just1and0/react-native-okra-webview/issues" 48 | }, 49 | "homepage": "https://github.com/just1and0/react-native-okra-webview#readme", 50 | "devDependencies": { 51 | "@commitlint/config-conventional": "^11.0.0", 52 | "@react-native-community/eslint-config": "^2.0.0", 53 | "@release-it/conventional-changelog": "^2.0.0", 54 | "@types/jest": "^26.0.0", 55 | "@types/react": "^16.9.19", 56 | "@types/react-native": "0.62.13", 57 | "commitlint": "^11.0.0", 58 | "eslint": "^7.2.0", 59 | "eslint-config-prettier": "^7.0.0", 60 | "eslint-plugin-prettier": "^3.1.3", 61 | "husky": "^6.0.0", 62 | "jest": "^26.0.1", 63 | "pod-install": "^0.1.0", 64 | "prettier": "^2.0.5", 65 | "react": "16.13.1", 66 | "react-native": "0.63.4", 67 | "react-native-builder-bob": "^0.18.0", 68 | "release-it": "^14.2.2", 69 | "typescript": "^4.1.3" 70 | }, 71 | "dependencies": { 72 | "react-native-webview": "*" 73 | }, 74 | "peerDependencies": { 75 | "react": "*", 76 | "react-native": "*" 77 | }, 78 | "jest": { 79 | "preset": "react-native", 80 | "modulePathIgnorePatterns": [ 81 | "/example/node_modules", 82 | "/lib/" 83 | ] 84 | }, 85 | "commitlint": { 86 | "extends": [ 87 | "@commitlint/config-conventional" 88 | ] 89 | }, 90 | "release-it": { 91 | "git": { 92 | "commitMessage": "chore: release ${version}", 93 | "tagName": "v${version}" 94 | }, 95 | "npm": { 96 | "publish": true 97 | }, 98 | "github": { 99 | "release": true 100 | }, 101 | "plugins": { 102 | "@release-it/conventional-changelog": { 103 | "preset": "angular" 104 | } 105 | } 106 | }, 107 | "eslintConfig": { 108 | "root": true, 109 | "extends": [ 110 | "@react-native-community", 111 | "prettier" 112 | ], 113 | "rules": { 114 | "prettier/prettier": [ 115 | "error", 116 | { 117 | "quoteProps": "consistent", 118 | "singleQuote": true, 119 | "tabWidth": 2, 120 | "trailingComma": "es5", 121 | "useTabs": false 122 | } 123 | ] 124 | } 125 | }, 126 | "eslintIgnore": [ 127 | "node_modules/", 128 | "lib/" 129 | ], 130 | "prettier": { 131 | "quoteProps": "consistent", 132 | "singleQuote": true, 133 | "tabWidth": 2, 134 | "trailingComma": "es5", 135 | "useTabs": false 136 | }, 137 | "react-native-builder-bob": { 138 | "source": "src", 139 | "output": "lib", 140 | "targets": [ 141 | "commonjs", 142 | "module", 143 | [ 144 | "typescript", 145 | { 146 | "project": "tsconfig.build.json" 147 | } 148 | ] 149 | ] 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | const path = require('path'); 3 | const child_process = require('child_process'); 4 | 5 | const root = path.resolve(__dirname, '..'); 6 | const args = process.argv.slice(2); 7 | const options = { 8 | cwd: process.cwd(), 9 | env: process.env, 10 | stdio: 'inherit', 11 | encoding: 'utf-8', 12 | }; 13 | 14 | if (os.type() === 'Windows_NT') { 15 | options.shell = true 16 | } 17 | 18 | let result; 19 | 20 | if (process.cwd() !== root || args.length) { 21 | // We're not in the root of the project, or additional arguments were passed 22 | // In this case, forward the command to `yarn` 23 | result = child_process.spawnSync('yarn', args, options); 24 | } else { 25 | // If `yarn` is run without arguments, perform bootstrap 26 | result = child_process.spawnSync('yarn', ['bootstrap'], options); 27 | } 28 | 29 | process.exitCode = result.status; 30 | -------------------------------------------------------------------------------- /src/__tests__/index.test.tsx: -------------------------------------------------------------------------------- 1 | it.todo('write a test'); 2 | -------------------------------------------------------------------------------- /src/build-with-options.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { View, Modal, Text, TouchableOpacity, SafeAreaView, ActivityIndicator, Alert } from 'react-native' 3 | import { OkraBuildWithOptionsProps } from './types'; 4 | import { WebView, WebViewNavigation } from 'react-native-webview'; 5 | import { OptionWebViewConfig } from './webview-config'; 6 | 7 | const BuildWithOptions = (props: OkraBuildWithOptionsProps) => { 8 | const { name, env, okraKey, token, products, color, logo, payment, filter, isCorporate, limit, callback_url, connectMessage, currency, widget_success, widget_failed, exp, onSuccess, onClose, onError, BeforeClose, onEvent } = props; 9 | 10 | const [toggleModal, setToggleModal] = useState(true) 11 | const [isLoading, setisLoading] = useState(true); 12 | 13 | const onTransactionSuccess = (res: any) => { 14 | onSuccess({ status: 'options success', res }) 15 | } 16 | 17 | const onTransactionCloseConfirmation = () => { 18 | Alert.alert( 19 | "End Transaction", 20 | "You are about to end this transaction, Are you sure you want to do this?", 21 | [ 22 | { 23 | text: "No", 24 | onPress: () => onTransactionClose() 25 | }, 26 | { 27 | text: "Yes", 28 | onPress: () => { onTransactionClose(), setToggleModal(false) }, 29 | style: "cancel", 30 | }, 31 | ], 32 | { 33 | cancelable: true 34 | } 35 | ); 36 | } 37 | 38 | const onTransactionClose = () => { 39 | onClose({ status: 'options close' }) 40 | } 41 | 42 | 43 | const onTransactionError = (res: any) => { 44 | onError && onError({ status: 'options error', res }) 45 | } 46 | 47 | const onTransactionBeforeClose = () => { 48 | BeforeClose && BeforeClose() 49 | } 50 | 51 | const messageReceived = (data: string) => { 52 | const webResponse = JSON.parse(data); 53 | 54 | switch (webResponse.event) { 55 | case 'option success': 56 | onTransactionSuccess(webResponse) 57 | break; 58 | 59 | case 'option close': 60 | onTransactionClose() 61 | break; 62 | 63 | case 'option error': 64 | onTransactionError(webResponse) 65 | break; 66 | 67 | case 'option before close': 68 | onTransactionBeforeClose() 69 | break; 70 | 71 | case 'option event': 72 | onEvent && onEvent(webResponse); 73 | break 74 | 75 | 76 | default: 77 | onTransactionClose() 78 | break; 79 | } 80 | }; 81 | 82 | const onNavigationStateChange = (state: WebViewNavigation) => { 83 | const { url } = state; 84 | if (!url) return; 85 | if (url.includes('shouldClose=true')) { 86 | onTransactionClose() 87 | } 88 | }; 89 | 90 | return ( 91 | 92 | 93 | 94 | { 97 | messageReceived(e.nativeEvent?.data); 98 | }} 99 | onLoadStart={() => setisLoading(true)} 100 | onLoadEnd={() => setisLoading(false)} 101 | onNavigationStateChange={onNavigationStateChange} 102 | cacheEnabled={false} 103 | cacheMode={'LOAD_NO_CACHE'} 104 | /> 105 | 106 | 107 | 108 | {isLoading && ( 109 | 110 | 111 | 112 | )} 113 | 114 | 115 | onTransactionCloseConfirmation()}> 116 | 117 | close 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | ) 127 | } 128 | 129 | export default BuildWithOptions; 130 | -------------------------------------------------------------------------------- /src/build-with-short-url.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { View, Modal, SafeAreaView, ActivityIndicator, TouchableOpacity, Text, Alert } from 'react-native' 3 | import { OkraBuildWithShortUrlProps } from './types'; 4 | import { WebView, WebViewNavigation } from 'react-native-webview'; 5 | import { ShortUrlWebViewConfig } from './webview-config'; 6 | 7 | const BuildWithShortUrl = (props: OkraBuildWithShortUrlProps) => { 8 | const { short_url, onSuccess, onClose, onError, BeforeClose, onEvent } = props; 9 | 10 | const [toggleModal, setToggleModal] = useState(true) 11 | const [isLoading, setIsLoading] = useState(true); 12 | 13 | const onTransactionSuccess = (res: any) => { 14 | 15 | onSuccess({ status: 'options success', res }) 16 | 17 | } 18 | 19 | const onTransactionCloseConfirmation = () => { 20 | Alert.alert( 21 | "End Transaction", 22 | "You are about to end this transaction, Are you sure you want to do this?", 23 | [ 24 | { 25 | text: "No", 26 | onPress: () => onTransactionClose() 27 | }, 28 | { 29 | text: "Yes", 30 | onPress: () => { onTransactionClose(), setToggleModal(false) }, 31 | style: "cancel", 32 | }, 33 | ], 34 | { 35 | cancelable: true 36 | } 37 | ); 38 | } 39 | 40 | const onTransactionClose = () => { 41 | onClose({ status: 'options close' }) 42 | 43 | } 44 | 45 | const onTransactionError = (res: any) => { 46 | onError && onError({ status: 'options error', res }) 47 | 48 | } 49 | 50 | const onTransactionBeforeClose = () => { 51 | BeforeClose && BeforeClose() 52 | 53 | } 54 | 55 | const messageReceived = (data: string) => { 56 | const webResponse = JSON.parse(data); 57 | 58 | switch (webResponse.event) { 59 | case 'option success': 60 | onTransactionSuccess(webResponse) 61 | break; 62 | 63 | case 'option close': 64 | onTransactionClose() 65 | break; 66 | 67 | case 'option error': 68 | onTransactionError(webResponse) 69 | break; 70 | 71 | case 'option before close': 72 | onTransactionBeforeClose() 73 | break; 74 | 75 | case 'option event': 76 | onEvent && onEvent(webResponse); 77 | break 78 | 79 | default: 80 | onTransactionClose() 81 | break; 82 | } 83 | }; 84 | 85 | const onNavigationStateChange = (state: WebViewNavigation) => { 86 | const { url } = state; 87 | if (!url) return; 88 | if (url.includes('shouldClose=true')) { 89 | onTransactionClose() 90 | } 91 | }; 92 | 93 | return ( 94 | 95 | 96 | 97 | { 100 | messageReceived(e.nativeEvent?.data); 101 | }} 102 | onLoadStart={() => setIsLoading(true)} 103 | onLoadEnd={() => setIsLoading(false)} 104 | onNavigationStateChange={onNavigationStateChange} 105 | cacheEnabled={false} 106 | cacheMode={'LOAD_NO_CACHE'} 107 | /> 108 | 109 | 110 | {isLoading && ( 111 | 112 | 113 | 114 | )} 115 | 116 | 117 | onTransactionCloseConfirmation()}> 118 | 119 | close 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | ) 129 | } 130 | 131 | export default BuildWithShortUrl; 132 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import BuildWithShortUrl from './build-with-short-url' 2 | import BuildWithOptions from './build-with-options'; 3 | 4 | const Okra = { 5 | BuildWithShortUrl, 6 | BuildWithOptions 7 | } 8 | export { Okra } 9 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | let product: string[]; 2 | 3 | export interface OkraBuildWithOptionsProps { 4 | name: string; 5 | env: string; 6 | app_id?: string; 7 | okraKey: string; 8 | token: string; 9 | products: typeof product; 10 | exp?:Date; 11 | currency?:string; 12 | callback_url?:string; 13 | widget_failed?:string; 14 | widget_success?:string; 15 | connectMessage?:string; 16 | isCorporate?:boolean; 17 | filter?:any[]; 18 | limit?:number; 19 | color?:string; 20 | logo?:string; 21 | charge?:string[]; 22 | payment?:boolean 23 | onSuccess: (e: any) => void; 24 | onClose: (e: any) => void; 25 | BeforeClose?: () => void; 26 | onError?: (e:any) => void; 27 | onEvent?: (e:any) => void; 28 | 29 | } 30 | 31 | export interface OkraBuildWithShortUrlProps { 32 | short_url: string; 33 | onSuccess: (e: any) => void; 34 | onClose: (e: any) => void; 35 | BeforeClose?: () => void; 36 | onError?: (e:any) => void; 37 | onEvent?: (e:any) => void; 38 | } 39 | 40 | export interface ShortUrlWebViewConfigProps { 41 | short_url: string; 42 | } 43 | 44 | export interface OptionWebViewConfigProps { 45 | name: string; 46 | env: string; 47 | app_id?: string; 48 | okraKey: string; 49 | token: string; 50 | products: typeof product; 51 | exp?:Date; 52 | currency?:string; 53 | callback_url?:string; 54 | widget_failed?:string; 55 | widget_success?:string; 56 | connectMessage?:string; 57 | isCorporate?:boolean; 58 | filter?:any[]; 59 | limit?:number; 60 | color?:string; 61 | logo?:string; 62 | charge?:chargeProps; 63 | payment?:boolean 64 | } 65 | 66 | interface chargeProps { 67 | type:type; 68 | amount:number | null; 69 | note?:string; 70 | currency?:string; 71 | account:string; 72 | } 73 | 74 | type type = 'one-time' | 'recurring'; -------------------------------------------------------------------------------- /src/webview-config.ts: -------------------------------------------------------------------------------- 1 | import { OptionWebViewConfigProps, ShortUrlWebViewConfigProps } from './types'; 2 | 3 | const ShortUrlWebViewConfig = (props: ShortUrlWebViewConfigProps) => ` 4 | 5 | 6 | 7 | 8 | 9 | 10 | Okra React Native SDK 11 | 12 | 13 | 14 | 15 | 47 | 48 | 49 | 50 | `; 51 | 52 | const OptionWebViewConfig = (props: OptionWebViewConfigProps) => { 53 | const { color } = props; 54 | 55 | 56 | let setLogo = props.logo 57 | ? props.logo 58 | : `https://media-exp1.licdn.com/dms/image/C4D0BAQHC76UBZ4sKVQ/company-logo_200_200/0/1573671434447?e=1644451200&v=beta&t=roLpHuqKsAsFGpfP39Ne5bqWKOWsBc0pB3Una1fK0WU`; 59 | let setColor = color ? color : 'rgb(58, 183, 149)'; 60 | let setPayment = props.payment ? `${props.payment}` : 'false'; 61 | let setProducts = props.products && `products:${JSON.stringify(props.products)},`; 62 | let setFilter = props.filter ? `filter:${JSON.stringify(props.filter)},` : `filter:${JSON.stringify([])},`; 63 | let setCharge = props.charge ? `charge:${JSON.stringify(props.charge)},` : `filter:${JSON.stringify([])},`; 64 | let setIsCorporate = props.isCorporate ? `${props.isCorporate}` : 'false'; 65 | let setcallback_url = props.callback_url ? `${props.callback_url}` : null; 66 | let setConnectMessage = props.connectMessage ? `${props.connectMessage}` : null; 67 | let setwidget_success = props.widget_success ? `${props.widget_success}` : `Your account was linked successfully with ${props.name}`; 68 | let setwidget_failed = props.widget_failed ? `${props.widget_failed}` : `Something went wrong while linking your account to ${props.name}`; 69 | let setExp = props.exp ? `${props.exp}` : null; 70 | let setCurrency = props.currency ? `${props.currency}` : 'NGN'; 71 | let setLimit = props.limit ? `${props.limit}` : null; 72 | 73 | return ` 74 | 75 | 76 | 77 | 78 | 79 | 80 | Okra React Native SDK 81 | 82 | 83 | 84 | 85 | 133 | 134 | 135 | 136 | `; 137 | }; 138 | 139 | export { ShortUrlWebViewConfig, OptionWebViewConfig }; -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": "./tsconfig", 4 | "exclude": ["example"] 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./", 4 | "paths": { 5 | "react-native-okra-webview": ["./src/index"] 6 | }, 7 | "allowUnreachableCode": false, 8 | "allowUnusedLabels": false, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "jsx": "react", 12 | "lib": ["esnext"], 13 | "module": "esnext", 14 | "moduleResolution": "node", 15 | "noFallthroughCasesInSwitch": true, 16 | "noImplicitReturns": true, 17 | "noImplicitUseStrict": false, 18 | "noStrictGenericChecks": false, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "resolveJsonModule": true, 22 | "skipLibCheck": true, 23 | "strict": true, 24 | "target": "esnext" 25 | } 26 | } 27 | --------------------------------------------------------------------------------