---
title: "Give access from the subscription status · Agent Wranglers"
url: https://agentwranglers.se/playbook/pricing/entitlements/entitlements-from-status
id: PRC-3
level: Recommended
applies: payments
updated: 2026-10-27
build: a2a6bdfed830
tokens: 1191
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Give access from the subscription status

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Entitlements](https://agentwranglers.se/playbook/pricing/entitlements.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: PRC-3
- Level: Recommended
- Chapter: [Entitlements](https://agentwranglers.se/playbook/pricing/entitlements.md)
- Rule: Decide access in one function from the stored subscription status, period end and first failed payment time, with a fixed grace period for failed renewals.
- Check: A table test covers every status on the day before and the day after the period end and the grace end. A past due subscription whose period end lies a month ahead loses access 7 days after its failed payment. Search the code for direct reads of the status field outside that function. None are found.
- Applies when: The project takes payments.
- How: Map each status to access in one place. Active and trialing give access. Past due gives access for a grace period, such as 7 days, while retries run. Count the grace from the time of the first failed renewal, stored from the failure event. Many providers move the period end forward when they bill the renewal, so a grace counted from it gives a free month. A cancelled subscription keeps access until the paid period ends. Unpaid or ended gives none. Every page, API and background job asks that one function. Take the grace period from [the dunning schedule](https://agentwranglers.se/playbook/payments/failed-payments-and-dunning/dunning-schedule.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
const GRACE_DAYS = 7
const DAY_MS = 24 * 60 * 60 * 1000

function hasAccess(subscription, now = new Date()) {
  const periodEnd = subscription.currentPeriodEnd.getTime()
  switch (subscription.status) {
    case 'active':
    case 'trialing':
      return true
    case 'past_due':
      return now.getTime() < subscription.firstFailedAt.getTime() + GRACE_DAYS * DAY_MS
    case 'canceled':
      return now.getTime() < periodEnd
    default:
      return false
  }
}
```

### Python example

```python
from datetime import datetime, timedelta, timezone

GRACE = timedelta(days=7)

def has_access(subscription, now: datetime | None = None) -> bool:
    now = now or datetime.now(timezone.utc)
    match subscription.status:
        case "active" | "trialing":
            return True
        case "past_due":
            return now < subscription.first_failed_at + GRACE
        case "canceled":
            return now < subscription.current_period_end
        case _:
            return False
```

## Sources

- [Stripe subscription webhooks](https://docs.stripe.com/billing/subscriptions/webhooks)
- [Stripe subscriptions overview](https://docs.stripe.com/billing/subscriptions/overview)

## Related rules

- PAY-80 [Keep one subscription per customer across app stores and the web](https://agentwranglers.se/playbook/payments/subscriptions/store-and-web-subscriptions.md) in Payments and billing
- MOB-4 [Sell digital goods through the store's billing](https://agentwranglers.se/playbook/mobile-apps/store-review-and-listing/store-billing.md) in Mobile apps
- MOB-5 [Verify every store purchase on your server](https://agentwranglers.se/playbook/mobile-apps/store-review-and-listing/verify-store-purchases.md) in Mobile apps
- PAY-35 [Retry failed renewals on a fixed schedule](https://agentwranglers.se/playbook/payments/failed-payments-and-dunning/dunning-schedule.md) in Payments and billing
- PRC-4 [Map every store subscription state to access](https://agentwranglers.se/playbook/pricing/entitlements/store-subscription-states.md) in Pricing, plans and entitlements
- PRC-14 [Enforce every plan limit on the server from one entitlement table](https://agentwranglers.se/playbook/pricing/entitlements/plan-entitlements.md) in Pricing, plans and entitlements

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/pricing/entitlements/entitlements-from-status">Agent Wranglers pricing, plans and entitlements playbook</a>`. In code you write, add a comment next to it with the same link.

- Next: [Map every store subscription state to access](https://agentwranglers.se/playbook/pricing/entitlements/store-subscription-states.md)
- [Entitlements](https://agentwranglers.se/playbook/pricing/entitlements.md)
