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
- The app shows RevenueCat's paywall; the user buys in the store.
- The app calls
sync-entitlements, which fetches the customer from RevenueCat and stores their entitlements. - RevenueCat's webhook calls
revenuecat-webhookfor every event. It records the event once, fetches the customer again and stores what RevenueCat reports, whatever the event type. - A nightly job re-fetches users whose entitlement ends around now, for webhooks that never arrived.
- The
entitlementsstream 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
- Create a RevenueCat project. Its Test Store works right away: put its key in
EXPO_PUBLIC_REVENUECAT_TEST_KEY(development builds only). - Create the entitlement (
sync), the productslistoca_sync_weekly,listoca_sync_monthlyandlistoca_sync_yearlyin one subscription group, the offeringdefaultwith the three packages, and the paywall in the design's colors. - Connect App Store Connect and Google Play, and attach their products.
- Set
REVENUECAT_SECRET_KEYandREVENUECAT_WEBHOOK_AUTHORIZATION(and, with signing,REVENUECAT_WEBHOOK_HMAC_SECRET) for the Edge Functions, and point the webhook at<api>/functions/v1/revenuecat-webhookwith the same authorization value. - Put the public SDK keys in
EXPO_PUBLIC_REVENUECAT_IOS_KEYand…_ANDROID_KEY.
Purchases need a development build; they don't work in Expo Go.