Inspiration

Group buys die in the group chat. Everyone argues about price, half the group drops out, and nobody ever pays. We wanted the argument and the money to live in one place, and wanted it to be funny.

What it does

One project, two parts: Haggle Court (the negotiation) and Pool (the settlement).

Statler (buyer bot) and Waldorf (seller bot) haggle the price of a group buy, trading insults each turn. The agreed price becomes a PayPal order with intent AUTHORIZE, so the funds are held, not taken. A rule-based judge reads the PayPal receipt and the group chat, then rules. If the group is in, it captures the order and works out each person's share, and PayPal Payouts submits the splits. If half the group or more says they are out, it voids the authorization and nobody is charged. A web page shows the argument live, with the PayPal IDs and the verdict.

Pool turns the agreed price into a group-funded purchase. Participant agents review the terms, but only a human approval tied to the exact terms counts, and any change clears all approvals. The coordinator holds each person's share through PayPal, asks for a final approval, captures, buys, and requests remainder payouts through Payouts. In the failure demo one capture fails: the coordinator stops, records the partial result, requests refunds for successful captures and voids the other holds, and never claims everyone paid. Payout or compensation failures remain pending for follow-up. Venmo is shown as a labeled simulation because its sandbox has no hold step.

How we built it

Python standard library, no framework. A negotiation loop for the two bots, a rule-based judge that reads the order and chat (optionally Google Gemini writes the banter and suggests judge weights through a free AI Studio API key; earlier builds used Vertex AI under a trial credit, removed before expiry. Code computes all money and falls back to scripted on any error), a PayPal client with a real sandbox implementation and a mock with the same interface, a small HTTP server and one-page UI, and a signature-checking webhook receiver. Webhook registration and live delivery verified against the real sandbox Oct 23, 2026: a real signed capture event was accepted and an unverifiable simulated post was refused. PayPal APIs: OAuth2, Orders v2 (create, authorize, capture), Payments v2 (void, refund), and Payouts. The coordinator is an explicit state machine with an event log that deduplicates log keys (not a durable transaction retry ledger). 63 unit tests pass offline, including receipt evidence failure and full-chat preservation checks. The AI role is limited on purpose: the model only writes banter and suggests judge weights. Prices, shares, captures and voids are computed by code, while the model can influence judge weights within code limits; model output never directly calls a payment API. Merchant purchase and participant approvals are simulated in the demo.

After capture, a receipt-only evidence check reads vendor, total and date. Clairic is supported when credentialed; the hosted setup has no Clairic credentials, and the demonstration video uses the local parser. A mismatch only warns. Malformed or unavailable evidence must not stop payouts after capture. The full speaker chat still reaches the judge unchanged.

Accomplishments

A private integrated live-Gemini plus PayPal sandbox run succeeded on November 10, 2026: 9/9 model calls, no fallback, and a verified $168 sandbox capture. Payout delivery is not claimed.

A full hold, judge, capture or void, payout cycle running against the live PayPal sandbox with real IDs, and a void path that leaves no charge. The hosted demo runs this against the real sandbox: verified Oct 18, 2026 with a live authorize, capture and payout batch on the success path and a live authorize and void on the bail-out path.

What we learned

Authorize-then-decide fits agent commerce well: an agent can commit to a price without moving money until a second agent signs off.

What's next

Verifying the buyer wallet approval step end to end (the flow is built and needs a Personal sandbox buyer to exercise it), webhook-driven status updates, and multi-seller bidding.

Current AI status

The hosted demo currently uses scripted AI. On November 10, 2026, one private integrated run completed nine successful Gemini 3.5 Flash-Lite calls with PayPal sandbox authorization and capture of $168. The owning free project had no billing account linked. Code calculated shares of $81.11, $28.97, $28.96 and $28.96, totaling $168; its payout batch was pending when checked, not confirmed delivered. Earlier transient model failures are not hidden by the successful run. Earlier builds used Vertex AI under trial credits; that hosted key was removed before credit expiry. The public hosted demo remains scripted and has no model credential. The demonstration video explicitly labels its integrated UI section as a replay of the exact saved private-run response, not another live API click. Buyer-wallet approval remains untested; the verified sandbox route uses a test card.

How judges can test

  • Open https://haggle-court.onrender.com (free tier, allow about a minute for a cold start). It runs against the PayPal sandbox: click "Open court" for the success path (real sandbox authorize, capture and payout IDs shown) and "Group bails out" for the void path. The Pool page shows the group purchase and the failure rollback.
  • Or run locally with no keys: PYTHONPATH=src python3 -m unittest discover -s tests then PYTHONPATH=src python3 -m haggle.server and open http://localhost:8000. Mock PayPal mode is the default.
  • No credentials are needed. The live Gemini role needs your own Google key (see README).

Built With

Share this project:

Updates

Submission history