merce.STACK
merce.STACK
Skip to content
PricingWhat's new
Log inGet started
{}Developers
GuidesAPI referenceChangelogGet API keys →
  • Get started

    • Quickstart
    • Keys & authentication
  • Storefront

    • Products & catalog
    • Carts
    • Checkout & payment
    • Customer accounts
    • Digital products
    • Without a build step
    • Bookings
    • Courses
    • Drop-in components
  • Server API

    • Server API
    • Customers
    • Payment links & transactions
    • Balance & payouts
    • Classes & students
    • Node SDK
  • Email API

    • Email API
    • Sending email
    • Delivery events
  • Events & errors

    • Webhooks
    • Errors
  • Reference

    • API reference
    • Changelog

Storefront

Checkout & payment

One call. Revalidated server-side, idempotent, stock held safely.

TypeScript
const result = await mercestack.checkout({
  email: "[email protected]",
});

result.order.number;  // "ORD-000042"
result.paymentLink;   // hosted payment page slug, or null
result.paid;          // true when gift cards covered it
result.library;       // { accessToken, count } when digital goods were bought

Or hand the whole thing over and let us take the payment:

TypeScript
await mercestack.openCheckout({
  email,
  returnUrl: "https://shop.example.com/thank-you",
});

What happens on our side

  1. 1.Every product is rechecked as still published and every variant as still active.
  2. 2.Stock is reserved under a row lock, spread across warehouses if one cannot cover it. Two shoppers racing for the last unit: exactly one gets it.
  3. 3.The discount is re-resolved and its usage count incremented under lock, so a code limited to 100 uses is used 100 times, not 103.
  4. 4.Gift cards are charged, in the same transaction as the order.
  5. 5.The order is written with a snapshot of every line — name, SKU, price — so a price change tomorrow does not rewrite yesterday's order.
  6. 6.A payment intent is created, unless there is nothing left to pay.

Checkout is idempotent

A double-tapped Pay button and a retried request both get the order that already exists. Neither creates a second one, and neither charges twice.

An unpaid order holds its stock for one hour. If the customer never pays, the reservation is released automatically and the stock goes back on sale — a closed tab does not hold the last unit all day.

Never treat a redirect back as proof of payment

A query parameter on your success page is set by the browser, and a browser is not a witness. Wait for the order.paid webhook, or read the order back from the API. This is the single most common way an online shop gives away stock.

← PreviousCartsNext →Customer accounts
Create a workspaceTalk to usPricing

One workspace for everything your business runs on — your team, customers, store, marketing and payouts in one place.

Get started

Product

  • All products
  • Pricing
  • What's new
  • Security

Resources

  • Documentation
  • Guides
  • Use cases
  • Blog
  • Get support

Company

  • About
  • Careers
  • Contact us
  • Talk to the team

Legal

  • Privacy
  • Terms
  • Cookie policy
  • GDPR
  • Report a vulnerability

© 2026 Mercestack. All rights reserved.

Mercestack StructureOS

mercestack