Migrating Lemon Squeezy Webhooks to Stripe Managed Payments
When you move a SaaS or digital-product app from Lemon Squeezy to Stripe Managed Payments before March 31, 2027, you cannot swap webhook handlers in one shot. New checkouts land on Stripe while existing subscribers stay on Lemon Squeezy until you migrate them in batches. Running both webhooks safely comes down to one cutover event (subscription_migrated), one status trap that can accidentally lock out paying users, and a clean event-and-signature map.
1. Event map: Lemon Squeezy → Stripe Managed Payments
| Lemon Squeezy event | Stripe Managed Payments equivalent | Key difference / trap |
|---|---|---|
order_created |
checkout.session.completed + checkout.session.async_payment_succeeded |
Fulfill only when payment_status !== 'unpaid'; delayed payment methods (e.g. ACH Direct Debit) confirm later via the async event. |
subscription_created |
checkout.session.completed (mode: 'subscription') / customer.subscription.created |
Migration also creates a Stripe subscription for an existing subscriber, and the docs don’t say whether customer.subscription.created arrives before or after subscription_migrated. Fulfill new purchases from Checkout (checkout.session.completed with payment_status not unpaid, or checkout.session.async_payment_succeeded), never from customer.subscription.created or subscription_migrated. |
subscription_updated |
customer.subscription.updated |
Catch-all for renewals, plan changes (previous_attributes.items), scheduled cancellations, and pauses. |
subscription_cancelled |
customer.subscription.updated |
Check cancel_at_period_end or cancel_at; the user keeps access until the period ends. |
subscription_resumed | customer.subscription.updated | Cancellation undone: check that cancel_at_period_end / cancel_at are cleared. |
subscription_plan_changed | customer.subscription.updated | Compare previous_attributes.items to spot a new price or quantity. |
subscription_expired |
customer.subscription.deleted |
Fires when the subscription actually ends (grace period finished or dunning exhausted). |
subscription_paused / subscription_unpaused |
customer.subscription.updated (pause_collection) |
Stripe does not send customer.subscription.paused when you pause payment collection; inspect pause_collection on updated instead. |
subscription_payment_success / subscription_payment_recovered |
invoice.paid |
A new subscription’s first invoice has billing_reason: 'subscription_create'; renewals use subscription_cycle. |
subscription_payment_failed |
invoice.payment_failed |
Also watch checkout.session.async_payment_failed for delayed checkout methods. |
order_refunded / subscription_payment_refunded |
charge.refunded |
On API 2025-03-31.basil+ (required for Managed Payments), charges do not link directly to invoices; map via charge.payment_intent and the Invoice Payments API. |
dispute_created / dispute_resolved |
charge.dispute.created / charge.dispute.closed |
Check dispute.status on close (anything except lost means you did not lose the dispute). |
subscription_migrated |
LS-only (no paired Stripe event) | LS-only cutover event carrying meta.migration. Migration doesn’t charge, so the first invoice.paid comes at the next renewal. |
Sources: Lemon Squeezy Webhook event types, Digital fulfillment migration, Migrate existing subscriptions, and Go live; Stripe Managed Payments setup and Subscription webhooks.
2. The subscription_migrated trap: do not revoke access on status: "expired"
When Lemon Squeezy moves a subscription to your Stripe account, it sends one webhook: subscription_migrated (and no other Lemon Squeezy webhooks for the move). Migration doesn’t trigger a charge, so Stripe’s first invoice.paid for that subscription comes at its next billing cycle. Stripe does create the subscription (and possibly a new customer) at migration, so make your Stripe handlers recognise migrated IDs and skip new-purchase fulfillment for them. The order of customer.subscription.created and subscription_migrated isn’t documented. Fulfill new purchases from Checkout (checkout.session.completed with payment_status not unpaid, or checkout.session.async_payment_succeeded), never from customer.subscription.created or subscription_migrated.
subscription_migrated payload, data is the Lemon Squeezy subscription object, and data.attributes.status usually reads expired. Per Lemon Squeezy’s migration docs, that means Lemon Squeezy stopped billing its side—not that the customer canceled. Ignore data.attributes.status on subscription_migrated, or you will lock out every migrated customer.
Read the new Stripe IDs from meta.migration instead:
meta.migration.stripe_subscription_idmeta.migration.stripe_customer_idmeta.migration.stripe_account_idmeta.migration.migrated_at
Two extra guards before applying the cutover:
- Verify
stripe_account_idmatches your expectedSTRIPE_ACCOUNT_ID. - Skip events with
nullStripe IDs. Lemon Squeezy’s test-mode “Simulate event” tool sendssubscription_migratedwithnullStripe IDs because real subscription migration cannot run in test mode or a Stripe sandbox.
3. Dual-webhook cutover: one source of truth + Migration Hub fallback
During migration, keep both /webhooks/lemonsqueezy and /webhooks/stripe live and tag every subscription row in your database with a billing source (source: 'lemonsqueezy' | 'stripe'):
- Existing LS subscriptions start as
source = 'lemonsqueezy'. - New Stripe checkouts start as
source = 'stripe'. - On
subscription_migrated, savestripe_subscription_idandstripe_customer_id, flipsource = 'stripe', keep existing entitlements/license keys untouched, and ignore all subsequent Lemon Squeezy webhooks for any record whosesourceis'stripe'. - Map plans via the Stripe Product, not subscription metadata: migrated subscriptions and their prices carry no Lemon Squeezy metadata. Use the Migration Hub product mapping report (
ls_product_id,ls_variant_id,stripe_product_id) to map renewals and plan changes. (For new checkouts, see wherecustom_datagoes in Stripe.)
ls_subscription_id, stripe_subscription_id, stripe_customer_id, migration_status) for rows where migration_status === 'migrated'.
Need a structured reconciliation checklist and test plan for cutover week? The Lemon Squeezy Cutover Kit ($9) includes the reconciliation worksheet and 10 end-to-end cutover test scripts with pass criteria.
4. Signature verification side-by-side (X-Signature vs Stripe-Signature)
Both providers sign the exact raw request body. Do not run a JSON body parser before verifying the signature, and make every handler idempotent so retried or duplicate deliveries never double-provision or send duplicate emails.
// Node.js — Untested snippet; verify in a Stripe sandbox before shipping.
import crypto from 'node:crypto';
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-03-31.basil', // minimum required for Managed Payments
});
// 1) Lemon Squeezy: hex HMAC-SHA256 in X-Signature
export function verifyLemonSqueezy(rawBody, signatureHeader) {
const digest = Buffer.from(
crypto
.createHmac('sha256', process.env.LEMONSQUEEZY_WEBHOOK_SECRET)
.update(rawBody)
.digest('hex'),
'utf8'
);
const signature = Buffer.from(signatureHeader || '', 'utf8');
if (digest.length !== signature.length || !crypto.timingSafeEqual(digest, signature)) {
throw new Error('Invalid Lemon Squeezy signature');
}
return JSON.parse(rawBody.toString('utf8'));
}
// 2) Stripe: timestamped signature in Stripe-Signature
export function verifyStripe(rawBody, signatureHeader) {
return stripe.webhooks.constructEvent(
rawBody,
signatureHeader,
process.env.STRIPE_WEBHOOK_SECRET
);
// On Deno / Cloudflare Workers / Edge runtimes, use:
// await stripe.webhooks.constructEventAsync(
// rawBody, signatureHeader, process.env.STRIPE_WEBHOOK_SECRET,
// undefined, Stripe.createSubtleCryptoProvider()
// );
}
Source: Lemon Squeezy Signing requests; Stripe Managed Payments setup.
5. Pre-cutover webhook test checklist
- Verify both endpoints reject tampered bodies and missing signatures with HTTP 400/401, and return HTTP 200 quickly on valid payloads.
- With
stripe listen --forward-torunning, deliver each Stripe event twice (for example withstripe events resend) and confirm your handler is idempotent (no duplicate entitlements or emails). - With a fresh migration fixture and no Stripe ID mapping yet, send
customer.subscription.createdfor that fixture’s Stripe subscription ID. Verify that it issues no key and sends no welcome email. Then send the signed Lemon Squeezysubscription_migratedpayload withdata.attributes.status: "expired"and matchingmeta.migrationIDs; verify the subscription flips tosource = 'stripe'and keeps active access without issuing a key or sending a welcome email. - Send a second Lemon Squeezy webhook for that same subscription after cutover and verify your handler ignores it.
- Test a dry-run import of the Migration Hub subscription mapping CSV so you have a working fallback if any
subscription_migrateddelivery is missed during the 30-second retry window. - Before going live on Checkout, validate your Stripe product tax codes with our client-side Tax-Code Checker.
Related
See replacing Lemon Squeezy Customer Portal, where Lemon Squeezy custom_data goes in Stripe, 11 Migration Hub gotchas, and the full LS migration checklist.
This page is free. The kit is the paperwork.
Everything above is the webhook mapping. The Lemon Squeezy Cutover Kit ($9, 10-page PDF) is what you fill in and send:
| This page (free) | Cutover Kit ($9) | |
|---|---|---|
| Official dates, rules, Hub traps | Linked | Yes, in one table, each with “what it means for you” |
| Route decision (Managed Payments / MP + add-ons / other provider) | No | 5-minute decision tree |
| Week-by-week schedule | No | 8-week plan for each route |
| Customer emails | No | 5 fill-in templates (heads-up, PayPal, India cards, last call, help page) |
| Test scripts | 6 webhook checks | 10 end-to-end scripts with pass criteria |
| Worksheets | No | Link inventory, subscriber segmentation, reconciliation |
Read a sample: Template 1 (heads-up email)
Subject: A change to how [Product] billing works on [date]
Hi [name], Lemon Squeezy, which handles our payments, stops processing on 31 March 2027, so we’re moving billing to [new provider] on or around [confirmed date]. [Only if confirmed: Your plan, price and renewal date stay the same.] After the move your statement will show [exact descriptor], and you’ll manage billing at [where]. You may also get an official notice from [provider]. That one is genuine. Questions? Just reply to this email.
Instant PDF delivery via Getly. Pay by card, Apple/Google Pay, or USDT/USDC. Getly offers a 30-day refund request window. Selling from a country without Stripe? See Getting Paid Online Without Stripe ($7).