referencias stripe corregidas

This commit is contained in:
DANYDHSV 2026-04-06 13:58:11 -06:00
parent 01f42e07d7
commit d680132d3e
3 changed files with 1058 additions and 3 deletions

File diff suppressed because it is too large Load Diff

View File

@ -425,6 +425,26 @@ if (isset($_GET['action'])) {
// POST Actions for Intents // POST Actions for Intents
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
header('Content-Type: application/json'); header('Content-Type: application/json');
if ($_POST['action'] === 'create_intent') {
try {
$clientId = $_POST['clientId'] ?? null;
$amount = (float)($_POST['amount'] ?? 0);
$stripeCustomerId = $_POST['stripeCustomerId'] ?? null;
$adminId = $_POST['adminId'] ?? null;
if (!$clientId || !$amount || !$stripeCustomerId) {
throw new \Exception("Datos incompletos para crear intención de pago.");
}
if (ob_get_length()) ob_clean();
$result = $paymentIntentService->createPaymentIntent($clientId, $amount, $stripeCustomerId, $adminId);
echo json_encode($result);
} catch (\Exception $e) {
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}
exit;
}
if ($_POST['action'] === 'create_oxxo_intent') { if ($_POST['action'] === 'create_oxxo_intent') {
try { try {
$builder = new \DI\ContainerBuilder(); $builder = new \DI\ContainerBuilder();

View File

@ -178,11 +178,38 @@
function showStripeResult(data) { function showStripeResult(data) {
const c = document.getElementById('stripeResultContent'); const c = document.getElementById('stripeResultContent');
c.innerHTML = `<h3 style="color:var(--success);text-align:center">¡Referencia Creada!</h3><p style="text-align:center">Monto: $${data.amount}</p>`; let html = `<div style="text-align:center; margin-bottom: 20px;">
<h3 style="color:var(--success); margin-bottom: 5px;">¡Referencia Creada!</h3>
<p style="font-size: 1.1rem; color: var(--text-main);">Monto: <strong>$${data.amount} MXN</strong></p>
</div>`;
if (data.next_action?.display_bank_transfer_instructions) { if (data.next_action?.display_bank_transfer_instructions) {
const i = data.next_action.display_bank_transfer_instructions.financial_addresses[0].spei; const instr = data.next_action.display_bank_transfer_instructions;
c.innerHTML += `<div style="background:#f1f5f9;padding:15px;border-radius:8px;margin-top:10px"><p><strong>Banco:</strong> ${i.bank_name}</p><p><strong>CLABE:</strong> ${i.clabe}</p></div>`; const spei = instr.financial_addresses[0]?.spei;
if (spei) {
html += `
<div style="background:#f8fafc; border: 1px solid #e2e8f0; padding:1.5rem; border-radius:12px; color: #1e293b; text-align: left;">
<div style="margin-bottom: 1rem;">
<span style="display:block; font-size: 0.8rem; color: #64748b; text-transform: uppercase; font-weight: 600;">Institución Bancaria</span>
<strong style="font-size: 1.1rem;">${spei.bank_name}</strong>
</div>
<div style="margin-bottom: 0;">
<span style="display:block; font-size: 0.8rem; color: #64748b; text-transform: uppercase; font-weight: 600;">CLABE Interbancaria</span>
<strong style="font-size: 1.3rem; letter-spacing: 1px; font-family: monospace; display: block; margin-top: 5px;">${spei.clabe}</strong>
</div>
</div>
<p style="font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-top: 1.5rem;">
Realiza tu transferencia vía SPEI con estos datos. El pago se registrará automáticamente al recibirse.
</p>`;
}
} else {
html += `<div style="background:rgba(255,165,0,0.1); padding: 15px; border-radius: 8px; border: 1px solid orange; color: orange; text-align:center;">
No se encontró información de transferencia. Por favor, revisa el historial.
</div>`;
} }
c.innerHTML = html;
document.getElementById('stripeResultModal').style.display = 'flex'; document.getElementById('stripeResultModal').style.display = 'flex';
} }