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

Added isValidVatNumberFormat + connection_timeout for the SOAP Client #143

Closed pmochine closed 2 years ago

pmochine commented 2 years ago

142

36

I have added the function isValidVatNumberFormat to validate the formating of the VAT number based on VIES.

Besides that, I have added an option to the config file, to change the connection_timeoutof the SOAP client. It's called soap_timeout in the config file. Its default value is 30 seconds.

Three questions came into my mind:

  1. When validating the formate, I have used your code to "clean up" the VAT number:

$vatNumber = str_replace([' ', "\xC2\xA0", "\xA0", '-', '.', ','], '', trim($vatNumber));

The question is. Why should I replace empty space? As it is officially okay to use it, according to VIES. Obviously, we should trim it. But why should we remove the rest? If the patterns do not match the VAT number string, we just say it's the wrong format.

  1. I have set the soap_timeout to 30 seconds. Is this a good default value?
  2. I have used some code from another package. How do you give credits in the comments block? (Not sure how it's done usually)

Thanks for letting me contribute :)

pmochine commented 2 years ago

My last commit with connection_timeout is not working as intended. I'm still not sure how to resolve it, because SOAP has no direct way to change the timeout.

https://stackoverflow.com/questions/3500527/php-soapclient-timeout/12119215#12119215

pmochine commented 2 years ago

Fixed the timeout bug with https://stackoverflow.com/a/68914117/7009480

pmochine commented 2 years ago

@driesvints I know we are all busy but can I do something to make the pull faster :D

driesvints commented 2 years ago

Thanks @pmochine. This is now released.