embpa
A B2B invoicing platform where a customer pays without leaving the page: Express issues the invoice, Stripe confirms the payment, and a signature verified webhook marks it paid.
Overview
embpa is a small, complete payments loop. The browser fetches a publishable key
from the server, pays through Stripe's embedded form, and never sees the secret
key. The webhook route is mounted before express.json() so it can
verify the raw body, and invoice ownership is enforced on every route.
browser --publishable key--> Stripe Elements
browser --create invoice----> Express -> SQLite
Stripe --signed webhook----> Express -> invoice.paid
Key features
- Embedded paymentsThe Stripe Payment Element sits inside the invoice page; no redirect to a hosted checkout.
- Raw body webhookMounted before JSON parsing, so signature verification sees the exact bytes Stripe signed.
- Cookie authhttpOnly JWT cookie with
SameSite=Laxand an optional secure flag. - Invoice ownershipEvery invoice carries
user_id; list and pay routes filter by the session user. - Startup migrationsAdds
payment_intent_id,user_idandcurrencyto older databases. - Fail fast configThe process exits if
JWT_SECRETorSTRIPE_SECRET_KEYis missing.
How it works
- Fill
.envwith Stripe test keys, the webhook secret and a JWT secret. - Run
npm install && npm start. - Register, create an invoice, and pay it with a Stripe test card.
- The webhook marks the invoice paid; the list reflects it on the next load.
npm install
npm start
# .env
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
JWT_SECRET=...
Stack
Node.js
Express JS
Stripe
better-sqlite3
JWT
bcrypt