Ajax, ON · Baseball Training Academy
Loading…
injection) var _pp = (window.TI_PRICING || {}); var _perSess = (_pp['one-on-one-per-session'] && _pp['one-on-one-per-session'].dollars) || 75; var _fourPack = (_pp['one-on-one-4pack-total'] && _pp['one-on-one-4pack-total'].dollars) || 320; var total = (qty === 4) ? _fourPack : (qty * _perSess); totalEl.textContent = fmtCAD(total); if (mode === 'monthly'){ summaryLbl.textContent = 'Charged monthly'; recurSuffix.textContent = ' / month'; } else { summaryLbl.textContent = 'Total today'; recurSuffix.textContent = ''; } dec.disabled = qty <= 4; inc.disabled = qty >= 12; } dec.addEventListener('click', function(){ if(qty>4){qty--; update();} }); inc.addEventListener('click', function(){ if(qty<12){qty++; update();} }); function setMode(m){ mode = m; modeOne.classList.toggle('active', m==='one_time'); modeMonthly.classList.toggle('active', m==='monthly'); update(); } modeOne.addEventListener('click', function(){ setMode('one_time'); }); modeMonthly.addEventListener('click', function(){ setMode('monthly'); }); payBtn.addEventListener('click', async function(){ errBox.classList.remove('show'); payBtn.disabled = true; payBtn.textContent = 'Loading checkout…'; try { var r = await fetch('/api/checkout', { method:'POST', headers:{'Content-Type':'application/json'}, credentials:'same-origin', body: JSON.stringify({ mode: mode, quantity: qty }) }); var d = await r.json(); if(!r.ok || !d.url){ errBox.textContent = d.error || 'Could not start checkout. Please try again.'; errBox.classList.add('show'); payBtn.disabled = false; payBtn.textContent = 'Proceed To Secure Checkout'; return; } window.location.href = d.url; // → Stripe Checkout } catch(e){ errBox.textContent = 'Network error. Please try again.'; errBox.classList.add('show'); payBtn.disabled = false; payBtn.textContent = 'Proceed To Secure Checkout'; } }); // Gate to logged-in users fetch('/api/me', {credentials:'same-origin'}) .then(function(r){ return r.json(); }) .then(function(d){ if(!d.authenticated){ window.location.href='/login?next=/dashboard/buy'; return; } document.getElementById('loading-state').style.display='none'; document.getElementById('buy-wrap').style.display='block'; }); document.getElementById('year').textContent = new Date().getFullYear(); update(); })();