#burt-tax-rates
1 messages · Page 1 of 1 (latest)
const session = await stripe.checkout.sessions.create({
line_items: myArray,
mode: 'payment',
success_url: http://localhost:3000/ordersuccess?success=true,
cancel_url: http://localhost:3000/cart?canceled=true,
automatic_tax: { enabled: true },
});
myArray is an array of objects that are {price: 'xxx', quantity: 1}
which works fine, but when I add to make those objects in the line_items array to be {price: 'xxx', quantity: 1, rax_rates: 'xxx'} I receive the invalid array error
So line_items takes and array of hashes
So you'll want myArray to look like:
line_items: [ { price: 'xxx', quantity: 1 } ]
which it does
Or :
line_items: [{price: 'xxx', quantity: 1}]
adding tax_rates seems like it should be possible from the API docs? but doing so gives me the invalid array error
So the error is this:
line_items: [{price: 'xxx', quantity: 1, tax_rates: 'xxx'}]
line_items in the API reference also has "line_items.tax_rates
optional
The tax rates which apply to this line item."
Can you enclose the value for tax_rates in square brackets?
In other words, does this work?
line_items: [{price: 'xxx', quantity: 1, tax_rates: ['xxx']}]
Or this?
line_items: [{price: 'xxx', quantity: 1, tax_rates: {'xxx'}}]
Ahhh, yup. this one should work: https://stripe.com/docs/payments/checkout/taxes?tax-calculation=tax-rates#fixed-tax-rates