GithubHelp home page GithubHelp logo

avadev / avatax-rest-v2-php-sdk Goto Github PK

View Code? Open in Web Editor NEW
48.0 16.0 94.0 1.71 MB

Sales Tax API SDK for PHP and AvaTax REST

Home Page: https://developer.avalara.com/sdk/

License: Apache License 2.0

PHP 100.00%
avatax php-sdk avatax-sdk avalara ecommerce sales-tax sale-tax-api tax-rates tax-rate

avatax-rest-v2-php-sdk's People

Contributors

akshit-avalara avatar avalara-chriswalker avatar avalara-tela avatar avasachinbaijal avatar ballen-inq avatar bubnov-mikhail avatar caleywoods avatar contygm avatar craig-davis avatar danadesrosiers avatar dmnc avatar han8909227 avatar jimdoescode avatar jondmcelroy avatar lordzardeck avatar marcuswindecker avatar matt-h avatar nitinshirsat avatar qjavalara avatar rahulv-dev avatar ramashishv-avalara avatar rsohlman-ava avatar shilpa-khanal avatar shilpakhanal avatar snags88 avatar spadbob avatar svc-developer avatar ted-spence-avalara avatar vijaynalawade-avalara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avatax-rest-v2-php-sdk's Issues

Transactions are not being reported in real-time in the dashboard

We're having an issue as the Avalara transactions are not being reported in the dashboard in real-time.
We have submitted some lookup calls and committed the transactions but the dashboard doesn't display all of our transactions. Is there any reason why?

Thanks,
Franclin

Missing method to set $this->_model['email '] (Customer Email)

The PHP class TransactionBuilder does not have a method to set the customer email.

The .NET class has this available:
https://github.com/avadev/AvaTax-REST-V2-DotNet-SDK/blob/master/src/TransactionBuilder.cs

line 812:

public TransactionBuilder WithEmail(string email)
        {
            _model.email = email;
            return this;
        }

There is no equivalent method in the PHP class. To add this method, this file must be adjusted:
https://github.com/avadev/AvaTax-REST-V2-PHP-SDK/blob/master/src/TransactionBuilder.php

Example code for new method:

    /**
     * Set a customer email
     *
     * @param   string              email
     * @return  TransactionBuilder
     */
    public function withEmail($email)
    {
        $this->_model['email'] = $email;
        return $this;
    }

downloadTaxRatesByZipCode endpoint fails with unexpected format

Trying to use downloadTaxRatesByZipCode will always fail because the response is a CSV but Client::restCall tries to json_decode() the response regardless of the header content type. The exception being thrown then tries to use the decoded body which will always be null (which is another minor bug).

Client.php lines 220-225 needs some fixin'

Semi related but the docs for the endpoint say that the date is required but the default is today yet the param is required and doesn't default to anything. The region is supposed to be completely optional but it's also required in the SDK.

commitTransaction method not behaving as expected, has incorrect inline documentation

The inline documentation for the commitTransaction method states that it's should be used for committing a transaction for reporting and marking it as Committed by changing its status.

The $transactionCode is passed to this method, so why must both the $documentType and $model be provided when using it event if your inline documentation mentions that $documentType is optional (in the DocBlock) ?

I assumed this method can be used to change the status from Saved to Committed, for an existing transaction in Avalara. If so, then I should not have to re-build the model, the transaction already exists and was Saved in Avalara. All I want to do is change it's status.

What am I missing?

If this is not the correct method to change the status of an existing transaction from Saved to Committed, which method should I use?

Thanks

Custom line number via SDK

👋,

Via the API we are able to insert a custom line number. I do not see this functionality via the SDK.

I've attempted using ->withLineParameter('number', 'customNumber'), but not matter what parameter I add it's invalid. Is there a list of valid params?

{"error":{"code":"InvalidParameter","message":"The parameter 'number' is not a valid parameter.","target":"IncorrectData (truncated...)\n

Any info on this is greatly appreciated.

Avatax php sdk giving zero tax in response to the API call.

I have been trying with PHP SDK to get the tax rate. I noticed that for every request avatax api giving me zero tax. The reson for this one is I found that in the response totalExempt is set to the total amount i tried to get tax rate. I did not pass this exempt parameter with my request. Then how will this happen? My API call code looks like below,
$tb = new Avalara\TransactionBuilder($client, "DEFAULT", Avalara\DocumentType::C_SALESORDER, 'ABC'); $t = $tb->withAddress('ShipFrom', '123 Main Street', null, null, 'Irvine', 'CA', '92615', 'US') ->withAddress('ShipTo', '100 Ravine Lane', null, null, 'Bainbridge Island', 'WA', '98110', 'US') ->withLine(40.21, 1, null, PC040400) ->create(); echo('<h2>Transaction #2</h2>'); echo('<pre>' . json_encode($t, JSON_PRETTY_PRINT) . '</pre>');

My response looks like(this is not for the same request but all response looks like this. Look at the totalExempt and totalAmount),

Transaction #1 { "id": 0, "code": "7a89a8fb-be32-4cc6-8408-a12feb7d4ba9", "companyId": 211434, "date": "2019-05-20", "paymentDate": "2019-05-20", "status": "Temporary", "type": "SalesOrder", "customerVendorCode": "EXAMPLECUSTOMER", "customerCode": "EXAMPLECUSTOMER", "reconciled": false, "totalAmount": 40.21, "totalExempt": 40.21, "totalDiscount": 0, "totalTax": 0, "totalTaxable": 0, "totalTaxCalculated": 0, "adjustmentReason": "NotAdjusted", "locked": false, "version": 1, "exchangeRateEffectiveDate": "2019-05-20", "exchangeRate": 1, "modifiedDate": "2019-05-20T05:04:16.4602473Z", "modifiedUserId": 236613, "taxDate": "2019-05-20T00:00:00", "lines": [ { "id": 0, "transactionId": 0, "lineNumber": "1", "discountAmount": 0, "exemptAmount": 40.21, "exemptCertId": 0, "isItemTaxable": true, "lineAmount": 40.21, "quantity": 1, "reportingDate": "2019-05-20", "tax": 0, "taxableAmount": 0, "taxCalculated": 0, "taxCode": "PC040400", "taxCodeId": 5197, "taxDate": "2019-05-20", "taxIncluded": false, "details": [ { "id": 0, "transactionLineId": 0, "transactionId": 0, "country": "US", "region": "CA", "exemptAmount": 0, "jurisCode": "06", "jurisName": "CALIFORNIA", "stateAssignedNo": "", "jurisType": "STA", "jurisdictionType": "State", "nonTaxableAmount": 40.21, "rate": 0, "tax": 0, "taxableAmount": 0, "taxType": "Use", "taxName": "CA STATE TAX", "taxAuthorityTypeId": 45, "taxCalculated": 0, "rateType": "General", "rateTypeCode": "G", "isNonPassThru": false } ], "nonPassthroughDetails": [], "hsCode": "", "costInsuranceFreight": 0, "vatCode": "", "vatNumberTypeId": 0 } ], "addresses": [ { "id": 0, "transactionId": 0, "boundaryLevel": "Address", "line1": "2000 Main Street", "line2": "", "line3": "", "city": "Irvine", "region": "CA", "postalCode": "92614", "country": "US", "taxRegionId": 4017409, "latitude": "33.684689", "longitude": "-117.851495" }, { "id": 0, "transactionId": 0, "boundaryLevel": "Address", "line1": "255 S. King Street", "line2": "", "line3": "", "city": "Seattle", "region": "WA", "postalCode": "98104", "country": "US", "taxRegionId": 1048894, "latitude": "0", "longitude": "0" } ], "summary": [ { "country": "US", "region": "CA", "jurisType": "State", "jurisCode": "06", "jurisName": "CALIFORNIA", "taxAuthorityType": 45, "stateAssignedNo": "", "taxType": "Use", "taxName": "CA STATE TAX", "rateType": "General", "taxable": 0, "rate": 0, "tax": 0, "taxCalculated": 0, "nonTaxable": 40.21, "exemption": 0 } ] }

Problem with psr-4 autoloader

You are using psr-4: "Avalara\": "src/"
But all classes are living inside only one file: AvaTaxClient.php
If I am going to create an new AvaTaxClient() first - that is ok.
But if I want to use other classes (DocumentType, RefundTransactionModel, etc..) - I well got an error - psr-4 autoloader whould not find this class in Avalara/DocumentType.php

You should split classes in files to follow psr-4 or use "classmap" autoload.

Is there a changelog?

Hello AvaTax team,

I was wondering if it would be too much to ask to add a simple message to what is being changed in the releases. Either in the release description or in the changelog. It would help us a great deal to determine if we want to update the SDK or keep using the older version for the time being.

Thank you.

Request/response logging

In the AvaTax Certification docs, which I used as a guideline for scoping out the integration work for a client, it is mentioned that logging the requests to the APIs should be loggable:

Enable client side logging - Required

Enables detailed AvaTax transaction logging within the application including capture of round-trip processing time. We need the complete request/response for each call made to Avalara services. It does not need to run all the time as we understand the database will grow unnecessarily large – you are free to only log the last week, 30 days, custom, or have a control for the next N hours, etc. The spirit of the requirement is to assist customers and support in troubleshooting exercises, so it needs to be retrievable by an end user (or an administrator). It should be specifically Avalara service calls.

Am I correct in seeing the official SDK does not currently offer a way to do so? I was kinda hoping that requirement could be met by for example passing in a PSR3 logger (Monolog) into the client which would then log what goes in on the Client->restCall.

That same document also says...

Request time out definition - Suggested

Define AvaTax request time out length, AvaTax best practices prescribes default setting of 300 ms.

.. but I just spotted a hardcoded limit of 20 minutes(!) in restCall() 😬 Would that be worth a separate bug report?

TransactionBuilder support for adding fields at the document level on CreateTransaction?

In experimenting with the API and the PHP SDK, I had a need to use some of the fields listed here in the CreateTransactionModel. In one case I wanted to use "exemptionNo" and saw no way with TransactionBuilder to add this.

I see that there is a withParameter() method but the code for that places whatever is passed in into:

$this->_model['parameters'][$name] = $value;

Where $name is what you passed into the method and $value is what you wish to set.

I have already duplicated TransactionBuilder on my end to support some other functionality and I went ahead and created a withDocumentParameter() function that reads:

$this->_model[$name] = $value;

So it's skipping the 'parameters' part and sticking them right into the model, this seems to function just fine. I suppose withParameter() could be made to take a third argument of a boolean that defaults to false that controls whether it's added at the document level or within 'parameters'. I know when I tried to set exemptionNo on my document with the withParameter() method the API told me that "exemptionNo" is an invalid parameter.

According to the docs for CreateTransaction there is a "parameters" field that is optional and supports a list of things found when making a call to the /api/v2/definitions/parameters endpoint but I don't see the parameters in that list that would be of use.

Just wanted to gather input/feedback on this to see if it should be supported of if I am handling it incorrectly. I can open a PR with my additional function if need be.

How to handling error?

I have tried resolve address api call, I am getting like
Client error: GET https://sandbox-rest.avatax.com/api/v2/addresses/resolve?line1=sdfsdfsdfsdf&city=wrwerwer®ion=AK&postalCode=werwerwerwer&country=US&textCase=UPPER resulted in a 400 Bad Request response:
{"error":{"code":"StringLengthError","message":"Field 'postalCode' has an invalid length.","target":"IncorrectData","det (truncated...)

Guzzle 7 support

Trying to update guzzle on my project to 7.0.1 I got this error:

`$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- avalara/avataxclient 19.12.1 requires guzzlehttp/guzzle ~6 -> satisfiable by guzzlehttp/guzzle[6.0.0, 6.0.1, 6.0.2, 6.1.0, 6.1.1, 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.4.0, 6.4.1, 6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.x-dev] but these conflict with your requirements or minimum-stability.
- avalara/avataxclient 19.11.0 requires guzzlehttp/guzzle ~6 -> satisfiable by guzzlehttp/guzzle[6.0.0, 6.0.1, 6.0.2, 6.1.0, 6.1.1, 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.4.0, 6.4.1, 6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.x-dev] but these conflict with your requirements or minimum-stability.
- avalara/avataxclient 19.12.1 requires guzzlehttp/guzzle ~6 -> satisfiable by guzzlehttp/guzzle[6.0.0, 6.0.1, 6.0.2, 6.1.0, 6.1.1, 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.4.0, 6.4.1, 6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for avalara/avataxclient ^19.11 -> satisfiable by avalara/avataxclient[19.11.0, 19.12.1].`

Can you please update, or allow us to update guzzle?

How to omit tax codes in transactions

We are mapping items to tax codes within AvaTax portal only. Therefore, in our API it is necessary to omit tax codes and supply item codes ONLY, according to our Avalara sr. project consultant. However, the the SDK documentation indicates that setting $taxCode in 'withLine' method of the transaction builder to blank will cause a default tax code of P000000 to be applied
(

* @param string $taxCode Tax Code of the item. If left blank, the default item (P0000000) is assumed.
).

How are we supposed to omit tax codes from being sent in transactions?

Thanks

Address model cannot be set with locationCode

I am trying to create a transaction with the main address to be:

    "addresses": {
        "singleLocation": {
            "locationCode": "DEFAULT"
        }
    },

In version 22.9.0 the transactionbuilder has a withAddress() method but it does not accept locationCode (https://developer.avalara.com/api-reference/avatax/rest/v2/models/AddressLocationInfo/) only the explicit address parameters (@TransactionBuilder.php line 294):

public function withAddress($type, $line1, $line2, $line3, $city, $region, $postalCode, $country)
    {
        if (empty($this->_model['addresses'])) $this->_model['addresses'] = [];
        $ai = [
            'line1' => $line1,
            'line2' => $line2,
            'line3' => $line3,
            'city' => $city,
            'region' => $region,
            'postalCode' => $postalCode,
            'country' => $country
        ];
        $this->_model['addresses'][$type] = $ai;
        return $this;
    }

Am I missing something here (maybe another withXXXX() method for address location code) or this feature does not exist yet?

Make Guzzle HTTP Client configuration extendable

Hi,

currently there is no way provided to extend Guzzle client configuration, e.g. adding a request logger.

I think the best option is to make the client "overwriteable", e.g. introduce some kind of getClient method and depend on this method instead of the private property, in this way you can easily extend the AvaTaxClient class and overwrite the client as you needed.

By the way, all parameters has to be protected instead of private in the client class to allow class extension.

File has mixed line endings; this may cause incorrect results

Hello. During running tests we got such errors:

FILE: .../magento2/vendor/avalara/avataxclient/src/Methods.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | WARNING | File has mixed line endings; this may cause incorrect
   |         | results
----------------------------------------------------------------------


FILE: .../magento2/vendor/avalara/avataxclient/src/Models.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | WARNING | File has mixed line endings; this may cause incorrect
   |         | results
----------------------------------------------------------------------


FILE: .../magento2/vendor/avalara/avataxclient/src/Constants.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | WARNING | File has mixed line endings; this may cause incorrect
   |         | results
----------------------------------------------------------------------

PHP Version: 8.1
Package version: 22.10.0

Please add correct endings to these files. Thank you.

Debugging: truncated error messages, exception handling

Hi team,

Some feedback for the SDK. The biggest issue we've identified on our side with regard to using the PHP SDK is how error messages are truncated, making it difficult to determine issue details.

For example:

"error":{
    "code":"AuthenticationException",
    "message":"Field username is required.",
    "target":"HttpRequestHeaders",
    "detail (truncated...) 

Potentially related, we would find it useful to have improved exception handling - allowing us to inspect the full details of the error, but certainly allowing us to better differentiate between server 500 errors and client 400 errors.

Cheers!

Company not found

I tried to code example from this package but get an message "Company not found"

Client error: POST https://sandbox-rest.avatax.com/api/v2/transactions/create resulted in a 404 Not Found response: {"error":{"code":"EntityNotFoundError","message":"Company not found.","target":"HttpRequest","details":[{"code":"EntityN (truncated...)

Refund Transaction creates transaction with all zero amounts

The Refund Transaction method is just not that complicated, you give it the old transaction code, the doc type, SalesInvoice , then in the body a new transaction code, the date and the refund type, partial, full or tax only. There's not a whole lot I can be doing wrong here, but every time I try I get a perfect copy of the old transaction (as expected, all the lines are there and everything) but all the amounts are 0 (and all the quantities on the lines are reset to 1). What is going wrong?

Please use classmap autoloader in composer.json

Your class file structure is not in PSR-4 format.

Example Avalara\AccountModel is in src/Models.php
for this class to be PSR-4, the file needs to be src/AccountModel.php all by itself.

Since you seem to generate Constants.php, Methods.php and Models.php, the autoloader section should say:

"autoload": { "classmap": ["src/"], "exclude-from-classmap": ["src/AvaTaxClient.php"] }

This will create the mappings even for your generated files and also be automatically optimized.

Calling the SDK->adjustTransaction() results in a UnhandledException on Ava server

{"error":{"code":"ServerConfiguration","message":"An invalid exception handler routine has been detected.","target":"AvaTaxApiServer","details":[{"code":"UnhandledException","number":50,"message":"An invalid exception handler routine has been detected.","description":"This error has been logged and reported to Avalara system administrators. ","faultCode":"Client","helpLink":"http://developer.avalara.com/avatax/errors/UnhandledException","severity":"Exception"}]}}

$useTaxOverride param in refundTransaction method - boolean or string?

When using the $client->refundTransaction method the $useTaxDateOverride param is described as a boolean, but if you pass a boolean it gets passed incorrectly to the API as PHP is converting the value to a 1, resulting in the following API error:

Client error: `POST https://sandbox-rest.avatax.com/api/v2/companies/xxx/transactions/xxx/refund?useTaxDateOverride=1` resulted in a `400 Bad Request` response:
{"error": {"code":"ModelStateInvalid","message":"Incorrect data type for 'useTaxDateOverride'.","target":"HttpRequest","d (truncated...)

A string literal of "true" works as expected. This is probably just a documentation issue that the passed param should just be a string so it gets passed along to the Guzzle query option array correctly.

For example:

$client->refundTransaction('xxx', 'xxx', null, null, true, $model);

...results in the following api url being called:

https://sandbox-rest.avatax.com/api/v2/companies/xxx/transactions/xxx/refund?useTaxDateOverride=1

But:

$client->refundTransaction('xxx', 'xxx', null, null, 'true', $model);

...results in the following api url being generated correctly:

https://sandbox-rest.avatax.com/api/v2/companies/xxx/transactions/xxx/refund?useTaxDateOverride=true

Add Method to TransactionBuilder to support adding Avalara\LineItemModel objects

I have some code I've added in my own file that is basically a duplicate of the TransactionBuilder.php file which accepts either a single instance of LineItemModel or an array of them. This gives flexibility to the end user to not be boxed in by needing to use the withParameter() method found here to add parameters to the line items which cannot be set by one of the many methods already in the file to add line items to the TransactionBuilders internal _model array.

I will open a pull request in the next day or two so that this can be examined and I can provide the code that goes along with it to show how I am using it.

PHP 8 Support

Hi,
As far as I see, the SDK has a lot of issues with PHP8:

Deprecated: Required parameter $countryCode follows optional parameter $filter in
/vendor/avalara/avataxclient/src/Methods.php
on line 4214

Deprecated: Required parameter $countryCode follows optional parameter $filter in
/vendor/avalara/avataxclient/src/Methods.php
on line 4240

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 6498

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 6644

Deprecated: Required parameter $model follows optional parameter $include in
vendor/avalara/avataxclient/src/Methods.php
on line 6862

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 8893

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 8948

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9125

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9178

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9234

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9297

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9337

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9574

Deprecated: Required parameter $documentType follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9640

Deprecated: Required parameter $useTaxDateOverride follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9640

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9640

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9693

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9836

Deprecated: Required parameter $model follows optional parameter $include in
/vendor/avalara/avataxclient/src/Methods.php
on line 9890

Deprecated: Required parameter $environment follows optional parameter $machineName in
/vendor/avalara/avataxclient/src/Client.php
on line 57

Can you please update the SDK accordingly?

Thank you,

Keep SDK version in constant and use it across requests

I would like to suggest slight change of how this SDK passes its version in API calls. Currently Avalara\AvaTaxClientBase::restCall() has $apiversion argument which is used for creating X-Avalara-Client header. This method is used maaaaaany times in Avalara\AvaTaxClient, which is generated by AvaTax SDK process. It leads to huge diff where most of the changes are bumped version number in several restCall() calls.

It would be much better if Avalara\AvaTaxClient::SDK_VERSION was introduced, and then its value could be automatically updated by AvaTax SDK process. Then, in every restCall() this constant could be used instead of hardcoded value.

It would drastically improve each release's diff because only 1 line would be changed in terms of SDK version. It would allow people to get familiar only with actual changes in the SDK version.

Timeout Hardcoded

While the AvaTaxClient supports passing guzzle parameters to it, the 'timeout' param is getting overwritten in AvaTaxClientBase::restCall:181 with a value of 20 minutes:

// timeout for 1200s (20 min)
$guzzleParams['timeout'] = 1200;

While it's good to use some type of default, I think it would make more sense to timeout at 30 seconds, and also not overwrite a value that's being passed in.

It may also be useful to set a default for 'connect_timeout' so connections don't hang forever.

How do I specify a unit for parameters that accept units?

I am trying to add a NetWeight parameter that accepts a value and unit according to the documentation.

The code does not seem to allow this:

/**
* Add a parameter to the current line
*
* @param string name
* @param string value
* @return TransactionBuilder
*/
public function withLineParameter($name, $value)
{
$li = $this->getMostRecentLineIndex();
if (empty($this->_model['lines'][$li]['parameters'])) {
$this->_model['lines'][$li]['parameters'] = [];
}
$this->_model['lines'][$li]['parameters'][$name] = $value;
return $this;
}

Client.php not allowing JSON error returns from the AvaTax API

I have been testing the PHP SDK over the last few days and was running into a problem where I was receiving strings back as error messages in cases where I was purposefully botching the postal code at the invoice level. I finally tracked this down to L#141 in the Avalara\Client.php file. For some reason when the AvaTax API returns this HTTP 403 this is raised as an exception by the Promise from Guzzle and thus falls into this catch statement where $e->getMessage(); is returned and this results in a truncated string error being returned.

I will get some screenshots together to add to this issue.

Try/catch is not firing on exception and server is responding with 502 error for transaction with invalid addresses

Cannot get the system to catch exception and server returns a 502 response assumed to be when an invalid address is supplied as providing a valid address does not cause an error. Used to be able to see the exceptions thrown but a 502 response is sent immediately after $tb->create() using PHP SDK v23.7.0.

Invalid address:
{
"line1": "123 Test Street",
"line2": "",
"line3": null,
"city": "City",
"region": "Alabama",
"postal_code": "12345",
"country_code": "US"
}

$client = new AvaTaxClient('Test', '1.0', 'n/a', 'sandbox');
$client->withLicenseKey(ACCOUNT_ID, KEY);
$client->withCatchExceptions(true); //doesn't matter if I include, exclude to change true to false

$tb = new TransactionBuilder($client, 'Test', DocumentType::C_SALESORDER, $id);

....withLine()

$tb->withAddress('SingleLocation', $address_line1, $address_line2, $address_line3, $address_city, $address_region, $address_postal_code, $address_country_code);

$tb->create() is wrapped in try/catch with the following catch statements not firing and immediately producing a 502 response:

catch (\GuzzleHttp\Exception\ClientException $e)
catch (\Exception $e)
catch (\Throwable $e)

Has something changed that I need to configure to capture an exception in this regard?

Thank you.

Adding custom line params with SDK

👋,

Via the API we are able to insert a custom line number. I do see this functionality via the SDK.

I've attempted using ->withLineParameter('number', 'customNumber'), but not matter what parameter I add it's invalid.

{"error":{"code":"InvalidParameter","message":"The parameter 'number' is not a valid parameter.","target":"IncorrectData (truncated...)\n

Any info on this is greatly appreciated.

Magento 2.4.4 setup:di:compile error for lib 23.6.0

Hello Team,
how r u there?

we, Astound team, are working to deliver a new version of AvaTax extension 2.2.10 that supports Magento 2.4.4.
unfortunately, we have an issue with your lib latest version 23.6.0 during setup:di:compile command.
please, review the screenshot.

steps to reproduce:
install magento 2.4.4 with PHP 8.1.0
composer require avalara/avatax-magento:2.2.10-alpha4
php ./bin/magento setup:upgrade
php ./bin/magento setup:di:compile

exception:
Deprecated Functionality: Optional parameter $machineName declared before required parameter $environment is implicitly treated as a required parameter in /var/www/html/vendor/avalara/avataxclient/src/ClientExtensionExa
mple.php on line 21

it could be fixed with such enhancement.
fix looks like a minor but fixing it this week will help us to bring the requested 2.2.10 release quicker for Avalara.
could we resolve an issue this week?

thank you :)

Option to enable exception throwing

Hi,

for external framework developers its hard that all exceptions hard catched.

I think its better to make this configureable, so external developers can catch this exception and display the problem to the user. Currently we have to check if the result is a string or an object, to decide next.

What do you think?

AvaTaxClient methods no longer returning API JSON error message for HTTP 4** etc responses.

Using Composer I recently updated the SDK source, this took me from RestClient 22.10.0 to 23.5.0. Unfortunately my code no longer works as it did previously because the AvaTaxClient method -

refundTransaction($companyCode, $transactionCode, $include=null, $documentType=null, $useTaxDateOverride=null, $model=null)

  • is NOT returning the Error JSON/text as it did previously it infact returns an empty string not the

I have Not changed the default of the AvaTaxClient to return the response rather than throw an exception.

I had previously added logging code by extending the AvaTaxClient class and adding a middleware History handler ( Middleware::history) to guzzel's handler Stack ( $handlerStack->push($history) ).

Using this history handler to retrieve the API response I can obtain the following structure from guzzel's response stream -

{
"error": {
"code": "EntityNotFoundError",
"message": "Document not found.",
"target": "HttpRequest",
"details": [
{
"code": "EntityNotFoundError",
"number": 4,
"message": "Document not found.",
"description": "The Document with ID 'b295bd0a-f8c1-428f-90cd-example304baa' was not found.",
"faultCode": "Client",
"helpLink": "https://developer.avalara.com/avatax/errors/EntityNotFoundError",
"severity": "Error"
}
]
}
}

Which is exactly what the previous version ( 22.10. 0) of the SDK, was returning from the refundTransaction() method. This may well be the case for other AvaTaxClient methods as they appear to go through the same restCall() Method, though I have not yet tested the ones I use.

guzzle 6.3.0 ?

says avalara/avataxclient 17.5.0.67 requires guzzlehttp/guzzle 5.* but I have some other packages that use guzzle 6.3.0. any plans to update avataxclient ?

DocumentType class is missing

there is no class named DocumentType in avalara\avalarataxclient\src
but you are using it here
new TransactionBuilder($client, "DEFAULT", Avalara\DocumentType::C_SALESINVOICE, 'ABC');

how to handle it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.