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": "Sin conectar"
},
"plans": {
"title": "Planes",
"subtitle": "Límites de Free y Pro, y precio de Pro en cada país.",
"loading": "Cargando planes",
"loadError": "No pudimos cargar los planes.",
"saveError": "No pudimos guardar el cambio.",
"edit": "Editar",
"save": "Guardar",
"cancel": "Cancelar",
"limits": {
"title": "Límites",
"hint": "Se aplican al instante a todas las cuentas del plan. Una cuenta que quede por encima pasa a solo lectura.",
"maxGroups": "Grupos",
"maxAttendees": "Alumnos activos",
"unlimited": "Sin límite",
"unlimitedFor": "{{label}} sin límite",
"mpCharges": "Cobros con Mercado Pago",
"whatsappAutomations": "Mensajes automáticos por WhatsApp",
"impact_one": "{{count}} cuenta ya supera estos límites y quedará en solo lectura al guardar.",
"impact_other": "{{count}} cuentas ya superan estos límites y quedarán en solo lectura al guardar.",
"saved": "Límites guardados."
},
"prices": {
"title": "Precio de Pro",
"hint": "Las suscripciones nuevas toman el precio al instante. Las existentes conservan el suyo, salvo que elijas aplicarlo.",
"live_one": "{{count}} suscripción activa",
"live_other": "{{count}} suscripciones activas",
"atOtherPrice_one": "{{count}} con otro precio",
"atOtherPrice_other": "{{count}} con otro precio",
"updatedAt": "cambiado el {{date}}",
"pending_one": "{{count}} cambio en curso",
"pending_other": "{{count}} cambios en curso",
"failed_one": "{{count}} cambio falló",
"failed_other": "{{count}} cambios fallaron",
"editFor": "Editar el precio de {{country}}",
"amount": "Precio mensual ({{currency}})",
"applyToExisting": "Aplicar a las suscripciones existentes",
"applyHint_one": "{{count}} suscripción pasa al precio nuevo desde su próximo cobro. Le avisamos por correo.",
"applyHint_other": "{{count}} suscripciones pasan al precio nuevo desde su próximo cobro. Les avisamos por correo.",
"saved": "Precio guardado.",
"savedQueued_one": "Precio guardado. {{count}} suscripción pasa al precio nuevo desde su próximo cobro.",
"savedQueued_other": "Precio guardado. {{count}} suscripciones pasan al precio nuevo desde su próximo cobro."
}
}
}

View File

@@ -88,6 +88,7 @@
"paidThrough": "Pagado hasta el {{date}}.",
"notEnforced": "Por ahora todas las funciones están habilitadas para todas las cuentas.",
"groups": "Grupos",
"students": "Alumnos activos"
"students": "Alumnos activos",
"nextPrice": "Nuevo precio desde tu próximo cobro: {{amount}} al mes."
}
}

View File

@@ -60,5 +60,8 @@
},
"attendance": {
"empty": "Envía al menos un registro de asistencia"
},
"billing": {
"priceInvalid": "Ingresa un precio mayor a cero"
}
}