The gap
If you read Visa CLI's "Build with an enabler" docs, the advice is sound but conceptual: pick an enabler — VGS, Basis Theory, or Turnkey — and build your own card step. What you don't get is a runnable reference. You still have to open three different vendors' docs, reconcile three different card models (hosted fields, React elements, embedded wallets), and figure out how TRID registration and agent enrollment fit together. For a marketplace outside the US, that's a real barrier.
Enabler-in-a-Box is my attempt to lower it: a small, forkable reference implementation with (1) a JSON API for the card-step → TRID → enrollment flow, (2) a clean TypeScript service layer, and (3) a browser demo that makes an otherwise invisible backend visible. This post walks through what I built, the architecture, the code, and where I'd take it next.
Repo status: MVP. No real money moves, no database, no auth — it's a reference to build on, not a production payment service.
What it does
- Card-step sessions — create a session for a chosen enabler, then simulate card entry with a
PUT. - TRID registration — register the sandbox TRID (
40010092347) against an enabler and company name. - Agent enrollment — enroll a Visa agent key against a TRID.
- Sandbox config — expose the test card (
4111 1111 1111 1111) and test code (123456) via API. - Interactive demo UI — a single-page browser app that calls the real API and renders live JSON responses, with a step tracker and a one-click full-flow runner.
Tech stack
| Layer | Technology | Reason |
|---|---|---|
| Runtime | Node.js 22 | LTS, native crypto.randomUUID |
| Language | TypeScript 5.5, strict, NodeNext ESM | Type-safe service layer |
| HTTP | Hono 4 + @hono/node-server | Tiny, fast, has serveStatic |
| Dev | tsx (watch), ESLint, Vitest, drizzle-kit | Hot reload + quality tooling |
| Validation / logging | Zod, pino (+ pino-pretty) | Installed, ready to wire in |
| Persistence scaffold | Drizzle ORM + postgres.js | Present but unused in the MVP |
| Demo | Vanilla HTML/CSS/JS | No build step, served by same origin |
| Packaging | Multi-stage Docker (node:22-alpine) | Small runtime image |
Deliberate choice: no database. For a reference implementation, three in-memory Maps remove all setup friction. src/db.ts exists as a scaffold for when persistence is needed.
Architecture
┌────────────────────┐ fetch() JSON ┌──────────────────────────────┐ │ Browser (demo UI) │ ───────────────────────────► │ Hono app (src/server.ts) │ │ demo/index.html │ ◄─────────────────────────── │ REST routes + serveStatic │ └────────────────────┘ JSON responses └──────────────┬───────────────┘ │ imports ▼ ┌──────────────────────────────┐ │ Service layer │ │ src/services/enabler.ts │ │ in-memory Maps, sandbox data │ └──────────────┬───────────────┘ ▼ ┌──────────────────────────────┐ │ Types (src/types.ts) │ └──────────────────────────────┘ The request path for the main flow:
Browser Hono routes Service layer (Maps) │ │ │ │── POST /card-step/sessions ─► │ │ │── createCardStepSession() ──►│ sessions.set(id, …) │◄── { session } ────────│◄────────────────────────────│ │── PUT .../sessions/:id ─► │ │ │── updateCardStepSession() ──►│ cardLast4, status │── POST /trids ────────►│── registerTrid() ───────────►│ trids.set(id, …) │── POST /enrollments ──►│── enrollAgent() ────────────►│ enrollments.set(id, …) Three design decisions worth calling out:
- Routes stay thin.
server.tsonly parses the body and delegates. Business logic is testable without HTTP. - The demo is same-origin.
serveStaticservesdemo/index.htmlfrom the same Hono process, so there's no CORS headache and no second dev server. - Types are shared.
src/types.tsdefinesCardStepSession,TridRegistration,AgentEnrollment, etc., consumed by both routes and services.
Walking the code
Entry point
// src/index.ts import { serve } from '@hono/node-server' import app from './server.js' const PORT = Number(process.env.PORT) || 3000 serve({ fetch: app.fetch, port: PORT }, (info) => { console.log(`Enabler-in-a-Box listening on :${info.port}`) }) Routes + static demo
// src/server.ts (excerpt) const app = new Hono() // Serve the interactive showcase page from ./demo app.use('/demo/*', serveStatic({ root: './' })) app.get('/demo', serveStatic({ path: './demo/index.html' })) app.get('/health', (c: Context) => c.json({ status: 'ok', timestamp: new Date().toISOString(), version: '0.1.0' }) ) app.post('/card-step/sessions', async (c: Context) => { const body = await c.req.json() const enablerType = body.enablerType || 'vgs' const session = createCardStepSession(enablerType) return c.json({ session }, 201) }) Note the 201 Created on session creation and 404 on missing IDs — small details that make the API feel real to consumers and to the demo.
Service layer
// src/services/enabler.ts (excerpt) const sessions = new Map<string, CardStepSession>() const trids = new Map<string, TridRegistration>() const enrollments = new Map<string, AgentEnrollment>() export function createCardStepSession(enablerType: string): CardStepSession { const session: CardStepSession = { id: crypto.randomUUID(), enablerType: enablerType as any, status: 'created', createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), } sessions.set(session.id, session) return session } export function updateCardStepSession( id: string, updates: Partial<CardStepSession> ): CardStepSession | null { const session = sessions.get(id) if (!session) return null Object.assign(session, updates, { updatedAt: new Date().toISOString() }) sessions.set(id, session) return session } Only a cardLast4 is stored on card entry — never a full card number. That's a deliberate data-minimization habit even in a sandbox.
Types
// src/types.ts (excerpt) export type EnablerType = 'vgs' | 'basis-theory' | 'turnkey' export interface CardStepSession { id: string enablerType: EnablerType status: 'created' | 'card_entered' | 'verified' | 'failed' cardLast4?: string trid?: string agentId?: string createdAt: string updatedAt: string } The demo UI
The demo is the part that makes this project showable. It's one HTML file, no framework:
async function call(method, path, body) { const res = await fetch(base() + path, { method, headers: body ? { 'Content-Type': 'application/json' } : {}, body: body ? JSON.stringify(body) : undefined, }) const data = await res.json() setResp(method + ' ' + path, res.status, data, !res.ok) return { ok: res.ok, data } } Visually, I deliberately moved away from gradients toward a calm, Apple-inspired system: solid layered surfaces, a translucent sticky header (backdrop-filter: saturate(180%) blur(20px)), iOS system colors (#0a84ff, #30d158, #ff9f0a, #ff453a), size-specific type tracking, instant press feedback on :active, and proper prefers-reduced-motion / prefers-reduced-transparency / prefers-contrast handling. It's a small detail, but an API demo you can look at is far easier to share.
Running it
npm install npm run dev # http://localhost:3000 # or: PORT=3100 npm run dev → demo at http://127.0.0.1:3100/demo npm run build && npm start docker build -t enabler-in-a-box . && docker run -p 3000:3000 enabler-in-a-box Try the flow with curl:
curl -X POST http://localhost:3000/card-step/sessions \ -H 'Content-Type: application/json' -d '{"enablerType":"vgs"}' curl -X POST http://localhost:3000/trids \ -H 'Content-Type: application/json' \ -d '{"enablerType":"vgs","companyName":"Demo Marketplace Inc."}' curl -X POST http://localhost:3000/enrollments \ -H 'Content-Type: application/json' \ -d '{"trid":"40010092347","agentName":"Demo Shopping Agent"}' npm test currently reports "No test files found" — meaning the first good contribution is a Vitest suite for the service layer.
Supported enablers
| Enabler | Card model | PCI scope |
|---|---|---|
| VGS | Hosted fields (VGS Collect) | SAQ A |
| Basis Theory | Elements (React components) | SAQ A |
| Turnkey | Embedded wallet | SAQ A-EP |
Sandbox constants: card 4111 1111 1111 1111, code 123456, TRID 40010092347.
Where I'd take it next
- Vitest tests so
npm testis green. - Real Zod validation of request bodies.
- Wire up
src/db.ts— swap theMaps for Drizzle tables and add migrations. - Actual VGS/Basis Theory/Turnkey adapter implementations behind the simulated flow.
- Auth, rate limiting, and pino logging before any real deployment.
- A complete session state machine (
card_entered → verified → linked trid/agentId). - CI running build + lint + tests on every PR.
If any of that sounds like a good first PR, the repo is MIT and fork-friendly.
Links
- Visa CLI Docs: https://app.visacli.sh/docs
- Build with an enabler: https://app.visacli.sh/docs/build-with-an-enabler.md
Code & more: https://www.dailybuild.xyz/project/332-enabler-in-a-box


