4 mejoras en canales de comunicación con el cliente
1. Reintentos automáticos (Telegram Job): usa autoAplicarRecarga para ejecutar la compra pendiente automáticamente al confirmar el pago, sin botón extra. 2. Pagar servicio directo con Bre-B sin recargar saldo previamente (ambos canales): botón 'Pagar con Bre-B directo' en el flujo de compra con saldo insuficiente. 3. Mensaje de gracias + bloque de credenciales fácil de copiar al entregar servicio: Telegram usa bloque de código (tiene botón Copy nativo), Chat Web muestra el texto completo de gracias con copia por campo y botón 'Copiar todo'. 4. Botón copiar llave Bre-B: ya existía en Chat Web, confirmado sin cambio. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
932a9b43c7
commit
1245d255bb
@@ -133,24 +133,26 @@ class TelegramBotService
|
||||
'menu' => $this->showMainMenu($chatId),
|
||||
'logout_ask' => $this->showLogoutConfirmation($chatId),
|
||||
'logout_confirm' => $this->confirmLogout($chatId),
|
||||
'svc_list' => $this->listServices($chatId),
|
||||
'svc_view' => $this->viewService($chatId, (int) ($parts[1] ?? 0)),
|
||||
'buy_start' => $this->startPurchase($chatId, (int) ($parts[1] ?? 0)),
|
||||
'buy_saldo' => $this->payWithSaldo($chatId),
|
||||
'promo_list' => $this->listPromos($chatId),
|
||||
'promo_view' => $this->viewPromo($chatId, (int) ($parts[1] ?? 0)),
|
||||
'promo_saldo' => $this->buyPromoSaldo($chatId, (int) ($parts[1] ?? 0)),
|
||||
'rec_init' => $this->showRechargeAmounts($chatId),
|
||||
'rec_custom' => $this->askCustomAmount($chatId),
|
||||
'rec_amount' => $this->chooseRechargeMethod($chatId, (int) ($parts[1] ?? 0)),
|
||||
'rec_breb' => $this->askRemitenteNombre($chatId, (int) ($parts[1] ?? 0)),
|
||||
'breb_nom' => $this->seleccionarNombreRemitente($chatId, (string) ($parts[1] ?? 'nuevo')),
|
||||
'creds' => $this->showCredentials($chatId),
|
||||
'history' => $this->showHistory($chatId),
|
||||
'profile' => $this->showProfile($chatId),
|
||||
'agent' => $this->showMainMenu($chatId),
|
||||
'pay_retry' => $this->retryPayment($chatId),
|
||||
default => $this->showMainMenu($chatId),
|
||||
'svc_list' => $this->listServices($chatId),
|
||||
'svc_view' => $this->viewService($chatId, (int) ($parts[1] ?? 0)),
|
||||
'buy_start' => $this->startPurchase($chatId, (int) ($parts[1] ?? 0)),
|
||||
'buy_saldo' => $this->payWithSaldo($chatId),
|
||||
'breb_tarifa' => $this->startDirectBrebPayment($chatId, (int) ($parts[1] ?? 0), (int) ($parts[2] ?? 0)),
|
||||
'promo_list' => $this->listPromos($chatId),
|
||||
'promo_view' => $this->viewPromo($chatId, (int) ($parts[1] ?? 0)),
|
||||
'promo_saldo' => $this->buyPromoSaldo($chatId, (int) ($parts[1] ?? 0)),
|
||||
'breb_promo' => $this->startDirectBrebPromo($chatId, (int) ($parts[1] ?? 0), (int) ($parts[2] ?? 0)),
|
||||
'rec_init' => $this->showRechargeAmounts($chatId),
|
||||
'rec_custom' => $this->askCustomAmount($chatId),
|
||||
'rec_amount' => $this->chooseRechargeMethod($chatId, (int) ($parts[1] ?? 0)),
|
||||
'rec_breb' => $this->askRemitenteNombre($chatId, (int) ($parts[1] ?? 0)),
|
||||
'breb_nom' => $this->seleccionarNombreRemitente($chatId, (string) ($parts[1] ?? 'nuevo')),
|
||||
'creds' => $this->showCredentials($chatId),
|
||||
'history' => $this->showHistory($chatId),
|
||||
'profile' => $this->showProfile($chatId),
|
||||
'agent' => $this->showMainMenu($chatId),
|
||||
'pay_retry' => $this->retryPayment($chatId),
|
||||
default => $this->showMainMenu($chatId),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -823,7 +825,6 @@ class TelegramBotService
|
||||
} else {
|
||||
$falta = $valor - $saldo;
|
||||
|
||||
// Guardar compra pendiente para ejecutarla automáticamente tras recargar
|
||||
$state['data']['pending_purchase'] = [
|
||||
'type' => 'tarifa',
|
||||
'tarifa_id' => $tarifaId,
|
||||
@@ -833,12 +834,13 @@ class TelegramBotService
|
||||
];
|
||||
$this->setState($chatId, $state);
|
||||
|
||||
$buttons[] = [['text' => "💰 Recargar \$" . number_format($falta) . " para comprar {$tarifa->servicio->nombre}", 'callback_data' => 'rec_init']];
|
||||
$buttons[] = [['text' => "💳 Pagar con Bre-B directo (\$" . number_format($valor) . ")", 'callback_data' => 'breb_tarifa|' . $tarifaId . '|' . $valor]];
|
||||
$buttons[] = [['text' => "💰 Recargar saldo (\$" . number_format($falta) . " faltantes)", 'callback_data' => 'rec_init']];
|
||||
$buttons[] = [['text' => '🔙 Ver planes', 'callback_data' => 'svc_view|' . $tarifa->servicio_id]];
|
||||
|
||||
$this->sendWithKeyboard(
|
||||
$chatId,
|
||||
"*{$tarifa->servicio->nombre}* — {$detalle}\nPrecio: *\$" . number_format($valor) . "*\n\nSaldo actual: \$" . number_format($saldo) . " — te faltan *\$" . number_format($falta) . "*\n\nRecarga para continuar:",
|
||||
"*{$tarifa->servicio->nombre}* — {$detalle}\nPrecio: *\$" . number_format($valor) . "*\n\nSaldo actual: \$" . number_format($saldo) . " — te faltan *\$" . number_format($falta) . "*\n\n¿Cómo quieres pagar?",
|
||||
$buttons
|
||||
);
|
||||
}
|
||||
@@ -896,18 +898,22 @@ class TelegramBotService
|
||||
$saldo->update(['valor' => $nuevoSaldo]);
|
||||
});
|
||||
|
||||
$text = "✅ *¡Compra exitosa!*\n\n";
|
||||
$text .= "🎬 *{$tarifa->servicio->nombre}*\n";
|
||||
$text .= "📧 Email: `{$cuenta->correo}`\n";
|
||||
$text .= "🔑 Password: `{$cuenta->password}`\n";
|
||||
if ($tarifa->pantallas) {
|
||||
$text .= "📺 Perfil: {$tarifa->pantallas}\n";
|
||||
}
|
||||
$text .= "📅 Vence: " . now()->addDays($tarifa->dias)->format('d/m/Y') . "\n";
|
||||
$text .= "💰 Pagado: *\$" . number_format($precio) . "*\n";
|
||||
$text .= "\nSaldo restante: *\$" . number_format($nuevoSaldo) . "*";
|
||||
$this->send($chatId,
|
||||
"🎉 *¡Muchas gracias por tu compra!*\n\n" .
|
||||
"Disfruta tu servicio. Si tienes algún inconveniente no dudes en escribirnos, estamos aquí para ayudarte. 😊"
|
||||
);
|
||||
|
||||
$this->send($chatId, $text);
|
||||
$code = "```\n";
|
||||
$code .= "Servicio: {$tarifa->servicio->nombre}\n";
|
||||
$code .= "Email: {$cuenta->correo}\n";
|
||||
$code .= "Password: {$cuenta->password}\n";
|
||||
if ($tarifa->pantallas) {
|
||||
$code .= "Perfil: {$tarifa->pantallas}\n";
|
||||
}
|
||||
$code .= "Vence: " . now()->addDays($tarifa->dias)->format('d/m/Y') . "\n";
|
||||
$code .= "Pagado: \$" . number_format($precio) . "\n";
|
||||
$code .= "```";
|
||||
$this->send($chatId, $code);
|
||||
|
||||
$state['data'] = [];
|
||||
$this->setState($chatId, $state);
|
||||
@@ -915,6 +921,49 @@ class TelegramBotService
|
||||
}
|
||||
|
||||
|
||||
// ─── Direct Bre-B purchase (sin saldo previo) ────────────
|
||||
|
||||
private function startDirectBrebPayment(string $chatId, int $tarifaId, int $valor): void
|
||||
{
|
||||
$state = $this->getState($chatId);
|
||||
$tarifa = Tarifas::with('servicio')->find($tarifaId);
|
||||
|
||||
if (! $tarifa) {
|
||||
$this->send($chatId, "Plan no encontrado.");
|
||||
return;
|
||||
}
|
||||
|
||||
$state['data']['pending_purchase'] = [
|
||||
'type' => 'tarifa',
|
||||
'tarifa_id' => $tarifaId,
|
||||
'valor' => $valor,
|
||||
'servicio' => $tarifa->servicio->nombre,
|
||||
'servicio_id' => $tarifa->servicio_id,
|
||||
];
|
||||
$this->setState($chatId, $state);
|
||||
$this->askRemitenteNombre($chatId, $valor);
|
||||
}
|
||||
|
||||
private function startDirectBrebPromo(string $chatId, int $promoId, int $precio): void
|
||||
{
|
||||
$state = $this->getState($chatId);
|
||||
$promo = \App\Models\Promociones::find($promoId);
|
||||
|
||||
if (! $promo) {
|
||||
$this->send($chatId, "Promoción no encontrada.");
|
||||
return;
|
||||
}
|
||||
|
||||
$state['data']['pending_purchase'] = [
|
||||
'type' => 'promo',
|
||||
'promo_id' => $promoId,
|
||||
'valor' => $precio,
|
||||
'nombre' => $promo->nombre ?? 'Promoción',
|
||||
];
|
||||
$this->setState($chatId, $state);
|
||||
$this->askRemitenteNombre($chatId, $precio);
|
||||
}
|
||||
|
||||
// ─── Promos ───────────────────────────────────────────────
|
||||
|
||||
private function listPromos(string $chatId): void
|
||||
@@ -997,7 +1046,6 @@ class TelegramBotService
|
||||
} else {
|
||||
$falta = $precio - $saldo;
|
||||
|
||||
// Guardar compra pendiente para ejecutarla automáticamente tras recargar
|
||||
$state = $this->getState($chatId);
|
||||
$state['data']['pending_purchase'] = [
|
||||
'type' => 'promo',
|
||||
@@ -1007,12 +1055,13 @@ class TelegramBotService
|
||||
];
|
||||
$this->setState($chatId, $state);
|
||||
|
||||
$buttons[] = [['text' => "💰 Recargar \$" . number_format($falta) . " para comprar " . ($promo->nombre ?? 'Promo'), 'callback_data' => 'rec_init']];
|
||||
$buttons[] = [['text' => "💳 Pagar con Bre-B directo (\$" . number_format($precio) . ")", 'callback_data' => 'breb_promo|' . $promoId . '|' . $precio]];
|
||||
$buttons[] = [['text' => "💰 Recargar saldo (\$" . number_format($falta) . " faltantes)", 'callback_data' => 'rec_init']];
|
||||
$buttons[] = [['text' => '🔙 Promociones', 'callback_data' => 'promo_list']];
|
||||
|
||||
$this->sendWithKeyboard(
|
||||
$chatId,
|
||||
"*{$promo->nombre}*\n\$" . number_format($precio) . "\n\nSaldo actual: \$" . number_format($saldo) . " — te faltan *\$" . number_format($falta) . "*\n\nRecarga para continuar:",
|
||||
"*{$promo->nombre}*\n\$" . number_format($precio) . "\n\nSaldo actual: \$" . number_format($saldo) . " — te faltan *\$" . number_format($falta) . "*\n\n¿Cómo quieres pagar?",
|
||||
$buttons
|
||||
);
|
||||
}
|
||||
@@ -1074,14 +1123,19 @@ class TelegramBotService
|
||||
$saldo->update(['valor' => $nuevoSaldo]);
|
||||
});
|
||||
|
||||
$text = "✅ *¡Promo activada!*\n\n";
|
||||
$text .= "🎬 *{$promo->nombre}*\n";
|
||||
$text .= "📧 Email: `{$cuenta->correo}`\n";
|
||||
$text .= "🔑 Password: `{$cuenta->password}`\n";
|
||||
$text .= "📅 Vence: " . now()->addDays($dias)->format('d/m/Y') . "\n";
|
||||
$text .= "\nSaldo restante: *\$" . number_format($nuevoSaldo) . "*";
|
||||
$this->send($chatId,
|
||||
"🎉 *¡Muchas gracias por tu compra!*\n\n" .
|
||||
"Disfruta tu servicio. Si tienes algún inconveniente no dudes en escribirnos, estamos aquí para ayudarte. 😊"
|
||||
);
|
||||
|
||||
$this->send($chatId, $text);
|
||||
$code = "```\n";
|
||||
$code .= "Promoción: {$promo->nombre}\n";
|
||||
$code .= "Email: {$cuenta->correo}\n";
|
||||
$code .= "Password: {$cuenta->password}\n";
|
||||
$code .= "Vence: " . now()->addDays($dias)->format('d/m/Y') . "\n";
|
||||
$code .= "Pagado: \$" . number_format($precio) . "\n";
|
||||
$code .= "```";
|
||||
$this->send($chatId, $code);
|
||||
$this->showMainMenu($chatId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user