#rockywearsahat
1 messages · Page 1 of 1 (latest)
Hello rockywearsahat, we'll be with you shortly! Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
• https://discord.com/channels/841573134531821608/1164503998972313661, 0 days ago, 9 messages
yes, you'd expand the line_items field on the object
see https://dev.to/stripe/purchase-fulfilment-with-checkout-or-wait-what-was-i-paid-for-335d for a detailed examples
I'll read into it
I see, I'll keep that in mind for actually processing the payments, but I'm still trying to set up the checkout session, sorry if my question wasn't clear at all, when using
stripe.checkout.sessions.create({
mode: "payment",
payment_method_types: ["card"],
line_items: [
//This works
{
price_data: {
currency: "usd",
product_data: {
name: "Beanie",
},
unit_amount: 2499,
},
quantity: 2,
},
//Is there any way to get the data for this beanie product from the id that is generated in stripe 'price_1O2...'? Something like:
{
price_data: {
id: "price_1O2...",
currency: "usd",
},
quantity: 1,
},
//However this doesn't work whatsoever, says unknown parameter line_items[1][price_data][id]
any help is very much appreciated, I mainly just want to show the image on the page but it would be cool if there were some way to do it
hmm you can just do price:"price_xxx" instead of price_data:{...} if you already know a Price you want to use
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price
is that what you were looking for @solemn ruin ?
ayyyye yea perfect, I'm really dumb that's way easier than I was making it, thank you!
and one more thing as well, how can I tell the session that I want that product to have taxes on it as well? I saw the tax setup and was able to set a tax code for the beanie but it doesn't seem to update prices for taxes?
are they auto enabled and it's something I did in my product setup or do I have to tell the line_item spefically to use taxes for the item?
if you pass https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-automatic_tax-enabled it should use your tax settings
yep exactly, I had to do a little bit of setup for the tax calculations on stripe itself but I got it, I appreciate the help thank you!
and then final thing and I'm going to bed, is there a way to add a shipping address for where the physical products should be sent to or should I collect that on my site before I redirect to the checkout page?
Hi! I'm taking over this thread.
If you are using Checkout Session, then you can collect a shipping address with https://stripe.com/docs/api/checkout/sessions/create?lang=node#create_checkout_session-shipping_address_collection
no worries, this seems like a busy server, do y'all go in shifts here?
perfect thank you I will look into it
I really appreciate all the help y'all have provided, it's really nice to be able to go from knowing nothing to having a very good base of a checkout page done in one night
Happy to help 🙂
how do I set the values for the shipping address collection? is it a string array with the allowed countries?
It's an array that contains all the country codes where you allow shipping. So somehting like ["BE", "FR", "..."]
i'm getting the error Received unknown parameters: 0, 1, 2
am I doing this right?
const session = await stripe.checkout.sessions.create({
mode: "payment",
payment_method_types: ["card"],
line_items: {
{
price: "price_1O2sMJAI6vEkS2uiPAxdkWzB",
quantity: 1,
},
],
automatic_tax: {
enabled: true,
},
success_url: `http://localhost:3000/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `http://localhost:3000/cart`,
//Here???
shipping_address_collection: ["US", "BE", "FR"],
});
Oh sorry, I want wrong. It's:
shipping_address_collection: { allowed_countries: ["US", "BE", "FR"] }
ahhhh I see, my bad
No worries, that's my fault.
is there by chance a way to specify that any of the countries shipping addresses are allowed without specifying every one individually?
Nope, you'll have to set each of of them unfortunately.
lmao nice, well on that note I'm going to bed, this is a really nice api and you guys do great work both in terms of security and making it relatively simple to understand, I appreciate all the help!
really it's amazing that I can go from a site that has no functionality at all besides adding products to a cart to a close to completion checkout page in one night, you guys do great work in developing this api and in making it accessible
thank you for all the help!
thanks for the kind words!