Live Demo: https://nodejs-payment-api.onrender.com A simple and extendable RESTful API for accepting payments using Stripe.
This project is a basic RESTful API that allows small businesses to accept payments from customers via the Stripe payment gateway. The system is built to be extendable for future integration with other providers such as PayPal, Paystack, or Flutterwave.
- Make Payment: When a customer initiates a payment, their information is saved (if new), and a transaction is recorded. A Stripe Checkout Session is then created, and the customer is redirected to the Stripe payment page.
- Webhook Listener: After payment completion (or failure), a Stripe webhook notifies the server to update the payment status.
- Query Payment: Users can query the status or history of their payments using their email or session ID.
- Make payment
- Get payment status
- Get error report
- ✅ High Availability
- ✅ Scalability
- ✅ Secure Transactions
- ✅ Optimized Performance
- ✅ Maintainable Codebase
| Field | Type |
|---|---|
| id | UUID |
| name | String |
| String |
| Field | Type |
|---|---|
| id | UUID |
| userId | UUID |
| sessionId | String |
| customerId | String |
| provider | String |
| status | String |
| amount | Float |
Relation: One-to-Many → One user can have multiple payments.
npm test| Area | Stack/Tool |
|---|---|
| Server | Node.js, Express |
| Validation | express-validator |
| ORM | Sequelize |
| Payment | Stripe SDK |
| Testing | Jest, Supertest |
| Formatting | ESLint, Prettier |
| Deployment | Render.com |
| CI/CD | GitHub Actions |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/payments |
Initiate a payment (name, email, amount) |
| GET | /api/v1/payments/:id |
Get payment transaction by session ID |
| GET | /api/v1/payments?email= |
Get all transactions by user email |
| GET | /api/v1/payments/stripe/:id |
Get payment details directly from Stripe by ID |
git clone git@github.com:ngodi/nodejs-payment-api.git
cd nodejs-payment-apinpm installCreate a .env file at the root of your project with the following variables:
PORT=5000
DATABASE_URL=your_database_connection_string
STRIPE_SECRET_KEY=your_stripe_secret_key
CLIENT_URL=http://localhost:3000- Continuous Integration/Deployment is handled using GitHub Actions.
- Hosted on Render.com.
Pull requests and issues are welcome. Please include tests for any new features or bug fixes.
This project is open-source and available under the MIT License.