Live demo: https://playpen-yw8o.onrender.com · Code (MIT): https://github.com/ejose0509-del/playpen-paypal-ai

Inspiration

Healthy grocery shopping feels like a chore, loyalty programs are forgettable, and giving back usually means a separate app nobody opens twice. Cozy farm games, on the other hand, get people to come back every day just to water their crops. We put those together: a small daily ritual where the things you already buy (organic oats, honey, seeds) help a farm grow and unlock donations to good causes, with PayPal as the trusted way to pay and AI as a friendly guide.

What it does

PlayPen is a browser farm game with a companion, Bramble the hedgehog, powered by Claude.

  • A daily farm ritual. Swipe to plant, water and harvest in a pannable valley full of animals. Villagers place orders, coins restore the barn and orchard, and levels unlock new animals.
  • An AI companion that knows your farm. Bramble reads your farm's live state from the server and suggests the next step in plain language.
  • Agentic checkout with PayPal. At the market, ask Bramble to "buy the organic honey for me". Claude calls a start_sandbox_checkout tool, the server creates a PayPal Orders API order in Sandbox, and the chat shows an Approve in PayPal button. Bramble can never approve or pay: the player approves on PayPal, the server verifies the capture and amount, and the farm earns XP exactly once.
  • Bramble rides along in Chrome. A Chrome extension brings Bramble to your other tabs. It wanders the page, can take you to a shopping search ("show me organic granola"), marks organic products and demo partner brands, gives a guided tour, and searches real products across stores with Channel3.
  • Impact milestones. Level 3 and Level 5 record sponsor donations to pollinator habitat and community orchard causes, celebrated with a coin-drop ceremony at the old well. In this prototype the donations are simulated records; no real money moves.
  • A transparent ledger. Every XP reward, PayPal Sandbox payment and donation is listed in an AG Grid farm ledger with totals, filters and search.

Who it's for

Casual players and families who already shop online and want healthier habits to feel rewarding, and the brands and causes that want to reach them with a positive, opt-in experience instead of ads. The game stays fully playable by farming alone: buying is never required.

How we built it

  • Backend: Python, Flask and SQLite. All rewards, levels, costs and XP are decided on the server in a reward ledger keyed by source, so duplicate or replayed actions can't grant rewards twice.
  • PayPal: PayPal Orders API (Sandbox) to create, approve and capture orders. The server sets product and price, checks the order belongs to the farm, verifies the completed capture and amount, and grants rewards in the same database transaction.
  • AI: Claude (claude-opus-5-5) through the Anthropic API with tool use: start_sandbox_checkout in the market, browse_amazon and search_products in Chrome. Each request carries a compact farm summary from the server; chats are rate-limited per farm, and the model never sees approval links.
  • Frontend: vanilla JavaScript and CSS, with an animated SVG Bramble (blinks, follows your cursor, walks, talks, waves, naps) shared by the game and the extension.
  • Chrome extension: Manifest V3, paired to your farm with a private token instead of cookies.
  • Sponsor tools: Render (Blueprint deploy), AG Grid (ledger), Channel3 (product search).
  • Tests: 49 automated tests cover rewards, the ledger, checkout, the companion's tools and the extension API.

Challenges we ran into

  • Keeping an AI agent safe around money: Bramble can start an order but never approve it, and the server, not the model, decides prices and rewards.
  • Making rewards idempotent across simulated purchases, Sandbox captures and retries.
  • Product search quality: early food searches returned pet treats, so we filter categories and steer searches toward what the catalog covers well.

Accomplishments that we're proud of

An end-to-end agentic commerce loop that feels like play: talk to a pet, approve on PayPal, watch the farm grow, and see every reward in the ledger. And a companion that follows you off the farm into your real browsing.

What we learned

Agentic payments work best with a clear split: the AI handles intent and conversation, PayPal handles approval, and the server handles truth.

What's next for PlayPen

Real partner brands and sponsor-funded donations, PayPal's agent tooling for more payment flows, a mobile version, and seasonal farm events.

Brands shown in the demo (such as 365 by Whole Foods Market) appear only as "partner brand (demo)" examples; they have not partnered with PlayPen.

Built With

Share this project:

Updates

Submission history