document.addEventListener(‘DOMContentLoaded’, () => { const currentUser = wp_data.user; function loadWallet() { fetch(‘/wp-json/blinkquiz/v1/wallet/’ + currentUser) .then(res => res.json()) .then(data => { document.getElementById(‘wallet-balance’).innerText = data.balance || 0; }); fetch(‘/wp-json/blinkquiz/v1/transactions/’ + currentUser) .then(res => res.json()) .then(data => { const txList = document.getElementById(‘wallet-transactions’); txList.innerHTML = ”; data.forEach(tx => { const li = document.createElement(‘li’); li.textContent = `${tx.type} – ₦${tx.amount} (${tx.status})`; txList.appendChild(li); }); }); } function depositFunds() { const amt = parseInt(document.getElementById(‘depositAmount’).value); if (!amt || amt < 50) return alert('Minimum deposit is ₦50'); fetch('/wp-json/blinkquiz/v1/deposit', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ username: currentUser, amount: amt }) }) .then(res => res.json()) .then(() => { alert(‘Deposit submitted!’); loadWallet(); }); } function requestWithdraw() { const amt = parseInt(document.getElementById(‘withdrawAmount’).value); if (!amt || amt < 100) return alert('Minimum withdrawal is ₦100'); fetch('/wp-json/blinkquiz/v1/withdraw', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ username: currentUser, amount: amt }) }) .then(res => res.json()) .then(() => { alert(‘Withdrawal request submitted!’); loadWallet(); }); } function playPaidQuiz() { if (confirm(“₦50 will be deducted to start the paid quiz. Continue?”)) { fetch(‘/wp-json/blinkquiz/v1/play-paid’, { method: ‘POST’, headers: {‘Content-Type’: ‘application/json’}, body: JSON.stringify({ username: currentUser }) }) .then(res => res.json()) .then(res => { if (res.success) { alert(‘Enjoy your quiz!’); window.location.href = ‘/quiz-page-paid’; } else { alert(res.message || ‘Insufficient balance’); } }); } } window.depositFunds = depositFunds; window.requestWithdraw = requestWithdraw; window.playPaidQuiz = playPaidQuiz; loadWallet(); });

Empowering Youths With Comprehensive ICT Skills While Helping Businesses Thrive In The Online Landscape.

Download Our App

Copyright © 2026 Created and Powered by Blink Tech & IT Consult

preloader image
Building a Brighter Digital Future