This project is a MERN stack payment gateway integration, using the PayHere sandbox for secure payment processing.
- Initiate payments via PayHere (sandbox)
- Store payment records in MongoDB
- Simple React frontend for payment form and status pages
- Node.js (v18+ recommended)
- MongoDB Atlas account (or local MongoDB)
- PayHere Sandbox account: https://sandbox.payhere.lk/
-
Create a PayHere Sandbox Account:
- Go to https://sandbox.payhere.lk/, sign up, and log in.
-
To Get Merchant ID and Merchant Secret:
-
Copy
.env.exampleto.envin the Payment_Service_Backend/ directory and fill it with your actual credentials. -
Install dependencies:
cd Payment_Service_Backend npm install -
Start the backend server:
npm run dev
-
Copy
.env.exampleto.envinPayment_Service_Frontend/and fill with your actual credentials. -
Install dependencies:
cd Payment_Service_Frontend npm install -
Start the frontend:
npm run dev
- Visit http://localhost:5173 in your browser.
- Use the frontend payment form to initiate a payment.
- You’ll be redirected to PayHere’s sandbox checkout.
- Use a test card for transactions. Visit https://support.payhere.lk/sandbox-and-testing to get test card details.
- Visa:
4123 4567 8912 3456 - CVV:
123 - Expiry:
12/25
- Visa:
- On completion/cancel, you’ll be redirected to the appropriate status page.
- Check MongoDB for payment records.
- Sandbox transactions are free and use dummy data.
- Keep your secrets in
.envfiles (do not commit them). - For production, use live PayHere credentials and update URLs accordingly.
- For PayHere issues: support@payhere.lk