• Plugin Author Diego

    (@daigo75)


    It has been reported that the VAT validation service for Belgium has not been working properly for a couple of days. The remote service returns a “service unavailable” response code, and the validation of VAT numbers fails. Due to that, VAT is not removed from the order.

    This behaviour is by design. The EU VAT Assistant errs on the side of caution, and won’t apply an exemption unless the VAT number is confirmed to be valid. When the validation service is down, such verification can’t be performed.

    Restoring the service is a responsibility of the Revenue Authority of the respective country (or countries). The EU VAT Assistant can’t do anything about it, from its side.

    Possible workaround
    If you trust your clients, and you are willing to take the risk of accepting potentially incorrect VAT numbers, you can use the following code to tell the EU VAT Assistant to accept as valid any VAT number that could not be validated due to the remote service being unavailable.

    
    /**
     * Indicates if the response code returned by the VIES service
     * is "service unavailable.
     *
     * @return bool
     */
    function is_vies_service_unavailable($validation_error) {
        return ($validation_error === 'SERVICE_UNAVAILABLE') || ($validation_error === 'MS_UNAVAILABLE');
    }
    
    /**
     * Intercepts the VAT number validation process, to force the EU VAT 
     * assistance to accept as valid any number that could not be validated
     * due to the remote service being unavailable.
     * This code requires the EU VAT Assistant 1.9.16.191004 or newer, due
     * to some changes in the VIES response.
     *
     * @param array $validation_result
     * @param string $country
     * @param string $vat_number
     * @return array
     */
    add_filter('wc_aelia_euva_eu_vat_number_raw_validation_result', function($validation_result, $country, $vat_number) {
      $validation_error = $validation_result['errors'][0];
      if(!empty($validation_error) && is_vies_service_unavailable($validation_error)) {
        $validation_result['valid'] = true;
      }
      return $validation_result;
    }, 10, 3);
    

    You can add the code to your theme’s functions.php file, or to a code snippet using the Code Snippets plugin.

    Important notes

    • The responsibility of applying the reverse charge rule correctly on intra-EU B2B transactions remains entirely on the merchant (i.e. you). If you choose to use the above code to apply a zero-rate VAT when a VAT number can’t be validated, you assume the risk of accepting invalid VAT numbers. Should that happen, it will be up to you to contact your local Revenue Authority and apply the necessary corrections.
    • GPL DISCLAIMER<nr>Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the program “as is” without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
Viewing 1 replies (of 1 total)
  • Thanks for this.

    The code only triggers when VIES is not available. What code should be used if we want to accept any VAT number that is entered? So completely skip VIES. On our own responsibility of course.

    * – edit got it:

    add_filter('wc_aelia_euva_eu_vat_number_raw_validation_result', function($validation_result, $country, $vat_number) {
      $validation_error = $validation_result['errors'][0];
       {
        $validation_result['valid'] = true;
      }
      return $validation_result;
    }, 10, 3);
    • This reply was modified 4 years, 10 months ago by vememe.
    • This reply was modified 4 years, 10 months ago by vememe.
Viewing 1 replies (of 1 total)
  • The topic ‘VAT numbers from specific countries can’t be validated – Workaround’ is closed to new replies.