mirror of
https://github.com/vernu/textbee.git
synced 2026-06-17 04:00:08 -04:00
A paid subscriber upgrading (pro -> scale) or downgrading (scale -> pro) previously got a brand-new Polar checkout, ending up with two live Polar subscriptions and double billing. Now an active paid subscription is updated in place via Polar's subscription update API. - store polarSubscriptionId/polarCustomerId/cancelAtPeriodEnd on subscriptions (recovered via externalCustomerId for legacy records) - POST /billing/checkout returns a planChange preview for paid users; new POST /billing/change-plan executes it (uncancels a scheduled cancellation first, org-default proration, idempotent with webhooks) - allow monthly<->yearly interval switches; keep ALREADY_ON_PLAN only for same plan + same interval; block custom plans (CONTACT_BILLING) - map Polar 402/403/409 errors to actionable messages; run plan-change detection before cached checkout-session reuse - checkout page shows a confirmation screen before applying the change; account page shows a success toast Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>