taxjar / taxjar-magento2-extension

Magento 2 Sales Tax Extension by TaxJar
http://www.taxjar.com/guides/integrations/magento2/
Open Software License 3.0
22 stars 29 forks source link

Remove Zend for Magento 2.4.6 #362

Closed rangerz closed 1 year ago

rangerz commented 1 year ago

Context

Because https://github.com/taxjar/taxjar-magento2-extension/issues/358 and https://github.com/taxjar/taxjar-magento2-extension/pull/360 still not update.

Description

# My test code for debug
$om = \Magento\Framework\App\ObjectManager::getInstance();
$clientFactory = $om->get(\Magento\Framework\HTTP\LaminasClientFactory::class);
$client = $clientFactory->create();

$method = 'POST';
$apiKey = 'fake_key';
$url = 'https://httpbin.org/post';
$data = [
  'city' => 'Irving',
  'country' => 'US',
  'state' => 'TX',
  'street' => '101 No Steet',
  'zip' => '77777',
];

$client->setUri($url);
$client->setMethod($method);
$client->setHeaders([
    'Authorization' => 'Bearer ' . $apiKey,
    'x-api-version' => 'FAKE_VERSION',
    'Referer' => 'https://www.taxjar.com/'
]);
$client->setOptions([
  'timeout' => 30,
  'useragent' => 'my UA'
]);
$client->setRawBody(json_encode($data));
$client->setEncType('application/json');

echo $client->send();

$output = <<<OUTPUT
{
  "args": {},
  "data": "",
  "files": {},
  "form": {
    "{\"city\":\"Irving\",\"country\":\"US\",\"state\":\"TX\",\"street\":\"101 No Steet\",\"zip\":\"77777\"}": ""
  },
  "headers": {
    "Accept": "*/*",
    "Content-Length": "83",
    "Content-Type": "application/x-www-form-urlencoded",
    "Host": "httpbin.org",
    "Https": "//www.taxjar.com/",
    "User-Agent": "my UA",
    "X-Amzn-Trace-Id": "Root=1-647a40aa-44948c4f575e30814c965143"
  },
  "json": null,
  "origin": "MY_IP_ADDRESS",
  "url": "https://httpbin.org/post"
}
OUTPUT;

# Set Adapter for Authorization header
$client->setAdapter(\Laminas\Http\Client\Adapter\Socket::class);
echo $client->send();

$output = <<<OUTPUT
{
  "args": {},
  "data": "{\"city\":\"Irving\",\"country\":\"US\",\"state\":\"TX\",\"street\":\"101 No Steet\",\"zip\":\"77777\"}",
  "files": {},
  "form": {},
  "headers": {
    "Accept-Encoding": "gzip, deflate",
    "Authorization": "Bearer fake_key",
    "Content-Length": "83",
    "Content-Type": "application/json",
    "Host": "httpbin.org",
    "Referer": "https://www.taxjar.com/",
    "User-Agent": "my UA",
    "X-Amzn-Trace-Id": "Root=1-647a40c7-346b48df0919db53041d4158",
    "X-Api-Version": "FAKE_VERSION"
  },
  "json": {
    "city": "Irving",
    "country": "US",
    "state": "TX",
    "street": "101 No Steet",
    "zip": "77777"
  },
  "origin": "MY_IP_ADDRESS",
  "url": "https://httpbin.org/post"
}
OUTPUT;

Performance

N/A

Testing

N/A

Versions

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

rangerz commented 1 year ago

@smolentzov-stripe This pull request only works for Magento 2.4.6 and above.

You should not directly use it and update the module version to release.

ex: Use Magento 2.4.4 to install taxjar/module-taxjar:2.2.0 will fail to get the error message by bin/magento setup:di:compile

Area configuration aggregation... 5/9 [===============>------------]  55% 1 min 466.0 MiB
In ClassReader.php line 57:

  Impossible to process constructor argument Parameter #5 [ <required> Magento\Framework\HTTP\LaminasClientFactory $clien
  tFactory ] of Taxjar\SalesTax\Model\Smartcalcs class

In GetParameterClassTrait.php line 34:

  Class "Magento\Framework\HTTP\LaminasClientFactory" does not exist
damienwebdev commented 1 year ago

This PR should have caused a major version bump to v3 as well as a modification to the composer.json. The breaks older installs of v2.4.4.