RestPay — Your agent. Your rules.

A spending guardrail for AI shopping agents, with deterministic policy checks and PayPal checkout. Inspiration

AI agents are getting good at finding products, but handing one my card still feels like giving it a blank check.

I realized the main problem was not shopping capability—it was trust. Today, delegation is usually all-or-nothing: either approve every purchase yourself or give the agent unrestricted payment access.

RestPay was inspired by corporate expense policies. Instead of hoping an AI makes good decisions, users should be able to say:

“Only groceries and books. Keep groceries under $150 a month, no subscriptions, and ask me before anything over $50.”

The agent can then shop independently—within boundaries the user actually understands. What it does

RestPay turns plain-language spending mandates into structured rules and enforces them before money moves.

Allowed purchases proceed to PayPal sandbox checkout.
Purchases over the approval threshold pause for a human decision.
Rule-breaking purchases are blocked before a PayPal order exists.
Every outcome produces an explainable receipt with the policy snapshot and individual rule checks.

The demo includes a verified product catalog, monthly budget tracking, human approve/deny controls, and a downloadable audit trail. It also has a clearly labelled checkout simulator for anyone running the project without credentials. How I built it

I built RestPay with TypeScript, Node.js, Express, and a lightweight HTML/CSS/JavaScript frontend.

An OpenAI-compatible LLM performs two constrained tasks: compiling mandates into JSON and selecting products from the catalog. Runtime schema validation checks the model’s output, and a transparent local parser provides a fallback. The model never sets prices, interprets policy at checkout, or decides whether money should move.

Those decisions belong to a deterministic policy engine. Amounts use integer cents, and monthly budgets include both captured spending and active reservations: Scaptured+Sreserved+Spurchase≤Bmonthly Scaptured​+Sreserved​+Spurchase​≤Bmonthly​

For payments, I integrated PayPal’s sandbox OAuth and Orders v2 APIs. RestPay creates an order only after passing policy, uses PayPal-hosted buyer approval, then verifies the order status, amount, and reference before capture. Idempotency keys protect payment requests, and an atomic compare-and-set operation prevents concurrent capture attempts.

The project includes 18 automated tests, plus seed and sample-purchase commands so judges can reproduce the flow quickly. What I learned

I learned that buyer approval and policy approval are separate trust decisions. PayPal can confirm that a buyer approved a payment, but RestPay still needs to verify that the payment complies with the user’s mandate.

I also learned how important failure behavior is for agentic systems. AI providers can fail, models can return unexpected output, and multiple requests can arrive simultaneously. A financial guardrail should fail closed, validate every model response, and make concurrency protection explicit rather than accidental. Challenges

The hardest challenge was preventing small gaps between decisions and payment. A purchase could pass its initial check, then overspend while waiting for approval or another transaction. I addressed this with budget reservations and policy re-checks at approval and immediately before capture.

Another challenge was making the project demoable without hiding its limitations. Rather than pretending every AI or payment call succeeded, I added labelled fallbacks, real PayPal sandbox support, reproducible seed data, and receipts that expose exactly what happened. What’s next

I’d add authenticated multi-user workspaces, PostgreSQL-backed transactions, real merchant catalogs, and support for delegated agentic payment protocols. The core principle would remain the same:

AI proposes. Rules decide. You stay in control.

Share this project:

Updates

Submission history