#hatschi - checkout payment link
1 messages · Page 1 of 1 (latest)
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?
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
If you're generating payment links dynamically you choose the item quantity here:
https://stripe.com/docs/api/payment_links/payment_links/create#create_payment_link-line_items-quantity
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
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
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
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
If you can share your actually Stripe API request ID ( https://stripe.com/docs/api/request_ids like req_123) I can tell you which parameter we receive, and you can comare this to what you think you send
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
This is something you'll need to work on building yourself
I think you don't see my problem i described it bad
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?
here, please listen to it, this is my problem
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
Mmm this didn't work well, i'll wtite you again when i'm home, no that was not what i meant hahaha:)
Yeah about that