#louis_checkout-tax
1 messages Ā· Page 1 of 1 (latest)
š Welcome to your new thread!
ā²ļø We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
ā±ļø We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1250841897430286356
š Have more to share? Add details, code, screenshots, videos, etc. below.
I have my checkout session set up likehtis but i dont want to calculate tax on each product. Iwant tax to be applied tothe total amout on checkout which is shipping + all lineitem prices 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.id],
quantity: product.qty,
}));
// Create stripe session
const session = await stripe.checkout.sessions.create({
shipping_options: [
{
shipping_rate_data: {
type: "fixed_amount",
fixed_amount: {
amount: shipping * 100,
currency: "cad",
},
display_name: "Express shipping", // Example: display name for shipping
},
},
],
payment_method_types: ["card"],
line_items: lineItems,
shipping_address_collection: shippingAddress,
mode: "payment",
after_expiration: {
recovery: {
enabled: true,
allow_promotion_codes: true,
},
},
success_url: `${req.protocol}://${frontendBaseUrl}/ordersuccess`,
cancel_url: `${req.protocol}://${frontendBaseUrl}/orderfailed`,
});
// Send the session URL back to the client instead of redirecting
res.status(200).json({ sessionUrl: session.url, sessionId: session.id });
} catch (error) {
console.error("Error creating checkout session:", error);
res.status(500).json({ error: "Internal server error." });
}
});
We calculate tax for you so you should follow https://docs.stripe.com/tax/checkout instead
if i add this to the session how to do i ensure it collects tax in my region automatic_tax
: {
enabled
: true,
},
i did and still do not understandwhere to apply tax to my session. that is why i am here
You don't "appluy tax to a session". You instead enable automatic tax calculation and we (Stripe) will calculate the tax for you
But for that to work you have to configure all your Products/Prices to have the relevant tax code, you have to tell us where you are registered to file taxes, etc.
This is something you need to carefully read end to end in our guide which walks you through the integration
when i add this to my stripe expressbackend it throws and error when trying to create the session automatic_tax
: {
enabled
: true,
},
I'm sorry your code is weirdly formatted with new lines in the middle and no context. I can't really help you without exact real code, exact error message, what you tried, what doesn't work, etc.
this is where my checkout session is https://github.com/Louistam888/RCCF3/blob/dispatchOrder/server/routes/stripeRoutes.js
there is no mention of the word automatic_tax on that page anywhere
i havenot pushedit intothe repository but when I add it won't creat the session
All good! I'm trying to help you debug things here. You're the developer writing the code and you see the code. What exact code are you using? What exact error are you getting?
Our API is usually really clear and tells you exactly what's wrong
this is the error I am getting Payment failed:
Object { stack: "AxiosError@http://localhost:3000/static/js/bundle.js:509471:18\nsettle@http://localhost:3000/static/js/bundle.js:510124:12\nonloadend@http://localhost:3000/static/js/bundle.js:508786:66\n", message: "Request failed with status code 500", name: "AxiosError", code: "ERR_BAD_RESPONSE", config: {ā¦}, request: XMLHttpRequest, response: {ā¦} }
ā
code: "ERR_BAD_RESPONSE"
ā
config: Object { timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", ⦠}
ā
message: "Request failed with status code 500"
ā
name: "AxiosError"
ā
request: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, ⦠}
ā
response: Object { data: {ā¦}, status: 500, statusText: "Internal Server Error", ⦠}
ā
stack: "AxiosError@http://localhost:3000/static/js/bundle.js:509471:18\nsettle@http://localhost:3000/static/js/bundle.js:510124:12\nonloadend@http://localhost:3000/static/js/bundle.js:508786:66\n"
ā
<prototype>: Object { constructor: AxiosError(message, code, config, request, response), toJSON: toJSON(), stack: "", ⦠}
when my session is like this const session = await stripe.checkout.sessions.create({
shipping_options: [
{
shipping_rate_data: {
type: "fixed_amount",
fixed_amount: {
amount: shipping * 100,
currency: "cad",
},
display_name: "Express shipping", // Example: display name for shipping
},
},
],
payment_method_types: ["card"],
line_items: lineItems,
shipping_address_collection: shippingAddress,
automatic_tax
: {
enabled
: true,
},
mode: "payment",
after_expiration: {
recovery: {
enabled: true,
allow_promotion_codes: true,
},
},
success_url: ${req.protocol}://${frontendBaseUrl}/ordersuccess,
cancel_url: ${req.protocol}://${frontendBaseUrl}/orderfailed,
});
When you call our API, if an error is returned it's raised as an exception. Read https://docs.stripe.com/error-handling?lang=node which covers in details how this works and make sure to properly catch exceptions and log them.
Once you do, this should give you the exact error message our API return and help you self-serve debugging the issue.
You can also go in your Dashboard and read the logs at https://dashboard.stripe.com/test/logs my guess is that you have a real/clear error there you're not seeing in your code and it's going to tell you what you missed
You likely forgot to activate/configure Stripe Tax first
where do i find activate/configure stripe tax in my dashboard