#louis-tam_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1237843344332423289
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
When you say "hosted checkout page" you mean Stripe Checkout, correct?
In which case you would pass the tax rate ID to the line_items.tax_rates param: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-line_items-tax_rates
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hi Bismarck, you mean like this? const lineItems = products.map((product) => ({
price_data: {
currency: "cad",
product_data: {
name: product.name,
},
unit_amount: Math.round(product.price * 100), // Ensure price is in cents
},
tax_rates: taxRate.percentage,
quantity: product.qty,
}));
//calculate tax
const taxRate = await stripe.taxRates.create({
display_name: "Ontario HST",
description: "Harmonized Sales Tax for Ontario",
percentage: 13,
jurisdiction: "CA", // Jurisdiction code for Canada
inclusive: false,
});
Nope, not the percentage -- you just pass the ID and it will apply the percentage. Also it is an array
So: tax_rates: [taxRate.id],
To be clear, you have to create the tax rate prior to creating the Checkout Session
oh got it.I thought you had to pass that in the session not the line items. It works now thanks!