Inspiration
A successful payment does not always mean a successful order.
An online store can receive a completed PayPal payment while its own system holds a duplicate order, a missing order or inconsistent records. Retries, concurrent handlers and interrupted processing make it hard to work out what actually happened.
For merchants, these mismatches mean duplicate fulfillment, inventory errors, confused customers and slow manual investigation.
We built OrderTruth to connect payment evidence with what the merchant actually recorded, investigate the mismatch, and safely correct merchant records without touching the customer's payment.
What it does
OrderTruth is a payment-integrity and merchant-recovery prototype built on PayPal Sandbox.
For its reference merchant, it checks one lifecycle rule: each completed capture should have exactly one active merchant order.
In the public experience, a visitor can:
- Inspect a genuine PayPal Sandbox capture that was recorded earlier, with its authoritative payment readback.
- Create an isolated, clearly labelled merchant-side duplicate.
- Detect the discrepancy with deterministic checks.
- Review merchant write evidence and run optional AI-assisted investigation.
- Review and explicitly approve an exact, time-limited recovery plan.
- Execute the merchant-only correction as a separate step and inspect the saved verification receipt.
- Reload and reopen the receipt to confirm the recorded outcome.
OrderTruth also opens a missing-order incident when a confirmed payment still has no order after a five-minute grace period. It never creates an order or starts fulfillment automatically.
How we built it
We used TypeScript, Node.js, Fastify, PostgreSQL, Better Auth, Vite, Vercel, Render, Neon, the PayPal developer platform, Groq and Google Gemini.
PayPal integration. We created a genuine PayPal Sandbox order (USD 1.00), approved it as a buyer by hand, captured it, and confirmed it with an authoritative GET readback. Two genuine PayPal webhook events (order approved, capture completed) passed PayPal signature verification and were each processed exactly once. The public demo references this stored evidence. It does not take a new payment for each visitor.
Evidence and recovery. Each visitor gets an isolated merchant scenario linked to the stored payment observation. Deterministic checks find the extra active order. The app shows merchant write identities, handler timing and recorded outcomes to help tell possible causes apart. The repair workflow prepares an exact merchant-only correction and binds approval to that plan and its evidence. Running it is a separate action. Afterwards, the app independently re-checks the merchant orders and confirms the stored PayPal evidence is unchanged. The receipt survives a reload.
AI investigation. The hosted demo uses Groq's openai/gpt-oss-120b. Google Gemini was also exercised during separate qualification work. OrderTruth's Autopilot runs a bounded, evidence-grounded investigation. The model only picks a comparison or an available read-only diagnostic. Our backend code checks the evidence and writes every factual sentence. Payment observations never go to the model. In the recorded demo, the model chose a handler-timing diagnostic. The disjoint handler intervals weakened the race explanation, and the root cause stayed unconfirmed.
The AI cannot approve a repair, change merchant data, or start any PayPal financial action. Earlier evaluations found model-output failures and showed no general advantage over deterministic controls. We kept those results public rather than hiding them.
Infrastructure and testing. The frontend runs on Vercel, and the API runs on one owner-upgraded Render instance. Neon PostgreSQL stores sessions, cases, investigations, approvals and receipts across restarts. The automated tests cover payment-state rules, session ownership, concurrency, evidence consistency, recovery authorization and post-repair verification. Our release candidate passed 1,378 offline tests and 72 PostgreSQL tests. These results back the specific workflows we demonstrated. They are not a guarantee of production reliability, hosted capacity or uptime.
Challenges we ran into
- Separating payment truth from merchant truth. A completed capture proves the payment happened. It says nothing about whether the merchant created the right orders.
- Uncertain outcomes. A timeout or lost response doesn't prove a write failed. We used durable identities and readback to tell committed outcomes apart from genuine uncertainty.
- Keeping the AI from overclaiming. Valid evidence references don't prove causation. Model output is validated and stays advisory.
- Making repair safe. Detection and correction need different controls. We built exact-plan approval, expiry checks, transactional merchant-only changes and independent postcondition checks.
- Working within free-tier limits. Limited hosting and AI allowances meant persistent state, explicit fallbacks when the AI is unavailable, and careful recovery after interruptions.
What we learned
Trustworthy payment recovery means joining several sources of evidence, not trusting a payment status on its own.
Deterministic checks and model-generated hypotheses need separate jobs, especially around financial and merchant records.
Most of all, a recovery system should explain what happened, what is still uncertain, what change was authorized, and what was verified afterwards.
What makes OrderTruth different
OrderTruth combines genuine stored payment evidence, detection of controlled order discrepancies, read-only AI-assisted investigation, exact human authorization and verifiable merchant-only recovery. It takes a merchant from "the payment and the orders don't match" to a documented, approved correction with a durable receipt.
We also kept a separate experiment, the V3 Integration Lab, which tests a synthetic integration guard. It did not protect or repair the demonstrated payment, and it is not an AI-generated migration.
Try it
- Live application: https://order-truth.vercel.app
- Source code: https://github.com/ANIRUDDH-001/OrderTruth
Choose Inspect a payment outcome. You don't need an email, password or PayPal account. The first load can take up to a minute while the free-tier API wakes up.
The visitor journey uses controlled reference-merchant scenarios built on stored genuine Sandbox evidence. It never creates payments, issues refunds or changes PayPal records.
OrderTruth is a prototype. General merchant integrations, broader recovery permissions, larger independent evaluations of the AI's value, and production hardening are future work.
Built With
- better-auth
- fastify
- github-actions
- groq
- neon
- node.js
- paypal
- paypal-orders-api
- paypal-sandbox
- paypal-webhooks
- pnpm
- postgresql
- render
- typescript
- vercel
- vite
- vitest
- zod