Catch mistakes in custom t-shirt orders before the customer pays, and tie the PayPal payment to the exact version they approved.
A t-shirt order lives in three places that drift apart: the shop's order brief, the email thread with the customer, and the artwork file. The customer emails "make it 150", but the brief still says 120. The artwork still says last year. A third ink color sneaks in that nobody priced. Shops find out after printing.
ProofPay is AI-assisted verification backed by merchant and customer confirmation. A vision model reads the brief, the messages and the artwork image together and flags mismatches in four areas: quantity and sizes, printed text and dates, colors, and pricing. Each flag quotes its sources. The merchant settles every flag. If the artwork itself is wrong, the merchant uploads a corrected file and the AI checks it again. The customer then approves one exact version, covering the spec, the artwork files and the amount, and pays with PayPal. The payment is held until production starts.
The AI doesn't replace a human proof check: file hashes and evidence checks show it looked at the right file and cited real text, not that it read the image perfectly. That's why the merchant confirms every value and the customer approves the artwork itself.
Built for the PayPal AI Hackathon 2026. PayPal sandbox only; no real money moves.
Demo video (2:52): https://youtu.be/nZE4VfG551E (MP4 copy)
Hosted demo: https://proofpay-vpw3.onrender.com (PayPal sandbox, demo-mode AI). It runs on a free instance: the first
request after 15 idle minutes takes about a minute, and stored orders reset when it sleeps or redeploys. If an order
disappears, click Load sample order again. In demo mode the AI results are saved ones, labelled as such: the
re-check step only accepts the sample's own corrected file. Add ASTRO_GATEWAY_API_KEY to run live checks.
Run it locally in 2 minutes, no keys needed (demo mode). Requires Node.js 22 or newer.
git clone https://github.com/dngvmnh/PayPal-AI-Hackathon.git
cd PayPal-AI-Hackathon
npm install
npm run build && npm start # http://localhost:3000-
Click Load sample order (Riverside 5K), then Run AI check. Without an AI key, the sample uses a saved analysis.
-
Settle the spec findings (quantity, sizes, total): Confirm value, Waive (with a reason the customer will see), or Dismiss as AI error (with a logged reason).
-
The two artwork findings can't be confirmed or waived, because the file itself is wrong. On each, set what the corrected artwork must show, then click Require corrected artwork:
- printed text: Year =
2026, Date =Sunday, May 17, URL =riverside5k.org(+ Add field adds a row) - ink colors: Ink colors =
white, safety orange
Download the corrected file from the link in the Artwork panel, upload it with Upload corrected version, and click Run AI check again. Each required field then shows expected against what was read. Without an AI key this is a saved result that applies only to that exact file; any other upload is refused.
- printed text: Year =
-
When the banner turns green, click Open customer proof page. Tick the box, type a name, and click Approve this version.
-
To pay, add PayPal sandbox keys (setup below) and use a sandbox personal account. Then go back to the order and click Start production & capture, Void & reopen for changes, or Void & cancel order.
Without PayPal keys, you can still exercise the whole payment flow against a local stand-in for the PayPal API. It is not PayPal; it only returns responses in the same shape:
npm run mock:paypal # terminal 1
PAYPAL_API_BASE=http://localhost:4010 PAYPAL_CLIENT_ID=x PAYPAL_CLIENT_SECRET=x \
PAYPAL_WEBHOOK_ID=x npm start # terminal 2 (after npm run build)
npm run e2e # terminal 3: 19 checks, settle and re-check → approve → pay → void & reopen → pay → webhook capture- Collect sources. The merchant creates an order with the brief, the pasted message thread, and artwork (PNG/JPG/WebP/GIF/PDF).
- AI check. One model request gets every source, with the artwork as an image. It returns findings with a severity, quotes from each source, a suggested value, a question for the customer, and whether the artwork itself must change. The check records the fingerprint (sha256) of each artwork file it read.
- Resolve.
- Spec errors: the merchant confirms the value.
- Artwork errors: the merchant sets what the artwork must show (year, date, name, URL, text line, ink colors), uploads a corrected file (kept as a new version), and re-runs the check.
- Waive: a real issue is accepted, with a reason the customer will see.
- Dismiss: the AI was wrong, with a reason that is logged.
- Approval gate (
lib/gate.ts). Approval is allowed only when:- the latest check succeeded on the current artwork;
- no blocking or warning finding is open;
- artwork errors were fixed by a new file or dismissed;
- every waive or dismissal has a reason;
- quantity and price are set.
- Customer approval. The proof page shows the spec, the current artwork version, the amount and any waived exceptions. The customer approves that version, and the approval is saved on the server with a hash of all of it. Any later change cancels the approval.
- PayPal authorize. Checkout uses
intent: AUTHORIZE, so the money is held, not taken.custom_idcarries the order, the revision and the approved version hash. The order is now locked. - Capture or void. The merchant captures when production starts. Or they void, either to cancel the order or to reopen it for changes; a reopened order needs a new approval and a new payment. Webhooks keep the status in sync with PayPal.
| Ready for approval | Customer approves the exact version |
|---|---|
![]() |
![]() |
| Sandbox capture and signed webhook events | Customer receipt on a phone |
|---|---|
![]() |
![]() |
These screenshots show a PayPal sandbox payment on the hosted app on Nov 5, 2026: 1,425.00 USD captured, with signed authorization and capture webhook events recorded. The receipt shows the same approved version and PayPal order. The sample uses labelled saved AI results.
The sandbox's API log shows the payment tied to one approved version, through custom_id = order:revision:versionHash:
| Step | API |
|---|---|
| Checkout button on the proof page | PayPal JS SDK via @paypal/react-paypal-js (PayPalButtons, intent=authorize) |
Create the order: line items, custom_id = order:revision:versionHash, invoice_id |
Orders v2 POST /v2/checkout/orders |
| Hold the funds after the customer approved the version | Orders v2 POST /v2/checkout/orders/{id}/authorize |
| Take the funds when production starts | Payments v2 POST /v2/payments/authorizations/{id}/capture |
| Release the funds to cancel, or to reopen the order for changes | Payments v2 POST /v2/payments/authorizations/{id}/void |
Keep status in sync: PAYMENT.AUTHORIZATION.CREATED/VOIDED, PAYMENT.CAPTURE.COMPLETED/DENIED |
Webhook at /api/paypal/webhook, verified with POST /v1/notifications/verify-webhook-signature |
Every call sends a PayPal-Request-Id, so retries don't create duplicates. Code: lib/paypal.ts, lib/webhooks.ts.
| What | How |
|---|---|
| Model | qwen3-vl (vision) through the Astropods AI gateway's OpenAI-style API, set by ASTRO_MODEL. Without a gateway key, ANTHROPIC_API_KEY runs Claude Opus 5.5 instead |
| Inputs | Brief and messages as text; artwork as images. PDF artwork works only with Claude; through the gateway it fails the check rather than going unread |
| Output | A JSON schema generated from the Zod schema (AIAnalysis in lib/types.ts), and the reply is validated against it |
| Code checks | Code does the arithmetic on the brief, using the quantity and unit price the model settled on: sizes against quantity, price lists, totals (lib/spec-checks.ts). These can raise or harden a finding, never clear one |
| Safety | A failed, refused or unparseable reply fails the check, and a failed check blocks payment |
| Demo mode | Without an AI key, the sample order uses saved results (samples/riverside-5k/demo-analysis.json, and demo-recheck.json for the exact bytes of front-v2.png, matched by sha256) |
| Evaluation | Sample orders with answer keys in samples/ (format: samples/FORMAT.md), including 3 held-out cases in samples/heldout/. Tuning history: docs/eval/TUNING.md |
Code: lib/ai.ts.
cp .env.example .env.local| Variable | What it's for |
|---|---|
ASTRO_GATEWAY_API_KEY, ASTRO_GATEWAY_URL, ASTRO_MODEL |
Live AI checks through the Astropods gateway. Leave the key empty for demo mode |
ANTHROPIC_API_KEY |
Optional: live checks with Claude when the gateway key is empty |
PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET |
Sandbox REST app credentials (server side) |
NEXT_PUBLIC_PAYPAL_CLIENT_ID |
The same client ID, for the browser's PayPal buttons. Read at build time |
PAYPAL_WEBHOOK_ID |
Id of the webhook registered for this app. Needed to accept webhooks |
PAYPAL_API_BASE |
Defaults to the sandbox, https://api-m.sandbox.paypal.com |
DATA_DIR |
Where orders and uploads are stored. Defaults to .data/; point it at a persistent disk when hosting |
APP_BASE_URL |
Public URL of the app |
Check what is configured at GET /api/health.
- Sign in at https://developer.paypal.com and open Apps & Credentials with the Sandbox toggle on.
- Create App (type Merchant). Copy the Client ID into both
PAYPAL_CLIENT_IDandNEXT_PUBLIC_PAYPAL_CLIENT_ID, and the Secret intoPAYPAL_CLIENT_SECRET. - Testing Tools → Sandbox Accounts: PayPal creates a default Business account (receives the money) and a Personal account (pays). Use the personal account's email and password in the PayPal popup.
- Webhooks (needs a public URL: the hosted app, or a tunnel to localhost such as
cloudflared tunnel --url http://localhost:3000). Register it withnpm run sandbox -- webhook <public URL>, which subscribes<public URL>/api/paypal/webhooktoPAYMENT.AUTHORIZATION.CREATED,PAYMENT.AUTHORIZATION.VOIDED,PAYMENT.CAPTURE.COMPLETEDandPAYMENT.CAPTURE.DENIEDand prints the id to put inPAYPAL_WEBHOOK_ID. Running it again for the same URL changes nothing. You can also add the webhook by hand in the app's settings in the developer dashboard. - Restart the app (rebuild if you changed
NEXT_PUBLIC_PAYPAL_CLIENT_ID). In the sandbox dashboard, the transaction's custom field showsorder:revision:versionHash.
scripts/sandbox.mjs reads .env.local and talks to the PayPal sandbox directly:
npm run sandbox -- check # credentials work and the running app has them too
npm run sandbox -- webhook <public URL> # register the webhook, print PAYPAL_WEBHOOK_ID
npm run sandbox -- webhooks # list registered webhooks
npm run sandbox -- live # sample order → you pay in the browser → authorize → capture,
# then a second order → authorize → void & reopen; checks custom_id
npm run sandbox -- order <PayPal order> # status and custom_id of one PayPal orderlive prints a PayPal approval link for each order; open it and pay with the sandbox personal account. Point it at
the hosted app with APP_URL=https://... and it also waits for PayPal's signed webhook events to arrive.
npm test # unit tests: gate, finding rules, artwork versions, approval cancellation,
# payment revisions, void/reopen, webhooks, sample answer keys
npm run typecheck
npm run e2e # end-to-end against a running app + mock PayPal (see Quickstart)
npm run eval # live AI check on the tuning samples, scored against answer keys; report in docs/eval/render.yaml is a Render blueprint on the free plan: New → Blueprint → this repo,
then fill in the secret environment variables. The free instance sleeps after 15 idle minutes (the first request
then takes about a minute) and loses its stored orders when it sleeps or redeploys; Load sample order recreates
the sample, so the whole flow still works. Leaving the AI keys empty keeps the hosted app in demo mode. To
keep data, switch to a paid plan with a persistent disk (see the comment in render.yaml). Any Node 22 host works
the same way: npm ci && npm run build, then npm start.
After deploying, set APP_BASE_URL, register the webhook with npm run sandbox -- webhook <URL>, set
PAYPAL_WEBHOOK_ID on the host, and wait for the redeploy to finish before testing: on the free plan a redeploy wipes
stored orders, including ones in the middle of a payment.
app/
page.tsx order list
orders/new/ new order form
orders/[id]/ merchant workspace: findings, artwork versions, spec, approval & payment, history
p/[id]/ customer proof page: approve this version, PayPal buttons, receipt
api/orders/... create, read, analyze, finding actions, spec edits, artwork upload, approve,
PayPal create / authorize / capture / void
api/paypal/webhook verified PayPal webhook events
api/health which integrations are configured
lib/
ai.ts AI check: prompt, multimodal content, gateway and Claude calls, saved demo results
gate.ts approval gate, version hash, artwork fingerprints
orders.ts state transitions: findings, artwork versions, approval, payments, status
paypal.ts PayPal REST client
webhooks.ts PayPal webhook events → payment revisions
store.ts JSON-file storage in DATA_DIR
samples/ sample orders, answer-key format, held-out eval cases
scripts/ mock PayPal API and end-to-end check
docs/PLAN.md MVP plan, decisions, task split
MIT, see LICENSE.





