Add files via upload
This commit is contained in:
parent
4a49e7e18b
commit
c4810e8a7c
|
|
@ -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 || {});
|
||||
|
|
|
|||
Loading…
Reference in New Issue