Checkout API, links and embed

Start a checkout from your server, a link or a button on your own website.

All three open the same hosted checkout. Prices and totals are always worked out by PaidGoods, never taken from the caller.

Links can prefill cart lines, the buyer's email, a coupon, an affiliate code, UTM fields, the currency (?currency=EUR, for currencies you sell in) and a test-mode token. The storefront's /checkout-link route turns the link's parameters into a hosted checkout URL.

Developers → Embeds & links builds links and buttons for you. In Sales → Invoices → ⋯ → Create a checkout link you can build a link with your own custom items and copy it.

Embed script

Add the script from your store's address, /embed/v1.js or /embed/v3.js. It opens checkout in a popup: full screen on phones, a centred sheet on larger screens.

<script src="https://yourstore.paidgoods.com/embed/v3.js"></script>
<button onclick="StoreEmbed.open({ cart: [{ productId: 'prod_id', variantId: 'variant_id', quantity: 1 }] })">
  Buy now
</button>

StoreEmbed.open() takes cart, email, coupon, affiliate, metadata and redirectUrl. The script also has close, on, off and version.

Buttons can use attributes instead of code: data-dc-cart or data-dc-variant, and data-dc-test-token for test links (or testToken in open()).

  • Events are sent as dc:*.
  • The script records UTM parameters, the referrer, the affiliate code and your metadata with the checkout.
  • The support-ticket card after purchase is hidden in the popup unless you pass ticketPanel: true. A checkout opened in a new tab always shows it.

The same script answers to SellAuth's sellAuth global and data-sellauth-* attributes, so a SellAuth embed keeps working. See SellAuth-format API.

React storefront starter

Download the React storefront starter to build your own storefront on top of hosted checkout. It loads your public catalogue and sends the chosen variant and quantity to checkout, which collects the buyer's details, works out the price and takes payment. Copy .env.example to .env.local, set your store ID and hosted checkout URL, then run pnpm install && pnpm build. It needs no API key.

Checkout API

POST /v1/stores/{storeId}/checkouts, from your server with an API key that has invoices:write.

FieldMeaning
linesCatalogue items: variantId, qty, and optionally customFields, addonIds, subscribe.
customItemsItems you price yourself: name, unitPriceMinor (whole minor units, 1250 for 12.50) and qty. One can cost 0, but a checkout of only custom items must cost more than 0.
currencyRequired when every item is custom. With products, the products set the currency and a different one is refused.
email, paymentMethodIdWith both, the invoice is created at once.
couponCode, affiliateCode, newsletter, attribution, returnUrlPrefills.
metadataUp to 10 string values, kept with the invoice.
billingAddress, shippingAddress, discordUserIdBuyer details.
buyerip, country, userAgent, asn when you call on the buyer's behalf. Anti-fraud and country rules use these.

The response type tells you what to do next:

  • redirect: send the buyer to url, the payment provider's page.
  • invoice: send the buyer to url, the invoice page.
  • session: url is a hosted checkout link for the buyer to finish. Items, prices and metadata stay on our server; the link carries only a random token, so the buyer can't change a price. It works for 24 hours (expiresAt) and makes one invoice. A test-mode key returns a test link.

Errors

  • 422 when the body doesn't add up (for example a currency that doesn't match the products, or an empty custom-only checkout).
  • 403 with "code": "missing_scope" when the key lacks invoices:write. See API keys.
  • 429 when you send too many. See Rate limits.

Buyers refused by anti-fraud rules get no invoice.

On this page