Giter VIP home page Giter VIP logo

taxjar-php's People

Contributors

acdameli avatar andyg5000 avatar bobbarn avatar fastdivision avatar kylechallis avatar rrehbein avatar scottrudiger avatar sethobey avatar sethobey-stripe avatar vladimirrebilly 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  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

taxjar-php's Issues

Exception handling

I'm trying to handle exceptions from TaxJar but I'm unable to effectively due to a single exception for all issues. For example, an invalid address is a very different scenario to a country not being supported in terms of fallback/actions to take.

Do you have any suggestions on how one might catch these and act accordingly? I can't see that there's an endpoint to check whether a country is supported up-front to get around the issue that way.

Do I need to interrogate/case switch on a strstr of the exception message? Are these likely to ever change?

taxjar is not working for any of the method

i have put all the taxjar required files for php using composer in vendor folder, vendor folder is in application/libraries/taxjar folder. my vendor folder structure is

                    vendor
                              composer
                              guzzlehttp
                              psr
                              taxjar
                              autoload.php

i put just a simple code to calculate tax for an order and it is not returing anything. The code i placed is

`require_once($_SERVER['DOCUMENT_ROOT'].'/application/libraries/taxjar/vendor/autoload.php');

	$client = TaxJar\Client::withApiKey("[REDACTED]");

	$order_taxes = $client->taxForOrder([
		'from_country' => 'US',
		'from_zip' => '07001',
		'from_state' => 'NJ',
		'to_country' => 'US',
		'to_zip' => '07446',
		'to_state' => 'NJ',
		'amount' => 16.50,
		'shipping' => 1.5,
		'line_items' => [
			[
  				'quantity' => 1,
  				'unit_price' => 15.0,
  				'product_tax_code' => 31000
			]
		]
	]);
            var_dump($order_taxes);`

where have i gone wrong ?

guzzlehttp upgrade

Can this package work with guzzlehttp/guzzle ^7.0.1?
Currently your composer.json has ^6.0.2.
Thanks

TaxJar\Client->createOrder() throws "GuzzleHttp\Exception\ClientException" with "Client error: 422".

TaxJar\Client->createOrder() throws GuzzleHttp\Exception\ClientException with Client error: 422.

