Guides
GuidePaid Access (Entitlements)

Paid Access (Entitlements)

An entitlement is a key a member holds — “pro”, “course-101”, “vip”. Payments grant keys; access rules check them. That one idea powers every paid feature: membership tiers, paid courses, gated files, even paid chat rooms.

The loop: a Product gives one or several keys (a Pro plan can give “pro” and “basic”), ticked from your site’s keys → a member buys it (your Stripe, another provider, or manual/cash you approve) → every key it gives is granted automatically → everything gated with those keys unlocks. In the site editor, Payments → Members & access lists your keys, the plans that give each and who holds them, and gives, pauses, resumes, removes or extends a member’s key by picking it: nobody types a key. When a subscription ends or the key’s date passes, access ends just as automatically. You can pause or remove a member’s key by hand and resume it later (its end date is kept); a payment never undoes your pause.

Gate anything with one rule

The same rule works on pages, tables, files, backend functions, realtime channels, and email-campaign audiences:

{ "type": "has_entitlement", "key": "pro" }

Pages can also check state for UI (show “Upgrade” vs the content):

const mine = await serenities.user.entitlements();
// each key: { key, status, isLive, expiresAt, graceUntil, reason, payPath, test }
// test: true when a test-mode payment gave it (it ends when the site's payment provider goes live)
const pro = mine.find((e) => e.key === 'pro');
const isPro = !!pro?.isLive;
// reason: 'payment_due' (send them to pro.payPath to pay), 'paused_by_site', 'ended', 'disputed', 'refunded', or null when live

What a member without the key sees, and your pay page

Pick your site’s pay page once: in the site editor, Payments → Providers → Pay page, choose one of your pages (for example /pay), or ask the AI to set it. A signed-in member who is missing only the key then sees “This page needs Pro Monthly access.” with a Get access button that opens that page (the plan’s name when one plan gives the key). The billing emails’ Pay now link goes to the same page. To see whether each billing email went out (and why one did not, such as an offer with no sending account), open Payments and read the Emails line under the member’s unpaid invoice, or ask the AI “did the reminders go out?”. Without a pay page, or when you paused their key by hand, they are told to sign in with an account that has it or contact you.

Your page code gets the same answer from every table, file, function, flow, email and server call it makes through the SDK, so it can send them to pay (a file’s bare public link is not a signed-in call: it opens only files open to anyone):

try {
  await serenities.entities.Lessons.list();
} catch (e) {
  // e.code === 'NEEDS_ACCESS', e.key === 'pro', e.reason: 'payment_due' | 'ended' | 'paused_by_site' | null
  if (e.code === 'NEEDS_ACCESS' && e.payPath) window.location.href = e.payPath;
}

Lifetimes that match how you sell

  • Forever — one-time purchase, lifetime access
  • N days — passes and time-boxed access; buying again adds the days to the ones still left
  • Until a date — cohorts and challenges that end on one day
  • While subscribed — follows the Stripe subscription (or one billing period per payment by another provider or by hand), with a grace period you set on the plan, 7 days unless you change it (members aren’t locked out over a card hiccup; access ends only if payment truly stops). A plan with billing settings (monthly invoices) has no grace days: its billing schedule’s pause step is when access pauses.

Changing plans. You can change a member’s billed plan or amount from Payments (Change plan or amount), the AI chat or your own AI client, at once or from the next bill. Members can move themselves between plans you put in the same plan group, from your site’s billing page (payments.changePlan): a move up bills the difference, a move down starts at the next bill.

Refunds and disputes

  • A full refund removes the access that payment gave — at once, and only that payment’s: a member who bought again later keeps the later access, and anything you gave by hand stays.
  • A partial refund keeps the access. The payments list shows how much was refunded; several refunds that add up to the whole amount count as a full one.
  • A dispute pauses the access until it ends — given back if you win it, removed if you lose it.
  • Stripe tells us by itself. Refund a Stripe payment in your Stripe dashboard and the change follows here. A payment made any other way (bank transfer, cash, another provider) you refund outside, then record the refund on the payment from the dashboard, the AI chat or your own AI client.
  • Any provider, the same rules. Stripe reports its own disputes. When another provider (Pesapal, a payment provider you added, a bank) tells you a buyer disputed a payment, record it on the payment as opened, then won or lost, from the dashboard (Payments → Payment history), the AI chat or your own AI client: the access pauses, comes back or goes exactly as it does for Stripe.
  • Your hand always wins. A key you paused or removed by hand stays exactly as you left it; a won dispute never gives back a key you removed. A full refund (or a lost dispute) of a payment that paid a plan’s bill makes that bill unpaid again: the plan’s billing schedule then pauses the member on its pause day unless the bill is paid again. A partial refund changes nothing about the bill.

Why it’s trustworthy

  • One audited ledger. Every grant, extension, suspension, and revocation is recorded with who/why — payments, owner actions, and function code (ctx.entitlements.*) all write through the same guarded API.
  • Payment-agnostic. Stripe checkout, manual/cash with owner approval, a custom gateway’s backend function, or a grant you make by hand — the key is the same, so your content rules never care how someone paid.
  • Checks are fail-closed. No key, expired key, or any doubt = no access.
  • Keys by hand are yours. You give, extend, pause, resume and remove a member’s key by hand from the dashboard, the AI chat or your own AI client. In a workspace with members, only the Owner and Admins can; a Developer or a Viewer who tries is told to ask one of them, and nothing changes.