-
-
Every agent purchase gets an undo: AI agents shop under a mandate the shopper signs, and PayPal only holds the money.
-
Undo windows on a timeline (Bryntum), with agent trust scores that the store's own rules act on at checkout.
-
Every step is hash-chained and signed. Anyone can verify the whole record in their own browser, and a tampered copy gets caught.
-
Nine agents attack one signed mandate live, including a real AI hijacked by a hidden prompt injection. Every bad cart is blocked.
-
A real purchase: the cart passed the mandate check, PayPal holds the money, and the undo window shows how long you have to reverse it.
-
Merchant console: every agent order with its verdict and who pays. Agent-fault refunds are billed to the agent's operator via Payouts.
Inspiration
AI agents can already buy things for people. Nobody has an answer for what happens when one buys the wrong thing. The shopper never clicked "pay". The merchant shipped exactly what was ordered. The company that runs the agent isn't part of the transaction at all. Today that ends in a chargeback, and the merchant loses the sale plus the fees.
Computers have had Ctrl+Z for decades. Agent purchases need one before anyone trusts an agent with real money. That's Undo.
What it does
Undo is a reversal layer for agent purchases, built on PayPal.
- The shopper signs the rules. "Black hoodie, size M, under $80" becomes a signed mandate: item, size, colour, budget, quantity, expiry, and which agent may use it. The signing key never leaves the shopper's device, so no agent can edit or reuse the mandate.
- A guard checks every cart before PayPal sees it. The product is fetched again live, in the exact variant, and compared with the mandate. A cart that breaks the mandate never becomes a checkout.
- PayPal only holds the money. Checkout uses
intent: AUTHORIZE, and each purchase gets an undo window based on risk. Expensive purchases, uncertain listings and low-trust agents get longer windows. - Undo with a verdict. Inside the window, undo is a free void. After capture, a fault engine decides whose mistake it was and picks the PayPal path: a full refund, a claim against the merchant with a signed evidence pack, or a return. Rules decide first, AI only where rules can't, and a person when it's close.
- The agent's operator pays. When the agent broke the mandate, the shopper is refunded and the operator pays the merchant back through PayPal Payouts, so the merchant isn't out the sale.
- Anyone can check it. Every step goes into a hash-chained event log. The order page re-checks the whole chain and both signatures in your own browser, and lets you tamper with a copy to watch it get caught.
Around that core:
- Rogue agents demo. Nine agents attack one signed mandate live. One of them is a real Gemini agent hijacked by a prompt injection hidden in a product listing.
- Autopay. The agent can pay by itself from a wallet saved with PayPal Vault. That permission is signed into the mandate, the money is still only held, and the undo window gets longer.
- Merchant console. Every agent order with its verdict and who pays, a live activity feed, an undo-window timeline, and agent trust scores that the store's own rules act on.
- Any agent can plug in. An MCP server lets outside agents shop under a mandate and pass exactly the same checks. There's also a documented HTTP API, TypeScript and Python SDKs, and a Postman collection.
How we built it
- PayPal (sandbox): Orders v2 with authorize-only checkout; Payments v2 to authorize, capture, void and refund; Payouts for operator liability; Vault v3 for autopay; signature-checked Webhooks; and Disputes. Every money-moving call carries a fixed
PayPal-Request-Id, so a retry can never move money twice. - Signing: Ed25519 keys created in the browser with WebCrypto, marked non-extractable. Mandates are canonical JSON hashed with SHA-256, and the server re-checks them on every load.
- App: Next.js 16 and React 19 on Render's free tier, Neon Postgres with Drizzle, Tailwind v4.
- Products: real retailer listings from the Channel3 catalog.
- AI: Gemini through the Vercel AI SDK. It turns requests into draft mandates, ranks products that already passed the guard, and reads complaints and delivery photos when rules can't settle a case.
- Merchant UI: AG Grid and Bryntum Scheduler.
- Developer tools: an OpenAPI spec validated with APIMatic, an APIMatic docs portal with a live playground, generated SDKs, and a Postman collection run against the live service.
- Everything runs on free tiers. Nothing cost money to build or host.
Challenges we ran into
- Making liability real, not a label. "The agent's operator pays" means nothing unless money actually moves. That took a second sandbox business account acting as the operator, plus Payouts, plus tracking each payout until it settles.
- Buyer-side disputes need partner permissions this app doesn't have. The merchant-fault path became Undo's own claim, with a signed evidence pack and a Payments API refund.
- Listings don't always say which sizes or colours exist. Rather than guess, Undo says what it couldn't confirm and gives the purchase a longer undo window.
- Free hosting. A large timeline library ran the build out of memory on Render's free tier, and the server sleeps when idle. The library now loads at runtime, and a scheduled GitHub Action keeps the server awake and also runs payment captures.
- AI doesn't behave the same way twice. The real hijacked agent doesn't fall for the injection every time, so the demo labels each run honestly: "fooled" or "resisted".
Accomplishments that we're proud of
- A prompt-injected AI agent is stopped without any injection detector, because the signed mandate is the boundary.
- When an agent is at fault, its operator pays the merchant back through PayPal Payouts. This was run end to end with sandbox money.
- One undo button, four PayPal outcomes (void, refund, merchant claim, return), each picked by whose fault it was.
- Every verdict can be checked by anyone, in their own browser, without trusting Undo's server.
- Built solo, on free tiers only, with 49 automated tests.
What we learned
The hard problem in agent commerce isn't letting an agent pay. It's deciding afterwards who was responsible, and proving it. A signed mandate plus a payment that's only held gives you both: the mandate says what was allowed, and the hold leaves time to act before the money is gone.
We also learned that you can stop a hijacked agent without detecting the hijack. If every cart has to match what the shopper signed, the agent can't do anything the shopper didn't allow.
What's next for Undo
- Separate payout accounts for each operator, so every agent company settles its own liability.
- PayPal Disputes with partner permissions, so merchant-fault cases go through PayPal's own process.
- A standard mandate format that agent platforms can request and check.
- A merchant plug-in so any PayPal store can show an agent's trust score at checkout.
Built With
- ag-grid
- apimatic
- bryntum
- channel3
- drizzle
- gemini
- mcp
- neon
- next.js
- paypal
- paypal-orders-api
- paypal-payouts
- paypal-vault
- paypal-webhooks
- postgresql
- react
- render
- tailwindcss
- typescript
- webcrypto