Getting Started

Run PGLink locally

Get the aggregator running in a few minutes with Node.js, MongoDB and pnpm.

Prerequisites

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_ENABLED is optional: it defaults to enabled when NODE_ENV is not production.

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

URLDescription
/Redirects to /admin (login)
/docsThis documentation site
/api-docsSwagger / OpenAPI UI
/api-docs-jsonRaw OpenAPI document
/adminAdmin 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.