Skip to main content
This page is designed for first success quickly:
  1. install the SDK → 2) authenticate → 3) create an invoice → 4) observe status via REST or WebSockets.

1) Get API keys (dashboard)

Sign in to the Pepay Dashboard (login required) to create API keys:

Pepay Dashboard Login

Create API keys for server-to-server integrations.
If you need access or onboarding support, email {SUPPORT_EMAIL}.

2) Install the SDK

npm install pepay

3) Configure your environment variables

export PEPAY_API_URL="https://api-beta.pepay.io"
export PEPAY_API_KEY="sk_live_..."
Defaults used in these docs:
  • Base URL: {DEFAULT_BASE_URL}
  • Dashboard login: {DEFAULT_DASHBOARD_URL} (set PEPAY_DASHBOARD_URL to override)

4) Create an invoice (server)

import { Pepay } from 'pepay';

const pepay = new Pepay({
  apiKey: process.env.PEPAY_API_KEY!,
  baseUrl: process.env.PEPAY_API_URL ?? 'https://api-beta.pepay.io'
});

const invoice = await pepay.invoices.create({
  amount_usd: 49.99,
  description: 'Starter plan'
});

console.log(invoice);
Example response:
{
  "invoice_id": "550e8400-e29b-41d4-a716-446655440000",
  "payment_url": "https://<payment-iframe-host>/pay?session=pst_...&signature=sig_...",
  "expires_at": "2025-12-21T13:00:00.000Z",
  "session_token": "pst_...",
  "signature": "sig_...",
  "payment_session_headers": {
    "x-session-token": "pst_...",
    "x-signature": "sig_..."
  }
}

5) Observe status (REST)

const status = await pepay.invoices.status(invoice.invoice_id);
console.log(status);

6) Observe events (WebSockets)

For realtime delivery, mint a short-lived ws_token server-to-server and connect to the merchant stream:
  • Mint token: POST /api/v1/ws/token
  • Connect: wss://…/ws/merchant/events?token=<ws_token>
Next: Install