/** * Koha Success Page - Donation Verification */ // Get session ID from URL const urlParams = new URLSearchParams(window.location.search); const sessionId = urlParams.get('session_id'); // Verify donation async function verifyDonation() { if (!sessionId) { // No session ID - just show success message document.getElementById('loading-content').classList.add('hidden'); document.getElementById('success-content').classList.remove('hidden'); return; } try { const response = await fetch(`/api/koha/verify/${sessionId}`); const data = await response.json(); if (data.success && data.data.isSuccessful) { // Show success content document.getElementById('loading-content').classList.add('hidden'); document.getElementById('success-content').classList.remove('hidden'); // Update details document.getElementById('amount').textContent = `$${data.data.amount.toFixed(2)} ${data.data.currency.toUpperCase()}`; const frequencyText = data.data.frequency === 'monthly' ? 'Monthly Donation' : 'One-Time Donation'; document.getElementById('frequency').textContent = frequencyText; // Show monthly section if applicable if (data.data.frequency === 'monthly') { document.getElementById('monthly-section').classList.remove('hidden'); } } else { throw new Error('Donation not successful'); } } catch (error) { console.error('Verification error:', error); document.getElementById('loading-content').classList.add('hidden'); document.getElementById('error-content').classList.remove('hidden'); } } // Verify on page load if (sessionId) { document.getElementById('success-content').classList.add('hidden'); document.getElementById('loading-content').classList.remove('hidden'); verifyDonation(); }