I’m investigating into the possibility of developing a small and (relatively) simple app to take over calculation of VAT and duties when selling from our UK-based store to the EU. I’ve been looking, but couldn’t figure out where and how in the Shopify API I’d start in implementing such a thing? I presume it is possible since there are some apps in the marketplace that seem to do this.
For context, we mostly sell books, which are zero-rated for VAT in the UK but have varying special-rate taxes in different EU countries, although we also sell some products that are rated at the full VAT level. Shopify Markets does not currently support this situation at all, but not using Markets in order to use tax overrides means that orders over €150 don’t have tax or duty collected, so neither situation is good for us or for our customers.
Where would I start in this?
I’ve previously developed a private app that we use for shipping rate calculations to handle the special rules for our products and integrate rates, so what I’m hoping is that there is an API that works in a similar way to the CarrierRate API but that allows external calculation of tax and duty rates instead?
Many thanks to anyone with any information to offer on this!
Great to hear you’re exploring managing duties and taxes for your store with a custom app - I’m sure you can create this functionality! Unlike the CarrierRate API you’ve used for shipping rates in the past, there’s no direct API to calculate and modify tax rates on the fly, so instead there could be additional logic and data management you’ll need to set up.
To implement a custom VAT and duties calculation solution, you might consider the following approach:
Order Editing API: Once you get the webhook notification, you can use the Order Editing API to make necessary adjustments based on the VAT and duties calculated. Remember that you only have a small window (up to 60 seconds after the order is created) to modify the order.
Metafields: You can use metafields to store additional information with the products such as their specific VAT rates.
Here is a basic flow of how it might work:
An order is placed on your store.
Shopify triggers the orders/create webhook.
Your app receives the webhook, and identifies the ordered items, their quantities, and the customer’s shipping address.
Your app calculates the VAT and duties based on your custom logic (which may involve looking up the product’s metafields and applying logic based on the customer’s location).
Your app uses the Order Editing API to adjust the tax lines of the order to reflect the calculated VAT and duties.
The actual implelentation of the above might be different depending on your store settings, but as a general approach this would be a good guide.
Hi Liam, thanks for this! That gives me an idea where to start.
From your description it makes it sound like its not possible to calculate the duties and taxes at the point of checkout – ie there is no way to make the customer pay for the duties and taxes, they’d have to be taken out of the revenue collected when the order is paid for?
If that’s the case then it doesn’t sound like it would be possible to make this work how we require it – currently there is no way to configure Shopify in such a way that it can correctly add the correct amount of VAT and duties for all the different regions and product types, so merely recalculating the proportions of revenue collected that go to tax and duty would still mean that we’re essentially being underpaid in some situations. To be able to correctly collect tax and duty we need to be adjust the way that tax is calculated at the point of checkout and adjust the order total before the customer pays.
Please could you confirm that my understanding of what you’ve said is correct and if therefore it is impossible to do this?
edit to add: reading again, the create webhook is done before payment..? But would this still allow changes to happen quick enough to adjust the final payment amount before the customer places the order if they were rushing through the checkout?
So Shopify’s checkout process has the taxes calculated based on the store’s tax settings and product tax codes at the point of sale. This means you can’t, for example, change the tax amount a customer sees at checkout based on some custom logic in your app.
The webhooks (including the order creation webhook) are triggered after an order is created, which typically means after payment has been processed. While it’s technically possible to capture payment details and adjust the order total before finalizing the order, it’s not possible to modify the tax portion of the order in real time during the checkout flow.
Hi again Liam, many thanks for clarifying this. From what you’re saying, it doesn’t sound like its currently possible to set up Shopify to correctly calculate taxes for our situation, even with a custom app to help. Hopefully this will become possible in the future!