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.
- Event order or state
- 3 of 388
Apply the fix
Sync both events to the same row
After checking
X-Signature, usedata.idto identify the subscription. Feedsubscription_cancelled,subscription_updated,subscription_resumedandsubscription_expiredinto the same sync routine. Use the returned status and dates to decide access.Reject older snapshots atomically
Store
data.attributes.updated_atand 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 withGET /v1/subscriptions/{id}. Use the same per-subscription lock for reconciliation and webhook writes. Hold it through the API read and commit.Enforce the grace period from ends_at
For a
cancelledsubscription, keep access only up toends_at. Evaluate that time when you check access so a delayedsubscription_expiredcannot 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.