Inspiration

AI shopping agents are starting to check out for people, and their carts can drift from what was asked:

  • a size 9.5 instead of a size 10, at the same price
  • a pre-ticked membership
  • an order whose items change after the shopper said yes

Spending caps and allowances (like ACP's max_amount) check how much. A size 9.5 at $99 has the same total as a size 10 at $99, so in our ablation runs (REAL SANDBOX, test money) an amount-only guard paid it.

CartMirror sits in front of PayPal's official MCP server (@paypal/mcp 1.8.1) as an opt-in path: pay_order runs only after the live order still matches what was approved. (REAL SANDBOX; buyer approval via Sandbox API (test card), not a wallet click; CartMirror approval card approved by the test script; orders under Evidence.)

We wanted the payment step itself to check what is being bought, against what the shopper approved, right before capture.

Who it's for

  • Primary: developers building AI shopping agents that pay with PayPal.
    • CartMirror binds the shopper's approval to exact line items (SKU, quantity, unit price).
    • The agent proposes carts; CartMirror's guard owns the capture call.
  • Their shoppers: they say what they want once, in plain words, confirm the rules the AI drafted, and are asked again when the price changes.

Honest scope: a hackathon prototype on PayPal Sandbox with test money and a SYNTHETIC demo catalog (TrailRunner Co. and its products, SKUs, sizes, prices and descriptions are invented test fixtures, not a real merchant or real listings). It has not been tested with outside developers.

What it does

CartMirror re-reads the live PayPal order right before capture and refuses if its items changed after approval.

  1. AI turns a messy request into rules. SYNTHETIC demo request: "Running shoes for Saturday's race. I wear a ten. Keep it under 120 bucks all in, and no monthly clubs or auto-renew junk." The LLM drafts size 10, 1 pair, $120 all-in and no recurring charges, and flags "for Saturday's race" as something CartMirror can't enforce. The shopper confirms the rules, and they are locked on the server.
  2. The shopper approves the exact cart (SKU, quantity, unit price).
  3. Line-item check at proposal, before any PayPal order exists: a wrong size, an upgrade or a membership line is blocked with a structured reason.
  4. A price rise triggers re-approval. A price that is under the limit but isn't the approved price needs the shopper's approval again.
  5. Line-item re-read before capture (PayPal Orders v2, Sandbox). Right before requesting capture, CartMirror GETs the live PayPal order and compares its items (SKU, quantity, unit price), total, currency, payee, approval reference, intent and purchase-unit count with the approval. Any difference prevents capture. The GET and the capture are two separate calls, so a short window remains between them.
  6. Agents connect over MCP. Your agent connects over MCP and gets three tools: lock_intent, propose_cart, request_payment. There is no capture tool. (MCP Python SDK 2.3.0; part of the project's main branch.)
  7. Idempotent capture with reconciliation (SIMULATED). Concurrent payment requests for one approval send a single capture. REAL SANDBOX: PayPal can report an order COMPLETED while its capture is DECLINED. We saw this on Sandbox with a Sandbox negative-testing card (order 0WW59160BF638884F, capture 42U99242M7599960W DECLINED; payload archive 20261103T062040Z-0WW-get, commit 7a00f17), and CartMirror counts only a COMPLETED capture as paid.
  8. Evidence. A drawer shows the hashes, every check and every PayPal call for the run. Raw Sandbox payloads for the canonical runs are archived with the project and available on request.

Evidence (labels: REAL SANDBOX = PayPal Sandbox API, test money · SIMULATED = no PayPal call · SYNTHETIC = offline evaluation)

PayPal Sandbox purges orders that are never captured. The "capture prevented" order ids below were purged (404 as of Nov 10; for the five purged ids 80L…, 8P4…, 22L…, 63J… and 57K…, read-only re-GETs are archived in payload set 20261110T051215Z-cited-id-sweep; the earlier-run ids 6TF… and 42K… were already 404 on Nov 9 and are labelled so where cited), so the evidence for each is its archived raw request/response payload (available on request). The source code is not published with this submission: commit hashes below refer to the project's private git history, and each payload set is named by its archive folder. The COMPLETED (captured) ids still resolve and can be checked live.

  • REAL SANDBOX, MCP route (scripted MCP client). CartMirror re-reads the live PayPal order right before capture and refuses if its items changed after approval. STAGED ATTACK: after the Sandbox buyer approved by clicking in the PayPal wallet (a real browser click; unlike our other runs, this order did not use the Sandbox API test card; per the run notes), a test-only tamper step PATCHed the approved order (80L98944MK702470M) from TR-PACE3-10 to TR-RIDGE2-10 via the Orders v2 API (PayPal HTTP status not recorded for this run). CartMirror's capture re-read the order, detected the mismatch with the approved snapshot, and refused to capture (CAPTURE_PREVENTED, 0 captures). Evidence: archived run log plus after-state (GET Nov 9: APPROVED, TR-RIDGE2-10, captures []) in archive 20261109T170935Z-post-approval-edit; the order was never captured and Sandbox has since purged it (404 as of Nov 10). Control 5XU48016N0993580Y / 58B026332L904971S COMPLETED and still resolves (approved via the Sandbox API with a test card). Earlier run 6TF12997WF643483H (purged, 404 since Nov 9): payload archive 20261103T052554Z-post-approval-edit. Not shown in our recorded demo.
  • REAL SANDBOX (staged attack, real Sandbox change). The same catch works from the web checkout (HTTP/UI route). Item swap: payload archive 20261109T172714Z-web-sku-swap, order 57K91511W3073712D (Nov 9, main 65420dd; labelled test-step PATCH TR-PACE3-10 → TR-RIDGE2-10 at $99; capture 409 CAPTURE_PREVENTED, $0 captured; approved via the Sandbox API with a test card; never captured, purged by Sandbox, 404 as of Nov 10). Amount edit: payload archive 20261109T171539Z-sandbox-e2e-order-edit, order 63J96469B97984024 (CAPTURE_PREVENTED; approved via the Sandbox API with a test card; never captured, purged by Sandbox, 404 as of Nov 10). Recorded take (Reel's final-v2 take, recorded at the submission pin 8ff656f, real clicks; the final-v7.1 recorded demo uses short clips of it, cropped so this order's id is not on screen, and shows the capture-prevented result as a drawn card of the saved payload): sku-swap prevented, payload archive final-v2/8P4413430D143010N, order 8P4413430D143010N (labelled test-step PATCH sku_swap; re-GET Nov 9 12:53 PM ET: APPROVED TR-RIDGE2-10 $99, captures []; never captured, purged by Sandbox, 404 as of Nov 10). Older web-route footage ids from Nov 1–3 were purged by Sandbox and have no archived payload, so they are not cited. In the recorded take the shopper approved the cart with a browser click; the test card was confirmed on the order via the Sandbox API (not a wallet click).
  • REAL SANDBOX (SYNTHETIC catalog). In our ablation runs (both guards ran against the PayPal Sandbox API; the amount-only guard is our own baseline code, not a vendor product; buyer approval via Sandbox API with a test card, not a wallet click), on the same proposals, an amount-only guard captured a size swap (order 19N895243L779525U, capture 7RJ771313X537581A) and a same-total product swap (order 87L04580CW243842P, capture 1CE31937VD1195834); CartMirror blocked both before PayPal and paid only the clean cart (41C48190CR209445H). Captured orders do not purge (re-GET Nov 9: COMPLETED); payload archive 20261103T052804Z-9.5-rerun (commit d817b33). A rerun on Nov 9 (commit 93ff13b) gave the same result: 9P494506FW747262E, 48D89534RM507563V; payload archive 20261109T170804Z-9.5-rerun. The recorded demo shows only the same-total swap (48D89534RM507563V / 2C500362R5972340S). See the table below.
  • REAL SANDBOX. The full happy path pays: a price rise triggers re-approval, then a $109 capture completes (order 9G869150KU433503G, capture 5KR37542SL509161B; earlier run: 2FK94572P62903929 / 85G47189WT573943J). In our recorded demo (final-v7.1: six ids on screen, three orders and their captures; all COMPLETED in Ledger's read-only sweep of PayPal on Nov 10, 1:28 AM ET, archive 20261110T062811Z-slide-id-sweep; the swapped order is shown only as a drawn card with no id): happy path 44N476938B798243L / 493468135B907631L COMPLETED $99, and after the price rise and re-approval 6SF16754HC6712443 / 4PN98916C4851773H COMPLETED $109 (pin 8ff656f take: browser approval, then test card via the Sandbox API; payload archive final-v2); and the amount-only baseline's wrong-shoe capture 48D89534RM507563V / 2C500362R5972340S COMPLETED $99 (ablation test cart approved via the Sandbox API with a test card, not a wallet click; payload archive 20261109T170804Z-9.5-rerun). The id table is kept in the recorded demo's archive (available on request).
  • REAL SANDBOX (scripted MCP client, one run each, opt-in path; buyer approval via Sandbox API (test card), not a wallet click; CartMirror approval card approved by the test script): CartMirror sits in front of PayPal's official MCP server (@paypal/mcp 1.8.1): pay_order runs only after the live order still matches what was approved. Control order 1FV03190X0874042K (capture 96M57027PA181591G COMPLETED); staged-attack order 22L50885WE065332X changed after approval to TR-RIDGE2-10 at a $99 test price (APPROVED, no capture, pay_order never called; never captured, purged by Sandbox, 404 as of Nov 10; evidence is the archived payload). Payloads: archive 20261109T170805Z-b6-toolkit (main 93ff13b). First run Nov 3 (attack 42K293329A744981T, purged by Sandbox, 404 since Nov 9): payload archive 20261103T060517Z-b6-toolkit (run at 2af10e6; payload archived in 93ff13b). Baseline without CartMirror: PayPal's official Toolkit pay_order, called directly on an order edited the same way, captured it (9YF60083YC460523K, capture 7DY64026A34133246 COMPLETED, TR-RIDGE2-10; scripted call, same approval method; re-GET Nov 9: COMPLETED; payload archive 20261109T174555Z-b6-baseline). Not shown in our recorded demo.
  • REAL (MCP SDK 2.3.0 handshake, no PayPal call). Your agent connects over MCP and gets three tools: lock_intent, propose_cart, request_payment. There is no capture tool.
  • SIMULATED. Concurrent payment requests for one approval send a single capture: idempotent capture with reconciliation.
  • SIMULATED (FakePayPal, Nov 1 run, before the rename). 50 of 50 adversarial probes pass (results file 20261101T160803Z; commit 9dda37a, dirty tree).
  • Code + tests (no live run). Webhooks fail closed: one PayPal can't verify is refused with a 400 and not recorded (main 643025b). Live webhook verification is not claimed.
  • SIMULATED (LLM agent: opt-in path on main, off by default, not the default checkout; described in this text only; not shown in our recorded demo). Agent loop, N=30 per scenario at code pin 8ff656f (clean tree, dirty=false), batch ae-20261109T125511, SIMULATED PayPal: 5 of 6 scenarios 30/30 and membership 29/30 (a missed payment, not unsafe); 0 orders outside the buyer's mandate; prompt injection followed 0/30. Source: our agent-evaluation write-up (available on request). One REAL PayPal Sandbox agent run: order 6UG26118FK469694R, captured as 9KJ540049U2171934 (one purchase), at commit 93f5d15; redacted readback at a5574c9. Between 93f5d15 and the pin, agent, guard, policy, quote gate, PayPal client and approval route code are byte-identical. The pin differs in the app's request-handling module (/confirm: agent-credential and cross-origin refusal, the product model taken from the server's draft, and the size-system/audience fill-or-422 rule; this run's /confirm predates all three) and in the LLM-extraction module (the default model setting, plus one unused constant). Payload: archive 20261109T180200Z-agent-run-6UG26118FK469694R. NOT RUN: a batch with a second model at the pin (HTTP 429 model cooldown, then the gateway became unreachable) and a fresh REAL SANDBOX agent run at the pin (gateway unreachable). Earlier pre-pin batches with the same model the same day scored 29/30 in both membership and prompt_injection (not cited). Historical: a pre-merge batch with another model (ae-20261103T004822, 3d6d5cd) was 30/30 in all 6; on Nov 1, a third model succeeded in 15 of 180 runs before the prompt fix (86 of the 165 failed runs were gateway 503 errors, not model behavior); a later batch with that third model and the fixed prompt (ae-20261109T122502, c752c51, dirty tree, not the pin) completed 179 of 180 (the other was a gateway 429) with 0 out-of-mandate orders, and is not cited as a pin result.
  • SYNTHETIC (LLM matcher, offline; matcher on an evaluation branch, not shipped). Alone, the AI matcher would have accepted 12 of 47 bad listings; behind CartMirror's deterministic gate, 0 of 47. The AI advises; the guard decides. With the AI's advice, block reasons named the problem in 22/22 cases vs 16/22 for rules alone. SYNTHETIC · offline eval: the AI did not beat the rules (rules 58% pre-registered, 92% tuned after the fact, vs 50%). The AI advises; the guard decides.

Our ablation runs: same carts, two guards (REAL SANDBOX, SYNTHETIC catalog). Both guards' orders and captures are real PayPal Sandbox calls with test money (payloads below). Our baseline "amount-only guard" GETs the live order and allows capture when the total equals the approved $99, the currency and approval reference match, and the order is APPROVED. We built it for this test; it is not any vendor's product. The shopper approved a size 10 Pace 3 for $99, with a $120 all-in limit (SYNTHETIC demo request).

Cart the agent proposed Amount-only guard CartMirror
Size 10 Pace 3, $99 (correct) Paid (order 72A59469Y3742813U, capture 95241593GT8568706) Paid (order 41C48190CR209445H, capture 02Y127791U206674T)
Size 9.5 Pace 3 (SKU TR-PACE3-9.5), same $99 Paid the wrong shoe (order 19N895243L779525U, capture 7RJ771313X537581A) Blocked: size mismatch, no PayPal call
Correct shoe + $4.99/month club Blocked (total $103.99) Blocked: recurring charge
Correct shoe at $109 Blocked (total $109) Blocked: price changed
Different shoe (Ridge 2) at the same $99 (test price) Paid the wrong shoe (order 87L04580CW243842P, capture 1CE31937VD1195834) Blocked: product mismatch, no PayPal call

Run on Nov 3, 2026 (12:28 AM ET, commit d817b33; payload archive 20261103T052804Z-9.5-rerun). A first run on Nov 1 and a rerun on Nov 9 (commit 93ff13b, payload archive 20261109T170804Z-9.5-rerun; wrong-shoe orders 9P494506FW747262E / 48D89534RM507563V, captures 2WK82770U93619930 / 2C500362R5972340S) gave the same result. Buyer approval via Sandbox API (test card). SYNTHETIC demo catalog, Sandbox test money.

How it compares. The first two columns come from our reading of public code (paypal/agent-toolkit @ a3aa963; a public hackathon repo @ 8d7905f). We did not run that hackathon repo. We did run the raw Toolkit once: PayPal's official Toolkit pay_order captured the edited order when called directly (REAL SANDBOX: 9YF60083YC460523K, payload archive 20261109T174555Z-b6-baseline). With CartMirror in front, pay_order was never called (42K293329A744981T, payload archive 20261103T060517Z-b6-toolkit; rerun 22L50885WE065332X, payload archive 20261109T170805Z-b6-toolkit; both never captured and purged by Sandbox; payloads archived). Scripted calls, not an agent: whether an agent calls pay_order depends on its prompt.

What is checked before capture (code read) Source
PayPal Agent Toolkit pay_order Capture is governed by the agent's instructions; on/off allowlist per action. CartMirror gates pay_order behind a line-item re-read (REAL SANDBOX; buyer approval via Sandbox API (test card), not a wallet click; CartMirror approval card approved by the test script). paypal/agent-toolkit @ a3aa963 · we read the code. Gating runs: 2af10e6 (orders 5S5091320M0363113 / 42K293329A744981T, payload archive 20261103T060517Z-b6-toolkit) and 93ff13b (1FV03190X0874042K / 22L50885WE065332X, payload archive 20261109T170805Z-b6-toolkit; the attack orders 42K… and 22L… were never captured and are purged by Sandbox, payloads archived); raw-Toolkit baseline 9YF60083YC460523K (payload archive 20261109T174555Z-b6-baseline)
An amount-only pre-capture guard (pattern in a public hackathon repo) Reference id, total, currency, APPROVED status from a live GET. A same-total item swap is not compared. @ 8d7905f · we read the code; not run

Honest overlap: other projects also re-read the live order, handle idempotency, expose a guard over MCP, or use a stop-explain-correct flow, and another team targets the same gap. What we add is what gets compared: variant-level cart meaning bound to the approval, plus a line-item comparison against the live PayPal order right before capture. Emerging agent-payment mandate standards also describe line-item approvals; CartMirror is an enforcement point for that idea on PayPal Orders v2, not a new standard.

What "size 10" means here: CartMirror checks the merchant's declared SKU attributes and the items on the live PayPal order. It does not check the physical item shipped.

Known limitation (UI wording): the kids-sizing, named-shipping-method and child-purchase items appear in the UI under the header "Not enforced: CartMirror cannot check this condition", although CartMirror does act on them (it asks the shopper to confirm and never pays automatically). The UI is frozen for the submission, so the header stays.

Known limitation (cross-site requests): there is no CSRF token (UI frozen). The main cross-site defence is the SameSite=Lax session cookie, so a cross-site browser POST does not carry the shopper's session. On top of that, /confirm and the MCP approval routes (/approve, /decline) check the request Origin or Referer and refuse a foreign one with 403 CROSS_ORIGIN (covered by an automated test). The other checkout steps do not check Origin, and a request with no Origin or Referer, such as a script, is accepted. Our reviewer's probe (Sandbox order 0EH005471S403271B) rated this LOW for Sandbox. The full limitations list is available on request.

How we built it

  • PayPal REST API, Orders v2, on Sandbox. Create order → confirm-payment-source (public Sandbox test card) or buyer approval → GET order (live line-item re-read) → capture → GET capture. PayPal-Request-Id makes create and capture idempotent. The client refuses any host other than api-m.sandbox.paypal.com.
  • MCP server (Python, MCP Python SDK 2.3.0): three tools, no capture tool. The shopper approves an MCP payment request in their own browser, on an approval card at /?mcp_decision=<decision_id> that uses the same approval route; the agent has no approve tool. request_payment does not print the link yet.
  • AI in the product: one LLM call drafts the constraints, through any OpenAI-compatible endpoint (LLM_BASE_URL, LLM_API_KEY, LLM_MODEL); the default model is set in DEFAULT_MODEL (changed Nov 9 after the previous default hit a quota limit on our gateway). If the call fails, the page says so and falls back to a deterministic rule parser. The AI drafts the rules; the shopper confirms them; deterministic code enforces them. The model never decides or makes a payment.
  • Backend: Python 3 standard library (http.server, sqlite3, urllib), SQLite for approvals, payment operations and receipts.
  • Frontend: one HTML page with plain JavaScript and CSS. It works at 390 px.
  • Video and app code: 8ff656f (the submission pin; later commits change only docs (including the setup instructions), evidence and comments in the two Render files, and the app code (the cartmirror package) is byte-identical to the pin). The recorded demo (2:24; a video file, not hosted publicly) is Reel's final cut (presentation style: slides plus short real-UI clips from the pin take; the ids on screen and their payloads are listed in an id log kept in the demo's archive).
  • Live AI in the recorded demo: the take ran at the pin with LLM_MODEL unset, so the default model drafted the rules live; in the "Step 1 · You approve" clip the UI shows "Extraction: live AI" with the model's name (a saved frame of that moment is kept in the demo's archive).
  • Tests: 565 at the pin 8ff656f: Ran 565, OK (skipped=9) without the optional MCP SDK; Ran 565, OK (skipped=1) with it (documented test command, clean copy, no keys; Juno, Nov 9, 12:50 PM ET).
  • No secrets in the source code or its git history.
  • Packaging: Dockerfile and Render blueprints. No hosted URL.

AI tools used

  • Demo video narration: AI voice via the free edge-tts text-to-speech tool, English; the Grok Bot text-to-speech service used in the earlier cuts was unreachable on Nov 10. Delivered as a separate audio file (WAV and MP3, 2:24) with a captions file (SRT), so a human can re-voice it later. The UI clips are from the pin 8ff656f take. Labelled honestly: not a human narrator. Nothing paid.
  • Demo stills / gallery: real screens of the local app on PayPal Sandbox (Iris gallery 00–07 rebuilt from FINAL UI lock 8fa96df, credited to Iris; Reel rehearsal9 stills 01–23 / 30-mcp-* on b4dfcc5).

In the product (runtime): an LLM via an OpenAI-compatible API, for constraint drafting. The default model is set by the DEFAULT_MODEL setting in the app's LLM-extraction module and can be changed with LLM_MODEL; a live call returned a correct draft in our Nov 9 review probe.

In evaluation (not the default checkout): several LLMs through the same OpenAI-compatible gateway: one for the agent evaluation of the merged code (and the cited REAL SANDBOX agent run), one for the offline matcher evaluation and the pre-merge agent batch (now retired), and one for a second agent batch (pre-pin, dirty tree; not a pin result). Exact model ids are recorded in the evaluation result files (available on request).

In development:

  • Grok Bot (AI agents) wrote most of the code, tests, docs, video script and this text under our direction. We checked them against the code and the test results.
  • Multiple LLMs through an OpenAI-compatible gateway, for drafting and review.
  • An AI image model: illustrative cover and end-card art in earlier recorded cuts and covers kept in the project archive (labelled on the image as AI-generated and not the product UI); the final-v7.1 recorded demo has no AI-generated imagery (no image model was used for its slides); not in the product.

Challenges we ran into

  • Checking the live order, not our copy. A cart can match at create time and still change before capture. We GET the live PayPal order right before requesting capture and compare its line items with the approval.
  • Retries (SIMULATED). Idempotent capture with reconciliation: concurrent payment requests for one approval send a single capture.
  • Honest payment states (REAL SANDBOX). PayPal can report an order COMPLETED while its capture is DECLINED. We saw this on Sandbox with a Sandbox negative-testing card (archive 20261103T062040Z-0WW-get, commit 7a00f17), and CartMirror counts only a COMPLETED capture as paid.
  • Unverifiable wishes. The AI picks up conditions nobody can check. The UI makes the shopper remove them explicitly.
  • Keeping the AI advisory. SYNTHETIC · offline eval: the AI did not beat the rules. The AI advises; the guard decides.

Accomplishments that we're proud of

  • The model is not in the payment path. AI drafts, the shopper confirms, and code checks the line items at proposal and again before capture.
  • PayPal Sandbox evidence with archived payloads: a post-approval item swap (a labelled test step) stopped before capture over MCP (scripted MCP client, not an LLM) and from the web checkout, a paid happy path ($109 COMPLETED), and ablation runs where an amount-only baseline captured 2 mismatched carts and CartMirror captured 0.

Agent-loop eval (SIMULATED, Devpost text only). Opt-in path on main, off by default; one LLM at the pin 8ff656f: 30/30 in 5 of 6 scenarios and 29/30 in membership, with 0 out-of-mandate orders, 0 out-of-mandate ALLOW verdicts and 0 errors in every scenario (see Evidence). Not shown in our recorded demo.

What we learned

  • Amount checks and approval buttons answer "how much" and "did they click". Neither answers "is this what they asked for".
  • "Order COMPLETED" is not "paid". The UI has to say what actually happened.
  • An AI is useful for explaining a block, not for deciding one.

What's next for CartMirror

  • request_payment returning the approval-card link, and a live LLM agent as the default MCP client. Today the guard's MCP Sandbox evidence uses a scripted client; the cited REAL SANDBOX agent run is order 6UG26118FK469694R, capture 9KJ540049U2171934 (one purchase, COMPLETED), at commit 93f5d15, not at the pin.
  • Make the agent loop the default only after a held-out evaluation, and merge the matcher after the same evaluation.
  • Verify the PayPal-account (wallet) path, pending captures and refunds, and webhook verification on a hosted HTTPS URL.
  • Talk to developers building agents on PayPal.

Built during the hackathon

Built within the Submission Period (Oct 1 – Nov 12, 2026). PayPal Sandbox only, with test money and the public Sandbox test card. Demo catalog: SYNTHETIC (invented store, products, prices and descriptions). The source code is not published with this submission; setup instructions, raw payloads and the demo recording are available on request.

Built With

Share this project:

Updates

Submission history