home
/
u529748449
/
domains
/
borabilhete.com
/
public_html
/
public
➕ New
📤 Upload
✎ Editing:
erro_pagamento.php
← Back
<?php // public/erro_pagamento.php ini_set('display_errors', 1); error_reporting(E_ALL); include __DIR__ . '/../admin/conexao.php'; // --- Entrada --- $motivo = strtolower(trim($_GET['motivo'] ?? '')); $token = $_GET['token'] ?? ''; $extRef = isset($_GET['external_reference']) ? (int)$_GET['external_reference'] : 0; // --- Busca pedido (por external_reference ou token) --- $pedido = null; if ($extRef > 0) { $stmt = $conn->prepare(" SELECT p.id, p.status_pagamento, p.nome_cliente, p.forma_pagamento, p.criado_em, p.token_seguro, e.slug, e.nome AS nome_evento FROM pedidos p JOIN eventos e ON e.id = p.id_evento WHERE p.id = ? LIMIT 1 "); $stmt->bind_param("i", $extRef); $stmt->execute(); $pedido = $stmt->get_result()->fetch_assoc(); } elseif (!empty($token)) { $stmt = $conn->prepare(" SELECT p.id, p.status_pagamento, p.nome_cliente, p.forma_pagamento, p.criado_em, p.token_seguro, e.slug, e.nome AS nome_evento FROM pedidos p JOIN eventos e ON e.id = p.id_evento WHERE p.token_seguro = ? LIMIT 1 "); $stmt->bind_param("s", $token); $stmt->execute(); $pedido = $stmt->get_result()->fetch_assoc(); } // Se encontrou e já está pago, manda para sucesso if ($pedido && ($pedido['status_pagamento'] === 'pago')) { $tk = $pedido['token_seguro'] ?? $token; header('Location: /public/sucesso.php?token=' . urlencode($tk)); exit; } // --- Mensagens por motivo --- function tituloPorMotivo(string $m): string { return match ($m) { 'cancelado' => 'Pagamento cancelado', 'rejected' => 'Pagamento recusado', 'expired' => 'Prazo expirado', 'failure' => 'Falha no pagamento', default => 'Não foi possível concluir o pagamento', }; } function mensagemPorMotivo(string $m): string { return match ($m) { 'cancelado' => 'A operação foi cancelada. Você pode tentar novamente agora.', 'rejected' => 'O emissor não aprovou a transação. Confira os dados e tente outro método ou cartão.', 'expired' => 'O prazo para pagar expirou. Gere um novo pagamento para continuar.', 'failure' => 'Ocorreu uma falha ao processar seu pagamento. Tente novamente em instantes.', default => 'Não conseguimos concluir o pagamento desta vez. Você pode tentar novamente.', }; } $title = tituloPorMotivo($motivo); $desc = mensagemPorMotivo($motivo); // Dados p/ botões e infos $pedidoId = $pedido['id'] ?? null; $forma = $pedido['forma_pagamento'] ?? ''; $slugEvento = $pedido['slug'] ?? ''; $nomeEvento = $pedido['nome_evento'] ?? ''; $tkPedido = $pedido['token_seguro'] ?? ($token ?: ''); // URLs de ação $urlRetry = $pedidoId ? "/public/checkout_mp.php?id=" . urlencode((string)$pedidoId) : ''; $urlEvento = $slugEvento ? "/public/evento/" . rawurlencode($slugEvento) . ".php" : "/public/eventos.php"; $urlStatus = $tkPedido ? "/public/aguardando.php?token=" . urlencode($tkPedido) : ''; ?> <!DOCTYPE html> <html lang="pt-BR"> <head> <meta charset="UTF-8" /> <title><?= htmlspecialchars($title) ?></title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> :root{ --bg:#f7f7f8; --card:#fff; --text:#222; --muted:#666; --danger:#c62828; --primary:#111; --btn:#111; --btnText:#fff; } *{box-sizing:border-box} body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;background:var(--bg);margin:0} .wrap{max-width:720px;margin:40px auto;background:var(--card);border-radius:14px;box-shadow:0 8px 24px rgba(0,0,0,.07);padding:28px} h1{font-size:22px;margin:0 0 8px;color:var(--danger)} p{color:var(--text);margin:8px 0 14px} .muted{color:var(--muted);font-size:14px} .badge{display:inline-block;padding:4px 10px;border-radius:999px;background:#efefef;color:#333;font-size:12px;margin-left:6px} .event{font-weight:600} .actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:16px} a.btn, button.btn{display:inline-block;padding:10px 16px;border-radius:10px;background:var(--btn);color:var(--btnText);text-decoration:none;border:none;cursor:pointer} a.btn.secondary{background:#e7e7e7;color:#111} .tips{background:#fafafa;border:1px solid #eee;border-radius:10px;padding:12px;margin-top:14px} .tips ul{margin:8px 0 0 18px;padding:0} .tips li{margin:6px 0;color:#333} @media (max-width:520px){.actions{flex-direction:column}} </style> </head> <body> <div class="wrap"> <h1>❌ <?= htmlspecialchars($title) ?></h1> <?php if ($nomeEvento): ?> <p>Evento: <span class="event"><?= htmlspecialchars($nomeEvento) ?></span></p> <?php endif; ?> <p><?= htmlspecialchars($desc) ?> <?php if ($forma): ?> <span class="badge">Método: <?= htmlspecialchars($forma) ?></span> <?php endif; ?> </p> <div class="actions"> <?php if ($urlRetry): ?> <a class="btn" href="<?= htmlspecialchars($urlRetry) ?>">Tentar novamente</a> <?php endif; ?> <?php if ($urlStatus): ?> <a class="btn secondary" href="<?= htmlspecialchars($urlStatus) ?>">Ver status do pedido</a> <?php endif; ?> <a class="btn secondary" href="<?= htmlspecialchars($urlEvento) ?>">Voltar ao evento</a> </div> <div class="tips"> <strong>Dicas rápidas:</strong> <ul> <?php if ($motivo === 'rejected'): ?> <li>Verifique os dados do cartão e se há limite disponível.</li> <li>Tente outro cartão, Pix ou outra forma de pagamento.</li> <?php elseif ($motivo === 'expired' || $motivo === 'cancelado'): ?> <li>Para Pix, gere um novo QR Code — ele tem validade curta.</li> <li>Confirme se o app do banco concluiu a transação.</li> <?php else: ?> <li>Se o problema persistir, tente novamente em alguns instantes.</li> <li>Você também pode escolher outro método de pagamento.</li> <?php endif; ?> </ul> <p class="muted">Se precisar de ajuda, entre em contato com o suporte do evento.</p> </div> </div> </body> </html>
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel