#hakiros_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
âąď¸ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
đ 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/1212488765562683402
đ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
â˛ď¸ 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. Thank you for your patience!
Hello
Are you having an issue upon the initial Subscription creation?
Or just upon a Customer Portal update?
I didn't add this taxRate to my checkout yet, so im not having tax at anypoint, I can see info about auto tax collection in api doc but not about tax rates
const taxRate = await stripe.taxRates.create({
display_name: 'Vat',
inclusive: false,
percentage: 23,
});
const session = await stripe.checkout.sessions.create({
billing_address_collection: 'auto',
customer: clinic.stripe_customer_id,
line_items: [
{
price: prices.data[0].id,
quantity: amount,
},
],
mode: 'subscription',
payment_method_collection: 'if_required',
//add tax rate
tax_id_collection: {
enabled: true,
},
allow_promotion_codes: true,
locale: lang as any,
success_url: returnUrl,
cancel_url: cancelUrl,
});
this is full code, im trying to add this tax rate to this checkout
If you want to pass a tax rate then you pass it within line_items: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-line_items-tax_rates
Or, you can use subscription_data.default_tax_rates: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-subscription_data-default_tax_rates
oh, thanks, can you also tell me whether it will most likely also add tax to my customer portal, or I have to do something else?
If you want the tax rates to persist regardless of a Portal update then you do want to use subscription_data.default_tax_rates.
There is no way to have a tax rate apply if a Customer updates that Price via the Customer Portal
but I have problem - there are two types of subscriptions in my app
one of them have exclusive tax and one inclusive, so I can't just add default tax rate to all my taxes, unless it would be possible to set it in customer portal configuration
because if u have one subscription - you cant have another so i could generate seperate tax rates for each customer portal config (if i can set it there)
Then Customer Portal likely isn't a good fit here if you need this level of control on an update. I'm happy to put in a feature request to be able to set tax rates via Customer Portal Configs, but it simply isn't possible right now.
do you know some type of work around it? I basicly just want to add standard vat tax to my product - I can't have
automatic_tax: {
enabled: true,
},
because I don't allways have customer's address and it's required for this setting, so i always just want it to be 23%
I have 2 subscriptions in my app and one normal checkout,
1 sub and normaly payment should have inclusive tax
1 sub that have exclusive tax
I cant stop using customer portal now because we kinda relly on it,
what would you do?
You can set tax behavior on the Prices themselves.
That would work just fine too
As long as you aren't using two items with different tax behavior on the same Subscription
hmmm, but in my price I can only select whether to include tax in price or no, right? I can't just set it to be 23% - its auto calculated based if I enable
automatic_tax: {
enabled: true,
},
and
billing_address_collection: 'auto',
right? And this requires customer to have an address right?
Automatic Tax and Tax Rates are completely separate things.
Automatic Tax we handle this all for you.
Tax Rates you determine the amount of Tax to charge.
I know, but I dont see option to add tax rate to my price
Correct. You don't add Tax Rates to Prices. You add them to Subscriptions either alongside the Price within the line_item or as the default_tax_rates
For the Price you set the tax_behavior which dictates whether tax will be calculated inclusively or exclusively
https://docs.stripe.com/billing/taxes/tax-rates has more details if you haven't read through that yet
I have read it already, but didn't find it helpfull in this case, does price setting overwrite tax behaviour? Since tax rate is same - always 23% if I would set one default tax rate to be 23% and lets say invlusive (because there is no way not to set it), and I would set subscription price to have tax behaviour not inclusive- would that add tax by default to my subscription, and would it behave in way its set at price setting - not inclusive in that case, and would that work with customer portal?
Ah ah I see. Apologies, you are right -- you can't utilize the Price's tax_behavior here as that is only relevant for Auto Tax. You do have to specify that for Tax Rates so no that wouldn't work.
So let's back up a second. Why did you state:
because I don't allways have customer's address and it's required for this setting
If you are using Stripe Checkout here and using Auto Tax then you will always have enough information via the Checkout Session for Auto Tax to be calculated.
"Automatic tax calculation in Checkout requires a valid address on the Customer. Add a valid address to the Customer or set either customer_update[address] to 'auto' or customer_update[shipping] to 'auto' to save the address entered in Checkout to the Customer."
I had this error once user tried to pay for something after adding automatic_tax
I have assumed it was because user didn't provide address before trying to make a payment
It was production error so I had to hurry and I have just turn off taxes and thought that in this case I will just have to go with fixed tax rates instead of auto ones
Yeah since you are already passing in a Customer ID then you do want to set customer_update.address: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-customer_update-address