Although the TaxJar API accepts line item IDs of type string, when a numeric string is encountered, the corresponding response line item ID is returned as an integer rather than the request body's type of string.
When this error was previously identified, the accepted resolution in PR #8 was to modify the underlying OrderLineItem struct to decode ID values as json.Number rather than string, since the JSON number literal type will accept numeric string values.
While this change addressed the API's potential internal modification of ID value types, it did not account for the possibility of special characters (or letters) being included in item identifiers as raised in Issue #16.
Description
If a type error is encountered when Unmarshal-ing transaction request JSON and that type error is due to a numeric line item ID in the API response, we will no longer return an error. This will still surface all other errors, including other type errors on this field.
Testing
"Live"-token Order and Refund CRUD tests were failing due to Unmarshal error prior to these changes, but are no longer.
Additionally, UpdateOrder and UpdateRefund live tests had to be modified to account for API updates that include the requirement that shipping amount be included in the request body grand total amount.
Context
Although the TaxJar API accepts line item IDs of type
string
, when a numeric string is encountered, the corresponding response line item ID is returned as aninteger
rather than the request body's type ofstring
.When this error was previously identified, the accepted resolution in PR #8 was to modify the underlying
OrderLineItem
struct to decode ID values asjson.Number
rather thanstring
, since the JSON number literal type will accept numeric string values.While this change addressed the API's potential internal modification of ID value types, it did not account for the possibility of special characters (or letters) being included in item identifiers as raised in Issue #16.
Description
If a type error is encountered when
Unmarshal
-ing transaction request JSON and that type error is due to a numeric line item ID in the API response, we will no longer return an error. This will still surface all other errors, including other type errors on this field.Testing
WIth API key set in environment (live mode)
Without API key set in environment