Closed NateWr closed 9 years ago
This address #1.
4b9c40a caches the calls that are made to calculate the tax. In order to store the results within the class, I had to make a few methods non-static. I'm not always that clear on the use-case for static methods, so please take a look and make sure there's no potential fallout.
I have found two more API calls. One that sends the transaction and one that creates a refund.
I haven't tested a refund, but the actual transaction seemed pretty snappy to me, so I don't think we have any issues with repeated calls to the api there. That would probably throw up red flags with multiple transactions appearing in Taxamo anyway.
I think this takes care of it, but would love some more testers! I'm going live with it on my production site now.
Hi Nate,
Thanks for this :) - it does appear quicker.
I've tested a few times, and spotted a few issues though, which I'm not sure how they work but could be an issue going forward.
I'm assuming you're based in the UK, so this is from a UK IP.
If you are based in the UK, and put your billing address in the US, and confirm it, you will still get the UK cached tax rate. I guess we need to put a "If the submitted country code matches the cached country code, then use it, otherwise recollect it".
I'll see if I can take a look at it.
This PR stores the results of the API calls in
/includes/functions.php
to prevent multiple calls in a single page load with the same data. It's not a persistent cache, just storing it intoEDD_Taxamo_EDD_Integration::api_responses
for retrieval.The geoip lookup was the one that was really causing the delays. I went ahead and cached the vat details lookup as well, but I wasn't able to test that (I don't collect VAT details and Taxamo's API insists my VAT number is invalid -- though it validated the number in my account???).
Anyway, I recommend you test it before approving the PR.