magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

[Issue] Add VIES validation result object to the response. #38511

Open m2-assistant[bot] opened 6 months ago

m2-assistant[bot] commented 6 months ago

This issue is automatically created based on existing pull request: magento/magento2#31010: Add VIES validation result object to the response.


Description

This commit adds result_object to the method response. This allows doing some additional validation logic in the plugin written for Magento\Customer\Model\Vat model. For some countries, this object returns additional fields:

traderName: "customer or company name"
traderCompanyType: "company type"
traderAddress: "
multiline address
associated with tax number
"

Manual testing scenarios

  1. Apply the patch.

  2. To test it you need a valid Netherland taxvat number.

  3. Open vat validator model and add the following code right before the end of the method: https://github.com/magento/magento2/blob/HEAD/app/code/Magento/Customer/Model/Vat.php#L218

    (new \Zend\Log\Logger())
        ->addWriter(new \Zend\Log\Writer\Stream(BP . '/var/log/custom.log'))
        ->debug((array)$gatewayResponse->getResultObject());
  4. Go to admin config Stores > Configuration > General > Store Information

  5. Select a valid country for your tax number, fill the tax number field, and press the "Validate VAT Number" button.

  6. Check the magento_root/var/log/custom.log. You should see the VIES result object:

    2020-11-23T09:25:57+00:00 DEBUG (7): array (
      'countryCode' => 'NL',
      'vatNumber' => 'vatnumber',
      'requestDate' => '2020-11-23+01:00',
      'valid' => true,
      'traderName' => 'companyname',
      'traderCompanyType' => '---',
      'traderAddress' => '
    company
    address
    ',
      'requestIdentifier' => '',
    )
    

Contribution checklist (*)

m2-assistant[bot] commented 5 months ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 5 months ago

Hello @vovayatsyuk,

Thank you for the report and collaboration!

This issue can be marked as feature request, as you are adding reult object to log file for a better validation logic. Thank you.

vovayatsyuk commented 5 months ago

Yes, it's a feature request to add the address returned by Vat Vies validation service to the result object, so other third-party modules may work with it.