How FlowState locks and unlocks SOP / Checklist features based on ownership and purchased industry bundles.
User picks an industry and generates a document via the AI generator.
The system checks created_by_id — if the user is the owner, all features unlock immediately.
For others' content, the system queries active Purchase records for industries the user has unlocked.
If the document's industry matches a purchased industry → full access (print, edit, export, reorder).
If no matching purchase → buttons are replaced with a 'Locked' state and an amber banner appears.
Banner links to the pricing section where the user selects a bundle tier (Starter, Pro, Enterprise).
create-checkout backend function creates a Wix checkout session and a Purchase record (status: pending) with the bundle's industries.
Wix sends an order_approved webhook → wix-payments-webhook flips the Purchase status to 'active'.
usePurchasedIndustries hook now sees the active purchase — print, edit, export, and reorder unlock for that industry.
When someone opens an SOP or Checklist, the app first checks whether they created it. If they did, every feature — print, edit, export, reorder — is available right away, no purchase needed.
If the content belongs to someone else (e.g. a published template), the app looks up the user's active Purchase records to see which industries they've paid to unlock.
If the document's industry is in their purchased list, all features unlock. If not, the Print, Edit, Export, and Reorder buttons are hidden and replaced with a 'Locked' button, plus an amber banner explaining the content is locked and offering an 'Unlock Access' link.
Clicking 'Unlock Access' sends them to the pricing section, where they choose a bundle tier (Starter, Pro, or Enterprise). Each tier maps to specific industries.
The create-checkout backend function calls Wix Payments to create a checkout session and simultaneously creates a Purchase record in the database with status 'pending' and the bundle's industries stored on it.
After the user pays on the Wix checkout page, Wix fires an order_approved webhook to the wix-payments-webhook backend function, which finds the matching Purchase by checkout session ID and sets its status to 'active'.
On the next page load, the usePurchasedIndustries hook fetches all active purchases, sees the newly unlocked industries, and all previously locked features become available.
usePurchasedIndustriesFetches active purchases and exposes the unlocked industries list to any page.
Creates a Wix checkout session + a pending Purchase record with the bundle's industries.
Receives the payment confirmation from Wix and activates the Purchase record.
Stores bundle name, tier, price, industries array, status, and checkout session ID.