Listoca
Payments

Payments

The Sync plan, through RevenueCat; what pauses when it ends, and what is deleted after 30 days.

Purchases go through the App Store and Google Play, handled by RevenueCat. RevenueCat is the source of truth for what a user bought; Postgres keeps a copy in entitlements that the database, both apps and the admin area decide with.

Plans

packages/payments/src/config.ts has one paid plan, Sync. A list syncs while its owner has it (D2, D5); people they invite need only an account.

plans: {
  free: { isFree: true, limits: {} },
  sync: {
    entitlement: "sync",
    limits: { membersPerList: 25 },
    prices: [
      { per: "week", amount: 0.99, currency: "EUR", trialDays: 14 },
      { per: "month", amount: 2.99, currency: "EUR", trialDays: 14 },
      { per: "year", amount: 24.99, currency: "EUR", trialDays: 14 },
    ],
  },
},
syncGraceDays: 30,

The app always shows the store's prices from RevenueCat's offering (/choose-plan); the config's are only for the landing page. A price change is made in three places: here, App Store Connect and Google Play. There is no one-time purchase: sync needs servers for as long as someone uses it.

entitlementsOf(activeEntitlementIds) turns entitlements into the plan, whether the user paid, the paywall and the limits. The apps never work out plans from purchases themselves.

How a purchase reaches the database

  1. The app shows RevenueCat's paywall; the user buys in the store.
  2. The app calls sync-entitlements, which fetches the customer from RevenueCat and stores their entitlements.
  3. RevenueCat's webhook calls revenuecat-webhook for every event. It records the event once, fetches the customer again and stores what RevenueCat reports, whatever the event type.
  4. A nightly job re-fetches users whose entitlement ends around now, for webhooks that never arrived.
  5. The entitlements stream syncs the row to the user's devices.

On the device, useEntitlements() combines RevenueCat's SDK (it knows a purchase at once and caches offline) with the synced rows.

The plan check, and the pause

The lists_plan migration refuses every write to a list (and its tasks, steps and marks) whose owner has no Sync plan, with 23514 and hint sync_inactive. The device does not record that as a refused change: the write stays queued and goes through once the plan returns (packages/sync/src/upload.ts).

When the plan ends (the stores' own grace period comes first), the trigger on entitlements sets paused_at on the owner's lists and emails them. Members see the list read-only. The owner's device is paused: it disconnects, keeps working, and waits. A daily job emails 7 days before, then deletes lists paused for 30 days (members are told) and the inbox tasks of owners whose plan ended that long ago. After 30 days the device keeps everything on itself (stopSyncing).

Renewing: the store reports the plan, the app asks sync-entitlements first, and connects once the server answers active; what waited uploads.

The member limit (25 people a list) is checked in the app and enforced by a trigger (23514, hint plan_limit); limits.test.ts keeps the config and the SQL numbers equal. Sandbox purchases count only where private.settings.accept_sandbox is true (the local stack, staging) and in development builds.

Setting up RevenueCat

  1. Create a RevenueCat project. Its Test Store works right away: put its key in EXPO_PUBLIC_REVENUECAT_TEST_KEY (development builds only).
  2. Create the entitlement (sync), the products listoca_sync_weekly, listoca_sync_monthly and listoca_sync_yearly in one subscription group, the offering default with the three packages, and the paywall in the design's colors.
  3. Connect App Store Connect and Google Play, and attach their products.
  4. Set REVENUECAT_SECRET_KEY and REVENUECAT_WEBHOOK_AUTHORIZATION (and, with signing, REVENUECAT_WEBHOOK_HMAC_SECRET) for the Edge Functions, and point the webhook at <api>/functions/v1/revenuecat-webhook with the same authorization value.
  5. Put the public SDK keys in EXPO_PUBLIC_REVENUECAT_IOS_KEY and …_ANDROID_KEY.

Purchases need a development build; they don't work in Expo Go.

On this page