1.1.3 • Published 4 years ago

react-eyowo v1.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

React Eyowo

React integration for Eyowo.

build status npm version

Getting started

Documentation

Example

First, install React Eyowo

npm install react-eyowo --save

or with yarn

yarn add react-eyowo

Usage

import React from 'react';
import { useEyowoPayment, generateBill } from 'react-eyowo';

const App = () => {
	const [billLoading, setLoading] = React.useState('');
	const [billId, setBillId] = React.useState('');
	React.useEffect(() => {
		(async function () {
			setLoading(true);
			try {
				// Returns a bill with an _id required for payment
				const bill = await generateBill('DTGFJ5N-QS84G18-NKWV9PJ-65T9Y9S', 1000);
				setBillId(bill?._id);
			} catch (e) {
				console.log(e);
			}
			setLoading(false);
		})();
	}, []);
	const [loading, makePayment, verificationStatus] = useEyowoPayment({
		billId: billId,
		email: 'joshuaoluikpe@gmail.com',
		eyowoToken: 'DTGFJ5N-QS84G18-NKWV9PJ-65T9Y9S',
		_callback: function () {
			console.log('hi');
		},
		onClose: function () {
			console.log('ooooooooo');
		},
	});

	return billLoading ? 'Generating bill.....' : <button onClick={() => makePayment()}>Pay</button>;
};

export default App;

Variables

These are varaibles to pass to the hooks function

NameTypeDescription
billIdStringRequired. This a mongo id used for the payment.
emailStringRequired. The customer's email.
eyowoTokenStringRequired. This is your API token.It can be found in your dashboard
_callbackFunctionThis is trigged after a successful payment.
onCloseFunctionThis is trigged when the pop up modal is closed.
verifyPaymentBooleanThe default is true. It verifies payment in the callback function after successful transaction.

Return Values

These are destructed values returned from the hooks function

NameTypeDescription
makePaymentFunctionIt triggers the pop up modal.
loadingBooleanLoading state while verifying payment.
verificationStatusObjectThis returns paymentVerificationStatus('approved' or 'failed') and paymentVerificationErrorMessage(error message if status is failed)

Minimum requirements

The minimum supported version of React is v16.8. If you use an older version, upgrade React to use this library.

TypeScript support

No TypeScript support for now

Contributing

If you would like to contribute to React Eyowo,

  1. Clone the project!
  2. Create your feature branch
  3. Push and Commit your changes to that feature branch
  4. Submit a pull request
1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago