#Beninate-automatic_tax

1 messages ยท Page 1 of 1 (latest)

orchid imp
#

I'm guessing here you are providing the price data (amount and such) at the time of making this call?

heady slate
#

we are providing line_items when creating a session, each with their own amount

#

like such as

    cart.cart_items.each do |cart_item|
      line_items << {
        name: 'Foo',
        description: 'Bar',
        amount: 1000,
        currency: 'usd',
        quantity: 1,
      }
    end

    stripe_session = Stripe::Checkout::Session.create(
      line_items: line_items,
      automatic_tax: {
        enabled: true
      },
    )
orchid imp
#

There we go, that is what I was trying to describe. When it says "when not using prices" it is referring to the fact that it wants you to pass in the id of a Price object to the line items price param rather than using the price_data fields like amount and currency https://stripe.com/docs/api/checkout/sessions/create?lang=node#create_checkout_session-line_items-price

heady slate
orchid imp
#

Correct, if you want to use automatic_tax you'll need them to be those price objects

heady slate
#

understood, thanks for the clarification, i had no idea

#

one more question, should we also be creating a Product for every item, or that's optional?

orchid imp
#

It depends on how you want to structure it.

#

Each price will have to be attached to a product though so yes if each of these are distinct products you are selling one per price will make sense

heady slate
#

Creating Products might make things a lot easier for tracking sales of specific items and whatnot, so we may do that, since i have to create Prices anyway

#

thanks for the clarification, sorry for being a pain ๐Ÿ™‚