- Prefijo v2: MCH - TRACEABILITY-MASTER.yml creado - Listo para integracion como submodulo Workspace: v2.0.0 | SIMCO: v4.0.0
280 lines
7.1 KiB
Markdown
280 lines
7.1 KiB
Markdown
# Tareas Pendientes - Integraciones Externas
|
|
|
|
**Fecha creacion**: 2026-01-07
|
|
**Version**: 1.0.0
|
|
**Autor**: @PERFIL_DEVENV
|
|
**Estado**: Listo para asignacion
|
|
|
|
---
|
|
|
|
## Resumen
|
|
|
|
Este documento describe las tareas pendientes que requieren configuracion externa para completar el proyecto MiChangarrito al 100%.
|
|
|
|
**Progreso actual**: 95% (37/39 tareas)
|
|
**Tareas pendientes**: 2
|
|
|
|
---
|
|
|
|
## Tarea 1: Configurar Meta Business para WhatsApp
|
|
|
|
### Descripcion
|
|
|
|
Configurar cuenta Meta Business verificada para habilitar webhooks de WhatsApp Business API.
|
|
|
|
### Prerequisitos
|
|
|
|
- [ ] Cuenta de Facebook Business Manager
|
|
- [ ] Numero de telefono dedicado para WhatsApp Business
|
|
- [ ] Acceso a dominio para verificacion
|
|
|
|
### Pasos
|
|
|
|
1. **Crear cuenta en Meta Business**
|
|
- Ir a business.facebook.com
|
|
- Crear cuenta de negocio
|
|
- Verificar identidad del negocio
|
|
|
|
2. **Configurar WhatsApp Business Platform**
|
|
- En Meta Developer, crear app tipo "Business"
|
|
- Agregar producto "WhatsApp"
|
|
- Configurar numero de telefono
|
|
|
|
3. **Generar Access Token permanente**
|
|
- Crear System User en Business Manager
|
|
- Asignar permisos: `whatsapp_business_messaging`, `whatsapp_business_management`
|
|
- Generar token permanente
|
|
|
|
4. **Configurar Webhook**
|
|
- URL: `https://{DOMAIN}/webhook/whatsapp`
|
|
- Verify Token: (definido en .env)
|
|
- Suscribirse a: `messages`, `message_status`
|
|
|
|
5. **Actualizar variables de entorno**
|
|
|
|
```env
|
|
# WhatsApp Business API
|
|
WHATSAPP_ACCESS_TOKEN=<token_permanente>
|
|
WHATSAPP_PHONE_NUMBER_ID=<phone_number_id>
|
|
WHATSAPP_BUSINESS_ACCOUNT_ID=<business_account_id>
|
|
WHATSAPP_VERIFY_TOKEN=<verify_token>
|
|
WHATSAPP_WEBHOOK_URL=https://{DOMAIN}/webhook/whatsapp
|
|
```
|
|
|
|
### Validacion
|
|
|
|
```bash
|
|
# Verificar webhook
|
|
curl -X POST https://{DOMAIN}/webhook/whatsapp \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"object":"whatsapp_business_account","entry":[]}'
|
|
|
|
# Verificar envio de mensaje
|
|
curl -X POST "https://graph.facebook.com/v18.0/{PHONE_NUMBER_ID}/messages" \
|
|
-H "Authorization: Bearer {ACCESS_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"messaging_product":"whatsapp","to":"{PHONE}","type":"text","text":{"body":"Test"}}'
|
|
```
|
|
|
|
### Archivos a modificar
|
|
|
|
| Archivo | Cambio |
|
|
|---------|--------|
|
|
| `.env` | Agregar credenciales WhatsApp |
|
|
| `.env.docker` | Agregar credenciales WhatsApp |
|
|
|
|
### Referencias
|
|
|
|
- [Meta Business Platform](https://business.facebook.com/)
|
|
- [WhatsApp Business API Docs](https://developers.facebook.com/docs/whatsapp/cloud-api/)
|
|
- `docs/02-especificaciones/INTEGRACIONES-EXTERNAS.md`
|
|
- `apps/whatsapp-service/src/webhook/webhook.controller.ts`
|
|
|
|
---
|
|
|
|
## Tarea 2: Configurar Stripe para Produccion
|
|
|
|
### Descripcion
|
|
|
|
Migrar de modo sandbox a produccion con API keys reales de Stripe.
|
|
|
|
### Prerequisitos
|
|
|
|
- [ ] Cuenta Stripe verificada
|
|
- [ ] Informacion bancaria configurada
|
|
- [ ] Dominio con SSL para webhooks
|
|
|
|
### Pasos
|
|
|
|
1. **Activar cuenta Stripe**
|
|
- Completar verificacion de negocio
|
|
- Agregar informacion bancaria
|
|
- Configurar metodos de pago aceptados
|
|
|
|
2. **Crear productos y precios**
|
|
|
|
```bash
|
|
# Plan Emprendedor
|
|
stripe products create --name="Plan Emprendedor" --description="Para negocios en crecimiento"
|
|
stripe prices create --product={PRODUCT_ID} --unit-amount=19900 --currency=mxn --recurring[interval]=month
|
|
|
|
# Plan Negocio
|
|
stripe products create --name="Plan Negocio" --description="Para negocios establecidos"
|
|
stripe prices create --product={PRODUCT_ID} --unit-amount=49900 --currency=mxn --recurring[interval]=month
|
|
|
|
# Plan Enterprise
|
|
stripe products create --name="Plan Enterprise" --description="Para cadenas y franquicias"
|
|
stripe prices create --product={PRODUCT_ID} --unit-amount=99900 --currency=mxn --recurring[interval]=month
|
|
```
|
|
|
|
3. **Configurar webhook endpoint**
|
|
- URL: `https://{DOMAIN}/billing/webhooks`
|
|
- Eventos:
|
|
- `customer.subscription.created`
|
|
- `customer.subscription.updated`
|
|
- `customer.subscription.deleted`
|
|
- `invoice.paid`
|
|
- `invoice.payment_failed`
|
|
|
|
4. **Actualizar variables de entorno**
|
|
|
|
```env
|
|
# Stripe Production
|
|
STRIPE_SECRET_KEY=sk_live_xxx
|
|
STRIPE_PUBLISHABLE_KEY=pk_live_xxx
|
|
STRIPE_WEBHOOK_SECRET=whsec_xxx
|
|
|
|
# Price IDs (actualizar con IDs reales)
|
|
STRIPE_PRICE_EMPRENDEDOR=price_xxx
|
|
STRIPE_PRICE_NEGOCIO=price_xxx
|
|
STRIPE_PRICE_ENTERPRISE=price_xxx
|
|
```
|
|
|
|
5. **Actualizar seeds de planes**
|
|
|
|
Archivo: `database/seeds/01-plans.sql`
|
|
|
|
```sql
|
|
UPDATE subscriptions.plans
|
|
SET stripe_price_id_monthly = 'price_xxx',
|
|
stripe_price_id_annual = 'price_xxx'
|
|
WHERE code = 'emprendedor';
|
|
-- Repetir para otros planes
|
|
```
|
|
|
|
### Validacion
|
|
|
|
```bash
|
|
# Verificar conexion Stripe
|
|
curl https://api.stripe.com/v1/customers \
|
|
-u sk_live_xxx:
|
|
|
|
# Verificar webhook
|
|
stripe listen --forward-to https://{DOMAIN}/billing/webhooks
|
|
|
|
# Crear suscripcion de prueba
|
|
curl -X POST https://{DOMAIN}/billing/subscribe \
|
|
-H "Authorization: Bearer {JWT}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"planCode":"emprendedor"}'
|
|
```
|
|
|
|
### Archivos a modificar
|
|
|
|
| Archivo | Cambio |
|
|
|---------|--------|
|
|
| `.env` | Actualizar keys Stripe |
|
|
| `.env.docker` | Actualizar keys Stripe |
|
|
| `database/seeds/01-plans.sql` | Actualizar price IDs |
|
|
|
|
### Referencias
|
|
|
|
- [Stripe Dashboard](https://dashboard.stripe.com/)
|
|
- [Stripe API Docs](https://stripe.com/docs/api)
|
|
- `apps/backend/src/modules/billing/stripe.service.ts`
|
|
- `apps/backend/src/modules/billing/webhooks.controller.ts`
|
|
|
|
---
|
|
|
|
## Tarea 3 (Opcional): Configurar LLM Provider
|
|
|
|
### Descripcion
|
|
|
|
Configurar proveedor de LLM para el asistente IA.
|
|
|
|
### Opciones
|
|
|
|
| Proveedor | Costo | Latencia | Calidad |
|
|
|-----------|-------|----------|---------|
|
|
| OpenAI | Alto | Baja | Alta |
|
|
| OpenRouter | Medio | Media | Alta |
|
|
| Anthropic | Alto | Baja | Alta |
|
|
| Ollama | Gratis | Local | Media |
|
|
|
|
### Variables de entorno
|
|
|
|
```env
|
|
# Opcion 1: OpenAI
|
|
LLM_PROVIDER=openai
|
|
OPENAI_API_KEY=sk-xxx
|
|
LLM_MODEL=gpt-4o-mini
|
|
|
|
# Opcion 2: OpenRouter
|
|
LLM_PROVIDER=openrouter
|
|
OPENROUTER_API_KEY=sk-or-xxx
|
|
LLM_MODEL=anthropic/claude-3-haiku
|
|
LLM_BASE_URL=https://openrouter.ai/api/v1
|
|
|
|
# Opcion 3: Ollama (local)
|
|
LLM_PROVIDER=ollama
|
|
LLM_MODEL=llama2
|
|
LLM_BASE_URL=http://localhost:11434/v1
|
|
```
|
|
|
|
---
|
|
|
|
## Checklist de Completitud
|
|
|
|
### Pre-produccion
|
|
|
|
- [ ] Tarea 1: Meta Business configurado
|
|
- [ ] Tarea 2: Stripe produccion configurado
|
|
- [ ] Tarea 3: LLM provider configurado
|
|
- [ ] Dominio configurado con SSL
|
|
- [ ] Variables de entorno actualizadas
|
|
- [ ] Docker compose funcionando
|
|
|
|
### Post-configuracion
|
|
|
|
- [ ] Webhook WhatsApp verificado
|
|
- [ ] Webhook Stripe verificado
|
|
- [ ] Mensaje de prueba WhatsApp enviado
|
|
- [ ] Suscripcion de prueba creada
|
|
- [ ] LLM respondiendo correctamente
|
|
|
|
---
|
|
|
|
## Asignacion
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| Perfil recomendado | @PERFIL_DEVOPS o @PERFIL_BACKEND |
|
|
| Prioridad | Alta |
|
|
| Bloqueador | Si (para produccion) |
|
|
| Dependencias | Servidor de produccion, dominio SSL |
|
|
|
|
---
|
|
|
|
## Referencias Generales
|
|
|
|
- `orchestration/PLAN-IMPLEMENTACION.md` - Plan maestro
|
|
- `orchestration/PROJECT-STATUS.md` - Estado actual
|
|
- `orchestration/reportes/REPORTE-IMPLEMENTACION-2026-01-07.md` - Ultimo reporte
|
|
- `docs/02-especificaciones/INTEGRACIONES-EXTERNAS.md` - Especificacion de integraciones
|
|
- `.env.example` - Template de variables
|
|
|
|
---
|
|
|
|
**Documento creado**: 2026-01-07
|
|
**Proxima revision**: Al completar tareas
|