taxjar / taxjar.net Goto Github PK
View Code? Open in Web Editor NEWSales Tax API Client for .NET / C#
Home Page: https://developers.taxjar.com/api/reference/?csharp
License: MIT License
Sales Tax API Client for .NET / C#
Home Page: https://developers.taxjar.com/api/reference/?csharp
License: MIT License
I received an email from TaxJar indicating that we need to start using the "x-api-version" header but it doesn't appear this SDK supports it.
https://support.taxjar.com/article/1060-how-do-i-use-the-latest-version-of-the-taxjar-api
Is this .Net Nuget SDK still supported?
We have a .net core 2 project that we are having issues with TaxJar running on our servers but not our local developer machines. We are getting "could not load TaxJar" because file can't be found. The file is clearly on the server along with all other dependencies. We have uninstalled/re-installed the package. We have insured we have the latest version (3.0.2). The server only has .net core installed. Are there any other dependencies or requirements for deployment?
Using the example provided here: https://developers.taxjar.com/api/reference/#get-show-tax-rates-for-a-location
Throws the following:
InvalidCastException: Null object cannot be converted to a value type.
System.Convert.ChangeType(object value, Type conversionType, IFormatProvider provider)
JsonSerializationException: Error converting value {null} to type 'System.Decimal'. Path 'rate.super_reduced_rate', line 1, position 34.
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, object value, CultureInfo culture, JsonContract contract, Type targetType) in JsonSerializerInternalReader.cs, line 989
props maybe need to be marked as nullable?
Am I correct in thinking I can pass the x-api-version HTTP request header:
HEADER: "x-api-version: 2022-01-24"
via the following line of code:
client.headers.Add("x-api-version", "2022-01-24");
Or is this already hard-coded somewhen in the library?
This package requires the unsigned version of RestSharp package. If there is a need for a co-existing package in the same project that relies on the signed version of RestSharp - RestSharpSigned, then the two cannot work in the same project.
Would it be possible to provide a second option for a signed version of taxjar.net? In the meantime I'll have to maintain my own version.
Taxjar.TaxjarException: 'Unprocessable Entity - Something could not be processed'
I'm getting this generic error when creating an error.
Is there any way to get more info to help with troubleshooting?
Is there a way to expose the raw request and raw response so I could paste that into PostMan and troubleshoot?
Running off V3 now.
Thanks for your help!
I noticed in the source code that async versions of 'UpdateOrder' and 'UpdateRefund' (there might be others) are ignoring the 'TransactionId' property from the dotnet entities.
this is from the async method:
var transactionId = parameters.GetType().GetProperty("transaction_id").GetValue(parameters).ToString();
this was leading to a NullReferenceException when using the Taxjar.Order object.
Problem was solved when after switching to the synchronous version of UpdateOrder.
this is from the synchronous method:
var transactionIdProp = parameters.GetType().GetProperty("transaction_id") ?? parameters.GetType().GetProperty("TransactionId");
After installing version 4.0.0 of TaxJar and attempting to instantiate a new instance of TaxjarApi. When calling a new instance, the program is throwing a Method Not Found error.
System.MissingMethodException: 'Method not found: 'Void RestSharp.RestClient..ctor(RestSharp.RestClientOptions, System.Action`1<System.Net.Http.Headers.HttpRequestHeaders>)'.'
public TaxJarInterface(ITaxJarSecurity taxJarSecurity, int timeout = 0)
{
if (string.IsNullOrEmpty(taxJarSecurity.ApiKey))
throw new ArgumentNullException("apiToken", "Please provide an API token");
ApiInterface = new TaxjarApi(taxJarSecurity.ApiKey)
{
apiUrl = $"https://{(!taxJarSecurity.DemoMode ? TaxJarConstants.DefaultApiUrl : TaxJarConstants.SandboxApiUrl)}",
timeout = timeout
};
}
The Breakdown object has Shipping and LineBreadowns. All 3 of these objects have very similar properties. The common properties be put into a BaseBreakdown and individual breakdowns (Shipping, Line) could inherit. Any reason this couldn't be done?
Our README examples mainly use anonymous types to pass data for API requests. Let's add new examples using request entities so the data is easier to manage prior to passing it to a client method.
Currently our client is compiled against RestSharp v106.5.4. Let's upgrade to v106.6.9 and compile using the latest version.
TaxJar version 3.3.2 in NuGet requires Newtonsoft.Json minimum version 12.0.3 (if I'm reading the NPM description properly). I have Newtonsoft.Json v 13.0.1 already installed and I'm getting "Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0....The located assembly's manifest definition does not match the assembly reference" when I call a TaxJar method at runtime.
I've tried downgrading Newtonsoft to v12, which works for this problem but causes others which depend on v13.
Can TaxJar be updated to accept Newtonsoft.Json 13?
Thanks, Dave
Can you post example code where multiple line items are added to a TaxForOrder call but the line items are stored in an array which needs to be looped through using foreach?
The client's timeout property is of type int. It gets multiplied internally by 1000 to convert to milliseconds.
This is a limitation as it does not allow me to set a timeout of 1.5 seconds (1500 milliseconds).
The property should be more flexible (e.g. TimeSpan).
With TaxForOrderAsync using either of the Product Tax Codes 20010 or 20041, the amount to collect is always 0.
Any idea why? We have tried several states.
Please consider adding support for .net core on nuget either via a .netstandard1.x or PCL target.
Hi,
I was comparing this Tax
class to the API for Calculating sales tax for an order and noticed shouldn't certain fields be nullable? For example, Tax.Amount
and Tax.Shipping
should be of type decimal?
, right? Shouldn't any parameter that is considered optional in the API docs be nullable? When serializing any classes before sending them to the API (
taxjar.net/src/Taxjar/TaxjarApi.cs
Line 120 in 02a0d1c
null
(or nothing if NullValueHandling = NullValueHandling.Ignore
is being set).
This should be changed in all classes that have optional API parameters not just the Tax class referenced above.
Thanks!
Requesting validation of RestSharp latest, 108.0.1, and update of package references.
All of the API entities rely on the Newtonsoft JsonProperty
attribute to serialize correctly. By default RestSharp does not use Newtonsoft JsonNetSerializer which means the request body does not get serialized with the correct property names
For example nexus_addresses should look like this:
"nexus_addresses": [{
"id": null,
"country": "US",
"zip": null,
"state": "AZ",
"city": null,
"street": null
}],
instead it gets serialized (When using the NexusAddress
class instead of just a dynamic) as:
"nexus_addresses": [{
"Id": null,
"Country": "US",
"Zip": null,
"State": "AZ",
"City": null,
"Street": null
}],
Notice the casing.
This caused the API to return incorrect tax information as I'm assuming the nexus addresses do not get deserialized properly and are required for my use case.
To fix this we could set the Serializer when building the RestRequest Note: you will need to reference the package RestSharp.Serializers.NewtonsoftJson
var request = new RestRequest(action, method)
{
RequestFormat = DataFormat.Json, JsonSerializer = new JsonNetSerializer()
};
Hey thanks for the SDK its useful, however we are finding several gaps that we'd like to be able to include ourselves such as retry policies and things of that nature.
Any plans for this, or would you be willing to look at a PR contribution to open up some extensibility points?
@kdcllc has a PR out that appears to be a very good start but we'd like to open up access to be able to hook in Polly retry policies maybe as an optional parameter to the TaxJarApi or some such.
Polly in the .NET world is somewhat ubiquitous nowadays for people to implement really effective retry policies and most projects that require resiliency are very likely to already have some set of Polly policy builders and such so we believe this would be a great addition to the TaxJar .NET SDK.
While using the API, I came across an issue where I was getting an "object reference not set to an instance of an object" error. Debugging led me to the TaxForOrder method, but there was no further information about the error.
Eventually I was able to determine the issue was that I was missing the System.ValueTuple reference, which was causing RestSharp to fail (the request never went out). RestSharp in turn handled this error internally and returned a response object (without throwing any errors). the response object contains an error message which is how I was able to figure out I was missing a reference. This information, however, was not available as a consumer of the client. I had to use the source code to figure out what was going on.
The SendRequest method is not handling error conditions from RestSharp and simply returns a response with null content, which causes the null reference error mentioned above in TaxForOrder when attempting to deserialize the response.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.