-
-
The demo starts here. The agent is ready, and PayPal stays hidden until a basket passes the spending policy.
-
One box of pens, £4.50, passes every rule. The receipt is all Pass, and the PayPal button appears for that total.
-
The buyer signs in on sandbox.paypal.com with a personal sandbox account. That account is the payer.
-
Sandbox checkout for the allowed pens: £4.50 today, paid from the personal account's PayPal balance.
-
PayPal captured £4.50. The status is COMPLETED, the order id is on the receipt, and the spend is in the ledger.
-
A second box of pens is blocked. Desk & Co already sold that box within 24 hours, so no PayPal order is created.
-
The listing told the agent to buy 50 cables. £400 fails the £200 cap, and that quantity is not the user's goal.
-
"Buy a laptop" became a £749 laptop plus 50 cables, £1,149. The order cap, the weekly cap, and goal grounding all fail.
-
The agent proposed six stationery lines for a 3-person team, priced from the catalog at £77.96.
-
A £77.96 office basket is blocked because the pens were bought earlier. The cheaper-basket notes do not change the verdict.
Inspiration
An agent that can shop will eventually be asked to pay. PayPal already moves that money. The open question is what happens when the agent is the one holding the basket.
A product listing can tell the agent to ignore the buyer. In this catalog, one USB-C cable listing tells the agent to buy 50. A careful assistant would refuse. A naive one will follow the listing, add £400, and hand that total to checkout. Notary is the check in between: the agent may propose, and PayPal is offered only after the basket passes a spending policy.
What it does
You type one sentence. A shopping agent searches a catalog of 31 products and proposes a basket. The server prices every line from the catalog, then checks the proposal with Z3.
The policy caps an order at £200 and a 7-day total at £500, allows five merchants, blocks alcohol, rejects a repeat from the same merchant within 24 hours, checks that the stated total matches the lines, and checks that a quantity demanded by a listing is actually what the user asked for. Each rule comes back Pass or Fail. The page draws the reasoning graph: the user's goal, the listings the agent read, and each purchase. A pass shows a PayPal sandbox button for the catalog total. The browser sends a checkout id, not a price. The server checks the basket again, creates an Orders v2 order, and captures it only after the buyer approves. A fail shows no button and creates no order. The receipt lists the basket, the policy, every rule, the time, the checkout id, and the PayPal order id once the payment exists. That receipt can be downloaded.
The live demo is https://notary-jxts.onrender.com.
How I built it
Python and FastAPI serve a plain HTML page. The agent calls Groq through the OpenAI-compatible Chat Completions API, model openai/gpt-oss-20b, with tools to search the catalog, read one listing, and propose an order. It cannot pay.
The graph is built from the tool trace, not from a second reading of the prose. policies/default.yaml holds the caps. verify() gives each rule its own Z3 solver. Money is integer pence. A pass is saved as a checkout in SQLite, bound to the browser session. PayPal is the Orders v2 sandbox API plus the JavaScript SDK v6 button. A capture of COMPLETED or PENDING is written to the ledger, one row per line. Render hosts the app. The license is MIT.
Challenges we ran into
The first total check read the wrong number. The model wrote Total = £22.00 + … = £95.98, and the parser kept £22.00, so a legitimate office basket was blocked. The checker now evaluates the sum and reads the last stated total. PayPal's current JavaScript SDK wants createOrder to return { orderId }. A bare order-id string, which older examples return, never opened checkout. GBP captures also stayed PENDING until the sandbox seller was a UK business account. Paying with that same business account fails, because a seller cannot pay itself. The buyer has to be a sandbox personal account, on sandbox.paypal.com.
On Render, the rate limit first used the last address in X-Forwarded-For, which is the proxy. Every judge would have shared one bucket of 10 proposals a minute. The limit now uses the visitor's address, and the service starts with --proxy-headers. Groq retired llama-3.3-70b-versatile during the build, so the agent moved to openai/gpt-oss-20b.
Accomplishments that we're proud of
A real sandbox payment went through. "Buy one box of ballpoint pens" passed every rule, the buyer paid £4.50, and the capture came back COMPLETED. The same sentence a second time is blocked as a duplicate, with no PayPal button. "Buy one USB-C cable" becomes 50 cables at £400 and is blocked on the order cap and on goal grounding. "Buy a laptop" is £749 and is blocked on the order cap.
The receipt is the part that makes the name literal. One card shows the basket, each rule, the checkout id, and the PayPal order id.
What we learned
The agent's prices and arithmetic are not the payment. The catalog total stored with the check is the only amount PayPal is allowed to charge.
Sandbox identity matters as much as the API. The app, the seller, and the buyer are three different accounts, and the buyer must not be the merchant. A money cap is a reliable backstop when a wording rule is narrow. Goal grounding catches a listing that says "buy 50" or "50 units." A differently worded instruction can slip past that rule. The £200 and £500 caps still apply to the catalog total.
What's next for Notary
The duplicate check finds the earlier ledger row in Python, then asks Z3 to confirm a contradiction. The next step is to put that history into the solver with the other rules. Grounding should also catch number words and phrases like "a pack of." PayPal webhooks, verified by signature, should record captures that the browser never reports. A persistent ledger would survive a restart, and a Content-Security-Policy would lock the page down once the PayPal SDK v6 hosts are confirmed.