false, 'error' => 'Customer ID required']); exit; } try { $pdo = db(); $stmt = $pdo->prepare("SELECT id, points_change, reason, order_id, created_at FROM loyalty_points_history WHERE customer_id = ? ORDER BY created_at DESC LIMIT 50"); $stmt->execute([$customer_id]); $history = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode(['success' => true, 'history' => $history]); } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); }