Prerequisites
- Node.js v18 or newer
- MongoDB (or Docker)
- pnpm
- A Xendit, Midtrans and/or Mayar.id account (for live credentials)
1. Install dependencies
git clone <repository-url>
cd pglink
pnpm install
2. Configure the environment
cp .env.example .env
Edit .env:
NODE_ENV=development
PORT=3000
# Database
MONGO_URI=mongodb://localhost:27017/pglink_payment
# JWT
JWT_SECRET=your-jwt-secret
# Admin CMS
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123
# Payment providers
XENDIT_API_KEY=xendit-api-key
XENDIT_WEBHOOK_TOKEN=xendit-webhook-token
MIDTRANS_SERVER_KEY=midtrans-server-key
MIDTRANS_CLIENT_KEY=midtrans-client-key
# Mayar.id
MAYAR_API_KEY=mayar-api-key
MAYAR_WEBHOOK_TOKEN=mayar-webhook-token
# Optional; defaults to the production/sandbox host based on NODE_ENV
MAYAR_API_BASE=
# Swagger UI at /api-docs
SWAGGER_ENABLED=true
SWAGGER_ENABLEDis optional: it defaults to enabled whenNODE_ENVis notproduction.
3. Start MongoDB
docker run -d --name pglink-mongo -p 27017:27017 mongo:7
# or, with the bundled compose file
docker compose up -d mongo
Collections and indexes are created automatically by Mongoose on startup.
The connection defaults to mongodb://localhost:27017/pglink_payment
and can be overridden with MONGO_URI.
4. Run the application
# development (hot reload)
pnpm run start:dev
# production
pnpm run build && pnpm run start:prod
5. Explore
| URL | Description |
|---|---|
| / | Redirects to /admin (login) |
| /docs | This documentation site |
| /api-docs | Swagger / OpenAPI UI |
| /api-docs-json | Raw OpenAPI document |
| /admin | Admin dashboard |
Troubleshooting
Port already in use
Change PORT in .env or stop the process using it.
Database connection failed
Ensure MongoDB is running and the MONGO_URI in .env is correct.
Mayar requests fail with 404
Confirm you are using the right host: production keys use
https://api.mayar.id/hl/v2, sandbox keys use
https://api.mayar.io/hl/v2. Set MAYAR_API_BASE to override.
Next: read the API Reference and the Mayar.id guide.