Lemon Squeezy webhooks

Lemon Squeezy sends a subscription update as part of cancellation

Lemon Squeezy documents subscription_cancelled and subscription_updated for the same manual cancellation. Read data.attributes.status and ends_at from the subscription. A cancelled subscription keeps access during its grace period, and expired ends access.

Payment and webhook repair commits
Event order or state
3 of 388
Event order and state count

Apply the fix

  1. Sync both events to the same row

    After checking X-Signature, use data.id to identify the subscription. Feed subscription_cancelled, subscription_updated, subscription_resumed and subscription_expired into the same sync routine. Use the returned status and dates to decide access.

  2. Reject older snapshots atomically

    Store data.attributes.updated_at and write the snapshot only when that timestamp is newer than the stored value. Put the comparison in the database write so concurrent deliveries cannot both pass a stale read. If timestamps tie and the snapshots disagree, or the timestamp is missing, reconcile with GET /v1/subscriptions/{id}. Use the same per-subscription lock for reconciliation and webhook writes. Hold it through the API read and commit.

  3. Enforce the grace period from ends_at

    For a cancelled subscription, keep access only up to ends_at. Evaluate that time when you check access so a delayed subscription_expired cannot extend it. A valid resumption can restore an active status and clear the scheduled end.

Verify the change

Run npx viberaven check from your repo root. The webhook check starts in VibeRaven 1.15. To run the current release explicitly, run npx viberaven@1.20.1 check. Review payment_webhook_order warnings in the handler. Test a signed cancellation and its update in both arrival orders in a test environment. Include an older active snapshot and confirm it cannot undo cancelled. Check access before and after ends_at.

Research and sources

We labeled 3 of 388 payment and webhook repair commits as event order or state. The sample counts repair commits across payment providers. The cancellation and update pair itself is normal Lemon Squeezy behavior.