feat(billing): configurable plans from the backoffice and MP payment notifications

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>
This commit is contained in:
Jose Selesan
2026-11-11 07:50:14 -03:00
parent abb18f1815
commit aac142d324
90 changed files with 2642 additions and 104 deletions

View File

@@ -86,5 +86,49 @@
"PENDING": "Conectando",
"DISCONNECTED": "Desconectado",
"NONE": "Não conectado"
},
"plans": {
"title": "Planos",
"subtitle": "Limites do Free e do Pro, e preço do Pro em cada país.",
"loading": "Carregando planos",
"loadError": "Não conseguimos carregar os planos.",
"saveError": "Não conseguimos salvar a alteração.",
"edit": "Editar",
"save": "Salvar",
"cancel": "Cancelar",
"limits": {
"title": "Limites",
"hint": "Valem na hora para todas as contas do plano. Uma conta que ficar acima passa a somente leitura.",
"maxGroups": "Grupos",
"maxAttendees": "Alunos ativos",
"unlimited": "Sem limite",
"unlimitedFor": "{{label}} sem limite",
"mpCharges": "Cobranças com Mercado Pago",
"whatsappAutomations": "Mensagens automáticas por WhatsApp",
"impact_one": "{{count}} conta já passa desses limites e vai ficar em somente leitura ao salvar.",
"impact_other": "{{count}} contas já passam desses limites e vão ficar em somente leitura ao salvar.",
"saved": "Limites salvos."
},
"prices": {
"title": "Preço do Pro",
"hint": "As assinaturas novas usam o preço na hora. As existentes mantêm o delas, a menos que você escolha aplicá-lo.",
"live_one": "{{count}} assinatura ativa",
"live_other": "{{count}} assinaturas ativas",
"atOtherPrice_one": "{{count}} com outro preço",
"atOtherPrice_other": "{{count}} com outro preço",
"updatedAt": "alterado em {{date}}",
"pending_one": "{{count}} alteração em andamento",
"pending_other": "{{count}} alterações em andamento",
"failed_one": "{{count}} alteração falhou",
"failed_other": "{{count}} alterações falharam",
"editFor": "Editar o preço de {{country}}",
"amount": "Preço mensal ({{currency}})",
"applyToExisting": "Aplicar às assinaturas existentes",
"applyHint_one": "{{count}} assinatura passa ao preço novo a partir da próxima cobrança. Avisamos por e-mail.",
"applyHint_other": "{{count}} assinaturas passam ao preço novo a partir da próxima cobrança. Avisamos por e-mail.",
"saved": "Preço salvo.",
"savedQueued_one": "Preço salvo. {{count}} assinatura passa ao preço novo a partir da próxima cobrança.",
"savedQueued_other": "Preço salvo. {{count}} assinaturas passam ao preço novo a partir da próxima cobrança."
}
}
}