loadConfig(); $ipServer = $config['ipServer'] ?? ''; $baseUrl = 'https://' . $ipServer; $apiUcrmKey = $config['apiTokenUcrm'] ?? ''; $stripeApiKey = $config['apiTokenStripe'] ?? ''; $service = new PaymentIntentService($baseUrl, $apiUcrmKey, $stripeApiKey); // --- ROUTER --- $action = $_GET['action'] ?? 'view'; // 1. Image Handler if ($action === 'image') { $filename = basename($_GET['file'] ?? ''); $path = __DIR__ . '/img/' . $filename; if ($filename && file_exists($path)) { $mime = mime_content_type($path); header("Content-Type: $mime"); readfile($path); } else { http_response_code(404); echo "Image not found"; } exit; } // 2. Search Handler (AJAX) if ($action === 'search') { $query = $_GET['q'] ?? ''; if (strlen($query) < 2) { echo json_encode([]); exit; } $results = $service->searchClients($query); header('Content-Type: application/json'); echo json_encode($results); exit; } // 3. Get Details Handler (AJAX) if ($action === 'details') { $clientId = $_GET['id'] ?? 0; if (!$clientId) { echo json_encode(['error' => 'No ID provided']); exit; } $details = $service->getClientDetails($clientId); header('Content-Type: application/json'); echo json_encode($details); exit; } // 4. Create Intent Handler (AJAX) if ($action === 'create_intent') { $input = json_decode(file_get_contents('php://input'), true); $clientId = $input['clientId'] ?? 0; $amount = filter_var($input['amount'], FILTER_VALIDATE_FLOAT); $stripeCustomerId = $input['stripeCustomerId'] ?? ''; // Hardcoded admin ID as per user context in previous script (fallback) // In a real plugin, we might want to get this from a mapping or config, but for now specific ID or 1 $adminId = 5472; if (!$amount || $amount < 10) { echo json_encode(['success' => false, 'error' => 'El monto debe ser mayor a $10.00 MXN']); exit; } if (!$stripeCustomerId) { echo json_encode(['success' => false, 'error' => 'El cliente no tiene Stripe Customer ID']); exit; } $result = $service->createPaymentIntent($clientId, $amount, $stripeCustomerId, $adminId); // Logging for debug $log->appendLog("Create Intent Result: " . json_encode($result)); header('Content-Type: application/json'); echo json_encode($result); exit; } // --- VIEW (HTML) --- ?> Generar Payment Intent
Logo

Generar Intenci贸n de Pago

Busca un cliente para generar un cobro v铆a Stripe

馃攳
Nombre
--
ID Cliente
--
Stripe Customer ID
--
Email
--
Saldo Pendiente
--
M铆nimo $10.00 MXN