This project demonstrates how to integrate the SeerBit Standard Checkout payment flow in a Node.js + Express API. It loads configuration from environment variables, initializes the SeerBit SDK, exposes a /api/standard-checkout endpoint to create payment links, and includes built‑in health checks and error handling. Follow the sections below to get started quickly.
- Summary
- Table of Contents
- Features
- Prerequisites
- Installation
- Configuration
- Running the Server
- Error Handling
- Contributing
- License
- SeerBit Standard Checkout integration for secure payment link generation (GitHub)
- Express.js REST API with JSON parsing and CORS support (Express)
- Environment‑based configuration using
dotenv(GitHub) - Health‑check endpoint (
GET /) to verify server status (Express) - Global error handler for consistent HTTP 500 responses (GitHub)
- Node.js v14+ and npm installed on your machine (GitHub)
- A SeerBit merchant account with your Public & Secret keys and Bearer Token (doc.seerbit.com)
- Git for version control (optional)
-
Clone the repository
git clone https://github.com/yourusername/your-repo.git cd your-repo -
Install dependencies
npm install express cors dotenv seerbit-nodejs
Create a .env file in the project root with the following variables:
PUBLIC_KEY=sbpub_xxx
SECRET_KEY=sbsec_xxx
BEARER_TOKEN=eyJhbGci…
PORT=8000PUBLIC_KEY,SECRET_KEY, andBEARER_TOKENcome from your SeerBit dashboard (GitHub)PORTdefines which port the server listens on (default:8000)
Start the Express server:
node app.jsYou should see:
✅ Listening on port 8000
To auto‑reload on changes during development, use nodemon:
npx nodemon app.js
``` :contentReference[oaicite:12]{index=12}
## API Endpoints
### Health‑Check
```http
GET /Response:
200 OKwith body"Server is up and running"(Express)
POST /api/standard-checkout
Content-Type: application/jsonBody Parameters:
fullName(string)amount(number)currency(string, e.g.,NGN)country(string, ISO code)email(string)
Success (201):
{ "response": { /* SeerBit API response */ } }Under the hood, this uses SeerBit’s /payment/initialize endpoint to generate a checkout link (doc.seerbit.com).
- SDK Initialization Errors log “⛔ SDK init failed” and exit if configuration is invalid.
- Route Errors bubble up to a global handler that returns
500 Internal Server Errorwith a generic message. - Unhandled Routes return
404 Not Found. (You can add a catch‑all middleware if desired.) (GitHub)
- Fork the repo
- Create a feature branch:
git checkout -b feature/awesome-feature - Commit your changes:
git commit -m "Add awesome feature" - Push to your branch:
git push origin feature/awesome-feature - Open a Pull Request
Please ensure all new code is covered by tests and follows existing style conventions.
This project is licensed under the MIT License. See the LICENSE file for details. (GitHub)