Server integration

Owning your plan limits

Why App Center refuses to enforce your limits, and the one-table pattern that replaces it.

App Center answers *what did this account buy*. Your backend answers *what does that allow*. If the first question lived in App Center and the second in your product, every pricing experiment would need two releases — so the second question lives entirely with you.

The pattern

plan-limits.ts
export const PLAN_LIMITS: Record<string, Limits> = {
  basic: { shop: 1, warehouse: 0, user: 1 },
  pro: { shop: 3, warehouse: 1, user: 1000 },
  premium: { shop: 1000, warehouse: 1000, user: 1000 },
  enterprise: { shop: 1000, warehouse: 1000, user: 1000 },
};

/** Optional per-plan-code override, keyed by the code App Center returns. */
export const PLAN_CODE_LIMITS: Record<string, Partial<Limits>> = {};

export function limitsFor(subscription: Subscription | undefined): Limits {
  if (!subscription || subscription.status !== "active") return PLAN_LIMITS.basic;
  return {
    ...PLAN_LIMITS[subscription.accessTier.toLowerCase()],
    ...PLAN_CODE_LIMITS[subscription.planCode],
  };
}

Rules that keep this honest

  • Map by accessTier first and override by planCode only when you genuinely need a special case.
  • Treat a missing or inactive subscription as the most restrictive plan, not as unlimited.
  • Cache the subscription for a few minutes and invalidate on subscription.* webhooks — do not check it on every request.
  • When a limit is hit, answer with the limit and the plan name. "Upgrade to Pro" beats "403".

A failed subscription read must not unlock features

If the read times out, fail closed. The alternative — treating an unreachable platform as an enterprise account — is a revenue leak that is invisible until an audit.

Something here out of date or unclear?

The platform team answers integration questions directly.

support@versified.com.gh
32 pages in this documentation