Inspiration

Freelancers and clients lose billions every year to milestone disputes. Clients worry about paying upfront for incomplete or broken deliverables, while freelancers fear delivering code or websites only for the client to disappear without payment.

Traditional escrow services rely on slow human arbitration that takes weeks and charges high fees. We asked ourselves: What if PayPal authorizations could be autonomously governed by an objective, AI-driven verification engine? That sparked PayGuard Escrow—an autonomous escrow system where funds are locked securely via PayPal and automatically released only when an intelligent browser agent verifies that milestone criteria actually pass.

What it does

PayGuard Escrow acts as an autonomous digital referee between clients and contractors:

  1. Escrow Hold with PayPal: When a project is agreed upon, the client approves an escrow hold using PayPal's intent=AUTHORIZE API. No money leaves the client's hands until work is delivered.
  2. Autonomous Milestone Testing: The freelancer submits their deployment URL or API endpoint. Our autonomous Playwright and LLM engine spins up in a headless sandbox to interact with the app, verify core user flows, test responsive viewports, and detect broken authentication or visual bugs.
  3. Mathematical Verification Scoring: The verification engine computes a composite score \( S \in [0, 100] \) based on weighted test criteria: $$S = \sum_{i=1}^{n} w_i \cdot c_i \quad \text{where } \sum_{i=1}^{n} w_i = 100$$
  4. Automated Tiered Payouts: Based on the verified score \( S \), the PayPal authorization is captured proportionally: $$P(S) = \begin{cases} 100\% \text{ Full Capture} & \text{if } S \ge 90 \ 70\% \text{ Partial Payout} & \text{if } 70 \le S < 90 \ 0\% \text{ Held / Human Review} & \text{if } S < 70 \end{cases}$$
  5. Real-time Streaming Observability: Both parties watch the verification live via Server-Sent Events (SSE), complete with live terminal logs, screenshot diffs, and cryptographic audit proofs.

How we built it

  • Core Platform & Frontend: Built with Next.js (App Router), React, TypeScript, and Tailwind CSS, featuring dark-mode glassmorphic styling and live execution monitors.
  • PayPal Integration: Integrated PayPal Orders & Payments API (v2/checkout/orders and v2/payments/authorizations), supporting authorization holds, partial captures (amount.breakdown), and automated release voids.
  • Verification Engine: Built an orchestration runner using Playwright Chromium to simulate real end-user interaction (form fills, UI state assertions, layout checks, and network intercepts).
  • Security & SSRF Firewall: Designed strict IPv4/IPv6 CIDR validation to prohibit internal network probing, localhost bypasses, and DNS rebinding attacks when scanning target URLs.
  • Live Stream Architecture: Implemented custom Server-Sent Events (SSE) streaming so verification logs, milestone checkpoints, and run metrics stream with sub-second latency to the client dashboard.

Challenges we ran into

  • PayPal Authorization Idempotency: Ensuring that concurrent verification webhooks or network retries never double-capture an authorization required strict tokenized idempotency keys and state locking in our transaction ledger.
  • Sandboxed Browser Testing: Running browser automation against unpredictable user-submitted URLs required tight security sandboxing, aggressive execution timeouts, and an anti-SSRF layer preventing arbitrary network access.
  • Graceful Partial Captures: PayPal requires exact currency amount breakdown formatting when capturing partial sums (e.g. 70% of an authorization while voiding the remainder). We engineered robust arithmetic rounding handlers to guarantee exact cent matches.

Accomplishments that we're proud of

  • Achieving a 100% test pass rate (21/21 Vitest suites and 36/36 Node integration test suites) covering state machine transitions, edge-case scoring, and PayPal API mocks.
  • Flawless end-to-end rehearsal across all three verification tiers (100% pass, 70% partial payout, and 0% hold).
  • Building an interface that feels snappy, reliable, and gives instant transparency with real-time browser session replay and event streaming.

What we learned

  • Deep nuances of PayPal's payment lifecycle—specifically the differences between CAPTURE and two-step AUTHORIZE followed by partial/full capture.
  • How to combine deterministic browser automation (Playwright assertions) with intelligent validation routines to create an objective, dispute-proof evaluation score.
  • Edge deployment constraints on modern serverless platforms like Netlify.

What's next for PayGuard Escrow

  • Multi-Milestone Escrow Bundles: Enabling multi-phase projects with cumulative milestone authorizations and milestone dependencies.
  • Custom Milestone DSL: Allowing clients to define custom assertions (e.g., Lighthouse performance scores \( \ge 95 \), test coverage, OpenAPI compliance) directly in natural language.
  • Dispute Mediation AI: An AI arbitrator that synthesizes browser screen captures and server logs into a concise mediation brief if either party requests manual dispute resolution.

Built With

Share this project:

Updates

Submission history