Inspiration
Freelancing runs on a broken trust loop. Clients are told to pay upfront and hope the work is good. Freelancers deliver and then wait 30, 60, sometimes 90 days for an invoice to clear — chasing, re-sending, and politely nagging. Traditional escrow solved the trust problem decades ago, but it replaced it with a speed problem: every release requires a human to log in, review, and approve.
We kept asking the same question: what if the arbiter was always awake?
LLMs can now read a brief and objectively grade a deliverable in under three seconds. PayPal already has the rails to move money instantly. Nobody had welded the two together into a single autonomous loop. So we built PalPact: escrow where the AI is the judge, the jury, and the release trigger — and PayPal is the settlement layer.
What it does
PalPact is a micro-task marketplace with autonomous escrow:
A client posts a bounty — title, detailed requirements, reward amount, and the freelancer's PayPal sandbox email. The client funds it via PayPal Checkout. Funds are locked on the platform. The task status flips to IN ESCROW. Nothing is released yet. A freelancer claims and submits work through a submission modal. The AI Judge evaluates. Our backend sends the original requirements alongside the submission to an LLM using a strict JSON output contract. It returns a score, a pass/fail verdict, one or two sentences of feedback, and a release_funds boolean. If it passes, PayPal pays out in seconds. The backend acquires an OAuth token, calls the PayPal Payouts API, and sends the reward directly to the freelancer's PayPal account — automatically, with no human click. The batch ID is stored against the task. If it fails, no money moves. The freelancer sees the AI's specific feedback and can resubmit. Funds stay locked in escrow. Every task lives in an AG Grid dashboard showing reward, status badge, AI score, PayPal transaction/payout ID, and a contextual action button. On successful payout, a Zapier webhook fires an automated receipt to the freelancer and a notification to the client's Slack.
The whole settlement loop — submission to cash in hand — runs in about five seconds.
How we built it
Frontend: React (Next.js App Router) with Tailwind CSS and Lucide icons. The dashboard is built entirely on AG Grid — custom cell renderers for status pills and score bars, plus an action column that changes based on task state (Fund → Submit → View Receipt).
Backend: Next.js API routes on Node.js.
POST /api/paypal/token — caches the OAuth2 client-credentials token so we aren't re-authenticating on every request. POST /api/paypal/payout — calls v1/payments/payouts with an Idempotency-Key and a unique sender_batch_id derived from the task ID, so a double-click can never double-pay. POST /api/verify-and-payout — the orchestrator. Calls the LLM, parses the JSON verdict, and only forwards to the payout route if release_funds === true. Payments: @paypal/react-paypal-js for the sandbox checkout button on the fund flow; raw REST calls for the Payouts side.
AI: OpenAI (with a Groq fallback for speed during the demo) using response_format: { type: "json_object" }. The system prompt constrains the model to a fixed schema so we never have to regex a verdict out of prose — the model's output is our control flow.
State: Lightweight SQLite via Prisma so the app boots instantly with zero external infra. Every state transition is persisted, which also gives us an audit trail.
Deployment & tooling: Hosted on Render. The full PayPal integration was developed and documented against a Postman collection we've published alongside the repo, so judges can exercise the payout endpoint without touching the UI.
Challenges we ran into
PayPal sandbox payout authorization. Our first payout attempts failed silently. The cause: a Payouts-enabled app in the sandbox only pays to verified sandbox business/personal accounts that already exist in your test account list. We spent real time realizing that a made-up email address returns an ambiguous success from the batch endpoint — the individual payment inside the batch is what fails. Lesson learned: always read the batch-level item results, not just the HTTP status.
AI verdicts are not deterministic. The same submission scored 84 one run and 79 the next — straddling our pass threshold and producing a genuinely bad demo moment on a livestream. We fixed it three ways: lowered temperature to 0, made the rubric explicit and weighted in the system prompt, and — most importantly — changed the schema so the model is asked for a score first and the passed/release_funds booleans are derived on our server from that score. We stopped trusting the model to self-consistently set two fields that depend on each other.
Idempotency in a money-moving system. During testing we re-fired the verify endpoint and paid a sandbox freelancer twice. That's a one-line bug with catastrophic real-world consequences, so we made every payout carry a deterministic sender_batch_id and an idempotency key — and we now treat "the network timed out, did it send?" as a first-class state rather than an edge case.
Making AG Grid feel like a product, not a spreadsheet. Out of the box it's very enterprise. Getting status pills, score bars, and contextual action buttons to look native took more time than the backend.
Accomplishments that we're proud of
The loop actually closes. No mock, no "coming soon." A real sandbox payment goes in, a real LLM evaluates, a real Payouts API call goes out, and a real batch ID comes back — in a single unattended flow. We designed AI output as an API contract, not a chat response. The model returns machine-executable JSON that directly gates a financial transaction. That architectural decision is the reason the demo is reliable. We stacked four sponsor tools without bolting them on. AG Grid is the product surface, Zapier is the notification layer, Postman is the test harness, Render is the deployment. None of them are decorative. We built real safety rails into a money app — idempotency keys, server-derived verdicts, deterministic batch IDs, an immutable per-task audit trail — in a weekend.
What we learned
AI is a surprisingly good objective arbiter — if you give it a rubric. Vague prompts produce vibes. A weighted checklist ("30 pts for word count, 40 pts for required keywords, 30 pts for tone match") produces decisions consistent enough to move money. Never let the model hold the veto on its own consistency. Deriving passed server-side from the score removed an entire class of flaky failures. Payment APIs are unforgiving and that's a feature. The Idempotency-Key header, the batch-vs-item response structure, the OAuth token lifetime — PayPal forced us to build like adults. We now understand why fintech engineers are so paranoid. The hardest part of a "fast" product is trust. A 5-second payout is only impressive if it's correct. Speed without verification is just a faster way to lose money.
What's next for PalPact
Near term
Milestone-based escrow — split a project into stages, each independently AI-gated and paid, so $5,000 contracts work as well as $50 bounties. Dispute arbitration tier — when the AI verdict is contested, route to a human reviewer or a multi-model consensus (two of three LLMs must agree). Reputation layer — a freelancer's historical AI scores become a portable trust score, displayed in AG Grid and queryable via Elastic semantic search to match freelancers to bounties.
Built With
- ag-grid
- artificial-intelligence
- fintech
- gpt-4o
- javascript
- json
- llm
- nextjs
- node.js
- oauth2
- openai
- paypal
- paypal-checkout
- paypal-payouts
- paypal-sandbox
- postman
- react
- render
- rest-api
- tailwindcss
- typescript
- webhooks
- zapier