Add files via upload

This commit is contained in:
James 2025-10-06 01:41:18 -07:00 committed by GitHub
parent 4a49e7e18b
commit c4810e8a7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -689,20 +689,22 @@
const j1 = await r1.json();
if (!j1.ok) { alert(j1.error || 'reserve failed'); return; }
// 2) create checkout
// 2) create checkout
const r2 = await fetch(`${API}/api/create-checkout`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
resKey: j1.resKey,
items: [],
items: cart, // ← send your cart, not []
success_url: location.origin + location.pathname + '?ok=1',
cancel_url: location.origin + location.pathname + '?cancel=1'
})
});
const j2 = await r2.json();
if (!j2.url) { alert(j2.error || 'create-checkout failed'); return; }
location.href = j2.url; // redirect to Stripe
if (!r2.ok || !j2.url) { alert(j2.error || 'create-checkout failed'); return; }
location.href = j2.url;
}
document.getElementById('checkoutBtn').addEventListener('click', async () => {
const entries = Object.entries(state.cart || {});