SafaricomDarajaFrontEnd
SafaricomDarajaFrontEnd copied to clipboard
A frontend repository showing how to consume Daraja api from the frontend. Shows how to handle errors and status code recieved from safaricom daraja api.
React Mpesa Stk Push App
This is a React application for initiating Mpesa Stk Push transactions. It utilizes the Mpesa Stk Push API to submit transactions and provides real-time status updates through recursive validation.
Features
- Submit Mpesa Stk Push transactions with ease.
- Real-time transaction status updates.
- User-friendly notifications for transaction success, failure, and cancellation.
Prerequisites
Before running the application, ensure you have the following:
- Node.js installed
- npm (Node Package Manager) installed
- Backend API (Assuming it's available at
http://localhost:5000
) - You can find the backend API here: Domains18/Nodejs/Daraja
Installation
-
Clone the repository:
git clone https://github.com/Domains18/SafaricomDarajaFrontEnd.git
-
Navigate to the project directory:
cd client
-
Install dependencies:
npm install
-
Start the React application:
npm run dev
The application should now be running at http://localhost:5173.
Usage
- Enter the required details, including phone number and amount.
- Click the "Submit" button to initiate the Mpesa Stk Push transaction.
- Real-time notifications will inform you of the transaction status.
- Loading indicators will appear during the transaction submission.
Additional Information
- This application uses Axios for making HTTP requests.
- Toast notifications are implemented using the
react-toastify
library.
Feel free to customize and extend the application based on your specific requirements.
License
This project is licensed under the MIT License.