Lemon Squeezy Webhook Arrives but No User Is Linked? A custom_data Checklist
A customer pays, Lemon Squeezy shows the order, and your database stays empty, or it has a subscription row that belongs to nobody. The signature check passes (if it doesn't, fix that first: Lemon Squeezy webhook "invalid signature" checklist). The problem is one step later: either the request never reaches your handler, or it arrives without anything that tells you which of your users bought. This checklist covers both, in the order that's quickest to rule out.
Quick reference
| What you see | Most likely cause | Check |
|---|---|---|
| Webhook log shows 404 or 405 | URL path doesn't match your route | 2 |
| Webhook log shows 419 (Laravel) | CSRF protection on the webhook route | 2 |
| Your server logs a GET with an empty body | A redirect in front of the route | 2 |
| Nothing in the log for that purchase | Event not selected, or test/live mismatch | 3 |
Payload has no meta.custom_data |
Checkout started from a link without custom data | 4 |
custom_data is there but the lookup fails |
Wrong place or wrong type ("123" vs 123) |
5 |
| Renewal events can't find a user | Invoice events carry a subscription id, not your user | 5 |
| Laravel: "Webhook skipped due to invalid custom data." | Purchase didn't start from the package's checkout | 8 |
☐ 1. Read the webhook log before changing code
Lemon Squeezy logs recent webhooks on the webhooks settings page. The docs say you can see "which events have been sent, the full payloads of each request and also resend webhooks". Open the delivery for the purchase you're debugging and note two things:
- The response your server returned. A 200 means your handler ran and accepted it; anything else points to check 2.
- Whether
meta.custom_datais in the payload. If it isn't there, no handler code can find it (check 4).
Lemon Squeezy needs a 200 back. Any other status is retried "up to three more times using an exponential backoff strategy (e.g. 5 secs, 25 secs, 125 secs)", and then the delivery counts as failed. Fix the cause, then resend from the log.
Sources: Webhooks, Webhook Requests.
☐ 2. Make sure the POST reaches your handler
404 or 405. The callback URL must match a route that accepts POST, character for character. With the Lemon Squeezy for Laravel package, the route ships with the package and its README says the path "is /lemon-squeezy/webhook by default". php artisan route:list shows whether it's registered in your app.
419 on Laravel. Laravel turns a CSRF token mismatch into an HTTP 419 response, and Lemon Squeezy can't send a CSRF token. Laravel's CSRF docs describe excluding webhook routes for exactly this reason. On Laravel 11 and later:
// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
$middleware->validateCsrfTokens(except: [
'lemon-squeezy/*', // or the path of your own webhook route
]);
})
On older versions, add the same path to $except in App\Http\Middleware\VerifyCsrfToken.
A GET with an empty body. This is a redirect. HTTP allows a client that follows a 301 or 302 to switch the request from POST to GET: RFC 9110 says "For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request." The body is lost on the way. Common sources:
- A trailing-slash rule. Django's
APPEND_SLASH(on by default) redirects/webhookto/webhook/when only the slashed pattern exists, and Django's docs warn that "the redirect may cause any data submitted in a POST request to be lost". One Stack Overflow question about Lemon Squeezy webhooks arriving as GET was solved exactly this way. http://tohttps://, orexample.comtowww.example.com.
Fix: enter the final URL in the webhook settings, with the exact scheme, host and trailing slash your route uses, so nothing has to redirect.
Note: Lemon Squeezy's docs don't say how its sender treats redirects. The fix above avoids the question.
Sources: Lemon Squeezy for Laravel README, Laravel CSRF Protection, Laravel exception handler (419 mapping), RFC 9110 §15.4, Django APPEND_SLASH.
☐ 3. Is the webhook subscribed to the right events and mode?
- A webhook only fires for the events you selected when you created it. For a subscription app, Lemon Squeezy's recommended minimum is
subscription_created,subscription_payment_successandsubscription_updated; for one-time products,order_created. If you sell license keys through Lemon Squeezy itself,license_key_createdis a separate event. subscription_createdalways comes with anorder_created, and the docs callsubscription_updateda "catch-all" for the latest subscription data. If you only handle one subscription event, handle that one.- Test-mode and live-mode webhooks are separate: "a test mode webhook will only be triggered for test mode data and vice versa".
Sources: Event Types, Simulate Webhook Events.
☐ 4. Is meta.custom_data in the payload at all?
Lemon Squeezy doesn't know who your users are. It only sends back what you passed into the checkout. There are two ways to pass it, and both end up in meta.custom_data:
Checkout link with query parameters:
https://[STORE].lemonsqueezy.com/checkout/buy/[VARIANT_ID]?checkout[custom][user_id]=123
Checkout created through the API, with checkout_data.custom:
const res = 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: { email: user.email, custom: { user_id: String(user.id) } },
},
relationships: {
store: { data: { type: "stores", id: STORE_ID } },
variant: { data: { type: "variants", id: VARIANT_ID } },
},
},
}),
});
const checkoutUrl = (await res.json()).data.attributes.url;
So when custom_data is missing, ask how that particular buyer reached the checkout:
- A plain share link copied from the dashboard, a "Buy" button pasted into a landing page, or your Lemon Squeezy storefront. None of these carry your user id unless you added
checkout[custom][...]yourself. - A cart URL. When a buyer opens a
/checkout/buy/link, it turns into a/checkout/?cart=URL that is "unique to that customer and single-use only". Always share the original/checkout/buy/link. - An API checkout created without
custom, for example a code path that builds the checkout before the user has signed in.
Note: one comment in lmsqueezy/laravel#57 tentatively traces purchases without the expected custom data to Lemon Squeezy's recovered-cart emails, and suspects the default storefront as well. The docs don't confirm this either way. If you rely on custom data, check those payloads in the log.
Sources: Passing Custom Data, Taking Payments, Create a Checkout.
☐ 5. Read it from the right place, as the right type
- Place. It's
meta.custom_data.user_id, notdata.attributes. - Which events. The docs say
custom_datais included in "all Order, Subscription and License key related events". - Type. The docs show the same value as a number in one example (
"user_id": 123) and as a string in another ("user_id": "123"). Don't depend on either: convert to a string before you look the user up, and if your primary keys are integers, parse and validate it. - Renewals and payment events.
subscription_payment_success,_failed,_recoveredand_refundedsend a subscription invoice object. Its attributes includesubscription_idandcustomer_id. Link those events through the subscription you stored atsubscription_created, not throughcustom_data.
Note: the docs don't say explicitly whether invoice events include custom_data. Linking through subscription_id works either way.
Sources: Webhook Requests, Event Types, The Subscription Invoice Object.
☐ 6. Have a fallback when there's no user id
Some purchases will arrive without your id (check 4). Don't drop them, and don't return an error that makes Lemon Squeezy retry a payload that will never change. Save the record unlinked and match it later.
Order and subscription objects both include user_email and customer_id. Lemon Squeezy's guide recommends storing the subscription id, order_id, customer_id, product_id and variant_id.
type LsEvent = {
meta: { event_name: string; custom_data?: Record<string, unknown> };
data: { type: string; id: string; attributes: Record<string, any> };
};
// Returns the local user for an order or subscription event, or null.
async function resolveUser(evt: LsEvent, db: Db) {
const raw = evt.meta.custom_data?.user_id;
if (raw !== undefined && raw !== null && raw !== "") {
const user = await db.findUserById(String(raw));
if (user) return user;
}
const email = String(evt.data.attributes.user_email ?? "").trim().toLowerCase();
if (!email) return null;
const user = await db.findUserByEmail(email);
// Only trust an email match if your app has verified that this user owns the address.
return user?.emailVerified ? user : null;
}
// In the handler, after the signature check:
const user = await resolveUser(evt, db);
await db.upsertSubscription({
lsId: evt.data.id,
userId: user?.id ?? null, // null = unlinked; keep it
customerEmail: evt.data.attributes.user_email,
customerId: String(evt.data.attributes.customer_id),
status: evt.data.attributes.status,
});
return new Response("OK", { status: 200 });
// Later, after sign-in (not at sign-up), once the email is verified:
async function attachUnlinked(user: { id: string; email: string; emailVerified: boolean }, db: Db) {
if (!user.emailVerified) return 0;
return db.linkSubscriptionsByEmail(user.email.trim().toLowerCase(), user.id); // only rows with userId = null
}
Then, when someone signs in with that email and your app has verified they own it, attach any unlinked subscriptions to them.
- Buyers sometimes pay with a different email from the one they signed up with. Keep a way to link by hand, for example an admin action or a "claim with order number" form.
- Normalise case on both sides before you compare emails. Note: whether your database compares strings case-sensitively depends on the database and collation.
☐ 7. Don't treat a user id from a public link as proof
The signature proves the request came from Lemon Squeezy. It doesn't prove who the buyer is in your app. Whoever opens a checkout link can edit its query string first, checkout[custom][user_id] included.
- For signed-in users, create the checkout on your server through the API, using the id from the session (check 4). The browser never chooses the id.
- If you do use links, treat the id as a hint. Confirm that the user exists, and consider requiring the purchase email to match before you grant anything sensitive.
☐ 8. Laravel package: "Webhook skipped due to invalid custom data."
The official Lemon Squeezy for Laravel package links purchases through two custom-data keys it sets itself, billable_id and billable_type.
- Its README lists
billable_id,billable_typeandsubscription_typeas reserved keywords. Passing them yourself throws an exception. - In its webhook controller, an
order_created,order_refunded,subscription_createdorlicense_key_createdevent without both keys throwsInvalidCustomPayload. In issues #57 and #83 a contributor explains that purchases must start from the package (for example$user->checkout('variant-id')or$user->subscribe(...)) for those keys to be present. A share link or a hand-made API checkout won't have them. - Older versions answered with the text "Webhook skipped due to invalid custom data." In the current source the same case returns HTTP 400, so Lemon Squeezy will retry it and then mark it failed.
- Checkout for guests without a user (issue #86) is an open feature request. Until then, create the user first and start the checkout from the package, or handle those events yourself by listening to the package's
WebhookReceivedevent, which it dispatches before its own handlers run.
Sources: Lemon Squeezy for Laravel README, WebhookController.php, issue #57, issue #83, issue #86.
☐ 9. Don't rely only on the browser success event
With the checkout overlay, Lemon.js fires Checkout.Success and passes it an Order object. That's useful for showing a thank-you state straight away. But the event runs in the buyer's browser, so if the tab closes, your code never sees it. Lemon Squeezy's guide suggests storing subscription data from the subscription_created and subscription_updated webhooks. Use the browser event for the UI, and the webhook as the record.
Sources: Handling Events with Lemon.js, Taking Payments.
Symptom table
| Symptom | Likely cause | Check |
|---|---|---|
| Order visible in Lemon Squeezy, database empty | Handler not reached (404/419/redirect) | 1, 2 |
| Some purchases linked, others not | Those buyers came through a link without custom data | 4, 6 |
| Every purchase unlinked after moving to a new checkout button | New button is a plain share link | 4 |
Lookup fails though user_id is in the log |
Read from data.attributes, or number/string mismatch |
5 |
| Renewals fail to update | Invoice events handled like subscription events | 5 |
| Laravel returns 400 to every share-link purchase | Package needs billable_id/billable_type |
8 |
| Paid users see "no subscription" after closing the tab | Relying on Checkout.Success only |
9 |
If you're starting a Lemon Squeezy subscription app
Rindstack is a Next.js 15 starter for selling licensed software through Lemon Squeezy, with this linking already wired up. Its product page lists:
- Hosted checkout created through the API with your user id attached.
- A webhook handler that verifies
X-Signatureover the raw body, skips duplicate deliveries, and doesn't let late out-of-order events overwrite newer state. - One license key per subscription, issued by the webhook, with device limits per plan (3 / 10 by default), verify/deactivate APIs and a grace period for cancelled subscriptions.
- A customer-portal "Manage billing" link, and a Chrome extension (MV3) example that unlocks with the key.
- English, Chinese and Japanese UI.
In its source, a webhook links to a user only when the user_id from custom data belongs to an existing user. The dashboard also shows subscriptions whose customer email matches the signed-in user's email, so a purchase made without the id can still appear for the same email.
Note: Since v1.0.2, Rindstack's dashboard matches a subscription by email only when the GitHub or Google sign-in reports that address as verified (for GitHub, only the verified primary email). Emails are compared case-insensitively, only subscriptions not yet linked to a user are matched, and the first match links the subscription to that user permanently. The email-only demo login never matches by email; it runs only when AUTH_DEV_LOGIN is true, and never when NODE_ENV is production. If you add other sign-in methods, check email verification before matching subscriptions by email.
It costs $99 one-time (Personal) or $199 (Team).
Its listed limits:
- No Stripe, teams, blog, transactional email or admin panel.
- Lemon Squeezy was mocked in all its tests, and the starter hasn't yet been run against a live Lemon Squeezy store. Its guide asks you to do one test-mode purchase before launch.
- The Vercel deployment guide hasn't been deployed by its author.
Sources
- Lemon Squeezy Docs, Passing Custom Data: https://docs.lemonsqueezy.com/help/checkout/passing-custom-data
- Lemon Squeezy Docs, Webhooks: https://docs.lemonsqueezy.com/help/webhooks
- Lemon Squeezy Docs, Webhook Requests: https://docs.lemonsqueezy.com/help/webhooks/webhook-requests
- Lemon Squeezy Docs, Event Types: https://docs.lemonsqueezy.com/help/webhooks/event-types
- Lemon Squeezy Docs, Simulate Webhook Events: https://docs.lemonsqueezy.com/help/webhooks/simulate-webhook-events
- Lemon Squeezy Guides, Taking Payments: https://docs.lemonsqueezy.com/guides/developer-guide/taking-payments
- Lemon Squeezy API, Create a Checkout: https://docs.lemonsqueezy.com/api/checkouts/create-checkout
- Lemon Squeezy API, The Subscription Invoice Object: https://docs.lemonsqueezy.com/api/subscription-invoices/the-subscription-invoice-object
- Lemon Squeezy API, The Subscription Object: https://docs.lemonsqueezy.com/api/subscriptions/the-subscription-object
- Lemon Squeezy Docs, Handling Events with Lemon.js: https://docs.lemonsqueezy.com/help/lemonjs/handling-events
- Lemon Squeezy for Laravel, README: https://github.com/lmsqueezy/laravel
- Lemon Squeezy for Laravel, WebhookController.php: https://github.com/lmsqueezy/laravel/blob/main/src/Http/Controllers/WebhookController.php
- GitHub, lmsqueezy/laravel issues #57, #83, #86: https://github.com/lmsqueezy/laravel/issues/57, https://github.com/lmsqueezy/laravel/issues/83, https://github.com/lmsqueezy/laravel/issues/86
- Laravel Docs, CSRF Protection: https://laravel.com/docs/12.x/csrf
- Laravel framework, Foundation exception handler: https://github.com/laravel/framework/blob/12.x/src/Illuminate/Foundation/Exceptions/Handler.php
- RFC 9110, HTTP Semantics, §15.4 Redirection: https://www.rfc-editor.org/rfc/rfc9110#section-15.4
- Django Docs, APPEND_SLASH: https://docs.djangoproject.com/en/5.2/ref/settings/#append-slash
- Stack Overflow, LemonSqueezy webhook requests coming through as GET instead of POST: https://stackoverflow.com/questions/78058659
- Stack Overflow, Getting 404 on post request for Lemon squeezy Integration in a Laravel app: https://stackoverflow.com/questions/77851667
Note: code samples follow the current docs listed above. Framework defaults change between versions, so check the docs for the version you use.