Inspiration

Agents can already buy things. PayPal's Agent Ready lets a shop take a purchase made inside ChatGPT or Google's AI Mode, and the passkey at the end proves it is me. Nothing in that flow records what the agent was allowed to buy.

Google proposed the Agent Payments Protocol in September 2025, with PayPal as a partner. It defines a mandate: a signed record of what I agreed an agent may do. PayPal's SVP of AI wrote about it that day and named the mandate APIs, the mandate linked receipts and the dispute evidence he wanted built. No PayPal API creates a mandate today. The developer docs cover agent checkout in two protocols over three integration paths, and none of them can create, read or cancel one.

So I built that part, in TypeScript, on PayPal's sandbox.

What it does

I give an agent an allowance: a purpose, a total, a per purchase limit, one shop, and an end date. The agent gets three MCP tools: read the allowance, ask to buy something, and read the ledger. There is no fourth tool, so it cannot create, raise or cancel anything. It brings its own model, and nothing in the rules calls one.

Every request meets nine rules. They are a plain function over the request, the allowance and the clock, so the same inputs always give the same answer. There are three answers: allowed, waiting for you, refused. Each names its rule and says what happens next.

Permission to spend is issued only on "allowed". It works once, for one amount at one shop, and expires after two minutes. Cancelling the allowance clears any permission still alive, so the agent's next attempt fails because there is nothing to spend.

Every decision writes a ledger row, refusals included. A paid row carries a receipt in plain English and a refund button.

I can hand an agent my shopping without handing it my card.

How I built it

SvelteKit 3 on Svelte 5, TypeScript, Bun and Postgres, with a hand written Orders v2 client behind one interface. The agent surface is an MCP server built with tmcp, mounted on the app's own origin, so an MCP client connects to one URL with nothing to install. One module reads the API keys, and the agent process never gets them.

The order of the PayPal calls decides whether a refusal can stop the money. In the sandbox the merchant id arrives on the order response, and a card attached at create time authorises during that same call. So the service creates the order with no card, reads the merchant id, decides, attaches the card, places a hold, reads the id again, and captures. A mismatch after the hold is voided.

Receipts are written by code, from the facts the rule table already used, so a receipt cannot claim more than the decision did.

Challenges I ran into

Trusting the agent's word about the shop. The obvious merchant check compares the name the agent sends, which the agent writes, so it could write anything. The rule compares PayPal's own merchant id instead.

Stopping the money before the hold. A refusal has to land before anything is held, or the guarantee is only a promise to refund. That is why the order goes in bare and the card goes on afterwards.

Keeping one request from paying twice. The idempotency key is a hash of the allowance, the agent, the raw request text, the amount and the merchant, all known before anything else runs.

Accomplishments that I'm proud of

  • A refused purchase is never captured. The merchant check runs before the hold, and a change after the hold is voided.
  • The agent process will not start if it can see a single PayPal key, and a test checks it.
  • Every refusal names the rule that stopped it, so a person can read why a purchase did not go through.
  • A replay mode runs the whole story with no keys and no database, so a judge can walk every screen without signing up for anything.

What I learned

The rule that broke first was the one reading a name the agent wrote. Reading PayPal's id instead is the difference between a check and a guess.

What's next for Inkan

  • A real vault token. Today the service charges a sandbox test card from config. The real flow is a setup token, a person approving in a browser, then a payment token per purchase.
  • More MCP surface, so an agent can ask a person to narrow or cancel an allowance, not only spend inside it.
  • Notifications, so a request waiting for me arrives when the page is closed.
  • A login, on the dashboard and on the MCP endpoint.
  • An AP2 conformance check. I do not claim it today. The next step is to test the mandate model against the spec and say what passes.

Built With

Share this project:

Updates

Submission history