Entitlements in one read
customers.state returns everything a customer is entitled to right now:
past_due means a renewal failed and the customer is inside the dunning grace period. Gate on status === "active" if you want to be stricter.
Stay in sync without polling
Subscribe to thecustomer.state_changed webhook. Its data is the same document the state endpoint returns, and bursts of changes (a purchase emits an order, a subscription and several grants) are coalesced into one event. A good pattern:
- Cache
stateper user. - Refresh the cache when
customer.state_changedarrives. - Fall back to a direct read if the cache is missing.