Skip to content

Entitlement State Machine

An entitlement state machine is a product-owned model of what a customer may access, independent of the billing event that caused it. It turns payments, refunds, failed renewals, disputes, admin changes and policy decisions into explicit access states such as active, grace, expired or revoked.

The problem is that money events are not the same thing as product permission. A successful payment can be refunded, a renewal can fail during a retry window, a subscription can be cancelled but still valid until the end of a period, and support staff can grant exceptions. If feature gates keep interpreting billing records directly, access rules become duplicated across the codebase and disagree in edge cases.

The mechanism is a small state machine stored in your own product database. Billing and operational events are inputs. Transition rules decide whether those inputs grant access, extend it, put it into a grace period, expire it, or revoke it. The application then asks the entitlement record, not the payment provider, whether the customer can use a feature. The record usually carries state, relevant timestamps, reasons and provenance.

The trade-off is that you now own another source of truth, so its transitions must be designed carefully and kept in sync with external events. Webhooks can arrive late, out of order or more than once, so transitions need idempotency and sensible conflict handling. The honest answer to many cases is “it depends”: refund policy, grace length, dispute handling and admin override precedence are business decisions, not purely technical ones.

Engineers meet entitlement state machines in subscription products, usage-gated systems, paid account tiers, trials, complimentary access, enterprise contracts and refund flows. They commonly appear as an entitlement table, aggregate or service that sits between billing integration code and application authorisation. A common misunderstanding is to treat the payment provider’s subscription status as sufficient. It is useful input, but it rarely captures every product access rule.

Common questions

Why not just check whether the latest payment succeeded?
Because the latest payment is only one signal. Access may continue after a cancellation, pause during a dispute, survive a temporary renewal failure, or be removed after a refund or abuse decision. Checking payment history directly forces every feature gate to rediscover policy and makes exceptional cases inconsistent.
Is the entitlement state machine the same as subscription status?
No. Subscription status belongs to billing; entitlement status belongs to the product. A subscription can be past due while the product still grants grace access, or active while an admin revocation blocks use. The entitlement state is the answer your application should authorise against.
What should be stored on an entitlement record?
Store the current state, the subject it applies to, relevant start and end timestamps, the reason for the current state, and enough event or actor information to audit the transition. The exact fields depend on the product, but the record should explain why access is currently allowed or denied.