Skip to Content Skip to Menu

BUG: VAT check in CBSubs not properly handling service failure

  • GUEST
10 years 1 month ago - 10 years 1 month ago #248257 by
Hello,

from time to time the SOAP service checking the VIES VAT ID is not available.

If that happens the complete plan subscription/payment becomes unavailable because the error is not caught properly - user is shown a 500 error or the error message below depending on the configuration.

Here is the except from the log for the time interval the wsdl gave only a 404.
Code:
Warning: SoapClient::SoapClient(http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl): failed to <span>open</span> stream: HTTP request failed! HTTP/1.1 404 (Not Found) in <span>/</span>var<span>/</span>www/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubstax/validations/tax_eu/validation.php on line 131 Warning: SoapClient::SoapClient(): I/O warning : failed to load external entity "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl" in <span>/</span>var<span>/</span>www/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubstax/validations/tax_eu/validation.php on line 131 Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl' : failed to load external entity "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl" in <span>/</span>var<span>/</span>www/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubstax/validations/tax_eu/validation.php on line 131


This needs to be fixed in that way that he error is caught properly. It can't be that the whole payment system is down just because of this.

Best regards

Carsten
Last edit: 10 years 1 month ago by .

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • OFFLINE
  • Posts: 2169
  • Thanks: 463
  • Karma: 352
10 years 1 month ago #248264 by beat

c_schmitz wrote: Hello,

from time to time the SOAP service checking the VIES VAT ID is not available.

If that happens the complete plan subscription/payment becomes unavailable because the error is not caught properly - user is shown a 500 error or the error message below depending on the configuration.

Here is the except from the log for the time interval the wsdl gave only a 404.

Code:
Warning: SoapClient::SoapClient(http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl): failed to <span>open</span> stream: HTTP request failed! HTTP/1.1 404 (Not Found) in <span>/</span>var<span>/</span>www/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubstax/validations/tax_eu/validation.php on line 131 Warning: SoapClient::SoapClient(): I/O warning : failed to load external entity "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl" in <span>/</span>var<span>/</span>www/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubstax/validations/tax_eu/validation.php on line 131 Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl' : failed to load external entity "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl" in <span>/</span>var<span>/</span>www/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubstax/validations/tax_eu/validation.php on line 131


This needs to be fixed in that way that he error is caught properly. It can't be that the whole payment system is down just because of this.

Best regards

Carsten


Indeed! Good catch.

Here is the fix that will be included in next release, so you can apply it now already:

In that file at that line replace:
Code:
public function checkVatApprox( $params, $paymentBasket, &$vat_verification ) { $client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", array('exceptions' => 0) ); $result = $client->checkVatApprox($params); // log result // echo 'Params: '; var_export( $params ); echo "<br />\nResult: "; var_export( $result ); if ( is_soap_fault( $result ) ) {

by:
Code:
public function checkVatApprox( $params, $paymentBasket, &$vat_verification ) { try { $client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", array( 'exceptions' => true ) ); $result = $client->checkVatApprox($params); $checked = true; } catch ( \SoapFault $e ) { $result = $e->getMessage(); $checked = false; } // log result // echo 'Params: '; var_export( $params ); echo "<br />\nResult: "; var_export( $result ); if ( ( ! $checked ) || is_soap_fault( $result ) ) {

That should catch the Soap errors properly according to Php Soap docs.

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in or Create an account to join the conversation.

  • GUEST
10 years 1 month ago #248316 by
Thank you, beat!

Note that the same thing might also have to be done in :

public function checkVatNumber( $vat_number, &$userMessage ) {

as there is a soap call, too.

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • OFFLINE
  • Posts: 2169
  • Thanks: 463
  • Karma: 352
10 years 1 month ago #248323 by beat

c_schmitz wrote: Thank you, beat!

Note that the same thing might also have to be done in :

public function checkVatNumber( $vat_number, &$userMessage ) {

as there is a soap call, too.


Yup, applied similar fix to it too (even though that API is not used in CBSubs). For completeness, after I posted above, I also added an addional error case for this case to both functions with a proper nice error message to the user explaining that the EU VIES verification system is temporarly unavailable and to either purchase now paying VAT, or retry later. ;)

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum