#hatschi - checkout payment link

1 messages · Page 1 of 1 (latest)

plucky folio
#

Please edit your post to remove the solicitation for help for payment

#

hatch - checkout payment link

#

hatschi - checkout payment link

#

That repository is not accessible FYI

#

What exactly isn't updating when you expect?

foggy otter
#

mmh ok thx

#

document.getElementsByClassName('btn-purchase')[0].addEventListener('click', () => {
fetch("http://localhost:3000/create-checkout-session", {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
items: [
{id: 1, quantity: quantity1},
{id: 2, quantity: 1}
]
})
}).then(res => {
if (res.ok) return res.json()
return res.json().then(json => Promise.reject(json))
}).then(({ url }) => {
window.location = url
}).catch(e => {
console.error(e.error)
})
})

here, the quantity should be updated from the value in the html

plucky folio
#

That looks like the client side call to your own endpoint

#

so you'll likely want ot drive those item quantities using any form input values you have

#

depending on the needs of your backend

foggy otter
#

line_items: req.body.items.map(item => {
const storeItem = storeItems.get(item.id)
return {
price_data: {
currency: 'usd',
product_data: {
name: storeItem.name
},
unit_amount: storeItem.priceInCents,
},
quantity: item.quantity
}
}),

yes thats the snippet from the server

#

I'm uploading the files to a link so you can watch it, i have to go now, i'll write in about 6 hours again, but thank you very much

plucky folio
#

OK but what is not working like you expect, exactly?

#

This seems like an issue with your own API and what you pass/parse as items

#

I'd suggest debugging there first

foggy otter
#

Everything work like expected, but I would like that the quantity in shop.js updates live with the quantity in the shopping cart

#

i need help for the syntax etc

plucky folio
#

This is something you'll need to work on building yourself

foggy otter
#

I think you don't see my problem i described it bad

plucky folio
#

YOu're having trouble customizing your client code to pass to your backend a custom quantity to include in your payment link / checkout creation request, correct?

foggy otter
plucky folio
#

Your video is showing your discord window -- is that what you meant? But I still think you need to debug your client code taking input values and passing to your API

foggy otter