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:
@@ -16,6 +16,7 @@ import {
|
||||
} from './modules/analytics';
|
||||
import { attendeesRoutes } from './modules/attendees';
|
||||
import { authRoutes } from './modules/auth';
|
||||
import { billingRoutes, planReadOnlyMiddleware } from './modules/billing';
|
||||
import { classesRoutes } from './modules/classes';
|
||||
import { groupsRoutes } from './modules/groups';
|
||||
import { healthCheckRoutes } from './modules/health-check';
|
||||
@@ -40,6 +41,13 @@ const api = app.basePath('/api/v1');
|
||||
|
||||
api.use('*', sessionAuthMiddleware);
|
||||
|
||||
// Read-only accounts (Free over its limits) cannot write domain data. Billing,
|
||||
// onboarding and the MP/WhatsApp links stay open: that is how they get out of it.
|
||||
const planReadOnly = planReadOnlyMiddleware();
|
||||
for (const prefix of ['/groups', '/attendees', '/payments', '/classes', '/students', '/waitlist']) {
|
||||
api.use(`${prefix}/*`, planReadOnly);
|
||||
}
|
||||
|
||||
api.route('/auth', authRoutes);
|
||||
api.route('/health', healthCheckRoutes);
|
||||
api.route('/invitations', invitationsRoutes);
|
||||
@@ -50,6 +58,7 @@ api.route('/mp', mpRoutes);
|
||||
api.route('/whatsapp', whatsappRoutes);
|
||||
api.route('/attendees', attendeesRoutes);
|
||||
api.route('/payments', paymentsRoutes);
|
||||
api.route('/billing', billingRoutes);
|
||||
api.route('/waitlist', waitlistRoutes);
|
||||
api.route('/classes', classesRoutes);
|
||||
api.route('/students', studentStatusRoutes);
|
||||
|
||||
Reference in New Issue
Block a user