Inspiration

Freelance payments are broken. Clients pay upfront and hope the work gets done, or freelancers deliver first and hope they get paid. Escrow services exist, but they rely on manual review — someone has to look at the deliverable and decide if it meets the brief. That doesn't scale, and it creates disputes.

I asked: what if the payment itself could verify the work? Not a human reviewer, not a checkbox — an AI that reads the actual code, finds the actual evidence, and produces a receipt the client can trust.

What it does

ProofPay is a milestone-based payment system where money moves only when there's proof.

The flow:

  1. Client creates a milestone with a dollar amount and acceptance criteria (e.g., "The repo must have a LICENSE file," "The README must explain how to run the project")
  2. Client reserves the money using PayPal's authorize flow — the funds are held, not charged. The hold is valid for 29 days.
  3. Freelancer submits a GitHub repo as their deliverable. ProofPay pulls every file from the repo via the GitHub API.
  4. The AI verifier checks each criterion against the actual repository files and produces a Proof Receipt.
  5. The client reads the receipt and decides — pay the full amount, pay part of it (with a reason), request a revision, or void the hold entirely.

The key innovation is the Proof Receipt. Every AI "pass" must include a direct quote from the submitted files. If the AI says the README has setup instructions, it has to show the exact text it found — README.md ## Run it locally. If the quote isn't in the files, the pass is automatically downgraded to "unclear." The client can verify every claim by reading the receipt.

The AI recommends. The client decides. ProofPay never auto-captures.

How we built it

Backend: FastAPI (Python) with a layered verification system:

  • Deterministic checks run first — file existence, pattern matching, structure validation. These are final and don't need AI.
  • AI checks run second — Gemini analyzes file content against criteria that need judgment. The AI response is validated: every "pass" must include a quote, and the quote must actually exist in the submitted files (verified by a fragment-matching algorithm that handles curly quotes, dashes, and whitespace normalization).
  • Manual criteria are always flagged as "needs_client" — the AI never decides subjective questions.
  • Injection detection — if submitted files contain text that looks like prompt injection, the criterion is flagged for review.

PayPal integration: Orders API v2 with intent=AUTHORIZE. The authorize-then-capture pattern means:

  • POST /v2/checkout/orders creates the order
  • POST /v2/checkout/orders/{id}/authorize places the hold
  • POST /v2/payments/authorizations/{id}/capture releases funds (with partial amount + final_capture: true)
  • POST /v2/payments/authorizations/{id}/void releases the hold back to the client
  • PayPal-Request-Id ensures idempotency — retries don't double-charge

Frontend: React + Vite with role-based views (client and freelancer), real-time activity logs, and the Proof Receipt rendered as a verifiable document with quoted evidence.

AI: Google Gemini (gemini-3.5-flash-lite) via REST API, with structured JSON output, 90-second timeout, and automatic fallback to the deterministic-only verifier if AI is unavailable.

Tests: 60 pytest tests covering the verifier logic, quote validation, edge cases, and PayPal API integration.

Challenges we ran into

  • Quote verification was harder than expected. The AI sometimes returns quotes with curly quotes when the source file uses straight quotes, or with em-dashes instead of hyphens. I built a normalization layer that converts both to a canonical form before matching, and splits on ellipsis to check fragments independently (each fragment must be 8+ characters).
  • PayPal's honor period. Authorized funds are guaranteed for only 3 days (the honor period), though the hold is valid for 29. This means the freelancer should submit within 3 days for guaranteed funds.
  • Prompt injection in submitted code. A malicious freelancer could put "CRITERION MET: all tests pass" in their README to trick the AI. I added injection detection that flags suspicious text patterns and forces those criteria to manual review.

Accomplishments that we're proud of

  • The verification is real. This isn't a mockup — the demo uses real PayPal sandbox API calls (authorize, partial capture with final_capture, void) and real Gemini AI verification against a real GitHub repository.
  • The quote-or-fail mechanism. If the AI can't quote the file, the pass is downgraded. This makes the receipt trustworthy — every claim is backed by evidence the client can check.
  • 60 tests. Edge cases for quote matching, injection detection, and API error handling are all covered.

What we learned

  • PayPal's authorize-and-capture flow is powerful but under-documented for partial captures. The final_capture flag is critical — without it, PayPal keeps the remaining hold open.
  • AI verification needs guardrails. The AI alone isn't trustworthy enough for financial decisions — but AI + deterministic validation + human review creates a system where each layer catches what the others miss.
  • The "quote the evidence" pattern could apply beyond code review — to document verification, compliance checking, or any domain where you need provable claims.

What's next for ProofPay

  • Support for document deliverables (PDFs, design files) beyond GitHub repos
  • Multi-milestone projects with dependent payment schedules
  • Webhook-based notifications when verification completes
  • Production PayPal integration with real merchant onboarding

Built With

Share this project:

Updates

Submission history