Inspiration

AI agents are starting to shop and pay on our behalf, but handing an agent a wallet is scary. One bad instruction or a manipulated prompt could drain a budget. I wanted to see what it would take to delegate purchasing to AI safely.

What it does

MandatePay gives your AI agent a spending mandate, not your wallet.

  1. You write a rule in plain English, for example "office snacks, max $80, nothing over $25, no ShadyDeals".
  2. Gemini turns it into a validated mandate: total budget, per-item limit, allowed categories, blocked sellers and an auto-approve threshold.
  3. An AI agent searches products and proposes a cart.
  4. A deterministic policy engine decides: auto-approve, needs human approval, or blocked.
  5. Approved carts become PayPal sandbox orders. The buyer approves, the server captures the payment, and every decision lands in an AG Grid audit log with an AI-written explanation.

The core principle: the AI suggests, deterministic code enforces. The model can never move money on its own.

How I built it

  • PayPal - Orders v2 (create and capture), OAuth2 client credentials, idempotency keys, and webhook signature verification (sandbox only)
  • AI - Gemini API for structured output (mandate parsing validated with Zod and retried on invalid output) and a tool-calling agent loop with a hard step limit
  • Policy engine - pure TypeScript with no AI, covered by 7 unit tests (budget, per-item limits, categories, blocked sellers, expiry)
  • Stack - Node/Express, React, Vite, AG Grid

Challenges

I started with the Claude API, then switched to Gemini mid-build, which meant adapting the tool-calling format (for example input_schema became parameters). Getting PayPal's approve-then-capture flow right, and keeping the AI strictly separated from the money-moving code, took the most care.

What I learned

Payments engineering (idempotency, capture vs approval, webhook verification), LLM tool use, and why guardrails belong in code the model cannot override.

What's next

Live product search (Channel3), Postgres storage, multi-user mandates, and a "red team" mode that tests the agent against instructions to overspend.

Built With

Share this project:

Updates

Submission history