Home / patterns

Checkout prices, totals and discounts taken from the browser

A developer's desk at night with a monitor showing an online checkout page and order total above an open browser developer tools panel, next to a second screen of code
Quick answer: AI-generated checkouts often send the cart from the browser straight to the payment step: item prices, quantities, the total and the coupon discount all come from client code. Anyone can edit that request in dev tools and pay $1 for a $100 order, stack a coupon that should be blocked, or set a negative quantity. Hiding a field or disabling a button doesn't help, because the server never re-checks.

Last updated November 13, 2026

Steps

  1. Test it: add an item, open dev tools, and replay the checkout request with a lower price, a changed total, a quantity of 0 or -1, or a coupon that shouldn't apply. If the payment page or order shows your edited numbers, the server trusts the browser.
  2. Send only product IDs, quantities and coupon codes from the browser. Never send prices, totals or discount amounts.
  3. On the server, look up each price from your database or use predefined Stripe Price IDs, then calculate the total yourself.
  4. Validate quantities (whole numbers, at least 1, within stock and per-order limits) and check every coupon rule on the server: expiry, minimum spend, eligible items and one use per customer.
  5. Create the Stripe Checkout Session on the server. Only use inline price_data for truly dynamic prices, and compute those on the server too.
  6. Fulfill orders from a verified Stripe webhook, not the success page. Retrieve the session with line items, check payment_status, and make fulfillment safe to run twice.
  7. Compare what was paid with what you expected before shipping or granting access, and alert on mismatches.

Why it matters

MITRE tracks this as CWE-602 (Client-Side Enforcement of Server-Side Security), updated in CWE 5.0 on October 28, 2026. It describes software that relies on the client to enforce protections, which attackers bypass by changing the client or sending requests directly. MITRE's mitigation is to repeat every client-side check on the server, and it lists CVE-2024-50653 as an example, where a coupon-use limit was only enforced in the front end. It maps to OWASP Top 10 2025 A06 Insecure Design. Stripe's own quickstart creates Checkout Sessions on the server and says you'll typically use a predefined Price ID, with price_data for dynamic pricing. Stripe's fulfillment guide says webhooks are required for fulfillment, because customers aren't guaranteed to reach your success page, and that fulfillment should check payment_status and handle being called more than once.

Sources

MITRE CWE-602: Client-Side Enforcement of Server-Side Security — https://cwe.mitre.org/data/definitions/602.html

Stripe Docs: Payments quickstart (Checkout Sessions) — https://docs.stripe.com/payments/quickstart

Stripe Docs: Fulfill orders — https://docs.stripe.com/checkout/fulfillment

Checked at the source on October 31, 2026.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.