AI Receipt & Invoice OCR SaaS PHP Script — Free Download (ReceiptVault Pro)
ReceiptVault Pro: Dext/Expensify-style receipt & invoice OCR on your server — Gemini turns photos and PDFs into line-item ledgers, with users, credits, plans and an admin SuperPanel. Pure PHP + MySQL.
What it is
Around that engine sits a complete SaaS skeleton: registration/login with BCrypt and role-based access (a user hitting admin.php gets a hard 403 — verified), per-user scan credits (1 scan = 1 credit, new accounts start with 5), three seeded pricing tiers (Free Starter, Pro Accountant, Enterprise Agency), and an Admin SuperPanel that manages everything from the database: the master Gemini API key and model, Stripe/PayPal/Google Pay credentials, user moderation (ban/unban, +50 bonus credits), a live transactions feed, SMTP fields, and a dynamic SEO manager whose meta title/description/keywords and header analytics scripts render on the public landing page.
v1.1 update — the three gaps our original code review disclosed have been fixed, in a revision done with Claude Code: the payment layer is no longer a scaffold (real Stripe Checkout Sessions and PayPal Orders v2 via native cURL — the server creates the hosted checkout, verifies the payment server-side on return, and credits idempotently; the old direct-crediting endpoint is gone), a zero-dependency SMTP mailer now actually sends the admin-configured mail (welcome on signup, receipt on purchase, plus a one-click SMTP test button), transactional email templates are editable in the SuperPanel, plans/packages (name, price, credits, active) are editable there too, and the CSRF helpers are now enforced on every state-changing form and API call.
Zero Composer, zero Tesseract, zero ImageMagick: PHP 8 + PDO + cURL and nothing else. A one-click installer provisions all six tables and the master admin account.
ReceiptVault Pro vs hosted expense-OCR platforms
Hosted expense platforms price per user per month (advertised tiers commonly land in the \$49–\$129/mo band for teams) and keep your financial documents in their cloud. ReceiptVault runs on your server with your own Gemini key — receipts never leave infrastructure you control, and Gemini's per-scan cost is fractions of a cent.
| Feature | ReceiptVault Pro (self-hosted) | Dext / Expensify / Veryfi |
|---|---|---|
| Where receipts & invoices live | Your server + your Gemini key; nothing retained by a third-party platform | Vendor cloud, retention per their policy |
| Cost model | Server you already have + pay-per-scan Gemini API usage | Per-user monthly subscription |
| Line-item extraction to a relational table | ✓ receipt_items with qty / unit price / tax / total | ✓ (often on higher tiers) |
| Duplicate invoice detection | ✓ flagged on invoice number + vendor match | ✓ |
| Math audit (subtotal+tax−discount+tip = total) | ✓ CPA-style check with discrepancy notes | Varies |
| Multi-tenant SaaS wrapper (users, credits, plans, admin) | ✓ included — run it as YOUR product | N/A — you are the customer, not the operator |
| White-label + SEO/analytics control | ✓ brand name, meta tags, header scripts from admin | — |
| Payment capture | ✓ v1.1 — Stripe Checkout + PayPal Orders v2, server-side verification, idempotent crediting (revised with Claude Code) | ✓ (they charge you) |
| OCR engine dependencies | None — Gemini native multimodal, no Tesseract/ImageMagick | Their proprietary pipeline |
Server requirements & dependencies
- PHP 8.0 or newer (8.1 / 8.2 / 8.3 compatible)
- PHP extensions: pdo, pdo_mysql, curl, json, fileinfo — standard everywhere
- MySQL 5.7+ / 8.0+ or MariaDB 10.3+
- A Google Gemini API key (aistudio.google.com) — set once by the admin, users never need keys
- No Composer, no Tesseract/ImageMagick/OCR binaries — 100% native PHP
- Note: Google retires Gemini model IDs over time; the model field is admin-editable, so if the default gemini-2.5-flash ever 404s for new keys, switch to the current flash model in the SuperPanel.
How to install
2. Open /install.php: it runs a live dependency check, creates the database and all six tables (users, plans, settings, receipts, receipt_items, transactions), and provisions your Master Admin account — enter the admin email, password and (optionally) your Gemini API key, then hit deploy.
3. Sign in: admins land on the SuperPanel (admin.php), users on the scanning dashboard (dashboard.php). Set the Gemini key under Google Gemini & Core Settings if you skipped it, and you're scanning receipts.
4. Payments (v1.1): enable Stripe and/or PayPal in the SuperPanel and paste your keys — checkout is a real hosted flow (Stripe Checkout / PayPal Orders v2) verified server-side before any credits are granted. Set up SMTP there too and use the Send SMTP Test button; welcome and purchase-receipt emails are editable templates. Delete install.php after setup.
The prompt — build it yourself
Paste this into Gemini and you'll get this product. This is the actual spec that produced the code above.
Build a production-ready, self-hosted PHP 8+ and MySQL SaaS application called "ReceiptVault Pro SaaS" powered by Google Gemini 2.5 Flash that replaces paid accounting OCR platforms like Dext and Expensify.
Include a complete commercial SaaS architecture:
1. Multi-tenant User Authentication (login.php, register.php) with BCrypt password hashing, role-based access control (user vs admin), and scan credit balances.
2. Pricing & Payment Gateways (pricing.php, PaymentGateways.php) supporting Free, Pro, and Enterprise tiers with Stripe, PayPal, and Google Pay checkout flows and transaction logging.
3. Master Admin SuperPanel (admin.php) featuring:
- Google Gemini API Key, model, and audit language configuration
- Stripe, PayPal, and Google Pay credential management
- User Moderation (Ban/Unban users, grant +50 bonus scan credits)
- Live payment transactions feed
- SMTP server configuration
- Dynamic SEO Manager (Meta Title, Description, Keywords, Custom Header Analytics Scripts)
4. Multimodal Receipt & PDF Invoice Engine (GeminiReceiptService.php):
- Zero-dependency inline base64 parsing for JPG, PNG, WebP, and PDF invoices using gemini-2.5-flash and strict JSON responseSchema.
- Relational line-item extraction (
receipt_items), duplicate invoice detection, CPA math auditing, and UTF-8 BOM CSV export for Excel.5. One-click Setup Wizard (install.php) with server dependency checks and automatic Master Admin provisioning.
Independent verification before publishing — every file read line-by-line, all 14 linted clean, then a full install-and-attack pass on a throwaway database:
- Installer provisioned all six tables and the master admin in one POST. Registration granted the seeded 5 free credits; login routed admin→SuperPanel, user→dashboard.
- Role-based access is real: a logged-in customer requesting admin.php got a hard 403. Banned users are killed at session level. Passwords are BCrypt; every query in the codebase is a PDO prepared statement; output is consistently htmlspecialchars-escaped.
- Credit gating is real: uploads with 0 credits are refused, each scan decrements atomically, and an upload without a configured API key fails with a clean admin-facing message.
- What the 8-minute build glosses over, proven live: we called the purchase endpoint as a regular user and received 100 credits and a "completed" $29 Stripe transaction row — without any Stripe call ever leaving the server. The gateway layer stores credentials and writes a beautiful ledger, but charge capture is an integration point, not a feature. Same pattern twice more: CSRF token helpers exist but no form verifies them, and SMTP settings save but nothing sends mail. All three are disclosed on this page and in the install guide — that's the difference between an 8-minute scaffold and a shippable billing system, and it's exactly the kind of honest boundary this series exists to document.
- Real line count: 1,408 across 14 files (PHP + SQL + Tailwind UI).
v1.1 — revision done with Claude Code (2026-09-26): the disclosed gaps became the punch list, and each fix was verified live on a throwaway install:
1. The free-credit hole is closed. The old purchase endpoint now returns HTTP 410; calling it left the test account at exactly 5 credits. Real payments go through hosted checkout: the server creates a Stripe Checkout Session (or PayPal Order) via native cURL, the return handler re-verifies payment status with the gateway before crediting, and crediting is idempotent per gateway reference — refreshing the success page cannot double-credit. Proof the call path is real: with a deliberately fake key, Stripe's own API answered "Invalid API Key provided: sk_test_*E123" through our error surface.
2. Mail actually sends now. A ~110-line zero-dependency SMTP socket client (SSL:465 / STARTTLS, AUTH LOGIN) consumes the SuperPanel's SMTP settings. Verified against a live SMTP sink: the signup welcome mail and the admin "Send SMTP Test" button both landed as real SMTP transactions.
3. Email templates are admin-editable — welcome and purchase-receipt templates with {placeholders}, active toggles, edited from the SuperPanel and stored in a new email_templates table.
4. Plans/packages are admin-editable — name, price, credits and availability per tier; a price change was written and read back in the test.
5. CSRF is enforced, not just present** — every state-changing form and API action now verifies the token; tokenless POSTs to the API and the admin panel both returned 419 in testing.
v1.1 is 1,845 lines across 16 files (from 1,408/14). The Gemini-built core — the OCR engine, the SaaS skeleton, the SuperPanel — is untouched; this revision only filled the integration gaps the original 8-minute build had honestly left open.
Reviews
Used AI Receipt & Invoice OCR SaaS PHP Script — Free Download (ReceiptVault Pro)? A star rating takes two seconds and helps others.
More builds
License: MIT — free for personal and commercial use, no warranty. Software is provided as is; review the code before running it in production (it's short enough to actually read).