Inspiration
Autonomous AI agents can easily handle everyday procurement tasks like restocking supplies or ordering gear for new hires. The issue is that handing an LLM direct API keys or wallet access is unsafe. Models can hallucinate items, prompt injections can bypass spending limits, and multiple agents can drain a company budget at the same time. Setting budget constraints inside an LLM prompt is not a security boundary, and getting an email alert after money has already left the account is too late. We built Mandate Lite for the PayPal AI Hackathon to put a deterministic rule engine between the agent and payment: the agent plans the basket, the server validates the mandate before payment can start, and PayPal Orders v2 handles the final transaction.
What it does
Mandate Lite is a purchasing workspace and permission gateway for teams using AI agents. It splits the purchasing flow across four distinct authorities so that no single system has unchecked control:
First, the agent proposes items from the catalog. It cannot approve itself and holds no payment credentials.
Second, the gateway enforces rules on the server. It verifies prices in integer cents, checks merchant categories, enforces basket caps, and locks budget reservations atomically.
Third, the business owner reviews higher-value orders. Any purchase above a defined threshold requires explicit human approval, locked to the exact SHA-256 hash of the basket.
Fourth, the buyer gives payment consent on PayPal. The purchase is only marked complete once PayPal returns a verified capture.
The application demonstrates three core outcomes:
An allowed purchase, like an 18 dollar coffee restock, which passes policy checks and moves straight to buyer checkout. A blocked purchase, like a 900 dollar espresso machine, which gets stopped immediately by category and cap limits without creating a PayPal order. A review request, like a 180 dollar gift basket, which stays locked until the owner approves it in the attention queue.
We also included a standalone replay mode that lets evaluators walk through all three scenarios with preloaded fixtures without having to log in.
How we built it
For the frontend, we used React 19, TypeScript, and Vite with a custom design system written in plain CSS and SVG transitions. We did not use third-party animation libraries. For the audit log, we used AG Grid Community to handle column filtering, sorting, and CSV export.
The backend runs on Node.js and Express with SQLite in WAL mode. We used serialized transactions to guarantee that concurrent agent requests cannot overbook the total budget.
The AI purchasing planner connects to Groq or OpenAI using strict structured outputs. If a prompt is ambiguous or asks for items not in the catalog, the agent asks a clarification question instead of guessing.
The PayPal integration uses the sandbox Orders v2 API with OAuth token caching, idempotent request headers, preflight checks on amounts and merchant IDs, and direct order lookups for reconciliation.
The app is deployed as a web service on Render with persistent storage, set up to coordinate background agent tasks and periodic reconciliation jobs through Render Workflows.
Challenges we ran into
The primary challenge was separating business approval from payment consent. A manager approving an expense is not the same thing as a buyer submitting payment details. We had to build two distinct states so that owner approval authorizes checkout preparation, but final payment still requires buyer consent inside PayPal.
Another challenge was preventing parallel budget overbooking. If multiple agents submit orders at the exact same moment, standard database queries can easily overspend the budget. We solved this with serialized write transactions in SQLite that verify available funds before confirming reservations.
We also had to account for network drops during payment callbacks. We built a reconciliation flow where interrupted checkouts remain in a reserved checking state, allowing the operator to refresh provider status directly from PayPal without risking double charges.
Accomplishments that we're proud of
All 35 automated integration tests pass, covering policy boundaries, payload tampering, concurrent reservations, CSRF protection, and server recovery.
Every completed transaction in the live workspace runs against genuine PayPal Sandbox Orders v2 endpoints. We avoided fake payment simulations in live mode.
Our local transaction benchmark recorded p95 policy evaluation and reservation latency under 2 milliseconds.
We also built a complete replay mode alongside the live app so judges can review the full workflow without needing test credentials.
What we learned
Guardrails must live in backend application code, not in system prompts. Giving models structured output schemas makes them effective at planning, but financial calculations and rule enforcement must stay strictly on the server.
Using PayPal REST idempotency keys is essential for handling retries safely when automated workflows hit network timeouts.
We also learned how to use Render Workflows to run agent planning and background order checks as isolated background jobs without slowing down user checkout routes.
What's next for Mandate-Lite
We plan to add adapters for multiple merchants to support real-time inventory feeds, shipping options, and sales tax calculation.
We also want to investigate officially supported PayPal Vault billing agreements to allow automated micro-purchases under strict limits without requiring manual checkout clicks every time.
Finally, we want to package the gateway as a Model Context Protocol server so coding agents in tools like Claude Code or Cursor can safely request team supplies directly from their developer environments.
Built With
- ag-grid
- agentic-commerce
- ai-agents
- express.js
- groq
- idempotency
- node.js
- openai
- paypal
- paypal-orders-v2
- paypal-sandbox
- react
- render
- render-workflows
- rest-api
- sqlite
- structured-outputs
- typescript
- vite