Inspiration

Language learners in Japan buy apps and books and quit within a week. Streaks and badges are free to ignore. Commitment contracts with real stakes work, but nobody wants to pay to study, and "pay if you fail" apps charge first and refund later. A PayPal authorization is the right primitive: the money is held, not taken, and released when you succeed.

What it does

Finish your English week, or your missed days go to charity.

  1. Plan: type 3 things you love (anime, games, novels). A planning agent maps them to English books, podcasts and shows at your CEFR level and writes a 7-day plan.
  2. Pledge: choose $1 or $2 per day. The Worker creates a PayPal order with intent: AUTHORIZE, you approve it on PayPal, and on return it calls POST /v2/checkout/orders/{id}/authorize. $7 (or $14) is now on hold; nothing is charged.
  3. Daily check-in: an AI tutor (Workers AI, Llama 3.3 70B) writes three questions about today's session (a summary only someone who did it can answer, a personal reaction, one new word used in your own sentence). A second AI call grades the answers 0-100 (pass >= 60), gives feedback and corrects your English. One retry, then the day counts as missed. You can also skip a day honestly.
  4. Settlement agent: after day 7 the agent reads the whole record and proposes exactly one PayPal action (void, partial_capture or full_capture) with an amount and its reasoning.
  5. Guardrail: before any money moves, a deterministic policy checks the proposal against the ledger (missed days x daily amount). If the agent asks for anything else (a prompt-injected "refund me", or a greedy full capture) the ledger wins and the override is logged.
  6. PayPal: the Worker calls POST /v2/payments/authorizations/{id}/void, or .../capture with the missed amount and final_capture: true, which releases the rest of the hold.
  7. Ledger: every learner action, AI decision, guardrail check and PayPal REST call (method, path, status, PayPal-Debug-Id, latency) is shown on the pledge page.

How we built it

  • Cloudflare Workers (TypeScript, zero runtime dependencies), Workers KV for pledges, vanilla JS frontend, Vitest (141 tests).
  • PayPal REST APIs (sandbox): OAuth 2.0 client credentials (/v1/oauth2/token), Orders v2 (intent: AUTHORIZE, payment_source.paypal.experience_context with return/cancel URLs, custom_id = pledge id), /v2/checkout/orders/{id}/authorize, Payments v2 void and partial capture with final_capture and an agent-written note_to_payer. Every mutating call sends a PayPal-Request-Id derived from the pledge id, so retries are idempotent and a pledge can never be captured twice.
  • AI: Workers AI @cf/meta/llama-3.3-70b-instruct-fp8-fast with JSON-schema constrained output for quiz writing, grading with corrections, and the settlement decision. Learner input is always treated as data (prompt-injection rule). Every AI step has a deterministic rule-based twin that takes over if the model fails or returns something unusable, so a check-in or a settlement never gets stuck; the UI labels which one answered.
  • Claude Code (Anthropic) was used as the coding assistant.

Challenges we ran into

  • Letting an AI touch money safely. The agent only proposes; the guardrail recomputes the amount from the ledger and overrides anything else, and that override is visible in the ledger.
  • Questions you can't fake. Early quiz prompts produced "What happened?". The prompt now demands the title and today's activity in every question, and lazy questions are rejected and regenerated.
  • Making it judgeable in minutes. Days unlock as soon as the previous one is done, and a "sandbox test card" shortcut places a real sandbox authorization without needing a buyer account.

Accomplishments that we're proud of

A full, real sandbox money flow (authorize, then void or partial capture with release) driven by an AI agent, with an auditable trail of every decision and every PayPal call.

What we learned

Authorization holds are an underused primitive for commitment devices: they give real stakes without taking anyone's money up front. And for agentic payments, "AI proposes, deterministic policy disposes" is a simple pattern that keeps the agent useful and the money safe.

What changed during the hackathon

Taste-to-English started on 2026-10-21 (planning pipeline only). For this hackathon we added the PayPal client (src/paypal.ts), the pledge state machine and guardrail (src/pledge.ts), the AI tutor and settlement agent (src/pledge-ai.ts), Workers KV storage, the pledge UI (public/pledge.js) and tests.

Try it (judges)

  1. Open https://taste-to-english-pledge.shotaro-takakura.workers.dev , click Try an example, then Build my plan.
  2. Under the plan choose $1/day and either Hold $7 with PayPal (approve with a PayPal sandbox personal account) or the sandbox test card shortcut.
  3. On the pledge page: I did today's session - check me, answer in English, submit. Skip a day to see a partial capture.
  4. After day 7: Settle my pledge and read the ledger.

What's next for Taste-to-English Pledge

One day per calendar day, reminders, letting learners pick the cause, and PayPal Giving Fund for real donations.

Built With

Share this project:

Updates

Submission history