A minimal Express + TypeScript app that demonstrates the core Payments Central API flows: charging a card, listing transactions, issuing refunds, and creating hosted checkout sessions. Clone it, drop in your sandbox credentials, and you'll have a working demo in under two minutes.
- Node.js 18 or later
- A Payments Central sandbox account (free)
git clone <this-repo>
cd payments-central-example-nodejs
npm install
cp .env.example .env
# Open .env and fill in your API key and merchant ID
npm run dev
# → http://localhost:3000Open http://localhost:3000 in your browser. You'll see a simple page with links to each demo route.
| Method | Route | What it does |
|---|---|---|
GET |
/ |
Home page with links to all demo routes |
POST |
/demo/charge |
Charges $10.00 USD and returns the transaction object |
GET |
/demo/transactions |
Lists the last 10 transactions |
GET |
/demo/transaction/:id |
Fetches a single transaction by ID |
POST |
/demo/refund/:id |
Refunds a transaction (full amount) |
POST |
/demo/checkout |
Creates a checkout session and redirects to the hosted payment page |
GET |
/demo/success |
Landing page shown after a successful checkout |
GET |
/demo/cancel |
Landing page shown after a cancelled checkout |
POST routes can be triggered with curl:
# Charge
curl -X POST http://localhost:3000/demo/charge
# Refund (replace with a real transaction ID from the charge above)
curl -X POST http://localhost:3000/demo/refund/txn_abc123
# Checkout session
curl -X POST http://localhost:3000/demo/checkoutsrc/
types.ts — TypeScript interfaces for all API objects
client.ts — PaymentsCentralClient class (thin fetch wrapper)
server.ts — Express app and demo route handlers
npm run build # compiles TypeScript to dist/
npm start # runs the compiled outputA smoke test (npm run smoke) drives the demo through the full flow —
charge → list → get → refund → checkout — against a recorded mock of the core
API that asserts every request matches the current contract. It needs no
credentials, so it runs in CI on every push/PR (.github/workflows/ci-smoke.yml)
and fails loudly if the example ever drifts from the API.
Full API reference: https://developer.payments-central.com