├── dist ├── test │ ├── use-paystack.test.d.ts │ ├── paystack-button.test.d.ts │ ├── paystack-provider.test.d.ts │ └── fixtures.d.ts ├── paystack-actions.d.ts ├── use-paystack.d.ts ├── index.d.ts ├── paystack-context.d.ts ├── paystack-provider.d.ts ├── paystack-consumer.d.ts ├── paystack-button.d.ts ├── types.d.ts └── index.es.js ├── example ├── src │ ├── dist │ │ ├── test │ │ │ ├── paystack-button.test.d.ts │ │ │ ├── paystack-script.test.d.ts │ │ │ ├── use-paystack.test.d.ts │ │ │ ├── paystack-provider.test.d.ts │ │ │ └── fixtures.d.ts │ │ ├── paystack-script.d.ts │ │ ├── paystack-actions.d.ts │ │ ├── use-paystack.d.ts │ │ ├── index.d.ts │ │ ├── paystack-context.d.ts │ │ ├── paystack-provider.d.ts │ │ ├── paystack-consumer.d.ts │ │ ├── paystack-button.d.ts │ │ └── types.d.ts │ ├── index.js │ ├── index.css │ ├── App.css │ ├── logo.svg │ └── App.js ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html ├── .gitignore ├── package.json └── README.md ├── embed.jpg ├── React_App.png ├── React_App_01.png ├── jest.config.js ├── libs ├── src │ └── types │ │ └── @paystack │ │ └── inline-js │ │ └── index.d.ts ├── index.ts ├── test │ ├── fixtures.ts │ ├── paystack-button.test.tsx │ ├── paystack-provider.test.tsx │ └── use-paystack.test.tsx ├── paystack-actions.ts ├── paystack-context.ts ├── paystack-provider.tsx ├── paystack-button.tsx ├── paystack-consumer.tsx ├── types.ts └── use-paystack.ts ├── .prettierrc ├── babel.config.js ├── rollup.config.js ├── .github └── workflows │ └── node.js.yml ├── .gitignore ├── LICENSE.md ├── eslint.config.mjs ├── package.json ├── tsconfig.json └── README.md /dist/test/use-paystack.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/test/paystack-button.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/test/paystack-provider.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /example/src/dist/test/paystack-button.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /example/src/dist/test/paystack-script.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /example/src/dist/test/use-paystack.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /example/src/dist/test/paystack-provider.test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /embed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamraphson/react-paystack/HEAD/embed.jpg -------------------------------------------------------------------------------- /React_App.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamraphson/react-paystack/HEAD/React_App.png -------------------------------------------------------------------------------- /React_App_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamraphson/react-paystack/HEAD/React_App_01.png -------------------------------------------------------------------------------- /example/src/dist/paystack-script.d.ts: -------------------------------------------------------------------------------- 1 | export default function usePaystackScript(): boolean[]; 2 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | }; 5 | -------------------------------------------------------------------------------- /example/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /dist/paystack-actions.d.ts: -------------------------------------------------------------------------------- 1 | export declare const callPaystackPop: (paystackArgs: Record) => void; 2 | -------------------------------------------------------------------------------- /example/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamraphson/react-paystack/HEAD/example/public/favicon.ico -------------------------------------------------------------------------------- /example/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamraphson/react-paystack/HEAD/example/public/logo192.png -------------------------------------------------------------------------------- /example/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamraphson/react-paystack/HEAD/example/public/logo512.png -------------------------------------------------------------------------------- /example/src/dist/paystack-actions.d.ts: -------------------------------------------------------------------------------- 1 | export declare const callPaystackPop: (paystackArgs: Record) => void; 2 | -------------------------------------------------------------------------------- /libs/src/types/@paystack/inline-js/index.d.ts: -------------------------------------------------------------------------------- 1 | //@paystack/inline-js/index.d.ts 2 | declare module '@paystack/inline-js'; 3 | -------------------------------------------------------------------------------- /dist/test/fixtures.d.ts: -------------------------------------------------------------------------------- 1 | export declare const config: { 2 | reference: string; 3 | email: string; 4 | amount: number; 5 | publicKey: string; 6 | }; 7 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "singleQuote": true, 4 | "trailingComma": "all", 5 | "bracketSpacing": false, 6 | "jsxBracketSameLine": false 7 | } 8 | -------------------------------------------------------------------------------- /dist/use-paystack.d.ts: -------------------------------------------------------------------------------- 1 | import { HookConfig, InitializePayment } from './types'; 2 | export default function usePaystackPayment(hookConfig: HookConfig): InitializePayment; 3 | -------------------------------------------------------------------------------- /example/src/dist/test/fixtures.d.ts: -------------------------------------------------------------------------------- 1 | export declare const config: { 2 | reference: string; 3 | email: string; 4 | amount: number; 5 | publicKey: string; 6 | }; 7 | -------------------------------------------------------------------------------- /example/src/dist/use-paystack.d.ts: -------------------------------------------------------------------------------- 1 | import { HookConfig, InitializePayment } from './types'; 2 | export default function usePaystackPayment(hookConfig: HookConfig): InitializePayment; 3 | -------------------------------------------------------------------------------- /libs/index.ts: -------------------------------------------------------------------------------- 1 | export {default as usePaystackPayment} from './use-paystack'; 2 | export {default as PaystackButton} from './paystack-button'; 3 | export {default as PaystackConsumer} from './paystack-consumer'; 4 | -------------------------------------------------------------------------------- /libs/test/fixtures.ts: -------------------------------------------------------------------------------- 1 | export const config = { 2 | reference: `${new Date().getTime()}`, 3 | email: 'user@example.com', 4 | amount: 10000, 5 | publicKey: 'pk_test_xdxfddole1992asdfghjkleetdfgxxxxxxx', 6 | }; 7 | -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export { default as usePaystackPayment } from './use-paystack'; 2 | export { default as PaystackButton } from './paystack-button'; 3 | export { default as PaystackConsumer } from './paystack-consumer'; 4 | -------------------------------------------------------------------------------- /example/src/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export { default as usePaystackPayment } from './use-paystack'; 2 | export { default as PaystackButton } from './paystack-button'; 3 | export { default as PaystackConsumer } from './paystack-consumer'; 4 | -------------------------------------------------------------------------------- /libs/paystack-actions.ts: -------------------------------------------------------------------------------- 1 | import PaystackPop from '@paystack/inline-js'; 2 | 3 | export const callPaystackPop = (paystackArgs: Record): void => { 4 | const paystack = new PaystackPop(); 5 | paystack.newTransaction(paystackArgs); 6 | }; 7 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | '@babel/preset-env', 5 | { 6 | targets: { 7 | node: 'current', 8 | }, 9 | }, 10 | ], 11 | '@babel/preset-typescript', 12 | ], 13 | }; 14 | -------------------------------------------------------------------------------- /example/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById('root'), 11 | ); 12 | -------------------------------------------------------------------------------- /dist/paystack-context.d.ts: -------------------------------------------------------------------------------- 1 | import { InitializePayment, PaystackProps } from './types'; 2 | type IPaystackContext = { 3 | config: PaystackProps; 4 | initializePayment: InitializePayment; 5 | onSuccess: () => void; 6 | onClose: () => void; 7 | }; 8 | declare const PaystackContext: import("react").Context; 9 | export default PaystackContext; 10 | -------------------------------------------------------------------------------- /dist/paystack-provider.d.ts: -------------------------------------------------------------------------------- 1 | import { callback, PaystackProps } from './types'; 2 | interface PaystackProviderProps extends PaystackProps { 3 | children: JSX.Element; 4 | onSuccess: callback; 5 | onClose: callback; 6 | } 7 | declare const PaystackProvider: ({ children, onSuccess, onClose, ...config }: PaystackProviderProps) => JSX.Element; 8 | export default PaystackProvider; 9 | -------------------------------------------------------------------------------- /example/src/dist/paystack-context.d.ts: -------------------------------------------------------------------------------- 1 | import { InitializePayment, PaystackProps } from './types'; 2 | type IPaystackContext = { 3 | config: PaystackProps; 4 | initializePayment: InitializePayment; 5 | onSuccess: () => void; 6 | onClose: () => void; 7 | }; 8 | declare const PaystackContext: import("react").Context; 9 | export default PaystackContext; 10 | -------------------------------------------------------------------------------- /example/src/dist/paystack-provider.d.ts: -------------------------------------------------------------------------------- 1 | import { callback, PaystackProps } from './types'; 2 | interface PaystackProviderProps extends PaystackProps { 3 | children: JSX.Element; 4 | onSuccess: callback; 5 | onClose: callback; 6 | } 7 | declare const PaystackProvider: ({ children, onSuccess, onClose, ...config }: PaystackProviderProps) => JSX.Element; 8 | export default PaystackProvider; 9 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /example/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /dist/paystack-consumer.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { PaystackProps } from './types'; 3 | interface PaystackConsumerProps extends PaystackProps { 4 | children: (arg: Record) => any; 5 | onSuccess?: () => void; 6 | onClose?: () => void; 7 | } 8 | declare const PaystackConsumer: React.ForwardRefExoticComponent>; 9 | export default PaystackConsumer; 10 | -------------------------------------------------------------------------------- /example/src/dist/paystack-consumer.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { PaystackProps } from './types'; 3 | interface PaystackConsumerProps extends PaystackProps { 4 | children: (arg: Record) => any; 5 | onSuccess?: () => void; 6 | onClose?: () => void; 7 | } 8 | declare const PaystackConsumer: React.ForwardRefExoticComponent>; 9 | export default PaystackConsumer; 10 | -------------------------------------------------------------------------------- /dist/paystack-button.d.ts: -------------------------------------------------------------------------------- 1 | import { ReactNode } from 'react'; 2 | import { callback, PaystackProps } from './types'; 3 | interface PaystackButtonProps extends PaystackProps { 4 | text?: string; 5 | className?: string; 6 | disabled?: boolean; 7 | children?: ReactNode; 8 | onSuccess?: callback; 9 | onClose?: callback; 10 | } 11 | declare const PaystackButton: ({ text, className, children, onSuccess, onClose, disabled, ...config }: PaystackButtonProps) => JSX.Element; 12 | export default PaystackButton; 13 | -------------------------------------------------------------------------------- /example/src/dist/paystack-button.d.ts: -------------------------------------------------------------------------------- 1 | import { ReactNode } from 'react'; 2 | import { callback, PaystackProps } from './types'; 3 | interface PaystackButtonProps extends PaystackProps { 4 | text?: string; 5 | className?: string; 6 | disabled?: boolean; 7 | children?: ReactNode; 8 | onSuccess?: callback; 9 | onClose?: callback; 10 | } 11 | declare const PaystackButton: ({ text, className, children, onSuccess, onClose, disabled, ...config }: PaystackButtonProps) => JSX.Element; 12 | export default PaystackButton; 13 | -------------------------------------------------------------------------------- /libs/paystack-context.ts: -------------------------------------------------------------------------------- 1 | import {createContext} from 'react'; 2 | import {InitializePayment, PaystackProps} from './types'; 3 | 4 | type IPaystackContext = { 5 | config: PaystackProps; 6 | initializePayment: InitializePayment; 7 | onSuccess: () => void; 8 | onClose: () => void; 9 | }; 10 | 11 | const PaystackContext = createContext({ 12 | config: {} as PaystackProps, 13 | initializePayment: () => null, 14 | onSuccess: () => null, 15 | onClose: () => null, 16 | }); 17 | 18 | export default PaystackContext; 19 | -------------------------------------------------------------------------------- /example/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /example/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 5vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 30vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /libs/paystack-provider.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PaystackContext from './paystack-context'; 3 | import usePaystackPayment from './use-paystack'; 4 | import {callback, PaystackProps} from './types'; 5 | 6 | interface PaystackProviderProps extends PaystackProps { 7 | children: JSX.Element; 8 | onSuccess: callback; 9 | onClose: callback; 10 | } 11 | 12 | const PaystackProvider = ({ 13 | children, 14 | onSuccess, 15 | onClose, 16 | ...config 17 | }: PaystackProviderProps): JSX.Element => { 18 | const initializePayment = usePaystackPayment(config); 19 | 20 | return ( 21 | 22 | {children} 23 | 24 | ); 25 | }; 26 | 27 | export default PaystackProvider; 28 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import typescript from 'rollup-plugin-typescript2'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import external from 'rollup-plugin-peer-deps-external'; 4 | import resolve from '@rollup/plugin-node-resolve'; 5 | import pkg from './package.json'; 6 | //import * as react from 'react'; 7 | //import * as reactDom from 'react-dom'; 8 | 9 | export default { 10 | input: 'libs/index.ts', 11 | output: [ 12 | { 13 | file: pkg.main, 14 | format: 'cjs', 15 | exports: 'named', 16 | sourcemap: true, 17 | }, 18 | { 19 | file: pkg.module, 20 | format: 'es', 21 | exports: 'named', 22 | sourcemap: true, 23 | }, 24 | ], 25 | plugins: [ 26 | external(), 27 | resolve(), 28 | typescript({ 29 | rollupCommonJSResolveHack: true, 30 | clean: true, 31 | }), 32 | commonjs(), 33 | ], 34 | }; 35 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [18.x, 20.x, 22.*] 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | - name: Use Node.js ${{ matrix.node-version }} 24 | uses: actions/setup-node@v1 25 | with: 26 | node-version: ${{ matrix.node-version }} 27 | - run: yarn install 28 | - run: npm run lint 29 | - run: npm run build 30 | - run: npm test 31 | -------------------------------------------------------------------------------- /libs/paystack-button.tsx: -------------------------------------------------------------------------------- 1 | import React, {ReactNode} from 'react'; 2 | import usePaystackPayment from './use-paystack'; 3 | import {callback, PaystackProps} from './types'; 4 | 5 | interface PaystackButtonProps extends PaystackProps { 6 | text?: string; 7 | className?: string; 8 | disabled?: boolean; 9 | children?: ReactNode; 10 | onSuccess?: callback; 11 | onClose?: callback; 12 | } 13 | 14 | const PaystackButton = ({ 15 | text, 16 | className, 17 | children, 18 | onSuccess, 19 | onClose, 20 | disabled, 21 | ...config 22 | }: PaystackButtonProps): JSX.Element => { 23 | const initializePayment = usePaystackPayment(config); 24 | 25 | return ( 26 | 33 | ); 34 | }; 35 | 36 | export default PaystackButton; 37 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.5", 7 | "@testing-library/react": "^14.0.0", 8 | "@testing-library/user-event": "^14.4.3", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-scripts": "^5.0.1" 12 | }, 13 | "scripts": { 14 | "start": "DISABLE_ESLINT_PLUGIN=true react-scripts --openssl-legacy-provider start", 15 | "build": "react-scripts --openssl-legacy-provider build", 16 | "test": "react-scripts test", 17 | "eject": "react-scripts eject" 18 | }, 19 | "eslintConfig": { 20 | "extends": "react-app" 21 | }, 22 | "browserslist": { 23 | "production": [ 24 | ">0.2%", 25 | "not dead", 26 | "not op_mini all" 27 | ], 28 | "development": [ 29 | "last 1 chrome version", 30 | "last 1 firefox version", 31 | "last 1 safari version" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /libs/test/paystack-button.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {cleanup} from '@testing-library/react-hooks'; 3 | import {render, fireEvent} from '@testing-library/react'; 4 | import {callPaystackPop} from '../paystack-actions'; 5 | import PaystackButton from '../paystack-button'; 6 | import {config} from './fixtures'; 7 | 8 | jest.mock('../paystack-actions'); 9 | 10 | const componentProps = { 11 | ...config, 12 | className: 'btn', 13 | text: 'Pay my damn money', 14 | onSuccess: (): any => null, 15 | onClose: (): any => null, 16 | }; 17 | 18 | describe('', () => { 19 | beforeEach(() => { 20 | // @ts-ignore 21 | callPaystackPop = jest.fn(); 22 | }); 23 | 24 | afterAll(() => { 25 | cleanup(); 26 | document.body.innerHTML = ''; 27 | }); 28 | 29 | it('render PaystackButton', () => { 30 | const tree = ; 31 | const {getByText}: Record = render(tree); 32 | // Click button 33 | fireEvent.click(getByText('Pay my damn money')); 34 | // @ts-ignore 35 | expect(callPaystackPop).toHaveBeenCalledTimes(1); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | .idea 60 | .DS_Store 61 | .code 62 | 63 | yarn.lock 64 | 65 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Ayeni Olusegun 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 13 | > all 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 21 | > THE SOFTWARE. -------------------------------------------------------------------------------- /libs/test/paystack-provider.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {cleanup} from '@testing-library/react-hooks'; 3 | import {render, fireEvent} from '@testing-library/react'; 4 | import {callPaystackPop} from '../paystack-actions'; 5 | import PaystackConsumer from '../paystack-consumer'; 6 | import {config} from './fixtures'; 7 | 8 | jest.mock('../paystack-actions'); 9 | 10 | const componentProps = { 11 | ...config, 12 | text: 'Pay my damn money', 13 | onSuccess: (): any => null, 14 | onClose: (): any => null, 15 | }; 16 | 17 | describe('', () => { 18 | beforeEach(() => { 19 | // @ts-ignore 20 | callPaystackPop = jest.fn(); 21 | }); 22 | 23 | afterAll(() => { 24 | cleanup(); 25 | document.body.innerHTML = ''; 26 | }); 27 | 28 | it('render PaystackProvider', () => { 29 | const tree = ( 30 | 31 | {({initializePayment}: Record): JSX.Element => ( 32 | 33 | )} 34 | 35 | ); 36 | const {getByText}: Record = render(tree); 37 | // Click button 38 | fireEvent.click(getByText('Use render props 2000')); 39 | // @ts-ignore 40 | expect(callPaystackPop).toHaveBeenCalledTimes(1); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import globals from 'globals'; 2 | import pluginJs from '@eslint/js'; 3 | import tseslint from 'typescript-eslint'; 4 | import pluginReact from 'eslint-plugin-react'; 5 | import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; 6 | import PluginJest from 'eslint-plugin-jest'; 7 | 8 | export default [ 9 | { 10 | files: ['libs/test/**'], 11 | ...PluginJest.configs['flat/recommended'], 12 | rules: { 13 | ...PluginJest.configs['flat/recommended'].rules, 14 | 'jest/prefer-expect-assertions': 'off', 15 | }, 16 | }, 17 | { 18 | files: ['**/*.{js,ts,jsx,tsx}'], 19 | }, 20 | { 21 | files: ['**/*.js'], 22 | languageOptions: {sourceType: 'commonjs'}, 23 | }, 24 | { 25 | languageOptions: {globals: globals.browser}, 26 | }, 27 | pluginJs.configs.recommended, 28 | ...tseslint.configs.recommended, 29 | pluginReact.configs.flat.recommended, 30 | eslintPluginPrettierRecommended, 31 | { 32 | ignores: ['example/', 'dist/', 'babel.config.js', 'jest.config.js'], 33 | }, 34 | { 35 | rules: { 36 | '@typescript-eslint/no-explicit-any': 'off', 37 | '@typescript-eslint/camelcase': 'off', 38 | '@typescript-eslint/no-unused-vars': 'off', 39 | '@typescript-eslint/ban-ts-ignore': 'off', 40 | '@typescript-eslint/interface-name-prefix': 'off', 41 | '@typescript-eslint/ban-ts-comment': 'off', 42 | }, 43 | }, 44 | ]; 45 | -------------------------------------------------------------------------------- /libs/paystack-consumer.tsx: -------------------------------------------------------------------------------- 1 | import React, {forwardRef, useContext, FunctionComponentElement} from 'react'; 2 | import PaystackProvider from './paystack-provider'; 3 | import {PaystackProps} from './types'; 4 | import PaystackContext from './paystack-context'; 5 | 6 | interface PaystackConsumerProps extends PaystackProps { 7 | children: (arg: Record) => any; 8 | onSuccess?: () => void; 9 | onClose?: () => void; 10 | } 11 | 12 | const PaystackConsumerChild = ({ 13 | children, 14 | ref, 15 | }: { 16 | children: any; 17 | ref: any; 18 | }): FunctionComponentElement => { 19 | const {config, initializePayment, onSuccess, onClose} = useContext(PaystackContext); 20 | 21 | const completeInitializePayment = (): void => initializePayment({config, onSuccess, onClose}); 22 | return children({initializePayment: completeInitializePayment, ref}); 23 | }; 24 | 25 | // eslint-disable-next-line react/display-name 26 | const PaystackConsumer = forwardRef( 27 | ( 28 | {children, onSuccess: paraSuccess, onClose: paraClose, ...others}: PaystackConsumerProps, 29 | ref: any, 30 | ): JSX.Element => { 31 | const onSuccess = paraSuccess ? paraSuccess : (): any => null; 32 | const onClose = paraClose ? paraClose : (): any => null; 33 | return ( 34 | 35 | {children} 36 | 37 | ); 38 | }, 39 | ); 40 | 41 | export default PaystackConsumer; 42 | -------------------------------------------------------------------------------- /dist/types.d.ts: -------------------------------------------------------------------------------- 1 | export type Currency = 'NGN' | 'GHS' | 'USD' | 'ZAR' | 'KES' | 'XOF'; 2 | export type PaymentChannels = 'bank' | 'card' | 'qr' | 'ussd' | 'mobile_money' | 'eft' | 'bank_transfer' | 'payattitude'; 3 | type Bearer = 'account' | 'subaccount'; 4 | type phone = number | string; 5 | interface PaystackCustomFields { 6 | display_name: string; 7 | variable_name: string; 8 | value: any; 9 | } 10 | interface PaystackMetadata { 11 | custom_fields: PaystackCustomFields[]; 12 | } 13 | interface PaystackMetadata { 14 | [key: string]: any; 15 | } 16 | interface PaystackConnectSplit { 17 | account_id: string; 18 | share: number; 19 | } 20 | export type callback = (response?: any) => void; 21 | export interface PaystackProps { 22 | publicKey: string; 23 | email: string; 24 | amount: number; 25 | firstname?: string; 26 | lastname?: string; 27 | phone?: phone; 28 | reference?: string; 29 | metadata?: PaystackMetadata; 30 | currency?: Currency | string; 31 | channels?: PaymentChannels[] | string[]; 32 | label?: string; 33 | plan?: string; 34 | quantity?: number; 35 | subaccount?: string; 36 | transaction_charge?: number; 37 | bearer?: Bearer; 38 | split_code?: string; 39 | split?: Record; 40 | connect_split?: PaystackConnectSplit[]; 41 | connect_account?: string; 42 | onBankTransferConfirmationPending?: callback; 43 | } 44 | export type InitializePayment = (options: { 45 | onSuccess?: callback; 46 | onClose?: callback; 47 | config?: Omit; 48 | }) => void; 49 | export type HookConfig = Omit, 'publicKey'> & Pick; 50 | export {}; 51 | -------------------------------------------------------------------------------- /example/src/dist/types.d.ts: -------------------------------------------------------------------------------- 1 | export type Currency = 'NGN' | 'GHS' | 'USD' | 'ZAR' | 'KES' | 'XOF'; 2 | export type PaymentChannels = 'bank' | 'card' | 'qr' | 'ussd' | 'mobile_money' | 'eft' | 'bank_transfer' | 'payattitude'; 3 | type Bearer = 'account' | 'subaccount'; 4 | type phone = number | string; 5 | interface PaystackCustomFields { 6 | display_name: string; 7 | variable_name: string; 8 | value: any; 9 | } 10 | interface PaystackMetadata { 11 | custom_fields: PaystackCustomFields[]; 12 | } 13 | interface PaystackMetadata { 14 | [key: string]: any; 15 | } 16 | interface PaystackConnectSplit { 17 | account_id: string; 18 | share: number; 19 | } 20 | export type callback = (response?: any) => void; 21 | export interface PaystackProps { 22 | publicKey: string; 23 | email: string; 24 | amount: number; 25 | firstname?: string; 26 | lastname?: string; 27 | phone?: phone; 28 | reference?: string; 29 | metadata?: PaystackMetadata; 30 | currency?: Currency | string; 31 | channels?: PaymentChannels[] | string[]; 32 | label?: string; 33 | plan?: string; 34 | quantity?: number; 35 | subaccount?: string; 36 | transaction_charge?: number; 37 | bearer?: Bearer; 38 | split_code?: string; 39 | split?: Record; 40 | connect_split?: PaystackConnectSplit[]; 41 | connect_account?: string; 42 | onBankTransferConfirmationPending?: callback; 43 | } 44 | export type InitializePayment = (options: { 45 | onSuccess?: callback; 46 | onClose?: callback; 47 | config?: Omit; 48 | }) => void; 49 | export type HookConfig = Omit, 'publicKey'> & Pick; 50 | export {}; 51 | -------------------------------------------------------------------------------- /libs/types.ts: -------------------------------------------------------------------------------- 1 | export type Currency = 'NGN' | 'GHS' | 'USD' | 'ZAR' | 'KES' | 'XOF'; 2 | 3 | export type PaymentChannels = 4 | | 'bank' 5 | | 'card' 6 | | 'qr' 7 | | 'ussd' 8 | | 'mobile_money' 9 | | 'eft' 10 | | 'bank_transfer' 11 | | 'payattitude'; 12 | 13 | type Bearer = 'account' | 'subaccount'; 14 | 15 | type phone = number | string; 16 | 17 | interface PaystackCustomFields { 18 | display_name: string; 19 | variable_name: string; 20 | value: any; 21 | } 22 | 23 | interface PaystackMetadata { 24 | custom_fields: PaystackCustomFields[]; 25 | } 26 | 27 | interface PaystackMetadata { 28 | [key: string]: any; 29 | } 30 | 31 | interface PaystackConnectSplit { 32 | account_id: string; 33 | share: number; 34 | } 35 | 36 | export type callback = (response?: any) => void; 37 | 38 | export interface PaystackProps { 39 | publicKey: string; 40 | email: string; 41 | amount: number; 42 | firstname?: string; 43 | lastname?: string; 44 | phone?: phone; 45 | reference?: string; 46 | metadata?: PaystackMetadata; 47 | currency?: Currency | string; 48 | channels?: PaymentChannels[] | string[]; 49 | label?: string; 50 | plan?: string; 51 | quantity?: number; 52 | subaccount?: string; 53 | transaction_charge?: number; 54 | bearer?: Bearer; 55 | split_code?: string; 56 | split?: Record; 57 | connect_split?: PaystackConnectSplit[]; 58 | connect_account?: string; 59 | onBankTransferConfirmationPending?: callback; 60 | } 61 | 62 | export type InitializePayment = (options: { 63 | onSuccess?: callback; 64 | onClose?: callback; 65 | config?: Omit; 66 | }) => void; 67 | 68 | export type HookConfig = Omit, 'publicKey'> & 69 | Pick; 70 | -------------------------------------------------------------------------------- /example/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /libs/use-paystack.ts: -------------------------------------------------------------------------------- 1 | import {HookConfig, InitializePayment} from './types'; 2 | import {callPaystackPop} from './paystack-actions'; 3 | 4 | export default function usePaystackPayment(hookConfig: HookConfig): InitializePayment { 5 | function initializePayment({config, onSuccess, onClose}: Parameters[0]): void { 6 | const args = {...hookConfig, ...config}; 7 | 8 | const { 9 | publicKey, 10 | firstname, 11 | lastname, 12 | phone, 13 | email, 14 | amount, 15 | reference, 16 | metadata, 17 | currency = 'NGN', 18 | channels, 19 | label, 20 | plan, 21 | quantity, 22 | subaccount, 23 | transaction_charge, 24 | bearer, 25 | split, 26 | split_code, 27 | connect_account, 28 | connect_split, 29 | onBankTransferConfirmationPending, 30 | } = args; 31 | const paystackArgs: Record = { 32 | onSuccess: onSuccess ? onSuccess : () => null, 33 | onCancel: onClose ? onClose : () => null, 34 | key: publicKey, 35 | email, 36 | amount, 37 | ...(firstname && {firstname}), 38 | ...(lastname && {lastname}), 39 | ...(phone && {phone}), 40 | ...(reference && {ref: reference}), 41 | ...(currency && {currency}), 42 | ...(channels && {channels}), 43 | ...(metadata && {metadata}), 44 | ...(label && {label}), 45 | ...(onBankTransferConfirmationPending && {onBankTransferConfirmationPending}), 46 | ...(subaccount && {subaccount}), 47 | ...(transaction_charge && {transaction_charge}), 48 | ...(bearer && {bearer}), 49 | ...(split && {split}), 50 | ...(split_code && {split_code}), 51 | ...(plan && {plan}), 52 | ...(quantity && {quantity}), 53 | ...(connect_split && {connect_split}), 54 | ...(connect_account && {connect_account}), 55 | }; 56 | 57 | callPaystackPop(paystackArgs); 58 | } 59 | 60 | return initializePayment; 61 | } 62 | -------------------------------------------------------------------------------- /example/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './logo.svg'; 3 | import {usePaystackPayment, PaystackButton, PaystackConsumer} from './dist/index.es'; 4 | import './App.css'; 5 | 6 | const config = { 7 | reference: new Date().getTime().toString(), 8 | email: 'user@example.com', 9 | amount: 20000, 10 | publicKey: 'pk_test_a137d402b5975716e89952a898aad2832c961d69', 11 | firstname: 'cool', 12 | lastname: 'story', 13 | /*split: { //if you want to use transaction split 14 | "type": "percentage", 15 | "bearer_type": "all", 16 | "subaccounts": [ 17 | { 18 | "subaccount": "ACCT_mtl3xzwjfhcldkw", 19 | "share": 30 20 | }, 21 | { 22 | "subaccount": "ACCT_y19ht107y44o294", 23 | "share": 20 24 | } 25 | ] 26 | }*/ 27 | }; 28 | 29 | const onSuccess = (reference) => { 30 | // Implementation for whatever you want to do with reference and after success call. 31 | console.log('reference', reference); 32 | }; 33 | 34 | const onClose = () => { 35 | // implementation for whatever you want to do when the Paystack dialog closed. 36 | console.log('closed'); 37 | }; 38 | 39 | const PaystackHookExample = () => { 40 | const initializePayment = usePaystackPayment(config); 41 | return ( 42 |
43 | 50 |
51 | ); 52 | }; 53 | 54 | const PaystackHookSplitParameterExample = () => { 55 | const initializePayment = usePaystackPayment(config); 56 | return ( 57 |
58 | 65 |
66 | ); 67 | }; 68 | 69 | function App() { 70 | const componentProps = { 71 | ...config, 72 | text: 'Paystack Button Implementation', 73 | onSuccess, 74 | onClose, 75 | }; 76 | 77 | return ( 78 |
79 |
80 | logo 81 |

82 | Edit src/App.js and save to reload. 83 |

84 |
85 | 86 | 87 | 88 | 89 | {({initializePayment}) => { 90 | return ( 91 | 94 | ); 95 | }} 96 | 97 |
98 | ); 99 | } 100 | 101 | export default App; 102 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-paystack", 3 | "version": "6.0.0", 4 | "description": "This is an reactJS library for implementing paystack payment gateway", 5 | "main": "dist/index.js", 6 | "module": "dist/index.es.js", 7 | "typings": "dist/index.d.ts", 8 | "jsnext:main": "dist/index.es.js", 9 | "scripts": { 10 | "build": "rm -rf dist && rollup -c --bundleConfigAsCjs", 11 | "build:watch": "rm -rf dist && rollup -c --watch --bundleConfigAsCjs", 12 | "format": "prettier --write '**/**/*.{js,}'", 13 | "lint": "eslint .", 14 | "lint:fix": "npm run lint -- --fix", 15 | "test": "jest --env=jsdom", 16 | "test:watch": "jest --watch --verbose --env=jsdom" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/iamraphson/react-paystack.git" 21 | }, 22 | "keywords": [ 23 | "Javascript", 24 | "github", 25 | "ReactJS", 26 | "Open Source", 27 | "payments", 28 | "paystack", 29 | "Gateway" 30 | ], 31 | "author": "Olusegun Ayeni ", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/iamraphson/react-paystack/issues" 35 | }, 36 | "homepage": "https://github.com/iamraphson/react-paystack#readme", 37 | "peerDependencies": { 38 | "react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", 39 | "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" 40 | }, 41 | "dependencies": { 42 | "@paystack/inline-js": "^2.19.2", 43 | "@testing-library/dom": "^10.4.0" 44 | }, 45 | "devDependencies": { 46 | "@babel/core": "^7.25.2", 47 | "@babel/preset-env": "^7.25.3", 48 | "@babel/preset-typescript": "^7.24.7", 49 | "@eslint/js": "^9.8.0", 50 | "@rollup/plugin-commonjs": "^26.0.1", 51 | "@rollup/plugin-node-resolve": "^15.0.1", 52 | "@rollup/plugin-typescript": "^11.1.6", 53 | "@testing-library/react": "^16.0.0", 54 | "@testing-library/react-hooks": "^8.0.1", 55 | "@types/jest": "^29.5.12", 56 | "@types/react": "^18.3.3", 57 | "@types/react-dom": "^18.3.0", 58 | "@typescript-eslint/eslint-plugin": "^6.17.0", 59 | "@typescript-eslint/parser": "^6.17.0", 60 | "babel-eslint": "^10.1.0", 61 | "babel-jest": "^29.5.0", 62 | "eslint": "^9.8.0", 63 | "eslint-config-prettier": "^9.1.0", 64 | "eslint-config-standard": "^17.0.0", 65 | "eslint-plugin-jest": "^28.7.0", 66 | "eslint-plugin-prettier": "^5.2.1", 67 | "eslint-plugin-react": "^7.35.0", 68 | "globals": "^15.9.0", 69 | "jest": "^29.5.0", 70 | "jest-environment-jsdom": "^29.5.0", 71 | "prettier": "^3.3.3", 72 | "react": "^18.3.1", 73 | "react-dom": "^18.3.1", 74 | "react-test-renderer": "^18.3.1", 75 | "rollup": "^4.20.0", 76 | "rollup-plugin-babel": "^4.4.0", 77 | "rollup-plugin-commonjs": "^10.1.0", 78 | "rollup-plugin-node-resolve": "^5.2.0", 79 | "rollup-plugin-peer-deps-external": "^2.2.4", 80 | "rollup-plugin-typescript2": "^0.36.0", 81 | "ts-jest": "^29.2.4", 82 | "typescript": "^5.5.4", 83 | "typescript-eslint": "^8.0.0" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `yarn start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `yarn test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `yarn build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `yarn eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `yarn build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | // "incremental": true, /* Enable incremental compilation */ 5 | "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 6 | "module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 7 | "lib": [ 8 | "es6", 9 | "dom", 10 | "es2016", 11 | "es2017", 12 | "esnext" 13 | ], /* Specify library files to be included in the compilation. */ 14 | "allowJs": false, /* Allow javascript files to be compiled. */ 15 | // "checkJs": true, /* Report errors in .js files. */ 16 | "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 17 | "declaration": true, /* Generates corresponding '.d.ts' file. */ 18 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 19 | "sourceMap": true, /* Generates corresponding '.map' file. */ 20 | "outDir": "./dist", /* Redirect output structure to the directory. */ 21 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 22 | // "composite": true, /* Enable project compilation */ 23 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 24 | // "removeComments": true, /* Do not emit comments to output. */ 25 | "noEmit": true, /* Do not emit outputs. */ 26 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 27 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 28 | "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 29 | /* Strict Type-Checking Options */ 30 | "strict": true, /* Enable all strict type-checking options. */ 31 | "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 32 | "strictNullChecks": true, /* Enable strict null checks. */ 33 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 34 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 35 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 36 | "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 37 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 38 | "skipLibCheck": true, 39 | /* Additional Checks */ 40 | "noUnusedLocals": true, /* Report errors on unused locals. */ 41 | "noUnusedParameters": true, /* Report errors on unused parameters. */ 42 | "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 43 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 44 | 45 | /* Module Resolution Options */ 46 | "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 47 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 48 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 49 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 50 | // "typeRoots": [], /* List of folders to include type definitions from. */ 51 | // "types": [], /* Type declaration files to be included in compilation. */ 52 | "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 53 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 54 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 55 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 56 | 57 | /* Source Map Options */ 58 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 59 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 60 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 61 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 62 | 63 | /* Experimental Options */ 64 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 65 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 66 | 67 | /* Advanced Options */ 68 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 69 | }, 70 | "include": ["libs"], 71 | "exclude": [ 72 | "node_modules", 73 | "test", 74 | "example", 75 | "dist", 76 | "**/*.spec.ts", 77 | "rollup.config.js", 78 | "build" 79 | ] 80 | } 81 | -------------------------------------------------------------------------------- /libs/test/use-paystack.test.tsx: -------------------------------------------------------------------------------- 1 | import {renderHook, cleanup} from '@testing-library/react-hooks'; 2 | import {render, fireEvent} from '@testing-library/react'; 3 | import React, {act} from 'react'; 4 | import usePaystackPayment from '../use-paystack'; 5 | import {callPaystackPop} from '../paystack-actions'; 6 | import {config} from './fixtures'; 7 | import {Currency, PaymentChannels} from '../types'; 8 | 9 | jest.mock('../paystack-actions'); 10 | const onSuccess = jest.fn(); 11 | const onClose = jest.fn(); 12 | 13 | describe('usePaystackPayment()', () => { 14 | beforeEach(() => { 15 | // @ts-ignore 16 | callPaystackPop = jest.fn(); 17 | }); 18 | 19 | afterAll(() => { 20 | cleanup(); 21 | document.body.innerHTML = ''; 22 | }); 23 | 24 | it('should use usePaystackPayment', () => { 25 | const {result, rerender} = renderHook(() => usePaystackPayment(config)); 26 | rerender(); 27 | 28 | act(() => { 29 | result.current({onSuccess, onClose}); 30 | }); 31 | 32 | expect(onSuccess).toHaveBeenCalledTimes(0); 33 | expect(onClose).toHaveBeenCalledTimes(0); 34 | expect(callPaystackPop).toHaveBeenCalledTimes(1); 35 | }); 36 | 37 | it('should pass if initializePayment does not accept any args', () => { 38 | const {result, rerender} = renderHook(() => usePaystackPayment(config)); 39 | rerender(); 40 | 41 | act(() => { 42 | result.current({}); 43 | }); 44 | 45 | expect(callPaystackPop).toHaveBeenCalledTimes(1); 46 | }); 47 | 48 | it('should usePaystackPayment accept all parameters', () => { 49 | const {result, rerender} = renderHook(() => 50 | usePaystackPayment({ 51 | ...config, 52 | metadata: { 53 | custom_fields: [ 54 | { 55 | display_name: 'Mobile Number', 56 | variable_name: 'mobile_number', 57 | value: '2348012345678', 58 | }, 59 | ], 60 | cart_id: 398, 61 | }, 62 | currency: 'GHS', 63 | channels: ['mobile_money', 'ussd'], 64 | plan: '1', 65 | subaccount: 'ACCT_olodo', 66 | quantity: 2, 67 | split_code: 'SPL_ehshjerjh1232343', 68 | firstname: '404', 69 | lastname: 'err', 70 | phone: '080456789012', 71 | split: { 72 | type: 'percentage', 73 | bearer_type: 'all-proportional', 74 | subaccounts: [ 75 | { 76 | subaccount: 'ACCT_hhs519xgrbocdtr', 77 | share: 30, 78 | }, 79 | { 80 | subaccount: 'ACCT_fpzizqxofyshxs5', 81 | share: 20, 82 | }, 83 | ], 84 | }, 85 | connect_account: 'C_ACT_911WDFTY6GW', 86 | connect_split: [ 87 | { 88 | account_id: 'C_ACT_911WDFTY6GW', 89 | share: 70, 90 | }, 91 | { 92 | account_id: 'C_ACT_DHRI3498VB', 93 | share: 8, 94 | }, 95 | ], 96 | }), 97 | ); 98 | rerender(); 99 | act(() => { 100 | result.current({}); 101 | }); 102 | 103 | expect(callPaystackPop).toHaveBeenCalledTimes(1); 104 | }); 105 | 106 | it('should usePaystackPayment accept parameters', () => { 107 | const currency: Currency = 'GHS'; 108 | const channels: PaymentChannels[] = ['mobile_money', 'ussd']; 109 | const moreConfig = { 110 | amount: config.amount, 111 | email: config.email, 112 | metadata: { 113 | custom_fields: [ 114 | { 115 | display_name: 'Mobile Number', 116 | variable_name: 'mobile_number', 117 | value: '2348012345678', 118 | }, 119 | ], 120 | cart_id: 398, 121 | }, 122 | currency, 123 | channels, 124 | plan: '1', 125 | subaccount: 'ACCT_olodo', 126 | 'data-custom-button': 'savage', 127 | quantity: 2, 128 | split_code: 'SPL_ehshjerjh1232343', 129 | firstname: '404', 130 | lastname: 'err', 131 | phone: '080456789012', 132 | split: { 133 | type: 'percentage', 134 | bearer_type: 'all-proportional', 135 | subaccounts: [ 136 | { 137 | subaccount: 'ACCT_hhs519xgrbocdtr', 138 | share: 30, 139 | }, 140 | { 141 | subaccount: 'ACCT_fpzizqxofyshxs5', 142 | share: 20, 143 | }, 144 | ], 145 | }, 146 | connect_account: 'C_ACT_911WDFTY6GW', 147 | connect_split: [ 148 | { 149 | account_id: 'C_ACT_911WDFTY6GW', 150 | share: 70, 151 | }, 152 | { 153 | account_id: 'C_ACT_DHRI3498VB', 154 | share: 8, 155 | }, 156 | ], 157 | }; 158 | 159 | const {result, rerender} = renderHook(() => 160 | usePaystackPayment({ 161 | ...config, 162 | }), 163 | ); 164 | 165 | rerender(); 166 | act(() => { 167 | result.current({ 168 | config: moreConfig, 169 | onSuccess, 170 | onClose, 171 | }); 172 | }); 173 | 174 | expect(onSuccess).toHaveBeenCalledTimes(0); 175 | expect(onClose).toHaveBeenCalledTimes(0); 176 | expect(callPaystackPop).toHaveBeenCalledTimes(1); 177 | }); 178 | 179 | it('should be accept trigger from other component', () => { 180 | const {result, rerender} = renderHook(() => usePaystackPayment(config)); 181 | rerender(); 182 | const Btn = (): any => ( 183 |
184 | {' '} 185 |
186 | ); 187 | 188 | const {getByText}: Record = render(); 189 | // Click button 190 | fireEvent.click(getByText('Donation')); 191 | // @ts-ignore 192 | expect(callPaystackPop).toHaveBeenCalledTimes(1); 193 | }); 194 | 195 | it('should accept being rendered in a container', () => { 196 | const wrapper: React.FC = ({children}: Record) => { 197 | return
{children}
; 198 | }; 199 | 200 | const {result, rerender} = renderHook(() => usePaystackPayment(config), {wrapper}); 201 | 202 | rerender(); 203 | act(() => { 204 | result.current({}); 205 | }); 206 | 207 | // @ts-ignore 208 | expect(callPaystackPop).toHaveBeenCalledTimes(1); 209 | }); 210 | }); 211 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-paystack 2 | 3 | This is a react library for implementing paystack payment gateway 4 | 5 | ## Demo 6 | 7 | ![Demo](React_App_01.png?raw=true "Demo Image") 8 | 9 | ## Get Started 10 | 11 | This React library provides a wrapper to add Paystack Payments to your React application 12 | 13 | ### Install 14 | 15 | ```sh 16 | npm install react-paystack --save 17 | ``` 18 | 19 | or with `yarn` 20 | 21 | ```sh 22 | yarn add react-paystack 23 | ``` 24 | 25 | ### Usage 26 | 27 | This library can be implemented into any react application in 3 different ways: 28 | 1. By using hooks provided by the library 29 | 2. By using a button provided by the library 30 | 3. By using a context consumer provided by the library 31 | 32 | Note that all 3 implementations produce the same results. 33 | 34 | 35 | ### 1. Using the paystack hook 36 | ```javascript 37 | import React from 'react'; 38 | import logo from './logo.svg'; 39 | import { usePaystackPayment } from 'react-paystack'; 40 | import './App.css'; 41 | 42 | const config = { 43 | reference: (new Date()).getTime().toString(), 44 | email: "user@example.com", 45 | amount: 20000, //Amount is in the country's lowest currency. E.g Kobo, so 20000 kobo = N200 46 | publicKey: 'pk_test_dsdfghuytfd2345678gvxxxxxxxxxx', 47 | }; 48 | 49 | // you can call this function anything 50 | const onSuccess = (reference) => { 51 | // Implementation for whatever you want to do with reference and after success call. 52 | console.log(reference); 53 | }; 54 | 55 | // you can call this function anything 56 | const onClose = () => { 57 | // implementation for whatever you want to do when the Paystack dialog closed. 58 | console.log('closed') 59 | } 60 | 61 | const PaystackHookExample = () => { 62 | const initializePayment = usePaystackPayment(config); 63 | return ( 64 |
65 | 68 |
69 | ); 70 | }; 71 | 72 | function App() { 73 | return ( 74 |
75 |
76 | logo 77 |

78 | Edit src/App.js and save to reload. 79 |

80 | 86 | Learn React 87 | 88 |
89 | 90 |
91 | ); 92 | } 93 | 94 | export default App; 95 | ``` 96 | 97 | 98 | ### 2. Using the paystack button 99 | 100 | ``` javascript 101 | import React from 'react'; 102 | import logo from './logo.svg'; 103 | import { PaystackButton } from 'react-paystack'; 104 | import './App.css'; 105 | 106 | const config = { 107 | reference: (new Date()).getTime().toString(), 108 | email: "user@example.com", 109 | amount: 20000, //Amount is in the country's lowest currency. E.g Kobo, so 20000 kobo = N200 110 | publicKey: 'pk_test_dsdfghuytfd2345678gvxxxxxxxxxx', 111 | }; 112 | 113 | function App() { 114 | // you can call this function anything 115 | const handlePaystackSuccessAction = (reference) => { 116 | // Implementation for whatever you want to do with reference and after success call. 117 | console.log(reference); 118 | }; 119 | 120 | // you can call this function anything 121 | const handlePaystackCloseAction = () => { 122 | // implementation for whatever you want to do when the Paystack dialog closed. 123 | console.log('closed') 124 | } 125 | 126 | const componentProps = { 127 | ...config, 128 | text: 'Paystack Button Implementation', 129 | onSuccess: (reference) => handlePaystackSuccessAction(reference), 130 | onClose: handlePaystackCloseAction, 131 | }; 132 | 133 | return ( 134 |
135 |
136 | logo 137 |

138 | Edit src/App.js and save to reload. 139 |

140 | 146 | Learn React 147 | 148 |
149 | 150 |
151 | ); 152 | } 153 | 154 | export default App; 155 | ``` 156 | 157 | ### 3. using the Paystack consumer 158 | ``` Javascript 159 | import React from 'react'; 160 | import logo from './logo.svg'; 161 | import { PaystackConsumer } from 'react-paystack'; 162 | import './App.css'; 163 | 164 | const config = { 165 | reference: (new Date()).getTime().toString(), 166 | email: "user@example.com", 167 | amount: 20000, //Amount is in the country's lowest currency. E.g Kobo, so 20000 kobo = N200 168 | publicKey: 'pk_test_dsdfghuytfd2345678gvxxxxxxxxxx', 169 | }; 170 | 171 | // you can call this function anything 172 | const handleSuccess = (reference) => { 173 | // Implementation for whatever you want to do with reference and after success call. 174 | console.log(reference); 175 | }; 176 | 177 | // you can call this function anything 178 | const handleClose = () => { 179 | // implementation for whatever you want to do when the Paystack dialog closed. 180 | console.log('closed') 181 | } 182 | 183 | function App() { 184 | const componentProps = { 185 | ...config, 186 | text: 'Paystack Button Implementation', 187 | onSuccess: (reference) => handleSuccess(reference), 188 | onClose: handleClose 189 | }; 190 | 191 | return ( 192 |
193 |
194 | logo 195 |

196 | Edit src/App.js and save to reload. 197 |

198 | 204 | Learn React 205 | 206 |
207 | 208 | {({initializePayment}) => } 209 | 210 |
211 | ); 212 | } 213 | 214 | export default App; 215 | ``` 216 | 217 | ### Sending Metadata with Transaction 218 | If you want to send extra metadata e.g. Transaction description, user that made the transaction. Edit your config like so: 219 | 220 | ```ts 221 | const config = { 222 | // Your required fields 223 | metadata: { 224 | custom_fields: [ 225 | { 226 | display_name: 'description', 227 | variable_name: 'description', 228 | value: 'Funding Wallet' 229 | } 230 | // To pass extra metadata, add an object with the same fields as above 231 | ] 232 | } 233 | }; 234 | ``` 235 | 236 | Please checkout [Paystack Documentation](https://developers.paystack.co/docs/paystack-inline) for other available options you can add to the tag 237 | 238 | ## Deployment 239 | 240 | REMEMBER TO CHANGE THE KEY WHEN DEPLOYING ON A LIVE/PRODUCTION SYSTEM 241 | 242 | ## Contributing 243 | 244 | 1. Fork it! 245 | 2. Create your feature branch: `git checkout -b feature-name` 246 | 3. Commit your changes: `git commit -am 'Some commit message'` 247 | 4. Push to the branch: `git push origin feature-name` 248 | 5. Submit a pull request 😉😉 249 | 250 | ## How can I thank you? 251 | 252 | Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or Any Social Media? Spread the word! 253 | 254 | Don't forget to [follow me on twitter](https://twitter.com/iamraphson)! 255 | 256 | Thanks! 257 | Olusegun Ayeni. 258 | 259 | ## License 260 | 261 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details 262 | -------------------------------------------------------------------------------- /dist/index.es.js: -------------------------------------------------------------------------------- 1 | import React, { createContext, forwardRef, useContext } from 'react'; 2 | 3 | /****************************************************************************** 4 | Copyright (c) Microsoft Corporation. 5 | 6 | Permission to use, copy, modify, and/or distribute this software for any 7 | purpose with or without fee is hereby granted. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 14 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 | PERFORMANCE OF THIS SOFTWARE. 16 | ***************************************************************************** */ 17 | /* global Reflect, Promise, SuppressedError, Symbol */ 18 | 19 | 20 | var __assign = function() { 21 | __assign = Object.assign || function __assign(t) { 22 | for (var s, i = 1, n = arguments.length; i < n; i++) { 23 | s = arguments[i]; 24 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 25 | } 26 | return t; 27 | }; 28 | return __assign.apply(this, arguments); 29 | }; 30 | 31 | function __rest(s, e) { 32 | var t = {}; 33 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 34 | t[p] = s[p]; 35 | if (s != null && typeof Object.getOwnPropertySymbols === "function") 36 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 37 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 38 | t[p[i]] = s[p[i]]; 39 | } 40 | return t; 41 | } 42 | 43 | typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { 44 | var e = new Error(message); 45 | return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; 46 | }; 47 | 48 | function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),t.push.apply(t,a);}return t}function e(e){for(var t=1;t=0||(o[t]=n[t]);return o}(n,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(n,t)&&(o[t]=n[t]);}return o}function s(n,e){return function(n){if(Array.isArray(n))return n}(n)||function(n,e){var t=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null==t)return;var a,o,i=[],r=!0,c=!1;try{for(t=t.call(n);!(r=(a=t.next()).done)&&(i.push(a.value),!e||i.length!==e);r=!0);}catch(n){c=!0,o=n;}finally{try{r||null==t.return||t.return();}finally{if(c)throw o}}return i}(n,e)||p(n,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(n){return function(n){if(Array.isArray(n))return u(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||p(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(n,e){if(n){if("string"==typeof n)return u(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return "Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(n):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(n,e):void 0}}function u(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,a=new Array(e);t-1})).map((function(n){return t[n].nodeName}));}return n}var b='\n \n \n \n',k='\n\n\n\n',w='\n \n',x='\n\n';var M={height:"50px",width:"auto",borderRadius:"3px",padding:"10px",locale:"en",type:"pay"},V=function(n){return n&&"object"===t(n)?Object.keys(M).reduce((function(t,a){return e(e({},t),{},r({},a,n[a]||M[a]))}),{}):M},P='\n .pre-checkout-modal {\n display: none;\n position: fixed;\n z-index: 1;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100%;\n overflow: auto;\n background-color: rgba(0, 0, 0, 0.75);\n transition: all 0.2s ease;\n }\n\n .pre-checkout-modal.show {\n display: block;\n }\n\n .pre-checkout-modal__content {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n background-color: #fefefe;\n padding: 20px;\n padding-bottom: max(30px, env(safe-area-inset-bottom));\n width: 100%;\n border-radius: 6px 6px 0 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n max-width: 350px;\n\n box-sizing: border-box;\n transform: translateY(238px);\n transition: transform 0.3s cubic-bezier(.16,.81,.32,1);\n }\n\n .modal-wrapper {\n width: 100%;\n }\n\n .payment-info {\n position: relative;\n padding-bottom: 15px;\n border-bottom: solid 1px whitesmoke;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n width: 100%;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n }\n\n .customer-email {\n color: #737373;\n font-size: 13px;\n line-height: 16px;\n }\n\n .customer-info {\n flex: 1;\n text-align: right;\n }\n\n .merchant-logo {\n display: flex;\n align-items: center;\n height: 30px;\n }\n .transaction-amount {\n margin-top: 5px;\n font-size: 13px;\n line-height: 16px;\n color: #737373;\n }\n\n .amount {\n color: #29b263;\n font-weight: bold;\n }\n\n @media only screen and (min-width: 500px) {\n .pre-checkout-modal__content {\n bottom: 0;\n top: 0;\n margin: auto;\n border-radius: 6px;\n height: fit-content;\n }\n }\n\n .pre-checkout-modal__content.show {\n transform: translateY(0);\n margin: 0 auto;\n margin-top: 100px;\n }\n\n .pre-checkout-modal__content > * {\n margin-top: 0;\n margin-bottom: 40px;\n }\n .pre-checkout-modal__content > *:last-child {\n margin-bottom: 0;\n }\n\n .pre-checkout-modal__content svg {\n margin: auto;\n width: 100%;\n }\n\n #inline-button-wordmark--white {\n position: absolute;\n bottom: -50px;\n margin: auto;\n left: 0;\n right: 0;\n width: fit-content;\n }\n\n #inline-button-wordmark--grey {\n display: none;\n }\n\n .pre-checkout-modal__content #apple-pay-mark--light {\n margin-bottom: 16px;\n }\n\n .pre-checkout-modal p {\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n color: #4E4E4E;\n line-height: 140%;\n font-size: 14px;\n font-weight: 500;\n margin: 0;\n padding: 0 20px;\n text-align: center;\n letter-spacing: -0.3px;\n }\n\n .pre-checkout-modal button {\n height: 42px;\n width: 100%;\n \n box-sizing: border-box;\n border-radius: 3px;\n font-size: 14px;\n line-height: 24px;\n cursor: pointer;\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n }\n\n .pre-checkout-modal .open-paystack-pop-button {\n background: #FAFAFA;\n border: 1px solid #F2F3F3;\n color: #4E4E4E;\n font-weight: 500;\n }\n\n .pre-checkout-modal .open-paystack-pop-button:hover, \n .pre-checkout-modal .open-paystack-pop-button:active, \n .pre-checkout-modal .open-paystack-pop-button:focus {\n background: #F2F3F3;\n }\n\n .pre-checkout-modal .pay-with-vault-button {\n font-weight: 700;\n background: #44b669;\n background: linear-gradient(to bottom, #44b669 0%, #40ad57 100%);\n border: solid 1px #49a861;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n outline: none;\n color: white;\n transition: all 300ms;\n }\n\n .pre-checkout-modal .vault-instruction {\n color: #2f3d4d;\n font-size: 14px;\n letter-spacing: normal;\n line-height: 1.4;\n margin: 0 auto 24px;\n padding: 0;\n }\n .vault-logo-container {\n width: 74px;\n height: 20px;\n margin: 0 auto 24px\n }\n .vault-logo-container img {\n height: 100%;\n width: 100%;\n border-radius: 8px;\n }\n .vault-divider {\n margin-bottom: 16px;\n margin-top: 24px;\n position: relative;\n }\n .vault-divider__container {\n align-items: center;\n bottom: 0;\n display: flex;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n }\n .vault-divider__line {\n border: 1px dashed #ccced0;\n width: 100%;\n }\n .vault-divider__text-container {\n display: flex;\n justify-content: center;\n position: relative;\n }\n .vault-divider__text {\n background-color: #fff;\n color: #999da1;\n font-size: 14px;\n font-weight: 500;\n letter-spacing: -.3px;\n line-height: 19.6px;\n margin-bottom: 2px;\n padding: 0 8px;\n }\n\n #payment-request-button {\n width: 100%;\n height: fit-content;\n margin: 24px 0 16px 0;\n }\n\n #paystackpop-button {\n padding: 0 16px;\n }\n\n #apple-pay-close-button {\n position: absolute;\n text-align: center;\n top: 0;\n right: -26px;\n height: 16px;\n width: 16px;\n padding: 0;\n display: inline-block;\n z-index: 3;\n border-radius: 50%;\n background: transparent;\n transition: all 300ms;\n outline: none;\n cursor: pointer;\n border: none;\n }\n\n #apple-pay-close-button svg {\n width: initial;\n }\n \n #apple-pay-close-button:hover {\n background-color: #e22b28;\n }\n\n @media only screen and (max-width: 500px) {\n .pre-checkout-modal__content {\n max-width: 500px;\n border-radius: 0;\n padding-bottom: 0;\n }\n\n .modal-wrapper {\n padding: 0;\n }\n\n .vault-logo-container {\n width: 74px;\n height: 20px;\n }\n\n #inline-button-wordmark--white {\n display: none\n }\n \n #inline-button-wordmark--grey {\n display: block;\n width: 100%;\n margin: 16px 0;\n height: 13px;\n }\n\n #apple-pay-close-button {\n display: none;\n }\n }\n',_=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return Number(parseFloat(n/100).toFixed(2))},L={headers:{accept:"application/json, text/plain, */*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8","content-type":"application/x-www-form-urlencoded","sec-ch-ua-mobile":"?0","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"cross-site"},referrerPolicy:"no-referrer-when-downgrade",method:"POST",mode:"cors",credentials:"omit"};function S(n){return Object.keys(n).reduce((function(e,t){var a=encodeURIComponent(t),o=encodeURIComponent(n[t]),i="".concat(a,"=").concat(o);return [].concat(l(e),[i])}),[]).join("&")}var E=function(n){return {biannually:"BIANNUAL PLAN",annually:"ANNUAL PLAN"}[n]||"".concat(n.toUpperCase()," PLAN")},A=function(){try{return window.location&&"https:"===window.location.protocol&&window.ApplePaySession&&window.ApplePaySession.supportsVersion(m.applePayVersion)}catch(n){return !1}},T=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return A()&&n.includes("apple_pay")};function q(){var n=0;return Array.from(document.querySelectorAll("body *")).forEach((function(e){var t=window.getComputedStyle(e),a=parseFloat(t.zIndex);!Number.isNaN(a)&&a>n&&(n=a);})),n}function H(n){var e=document.createElement("iframe");return e.setAttribute("frameBorder","0"),e.setAttribute("allowtransparency","true"),e.id=n,e.style.display="none",e}function I(n){return n.querySelector("apple-pay-button")||n.querySelector("#apple-pay-button")}function z(n){return document.querySelector("#".concat(n))}function O(n,e,a){var o=e.channels,i=void 0===o?[]:o,r=e.styles,c=void 0===r?{}:r,s={applePay:!1};return new Promise((function(e,o){if(n)if(T(i)){if(I(n))return s.applePay=!0,void e(s);(function(n,e){return new Promise((function(t,a){var o=document.createElement("script");o.src=n,o.addEventListener("load",(function(){t(!0);})),o.addEventListener("error",(function(){o.remove(),a(!1);})),e?e.appendChild(o):document.head.appendChild(o);}))})("https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js",n).then((function(){if(a&&1077497!==a&&window&&!Array.isArray(window.webpackJsonp))throw new Error("Incorrect data type for 'webpackJsonp', expected array, got ".concat(t(window.webpackJsonp),". Switching to fallback apple pay button"));!function(n,e){var t=e.styles,a=e.theme,o=document.createElement("style"),i=function(n){var e=n.height,t=n.width,a=n.borderRadius,o=n.padding;return "\n apple-pay-button {\n --apple-pay-button-width: ".concat(t,";\n --apple-pay-button-height: ").concat(e,";\n --apple-pay-button-border-radius: ").concat(a,";\n --apple-pay-button-padding: ").concat(o,";\n --apple-pay-button-box-sizing: border-box;\n width: ").concat(t,";\n }\n")}(t);o.type="text/css",o.styleSheet?o.styleSheet.cssText=i:o.appendChild(document.createTextNode(i)),n.appendChild(o);var r=document.createElement("apple-pay-button");r.setAttribute("buttonstyle","light"===a?"white":"black"),r.setAttribute("type",t.type),r.setAttribute("locale",t.locale),n.appendChild(r);}(n,{styles:V(c.applePay),theme:c.theme}),s.applePay=!0,e(s);})).catch((function(){!function(n,e){var t=e.styles,a=e.theme,o=document.createElement("style"),i=function(n){var e=n.height,t=n.width,a=n.borderRadius,o=n.padding,i=n.type,r=n.locale;return "\n @supports (-webkit-appearance: -apple-pay-button) { \n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n width: ".concat(t,";\n height: ").concat(e,";\n border-radius: ").concat(a,";\n padding: ").concat(o,";\n -apple-pay-button-type: ").concat(i,";\n -webkit-locale: ").concat(r,";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n")}(t);o.type="text/css",o.styleSheet?o.styleSheet.cssText=i:o.appendChild(document.createTextNode(i)),n.appendChild(o);var r=document.createElement("button");r.classList.add("apple-pay-button","light"===a?"apple-pay-button-white":"apple-pay-button-black"),r.id="apple-pay-button";var c=document.createElement("span");c.classList.add("logo"),r.appendChild(c),n.appendChild(r);}(n,{styles:V(c.applePay),theme:c.theme}),s.applePay=!0,e(s);}));}else o("No wallet payment method is available on this device");else o("Container to mount elements was not provided");}))}function j(n){for(;n.firstChild;)n.removeChild(n.firstChild);}var N="payment-request-button",U="paystackpop-button",Z="pay-with-vault-button";function F(n){var e=document.createElement("button");return e.id=U,e.className="open-paystack-pop-button",e.innerText=n,e}function R(n){return n.querySelector("#".concat(U))}function B(){var n=document.createElement("div");return n.id=N,n}function D(n){return n.querySelector("#".concat(N))}function W(){var n=document.createElement("button");return n.className="pay-with-vault-button",n.id=Z,n.innerText="Pay with Vault",n}function J(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=document.createElement("div");t.className="vault-logo-container",t.innerHTML=x,n.appendChild(t);var a=document.createElement("p");a.id="instruction",a.className="vault-instruction",a.innerHTML="Access your saved cards and bank details for faster, more secure payments",n.appendChild(a);var o=W();n.appendChild(o);var i=document.createElement("div");if(i.className="vault-divider",i.innerHTML='
or
',n.appendChild(i),e.canPayWithApplePay){var r=B();n.appendChild(r);}var c=F("Use other payment methods");n.appendChild(c);}function K(n){var e=document.createElement("div");e.innerHTML='\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n',n.appendChild(e);var t=document.createElement("p");t.id="apple-pay-description",t.innerHTML="Pay with Apple Pay to complete your purchase without filling a form",n.appendChild(t);var a=B();n.appendChild(a);var o=F("More payment options");n.appendChild(o);}var Q=[{value:"key",required:!0,types:["string"]},{value:"amount",required:!0,or:["plan","planCode"],types:["string","number"]},{value:"currency",required:!1,types:["string"]},{value:"email",required:!0,or:["customerCode"],types:["string"]},{value:"label",required:!1,types:["string"]},{value:"firstName",required:!1,types:["string"]},{value:"lastName",required:!1,types:["string"]},{value:"reference",required:!1,types:["string"]},{value:"phone",required:!1,types:["string"]},{value:"customerCode",required:!1,override:"email",types:["string"]},{value:"channels",required:!1,types:["array"]},{value:"paymentRequest",required:!1,types:["string","number"]},{value:"paymentPage",required:!1,types:["string"]},{value:"hash",required:!1,types:["string"]},{value:"container",required:!1,types:["string"]},{value:"metadata",required:!1,types:["object"]},{value:"subaccountCode",required:!1,types:["string"]},{value:"bearer",required:!1,types:["string"]},{value:"transactionCharge",required:!1,types:["string","number"]},{value:"planCode",required:!1,override:"amount",types:["string"]},{value:"subscriptionCount",required:!1,types:["number"]},{value:"planInterval",required:!1,types:["string"]},{value:"subscriptionLimit",required:!1,types:["number"]},{value:"subscriptionStartDate",required:!1,types:["string"]},{value:"accessCode",required:!1,types:["string"]},{value:"onError",required:!1,types:["function"]},{value:"onLoad",required:!1,types:["function"]},{value:"onSuccess",required:!1,types:["function"]},{value:"onCancel",required:!1,types:["function"]},{value:"callback",required:!1,types:["function"]},{value:"onClose",required:!1,types:["function"]},{value:"onBankTransferConfirmationPending",required:!1,types:["function"]},{value:"firstname",required:!1,types:["string"]},{value:"lastname",required:!1,types:["string"]},{value:"customer_code",required:!1,types:["string"]},{value:"payment_request",required:!1,types:["string","number"]},{value:"subaccount",required:!1,types:["string"]},{value:"transaction_charge",required:!1,types:["number","string"]},{value:"plan",required:!1,types:["string"]},{value:"quantity",required:!1,types:["number"]},{value:"interval",required:!1,types:["string"]},{value:"invoice_limit",required:!1,types:["number","string"]},{value:"start_date",required:!1,types:["string"]},{value:"payment_page",required:!1,types:["number","string"]},{value:"order_id",required:!1,types:["number"]},{value:"ref",required:!1,types:["string"]},{value:"card",required:!1,types:["string"]},{value:"bank",required:!1,types:["string"]},{value:"split",required:!1,types:["object"]},{value:"split_code",required:!1,types:["string"]},{value:"transaction_type",required:!1,types:["string"]},{value:"subscription",required:!1,types:["number"]},{value:"language",required:!1,types:["string"]},{value:"connect_account",required:!1,types:["string"]},{value:"connect_split",required:!1,types:["array"]}];function G(n){var t,a=e({},n);a.metadata=n.metadata||{},a.metadata.referrer=(t=window.location.href)&&t.length>500?t.split("?")[0]:t,a.metadata=JSON.stringify(a.metadata),a.mode="popup",n.split&&"string"!=typeof n.split&&(a.split=JSON.stringify(a.split));return void 0!==a.card&&["false",!1].indexOf(a.card)>-1&&(a.channels=["bank"],delete a.card),void 0!==a.bank&&["false",!1].indexOf(a.bank)>-1&&(a.channels=["card"],delete a.bank),[{to:"firstname",from:"firstName"},{to:"lastname",from:"lastName"},{to:"customer_code",from:"customerCode"},{to:"payment_request",from:"paymentRequest"},{to:"subaccount",from:"subaccountCode"},{to:"transaction_charge",from:"transactionCharge"},{to:"plan",from:"planCode"},{to:"quantity",from:"subscriptionCount"},{to:"interval",from:"planInterval"},{to:"invoice_limit",from:"subscriptionLimit"},{to:"start_date",from:"subscriptionStartDate"},{to:"ref",from:"reference"}].forEach((function(n){a[n.from]&&(a[n.to]=a[n.from],delete a[n.from]);})),Object.values(n).forEach((function(e,t){if("function"==typeof e){var o=Object.keys(n)[t];delete a[o];}})),a}var Y=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"],X=window&&window.navigator&&(window.navigator.platform||window.navigator.userAgentData&&window.navigator.userAgentData.platform),$=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=n.platform,t=n.userAgent,a=void 0===t?window&&window.navigator&&window.navigator.userAgent:t,o=e||X;return Y.includes(o)||a.includes("Mac")&&"ontouchend"in document},nn=function(n,e,t){var a="".concat(m.paystackApiUrl,"transaction/update_log/").concat(n),o={Authorization:"Bearer ".concat(e)};return fetch(a,{method:"POST",body:JSON.stringify({payload:JSON.stringify(t)}),headers:o})},en=function(n,e){var t="".concat(m.paystackApiUrl,"transaction/set_ip/").concat(n),a={Authorization:"Bearer ".concat(e)};return fetch(t,{method:"POST",headers:a})},tn={initializeLog:function(n){var e=n||{},t=e.attempts,a=e.authentication,o=e.errors,i=e.history;this.log={start_time:Math.round(Date.now()/1e3),time_spent:0,attempts:t||0,authentication:a,errors:o||0,success:!1,mobile:$(),input:[],history:i||[]};},getTimeSpent:function(){var n=Math.round(Date.now()/1e3);return this.log.time_spent=n-this.log.start_time,this.log.time_spent},logAPIResponse:function(n,e){switch(n.status){case"success":return this.logApiSuccess(e);case"failed":return this.logApiError(n.message);default:return !1}},logValidationResponse:function(n){return this.log.history.push({type:"action",message:n,time:this.getTimeSpent()}),this.saveLog()},logAttempt:function(n){var e="Attempted to pay";return n&&(e+=" with ".concat(n)),this.log.attempts+=1,this.log.history.push({type:"action",message:e,time:this.getTimeSpent()}),this.saveLog()},logApiError:function(n){var e="Error";return n&&(e+=": ".concat(n)),this.log.errors+=1,this.log.history.push({type:"error",message:e,time:this.getTimeSpent()}),this.saveLog()},logApiSuccess:function(n){var e="Successfully paid";return n&&(e+=" with ".concat(n)),this.log.success=!0,this.log.history.push({type:"success",message:e,time:this.getTimeSpent()}),this.saveLog()},saveLog:function(){try{if(this.response)return nn(this.id,this.response.merchant_key,this.log)}catch(n){}},saveIpAddress:function(){try{if(this.response)return en(this.id,this.response.merchant_key)}catch(n){}}},an=["language","connect_account"],on={requestInline:function(){var n=this,t=this.urlParameters,a=t.language,o=t.connect_account,i=c(t,an),r=e({"Content-Type":"application/json"},a&&{"Accept-Language":a});return (this.accessCode?fetch(new URL("transaction/verify_access_code/".concat(this.accessCode),m.paystackApiUrl).toString(),{headers:r}):fetch(new URL("/checkout/request_inline",m.paystackApiUrl).toString(),{method:"POST",body:JSON.stringify(i),headers:e(e({},r),o&&{"x-connect-account":o})})).then((function(n){return n.json()})).then((function(e){if(!1===e.status)throw new Error(e.message);return n.response=e.data,n.id=e.data.id,n.status=e.data.transaction_status,n.accessCode=e.data.access_code,n.log=null,Object.assign(n,tn),n.initializeLog(e.data.log),n.saveIpAddress(),e.data}))}},rn=function(){function n(e){a(this,n),function(n){function e(n,e){this.message=n,this.issues=e||[];}if(!n||"object"!==t(n))throw new e("Transaction parameters should be a non-empty object");var a=n;if("accessCode"in a)return {accessCode:a.accessCode};Object.keys(a).forEach((function(n){void 0!==Q.find((function(e){return e.value===n}))||delete a[n];}));var o=Object.keys(a),i=[];if(Q.filter((function(n){return n.required})).forEach((function(n){var e=!a[n.value],t=n.or?n.or.some((function(n){return a[n]})):null;e&&!t&&i.push({message:"Required parameter missing: ".concat(n.value)});})),o.forEach((function(n){var e=a[n],o=Q.find((function(e){return e.value===n})),r=t(e);"object"===r&&Array.isArray(e)&&(r="array"),o.types.indexOf(r)<=-1&&i.push({message:"Invalid parameter type: ".concat(n),validTypes:o.types});})),o.forEach((function(n){var e=Q.find((function(e){return e.value===n}));e.override&&delete a[e.override];})),i.length)throw new e("Invalid transaction parameters",i)}(e),this.parameters=e,this.urlParameters=G(e),this.id=null,this.status=null,this.accessCode=e.accessCode||null,this.authorizationUrl=null,this.errors=[],this.response=null,this.isActive=!0;var o=e.onError,i=e.onLoad,r=e.onSuccess,c=e.onCancel,s=e.callback,l=e.onClose,p=e.onBankTransferConfirmationPending;this.callbacks={onError:o,onLoad:i,onSuccess:r,onCancel:c,onBankTransferConfirmationPending:p},this.deprecatedCallbacks={callback:s,onClose:l},Object.assign(this,on);}return i(n,[{key:"onSetupError",value:function(n){this.logError(n),this.callbacks.onError&&this.callbacks.onError(n);}},{key:"onLoad",value:function(n){var e=n.id,t=n.customer,a=n.accessCode;Object.assign(this,{id:e,customer:t,accessCode:a}),this.authorizationUrl="".concat(m.checkoutUrl).concat(a),this.callbacks.onLoad&&this.callbacks.onLoad({id:e,customer:t,accessCode:a});}},{key:"onSuccess",value:function(n){this.isActive=!1,this.response=n,this.status=n.status,this.callbacks.onSuccess&&this.callbacks.onSuccess(n),this.deprecatedCallbacks.callback&&this.deprecatedCallbacks.callback(n);}},{key:"setStatus",value:function(n){this.status=n;}},{key:"onCancel",value:function(){this.callbacks.onCancel&&this.callbacks.onCancel(),this.deprecatedCallbacks.onClose&&this.deprecatedCallbacks.onClose();}},{key:"cancel",value:function(){this.isActive=!1,this.onCancel();}},{key:"onBankTransferConfirmationPending",value:function(){this.cancel(),this.callbacks.onBankTransferConfirmationPending&&this.callbacks.onBankTransferConfirmationPending();}},{key:"logError",value:function(n){this.errors.push(n);}}]),n}(),cn=console?console.warn||console.log:function(){};function sn(n,e,t){cn('"'.concat(n,'" has been deprecated, please use "').concat(e,'". ').concat(t));}var ln,pn=["preload","inlineTransaction"],un=["container","styles","onElementsMount"];function dn(n,e){if(!n.length)return null;var t=n.filter((function(n){var t,a,o,i,r=!n.status||"abandoned"===n.status,c=(t=n.parameters,a=e,o=Object.keys(t).sort().join("")===Object.keys(a).sort().join(""),i=Object.values(t).sort().join("")===Object.values(a).sort().join(""),o&&i);return r&&c}));return t.length?t[t.length-1]:null}function hn(n){var e=n.checkoutIframe,t=n.urlParameters;e&&t&&e.contentWindow.postMessage({type:"inline:url",path:"newTransaction",params:t},"*");}var Cn="trackCheckoutClosed",mn="trackPaymentError",yn="trackPaymentAttempt",fn="trackPaymentCompletion";function vn(n){throw cn(n),new Error(n)}var gn,bn,kn=function(){function n(e){var t,o;a(this,n),this.id=function(){for(var n="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=0;t<5;t+=1)n+=e.charAt(Math.floor(Math.random()*e.length));return n}(),this.transactions=[],this.isOpen=!1,this.isLoaded=!1,this.isDeprecatedApi=e&&e.isDeprecatedApi,e&&e.isEmbed?this.isEmbed=!0:e&&e.isPaymentRequest&&(e.container&&z(e.container)||vn("A container is required to mount the payment request button"),this.paymentRequestContainer=z(e.container),this.paymentRequestTransaction=null),this.preCheckoutModal=null,this.backgroundIframe=function(n){var e=H("inline-background-".concat(n));e.style.cssText="\n z-index: 999999999999999;\n background: transparent;\n background: rgba(0, 0, 0, 0.75); \n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n margin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n transition: opacity 0.3s;\n -webkit-transition: opacity 0.3s;\n visibility: hidden;\n display: none;\n",document.body.appendChild(e);var t=e.contentWindow.document;return t.open(),t.write('\n \n \n\n \n \n \n \n Paystack Popup Loader\n \n \n\n \n
\n
\n
\n
\n
\n
\n \n\n \n'),t.close(),e}(this.id),this.checkoutIframe=(t=this.id,(o=H("inline-checkout-".concat(t))).src="".concat(m.checkoutUrl,"popup"),o.style.cssText="\n z-index: 999999999999999;\n background: transparent;\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n margin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n visibility: hidden;\n display: none;\n height: 100%;\n",o.setAttribute("allowpaymentrequest","true"),o.setAttribute("allow","payment; clipboard-read; clipboard-write"),document.body.appendChild(o),o),this.registerListeners();}return i(n,[{key:"registerListeners",value:function(){var n=this;window.addEventListener("message",(function(e){var t="".concat(e.origin,"/")===m.checkoutUrl,a=n.checkoutIframe&&n.checkoutIframe.contentWindow===e.source,o=n.isEmbed;t||a?n.respondToEvent(e):o&&n.respondToEmbedEvents(e);}));}},{key:"sendAnalyticsEventToCheckout",value:function(n,e){this.checkoutIframe.contentWindow.postMessage({type:"analytics",action:n,params:e},"*");}},{key:"checkout",value:function(n){this.activeTransaction()&&this.activeTransaction().cancel(),ln=this;var e=dn(this.transactions,n)||new rn(n);return new Promise((function(n,t){e.requestInline().then((function(t){var a=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=n.platform,t=n.userAgent,a=void 0===t?window&&window.navigator&&window.navigator.userAgent:t,o=e||X,i=a&&!!a.match(/Version\/[\d.]+.*Safari/),r=o&&/(Mac)/i.test(o);return $()||r&&i}()&&T(t.channels),o=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=!!n.custom_filters&&n.custom_filters.recurring,t=n.plan_details,a=e||t,o=!!n.link_config&&n.link_config.enabled&&n.link_config.has_payment_instruments;return !a&&o}(t);o||a?(ln.preloadTransaction({inlineTransaction:e}),ln.preCheckoutModal=function(n,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=document.querySelector("#pre-checkout-modal-".concat(n));if(a){if(R(a)&&D(a))return a;a.remove();}var o=document.createElement("div");o.classList.add("pre-checkout-modal"),o.id="pre-checkout-modal-".concat(n),o.style.zIndex=q()+1;var i=document.createElement("div");i.classList.add("pre-checkout-modal__content"),o.appendChild(i);var r=e||{},c=r.merchant_logo,s=r.merchant_name,l=r.email,p=r.amount,u=r.currency,d=r.label,h=new Intl.NumberFormat("en",{style:"currency",currency:u,currencyDisplay:"code",maximumFractionDigits:2,minimumFractionDigits:0}).format(p/100),C=document.createElement("div");C.classList.add("payment-info"),C.innerHTML='\n
\n
').concat(d||l,'
\n
Pay ').concat(h,"
\n
"),i.appendChild(C),i.innerHTML+=w;var m=document.createElement("div");m.classList.add("modal-wrapper"),t.canPayWithVault?J(m,{canPayWithApplePay:t.canPayWithApplePay}):K(m),m.innerHTML=m.innerHTML+b+k,i.appendChild(m);var y=document.createElement("style");return y.textContent=P,document.body.appendChild(y),document.body.appendChild(o),o}(ln.id,t,{canPayWithVault:o,canPayWithApplePay:a}),a?(ln.paymentRequestContainer=D(ln.preCheckoutModal),O(ln.paymentRequestContainer,{channels:t.channels,styles:{applePay:{width:"100%",type:"pay",height:"42px",padding:"15px",borderRadius:"5px"}}},t.merchant_id).then((function(){ln.registerPaymentRequestEventListeners(),ln.openPreCheckoutModal();})).catch((function(){o?(D(ln.preCheckoutModal).remove(),ln.openPreCheckoutModal()):(ln.closePreCheckoutModal(),ln.animateCheckoutIn());})).finally((function(){n(e);}))):(ln.openPreCheckoutModal(),n(e))):(ln.newTransaction({inlineTransaction:e}),n(e));})).catch((function(n){e.onSetupError({status:!1,message:n.message}),t(n);}));}))}},{key:"openPreCheckoutModal",value:function(){var n;this.registerPreCheckoutModalEventListeners(),n=this.preCheckoutModal,new Promise((function(e,t){try{var a=n.querySelector(".pre-checkout-modal__content");n.classList.add("show"),setTimeout((function(){a.classList.add("show"),e(!0);}),50);}catch(n){t(n);}}));}},{key:"registerPreCheckoutModalEventListeners",value:function(){var n,e=this,t=!1,a=this.activeTransaction();document.addEventListener("touchstart",(function(e){e.preventDefault(),t||(t=!0,n=setTimeout((function(){t=!1;}),125));}),!0),document.addEventListener("touchend",(function(e){e.target&&e.target.isSameNode(ln.preCheckoutModal)&&t&&(clearTimeout(n),ln.closePreCheckoutModal(),a&&a.cancel()),t=!1;}),!0);var o=R(this.preCheckoutModal),i=this.preCheckoutModal.querySelector("#".concat(Z));o.onclick=function(){e.closePreCheckoutModal(),e.animateCheckoutIn();},i&&(i.onclick=function(){e.closePreCheckoutModal(),e.animateCheckoutIn(),e.checkoutIframe.contentWindow.postMessage({type:"inline:pay-with-vault"},"*");});var r=function(n){return n.querySelector("#apple-pay-close-button")}(this.preCheckoutModal);r.onclick=function(){e.sendAnalyticsEventToCheckout(Cn),e.closePreCheckoutModalAndCancelTransaction();};}},{key:"closePreCheckoutModal",value:function(n){var e;this.preCheckoutModal&&("failed"===n?(e=this.preCheckoutModal)&&(e.querySelector("#apple-pay-mark--light").innerHTML='\n \n \n \n \n \n \n \n',e.querySelector("#apple-pay-description").textContent="An error occurred while paying with Apple Pay. Please try again or use another payment method."):(!function(n){n&&(n.querySelector(".pre-checkout-modal__content").classList.remove("show"),n.classList.remove("show"));}(this.preCheckoutModal),this.preCheckoutModal.remove(),this.preCheckoutModal=null));}},{key:"closePreCheckoutModalAndCancelTransaction",value:function(){this.preCheckoutModal&&(this.cancelTransaction(),this.checkoutIframe&&this.checkoutIframe.contentWindow&&this.checkoutIframe.contentWindow.postMessage("close","*"),this.closePreCheckoutModal());}},{key:"newTransaction",value:function(n){var e,t=n.preload,a=n.inlineTransaction,o=c(n,pn),i=this.paymentRequestContainer&&I(this.paymentRequestContainer);this.activeTransaction()&&!i&&this.activeTransaction().cancel();var r=dn(this.transactions,a?a.parameters:o),s=r||a||new rn(o);return r?(s.isActive=!0,e={accessCode:s.accessCode}):(e=s.accessCode?{accessCode:s.accessCode}:s.urlParameters,this.transactions.push(s)),this.isDeprecatedApi||this.open(e,t),s}},{key:"preloadTransaction",value:function(n){var t=this;this.newTransaction(e(e({},n),{},{preload:!0}));return function(){return t.animateCheckoutIn()}}},{key:"paymentRequest",value:function(n){var e=n.container,t=n.styles,a=n.onElementsMount,o=c(n,un);return ln=this,new Promise((function(i,r){var c=document.querySelector("#".concat(n.loadPaystackCheckoutButton));if(A()){ln.activeTransaction()&&ln.activeTransaction().cancel(),e&&z(e)||vn("A container is required to mount the payment request button"),ln.paymentRequestContainer=z(e);var s=dn(ln.transactions,o),l=s||new rn(o);l.requestInline().then((function(n){O(ln.paymentRequestContainer,{channels:n.channels,styles:t},n.merchant_id).then((function(n){a&&a(n);})).catch((function(){a&&a(null);})).finally((function(){if(s?l.isActive=!0:ln.transactions.push(l),ln.registerPaymentRequestEventListeners(),c){var n=ln.preloadTransaction({inlineTransaction:l});c.onclick=n;}i(l);}));})).catch((function(n){l.onSetupError({status:!1,message:n.message}),r(n);}));}else {if(n&&n.loadPaystackCheckoutButton)if(c){var p=ln.preloadTransaction(o);c.onclick=p;}else cn("This device does not support any payment request wallet options. Please consult our documentation at https://developers.paystack.co/docs/paystack-inline to see how to load alternative payment options using 'loadPaystackCheckoutButton'");a&&a(null);var u=ln.activeTransaction();i(u);}}))}},{key:"registerApplePayEventListener",value:function(){var n=this;I(this.paymentRequestContainer).onclick=function(){return n.startApplePay()};}},{key:"registerPaymentRequestEventListeners",value:function(){var n=this.activeTransaction();n&&T(n.response.channels)?this.registerApplePayEventListener():j(this.paymentRequestContainer);}},{key:"startApplePay",value:function(){var n,t,a,o,i,r=this,c="apple pay",s=this.activeTransaction();if(s){var l={channel:"apple_pay",paymentMethod:c,currency:s.currency,amount:s.amount},p={channel:"apple_pay",currency:s.currency,amount:s.amount,timeSpent:s.getTimeSpent()};try{s.logAttempt(c),this.sendAnalyticsEventToCheckout(yn,l);var u=(n={currency:s.response.currency,amount:s.response.amount,merchantName:s.response.merchant_name,interval:s.response.plan_details&&s.response.plan_details.interval},t=n.currency,a=n.amount,o=n.merchantName,i=n.interval,e({countryCode:"NG",currencyCode:t,merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],requiredBillingContactFields:["postalAddress","name","phone","email"],total:{label:"".concat(o," - Paystack"),type:"final",amount:String(_(a))}},"string"==typeof i&&""!==i.trim()&&{lineItems:[{label:E(i),amount:String(_(a))}]})),d=new window.ApplePaySession(m.applePayVersion,u);d.onvalidatemerchant=function(n){var t=function(n){var t=n.transactionId,a=n.validationURL,o=n.merchantName,i=n.domainName,r=void 0===i?window&&window.location&&window.location.hostname:i,c="".concat(m.paymentBaseUrl).concat(m.applePayValidateSessionPath),s=S({transaction:t,sessionUrl:a,displayName:o,domainName:r});return fetch(c,e(e({},L),{},{body:s})).then((function(n){return n.json()}))}({validationURL:n.validationURL,transactionId:s.id,merchantName:s.response.merchant_name});t.then((function(n){"success"!==n.status?s.onSetupError(n):d.completeMerchantValidation(n.data),s.logValidationResponse(n.message);})).catch((function(n){s.onSetupError(n);}));},d.oncancel=function(){ln.preCheckoutModal||s.onCancel();},d.onpaymentauthorized=function(n){var t=n.payment,a=function(n){var t=n.transactionId,a=n.payment,o="".concat(m.paymentBaseUrl).concat(m.applePayChargePath),i=S({transaction:t,paymentObject:JSON.stringify(a)});return fetch(o,e(e({},L),{},{body:i})).then((function(n){return n.json()}))}({transactionId:s.id,payment:t});a.then((function(n){s.logAPIResponse(n,c),"success"===n.status?(d.completePayment(d.STATUS_SUCCESS),s.onSuccess(n),r.sendAnalyticsEventToCheckout(fn,p)):(d.completePayment(d.STATUS_FAILURE),s.onSetupError(n),r.sendAnalyticsEventToCheckout(mn,{channel:"apple_pay",message:n&&n.message||"Transaction attempt failed"})),ln.closePreCheckoutModal(n.status);})).catch((function(n){d.completePayment(d.STATUS_FAILURE),s.onSetupError(n),r.sendAnalyticsEventToCheckout(mn,{channel:"apple_pay",message:n&&n.message||"Error occurred"}),ln.closePreCheckoutModal("failed");}));},d.begin();}catch(n){s.onSetupError(n);}}else vn("Could not initiate apple pay transaction");}},{key:"resumeTransaction",value:function(n){return this.newTransaction({accessCode:n})}},{key:"activeTransaction",value:function(){var n=this.transactions.filter((function(n){return n.isActive})),e=n.length?n[n.length-1]:null;return e}},{key:"cancelTransaction",value:function(n){var e=this.transactions.find((function(e){return e.id===n}))||this.activeTransaction();e&&(e.cancel(),this.close());}},{key:"respondToEvent",value:function(n){if(n){var e,t,a=this.activeTransaction();try{var o=n.data||n.message,i=o.event,r=o.data;if(i)switch(i){case"loaded:checkout":if(this.isLoaded=!0,a)hn({checkoutIframe:this.checkoutIframe,urlParameters:a.urlParameters});break;case"loaded:transaction":e=this.backgroundIframe,(t=e.contentWindow.document)&&(t.getElementById("app-loader").style.display="none"),a.onLoad(r);break;case"error":"setup"===r.type?a.onSetupError(r):a.logError(r);break;case"cancel":case"close":this.close();var c=r&&r.status;c&&a.setStatus(c),!(this.paymentRequestContainer&&I(this.paymentRequestContainer)&&!this.preCheckoutModal)&&(a.isActive=!1),a.onCancel();break;case"transfer:pending":this.close();var s=r&&r.status;s&&a.setStatus(s),a.onBankTransferConfirmationPending();break;case"success":this.close(),a.onSuccess(r);}}catch(n){}}}},{key:"respondToEmbedEvents",value:function(n){var e,t,a=this.activeTransaction(),o=n.data||n.message;if(o&&("string"==typeof o||o instanceof String)){var i={action:t=(e=o)&&"string"==typeof e?e.split(" ")[0]:null,data:t?e.split(" ").slice(2).join(" "):null};if(i&&"PaystackClose"===i.action)i.data&&a.onSuccess(o);"PaystackTLSClose"===i.action&&a.cancel();}}},{key:"animateCheckoutIn",value:function(){var n,e=this;if(!this.isOpen){var t=this.checkoutIframe,a=this.backgroundIframe;(n={checkoutIframe:t,backgroundIframe:a},new Promise((function(e,t){n||t("No dom element provided");var a=n.checkoutIframe,o=n.backgroundIframe;a&&o||t("No dom element provided"),a.style.display="",a.style.visibility="visible",o.style.display="",o.style.visibility="visible",e();}))).then((function(){e.checkoutIframe.contentWindow.postMessage("render","*");})),this.isOpen=!0;}}},{key:"open",value:function(n,e){n&&(hn({checkoutIframe:this.checkoutIframe,urlParameters:n}),e||this.animateCheckoutIn());}},{key:"close",value:function(){var n=this;if(this.isOpen){var e,t=this.checkoutIframe,a=this.backgroundIframe;(e={checkoutIframe:t,backgroundIframe:a},new Promise((function(n,t){e||t("No dom element provided");var a=e.checkoutIframe,o=e.backgroundIframe;a&&o||t("No dom element provided"),o.style.opacity=0,a.style.display="none",a.style.visibility="hidden",setTimeout((function(){o.style.display="none",o.style.visibility="hidden",o.style.opacity=1,n();}),300);}))).then((function(){n.checkoutIframe.contentWindow.postMessage("close","*");})),this.isOpen=!1;}}},{key:"isLoaded",value:function(){return this.isLoaded}}],[{key:"setup",value:function(e){var t=e&&e.container;ln||(ln=new n({isDeprecatedApi:!0,isEmbed:t})),sn("PaystackPop.setup()","new PaystackPop()","Please consult our documentation at https://developers.paystack.co/docs/paystack-inline");var a=ln.newTransaction(e,"deprecated"),o=a.urlParameters;if(t){var i="".concat(m.siteUrl,"/assets/payment/production/inline.html?").concat(y(o)),r=function(n,e){var t=H("embed-checkout-".concat(n));return t.style.cssText="\n background: transparent;\n background: rgba(0,0,0,0);\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n nmargin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n visibility: hidden;\n display: none;\n",t.src=e,t.id=n,t.name=n,t}(ln.id,i);!function(n,e){var t=document.getElementById(n);t.innerHTML="",t.removeAttribute("style"),t.className="paystack-embed-container",t.style.position="relative",t.style.width="100%",t.appendChild(e);}(e.container,r),r.onload=function(){var n;r.contentWindow.postMessage("PaystackOpen ".concat(ln.id),"*"),n=r,new Promise((function(e,t){n||t("No dom element provided"),n.style.display="",n.style.visibility="visible",e();}));};}else a.openIframe=function(){sn("openIframe","open","Please consult our documentation at https://developers.paystack.co/docs/paystack-inline"),ln.open(o);};return a}}]),n}();if(gn=g().length>0,bn=f()&&"FORM"===f().parentElement.tagName,gn&&bn){var wn,xn=function(){var n={},t=f();return g().forEach((function(e){var a=t.getAttribute(e),o=e.split("data-")[1].replace(/-([a-z])/g,(function(n){return n[1].toUpperCase()}));n[o]=a;})),function(n){if(n.buttonId&&!document.getElementById(n.buttonId))throw new Error("Please make sure the buttonId is an element available in the DOM");var t=e({},n);t.buttonText=n.buttonText||"Pay",t.buttonVariant="normal",t.buttonWordmarkVariant="normal";var a=["normal","light"];return n.buttonVariant&&a.indexOf(n.buttonVariant)>-1&&(t.buttonVariant=n.buttonVariant),n.buttonWordmarkVariant&&a.indexOf(n.buttonWordmarkVariant)>-1&&(t.buttonWordmarkVariant=n.buttonWordmarkVariant),t}(n)}(),Mn=f().parentElement;ln||(ln=new kn),function(n){var e;if(n.id)(e=document.getElementById(n.id)).setAttribute("data-inline-id",n.id);else {var t=document.createElement("div");t.id="inline-button-".concat(n.inlineId),t.innerHTML=function(n){var e,t,a={normal:'\n \n \n ',light:b};return "\n \n \n
\n ').concat(a[n.wordmarkVariant||"normal"],"\n
\n ")}(n),n.parent.parentNode.insertBefore(t,n.parent.nextSibling),e=s(t.getElementsByTagName("button"),1)[0];}return e}({inlineId:ln.id,amount:xn.amount/100,currency:xn.currency,id:xn.buttonId,text:xn.buttonText,variant:xn.buttonVariant,wordmarkVariant:xn.buttonWordmarkVariant,parent:f()}).addEventListener("click",(function(n){n.preventDefault(),wn?ln.resumeTransaction(wn.accessCode):wn=ln.newTransaction(e(e({},xn),{},{onSuccess:function(n){var e,t,a,o,i,r;e={type:"hidden",name:"reference",value:n.reference,parent:Mn},t=e.type,a=e.value,o=e.name,i=e.parent,(r=document.createElement("input")).type=t,r.value=a,r.name=o,i.appendChild(r),Mn.submit();}}));}));} 49 | 50 | var callPaystackPop = function (paystackArgs) { 51 | var paystack = new kn(); 52 | paystack.newTransaction(paystackArgs); 53 | }; 54 | 55 | function usePaystackPayment(hookConfig) { 56 | function initializePayment(_a) { 57 | var config = _a.config, onSuccess = _a.onSuccess, onClose = _a.onClose; 58 | var args = __assign(__assign({}, hookConfig), config); 59 | var publicKey = args.publicKey, firstname = args.firstname, lastname = args.lastname, phone = args.phone, email = args.email, amount = args.amount, reference = args.reference, metadata = args.metadata, _b = args.currency, currency = _b === void 0 ? 'NGN' : _b, channels = args.channels, label = args.label, plan = args.plan, quantity = args.quantity, subaccount = args.subaccount, transaction_charge = args.transaction_charge, bearer = args.bearer, split = args.split, split_code = args.split_code, connect_account = args.connect_account, connect_split = args.connect_split, onBankTransferConfirmationPending = args.onBankTransferConfirmationPending; 60 | var paystackArgs = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ onSuccess: onSuccess ? onSuccess : function () { return null; }, onCancel: onClose ? onClose : function () { return null; }, key: publicKey, email: email, amount: amount }, (firstname && { firstname: firstname })), (lastname && { lastname: lastname })), (phone && { phone: phone })), (reference && { ref: reference })), (currency && { currency: currency })), (channels && { channels: channels })), (metadata && { metadata: metadata })), (label && { label: label })), (onBankTransferConfirmationPending && { onBankTransferConfirmationPending: onBankTransferConfirmationPending })), (subaccount && { subaccount: subaccount })), (transaction_charge && { transaction_charge: transaction_charge })), (bearer && { bearer: bearer })), (split && { split: split })), (split_code && { split_code: split_code })), (plan && { plan: plan })), (quantity && { quantity: quantity })), (connect_split && { connect_split: connect_split })), (connect_account && { connect_account: connect_account })); 61 | callPaystackPop(paystackArgs); 62 | } 63 | return initializePayment; 64 | } 65 | 66 | var PaystackButton = function (_a) { 67 | var text = _a.text, className = _a.className, children = _a.children, onSuccess = _a.onSuccess, onClose = _a.onClose, disabled = _a.disabled, config = __rest(_a, ["text", "className", "children", "onSuccess", "onClose", "disabled"]); 68 | var initializePayment = usePaystackPayment(config); 69 | return (React.createElement("button", { className: className, onClick: function () { return initializePayment({ config: config, onSuccess: onSuccess, onClose: onClose }); }, disabled: disabled }, text || children)); 70 | }; 71 | 72 | var PaystackContext = createContext({ 73 | config: {}, 74 | initializePayment: function () { return null; }, 75 | onSuccess: function () { return null; }, 76 | onClose: function () { return null; }, 77 | }); 78 | 79 | var PaystackProvider = function (_a) { 80 | var children = _a.children, onSuccess = _a.onSuccess, onClose = _a.onClose, config = __rest(_a, ["children", "onSuccess", "onClose"]); 81 | var initializePayment = usePaystackPayment(config); 82 | return (React.createElement(PaystackContext.Provider, { value: { config: config, initializePayment: initializePayment, onSuccess: onSuccess, onClose: onClose } }, children)); 83 | }; 84 | 85 | var PaystackConsumerChild = function (_a) { 86 | var children = _a.children, ref = _a.ref; 87 | var _b = useContext(PaystackContext), config = _b.config, initializePayment = _b.initializePayment, onSuccess = _b.onSuccess, onClose = _b.onClose; 88 | var completeInitializePayment = function () { return initializePayment({ config: config, onSuccess: onSuccess, onClose: onClose }); }; 89 | return children({ initializePayment: completeInitializePayment, ref: ref }); 90 | }; 91 | // eslint-disable-next-line react/display-name 92 | var PaystackConsumer = forwardRef(function (_a, ref) { 93 | var children = _a.children, paraSuccess = _a.onSuccess, paraClose = _a.onClose, others = __rest(_a, ["children", "onSuccess", "onClose"]); 94 | var onSuccess = paraSuccess ? paraSuccess : function () { return null; }; 95 | var onClose = paraClose ? paraClose : function () { return null; }; 96 | return (React.createElement(PaystackProvider, __assign({}, others, { onSuccess: onSuccess, onClose: onClose }), 97 | React.createElement(PaystackConsumerChild, { ref: ref }, children))); 98 | }); 99 | 100 | export { PaystackButton, PaystackConsumer, usePaystackPayment }; 101 | //# sourceMappingURL=index.es.js.map 102 | --------------------------------------------------------------------------------