driesvints / vat-calculator

Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.
MIT License
1.2k stars 88 forks source link

504 Gateway Time-out: What can I do against this? #142

Closed pmochine closed 2 years ago

pmochine commented 2 years ago

How do you handle a request that leads to a 504 Gateway Time-out? Probably because VIES is down.

This issue thread speaks about a timeout, but does it even work? https://github.com/driesvints/vat-calculator/issues/36

Because when the user starts a request, the website just loads for 30 seconds and throws me a 504 Gateway Time-out error. Not so satisfying for a user.

driesvints commented 2 years ago

Doesn't https://github.com/driesvints/vat-calculator#handling-soap-faults works?

pmochine commented 2 years ago

@driesvints Thank you for your quick answer. Unfortunately, it does not work. It doesn't matter whether I set it to true or false.

if (isset($this->config) && $this->config->get('vat_calculator.forward_soap_faults')) {
    throw new VATCheckUnavailableException($e->getMessage(), $e->getCode(), $e->getPrevious());
}

return false;

The only difference is that an exception is thrown instead of a false.

driesvints commented 2 years ago

Ah I see. There's nothing you can do unfortunately. When VIES goes down the only thing to do is to wait until it's up again. Usually the way I handle things is to simply not validate the VAT number to unblock users and not stop people form making purchases.

pmochine commented 2 years ago

@driesvints Okay. It's just annoying in my example because I have developed an affiliate program where the affiliate has to validate his VAT number when registering to the affiliate program.

I'll have to figure something out. I just find it so funny how often VIES goes down.

driesvints commented 2 years ago

I just find it so funny how often VIES goes down.

Yeah, it's a joke really 😅

pmochine commented 2 years ago

@driesvints Not sure if you will read this again. Nonetheless, I just found another package similar to yours. And I didn't try it out yet, but you should also include a timeout option like in this line: https://github.com/ibericode/vat/blob/59831d65c8fbe2885228b09fc33a8ea5e1b5dee4/src/Vies/Client.php#L67

And another cool function would be to validate at least the format of the VAT. Have a look here: https://github.com/ibericode/vat/blob/59831d65c8fbe2885228b09fc33a8ea5e1b5dee4/src/Validator.php#L95

driesvints commented 2 years ago

Good thinking. Feel free to send in PR's for those if you want 👍

pmochine commented 2 years ago

@driesvints #143 😊