feat: configurable plans, MP payment notifications and onboarding language selector #15

Merged
jselesan merged 2 commits from development into main 2026-11-11 10:55:19 +00:00
Owner

Summary

  • Onboarding: language selector on the onboarding screen; fixed docker-compose.
  • Configurable plans (/admin/plans): plan limits and Pro prices per country now live in the database (plan_configs, plan_prices, seeded with the previous constants) and are read through PlanCatalog. Admins can change limits (seeing how many accounts would become read-only) and prices, optionally pushing the new price to live subscriptions from their next charge (MP preapproval amount / Stripe item without proration) with an email and a notice on /billing.
  • Mercado Pago:
    • Pro checkout returns through GET /billing/return on API_PUBLIC_URL (MP refuses a back_url on localhost).
    • OAuth callback: bounces from the tunnel to BETTER_AUTH_URL to find the session, requires the session to own the state, and redirects instead of answering JSON on unexpected errors.
    • Checkout Pro links skip auto_return off public HTTPS and carry a notification_url to POST /payments/webhooks/mp/:paymentId, which confirms the payment with the owner's token (same rule as the polling job, kept as fallback). The search now prefers the approved attempt.

Deploy notes

  • Migration 20261110214656_configurable_plans (seeds current limits and prices, so nothing changes on deploy).
  • New optional env API_PUBLIC_URL (defaults to BETTER_AUTH_URL, already the public domain in the compose).
  • TOKEN_ENCRYPTION_KEY must be base64 of 32 bytes (openssl rand -base64 32).

Test plan

  • bun run typecheck, bun run lint, backend tests (537 pass)
  • Local MP: Pro subscription with test users, OAuth link of the professor account, student payment marked PAID by the notification
  • Stripe test mode: price change applied on the upcoming invoice without proration
  • /admin/plans changes in a staging environment

🤖 Generated with Claude Code

## Summary - **Onboarding**: language selector on the onboarding screen; fixed `docker-compose`. - **Configurable plans** (`/admin/plans`): plan limits and Pro prices per country now live in the database (`plan_configs`, `plan_prices`, seeded with the previous constants) and are read through `PlanCatalog`. Admins can change limits (seeing how many accounts would become read-only) and prices, optionally pushing the new price to live subscriptions from their next charge (MP preapproval amount / Stripe item without proration) with an email and a notice on `/billing`. - **Mercado Pago**: - Pro checkout returns through `GET /billing/return` on `API_PUBLIC_URL` (MP refuses a `back_url` on localhost). - OAuth callback: bounces from the tunnel to `BETTER_AUTH_URL` to find the session, requires the session to own the `state`, and redirects instead of answering JSON on unexpected errors. - Checkout Pro links skip `auto_return` off public HTTPS and carry a `notification_url` to `POST /payments/webhooks/mp/:paymentId`, which confirms the payment with the owner's token (same rule as the polling job, kept as fallback). The search now prefers the approved attempt. ## Deploy notes - Migration `20261110214656_configurable_plans` (seeds current limits and prices, so nothing changes on deploy). - New optional env `API_PUBLIC_URL` (defaults to `BETTER_AUTH_URL`, already the public domain in the compose). - `TOKEN_ENCRYPTION_KEY` must be base64 of 32 bytes (`openssl rand -base64 32`). ## Test plan - [x] `bun run typecheck`, `bun run lint`, backend tests (537 pass) - [x] Local MP: Pro subscription with test users, OAuth link of the professor account, student payment marked PAID by the notification - [ ] Stripe test mode: price change applied on the upcoming invoice without proration - [ ] `/admin/plans` changes in a staging environment 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jselesan added 1 commit 2026-11-10 21:28:19 +00:00
jselesan added 1 commit 2026-11-11 10:51:57 +00:00
Plans:
- Plan limits and Pro prices per country live in the database
  (plan_configs, plan_prices, seeded with the previous constants) and are
  read through PlanCatalog (30 s cache, defaults as fallback).
- /admin/plans edits limits (with the count of accounts that would become
  read-only) and prices, optionally pushing the new price to live
  subscriptions from their next charge (MP preapproval amount, Stripe item
  without proration) via the ApplyPriceChanges job, with an email and a
  notice on /billing.
- GET /billing/plans feeds the onboarding and the billing screen.

Mercado Pago:
- The Pro checkout returns through GET /billing/return on API_PUBLIC_URL,
  since MP refuses a back_url on localhost.
- The OAuth callback bounces from the tunnel to BETTER_AUTH_URL to find the
  session, requires the session to own the state, and redirects instead of
  answering JSON on unexpected errors.
- Checkout Pro links skip auto_return off public HTTPS and carry a
  notification_url to POST /payments/webhooks/mp/:paymentId, which confirms
  the payment with the owner's token (same rule as the polling job, which
  stays as fallback). The search now prefers the approved attempt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jselesan changed title from Language selector on onboarding screen to feat: configurable plans, MP payment notifications and onboarding language selector 2026-11-11 10:52:39 +00:00
jselesan merged commit ca60733ea0 into main 2026-11-11 10:55:19 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jselesan/gruperly#15
No description provided.