#karsh

1 messages ยท Page 1 of 1 (latest)

ember brookBOT
humble marsh
stone creek
#

๐Ÿ‘‹ Thanks for reaching out
Thanks for sharing the failed request Id, let me check

humble marsh
#

Thanks!

#

Let me know if you need more information

stone creek
#

Still looking into it as this feature is still beta

humble marsh
#

Thanks ๐Ÿ™‚

timid wadi
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

#

when you created the order you enabled automatic_tax and you specified a customer and billing address so Stripe calculated the tax for you

#

by then you can't override the tax

#

before this request tax_details wasn't set

#

and when you specified the customer then it was calculated and added

humble marsh
#

Thanks! Can I add a customer without it trying to calcualte tax automatically?

I guess I can do so by disabled automatic_tax?
That would still allow me to add the tax details and have it calculate the tax amount?

timid wadi
#

but once it get calculated there's no going back from there

humble marsh
#

Hmm I don't want to calculate the tax myself though, but I want it to only calculate the tax AFTER adding a tax id

#

Else we don't know if they should be exempted or not

#

how would I do that

timid wadi
#

when I say calculated I mean the tax details and not the tax itself

#

my bad, it was a poor choice of word

humble marsh
#

No worries!
I'll try without automatic tax right now and see if that gives me the desired result

humble marsh
#

I think I don't understand it completely yet.

When I disable automatic tax when creating the order, it doesn't calculate any tax (as instructed) https://dashboard.stripe.com/test/logs/req_JN0w3GNJrn5RB1

the total_details.amount_tax is 0

I swear I had it working like this before:

  1. create order with automatic tax enabled
  2. update order with billing country (this allows it to calculate tax)
  3. update order with tax id
#

Just tried it again, this DOES work:

Updated order with tax amount 0 (exempted), after applying a tax idhttps://dashboard.stripe.com/test/logs/req_srPbCDO87gr80C

#

So the difference is that now I'm trying to:

  1. create order with automatic tax enabled
  2. update order with billing country (this allows it to calculate tax)
  3. update order with a customer
  4. update order with tax id

With this sequence, it throws the error at step 4

#

Adding a customer also sets a tax id?

elder ruin
#

Yes, the order will use tax_ids set on the Customer object:

If you do pass a Customer that has either tax_ids or tax_exempt, these values get copied into the tax_details hash of the order and are applied to the automatic tax calculation.
https://stripe.com/docs/orders/tax#tax-details

Learn how to automatically calculate tax for an order.

humble marsh
#

So I should just not add a customer until after I have updated the order with a tax id?

elder ruin
#

No, I'd assume you'll still have the same issues (trying to apply tax_ids when they're already been used to calculate the tax due)

#

Can you not just unset the tax_ids on the Customer?

#

Or update them?

humble marsh
#

Maybe? I want the user to be able to supply a tax id for each order. As they could be buying products for different companies, with different tax ids

elder ruin
#

I'd recommend just updating the Customer object before applying it to the order in that case

humble marsh
#

Maybe it helps to explain my goal: I'm trying to replicate the behaviour that Stripe Checkout has.

  1. Select a country
  2. input a tax id
  3. If tax id is valid, and exempt: show 0 tax.
  4. If you change the tax id again, make it invalid: show full tax again
#

Regardless of the customer object - the error says you can't update an order tax details once set.
Does this mean that it's simply impossible to replicate the behaviour as seen in the video I just sent?

elder ruin
#

You can't compare to Checkout here really. It doesn't use the Orders API

#

And has internal APIs for tax calculation

humble marsh
#

I see, so I can't expect to replicate that behaviour completely with the orders api...

elder ruin
#

I'm not sure, did you try what I described?

humble marsh
elder ruin
#

Which Order?

#

Where's the failing request ID?

humble marsh
#

order_1Lnh5nKWokmZWsWfbz7WM9bO

elder ruin
#

Did you try doing it the other way? Set the tax_details, then add a customer?

humble marsh
#

No, can try that now

#

with a new customer that doesn't have any tax ids set (unless I'm looking at the wrong location here)

elder ruin
#

Then I guess it isn't achievable in the way you expect

#

What about adding the automatic_tax parameter only after you've set the cus_xxx and Tax IDs as you need?

humble marsh
#

I appreciate all the advice so far, I feel like you're truly helping me get to a solution by thinking with me.

I'm thinking about that, but if I dsiable the automatic_tax param, I don't get total_details.amount_tax so I can't display that on the page yet.

Which I would like to do, I'd like to show a subtotal and total, example:
subtotal: 100
VAT (21%): 21
total: 121

#

Maybe there is a way for me to get the amount_tax value still? Or this is 100% only happening when automatic_tax is enabled?

elder ruin
#

Right, but once the tax IDs are set and then you apply the parameter, the response should have the tax totals

humble marsh
#

Ahh this doesn't work out I think practically... Maybe I'm missing something...

The flow I'm building is, similarly to checkout again ;-), that I'd like to show the default VAT rate (21% in this case) and only take it away after the user optionally adds their tax id

#

Many users won't add a tax id at all

elder ruin
#

Then I guess that isn't possible

humble marsh
#

The only solution I can see right now is that I save the tax rate somewhere (probably within the line items as you just sent me) and then show that on the page with my own code.
Then only after somebody applies a tax id, then we activate automatic tax

elder ruin
#

Hmm, I still think you'll have the same issues (i.e. not able to update the tax IDs as a tax calculation will have taken place)

#

Tax Rates are fundamentally the same thing โ€“ a way of calculating tax. They're just not automatic like Stripe Tax (i.e. you need to apply the tax rates according to the location of your customer)

humble marsh
#

Hmmmm then the only soltuion I see right now is to not update the order with a customer at all, I guess it's not absolutely necessary. I don't really know the benefit of it to be honest

#

Without updating the order with a customer, teh user can at least apply a tax id once. They still need to completely redo their checkout if they want to change it though

elder ruin
#

I still don't think you can update tax_ids on an order, regardless of whether a Customer is involved

humble marsh
#

yeah that does work, I think the issue really lies in the customer object somehow. Even if the customer is new, it has one of these 2 things set I guess...

#

Hang on I'll show you that it works to update a tax_id on an order

elder ruin
#

Sounds like a solution then!

humble marsh
#

This is my ui in the vid.

This is before upadting the tax id https://dashboard.stripe.com/test/logs/req_9bWus2v1YRxetJ
This is the order after updating https://dashboard.stripe.com/test/logs/req_aR5sMRRm2p7k09

#

Then i'd like to try deliberately unset the customer tax_id and tax_exempt status, when I create a customer. How do I do this?

elder ruin
#

You'd pass an empty string to those parameters in the update call

humble marsh
#

Doesn't work, seems like "none" is the default. And I think that is causing a problem because it considers the tax_details to be set once it's none

elder ruin
humble marsh
#

okay I give up, I'll not add a customer to the order.

THen my last questions:

  1. Not adding the customer to the order makes us not know which customer is linked to which order (in the stripe dashboard) I assume... I can compensate this by saving this all in our own database. Does it have any other effects to add a customer to an order?

  2. I am trying the orders api beta, because it gives us stripe tax + custom checkout flows. I feel like my issues now stem from limitations that have yet to be fixed. How do I find out if this is true? Then I know what to expect from the orders API in the future

timid wadi
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

#
  1. you can always add metadata if that helps. By adding a customer you could pay the order with a previously attached payment method
#

2.How do I find out if this is true
I don't follow