Code worked fine Friday evening, and it is broken now in Monday morning (Office was closed for the weekend and the local wich-doctor assures there's no ghosts here 😉.).

Following is the stack trace:

#0 __PROJECT_ROOT__/vendor/guzzlehttp/promises/src/Promise.php(199): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#1 __PROJECT_ROOT__/vendor/guzzlehttp/promises/src/Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#2 __PROJECT_ROOT__/vendor/guzzlehttp/promises/src/TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#3 __PROJECT_ROOT__/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(96): GuzzleHttp\Promise\TaskQueue->run()
#4 __PROJECT_ROOT__/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(123): GuzzleHttp\Handler\CurlMultiHandler->tick()
#5 __PROJECT_ROOT__/vendor/guzzlehttp/promises/src/Promise.php(240): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#6 __PROJECT_ROOT__/vendor/guzzlehttp/promises/src/Promise.php(217): GuzzleHttp\Promise\Promise->invokeWaitFn()
#7 __PROJECT_ROOT__/vendor/guzzlehttp/promises/src/Promise.php(261): GuzzleHttp\Promise\Promise->waitIfPending()
#8 __PROJECT_ROOT__/vendor/guzzlehttp/promises/src/Promise.php(219): GuzzleHttp\Promise\Promise->invokeWaitList()
#9 __PROJECT_ROOT__/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#10 __PROJECT_ROOT__/vendor/guzzlehttp/guzzle/src/Client.php(130): GuzzleHttp\Promise\Promise->wait()
#11 __PROJECT_ROOT__/vendor/guzzlehttp/guzzle/src/Client.php(88): GuzzleHttp\Client->request('post', 'transactions/or...', Array)
#12 __PROJECT_ROOT__/vendor/taxjar/taxjar-php/lib/Client.php(94): GuzzleHttp\Client->__call('post', Array)
#13 __PROJECT_ROOT__/vendor/taxjar/taxjar-php/lib/Client.php(94): GuzzleHttp\Client->post('transactions/or...', Array)
#14 __PROJECT_ROOT__/app/Providers/Tax/TaxJar/TaxService.php(69): TaxJar\Client->createOrder(Array)

Following is the debug log:

* Hostname was NOT found in DNS cache
* Trying 204.236.224.144...
* Connected to api.taxjar.com (204.236.224.144) port 443 (#6)
* successfully set certificate verify locations: 
* CAfile: none CApath: /etc/ssl/certs 
* SSL connection using ECDHE-RSA-AES128-GCM-SHA256 
* Server certificate: 
* subject: OU=Domain Control Validated; CN=api.taxjar.com 
* start date: 2014-09-23 14:43:22 GMT 
* expire date: 2016-09-23 14:43:22 GMT 
* subjectAltName: api.taxjar.com matched 
* issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2 
* SSL certificate verify ok. 

> POST /v2/taxes HTTP/1.1 Authorization: Bearer __API_KEY__ User-Agent: GuzzleHttp/6.0.2 curl/7.35.0 PHP/5.5.9-1ubuntu4.12 Content-Type: application/json Host: api.taxjar.com Content-Length: 142 
* upload completely sent off: 142 out of 142 bytes 
< HTTP/1.1 200 OK 
* Server Cowboy is not blacklisted 
< Server: Cowboy 
< Connection: keep-alive 
< Date: Tue, 29 Sep 2015 02:23:53 GMT 
< Status: 200 OK 
< Content-Type: application/json 
< Content-Length: 181 
< Vary: Origin 
< Etag: "ec670ee2dd3793e90fec6e9f299ee3ee" 
< Cache-Control: max-age=0, private, must-revalidate 
< X-Request-Id: 7cc5c3d1-6810-48f2-8162-6303a9d15997 
< X-Runtime: 0.041539 
< Via: 1.1 vegur 
< 
* Connection #6 to host api.taxjar.com left intact 
* Found bundle for host api.taxjar.com: 0x7f397c276860 
* Re-using existing connection! (#6) with host api.taxjar.com 
* Connected to api.taxjar.com (204.236.224.144) port 443 (#6)

> POST /v2/transactions/orders HTTP/1.1 Authorization: Bearer __API_KEY__ User-Agent: GuzzleHttp/6.0.2 curl/7.35.0 PHP/5.5.9-1ubuntu4.12 Content-Type: application/json Host: api.taxjar.com Content-Length: 273 
* upload completely sent off: 273 out of 273 bytes 
< HTTP/1.1 422 Unprocessable Entity 
* Server Cowboy is not blacklisted 
< Server: Cowboy 
< Connection: keep-alive 
< Date: Tue, 29 Sep 2015 02:23:54 GMT 
< Status: 422 Unprocessable Entity 
< Content-Type: application/json 
< Content-Length: 89 
< Vary: Origin 
< Cache-Control: no-cache 
< X-Request-Id: 729d3cf9-1a76-43eb-aca3-f2e056fe1232 
< X-Runtime: 0.323102 
< Via: 1.1 vegur 
< 
* Connection #6 to host api.taxjar.com left intact 

'validateAddress' issue?

I've loaded v1.8.0 into a working copy and tried to use the validateAddress method just included using the values used in the unittest:

$client = TaxJar\Client::withApiKey(TAXJAR_API_KEY);
$validation = $client->validateAddress(array(
            'country' => 'US',
            'state' => 'AZ',
            'zip' => '85297',
            'city' => 'Gilbert',
            'street' => '3301 South Greenfield Rd'));

I'm receiving the following in a PHP error log:

[02-Nov-2018 11:24:14 America/New_York] PHP Fatal error:  Uncaught TaxJar\Exception: 401  –  in C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\lib\TaxJar.php:36
Stack trace:
#0 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\promises\src\FulfilledPromise.php(39): TaxJar\TaxJar->TaxJar\{closure}(Object(GuzzleHttp\Psr7\Response))
#1 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise\{closure}()
#2 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\promises\src\Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true)
#3 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\promises\src\Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#4 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\promises\src\Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#5 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\promises\src\Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#6 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\promises\src\Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#7 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\guzzle\src\Client.php(131): GuzzleHttp\Promise\Promise->wait()
#8 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\vendor\guzzlehttp\guzzle\src\Client.php(89): GuzzleHttp\Client->request('post', 'addresses/valid...', Array)
#9 C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\lib\Client.php(314): GuzzleHttp\Client->__call('post', Array)
#10 C:\xampp\htdocs\taxjartest\test_taxjar.php(21): TaxJar\Client->validateAddress(Array)
#11 {main}
  thrown in C:\xampp\htdocs\taxjartest\includes\classes\vendors\TaxJar\lib\TaxJar.php on line 36

Note that the TAXJAR_API_KEY is valid and defined correctly, as I'm able to receive output from the categories method.

Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain

Hello,
I am trying to install the taxjar-php by following instruction from https://developers.taxjar.com/api/guides/php/#php-quickstart
I am facing the below error:

Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\wamp\www\project_research\taxjar-php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:187 Stack trace: #0 C:\wamp\www\project_research\taxjar-php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\wamp\www\project_research\taxjar-php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\wamp\www\project_research\taxjar-php\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHtt in C:\wamp\www\project_research\taxjar-php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187

I tried to enable SSL to my localhost but no luck. Please help me to get out of this issue.
Thanks
JenilK

TaxJar\Client->createOrder() throws "GuzzleHttp\Exception\ClientException" with "Client error: 406"

Hi,

I get the error when creating Order, this is the example of my "json_encode" array that I pass in to createOrder():

{"transacion_id":"359","transaction_date":"2015\/10\/14","from_country":"US","from_zip":"75211","from_state":"TX","from_city":"Dallas","from_street":"4105 Rock Quarry Road, Suite 400","to_country":"US","to_zip":"36604","to_state":"Alabama","to_city":"Helsinki","to_street":"Suvilahdenkatu 9 C 65 ","amount":27.65,"shipping":5.99,"sales_tax":2.77,"line_items":[{"quantity":1,"product-identifier":50369578,"description":"Waste Pick-Up - Rainbow","unit_price":14.35},{"quantity":1,"product-identifier":50194451,"description":"Fashion Dispenser and Refill Bags","unit_price":13.3}]}

What can be the problem?

Thank you very much for your help.

-Tung

TaxJar\Client::listOrders() responds with non existing transaction IDs.

When TaxJar\Client::listOrders() is called, it fetches the following response from your API:

Call:

$taxjar = \TaxJar\Client::withApiKey ( __API_KEY__ ) ;

$orders = $taxjar -> listOrders ( [
 'from_transaction_date' => '2015/01/01' ,
 'to_transaction_date' => '2015/12/31'
] ) ;

Response:

array:3 [
  0 => "123"
  1 => "5"
  2 => "6"
]

While there are transactions with Order IDs 5 and 6 displayed in your web interface's dashboard, there is no transaction with Order ID 123.

I suspect this has to do with the examples provided in the documentation. May be example data were accidentally hard coded into the system?

Set default timeout

Default timeout with Guzzle is 0 seconds (indefinite). We should set a default timeout of 30 seconds and document how to customize the timeout via setApiConfig in the README.

Null taxes for cross-state calculations

I am currently evaluating TaxJar to use it with a custom e-commerce solution we develop for one of our clients.

We use the PHP API Client. Everything seems to work fine except for the following issue. Please not that the issue described below is not specific to the PHP API Client, because I get the same issue when accessing your API through cURL.

When I request tax to be calculated for an order with both sender's and receiver's locations in the same US state, it all works fine and I get a sensible result from the API. See the below cURL code and the result it yielded.

Request:

curl --request POST \
  --url https://api.taxjar.com/v2/taxes \
  --header 'authorization: Bearer {--API-KEY--}' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form from_country=US \
  --form from_zip=07001 \
  --form from_state=NJ \
  --form to_country=US \
  --form to_zip=07446 \
  --form to_state=NJ \
  --form amount=16.50 \
  --form shipping=1.5

Result:

{
   "tax":{
      "order_total_amount":18.0,
      "shipping":1.5,
      "taxable_amount":18.0,
      "amount_to_collect":1.26,
      "rate":0.07,
      "has_nexus":true,
      "freight_taxable":true,
      "tax_source":"destination"
   }
}

However, when I change the to_zip and to_state to be different than the from address, I get zeros for the tax values.

Request:

curl --request POST \
  --url https://api.taxjar.com/v2/taxes \
  --header 'authorization: Bearer {--API-KEY--}' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form from_country=US \
  --form from_zip=07001 \
  --form from_state=NJ \
  --form to_country=US \
  --form to_zip=20500 \
  --form to_state=DC \
  --form amount=16.50 \
  --form shipping=1.5

Result:

{
   "tax":{
      "taxable_amount":0.0,
      "amount_to_collect":0.0,
      "rate":0.0,
      "has_nexus":false,
      "freight_taxable":null,
      "tax_source":null
   }
}

If I again make the sender's state and zip to that of the receiver's, I get correct results. Why is that? Doesn't TaxJar support cross-state transactions?

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.