feat: custom recharge amount in web chat and Telegram
- Web chat: 'Otro valor' button sets flujo=recarga.monto_custom, next text message is parsed as the amount (min $1.000) - Telegram: '✏️ Otro valor' button sets step=await_amount, next message is parsed and routed to method selection - Preset amounts in Telegram now show 2 per row for compactness Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
2fc2aba8a3
commit
a5bac9cee7
@@ -334,6 +334,21 @@ class PublicChat extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
// Capturar monto personalizado de recarga
|
||||
if ($this->flujo === 'recarga.monto_custom') {
|
||||
$monto = (int) preg_replace('/\D/', '', $texto);
|
||||
if ($monto >= 1000) {
|
||||
$this->flujo = '';
|
||||
$this->flujoData = [];
|
||||
$this->elegirMetodoRecarga($monto);
|
||||
} else {
|
||||
$this->guardarMensajeBot($this->convId, "El monto debe ser al menos $1.000. Escríbelo de nuevo:");
|
||||
}
|
||||
$this->cargarMensajes();
|
||||
$this->dispatchBrowserEvent('scroll-chat');
|
||||
return;
|
||||
}
|
||||
|
||||
$accionIA = $this->detectarIntencionIA($texto);
|
||||
|
||||
if ($accionIA) {
|
||||
@@ -369,6 +384,7 @@ class PublicChat extends Component
|
||||
$action === 'promo.comprar.saldo' => $this->comprarPromoConSaldo((int) ($data['id'] ?? 0)),
|
||||
$action === 'promo.comprar.mp' => $this->comprarPromoConMP((int) ($data['id'] ?? 0)),
|
||||
$action === 'recarga.iniciar' => $this->mostrarFormRecarga(),
|
||||
$action === 'recarga.otro_valor' => $this->solicitarMontoPersonalizado(),
|
||||
$action === 'recarga.elegir_metodo' => $this->elegirMetodoRecarga((int) ($data['monto'] ?? 0)),
|
||||
$action === 'recarga.mp' => $this->generarLinkRecargaMP((int) ($data['monto'] ?? 0)),
|
||||
$action === 'recarga.transferencia' => $this->mostrarTransferencia((int) ($data['monto'] ?? 0)),
|
||||
@@ -875,7 +891,8 @@ class PublicChat extends Component
|
||||
foreach ([20000, 50000, 100000, 200000, 500000] as $m) {
|
||||
$botones[] = ['label' => '$' . number_format($m), 'action' => 'recarga.elegir_metodo', 'data' => ['monto' => $m]];
|
||||
}
|
||||
$botones[] = ['label' => 'Volver', 'action' => 'menu.principal', 'data' => []];
|
||||
$botones[] = ['label' => 'Otro valor', 'action' => 'recarga.otro_valor', 'data' => []];
|
||||
$botones[] = ['label' => 'Volver', 'action' => 'menu.principal', 'data' => []];
|
||||
|
||||
ChatMessage::create([
|
||||
'conversation_id' => $this->convId,
|
||||
@@ -887,6 +904,13 @@ class PublicChat extends Component
|
||||
]);
|
||||
}
|
||||
|
||||
private function solicitarMontoPersonalizado(): void
|
||||
{
|
||||
$this->flujo = 'recarga.monto_custom';
|
||||
$this->flujoData = [];
|
||||
$this->guardarMensajeBot($this->convId, "Escribe el monto que deseas recargar (mínimo $1.000):");
|
||||
}
|
||||
|
||||
private function elegirMetodoRecarga(int $monto): void
|
||||
{
|
||||
if ($monto <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user