-
-
Corner Cafe's mandate, approved once in PayPal: $300 cap, $60 per item, approved retailers, daily limit, expiry. $47.32 left
-
Claude said buy, policy allowed it, and PayPal captured $31.00 from the saved wallet with nobody present. Capture id and mandate hash shown
-
Claude recommended a $79.84 buy; it exceeds the $16.32 left, so the policy engine denied it. Decided by policy, reason in plain words
-
Creating a mandate: total cap, per-item cap, approved retailers, purchases per day and days valid
-
The same Leash console in dark mode
Inspiration
Picture a tearoom owner in the UK (an illustrative persona) with seven staff who reorders about thirty items every Sunday evening: tea, consumables and ceramics, three separate budgets, an assistant manager who must never touch the card, and a bookkeeper who wants the month as a CSV for Xero. What she wants is not a bot with the card. She wants to approve a budget once in PayPal, have software keep every order inside the caps, and tap once on anything that falls outside them. Every agentic-commerce protocol I read this year signs the intent to buy; almost none enforce the limit afterwards. Leash is that enforcement: a mandate signed once in PayPal and a gate in Go that nothing talks its way past.
What it does
The owner creates a spend mandate: total cap, per-item cap, approved retailers, purchases per day, expiry. PayPal shows one approval screen, which saves the owner's wallet through Vault v3, and never again. The agent tracks products through Channel3 (any store URL becomes a canonical product with live offers), judges each offer with Claude, and asks the policy engine for permission. If allowed, Leash creates a new order paid from the saved vault_id, with nobody present and the mandate's hash in invoice_id, so every payment traces back to what was signed. Over the per-item cap? Denied with a reason and queued for the owner, who can approve it in one click. Retailer not on the list, budget exhausted, too many buys today, mandate expired? Hard denials that no approval overrides.
Six of nine matching buyers in a simulated 50-persona discovery programme wanted no autonomous spend at all, so there is a header toggle, "Buying: Agent judges | Suggest only". In suggest-only mode Claude is not called: the policy engine alone decides, every in-policy offer is held as NEEDS APPROVAL ("suggest-only: within mandate, awaiting your tap"), and the owner's tap captures it through the same approval path. Each ledger row records who decided, policy or model.
Candidly: checkout is PayPal sandbox only, against Channel3's demo retailers; no order reaches a real supplier yet. The mandate pattern is the part that is real and tested.
How I built it
Go backend, Preact console embedded in one binary, Postgres. A shared library, paypalgo, holds hand-written clients for Orders v2, Payments v2, Vault v3, Webhooks and Channel3, plus an LLM wrapper. The ledger row is written before the capture and its id is the PayPal-Request-Id, so a retry after a crash can never pay twice. The policy engine is pure Go with a unit test covering every rule. Claude returns structured JSON (buy/wait + reason) and never sets an amount. The APIMatic PayPal Context Plugin was installed in Claude Code during the build.
Challenges
My first sandbox business account was country-restricted from vaulting PayPal wallets, so I built Leash on authorize-once-then-partial-capture first. Moving to a US business account unlocked the real thing, a vault_id charged with no buyer present, and both modes now ship behind one switch. Vault mode raised the stakes: PayPal no longer holds a cap, so the policy engine is the only thing between the agent and the wallet. PayPal also caches OAuth tokens with stale scopes for eight hours after you enable a feature; the client now bypasses that cache.
Accomplishments
Real captures in the sandbox with no checkout page, each carrying the mandate hash. A denial, an approval, and an allowlist refusal, all explained in the ledger. Idempotent money movement. Security findings closed: auth gate, CSRF, fail-closed webhooks, prompt-injection hardening, escaped API paths.
What I learned
The interesting part of agentic commerce isn't the agent. It's the receipt chain and the gate. Once the gate is deterministic and tested, you can let the model be as clever as it likes.
What's next
The Channel3 checkout API when it opens, revoking a mandate by deleting its payment token, and an MCP server so any agent can call propose_cart and execute_payment under a mandate.
Built With
- channel3
- claude
- docker
- go
- paypal-orders-v2
- paypal-payments-v2
- paypal-vault-v3
- paypal-webhooks
- postgresql
- preact
- render