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:
@@ -7,6 +7,8 @@ import type {
|
||||
AttendeeList,
|
||||
AttendeeStats,
|
||||
AttendeeStatus,
|
||||
BillingChargeList,
|
||||
BillingStatusDto,
|
||||
BulkCreateAttendees,
|
||||
BulkCreateAttendeesResult,
|
||||
ClassTodayList,
|
||||
@@ -49,8 +51,12 @@ import type {
|
||||
RejectGroupPreRegistrationResult,
|
||||
RemoveAttendeeResult,
|
||||
RemoveGroupWaitlistEntryResult,
|
||||
SelectPlanInput,
|
||||
SelectPlanResultDto,
|
||||
SessionStudents,
|
||||
StudentsAtRisk,
|
||||
SubscribeInput,
|
||||
SubscribeResultDto,
|
||||
UpdateAttendee,
|
||||
UpdateStudentStatusResult,
|
||||
GroupAutomationsDto,
|
||||
@@ -112,6 +118,14 @@ export const createFirstGroup = (payload: CreateFirstGroup) =>
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
/* Paso obligatorio "Plan" del onboarding. Con Pro devuelve `checkoutUrl`: el
|
||||
navegador navega a Mercado Pago y vuelve a `/onboarding?sub=return`. */
|
||||
export const selectPlan = (payload: SelectPlanInput) =>
|
||||
apiFetch<SelectPlanResultDto>('/api/v1/onboarding/plan', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const createGroup = (payload: CreateFirstGroup) =>
|
||||
apiFetch<CreateGroupResult>('/api/v1/groups', {
|
||||
method: 'POST',
|
||||
@@ -131,6 +145,24 @@ export const getMpStatus = () => apiFetch<MpStatusDto>('/api/v1/mp/status')
|
||||
export const disconnectMp = () =>
|
||||
apiFetch<MpDisconnectResultDto>('/api/v1/mp/connect', { method: 'DELETE' })
|
||||
|
||||
// — Plan de Gruperly (suscripción a Pro con Mercado Pago) —
|
||||
|
||||
export const getBillingStatus = () => apiFetch<BillingStatusDto>('/api/v1/billing/status')
|
||||
|
||||
/* Igual que la vinculación de MP: el backend devuelve a dónde navegar y Mercado
|
||||
Pago devuelve el control a `/billing?sub=return`. */
|
||||
export const subscribeToPro = (payload: SubscribeInput) =>
|
||||
apiFetch<SubscribeResultDto>('/api/v1/billing/subscribe', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const cancelSubscription = () =>
|
||||
apiFetch<{ status: string }>('/api/v1/billing/cancel', { method: 'POST' })
|
||||
|
||||
export const getBillingCharges = (page = 1) =>
|
||||
apiFetch<BillingChargeList>(`/api/v1/billing/charges?page=${page}&pageSize=10`)
|
||||
|
||||
// --- WhatsApp (recordatorios y reenganche automáticos) ---
|
||||
|
||||
export const startWhatsappConnection = (returnTo: WhatsappReturnTo) =>
|
||||
|
||||
Reference in New Issue
Block a user