Talivia Docs
Talivia Docs
HomeDashboard
IntroductionInstallationTeamGetting updates
Stripe
Yolfi
Dodo Payments
LemonSqueezy
LemonSqueezy Checkout LinksLemonSqueezy Checkout APILemonSqueezy Return URL FallbackLemonSqueezy Subscriptions and RenewalsTest and troubleshoot LemonSqueezy
Polar
Manual Payment APITesting payment integrations
Integrations
llms.txtllms-full.txt
RevenueLemonSqueezy

LemonSqueezy Checkout API

Pass the Talivia session when your backend creates a custom LemonSqueezy checkout.

View Markdown

Use this flow when your backend calls POST /v1/checkouts and returns the generated checkout URL to the browser.

Send the session to your backend

Read the current session on the tracked page and include it in your own checkout request:

Start checkout from the browser
const sessionId = window.talivia.getSessionId();

const response = await fetch('/api/create-checkout', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ sessionId }),
});

const { checkoutUrl } = await response.json();
window.location.assign(checkoutUrl);

Treat the session ID only as attribution context. Validate the customer, product, price, and authorization independently on your backend.

Add custom checkout data

Merge the received value into attributes.checkout_data.custom in the LemonSqueezy request:

Create the LemonSqueezy checkout
const checkout = await fetch('https://api.lemonsqueezy.com/v1/checkouts', {
  method: 'POST',
  headers: {
    Accept: 'application/vnd.api+json',
    'Content-Type': 'application/vnd.api+json',
    Authorization: `Bearer ${process.env.LEMONSQUEEZY_API_KEY}`,
  },
  body: JSON.stringify({
    data: {
      type: 'checkouts',
      attributes: {
        checkout_data: {
          custom: {
            talivia_session_id: sessionId,
          },
        },
      },
      relationships: {
        store: { data: { type: 'stores', id: process.env.LEMONSQUEEZY_STORE_ID } },
        variant: { data: { type: 'variants', id: variantId } },
      },
    },
  }),
}).then(response => response.json());

return Response.json({ checkoutUrl: checkout.data.attributes.url });

LemonSqueezy copies custom checkout data to meta.custom_data in the signed webhook. This works for hosted custom checkouts and programmatically opened overlays.

Keep the LemonSqueezy API key on the server and preserve any other custom fields your application already sends.

LemonSqueezy Checkout Links

Attribute a hosted LemonSqueezy checkout or standard overlay link automatically.

LemonSqueezy Return URL Fallback

Match an order through the tracked return page when checkout metadata is unavailable.