Payments and Entitlements
Keep checkout, payment evidence, subscription state, and feature access separate, and enforce the access policy you chose on the server.
Content date: October 21, 2026.
Plain English
A payment is a financial event. An entitlement is permission to use a feature under your product's rules. Checkout completing, a browser redirect, an invoice's status, a subscription's status, and an access grant are related but different things. A paying customer still needs authorization for the account or resource they ask for, and paying doesn't make someone an administrator. If your product has no paid features, you don't need a payment processor to finish this course.
Use this when
Use this before a paid feature, a trial that converts, a recurring plan, or a usage charge reaches users. Use it again when you change payment methods, access rules, provider API versions, or cancellation and refund behavior.
If you are just starting
Use the local made-up exercise, which needs no account and no card. For each state, name the source that decides it and the place that enforces it. If you build real payments, prefer a checkout page or customer portal hosted by a payment provider over collecting card numbers yourself, and still check the account match and access on your server. A return URL only moves the browser, so never treat it as proof of payment. Keep test and live keys, prices, customers, and webhook destinations apart.
When your project grows
Verify the signature on every incoming provider event. Stripe says events can arrive more than once and out of order, so store handled event IDs and fetch current objects from the API instead of trusting arrival order. Match account, product, price, and test or live mode through a trusted mapping. Stripe also documents that a subscription can be active while an invoice is unpaid, for example with delayed methods like ACH debit, so "status equals active" isn't enough for every product. Base access on the evidence your written policy requires, and define trials, grace periods, expiry, holds, refunds, and disputes. Enforce access on the server for each protected action, and keep an audit trail with no card data or secrets. Before relying on it, test late and failed payments, payments needing customer action, retries, cancellations, and reconciliation in the provider's sandbox.
Worked example
A delayed notification says the Riverside Robotics Club paid, but the practice code's current trusted read says its grant is canceled. Reconciliation uses the current record and denies access. A second case lets a made-up past-due customer keep access only until a grace deadline someone assigned on purpose. These are classroom policies, not a Stripe integration, and they don't show that real webhooks were authenticated.
Practice
Define and test an entitlement boundary
- Run the local decision tests, and explain why a success URL, another account, a stale snapshot, or an expired grant isn't enough to grant access.
- Draw a map of who decides what for checkout, payment, subscription, feature access, and admin restrictions.
- Watch the delayed and repeated notifications run against the fake current-state reader, and note the storage and provider checks still missing.
- In a disposable copy, remove the freshness check, watch the expected test fail, put it back, and write the tradeoff your real policy needs.
- Write a failure table for delayed or failed payments, payments needing action, cancellation, refunds and disputes, outages, and a trusted support override.
Deliverable: A table of who decides each access state and the policy behind it, with your local test results and a separate plan for testing with the payment provider.
Common mistakes to watch for
- A customer types the success URL into the address bar and gets a paid feature without paying.
- One club's payment is matched to a different club's account.
- A delayed old event arrives and re-grants access to a canceled customer.
- A refund, a cancellation, and an account deletion are treated as one action, so a refunded customer keeps access or a canceled one loses their data.
Prompting
A weak prompt
If checkout returns success or the subscription is active, give full access permanently.
A better prompt
Map each state in my payment flow (checkout, payment or invoice, subscription, feature access, admin restriction) to the system that decides it. Build server-side checks that match account, product, and test or live mode before granting access. Handle duplicate, out-of-order, and missing provider events by storing event IDs and re-reading current state. Write my policy for trials, grace periods, evidence freshness, cancellation, refunds, and disputes, with tests at the edges. Start with made-up local cases, and never accept a browser success flag or a bare "active" status as proof of payment.
Without it, a billing screen or an ambiguous provider status becomes a way around your own access rules.
Check before you move on
- Your notes keep payment and access as separate things.
- The server matches account, product, price, and test or live mode.
- Every protected action checks access on the server.
- You chose how fresh evidence must be and how long grace lasts.
- Your refund and dispute policy is written down.
- Local and real-provider results are recorded separately.
You are done when
- You can show access denied for a client success flag, another account's payment, stale evidence, and a delayed "paid" notice.
- Your report names what the practice code leaves out, such as real signatures and storage, and doesn't call it a payment integration.
Questions to think about
A customer lands on your /thank-you?paid=true page. Can that page grant a paid feature?
No. Anyone can type that address. The server must look up the account's current entitlement from trusted evidence, such as a verified provider event or a fresh read from the provider.
A subscription's status is active. Does that prove every invoice is paid?
Not always. Stripe's docs say active doesn't necessarily mean all outstanding invoices are paid, and delayed methods like ACH can be active before the money arrives.
A "paid" event arrives after your records show the subscription canceled. Should it restore access?
Not automatically. Events can arrive late or out of order, so compare it with the current trusted state and your written rules first.