# How to charge a subscription in an AI-built app and unlock features only for those who paid

> Source: <https://dev.to/ciromaciel/how-to-charge-a-subscription-in-an-ai-built-app-and-unlock-features-only-for-those-who-paid-4bf8>
> Published: 2026-11-18 10:09:48+00:00

**Key takeaway:** Gate paid features by entitlement ID (e.g. advanced-reports) checked server-side via /sdk/v1/permissions, since client-side FeatureControl only hides UI and leaves the route open.

The app the AI helped you build has users, and now you want to charge. The agent usually proposes wiring Stripe directly: products, checkout, a webhook endpoint, subscription state in your database, a check on every screen. It works, but those pieces have to agree with each other. And the classic mistake of an app built in a hurry is hiding the paid button in the frontend while the server route stays open.

This is the path with Payments, from the Infrastructure line (by Ciro Cesar Maciel, who writes this).

A **project** holds **gateways**; each gateway holds **plans**; a customer subscribes to a plan and gets the **features** linked to it. The app never asks "which plan is this user on?". It asks "does this user have `advanced-reports`?". Changing what each plan includes needs no code change.

Recurring billing happens in **your** Stripe account: the money, the invoices and the receipts live there. Payments organizes plans, follows subscriptions through Stripe's events and tells the app who can do what.

`https://myinfrastructure.click/products/payments/llms.txt`. No account yet? The agent creates it and the project itself; you only read the e-mail code.`sk_test_…`) connects, answers everything with success and charges no one. `@ciromaciel/payments-react`, a `PaymentsProvider` with the project's public key, your own stable `userId` and the customer's e-mail. Then `<Pricing>` for the plans (subscribers change plans through the portal, never a second checkout), `<FeatureControl featureId="...">` with a `fallback`, and `<PortalButton>` for card, invoices and cancellation.
Anything in the browser can be changed by whoever is in the browser. `FeatureControl` and `useHasFeature` are for the interface: hide, show, invite to upgrade. The paid thing itself (the export, the report, the expensive call) must be refused on the server. Before delivering it, your backend asks for the user's permissions at `/sdk/v1/permissions`, which returns whether there is an active subscription and which features are unlocked.

That one line on the server is the difference between a paywall and a hidden button.

Upgrades apply at once and Stripe charges the prorated difference. Downgrades, or yearly to monthly, apply at the end of the paid period. The new plan arrives by webhook and the permissions follow.
