feat(billing): planes Free/Pro con Suscripciones de Mercado Pago

- Módulo billing: suscripción Pro mensual vía /preapproval con credenciales
  de plataforma por país, webhook firmado y reconciliación por polling.
- PlanGuard en los use-cases que crean grupos/alumnos, cobran con MP o
  activan automatizaciones (402 plan_limit_reached / plan_feature_required /
  plan_read_only), detrás de BILLING_ENFORCEMENT.
- Onboarding: paso Plan obligatorio (POST /onboarding/plan); con Free se
  saltean Cobros y WhatsApp.
- Web: pantalla /billing, aviso de Pro desde el MutationCache.
- Migración billing_subscriptions y docs/billing.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-23 15:49:27 -03:00
parent f4d2c26e29
commit f5e77c99f6
93 changed files with 4402 additions and 117 deletions

View File

@@ -1,9 +1,9 @@
import type { CountryCode } from '@gruperly/shared'
import { COUNTRY_CURRENCY, COUNTRY_LABELS, DEFAULT_COUNTRY } from '@gruperly/shared'
import { COUNTRY_CURRENCY, COUNTRY_LABELS } from '@gruperly/shared'
import { ArrowLeft, ArrowRight } from 'lucide-react'
import { useState } from 'react'
import { Button } from '../../components/ui'
import { cn } from '../../lib/utils'
import { useOnboarding } from './OnboardingProvider'
export const COUNTRY_OPTIONS: readonly CountryCode[] = [
'AR',
@@ -24,11 +24,12 @@ type CountryStepProps = {
* Paso "País" del onboarding.
*
* El país del profesor define la moneda con la que se generan los links de
* cobro, así que se pregunta al empezar. Por default Argentina (la moneda por
* default es ARS); se cambia después desde Ajustes.
* cobro y el precio de Pro, así que se pregunta al empezar. Por default
* Argentina (la moneda por default es ARS). Vive en el provider: el paso Plan y
* el del primer grupo lo usan, y se guarda junto con el plan.
*/
export function CountryStep({ onNext, onBack }: CountryStepProps) {
const [country, setCountry] = useState<CountryCode>(DEFAULT_COUNTRY)
const { country, setCountry } = useOnboarding()
return (
<section className="space-y-5">