This is a simple full-stack demo project that shows how to integrate Fapshi's payment APIs using a React.js frontend and a Node.js (Express) backend.
It demonstrates how developers can:
- Generate a payment link via Fapshi's API (initiate pay)
- Redirect users to pay
- Handle post-payment redirection or display a success message
- Handle payments with your own custom checkout page (direct pay)
- Handle webhooks for payment status updates
Check the Fapshi Documentation for details on the API and endpoints
This repository contains two folders showing different ways to use the Fapshi API:
/direct-pay β Direct Pay (Single-call payment link creation)
/initiate-pay β Initiate Pay (More controlled flow, two-step process)
β οΈ Important Note about Direct Pay:
The Direct Pay method is blocked by default in Live Mode for security reasons.
To activate Direct Pay in production, please contact Fapshi Support at support@fapshi.com.
- Frontend: React (with Vite or CRA)
- Backend: Node.js with Express
- Demonstrates both Direct Pay and Initiate Pay flows
- Example use case: simple product checkout
- Clean, beginner-friendly code
- Easily extendable to fit real-world scenarios
- React.js
- Node.js
- Express.js
- Axios (for API calls)
- Dotenv (for managing API credentials)
git clone https://github.com/fapshi/sample-react-nodejs.git
cd sample-react-nodejs
-
For Direct Pay, navigate to:
cd direct-pay
-
For Initiate Pay, navigate to:
cd initiate-pay
Each folder contains its own backend
and frontend
directories.
cd backend
cp .env.example .env
# Fill in your Fapshi API credentials
npm install
npm run dev
cd ../frontend
npm install
npm run dev
Ensure your backend is running on port
5000
, or update the API base URL in the frontend code.
In your .env
file inside the backend
folder:
FAPSHI_API_USER=your_api_user_here
FAPSHI_API_KEY=your_api_key_here
You can find your keys in the Fapshi Dashboard.
- User clicks "Pay" after filling a form or selecting a product.
- Frontend sends a request to the backend.
- Backend calls the Fapshi API to create a payment link.
- Frontend receives the link and redirects the user to complete payment.
- After payment, the user sees a success/failure confirmation screen.
Add UI screenshots or a demo GIF here if available.
Q: Can I use this project in production?
A: Yes, you can adapt and build on it for production use.
Q: Whatβs the difference between Direct Pay and Initiate Pay?
Follow this article: Direct Pay vs Initiate Pay
Q: Why is Direct Pay disabled in live mode?
A: Itβs restricted by default to prevent abuse. Contact support to activate it in production. Submit your request with the following details:
- Your Fapshi API user
- Your website URL (if applicable)
- Your business name
- A clear description of your use case and why you need Direct Pay over Initiate Pay
This project is open-source under the MIT License.
You are free to modify and use it in your projects.
Built with β€οΈ by the Fapshi Team
Website: fapshi.com
Support: support@fapshi.com
Help Center: fapshi.com/help-and-support