Files
sirpremiumv2/app/Http/Controllers/TelegramWebhookController.php
T
LizandroandClaude Sonnet 4.6 2fc2aba8a3 feat: Telegram transactional flows + role pricing + services slider
- New TelegramBotService: full OTP auth, registration, main menu with
  inline keyboards, buy plans, buy promos, recharge (MP + Bre-B),
  credentials, history, profile, agent transfer, photo receipt analysis
- TelegramWebhookController: now handles text, callback_query and photo
- Role-based pricing: tarifas filtered by user rol_id in both web chat
  and Telegram; Preferencial price overrides base tarifa valor
- Services and promos now render as horizontal scroll slider
  (cards_slider tipo_ui) instead of stacked individual cards

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-14 04:36:03 +00:00

47 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Services\TelegramBotService;
use Illuminate\Http\Request;
class TelegramWebhookController extends Controller
{
public function handle(Request $request)
{
$update = $request->all();
$bot = new TelegramBotService();
// Inline keyboard button taps
if (isset($update['callback_query'])) {
$cq = $update['callback_query'];
$chatId = (string) $cq['message']['chat']['id'];
$bot->handleCallback($chatId, $cq['id'], $cq['data'] ?? '');
return response()->json(['ok' => true]);
}
// Photos (payment receipts)
if (isset($update['message']['photo'])) {
$chatId = (string) $update['message']['chat']['id'];
$photos = $update['message']['photo'];
$fileId = end($photos)['file_id'];
$bot->handlePhoto($chatId, $fileId);
return response()->json(['ok' => true]);
}
// Text messages
if (isset($update['message']['text'])) {
$chatId = (string) $update['message']['chat']['id'];
$text = $update['message']['text'];
$nombre = trim(
($update['message']['from']['first_name'] ?? '') . ' ' .
($update['message']['from']['last_name'] ?? '')
);
$bot->handleText($chatId, $text, $nombre);
return response()->json(['ok' => true]);
}
return response()->json(['ok' => true]);
}
}