Your Packages

Select a package to view predictions

// ✅ Paystack Payment Integration (from pay.html) function initiatePayment(packageId, price) { const email = localStorage.getItem('user_email') || ''; const amount = parseInt(price.replace(/[^0-9]/g, '')) * 100; // Convert to kobo const handler = PaystackPop.setup({ key: 'pk_live_b31dbfd6e6220adaf38c0c38238ec2728b327b38', // TODO: Replace with your actual public key email: email, amount: amount, currency: 'NGN', ref: '' + Math.floor((Math.random() * 1000000000) + 1), metadata: { custom_fields: [{ display_name: "Package", variable_name: "package", value: packageId }] }, callback: function(response) { // Payment successful - record purchase recordPurchase(packageId, response.reference); }, onClose: function() { alert('Payment cancelled'); } }); handler.openIframe(); } // ✅ Record successful purchase function recordPurchase(packageId, reference) { const token = localStorage.getItem('auth_token'); fetch('/api/user/purchases', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token }, body: JSON.stringify({ package_id: packageId, reference: reference }) }) .then(res => res.json()) .then(data => { if (data.success) { alert('Payment successful! You can now access ' + packageId); closeModal(); loadPackages(); // Refresh to show purchased content } else { alert('Payment recorded but error: ' + (data.error || 'Unknown')); } }) .catch(err => { alert('Error recording purchase: ' + err.message); }); }