CodeIssuesPull RequestsActionsSecurityInsights
✨ AI
More
Settings

Fully functional store: eSIM lifecycle, top-ups, customer/admin dashboards, monitoring #3695

Merged⚡ AI-generatedXSccantynz wants to mergeclaude/esim-website-audit-16xl2rmainopened Jun 11, 2026
ccantynzcommented Jun 11, 2026

Originally written by @ccantynz-alt on GitHub.
Imported from https://github.com/ccantynz-alt/Esim/pull/3


The store is now fully functional (in safe simulation mode)

The complete purchase lifecycle works end to end: browse → buy → QR code issued → install → activate → live usage tracking → top up (recharge) → admin refund/deactivate/monitor.

Two simulation layers keep it safe until you're ready, and both flip on without touching anything else:

  • Stripe: wired + signature-verified, inert until keys are set (preview mode simulates payment)
  • eSIM provider: a EsimProvider adapter interface with a mock implementation — the real supplier (eSIM Access / Telna / etc.) plugs into lib/provider.ts when the contract is signed

Customer side

  • Passwordless sign-in (/login, demo auth — swap for magic links at launch)
  • Dashboard with real data: install QR codes, live usage bars, top-up menu that recharges the same eSIM with no new QR, activate (simulate landing), order history, account

Admin side ("see everything, monitor everything, fix everything")

  • Overview: live revenue, paid orders, active eSIMs, customers, top destinations, recent errors surfaced
  • Orders: full list with one-click refunds (Stripe-aware: issues real refunds when live; auto-deactivates the refunded eSIM)
  • eSIMs: whole fleet with usage, validity, deactivate + resend-QR actions
  • Monitoring: health checks (provider, Stripe, auth hardening, data store) + a 500-event audit log of everything the system does
  • /api/health JSON endpoint for an uptime monitor
  • Admin is password-gated (env ADMIN_PASSWORD), customers can't reach it

Architecture

  • lib/db.ts — repository-pattern data layer (file-persisted in dev; the interface is the contract for the Postgres swap before launch)
  • lib/fulfill.ts — one fulfillment path shared by preview checkout and the Stripe webhook (idempotent on webhook retries)
  • middleware.ts + HMAC-signed cookie sessions; top-up ownership checks (you can't recharge someone else's eSIM)

Verified end-to-end by driving the running server

  • Buy → order → eSIM provisioned → QR renders on success page ✅
  • Top-up applies +5 GB to the same eSIM, event logged ✅
  • Ownership guard: another user's top-up attempt → 403 ✅
  • Auth gates: /dashboard/login, customer hitting /admin/admin/login
  • All admin pages 200 with admin session ✅
  • tsc, lint, and next build (245 pages) clean ✅

https://claude.ai/code/session_016pMaCaxSE5WQMLnnC7QeYW


Generated by Claude Code

ccantynzcommented Jun 11, 2026

Originally written by @vercel[bot] on GitHub.


The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
esim Ready Ready Preview, Comment Jun 11, 2026 6:24am

Cross-repo impact

See what breaks downstream if this PR merges.

Analyze →
⮌ Merged

This pull request was merged into main.

c comment · e edit title · m merge · a approve · r request changes · ? shortcuts