• Resolved Andrej

    (@andrej0)


    Hi,

    In some EU countries it is required to have “consultation number” from vies response (requestIdentifier) stored as a proof that vat number vas valid.

    Is it possible to add this option, since now we have to edit plugin code every time it’s updated to have this option.

    In order to get this number, it’s required to send requester vat number in vies request. There should be a new option added for this field.

    Old “Eu vat assistant” plugin had this option, and stored the resulting string as “vies_consultation_number” in db, so we reused that name for compatibility reasons.

    This is how we do it now for soap request:

    In alg-wc-eu-vat-functions-validation.php we changed checkVat with checkVatApprox:

    $result = $client->checkVatApprox( array(
    ’countryCode’ => $country_code,
    ? ‘vatNumber’ ? => $vat_number,>
    ’requesterCountryCode’ ?=> ‘COUNTRYCODE’,
    ’requesterVatNumber’ ? ?=> ‘VATNUMBER’
    ) );

    And we hacked storing the result in the return function with:

    update_post_meta( $order_id, ‘vies_consultation_number’, $result->requestIdentifier );

Viewing 14 replies - 1 through 14 (of 14 total)
  • Taha Amin

    (@tahaamin)

    Hi @andrej0,

    Thank you for reaching out! I hope you’re doing well.

    I’ve forwarded your request to our development team, and they’ll get back to you as soon as possible. Please let me know if there’s anything else I can assist you with in the meantime.

    Best regards,

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @andrej0,

    Please update the plugin to the latest v4.2.0. Then go to “WPFactory > EU VAT > Admin & Advanced” and enable the “Request identifier” checkbox (it’s at the bottom of the settings page). You should also fill in the “Requester country code” and “Requester VAT number” fields there.

    The plugin will store the identifier in the billing_eu_vat_number_request_identifier order meta. You can replace it with a different meta key with our alg_wc_eu_vat_request_identifier_meta_key filter. For example, to use the vies_consultation_number meta key as in your post, please add this PHP snippet to your site (e.g., to the functions.php file):

    add_filter( 'alg_wc_eu_vat_request_identifier_meta_key', function ( $meta_key ) {
    return 'vies_consultation_number';
    } );

    Please give it a try and let me know what you think.

    P.S. If you like the plugin, please consider leaving us a rating.

    Thread Starter Andrej

    (@andrej0)

    I tried it with the latest version, and new option works. Thanks.

    There are two issues i found:
    For manually created orders, when we use the “Validate VAT and remove taxes” button in admin panel, request indentifier order meta is not created. Also “is_vat_exempt” order meta is not created, so we assume this is a bug somewhere else.

    Also sometimes when new order is created in a normal way, billing_eu_vat_number_request_identifier order meta is not created.
    We think this happens when first a wrong number is entered to “eu vat number” field (or when vies returns an error). Sometimes bug happens, and sometimes it’s fine.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @andrej0,

    Thank you for the feedback. Let me check and get back to you.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @andrej0,

    We’ve just released a new plugin version (v4.2.2).

    Validate VAT and remove taxes – the request identifier order meta is now created. And the is_vat_exempt order meta is now set to yes.

    Unfortunately, I could not reproduce the issue of the request identifier order meta not being created in normal checkout. The meta is created here, no matter what I try (e.g., entering the wrong VAT ID). Could you please help me to reproduce it?

    Thread Starter Andrej

    (@andrej0)

    I have managed to reproduce it and this happens only when SOAP validation method fails, then it goes to curl method, and since curl method doesn’t request request identifier, it’s not returned.

    this is what log shows:

    Info Error: Exception: MS_MAX_CONCURRENT_REQ (Country: [DE]; VAT ID: [xx]; Company: []; Method: [soap])
    Info Success: VAT ID is valid (Country: [DE]; VAT ID: [xx]; Company: []; Method: [curl])

    to get request identifier, “?requesterMemberStateCode=XX&requesterNumber=XXXXX” parameters should be added to the end of curl request url.

    edit:
    Maybe it would be a good idea to have an option to show user that vies is not available.
    Currently the “VIES error message” is shown only when “Accept the VAT number if VIES is not available” option is enabled, but when disabled “VAT is not valid” is shown.
    This confuses users since vat number is entered correctly, and is potentially valid, and they just need to retry the order.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @andrej0,

    Thank you – that’s really useful!

    I’ve tested it with our “cURL” and “Simple” validation methods, as you suggested, and it’s working. I will add it to the plugin ASAP.

    And I will check regarding the “VIES error message”.

    I will get back to you soon.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @andrej0,

    Please update the plugin to the latest v4.2.3 – we’ve added the request identifier code to the “cURL” and “Simple” validation methods.

    As for the “VIES error message” – as far as I was able to test – if the “Accept the VAT number if VIES is not available” option is disabled and VIES is down, it should display the “Progress > Validation failed” message (i.e., “Validation failed. Please try again.”). Did you get different results?

    Thread Starter Andrej

    (@andrej0)

    I tried Request identifier, and it’s working properly now. Thanks.

    For the “VIES error message”:
    If the “Accept the VAT number if VIES is not available” option is disabled (default state), and vies response error code is “MS_MAX_CONCURRENT_REQ”, I get “VAT is not valid.”

    This is how log looks:
    Info Error: Exception: MS_MAX_CONCURRENT_REQ (Country: [FR]; VAT ID: [XXX]; Company: []; Method: [soap])
    Info Error: VAT ID not valid (Country: [FR]; VAT ID: [XXX]; Company: []; Method: [curl])

    As far as i can see, cUrl method doesn’t have handling for “userError” field in json response, thus it assumes that vat is not valid. This is how curl reponse looks for that error:

    {
    "isValid": false,
    "requestDate": "2025-02-03T12:40:42.592Z",
    "userError": "MS_MAX_CONCURRENT_REQ",
    "name": "---",
    "address": "---",
    "requestIdentifier": "",

    If the “Accept the VAT number if VIES is not available” option is enabled, and vies response error code is “MS_MAX_CONCURRENT_REQ”, i get text from “VIES error message” option.
    In this case curl method is not tried.
    If i select cUrl as the “First validation method”, I get “VAT is not valid.” message.

    What I think would be a proper handling, try both methods and if both fail for first case return “Validation failed” message, and for the second case return “VIES error message”.

    I only got “Validation failed” message when i blocked traffic to vies server.


    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @andrej0,

    Thank you for your feedback. As always, it is very useful!

    Will add it to the plugin ASAP.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @andrej0,

    Please update the plugin to the latest v4.2.5 – I think it should work properly now.

    Please give it a try and let me know what you think.

    Thread Starter Andrej

    (@andrej0)

    I tired it and messages are now displayed properly.

    But i found out that again “Validate VAT and remove taxes” button in admin panel doesn’t generate request indentifier order meta.
    It worked in version 4.2.4, but in 4.2.5 and 4.2.6 it’s not working.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @andrej0,

    Thank you for noticing – I see the problem. Will fix asap.

    Plugin Author Algoritmika

    (@algoritmika)

    Please update the plugin to the latest v4.2.7 – it should be fixed now.

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.