diff --git a/.circleci/config.yml b/.circleci/config.yml index 4c13bc82..ce322f61 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,7 +21,7 @@ jobs: run-specs-solidus-older: executor: name: solidusio_extensions/postgres - ruby_version: "2.7" + ruby_version: "3.0" steps: - checkout - browser-tools/install-browser-tools diff --git a/CHANGELOG.md b/CHANGELOG.md index bf1195f9..29f87d59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,17 @@ # Changelog +All notable changes to this project will be documented in this file. -## master +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Unreleased + +- Nothing yet. + +## v1.0.0 + +### Added -- [#193](https://github.com/SuperGoodSoft/solidus_taxjar/pull/193) Bump version requirement for `solidus_support` to ">= 0.9.0", and as a result drop support for Rails 5.2. - [#190](https://github.com/SuperGoodSoft/solidus_taxjar/pull/190) Add transaction sync batch show page - [#188](https://github.com/SuperGoodSoft/solidus_taxjar/pull/188) Show transaction sync batches in user interface - [#185](https://github.com/SuperGoodSoft/solidus_taxjar/pull/185) Backfill transactions in batches @@ -12,23 +21,16 @@ - [#158](https://github.com/SuperGoodSoft/solidus_taxjar/pull/158) Update sandbox bin stub for `solidus@3` - [#88](https://github.com/SuperGoodSoft/solidus_taxjar/pull/88) Fire `shipment_shipped` event when any shipment on an order ships. - [#81](https://github.com/SuperGoodSoft/solidus_taxjar/pull/81) Add install generator -- [#95](https://github.com/SuperGoodSoft/solidus_taxjar/pull/95) Only require "state" for Canadian and US addresses - [#98](https://github.com/SuperGoodSoft/solidus_taxjar/pull/98) Add generator for TaxJar transaction IDs - [#103](https://github.com/SuperGoodSoft/solidus_taxjar/pull/103) Add `reporting_enabled` configuration option - [#97](https://github.com/SuperGoodSoft/solidus_taxjar/pull/97) Add public API method to request the latest transaction associated with a solidus order. - [#100](https://github.com/SuperGoodSoft/solidus_taxjar/pull/100) Add public API method to post a taxjar refund transaction for a solidus order. - [#102](https://github.com/SuperGoodSoft/solidus_taxjar/pull/102) Add description to transaction line item params -- [#107](https://github.com/SuperGoodSoft/solidus_taxjar/pull/107) Fix rails-engine binstub to point to correct engine entry point - [#108](https://github.com/SuperGoodSoft/solidus_taxjar/pull/108) Add new model associated with a `Spree::Order` to represent taxjar order creation transactions -- [#117](https://github.com/SuperGoodSoft/solidus_taxjar/pull/117) Fix migration install - [#114](https://github.com/SuperGoodSoft/solidus_taxjar/pull/114) Add new model associated with a `SuperGood::SolidusTaxjar::OrderTransaction` to represent taxjar refund creation transactions - [#116](https://github.com/SuperGoodSoft/solidus_taxjar/pull/116) Update the `OrderTransaction` model to record the transaction date. -- [#120](https://github.com/SuperGoodSoft/solidus_taxjar/pull/120) Change default `SOLIDUS_BRANCH` and `RAILS_VERSION` - [#109](https://github.com/SuperGoodSoft/solidus_taxjar/pull/109) Save `OrderTransaction` after API call to TaxJar -- [#119](https://github.com/SuperGoodSoft/solidus_taxjar/pull/119) Move the install generator into the correct path so that it will be installed in the dummy app. - [#111](https://github.com/SuperGoodSoft/solidus_taxjar/pull/111) Create a new taxjar transaction when a shipment is shipped. -- [#137](https://github.com/SuperGoodSoft/solidus_taxjar/pull/137) Only run tests against solidus 2.11. This also represents the drop of official support for solidus 2.9 and 2.10. -- [#137](https://github.com/SuperGoodSoft/solidus_taxjar/pull/137) Run tests against the most up to date versions of solidus. - [#141](https://github.com/SuperGoodSoft/solidus_taxjar/pull/141) Handle unimplemented reporting features - [#129](https://github.com/SuperGoodSoft/solidus_taxjar/pull/129) Report transaction asynchronously when a shipment is shipped. - [#127](https://github.com/SuperGoodSoft/solidus_taxjar/pull/127) Add acceptance test for calculating taxes with the extension. @@ -38,29 +40,68 @@ - [#174](https://github.com/SuperGoodSoft/solidus_taxjar/pull/174) Provide a link to Taxjar state settings - [#177](https://github.com/SuperGoodSoft/solidus_taxjar/pull/177) Make nexus caching configurable - [#169](https://github.com/SuperGoodSoft/solidus_taxjar/pull/169) Add basic backfill transaction functionality -- [#181](https://github.com/SuperGoodSoft/solidus_taxjar/pull/181) Take all non-tax adjustment types into account when calculating a line item's discount -- [#182](https://github.com/SuperGoodSoft/solidus_taxjar/pull/182) Automatically create default Tax Rate - [#176](https://github.com/SuperGoodSoft/solidus_taxjar/pull/176) Create refund transaction database models when reporting refunds. - [#192](https://github.com/SuperGoodSoft/solidus_taxjar/pull/192) Handle failures that occur in the middle of refunding a transaction. - [#194](https://github.com/SuperGoodSoft/solidus_taxjar/pull/194) Move the transaction backfill button to it's own unique page - [#198](https://github.com/SuperGoodSoft/solidus_taxjar/pull/198) Don't create zero dollar transactions when an order is fully refunded. - [#195](https://github.com/SuperGoodSoft/solidus_taxjar/pull/195) Run transaction backfills asynchronously -- [#200](https://github.com/SuperGoodSoft/solidus_taxjar/pull/200) Expand solidus gem into dependencies to support Solidus 3.2+ +- [#200](https://github.com/SuperGoodSoft/solidus_taxjar/pull/200) Expand `solidus` gem into dependencies to support Solidus 3.2+ - [#183](https://github.com/SuperGoodSoft/solidus_taxjar/pull/183) Add ability to fetch tax codes from TaxJar and assign to tax categories in admin - [#200](https://github.com/SuperGoodSoft/solidus_taxjar/pull/200) Render error message when backfilling transactions fails - [#203](https://github.com/SuperGoodSoft/solidus_taxjar/pull/203) Remove outdated backfill button - [#202](https://github.com/SuperGoodSoft/solidus_taxjar/pull/202) Add TaxJar transaction sync status to order show page - [#204](https://github.com/SuperGoodSoft/solidus_taxjar/pull/204) Add page to render an orders TaxJar transactions - [#201](https://github.com/SuperGoodSoft/solidus_taxjar/pull/201) Allow transaction backfills to be filtered by date range +- [#244](https://github.com/SuperGoodSoft/solidus_taxjar/pull/244) Let admins manually retry syncing failed TaxJar transactions +- [#255](https://github.com/SuperGoodSoft/solidus_taxjar/pull/255) Add a delay before reporting transactions +- [#253](https://github.com/SuperGoodSoft/solidus_taxjar/pull/253) Fix various bugs with reporting refund transactions + +### Changed + +- [#95](https://github.com/SuperGoodSoft/solidus_taxjar/pull/95) Only require "state" for Canadian and US addresses +- [#181](https://github.com/SuperGoodSoft/solidus_taxjar/pull/181) Take all non-tax adjustment types into account when calculating a line item's discount +- [#182](https://github.com/SuperGoodSoft/solidus_taxjar/pull/182) Automatically create default Tax Rate - [#205](https://github.com/SuperGoodSoft/solidus_taxjar/pull/205) Use nexus regions for taxable address checks - [#218](https://github.com/SuperGoodSoft/solidus_taxjar/pull/218) Removed `order_recalculated` event backport - [#216](https://github.com/SuperGoodSoft/solidus_taxjar/pull/216) Add `deface` as a dependency. - [#217](https://github.com/SuperGoodSoft/solidus_taxjar/pull/217) Handle updates to orders that have not been reported - [#227](https://github.com/SuperGoodSoft/solidus_taxjar/pull/227) Fix reporting for orders with refunds +- [#226](https://github.com/SuperGoodSoft/solidus_taxjar/pull/226) Refactor reporting subscriber logic +- [#238](https://github.com/SuperGoodSoft/solidus_taxjar/pull/238) Drop support for loading of reporting subscriber for Solidus < 2.11 +- [#237](https://github.com/SuperGoodSoft/solidus_taxjar/pull/237) Sort order transactions by `created_at` +- [#236](https://github.com/SuperGoodSoft/solidus_taxjar/pull/236) Don't send cancelled or returned line items +- [#225](https://github.com/SuperGoodSoft/solidus_taxjar/pull/225) Create sync logs for replace transaction jobs +- [#231](https://github.com/SuperGoodSoft/solidus_taxjar/pull/231) Load Solidus factories using new conventions +- [#246](https://github.com/SuperGoodSoft/solidus_taxjar/pull/246) Fix bugs with sync retries when reporting or replacing a transaction fails + +### Removed + +- [#137](https://github.com/SuperGoodSoft/solidus_taxjar/pull/137) Only run tests against Solidus 2.11. This also represents the drop of official support for Solidus 2.9 and 2.10. +- [#193](https://github.com/SuperGoodSoft/solidus_taxjar/pull/193) Bump version requirement for `solidus_support` to ">= 0.9.0", and as a result drop support for Rails 5.2. + +### Fixed + +- [#107](https://github.com/SuperGoodSoft/solidus_taxjar/pull/107) Fix rails-engine binstub to point to correct engine entry point +- [#117](https://github.com/SuperGoodSoft/solidus_taxjar/pull/117) Fix migration install +- [#119](https://github.com/SuperGoodSoft/solidus_taxjar/pull/119) Move the install generator into the correct path so that it will be installed in the dummy app. +- [#250](https://github.com/SuperGoodSoft/solidus_taxjar/pull/250) Improve error handling for `ReportTransactionJob` +- [#254](https://github.com/SuperGoodSoft/solidus_taxjar/pull/254) Get tests and binstubs working against Solidus `main` + +### Development Changes + +These changes only affect the development of this extension. + +- [#120](https://github.com/SuperGoodSoft/solidus_taxjar/pull/120) Change default `SOLIDUS_BRANCH` and `RAILS_VERSION` +- [#137](https://github.com/SuperGoodSoft/solidus_taxjar/pull/137) Run tests against the most up to date versions of Solidus +- [#249](https://github.com/SuperGoodSoft/solidus_taxjar/pull/249) Don't depend on `webdrivers` gem -## Upgrading Instructions +### Upgrading from 0.18.x to 1.0.0 -* If you had previously configured a `Spree::TaxRate` with the name "Sales Tax", it can be deleted after upgrading, as a new `Spree::TaxRate` with the name "Solidus TaxJar Rate" will automatically be created. Alternatively, you can rename your existing `Spree::TaxRate` from "Sales Tax" to "Solidus TaxJar Rate". [#182](https://github.com/SuperGoodSoft/solidus_taxjar/pull/182) +If you had previously configured a `Spree::TaxRate` with the name "Sales Tax", +it can be deleted after upgrading, as a new `Spree::TaxRate` with the name +"Solidus TaxJar Rate" will automatically be created. Alternatively, you can +rename your existing `Spree::TaxRate` from "Sales Tax" to "Solidus TaxJar +Rate". [#182](https://github.com/SuperGoodSoft/solidus_taxjar/pull/182) ## v0.18.2 diff --git a/Gemfile b/Gemfile index 8aa23ace..541efda3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ -source "https://rubygems.org" +# frozen_string_literal: true +source "https://rubygems.org" git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } branch = ENV.fetch("SOLIDUS_BRANCH", "v3.1") @@ -35,6 +36,13 @@ group :development, :test do gem "pry" gem "pry-stack_explorer" gem "pry-byebug" + + # FIXME: + # Once a new version of `solidus_dev_support` is released to RubyGems, we can + # use that. + gem "solidus_dev_support", + github: "solidusio/solidus_dev_support", + branch: "main" end gemspec diff --git a/README.md b/README.md index 10ff7ce1..5a90868e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # `SuperGood::SolidusTaxjar` - +[![Gem Version](https://badge.fury.io/rb/super_good-solidus_taxjar.svg)](https://badge.fury.io/rb/super_good-solidus_taxjar) [![CircleCI build status](https://circleci.com/gh/SuperGoodSoft/solidus_taxjar/tree/master.svg?style=shield)](https://circleci.com/gh/SuperGoodSoft/solidus_taxjar/tree/master) `SuperGood::SolidusTaxjar` is a [Solidus](https://github.com/solidusio/solidus) @@ -50,7 +50,7 @@ about using the Solidus TaxJar extension after it has been installed. 4. Finally, make sure that the `TAXJAR_API_KEY` environment variable is set to your TaxJar API key. -### Warning: Installing on production +### Warning: Installing on Production Before you install this extension in your production environment, **we strongly recommend that you install and configure a supported ActiveJob backend**. @@ -68,20 +68,7 @@ particularly helpful. [active-job-basics]: https://edgeguides.rubyonrails.org/active_job_basics.html [active-job-execution]: https://edgeguides.rubyonrails.org/active_job_basics.html#job-execution -## Project Status - - - -This extension is under active development and not yet at a v1.0 release, but -it's currently being used in production by multiple Solidus stores. - -Requirements for TaxJar integrations vary as some stores also need reporting, -which isn't provided out of the box by this extension. This is because -individual stores will be using different background job frameworks or runners -(Sidekiq, delayed_job, ActiveJob, etc.) and a reliable integration will rely on -one of these. Because this part of the integration is small, we've chosen to -provide the transaction reporting functionality, but have skipped directly -integrating it. +## Developer Support If you're having trouble integrating this extension with your store and would like some assistance, please reach out to Jared via e-mail at [jared@super.gd](mailto:jared@super.gd) @@ -104,9 +91,12 @@ that event to your applicaiton. This extension also supports: * syncing orders to TaxJar's reporting dashboard -* syncing nexus regions as configured in the connected TaxJar account +* syncing nexus regions as configured in the connected TaxJar account (including + automatic _and_ manual sync) * connecting your Solidus store's tax categories to TaxJar's tax categories (U.S. tax codes) +**Note that reporting is turned off by default.** + ### TaxCalculator `SuperGood::SolidusTaxjar::TaxCalculator` allows calculating the full tax @@ -240,7 +230,13 @@ Developers can configure the following settings in an initializer: Default value: `false` -### Exception handling +### Taxable Orders + +Note that the configuration setting `taxable_order_check` can be customized if +there is specific criteria that make some orders taxable and other orders not +taxable. By default this extension considers all orders taxable. + +### Exception Handling You can configure your own exception handler in an initializer. using the `exception_handler` configuration point: @@ -310,6 +306,15 @@ and `SOLIDUS_BRANCH` environment variables, respectively. See the The database vendor can also be changed from the default (`sqlite3`) by setting the `DB` environment variable. +### Testing the Extension + +When testing your application's integration with this extension you may use its factories. +You can load Solidus core factories along with this extension's factories using this statement: + +```ruby +SolidusDevSupport::TestingSupport::Factories.load_for(SuperGoodSolidusTaxjar::Engine) +``` + ## Releasing a New Version 1. Update the `master` header in changelog to the version that you're releasing. diff --git a/Rakefile b/Rakefile index 29cbb9de..11fe9f43 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ # frozen_string_literal: true +require "bundler/gem_tasks" require 'solidus_dev_support/rake_tasks' SolidusDevSupport::RakeTasks.install diff --git a/app/controllers/spree/admin/taxjar_transactions_controller.rb b/app/controllers/spree/admin/taxjar_transactions_controller.rb new file mode 100644 index 00000000..2689c3c3 --- /dev/null +++ b/app/controllers/spree/admin/taxjar_transactions_controller.rb @@ -0,0 +1,37 @@ +module Spree + module Admin + class TaxjarTransactionsController < Spree::Admin::BaseController + include SuperGood::SolidusTaxjar::Reportable + + def retry + order = Spree::Order.find_by number: params[:order_id] + + if transaction_replaceable? order + replace_transaction order + flash[:notice] = "Queued transaction sync job" + elsif order_reportable? order + report_transaction order + flash[:notice] = "Queued transaction sync job" + else + flash[:error] = "Could not retry sync successfully" + end + + redirect_to taxjar_transactions_admin_order_path(params[:order_id]) + end + + private + + def report_transaction(order) + with_reportable(order) do + SuperGood::SolidusTaxjar::ReportTransactionJob.perform_later(order) + end + end + + def replace_transaction(order) + with_replaceable(order) do + SuperGood::SolidusTaxjar::ReplaceTransactionJob.perform_later(order) + end + end + end + end +end diff --git a/app/jobs/super_good/solidus_taxjar/replace_transaction_job.rb b/app/jobs/super_good/solidus_taxjar/replace_transaction_job.rb index a77cbc0c..2967e9bd 100644 --- a/app/jobs/super_good/solidus_taxjar/replace_transaction_job.rb +++ b/app/jobs/super_good/solidus_taxjar/replace_transaction_job.rb @@ -6,7 +6,20 @@ class ReplaceTransactionJob < ApplicationJob queue_as { SuperGood::SolidusTaxjar.job_queue } def perform(order) - SuperGood::SolidusTaxjar.reporting.refund_and_create_new_transaction(order) + order_transaction = SuperGood::SolidusTaxjar.reporting.refund_and_create_new_transaction(order) + + SuperGood::SolidusTaxjar::TransactionSyncLog.create!( + order: order, + order_transaction: order_transaction, + status: :success + ) + + rescue Taxjar::Error => exception + SuperGood::SolidusTaxjar::TransactionSyncLog.create!( + order: order, + status: :error, + error_message: exception.message + ) end end end diff --git a/app/jobs/super_good/solidus_taxjar/report_transaction_job.rb b/app/jobs/super_good/solidus_taxjar/report_transaction_job.rb index 134d31bf..823aa294 100644 --- a/app/jobs/super_good/solidus_taxjar/report_transaction_job.rb +++ b/app/jobs/super_good/solidus_taxjar/report_transaction_job.rb @@ -13,7 +13,7 @@ def perform(order, transaction_sync_batch = nil) begin order_transaction = SuperGood::SolidusTaxjar.reporting.show_or_create_transaction(order) transaction_sync_log.update!(order_transaction: order_transaction, status: :success) - rescue Taxjar::Error => exception + rescue StandardError => exception transaction_sync_log.update!(status: :error, error_message: exception.message) end end diff --git a/app/models/super_good/solidus_taxjar/order_transaction.rb b/app/models/super_good/solidus_taxjar/order_transaction.rb index a9c0c4e3..f82a4047 100644 --- a/app/models/super_good/solidus_taxjar/order_transaction.rb +++ b/app/models/super_good/solidus_taxjar/order_transaction.rb @@ -9,7 +9,7 @@ class OrderTransaction < ActiveRecord::Base validates_presence_of :transaction_date def self.latest_for(order) - where(order: order).order(transaction_date: :desc).limit(1).first + where(order: order).order(transaction_date: :desc, created_at: :desc).limit(1).first end end end diff --git a/app/models/super_good/solidus_taxjar/transaction_sync_log.rb b/app/models/super_good/solidus_taxjar/transaction_sync_log.rb index f005d986..3bd1e774 100644 --- a/app/models/super_good/solidus_taxjar/transaction_sync_log.rb +++ b/app/models/super_good/solidus_taxjar/transaction_sync_log.rb @@ -2,6 +2,7 @@ class SuperGood::SolidusTaxjar::TransactionSyncLog < ApplicationRecord belongs_to :transaction_sync_batch, optional: true belongs_to :order, class_name: "Spree::Order" belongs_to :order_transaction, optional: true + delegate :refund_transaction, to: :order_transaction, :allow_nil => true - enum status: [:processing, :success, :error] + enum :status, [:processing, :success, :error] end diff --git a/app/overrides/spree/admin/orders_controller_override.rb b/app/overrides/spree/admin/orders_controller_override.rb index 6231ba40..d7ce6a29 100644 --- a/app/overrides/spree/admin/orders_controller_override.rb +++ b/app/overrides/spree/admin/orders_controller_override.rb @@ -1,6 +1,7 @@ module Spree module Admin module OrdersControllerOverride + # FIXME: Move this to TaxJar transactions controller. def taxjar_transactions load_order end diff --git a/app/overrides/spree/admin/shared/_configuration_menu.rb b/app/overrides/spree/admin/shared/_configuration_menu.rb deleted file mode 100644 index 5fbc78d2..00000000 --- a/app/overrides/spree/admin/shared/_configuration_menu.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -Deface::Override.new( - virtual_path: 'spree/admin/shared/_taxes_tabs', - name: 'add_taxjar_admin_menu_links', - insert_bottom: "[data-hook='admin_settings_taxes_tabs']" -) do - <<-HTML - <%= configurations_sidebar_menu_item "TaxJar Settings", edit_admin_taxjar_settings_path %> - - <%= configurations_sidebar_menu_item "TaxJar Backfill", admin_transaction_sync_batches_path %> - - <%= configurations_sidebar_menu_item "Orders That Need Taxes Filed", need_taxes_filed_admin_orders_path %> - HTML -end diff --git a/app/overrides/spree/admin/shared/_order_summary/add_taxjar_reported_at.html.erb.deface b/app/overrides/spree/admin/shared/_order_summary/add_taxjar_reported_at.html.erb.deface index 4b26e6e1..bdd3c62d 100644 --- a/app/overrides/spree/admin/shared/_order_summary/add_taxjar_reported_at.html.erb.deface +++ b/app/overrides/spree/admin/shared/_order_summary/add_taxjar_reported_at.html.erb.deface @@ -9,9 +9,10 @@ <% end %> +<% last_success_sync_log = @order.taxjar_transaction_sync_logs.success.order(:created_at).last %> <% last_sync_log = @order.taxjar_transaction_sync_logs.order(:created_at).last %>
Reported to TaxJar at:
-
<%= last_sync_log ? pretty_time(last_sync_log.created_at) : "-" %>
+
<%= last_success_sync_log ? pretty_time(last_success_sync_log.created_at) : "-" %>
TaxJar Sync:
<% last_sync_log_status = if last_sync_log @@ -26,3 +27,4 @@ <%= last_sync_log_status.capitalize %>
+
<%= link_to("TaxJar Sync History", spree.taxjar_transactions_admin_order_path(@order)) %>
diff --git a/app/overrides/spree/admin/shared/_taxes_tabs/add_configuration_menu_items.html.erb.deface b/app/overrides/spree/admin/shared/_taxes_tabs/add_configuration_menu_items.html.erb.deface new file mode 100644 index 00000000..0c1ad262 --- /dev/null +++ b/app/overrides/spree/admin/shared/_taxes_tabs/add_configuration_menu_items.html.erb.deface @@ -0,0 +1,5 @@ + + +<%= configurations_sidebar_menu_item "TaxJar Settings", edit_admin_taxjar_settings_path %> + +<%= configurations_sidebar_menu_item "TaxJar Backfill", admin_transaction_sync_batches_path %> diff --git a/app/overrides/super_good/solidus_taxjar/spree/order_override.rb b/app/overrides/super_good/solidus_taxjar/spree/order_override.rb index e073e049..1eed51f8 100644 --- a/app/overrides/super_good/solidus_taxjar/spree/order_override.rb +++ b/app/overrides/super_good/solidus_taxjar/spree/order_override.rb @@ -9,6 +9,7 @@ def self.prepended(base) inverse_of: :order base.has_many :taxjar_transaction_sync_logs, + -> { order(:created_at) }, class_name: "SuperGood::SolidusTaxjar::TransactionSyncLog", inverse_of: :order end diff --git a/app/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber.rb b/app/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber.rb index 5ad6d8fc..233ca920 100644 --- a/app/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber.rb +++ b/app/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber.rb @@ -3,84 +3,38 @@ module SolidusTaxjar module Spree class ReportingSubscriber include Omnes::Subscriber - - ORDER_TOO_OLD_MESSAGE = "Order cannot be synced because it was completed before TaxJar reporting was enabled" - - handle :shipment_shipped, with: :report_transaction - handle :order_recalculated, with: :replace_transaction - handle :reimbursement_reimbursed, with: :create_refund - - def report_transaction(event) - shipment = event.payload[:shipment] - order = shipment.order - - return unless SuperGood::SolidusTaxjar.configuration.preferred_reporting_enabled - - if completed_before_reporting_enabled?(order) - order.taxjar_transaction_sync_logs.create!(status: :error, error_message: ORDER_TOO_OLD_MESSAGE) - SuperGood::SolidusTaxjar.exception_handler.call(RuntimeError.new(ORDER_TOO_OLD_MESSAGE)) - return - end - - if reportable_order?(order) - SuperGood::SolidusTaxjar::ReportTransactionJob.perform_later(order) - end - end - - def replace_transaction(event) - return unless SuperGood::SolidusTaxjar.configuration.preferred_reporting_enabled - + include SuperGood::SolidusTaxjar::Reportable + + # FIXME: + # This is a workaround until we add a new Solidus event we can subscribe + # to. "order_recalculated" occurs too early. + # + # This delay helps us be sure that `Spree::OrderUpdater#persist_totals` + # has been called, and the `order` transaction has been completed, + # before we report this transaction to TaxJar. + # + DELAY = 2 + + handle :order_recalculated, with: :report_or_replace_transaction + handle :shipment_shipped, with: :report_or_replace_transaction + + def report_or_replace_transaction(event) order = event.payload[:order] - return unless order.completed? && order.shipped? + with_reportable(order) do + SuperGood::SolidusTaxjar::ReportTransactionJob + .set(wait: DELAY.seconds) + .perform_later(order) - if completed_before_reporting_enabled?(order) - order.taxjar_transaction_sync_logs.create!(status: :error, error_message: ORDER_TOO_OLD_MESSAGE) - SuperGood::SolidusTaxjar.exception_handler.call(RuntimeError.new(ORDER_TOO_OLD_MESSAGE)) return end - if reportable_order?(order) && transaction_replaceable?(order) && amount_changed?(order) - SuperGood::SolidusTaxjar::ReplaceTransactionJob.perform_later(order) - end - end - - def create_refund(event) - reimbursement = event.payload[:reimbursement] - order = reimbursement.order - - return unless SuperGood::SolidusTaxjar.configuration.preferred_reporting_enabled - - if reportable_order?(order) && transaction_refundable?(order) - SuperGood::SolidusTaxjar::ReportRefundJob.perform_later(reimbursement) + with_replaceable(order) do + SuperGood::SolidusTaxjar::ReplaceTransactionJob + .set(wait: DELAY.seconds) + .perform_later(order) end end - - private - - def amount_changed?(order) - # We use `order.payment_total` to ensure we capture any total changes - # from refunds. - SuperGood::SolidusTaxjar.api.show_latest_transaction_for(order).amount != - (order.payment_total - order.additional_tax_total) - end - - def completed_before_reporting_enabled?(order) - configuration = SuperGood::SolidusTaxjar.configuration - - configuration.preferred_reporting_enabled && - configuration.preferred_reporting_enabled_at > order.completed_at - end - - def reportable_order?(order) - SuperGood::SolidusTaxjar.reportable_order_check.call(order) - end - - def transaction_replaceable?(order) - order.taxjar_order_transactions.present? && order.payment_state == "paid" - end - alias transaction_refundable? transaction_replaceable? - end end end diff --git a/app/views/spree/admin/shared/_transaction_sync_log_table.html.erb b/app/views/spree/admin/shared/_transaction_sync_log_table.html.erb index 9f151b8d..dfbc3470 100644 --- a/app/views/spree/admin/shared/_transaction_sync_log_table.html.erb +++ b/app/views/spree/admin/shared/_transaction_sync_log_table.html.erb @@ -1,25 +1,34 @@ - +
- - - - - - + + + + + + + + - <% transaction_sync_logs.each do |log| %> + <% transaction_sync_logs.each.with_index(1) do |log, index| %> + + <% end %> diff --git a/bin/console b/bin/console index a62b885c..a1455529 100755 --- a/bin/console +++ b/bin/console @@ -1,5 +1,7 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require "bundler/setup" require "super_good/solidus_taxjar" require "pry" diff --git a/bin/sandbox b/bin/sandbox index aa222820..07e93225 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -1,58 +1,65 @@ #!/usr/bin/env bash - set -e +test -z "${DEBUG+empty_string}" || set -x -case "$DB" in -postgres|postgresql) - RAILSDB="postgresql" - ;; -mysql) - RAILSDB="mysql" - ;; -sqlite|'') - RAILSDB="sqlite3" - ;; -*) - echo "Invalid DB specified: $DB" - exit 1 - ;; -esac +test "$DB" = "sqlite" && export DB="sqlite3" -if [ ! -z $SOLIDUS_BRANCH ] +if [ -z "$PAYMENT_METHOD" ] then - BRANCH=$SOLIDUS_BRANCH -else - BRANCH="main" + PAYMENT_METHOD="none" fi +if [ -z "$SOLIDUS_BRANCH" ] +then + echo "~~> Use 'export SOLIDUS_BRANCH=[main|v4.0|...]' to control the Solidus branch" + SOLIDUS_BRANCH="main" +fi +echo "~~> Using branch $SOLIDUS_BRANCH of solidus" + +case $SOLIDUS_BRANCH in + v3* | v4.0* | v4.1*) + echo "~~> Using a SOLIDUS_BRANCH older than v4.2. Skipping the --admin-preview flag for compatibility." + ADMIN_PREVIEW_FLAG=" " + ;; + *) + ADMIN_PREVIEW_FLAG="--admin-preview=false" + ;; +esac + extension_name="super_good-solidus_taxjar" # Stay away from the bundler env of the containing extension. function unbundled { - ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@ + ruby -rbundler -e' + Bundler.with_unbundled_env {system *ARGV}' -- \ + env BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true $@ } +echo "~~~> Removing the old sandbox" rm -rf ./sandbox -unbundled bundle exec rails new sandbox --database="$RAILSDB" \ - --skip-bundle \ + +echo "~~~> Creating a pristine Rails app" +rails new sandbox \ + --database="${DB:-sqlite3}" \ --skip-git \ --skip-keeps \ --skip-rc \ - --skip-spring \ - --skip-test \ - --skip-javascript + --skip-bootsnap \ + --skip-test if [ ! -d "sandbox" ]; then echo 'sandbox rails application failed' exit 1 fi +echo "~~~> Adding solidus (with i18n) to the Gemfile" cd ./sandbox cat <> Gemfile -gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH' -gem 'solidus_auth_devise', '>= 2.1.0' +gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH' gem 'rails-i18n' gem 'solidus_i18n' +gem 'solidus_auth_devise' +gem "solidus_frontend" gem '$extension_name', path: '..' @@ -69,18 +76,16 @@ unbundled bundle exec rake db:drop db:create unbundled bundle exec rails generate solidus:install \ --auto-accept \ - --user_class=Spree::User \ - --enforce_available_locales=true \ - --with-authentication=false \ --payment-method=none \ + --frontend=none \ + ${ADMIN_PREVIEW_FLAG} \ $@ -unbundled bundle exec rails generate solidus:auth:install -unbundled bundle exec rails generate super_good:solidus_taxjar:install +SKIP_SOLIDUS_BOLT=true unbundled bundle exec rails generate solidus_frontend:install --auto-accept +unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations +unbundled bundle exec rails generate super_good:solidus_taxjar:install --auto-run-migrations echo echo "๐Ÿš€ Sandbox app successfully created for $extension_name!" echo "๐Ÿš€ Using $RAILSDB and Solidus $BRANCH" -echo "๐Ÿš€ Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter" -echo "๐Ÿš€ Use 'export SOLIDUS_BRANCH=' to control the Solidus version" -echo "๐Ÿš€ This app is intended for test purposes." +echo "๐Ÿงช This app is intended for test purposes." diff --git a/bin/setup b/bin/setup index dce67d86..67d91932 100755 --- a/bin/setup +++ b/bin/setup @@ -3,6 +3,6 @@ set -euo pipefail IFS=$'\n\t' set -vx -bundle install - -# Do any other automated setup that you need to do here +gem install bundler --conservative +bundle update +bin/rake clobber diff --git a/config/initializers/omnes.rb b/config/initializers/omnes.rb index 7fe2aa90..31a25a4a 100644 --- a/config/initializers/omnes.rb +++ b/config/initializers/omnes.rb @@ -8,6 +8,6 @@ tax_exemption_disapproved tax_exemption_customer_request ].each { |event_name| Spree::Bus.register(event_name) } - SuperGood::SolidusTaxjar::Spree::ReportingSubscriber.new.subscribe_to(Spree::Bus) SuperGood::SolidusTaxjar::Spree::TaxExemptionsSubscriber.new.subscribe_to(Spree::Bus) + SuperGood::SolidusTaxjar::Spree::ReportingSubscriber.new.subscribe_to(Spree::Bus) end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 593c1c68..cd4aa878 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,6 +26,8 @@ member do get :taxjar_transactions end + + post 'taxjar_transaction/retry', to: "taxjar_transactions#retry" end end end diff --git a/db/migrate/20230320211309_add_refund_transaction_to_sync_logs.rb b/db/migrate/20230320211309_add_refund_transaction_to_sync_logs.rb new file mode 100644 index 00000000..b845dee4 --- /dev/null +++ b/db/migrate/20230320211309_add_refund_transaction_to_sync_logs.rb @@ -0,0 +1,5 @@ +class AddRefundTransactionToSyncLogs < ActiveRecord::Migration[6.1] + def change + add_reference :solidus_taxjar_transaction_sync_logs, :refund_transaction, foreign_key: {to_table: :solidus_taxjar_refund_transactions}, index: {name: "index_transaction_sync_logs_on_refund_transaction_id"} + end +end diff --git a/lib/generators/super_good/solidus_taxjar/install/install_generator.rb b/lib/generators/super_good/solidus_taxjar/install/install_generator.rb index f4064a7d..3a49d463 100644 --- a/lib/generators/super_good/solidus_taxjar/install/install_generator.rb +++ b/lib/generators/super_good/solidus_taxjar/install/install_generator.rb @@ -21,14 +21,33 @@ def create_omes_initializer_file omnes_initializer_path = "config/initializers/omnes.rb" - create_file(omnes_initializer_path) unless File.exist?(omnes_initializer_path ) + create_file(omnes_initializer_path) unless File.exist?(omnes_initializer_path) append_to_file(omnes_initializer_path, <<~INIT) Rails.application.config.to_prepare do - ::Spree::Bus.register(:shipment_shipped) - SuperGood::SolidusTaxjar::Spree::ReportingSubscriber.omnes_subscriber.subscribe_to(Spree::Bus) + if SolidusSupport::LegacyEventCompat.using_legacy? + require 'super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb' + SuperGood::SolidusTaxjar::Spree::LegacyReportingSubscriber.omnes_subscriber.subscribe_to(Spree::Bus) + else + require 'super_good/solidus_taxjar/spree/reporting_subscriber.rb' + SuperGood::SolidusTaxjar::Spree::ReportingSubscriber.new.subscribe_to(Spree::Bus) + end end INIT + end + + def create_legacy_events_initializer_file + return unless Gem::Requirement.new('< 3.2') + .satisfied_by?(::Spree.solidus_gem_version) + + initializer_path = "config/initializers/solidus_taxjar_legacy_events.rb" + create_file(initializer_path) unless File.exist?(initializer_path) + append_to_file(initializer_path, <<~INIT) + Rails.application.config.to_prepare do + require 'super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb' + SuperGood::SolidusTaxjar::Spree::LegacyReportingSubscriber.activate + end + INIT end def add_migrations diff --git a/lib/super_good/engine.rb b/lib/super_good/engine.rb index 08628e80..b61d590e 100644 --- a/lib/super_good/engine.rb +++ b/lib/super_good/engine.rb @@ -5,15 +5,6 @@ class Engine < Rails::Engine isolate_namespace Spree engine_name 'super_good_solidus_taxjar' - # Solidus versions prior to 2.11.0 do not support auto-loading of subscribers - # so we need to manually register the reporting subscriber with the event - # bus. - if Spree.solidus_gem_version < Gem::Version.new('2.11.0') - require root.join('app/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber') - SuperGood::SolidusTaxjar::Spree::ReportingSubscriber.subscribe! - SuperGood::SolidusTaxjar::Spree::TaxExemptionsSubscriber.subscribe! - end - include SolidusSupport::EngineExtensions end end diff --git a/lib/super_good/solidus_taxjar.rb b/lib/super_good/solidus_taxjar.rb index 3bdb9f4f..4578e001 100644 --- a/lib/super_good/solidus_taxjar.rb +++ b/lib/super_good/solidus_taxjar.rb @@ -15,6 +15,7 @@ require "super_good/solidus_taxjar/discount_calculator" require "super_good/solidus_taxjar/addresses" require "super_good/solidus_taxjar/reporting" +require "super_good/solidus_taxjar/reportable" require "super_good/solidus_taxjar/backfill_transactions" module SuperGood diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb index 9301c6fc..fd4fe310 100644 --- a/lib/super_good/solidus_taxjar/api_params.rb +++ b/lib/super_good/solidus_taxjar/api_params.rb @@ -1,6 +1,8 @@ module SuperGood module SolidusTaxjar module ApiParams + UNTAXABLE_INVENTORY_UNIT_STATES = ["returned", "canceled"] + class << self def order_params(order) {} @@ -35,9 +37,24 @@ def tax_rate_address_params(address) }.merge(order_address_params(address)) end + def tax_amount(order) + # Sum of line items + shipping, excluding tax + line_items_total = order.line_items.sum do |line_item| + quantity = line_item.quantity + unit_price = SuperGood::SolidusTaxjar.line_item_unit_price_calculator.call(line_item) + quantity * unit_price + end + shipping_total = order.ship_total || 0 + + # Calculate total before tax + subtotal = line_items_total + shipping_total + order.promo_total + + # Ensure non-negative amount + [subtotal, 0].max + end + def transaction_params(order, transaction_id = order.number) - {} - .merge(customer_id(order)) + params = {}.merge(customer_id(order)) .merge(order_address_params(order.tax_address)) .merge(transaction_line_items_params(order.line_items)) .merge( @@ -45,10 +62,15 @@ def transaction_params(order, transaction_id = order.number) transaction_date: order.completed_at.to_formatted_s(:iso8601), # We use `payment_total` to reflect the total liablity # transferred. - amount: [order.payment_total - order.additional_tax_total, 0].max, + amount: tax_amount(order), shipping: shipping(order), sales_tax: sales_tax(order) ) + + customer_info = user_params(order&.bill_address) + params.merge!(customer_info) + + params end def refund_transaction_params(spree_order, taxjar_order) @@ -99,6 +121,29 @@ def validate_address_params(spree_address, include_street = true) params end + def user_params(address) + return {} if address.nil? + + { + customer_info: { + customer_id: address.user_id&.to_s, + name: address.company.present? ? address.company : address.name, + country: address.country.iso, + state: address.state&.abbr || address.state_name, + zip: address.zipcode, + city: address.city, + street: address.address1, + exempt_regions: address.user&.taxjar_exempt_regions&.approved&.map do |exempt_region| + state = exempt_region.state + { + state: state.abbr, + country: state.country.iso + } + end + } + } + end + def customer_params(customer) address = customer.address @@ -140,9 +185,18 @@ def order_address_params(address) } end + # @private + # This method builds line item parameters as expected by the TaxJar + # Tax API. + # + # @param line_items [Spree::LineItem::ActiveRecord_Relation] All of the + # order's line items. + # @return [Hash] A TaxJar API-friendly line item collection. def line_items_params(line_items) { - line_items: valid_line_items(line_items).map do |line_item| + line_items: line_items.filter_map { |line_item| + next unless line_item.quantity.positive? + { id: line_item.id, quantity: 1, @@ -150,16 +204,28 @@ def line_items_params(line_items) discount: discount(line_item), product_tax_code: line_item.tax_category&.tax_code } - end + } } end + # @private + # This method builds line item parameters as expected by the TaxJar + # Transactions API. Note that this logic different from + # `.line_item_params` as it excludes inventory units we consider to be + # untaxable (i.e. returned or cancelled inventory units). + # + # @param line_items [Spree::LineItem::ActiveRecord_Relation] All of the + # order's line items. + # @return [Hash] A TaxJar API-friendly line item collection. def transaction_line_items_params(line_items) { - line_items: valid_line_items(line_items).map do |line_item| + line_items: line_items.filter_map { |line_item| + quantity = line_item.quantity + next unless quantity.positive? + { id: line_item.id, - quantity: line_item.quantity, + quantity: quantity, product_identifier: line_item.sku, description: line_item.variant.descriptive_name, product_tax_code: line_item.tax_category&.tax_code, @@ -167,18 +233,10 @@ def transaction_line_items_params(line_items) discount: discount(line_item), sales_tax: line_item_sales_tax(line_item) } - end + } } end - def valid_line_items(line_items) - # The API appears to error when sent line items with no quantity... - # but why would you do that anyway. - line_items.reject do |line_item| - line_item.quantity.zero? - end - end - def discount(line_item) ::SuperGood::SolidusTaxjar.discount_calculator.new(line_item).discount end @@ -190,13 +248,47 @@ def shipping(order) def sales_tax(order) return 0 if order.total.zero? - order.additional_tax_total + order.additional_tax_total - order_reimbursement_tax_total(order) end def line_item_sales_tax(line_item) return 0 if line_item.order.total.zero? - line_item.additional_tax_total + line_item.additional_tax_total - line_item_reimbursement_tax_total(line_item) + end + + def taxable_quantity(line_item) + line_item.inventory_units + .where.not(state: UNTAXABLE_INVENTORY_UNIT_STATES) + .count + end + + def line_item_reimbursement_tax_total(line_item) + line_item + .inventory_units + .flat_map(&:return_items) + .filter { |return_item| return_item.reimbursement.present? } + .sum(&:additional_tax_total) + end + + def order_reimbursement_tax_total(order) + order.reimbursements.sum { |reimbursement| reimbursement_tax_total(reimbursement) } + end + + def reimbursement_tax_total(reimbursement) + reimbursement.return_items.sum(&:additional_tax_total) + end + + def refund_total_without_tax(order) + order.refunds.sum do |refund| + if refund.reimbursement.present? + refund.reimbursement.total - reimbursement_tax_total(refund.reimbursement) + else + # This use case represents making a line item level adjustment, and then refunding + # that amount. + refund.amount + end + end end end end diff --git a/lib/super_good/solidus_taxjar/reportable.rb b/lib/super_good/solidus_taxjar/reportable.rb new file mode 100644 index 00000000..1a896a58 --- /dev/null +++ b/lib/super_good/solidus_taxjar/reportable.rb @@ -0,0 +1,93 @@ +module SuperGood + module SolidusTaxjar + module Reportable + ORDER_TOO_OLD_MESSAGE = "Order cannot be synced because it was completed before TaxJar reporting was enabled" + + def self.included(base) + # Omnes subscribers are classes, whereas the legacy event system uses + # modules for subscribers. The type check ensures this is forwards + # compatible and can be removed when we drop support for the legacy + # event system. + base.extend(base) unless base.is_a?(Class) + end + + def with_reportable(order, &block) + raise "Please provide a block!" unless block_given? + + return unless order_reportable?(order) + return if completed_before_reporting_enabled?(order) + return unless order.taxjar_order_transactions.none? + + yield + end + + def with_replaceable(order, &block) + return unless order_reportable?(order) + return if completed_before_reporting_enabled?(order) + return unless transaction_replaceable?(order) + + yield + end + + # @return [Boolean] true if the TaxJar reporting is currently enabled + # and the order meets all the other requirements for reporting. + def order_reportable?(order) + return SuperGood::SolidusTaxjar.configuration.preferred_reporting_enabled && + order.completed? && + order.shipped? && + order.payment_state == "paid" && + %w[Spree::Order Mgx::Order::Reorder Mgx::Order::HardCopyProof].include?(order.type) && + ::Spree::TaxCategory.taxable?(order.line_items) + end + + # @return [Boolean] true if the transaction has been previously reported + # to TaxJar, the order is currently in `paid` state and there is a + # difference between the total (before tax) on the order in Solidus + # and the transaction amount on TaxJar. + def transaction_replaceable?(order) + order.taxjar_order_transactions.present? && + amount_changed?(order) + end + + private + + def completed_before_reporting_enabled?(order) + configuration = SuperGood::SolidusTaxjar.configuration + + completed_before_reporting_enabled = configuration.preferred_reporting_enabled && + configuration.preferred_reporting_enabled_at > order.completed_at + + if completed_before_reporting_enabled + log_order_too_old_to_sync(order) + end + + completed_before_reporting_enabled + end + + # Logs and notifies the custom exception handler for orders which are + # too old to be reported. If a log for this already exists a new one + # won't be created and the exception handler won't be called. + def log_order_too_old_to_sync(order) + sync_log = order.taxjar_transaction_sync_logs.find_or_initialize_by( + status: :error, + error_message: ORDER_TOO_OLD_MESSAGE + ) + + unless sync_log.persisted? + sync_log.save! + + SuperGood::SolidusTaxjar.exception_handler.call( + RuntimeError.new(ORDER_TOO_OLD_MESSAGE) + ) + end + end + + def amount_changed?(order) + # We use `order.payment_total` to ensure we capture any total changes + # from refunds. + SuperGood::SolidusTaxjar.api.show_latest_transaction_for(order).amount != + (order.payment_total - order.additional_tax_total) + end + end + end +end diff --git a/lib/super_good/solidus_taxjar/reporting.rb b/lib/super_good/solidus_taxjar/reporting.rb index eaf60115..e2f000d9 100644 --- a/lib/super_good/solidus_taxjar/reporting.rb +++ b/lib/super_good/solidus_taxjar/reporting.rb @@ -11,6 +11,7 @@ def create_refund(reimbursement) def refund_and_create_new_transaction(order) latest_order_transaction = OrderTransaction.latest_for(order) + unless latest_order_transaction.refund_transaction transaction_response = @api.create_refund_transaction_for(order) latest_order_transaction.create_refund_transaction!( diff --git a/lib/super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb b/lib/super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb new file mode 100644 index 00000000..43ffec05 --- /dev/null +++ b/lib/super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb @@ -0,0 +1,41 @@ +module SuperGood + module SolidusTaxjar + module Spree + module LegacyReportingSubscriber + include ::Spree::Event::Subscriber + include SolidusSupport::LegacyEventCompat::Subscriber + include SuperGood::SolidusTaxjar::Reportable + + # FIXME: + # This is a workaround until we add a new Solidus event we can subscribe + # to. "order_recalculated" occurs too early. + # + # This delay helps us be sure that `Spree::OrderUpdater#persist_totals` + # has been called, and the `order` transaction has been completed, + # before we report this transaction to TaxJar. + # + DELAY = 2 + + event_action :report_or_replace_transaction, event_name: :order_recalculated + + def report_or_replace_transaction(event) + order = event.payload[:order] + + with_reportable(order) do + SuperGood::SolidusTaxjar::ReportTransactionJob + .set(wait: DELAY.seconds) + .perform_later(order) + + return + end + + with_replaceable(order) do + SuperGood::SolidusTaxjar::ReplaceTransactionJob + .set(wait: DELAY.seconds) + .perform_later(order) + end + end + end + end + end +end diff --git a/lib/super_good/solidus_taxjar/testing_support/factories/transaction_sync_log_factory.rb b/lib/super_good/solidus_taxjar/testing_support/factories/transaction_sync_log_factory.rb index 29ecfb18..54a59194 100644 --- a/lib/super_good/solidus_taxjar/testing_support/factories/transaction_sync_log_factory.rb +++ b/lib/super_good/solidus_taxjar/testing_support/factories/transaction_sync_log_factory.rb @@ -9,5 +9,10 @@ log.order_transaction = build(:taxjar_order_transaction, order: log.order) end end + + trait :error do + status { "error" } + error_message { "Sync failed" } + end end end diff --git a/lib/super_good/solidus_taxjar/version.rb b/lib/super_good/solidus_taxjar/version.rb index 2cfa6997..bf4fe139 100644 --- a/lib/super_good/solidus_taxjar/version.rb +++ b/lib/super_good/solidus_taxjar/version.rb @@ -1,5 +1,5 @@ module SuperGood module SolidusTaxjar - VERSION = "0.18.2" + VERSION = "1.0.0" end end diff --git a/spec/features/spree/admin/backfill_transactions_spec.rb b/spec/features/spree/admin/backfill_transactions_spec.rb index 142280c7..8e587c33 100644 --- a/spec/features/spree/admin/backfill_transactions_spec.rb +++ b/spec/features/spree/admin/backfill_transactions_spec.rb @@ -33,7 +33,7 @@ expect(page).to_not have_content excluded_order.number expect(page).to_not have_content excluded_order.number expect(page).to have_content order.number - within "tbody td:nth-child(4)" do + within "tbody td:nth-child(5)" do expect(page).to have_content("Success") end end @@ -104,7 +104,7 @@ expect(page).to have_content("-") end - within "td:nth-child(4)" do + within "td:nth-child(5)" do expect(page).to have_content("Processing") end @@ -125,7 +125,7 @@ expect(page).to have_content(success_transaction_sync_log.order_transaction.transaction_id) end - within "td:nth-child(4)" do + within "td:nth-child(5)" do expect(page).to have_content("Success") end diff --git a/spec/features/spree/admin/refund_spec.rb b/spec/features/spree/admin/refund_spec.rb index 367c0d4f..d48dee7b 100644 --- a/spec/features/spree/admin/refund_spec.rb +++ b/spec/features/spree/admin/refund_spec.rb @@ -1,52 +1,167 @@ -require 'spec_helper' +require "spec_helper" -RSpec.feature 'Refunding an order', js: true do +RSpec.feature "Refunding an order", :js do stub_authorization! - let(:order) { create(:shipped_order, line_items_count: 3) } + include_context "checkoutable store" before do - country = create(:country, states_required: true) - create(:product, name: "RoR Mug") - create(:store, default: true) - create(:state, country: country, state_code: "CA") - create(:shipping_method) - create(:stock_location, name: "Montez's Warehouse") - create(:check_payment_method) - create(:zone) - create(:taxjar_configuration, :reporting_enabled) - create(:return_reason, name: "Defective") - create(:refund_reason, name: 'Return processing', code: "refund", mutable: false) - create(:reimbursement_type, name: "original payment", type: "Spree::ReimbursementType::OriginalPayment") - - SuperGood::SolidusTaxjar::ReportTransactionJob.perform_now(order) + create :stock_location, name: "Montez's Warehouse" + + create :return_reason, name: "Defective" + create :refund_reason, + code: "refund", + name: "Return processing", + mutable: false + create :reimbursement_type, + name: "original payment", + type: "Spree::ReimbursementType::OriginalPayment" + + # This will initially report the shipped order to TaxJar + perform_enqueued_jobs { order.recalculate } end - it "adds tax calculated by TaxJar to the order total", js: true, vcr: {cassette_name: "features/spree/admin/refund", allow_unused_http_interactions: false} do + # Each inventory unit in this order has a price of $10 before tax. Before the + # customer return, there are four units total, split across three line items. + # + let(:order) { + create :shipped_order, + line_items_attributes: [ + {variant: create(:product, name: "First Product").master}, + {variant: create(:product, name: "Second Product").master}, + {quantity: 2, variant: create(:product, name: "Third Product").master} + ], + number: "R925733488", + shipment_cost: 0, + shipping_method: create(:free_shipping_method) + } + + scenario "adds tax calculated by TaxJar to the order total", + js: true, + vcr: { + cassette_name: "features/spree/admin/refund", + allow_unused_http_interactions: false + } do visit spree.admin_order_return_authorizations_path(order) + click_on "New RMA" + + add_product_to_rma product_name: "First Product", + reimbursement_type: "Original payment", + reason: "Defective" + click_on "Create" + + # This customer return will remove an entire line item from the order. + # + click_on "Customer Return" + click_on "New Customer Return" + receive_return_item + click_on "Create" + + click_on "Create reimbursement" + select "Original payment", + from: "reimbursement[return_items_attributes][0][override_reimbursement_type_id]" + click_on "Update" + perform_enqueued_jobs do + click_on "Reimburse" + end + # The reimbursement should be initialized with the correct amount to balance + # the order and mark it as "paid" (not "credit owed" or "balance due"). + # + # It will be -1 * a single inventory unit: $10 + the TaxJar-calculated tax + # amount. + # + # + force_pending_on_ci do + expect(find(".reimbursement-refund-amount")).to have_content("$10.89") + end + + expect(page).to have_content("TaxJar Sync: Success", normalize_ws: true) + + click_on "RMA" click_on "New RMA" - check "return_authorization[return_items_attributes][0][_destroy]" - select "Montez's Warehouse", from: "Stock Location" - select "Original payment", from: "return_authorization[return_items_attributes][0][preferred_reimbursement_type_id]" - select "Defective", from: "return_authorization[return_items_attributes][0][return_reason_id]" + add_product_to_rma product_name: "Third Product", + reimbursement_type: "Original payment", + reason: "Defective" click_on "Create" + # This customer return will *not* remove an entire line item from the + # order. The line item quantity was `2` and after this return it should be + # `1`. + # click_on "Customer Return" click_on "New Customer Return" - check "customer_return[return_items_attributes][0][returned]" - select "Received", from: "customer_return[return_items_attributes][0][reception_status_event]" - select "Montez's Warehouse", from: "Stock Location" + receive_return_item click_on "Create" click_on "Create reimbursement" - select "Original payment", from: "reimbursement[return_items_attributes][0][override_reimbursement_type_id]" + select "Original payment", + from: "reimbursement[return_items_attributes][0][override_reimbursement_type_id]" click_on "Update" perform_enqueued_jobs do click_on "Reimburse" end - expect(find(".reimbursement-refund-amount")).to have_content("$10.89") + # The reimbursement should be initialized with the correct amount to balance + # the order and mark it as "paid" (not "credit owed" or "balance due"). + # + # It will be -1 * a single inventory unit: $10 + the TaxJar-calculated tax + # amount. + # + force_pending_on_ci do + expect(find(".reimbursement-refund-amount")).to have_content("$10.89") + end + + expect(page).to have_content("TaxJar Sync: Success", normalize_ws: true) + end + + def add_product_to_rma(product_name:, reimbursement_type:, reason:, quantity: 1) + return_items_table = find "table.return-items-table" + + within return_items_table do + rows_for_product = + find_all("tr").select { |row| row.text.include? product_name } + + if rows_for_product.size < quantity + raise Capybara::ElementNotFound, "didn't find enough RMA table rows" + end + + rows_for_product.first(quantity).each do |row| + within row do + checkbox = find "input[type='checkbox']" + checkbox.check + + reimbursement_type_select = find "select[id$='reimbursement_type_id']" + reimbursement_type_select.find(:option, reimbursement_type).select_option + + return_reason_select = find "select[id$='return_reason_id']" + return_reason_select.find(:option, reason).select_option + end + end + end + + select "Montez's Warehouse", from: "Stock Location" + end + + def receive_return_item + check "customer_return[return_items_attributes][0][returned]" + select "Received", from: "customer_return[return_items_attributes][0][reception_status_event]" + select "Montez's Warehouse", from: "Stock Location" + end + + # The assertions with this method wrapping them *sometimes* pass on CI. We + # only want to pend for failures. + # + def force_pending_on_ci(&block) + if ENV["CI"] + pending "A very annoying and hard to debug issue is causing the next" \ + "check to fail regularily in CI, but not locally. It seems like " \ + "a test-order dependency bug, but we can only reproduce it in CI " \ + "runs." + raise "False Error" + else + yield + end end end diff --git a/spec/features/spree/admin/reporting_to_taxjar_spec.rb b/spec/features/spree/admin/reporting_to_taxjar_spec.rb index 6b027c19..abecbb01 100644 --- a/spec/features/spree/admin/reporting_to_taxjar_spec.rb +++ b/spec/features/spree/admin/reporting_to_taxjar_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.feature 'Reporting orders to TaxJar', js: true, vcr: true do +RSpec.feature 'Reporting orders to TaxJar', js: true, vcr: { allow_unused_http_interactions: false } do stub_authorization! background do @@ -8,9 +8,12 @@ create :taxjar_configuration, :reporting_enabled end - let!(:order) { create :order_ready_to_ship } + let(:order) do + # FIXME: This factory is bad! + create(:order_ready_to_ship).tap { |o| o.touch(:completed_at) } + end - scenario "shipping a complete and paid order", vcr: { allow_unused_http_interactions: false } do + scenario "shipping a complete and paid order" do visit spree.edit_admin_order_path(order) perform_enqueued_jobs do wait_for_order_information_to_load @@ -22,6 +25,131 @@ expect(page).to have_text("TaxJar Sync: Success", normalize_ws: true) end + context "with an order with invalid zipcode" do + let(:invalid_address) do + create(:address, zipcode: 99999) + end + + let(:order) do + # FIXME: This factory is bad! + create( + :order_ready_to_ship, + ship_address: invalid_address + ).tap do |order| + order.touch(:completed_at) + order.recalculate + order.payments.first.update!(amount: 110) + end + end + + scenario "retry of a previously failed transaction sync" do + visit spree.edit_admin_order_path(order) + + perform_enqueued_jobs do + wait_for_order_information_to_load + + click_on "Ship" + expect(page).to have_content("Shipped package from") + end + + within("#order_tab_summary") do + expect(page).to have_text("Reported to TaxJar at: -", normalize_ws: true) + expect(page).to have_text("TaxJar Sync: Error", normalize_ws: true) + + click_on "TaxJar Sync History" + end + + within("#content-header") do + expect(page).to have_content("TaxJar Sync History") + end + + within('#transaction_sync_logs') do + expect(page).to have_content("Retry") + click_on "Retry" + end + + expect(page).to have_content("Queued transaction sync job") + end + end + + context "updating an order which was not reported due to failure" do + let(:invalid_address) do + create(:address, zipcode: 99999) + end + + let(:order) do + # FIXME: This factory is bad! + create( + :order_ready_to_ship, + ship_address: invalid_address + ).tap { |o| o.touch(:completed_at) } + end + + before do + # We need at least one reason before we can create a refund. + create(:refund_reason, name: "Refund") + end + + scenario "it reports the order instead of trying to replace it" do + visit spree.edit_admin_order_path(order) + + perform_enqueued_jobs do + wait_for_order_information_to_load + click_on "Ship" + expect(page).to have_content("Shipped package from") + end + + within("#order_tab_summary") do + expect(page).to have_text("Reported to TaxJar at: -", normalize_ws: true) + expect(page).to have_text("TaxJar Sync: Error", normalize_ws: true) + end + + # Update the order to fix the error with the address. + within("ul.tabs") do + click_on "Customer" + end + + expect(page).to have_content("Shipping Address") + + within("div[data-hook=\"ship_address_wrapper\"]") do + fill_in("Zip Code", with: "") + fill_in("Zip Code", with: "11430") + end + + perform_enqueued_jobs do + click_on "Update" + end + + expect(page).to have_content("Customer Details Updated") + + # To trigger reporting to TaxJar - by creating a refund to balance. + within("ul.tabs") do + click_on "Payments" + end + + expect(page).to have_content("Balance Due: $9.77") + + click_on "New Payment" + + expect(page).to have_content("New Payment") + + click_on "Update" + + expect(page).to have_content("Payment has been successfully created!") + + click_icon "capture" + + expect(page).to have_content("Payment Updated") + + flush_enqueued_jobs + + page.refresh + + + expect(page).to have_text("TaxJar Sync: Success", normalize_ws: true) + end + end + def wait_for_order_information_to_load expect(page).not_to have_content("Loading") end diff --git a/spec/features/spree/admin/checkout_spec.rb b/spec/features/spree/checkout_spec.rb similarity index 83% rename from spec/features/spree/admin/checkout_spec.rb rename to spec/features/spree/checkout_spec.rb index 208cefb9..1b27a7b9 100644 --- a/spec/features/spree/admin/checkout_spec.rb +++ b/spec/features/spree/checkout_spec.rb @@ -1,16 +1,10 @@ -require 'spec_helper' +require "spec_helper" -RSpec.feature 'Checkout', js: true do - let!(:country) { create(:country, states_required: true) } - let!(:mug) { create(:product, name: "RoR Mug") } +RSpec.feature "Checkout", :js do + include_context "checkoutable store" before do - create(:store, default: true) - create(:state, country: country, state_code: "CA") - create(:shipping_method) - create(:stock_location) - create(:check_payment_method) - create(:zone) + create :product, name: "RoR Mug" end def fill_in_address @@ -37,7 +31,7 @@ def fill_in_address it "adds tax calculated by TaxJar to the order total", js: true, vcr: {cassette_name: "features/spree/admin/checkout", allow_playback_repeats: true, allow_unused_http_interactions: false} do visit spree.root_path - click_link mug.name + click_link "RoR Mug" click_button "add-to-cart-button" click_button "Checkout" diff --git a/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/shipping_a_complete_and_paid_order.yml b/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/shipping_a_complete_and_paid_order.yml index 889eb1bd..2678a722 100644 --- a/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/shipping_a_complete_and_paid_order.yml +++ b/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/shipping_a_complete_and_paid_order.yml @@ -8,9 +8,9 @@ http_interactions: string: '' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 20.6.0 Darwin Kernel Version - 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 - x86_64; ruby 2.7.6-p219; OpenSSL 1.1.1n 15 Mar 2022) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin poison-ivy 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 + 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64; ruby 2.7.5-p203; + OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -33,28 +33,28 @@ http_interactions: Connection: - close Date: - - Mon, 12 Dec 2022 19:27:15 GMT + - Wed, 03 May 2023 23:27:16 GMT X-Amzn-Requestid: - - 87dfbf7a-5317-4641-a8b8-930a749ab98c + - 6a94a3c4-19ca-45ff-bf12-fe22d27b33b6 X-Amz-Apigw-Id: - - dDEHEGiyIAMF1KQ= + - EXoZSE0WoAMFZwg= X-Amzn-Trace-Id: - - Root=1-63978093-141349e55e49713b7a4c542e + - Root=1-6452edd4-266d7ff250de8a10627f2099 X-Cache: - Miss from cloudfront Via: - - 1.1 27fe6f224e0cfa3f3a446471ee256e56.cloudfront.net (CloudFront) + - 1.1 7f5c6f79ed16052a7a2f78b6025bcf5e.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P2 + - YVR50-C1 X-Amz-Cf-Id: - - qPC3yJoUTAyz5AX4p9ZbqmyLNmxpDpZh2ZQXj-_MjGEO9sZKaBMC9g== + - yeOhtgpzIJfbT6z4bkCC0BdFknl72z6eWgLNuKn1VWDR76nEkt949Q== body: encoding: UTF-8 string: '{"regions":[{"region_code":"BC","region":"British Columbia","country_code":"CA","country":"Canada"},{"region_code":"CA","region":"California","country_code":"US","country":"United States"},{"region_code":"NY","region":"New York","country_code":"US","country":"United States"}]}' http_version: - recorded_at: Mon, 12 Dec 2022 19:27:15 GMT + recorded_at: Wed, 03 May 2023 23:27:16 GMT - request: method: post uri: https://api.taxjar.com/v2/taxes @@ -62,12 +62,12 @@ http_interactions: encoding: UTF-8 string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 330223"}],"shipping":"100.0"}' + - 493485"}],"shipping":"100.0"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 20.6.0 Darwin Kernel Version - 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 - x86_64; ruby 2.7.6-p219; OpenSSL 1.1.1n 15 Mar 2022) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin poison-ivy 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 + 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64; ruby 2.7.5-p203; + OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -92,29 +92,29 @@ http_interactions: Connection: - close Date: - - Mon, 12 Dec 2022 19:27:15 GMT + - Wed, 03 May 2023 23:27:16 GMT X-Amzn-Requestid: - - '009c7626-ec75-470f-96b2-62adc6cf63a2' + - d33ddc5a-822b-46ac-966b-81be4e2831a4 Access-Control-Allow-Origin: - https://developers.taxjar.com X-Amz-Apigw-Id: - - dDEHGH31IAMFeiQ= + - EXoZUGbRoAMFoiQ= X-Amzn-Trace-Id: - - Root=1-63978093-1079da476d8f5789068226a6 + - Root=1-6452edd4-7ddc4db1507af3da7e0f076c X-Cache: - Miss from cloudfront Via: - - 1.1 d8d9c12d1a621129f4bc739038e7c72e.cloudfront.net (CloudFront) + - 1.1 733ae4e17f2a4786e797d3450daabd46.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P2 + - YVR50-C1 X-Amz-Cf-Id: - - MOntKk3GHK_lZyT2smonrJ7cC-vWB2RYc0EADsFeZnJ5AGrxEvd4nQ== + - NmP2-RKx6UmF5_Cw17MwSDMALEUSoIkWegj71p0LhwzOHWHKOf61FA== body: encoding: UTF-8 string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' http_version: - recorded_at: Mon, 12 Dec 2022 19:27:15 GMT + recorded_at: Wed, 03 May 2023 23:27:16 GMT - request: method: post uri: https://api.taxjar.com/v2/taxes @@ -122,12 +122,12 @@ http_interactions: encoding: UTF-8 string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 330223"}],"shipping":"100.0"}' + - 493485"}],"shipping":"100.0"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 20.6.0 Darwin Kernel Version - 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 - x86_64; ruby 2.7.6-p219; OpenSSL 1.1.1n 15 Mar 2022) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin poison-ivy 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 + 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64; ruby 2.7.5-p203; + OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -152,101 +152,29 @@ http_interactions: Connection: - close Date: - - Mon, 12 Dec 2022 19:27:16 GMT + - Wed, 03 May 2023 23:27:17 GMT X-Amzn-Requestid: - - b3d6b2b4-3b86-4352-9dc2-eb3f9861df30 + - 6bfb3740-d49c-486b-8954-e4d36b749b28 Access-Control-Allow-Origin: - https://developers.taxjar.com X-Amz-Apigw-Id: - - dDEHLH2mIAMFUnQ= + - EXoZYEH1IAMFu9g= X-Amzn-Trace-Id: - - Root=1-63978094-4931176016ee9afd150cc6dd + - Root=1-6452edd5-7c42fc4a15b89ae459e60aa7 X-Cache: - Miss from cloudfront Via: - - 1.1 d8d9c12d1a621129f4bc739038e7c72e.cloudfront.net (CloudFront) + - 1.1 4f130b04fa4df2503556325c16eee9f2.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P2 + - YVR50-C1 X-Amz-Cf-Id: - - PsCURP1XNxN_SVLr3LQ4p8wWMcYMAUvhUloNHjANlkDPABbh9p3YGg== + - 6Oux1Gd25yMW_2NVncdPeKOIWcylRNF6lgdsVH4rVNpt0Q8x7SAiPQ== body: encoding: UTF-8 string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' http_version: - recorded_at: Mon, 12 Dec 2022 19:27:16 GMT -- request: - method: post - uri: https://api.taxjar.com/v2/transactions/orders - body: - encoding: UTF-8 - string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A - Different Road","line_items":[{"id":1,"quantity":1,"product_identifier":"SKU-1","description":"Product - #1 - 7579 - Master","product_tax_code":"TaxCode - 330223","unit_price":"10.0","discount":0,"sales_tax":"0.89"}],"transaction_id":"R187680773","transaction_date":"2022-12-12T19:27:15Z","amount":"110.0","shipping":"100.0","sales_tax":"9.77"}' - headers: - User-Agent: - - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 20.6.0 Darwin Kernel Version - 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 - x86_64; ruby 2.7.6-p219; OpenSSL 1.1.1n 15 Mar 2022) taxjar-ruby/3.0.4' - Authorization: - - Bearer - X-Api-Version: - - '2020-08-07' - Plugin: - - supergoodsolidustaxjar - Connection: - - close - Content-Type: - - application/json; charset=UTF-8 - Host: - - api.taxjar.com - response: - status: - code: 201 - message: Created - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '643' - Connection: - - close - Date: - - Mon, 12 Dec 2022 19:27:17 GMT - X-Amzn-Requestid: - - f879fde8-9c5b-4762-ae41-47216c3c933d - X-Amzn-Remapped-Content-Length: - - '643' - X-Amzn-Remapped-Connection: - - keep-alive - X-Request-Id: - - FzAiW2o4vq2oh0MEMByC - X-Api-Version: - - '2020-08-07' - X-Amz-Apigw-Id: - - dDEHbHEuIAMFcOQ= - Cache-Control: - - max-age=0, private, must-revalidate - X-Amzn-Remapped-Server: - - Cowboy - X-Amzn-Remapped-Date: - - Mon, 12 Dec 2022 19:27:17 GMT - X-Cache: - - Miss from cloudfront - Via: - - 1.1 bd6f70221217681265382902c6157c76.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA73-P2 - X-Amz-Cf-Id: - - Su3N5g5KBmEaiU5ojj9SO8HMW28Nr6hgCkLstEQpIso0zIu_CcGrDw== - body: - encoding: UTF-8 - string: '{"order":{"user_id":225397,"transaction_reference_id":null,"transaction_id":"R187680773","transaction_date":"2022-12-12T19:27:15.000Z","to_zip":"11430","to_street":"A - Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"100.0","sales_tax":"9.77","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 330223","product_identifier":"SKU-1","id":0,"discount":"0.0","description":"Product - #1 - 7579 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"110.0"}}' - http_version: - recorded_at: Mon, 12 Dec 2022 19:27:17 GMT + recorded_at: Wed, 03 May 2023 23:27:17 GMT - request: method: post uri: https://api.taxjar.com/v2/taxes @@ -254,12 +182,12 @@ http_interactions: encoding: UTF-8 string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 330223"}],"shipping":"100.0"}' + - 493485"}],"shipping":"100.0"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 20.6.0 Darwin Kernel Version - 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 - x86_64; ruby 2.7.6-p219; OpenSSL 1.1.1n 15 Mar 2022) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin poison-ivy 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 + 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64; ruby 2.7.5-p203; + OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -284,40 +212,42 @@ http_interactions: Connection: - close Date: - - Mon, 12 Dec 2022 19:27:18 GMT + - Wed, 03 May 2023 23:27:18 GMT X-Amzn-Requestid: - - eedec9c3-4bb5-4646-b45d-1917acce4b7b + - 62be29ec-eb04-4dd1-bda0-747986345dd0 Access-Control-Allow-Origin: - https://developers.taxjar.com X-Amz-Apigw-Id: - - dDEHgFR2IAMFwVw= + - EXoZmGeGIAMFopg= X-Amzn-Trace-Id: - - Root=1-63978096-671feed55b3f974c4b163024 + - Root=1-6452edd6-4fc691366a6b1a97585ca90b X-Cache: - Miss from cloudfront Via: - - 1.1 b47618c03bd47cf085f27b1e215f76cc.cloudfront.net (CloudFront) + - 1.1 653091ac0195c12aece44bebed9fcff8.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P2 + - YVR50-C1 X-Amz-Cf-Id: - - NopU2pasp9wkKQuhhDJ2MEakI331SwFYhiDluEQsxz__n8BQiPvKRw== + - CAhcnneXewT2tGinpJwpprQC15O85sOn_FQZSJhOlT3VPAKh6drpKg== body: encoding: UTF-8 string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' http_version: - recorded_at: Mon, 12 Dec 2022 19:27:18 GMT + recorded_at: Wed, 03 May 2023 23:27:18 GMT - request: - method: get - uri: https://api.taxjar.com/v2/transactions/orders/R187680773 + method: post + uri: https://api.taxjar.com/v2/transactions/orders body: encoding: UTF-8 - string: '' + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A + Different Road","line_items":[{"id":1,"quantity":1,"product_identifier":"SKU-1","description":"Product + #1 - 6139 - Master","product_tax_code":"TaxCode - 493485","unit_price":"10.0","discount":0,"sales_tax":"0.89"}],"transaction_id":"R635383732","transaction_date":"2023-05-03T23:27:17Z","amount":"110.0","shipping":"100.0","sales_tax":"9.77"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 20.6.0 Darwin Kernel Version - 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 - x86_64; ruby 2.7.6-p219; OpenSSL 1.1.1n 15 Mar 2022) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin poison-ivy 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 + 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64; ruby 2.7.5-p203; + OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -326,12 +256,14 @@ http_interactions: - supergoodsolidustaxjar Connection: - close + Content-Type: + - application/json; charset=UTF-8 Host: - api.taxjar.com response: status: - code: 200 - message: OK + code: 201 + message: Created headers: Content-Type: - application/json; charset=utf-8 @@ -340,39 +272,39 @@ http_interactions: Connection: - close Date: - - Mon, 12 Dec 2022 19:27:18 GMT + - Wed, 03 May 2023 23:27:19 GMT X-Amzn-Requestid: - - 4c440c70-7bdb-457d-9ac4-864b39e80ebe + - 0a02df64-c43f-45d9-85c9-bcfc90b02869 X-Amzn-Remapped-Content-Length: - '643' X-Amzn-Remapped-Connection: - keep-alive X-Request-Id: - - FzAiW507O--c-UNujscB + - F1vF3Q--8cq0U4AFR-IC X-Api-Version: - '2020-08-07' X-Amz-Apigw-Id: - - dDEHkHsNIAMFWww= + - EXoZoEzsoAMF1FA= Cache-Control: - max-age=0, private, must-revalidate X-Amzn-Remapped-Server: - Cowboy X-Amzn-Remapped-Date: - - Mon, 12 Dec 2022 19:27:18 GMT + - Wed, 03 May 2023 23:27:19 GMT X-Cache: - Miss from cloudfront Via: - - 1.1 583992e175976bd59a21b4416890271e.cloudfront.net (CloudFront) + - 1.1 4201bd1d1fc37ea7749b3bd1b64fce02.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P2 + - YVR50-C1 X-Amz-Cf-Id: - - X0OOuXsNJLoHIkNRvDnaM2j_c4kZR-OBgjIdHaNZLh1xHB3qSpwxRg== + - tmFS5a2y8W0VGWY8LSBoFo0teZr7W_Ns63kHfcYVI5D0__gR_Oshsg== body: encoding: UTF-8 - string: '{"order":{"user_id":225397,"transaction_reference_id":null,"transaction_id":"R187680773","transaction_date":"2022-12-12T19:27:15.000Z","to_zip":"11430","to_street":"A + string: '{"order":{"user_id":225397,"transaction_reference_id":null,"transaction_id":"R635383732","transaction_date":"2023-05-03T23:27:17.000Z","to_zip":"11430","to_street":"A Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"100.0","sales_tax":"9.77","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 330223","product_identifier":"SKU-1","id":0,"discount":"0.0","description":"Product - #1 - 7579 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"110.0"}}' + - 493485","product_identifier":"SKU-1","id":0,"discount":"0.0","description":"Product + #1 - 6139 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"110.0"}}' http_version: - recorded_at: Mon, 12 Dec 2022 19:27:18 GMT + recorded_at: Wed, 03 May 2023 23:27:18 GMT recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/updating_an_order_which_was_not_reported_due_to_failure/it_reports_the_order_instead_of_trying_to_replace_it.yml b/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/updating_an_order_which_was_not_reported_due_to_failure/it_reports_the_order_instead_of_trying_to_replace_it.yml new file mode 100644 index 00000000..85f1668c --- /dev/null +++ b/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/updating_an_order_which_was_not_reported_due_to_failure/it_reports_the_order_instead_of_trying_to_replace_it.yml @@ -0,0 +1,794 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.taxjar.com/v2/nexus/regions + body: + encoding: ASCII-8BIT + string: '' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '277' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:41 GMT + X-Amzn-Requestid: + - 2bc4afa1-8013-4064-b9fb-b626a682f0a7 + X-Amz-Apigw-Id: + - P_1tBG_goAMEa7Q= + X-Amzn-Trace-Id: + - Root=1-657c9cb9-58f0c7b53f5019f005267137 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 a8e5d5aeee6eacca5c379e5059b1f68c.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - eSpB1fiJ6eL6AIt-3LWZ3VaDaRm2UZDHs4kduFUIqog1q4KqdOhmdw== + body: + encoding: UTF-8 + string: '{"regions":[{"region_code":"BC","region":"British Columbia","country_code":"CA","country":"Canada"},{"region_code":"CA","region":"California","country_code":"US","country":"United + States"},{"region_code":"NY","region":"New York","country_code":"US","country":"United + States"}]}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:41 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:41 GMT + X-Amzn-Requestid: + - b18991cd-a60d-4170-8c85-0d33bfc9f8f3 + X-Amz-Apigw-Id: + - P_1tEFPooAMErhg= + X-Amzn-Trace-Id: + - Root=1-657c9cb9-3fe9057c6ef709b37f395bad + X-Cache: + - Error from cloudfront + Via: + - 1.1 d2575afea3774df33dcf5e5ff475025e.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - EHxEWIwBfT1DGoLRELLFNSLo3W1CoCDO_-7v_wvNZnoPu1bHP6Gwfg== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:41 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:41 GMT + X-Amzn-Requestid: + - a3e66767-bb0a-4539-81c0-23b06aa02e48 + X-Amz-Apigw-Id: + - P_1tGGzjIAMEAcQ= + X-Amzn-Trace-Id: + - Root=1-657c9cb9-60a4a50c2a5268de7202656f + X-Cache: + - Error from cloudfront + Via: + - 1.1 25b9a991f871f75614e7f92f97b136a4.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - xmF_OU795uRHIpt9BpMelCR4oYjREAx3S2z_2ftI4ejVSjfzaa8i1A== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:41 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:42 GMT + X-Amzn-Requestid: + - 1df28c71-ffab-4545-9a44-43cd2bcc5452 + X-Amz-Apigw-Id: + - P_1tOHf-oAMEpwg= + X-Amzn-Trace-Id: + - Root=1-657c9cba-1766ff8b07afe51751bab726 + X-Cache: + - Error from cloudfront + Via: + - 1.1 73b60e9a9fd08eae9e034cedba707280.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - jD2RnXb7u6N4AqU3qibZw0Bkm0ZD1q1FgCMMmeoZiQiXNPJd5QLqQw== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:42 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/transactions/orders + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"product_identifier":"SKU-1","description":"Product + #1 - 1856 - Master","product_tax_code":"TaxCode - 410790","unit_price":"10.0","discount":0,"sales_tax":"0.0"}],"transaction_id":"R782923171","transaction_date":"2023-12-15T18:36:41Z","amount":"110.0","shipping":"100.0","sales_tax":"0.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:42 GMT + X-Amzn-Requestid: + - 7cdb0ba1-53f2-4050-a097-3982c657d4e7 + X-Amzn-Remapped-Content-Length: + - '91' + X-Amzn-Remapped-Connection: + - keep-alive + X-Request-Id: + - F6EVKbKgVGMNqo0B3iFj + X-Api-Version: + - '2020-08-07' + X-Amz-Apigw-Id: + - P_1tQENQoAMEREw= + Cache-Control: + - max-age=0, private, must-revalidate + X-Amzn-Remapped-Server: + - Cowboy + X-Amzn-Remapped-Date: + - Fri, 15 Dec 2023 18:36:42 GMT + X-Cache: + - Error from cloudfront + Via: + - 1.1 79880188a81becf1687ba18c0e064230.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - k8eO9ZyStm5gncq3gjERM1qzlckRrDm99zTRjDUwvm-GaxoN0bnP6A== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:42 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1487' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:43 GMT + X-Amzn-Requestid: + - 8914a8fb-08b1-4c39-9260-30714c2e9fcc + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - P_1tYE10IAMEECw= + X-Amzn-Trace-Id: + - Root=1-657c9cbb-772a21fe0452f08d204d5478 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 d2575afea3774df33dcf5e5ff475025e.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - Y3YGzvpPMKFKnB3qmBWpJhPcGFAPZYKNij5FCW8-dOjrT-XNxqcLYA== + body: + encoding: UTF-8 + string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:43 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1487' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:44 GMT + X-Amzn-Requestid: + - 73b025dd-907f-42a7-8679-72a516500ff4 + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - P_1tfHrmoAMETyg= + X-Amzn-Trace-Id: + - Root=1-657c9cbc-081dd70f53e8174844a52672 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 2a44ef7b9d28e74c78ffadeedcbb887c.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - SwHa5BbEbuWIeI61hRgfaOKCNUMM8KZWJXQOAz8UGYSSqjduas5hxQ== + body: + encoding: UTF-8 + string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:44 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1487' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:44 GMT + X-Amzn-Requestid: + - 23c59d0c-51f3-4794-8057-83d172f9d807 + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - P_1tiGBCIAMEHJg= + X-Amzn-Trace-Id: + - Root=1-657c9cbc-03aff3025808755342dd51b9 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 d2575afea3774df33dcf5e5ff475025e.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - x5YjSpOBykbkqOuTNHMoliOrrkqKE5fXOFDyCepDK211EhzYk1kYhg== + body: + encoding: UTF-8 + string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:44 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1487' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:45 GMT + X-Amzn-Requestid: + - 36af8d7d-cc56-4212-83b5-4b00632ab7d7 + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - P_1tmHz_oAMEPrQ= + X-Amzn-Trace-Id: + - Root=1-657c9cbd-50463d2901ef0bce7970d7dc + X-Cache: + - Miss from cloudfront + Via: + - 1.1 73b60e9a9fd08eae9e034cedba707280.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - ufVPDs8pA-hs6urIr8IBxpJ8CEKdQNoZLBaXUYNRnznKw5tsyI7-BA== + body: + encoding: UTF-8 + string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:45 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1487' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:45 GMT + X-Amzn-Requestid: + - 9a3cc2b3-59ea-4be8-8550-a9f41c13451d + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - P_1trECgoAMEO9w= + X-Amzn-Trace-Id: + - Root=1-657c9cbd-749282cc3fbf209479aa608b + X-Cache: + - Miss from cloudfront + Via: + - 1.1 25b9a991f871f75614e7f92f97b136a4.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - jlSKf1mxqVkO_Ei42Bw0iiZgE--p1B0nwbFLniRT1pHaFmOBRLFtDg== + body: + encoding: UTF-8 + string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:45 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1487' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:46 GMT + X-Amzn-Requestid: + - 74cd08e9-cdc9-480d-874d-126e0b75f711 + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - P_1tuHN0IAMEa7Q= + X-Amzn-Trace-Id: + - Root=1-657c9cbd-489bb91b21de6ade70ccf543 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 d8d9c12d1a621129f4bc739038e7c72e.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - 9FHb4OIGDHluRCV81zTisb9UGykCorMaUMCjWXEG7NLzOd6gmPtMjw== + body: + encoding: UTF-8 + string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:45 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410790"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1487' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:46 GMT + X-Amzn-Requestid: + - d09b080b-2733-4716-9f50-be010a5a6bf4 + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - P_1tyGdZIAMEUnQ= + X-Amzn-Trace-Id: + - Root=1-657c9cbe-5ab8d1597f51b9352852bcfe + X-Cache: + - Miss from cloudfront + Via: + - 1.1 34c44cb7892e57a3b6c51812bcf68ee4.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - 05nu-_1vBDWTy54KmDRJpbGSkmLKvdsq9WZeEEaw9VJFEiwSiBopMA== + body: + encoding: UTF-8 + string: '{"tax":{"amount_to_collect":9.76,"breakdown":{"city_tax_collectable":5.36,"city_tax_rate":0.04875,"city_taxable_amount":110.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":4.4,"state_tax_rate":0.04,"state_taxable_amount":110.0,"tax_collectable":9.76,"taxable_amount":110.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":110.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":110.0}}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:46 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/transactions/orders + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"product_identifier":"SKU-1","description":"Product + #1 - 1856 - Master","product_tax_code":"TaxCode - 410790","unit_price":"10.0","discount":0,"sales_tax":"0.89"}],"transaction_id":"R782923171","transaction_date":"2023-12-15T18:36:41Z","amount":"110.0","shipping":"100.0","sales_tax":"9.77"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 201 + message: Created + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '643' + Connection: + - close + Date: + - Fri, 15 Dec 2023 18:36:46 GMT + X-Amzn-Requestid: + - b427545b-a54d-4ad3-97af-92a188fb5450 + X-Amzn-Remapped-Content-Length: + - '643' + X-Amzn-Remapped-Connection: + - keep-alive + X-Request-Id: + - F6EVKpe20isoeLwcBTXB + X-Api-Version: + - '2020-08-07' + X-Amz-Apigw-Id: + - P_1t2GdzIAMEr7Q= + Cache-Control: + - max-age=0, private, must-revalidate + X-Amzn-Remapped-Server: + - Cowboy + X-Amzn-Remapped-Date: + - Fri, 15 Dec 2023 18:36:46 GMT + X-Cache: + - Miss from cloudfront + Via: + - 1.1 d2575afea3774df33dcf5e5ff475025e.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - 0CPcVafXYMEziH9pkSMSm8kelXNmzCRxNc_Us2rZwSDJ2AFztTdZbA== + body: + encoding: UTF-8 + string: '{"order":{"user_id":225397,"transaction_reference_id":null,"transaction_id":"R782923171","transaction_date":"2023-12-15T18:36:41.000Z","to_zip":"11430","to_street":"10 + Lovely Street","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"100.0","sales_tax":"9.77","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 410790","product_identifier":"SKU-1","id":0,"discount":"0.0","description":"Product + #1 - 1856 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"110.0"}}' + http_version: + recorded_at: Fri, 15 Dec 2023 18:36:46 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/with_an_order_with_invalid_zipcode/retry_of_a_previously_failed_transaction_sync.yml b/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/with_an_order_with_invalid_zipcode/retry_of_a_previously_failed_transaction_sync.yml new file mode 100644 index 00000000..bd5f4fb5 --- /dev/null +++ b/spec/fixtures/cassettes/Reporting_orders_to_TaxJar/with_an_order_with_invalid_zipcode/retry_of_a_previously_failed_transaction_sync.yml @@ -0,0 +1,418 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.taxjar.com/v2/nexus/regions + body: + encoding: ASCII-8BIT + string: '' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '277' + Connection: + - close + Date: + - Fri, 15 Dec 2023 20:38:42 GMT + X-Amzn-Requestid: + - c67921d2-5236-4585-9492-1f695c369c62 + X-Amz-Apigw-Id: + - QAHlAHBZoAMEQYQ= + X-Amzn-Trace-Id: + - Root=1-657cb952-1260ead76104c43e6abf75de + X-Cache: + - Miss from cloudfront + Via: + - 1.1 45d6a557ecb29942f314e3dd736d817a.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - 72Is89-961itqD-RRC0Y9mSahs4zOvzqM-k07UgLzWYqz0FCKSKl2w== + body: + encoding: UTF-8 + string: '{"regions":[{"region_code":"BC","region":"British Columbia","country_code":"CA","country":"Canada"},{"region_code":"CA","region":"California","country_code":"US","country":"United + States"},{"region_code":"NY","region":"New York","country_code":"US","country":"United + States"}]}' + http_version: + recorded_at: Fri, 15 Dec 2023 20:38:42 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410113"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 20:38:43 GMT + X-Amzn-Requestid: + - 274e2b32-fb34-44b4-bb1b-8fdb5d3513fc + X-Amz-Apigw-Id: + - QAHlDH0YIAMEicQ= + X-Amzn-Trace-Id: + - Root=1-657cb953-4082dd5510aa91b4048e2754 + X-Cache: + - Error from cloudfront + Via: + - 1.1 73b60e9a9fd08eae9e034cedba707280.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - 92pSNJxwx3xSqEJsuY-qn4AJ4QkWUBz3DTrhXCbSlzWEY0Gbo45Wjw== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 20:38:43 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410113"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 20:38:43 GMT + X-Amzn-Requestid: + - 445e9d76-304d-417f-9cff-6f58a4c3f381 + X-Amz-Apigw-Id: + - QAHlGHR1IAMEvXg= + X-Amzn-Trace-Id: + - Root=1-657cb953-5692ffc134979f4411f4d2ed + X-Cache: + - Error from cloudfront + Via: + - 1.1 27f6faf9790b5a2877fb528fa31f7922.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - t8tWyL2TQI2RFnYuJNwklIkFaWjPMyWYF3uZz8gHfIG3q3PC0GmoQQ== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 20:38:43 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410113"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 20:38:43 GMT + X-Amzn-Requestid: + - d1ba91e8-ec4c-48ee-87db-0b20fd90d191 + X-Amz-Apigw-Id: + - QAHlJEhcIAMEUnQ= + X-Amzn-Trace-Id: + - Root=1-657cb953-07bd97724c076b23745ea0e1 + X-Cache: + - Error from cloudfront + Via: + - 1.1 d1d67b07408bba8c682597d8303642e2.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - fxZ68Q6XpWi5mSllVFo5NqA4frDyfdYsVJG0VzHgcPxHvZc9s3r9Sg== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 20:38:43 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410113"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 20:38:44 GMT + X-Amzn-Requestid: + - c968b234-c010-4ffe-9525-1a9b4a64f6c7 + X-Amz-Apigw-Id: + - QAHlLGcmIAMEVDQ= + X-Amzn-Trace-Id: + - Root=1-657cb954-24b3351170d028f941f14305 + X-Cache: + - Error from cloudfront + Via: + - 1.1 1352c0a623ff0601dd16439f3f225f70.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - m1YkIm6eD11WqU3Q-yPys1xXG9bz0g-MZD3e7eZRXtsRwErVmSBelg== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 20:38:44 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 410113"}],"shipping":"100.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 20:38:44 GMT + X-Amzn-Requestid: + - 3a7769ef-378b-4dae-bcf3-c3a135f69c54 + X-Amz-Apigw-Id: + - QAHlTGyzoAMEa1g= + X-Amzn-Trace-Id: + - Root=1-657cb954-3a6fb2fe69c036a8052b4cfb + X-Cache: + - Error from cloudfront + Via: + - 1.1 de8fc80b494d3d381f7e006918dcc588.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - JrIhhRdFPrzJ4wA75yHoxI2jkNsmnDwNTdDrWuINUsuw3r_fiNt6ng== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 20:38:44 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/transactions/orders + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"99999","to_city":"Herndon","to_state":"NY","to_street":"10 + Lovely Street","line_items":[{"id":1,"quantity":1,"product_identifier":"SKU-1","description":"Product + #1 - 4937 - Master","product_tax_code":"TaxCode - 410113","unit_price":"10.0","discount":0,"sales_tax":"0.0"}],"transaction_id":"R075824223","transaction_date":"2023-12-15T20:38:43Z","amount":"110.0","shipping":"100.0","sales_tax":"0.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Mon + Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '91' + Connection: + - close + Date: + - Fri, 15 Dec 2023 20:38:45 GMT + X-Amzn-Requestid: + - 32deea5e-6dba-4a2c-9d64-aac0732cbf4b + X-Amzn-Remapped-Content-Length: + - '91' + X-Amzn-Remapped-Connection: + - keep-alive + X-Request-Id: + - F6Eb0oba6S1Jh2UQO0_B + X-Api-Version: + - '2020-08-07' + X-Amz-Apigw-Id: + - QAHlWGRjIAMEcog= + Cache-Control: + - max-age=0, private, must-revalidate + X-Amzn-Remapped-Server: + - Cowboy + X-Amzn-Remapped-Date: + - Fri, 15 Dec 2023 20:38:45 GMT + X-Cache: + - Error from cloudfront + Via: + - 1.1 95785220a566cd050f3ad80928463374.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA73-P2 + X-Amz-Cf-Id: + - hks_AewDz_vReaAoPP6arYF99D_IdtKshtq4g-0VSz6ml9UE-quJUw== + body: + encoding: UTF-8 + string: '{"status":400,"error":"Bad Request","detail":"to_zip 99999 is not used + within to_state NY"}' + http_version: + recorded_at: Fri, 15 Dec 2023 20:38:45 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/fixtures/cassettes/features/spree/admin/refund.yml b/spec/fixtures/cassettes/features/spree/admin/refund.yml index 8ebf5b96..f57cd969 100644 --- a/spec/fixtures/cassettes/features/spree/admin/refund.yml +++ b/spec/fixtures/cassettes/features/spree/admin/refund.yml @@ -4,13 +4,13 @@ http_interactions: method: get uri: https://api.taxjar.com/v2/nexus/regions body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -29,47 +29,47 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '277' + - '189' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:17 GMT + - Fri, 26 Jan 2024 21:12:59 GMT X-Amzn-Requestid: - - ac7ed4cd-f280-4bf4-9c99-7d39341d092e + - 8f336468-63a0-490d-bc15-5c5c958f1ac1 X-Amz-Apigw-Id: - - G41cDHcAIAMFWUQ= + - SKn-WH0sIAMEqYA= X-Amzn-Trace-Id: - - Root=1-64936919-53f5eb963487eb087334bf85 + - Root=1-65b4205b-528606af3a01aa1b52d08571 X-Cache: - Miss from cloudfront Via: - - 1.1 69c3a6c1e32b8c96e5765cc20e12c398.cloudfront.net (CloudFront) + - 1.1 70fd8dd903406754b301439f9111e256.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - LJgWipKhcu26cXR6A3ce8kT1RfBvW9Xn0A1wOWVe7xsjMFmUaF8fyg== + - gv8ot9nviMlv36Z5uHBDcahmNoV3HsDmcNTyVYUVdqRZ2fa16FbIpg== body: encoding: UTF-8 - string: '{"regions":[{"region_code":"BC","region":"British Columbia","country_code":"CA","country":"Canada"},{"region_code":"CA","region":"California","country_code":"US","country":"United + string: '{"regions":[{"region_code":"CA","region":"California","country_code":"US","country":"United States"},{"region_code":"NY","region":"New York","country_code":"US","country":"United States"}]}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:17 GMT + recorded_at: Fri, 26 Jan 2024 21:12:59 GMT - request: method: post uri: https://api.taxjar.com/v2/taxes body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"},{"id":3,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"}],"shipping":"100.0"}' + - 34067"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":3,"quantity":2,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"}],"shipping":"0.0"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -90,48 +90,110 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '2269' + - '2252' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:17 GMT + - Fri, 26 Jan 2024 21:12:59 GMT X-Amzn-Requestid: - - 5bda80f3-1f1d-41bd-93f7-832028f14b83 + - 021b3528-fcaa-4275-8c4e-73b389a2ef10 Access-Control-Allow-Origin: - https://developers.taxjar.com X-Amz-Apigw-Id: - - G41cFH9noAMFy9g= + - SKn-ZEuwoAMEvyQ= X-Amzn-Trace-Id: - - Root=1-64936919-10065b6814db144a0827b468 + - Root=1-65b4205b-03c46d563e9b862635d28bf4 X-Cache: - Miss from cloudfront Via: - - 1.1 1f3b7526ee62cb21563bff4f9bde58f4.cloudfront.net (CloudFront) + - 1.1 fdbf0bf4022c61868d8dad6b7d72a71a.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - jx7kbUtohUQyOr66lnzr5HSJiEfZLOtLb3rowopVmQ8syMBdGYhyQw== + - Qputxp_7_JNVqg11FSNaEH1InwWhB2gZbVjw5tziqtDn40FXDWr9ug== body: encoding: UTF-8 - string: '{"tax":{"amount_to_collect":11.54,"breakdown":{"city_tax_collectable":6.34,"city_tax_rate":0.04875,"city_taxable_amount":130.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":5.2,"state_tax_rate":0.04,"state_taxable_amount":130.0,"tax_collectable":11.54,"taxable_amount":130.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW - YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":130.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":130.0}}' + string: '{"tax":{"amount_to_collect":3.55,"breakdown":{"city_tax_collectable":1.95,"city_tax_rate":0.04875,"city_taxable_amount":40.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.98,"city_tax_rate":0.04875,"city_taxable_amount":20.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.8,"state_sales_tax_rate":0.04,"state_taxable_amount":20.0,"tax_collectable":1.78,"taxable_amount":20.0}],"shipping":{"city_amount":0.0,"city_tax_rate":0.04875,"city_taxable_amount":0.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":0.0,"state_sales_tax_rate":0.04,"state_taxable_amount":0.0,"tax_collectable":0.0,"taxable_amount":0.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":1.6,"state_tax_rate":0.04,"state_taxable_amount":40.0,"tax_collectable":3.55,"taxable_amount":40.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":40.0,"rate":0.08875,"shipping":0.0,"tax_source":"destination","taxable_amount":40.0}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:17 GMT + recorded_at: Fri, 26 Jan 2024 21:12:59 GMT - request: method: post uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A + Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":3,"quantity":2,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"}],"shipping":"0.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '2252' + Connection: + - close + Date: + - Fri, 26 Jan 2024 21:13:00 GMT + X-Amzn-Requestid: + - 6bdbc2ac-2da8-4573-82a9-1593c9cd18a5 + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - SKn-cHJmoAMEIpQ= + X-Amzn-Trace-Id: + - Root=1-65b4205c-51628d7b61e1df961bda5091 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 71eaa9eb77c2eecb57c03cdcdad1cf76.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - YTO50-P2 + X-Amz-Cf-Id: + - dHiF99FIWduRwwl7nQ0GoszBHIQsR5Q9g7wex6H_XlyU_RmED0Yk9A== body: encoding: UTF-8 + string: '{"tax":{"amount_to_collect":3.55,"breakdown":{"city_tax_collectable":1.95,"city_tax_rate":0.04875,"city_taxable_amount":40.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.98,"city_tax_rate":0.04875,"city_taxable_amount":20.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.8,"state_sales_tax_rate":0.04,"state_taxable_amount":20.0,"tax_collectable":1.78,"taxable_amount":20.0}],"shipping":{"city_amount":0.0,"city_tax_rate":0.04875,"city_taxable_amount":0.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":0.0,"state_sales_tax_rate":0.04,"state_taxable_amount":0.0,"tax_collectable":0.0,"taxable_amount":0.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":1.6,"state_tax_rate":0.04,"state_taxable_amount":40.0,"tax_collectable":3.55,"taxable_amount":40.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":40.0,"rate":0.08875,"shipping":0.0,"tax_source":"destination","taxable_amount":40.0}}' + http_version: + recorded_at: Fri, 26 Jan 2024 21:13:00 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"},{"id":3,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"}],"shipping":"100.0"}' + - 34067"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":3,"quantity":2,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"}],"shipping":"0.0"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -152,48 +214,48 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '2269' + - '2252' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:18 GMT + - Fri, 26 Jan 2024 21:13:00 GMT X-Amzn-Requestid: - - 2d7e6e6f-11b7-4113-ac4b-9d5c3f1997be + - 8b942569-ec53-4dbd-b750-36a65e47a6e4 Access-Control-Allow-Origin: - https://developers.taxjar.com X-Amz-Apigw-Id: - - G41cJHgYIAMFbYQ= + - SKn-fHXCoAMEFkQ= X-Amzn-Trace-Id: - - Root=1-6493691a-59d1c0cb595ede496f39b98a + - Root=1-65b4205c-5aca30583033a9cc133eb082 X-Cache: - Miss from cloudfront Via: - - 1.1 1f3b7526ee62cb21563bff4f9bde58f4.cloudfront.net (CloudFront) + - 1.1 0e761f7a5b2481acd893422a702c9fa8.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - cOfrK_O0GHaIXQLUCO4kLUCymqTCna2JBcMvFWhSOZWHfDjnxOdTEA== + - MDePLO-Dv7bsxQEPYGYdos6Sr4g7_MFwtzCde4K07eTEzzNmx4M3gw== body: encoding: UTF-8 - string: '{"tax":{"amount_to_collect":11.54,"breakdown":{"city_tax_collectable":6.34,"city_tax_rate":0.04875,"city_taxable_amount":130.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":5.2,"state_tax_rate":0.04,"state_taxable_amount":130.0,"tax_collectable":11.54,"taxable_amount":130.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW - YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":130.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":130.0}}' + string: '{"tax":{"amount_to_collect":3.55,"breakdown":{"city_tax_collectable":1.95,"city_tax_rate":0.04875,"city_taxable_amount":40.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.98,"city_tax_rate":0.04875,"city_taxable_amount":20.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.8,"state_sales_tax_rate":0.04,"state_taxable_amount":20.0,"tax_collectable":1.78,"taxable_amount":20.0}],"shipping":{"city_amount":0.0,"city_tax_rate":0.04875,"city_taxable_amount":0.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":0.0,"state_sales_tax_rate":0.04,"state_taxable_amount":0.0,"tax_collectable":0.0,"taxable_amount":0.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":1.6,"state_tax_rate":0.04,"state_taxable_amount":40.0,"tax_collectable":3.55,"taxable_amount":40.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":40.0,"rate":0.08875,"shipping":0.0,"tax_source":"destination","taxable_amount":40.0}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:18 GMT + recorded_at: Fri, 26 Jan 2024 21:13:00 GMT - request: method: post uri: https://api.taxjar.com/v2/transactions/orders body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A - Different Road","line_items":[{"id":1,"quantity":1,"product_identifier":"SKU-2","description":"Product - #1 - 574 - Master","product_tax_code":"TaxCode - 230591","unit_price":"10.0","discount":0,"sales_tax":"0.89"},{"id":2,"quantity":1,"product_identifier":"SKU-3","description":"Product - #2 - 9979 - Master","product_tax_code":"TaxCode - 230591","unit_price":"10.0","discount":0,"sales_tax":"0.89"},{"id":3,"quantity":1,"product_identifier":"SKU-4","description":"Product - #3 - 4201 - Master","product_tax_code":"TaxCode - 230591","unit_price":"10.0","discount":0,"sales_tax":"0.89"}],"transaction_id":"R525233498","transaction_date":"2023-06-21T21:18:17Z","amount":"130.0","shipping":"100.0","sales_tax":"11.55"}' + Different Road","line_items":[{"id":1,"quantity":1,"product_identifier":"SKU-1","description":"First + Product - Master","product_tax_code":"TaxCode - 34067","unit_price":"10.0","discount":0,"sales_tax":"0.89"},{"id":2,"quantity":1,"product_identifier":"SKU-2","description":"Second + Product - Master","product_tax_code":"TaxCode - 34067","unit_price":"10.0","discount":0,"sales_tax":"0.89"},{"id":3,"quantity":2,"product_identifier":"SKU-3","description":"Third + Product - Master","product_tax_code":"TaxCode - 34067","unit_price":"10.0","discount":0,"sales_tax":"1.78"}],"transaction_id":"R925733488","transaction_date":"2024-01-26T21:12:59Z","amount":"40.0","shipping":"0.0","sales_tax":"3.56"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -214,64 +276,64 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1019' + - '1002' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:18 GMT + - Fri, 26 Jan 2024 21:13:00 GMT X-Amzn-Requestid: - - 927ad1a2-3841-4c78-87ba-ee224f3e3034 + - 88a6e44b-3f76-4c51-abeb-e2a0b57b8075 X-Amzn-Remapped-Content-Length: - - '1019' + - '1002' X-Amzn-Remapped-Connection: - keep-alive X-Request-Id: - - F2rJQqv1q2SlFTwQ4xGB + - F64CEP47noV1ss0Jr-9C X-Api-Version: - '2020-08-07' X-Amz-Apigw-Id: - - G41cMFGsIAMFSpQ= + - SKn-jGy9IAMES4w= Cache-Control: - max-age=0, private, must-revalidate X-Amzn-Remapped-Server: - Cowboy X-Amzn-Remapped-Date: - - Wed, 21 Jun 2023 21:18:18 GMT + - Fri, 26 Jan 2024 21:13:00 GMT X-Cache: - Miss from cloudfront Via: - - 1.1 7db4e24dac37de5a6dd7ddc6e5551834.cloudfront.net (CloudFront) + - 1.1 21c66eb5f493a6e3ddbaa803cebfe014.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - b-EBIzpQGDumuRD1FDW6JgPfJGby4C9tJNCilQwaFuTp1KOmAJ0_Jg== + - NaLSZWCV7TZhc7kD0nB1qnxXOIEair0I0QhzRLGcVXtfb01GgzoxLQ== body: encoding: UTF-8 - string: '{"order":{"user_id":225397,"transaction_reference_id":null,"transaction_id":"R525233498","transaction_date":"2023-06-21T21:18:17.000Z","to_zip":"11430","to_street":"A - Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"100.0","sales_tax":"11.55","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Product - #1 - 574 - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Product - #2 - 9979 - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-4","id":2,"discount":"0.0","description":"Product - #3 - 4201 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"130.0"}}' + string: '{"order":{"user_id":345723,"transaction_reference_id":null,"transaction_id":"R925733488","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"0.0","sales_tax":"3.56","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-1","id":0,"discount":"0.0","description":"First + Product - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":1,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"10.0","sales_tax":"1.78","quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":2,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"40.0"}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:18 GMT + recorded_at: Fri, 26 Jan 2024 21:13:00 GMT - request: method: post uri: https://api.taxjar.com/v2/taxes body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"},{"id":3,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"}],"shipping":"100.0"}' + - 34067"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":3,"quantity":2,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"}],"shipping":"0.0"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -292,48 +354,48 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '2269' + - '2252' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:20 GMT + - Fri, 26 Jan 2024 21:13:02 GMT X-Amzn-Requestid: - - 1fa2792f-80db-4e41-9603-6f541c30bb8f + - 2bfc715b-65cb-4eff-87b5-43229d95d86d Access-Control-Allow-Origin: - https://developers.taxjar.com X-Amz-Apigw-Id: - - G41cjEo-IAMFnrg= + - SKn-yF-IIAMEueg= X-Amzn-Trace-Id: - - Root=1-6493691c-1aa91238148e909f4a3c0e26 + - Root=1-65b4205e-59beb2a916833fa71bad48df X-Cache: - Miss from cloudfront Via: - - 1.1 460acc1f45378318570dee9fef15e250.cloudfront.net (CloudFront) + - 1.1 019b4503d2ffede0ae900992ff140770.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - Z2k-ikphJv0D_NV1OUuvLKYMIWbc8sb2UZgnrV5yGMmKzs32hhqs4w== + - Vpi92riSN2RP-zLxed8syzKdtPYVzd7xK6GnbCLmBCvXTuWIn7h-0w== body: encoding: UTF-8 - string: '{"tax":{"amount_to_collect":11.54,"breakdown":{"city_tax_collectable":6.34,"city_tax_rate":0.04875,"city_taxable_amount":130.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":5.2,"state_tax_rate":0.04,"state_taxable_amount":130.0,"tax_collectable":11.54,"taxable_amount":130.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW - YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":130.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":130.0}}' + string: '{"tax":{"amount_to_collect":3.55,"breakdown":{"city_tax_collectable":1.95,"city_tax_rate":0.04875,"city_taxable_amount":40.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.98,"city_tax_rate":0.04875,"city_taxable_amount":20.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.8,"state_sales_tax_rate":0.04,"state_taxable_amount":20.0,"tax_collectable":1.78,"taxable_amount":20.0}],"shipping":{"city_amount":0.0,"city_tax_rate":0.04875,"city_taxable_amount":0.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":0.0,"state_sales_tax_rate":0.04,"state_taxable_amount":0.0,"tax_collectable":0.0,"taxable_amount":0.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":1.6,"state_tax_rate":0.04,"state_taxable_amount":40.0,"tax_collectable":3.55,"taxable_amount":40.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":40.0,"rate":0.08875,"shipping":0.0,"tax_source":"destination","taxable_amount":40.0}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:20 GMT + recorded_at: Fri, 26 Jan 2024 21:13:02 GMT - request: method: post uri: https://api.taxjar.com/v2/taxes body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"},{"id":3,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode - - 230591"}],"shipping":"100.0"}' + - 34067"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":3,"quantity":2,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"}],"shipping":"0.0"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -354,44 +416,116 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '2269' + - '2252' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:21 GMT + - Fri, 26 Jan 2024 21:13:02 GMT X-Amzn-Requestid: - - 8c2bf3d9-bcb3-4762-a38c-3dbef4c33f2f + - efa7750a-cc0c-44a5-b174-28e9fd5624df Access-Control-Allow-Origin: - https://developers.taxjar.com X-Amz-Apigw-Id: - - G41crH72oAMFlUg= + - SKn-4GjYIAMEKEQ= X-Amzn-Trace-Id: - - Root=1-6493691d-0920a539759cb1450949427a + - Root=1-65b4205e-12bb9a6716a49b7e4f9e81ae X-Cache: - Miss from cloudfront Via: - - 1.1 c62a93323aa9596e4fc904c577b75368.cloudfront.net (CloudFront) + - 1.1 4ec5f8da969dc981ba2067c9dad5dad8.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - HJ8h95FsqJZlNz4chgG5ol0KOuzgcrn-S31DZd6wfem2OUch8zmRnQ== + - BB_R0-Jb89SCyRzYe3amKGojR4kbb_tOWdkzpr48fAyQE2AsnbIwmA== body: encoding: UTF-8 - string: '{"tax":{"amount_to_collect":11.54,"breakdown":{"city_tax_collectable":6.34,"city_tax_rate":0.04875,"city_taxable_amount":130.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0}],"shipping":{"city_amount":4.88,"city_tax_rate":0.04875,"city_taxable_amount":100.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":4.0,"state_sales_tax_rate":0.04,"state_taxable_amount":100.0,"tax_collectable":8.88,"taxable_amount":100.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":5.2,"state_tax_rate":0.04,"state_taxable_amount":130.0,"tax_collectable":11.54,"taxable_amount":130.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW - YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":130.0,"rate":0.08875,"shipping":100.0,"tax_source":"destination","taxable_amount":130.0}}' + string: '{"tax":{"amount_to_collect":3.55,"breakdown":{"city_tax_collectable":1.95,"city_tax_rate":0.04875,"city_taxable_amount":40.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.98,"city_tax_rate":0.04875,"city_taxable_amount":20.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.8,"state_sales_tax_rate":0.04,"state_taxable_amount":20.0,"tax_collectable":1.78,"taxable_amount":20.0}],"shipping":{"city_amount":0.0,"city_tax_rate":0.04875,"city_taxable_amount":0.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":0.0,"state_sales_tax_rate":0.04,"state_taxable_amount":0.0,"tax_collectable":0.0,"taxable_amount":0.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":1.6,"state_tax_rate":0.04,"state_taxable_amount":40.0,"tax_collectable":3.55,"taxable_amount":40.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":40.0,"rate":0.08875,"shipping":0.0,"tax_source":"destination","taxable_amount":40.0}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:21 GMT + recorded_at: Fri, 26 Jan 2024 21:13:02 GMT - request: method: get - uri: https://api.taxjar.com/v2/transactions/orders/R525233498 + uri: https://api.taxjar.com/v2/transactions/orders/R925733488 + body: + encoding: ASCII-8BIT + string: '' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1002' + Connection: + - close + Date: + - Fri, 26 Jan 2024 21:13:03 GMT + X-Amzn-Requestid: + - e5866fe7-611a-410c-ad63-cb20e20b5aeb + X-Amzn-Remapped-Content-Length: + - '1002' + X-Amzn-Remapped-Connection: + - keep-alive + X-Request-Id: + - F64CEY2lHIapol4GmwgD + X-Api-Version: + - '2020-08-07' + X-Amz-Apigw-Id: + - SKn-7GDAIAMEeYQ= + Cache-Control: + - max-age=0, private, must-revalidate + X-Amzn-Remapped-Server: + - Cowboy + X-Amzn-Remapped-Date: + - Fri, 26 Jan 2024 21:13:03 GMT + X-Cache: + - Miss from cloudfront + Via: + - 1.1 53d47b61433f6e1682b806fc166731be.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - YTO50-P2 + X-Amz-Cf-Id: + - 3Zad1Ulgbcwyi29z2g80A-qt_5hcTuwbs2b8Ach9eLPEEhBhtq0Q3Q== body: encoding: UTF-8 + string: '{"order":{"user_id":345723,"transaction_reference_id":null,"transaction_id":"R925733488","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"0.0","sales_tax":"3.56","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-1","id":0,"discount":"0.0","description":"First + Product - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":1,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"10.0","sales_tax":"1.78","quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":2,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"40.0"}}' + http_version: + recorded_at: Fri, 26 Jan 2024 21:13:03 GMT +- request: + method: get + uri: https://api.taxjar.com/v2/transactions/orders/R925733488 + body: + encoding: ASCII-8BIT string: '' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -410,60 +544,410 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1019' + - '1002' + Connection: + - close + Date: + - Fri, 26 Jan 2024 21:13:03 GMT + X-Amzn-Requestid: + - d582b8a5-6287-4567-bcea-df48bddf2f92 + X-Amzn-Remapped-Content-Length: + - '1002' + X-Amzn-Remapped-Connection: + - keep-alive + X-Request-Id: + - F64CEZvC6W2ZjtYMjJaB + X-Api-Version: + - '2020-08-07' + X-Amz-Apigw-Id: + - SKn-9GIQoAMEN1Q= + Cache-Control: + - max-age=0, private, must-revalidate + X-Amzn-Remapped-Server: + - Cowboy + X-Amzn-Remapped-Date: + - Fri, 26 Jan 2024 21:13:03 GMT + X-Cache: + - Miss from cloudfront + Via: + - 1.1 cfcfb1d8fbf5ce2b107182799687a614.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - YTO50-P2 + X-Amz-Cf-Id: + - rB9mm0gB-bTEHMSYvIMASjfF-rPQJMDXYAyAj--L6C-Or1tSOvVrZw== + body: + encoding: UTF-8 + string: '{"order":{"user_id":345723,"transaction_reference_id":null,"transaction_id":"R925733488","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"0.0","sales_tax":"3.56","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-1","id":0,"discount":"0.0","description":"First + Product - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":1,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"10.0","sales_tax":"1.78","quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":2,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"40.0"}}' + http_version: + recorded_at: Fri, 26 Jan 2024 21:13:03 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/transactions/refunds + body: + encoding: ASCII-8BIT + string: '{"to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A + Different Road","transaction_id":"R925733488-REFUND","transaction_reference_id":"R925733488","transaction_date":"2024-01-26T21:12:59Z","amount":-40.0,"sales_tax":-3.56,"shipping":-0.0,"line_items":[{"unit_price":-10.0,"sales_tax":-0.89,"quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-1","id":0,"discount":-0.0,"description":"First + Product - Master"},{"unit_price":-10.0,"sales_tax":-0.89,"quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":1,"discount":-0.0,"description":"Second + Product - Master"},{"unit_price":-10.0,"sales_tax":-1.78,"quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":2,"discount":-0.0,"description":"Third + Product - Master"}]}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 201 + message: Created + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1028' + Connection: + - close + Date: + - Fri, 26 Jan 2024 21:13:03 GMT + X-Amzn-Requestid: + - 536f24f6-94bf-4612-be5a-12bd2929f091 + X-Amzn-Remapped-Content-Length: + - '1028' + X-Amzn-Remapped-Connection: + - keep-alive + X-Request-Id: + - F64CEazOk20Gk4oMjJkB + X-Api-Version: + - '2020-08-07' + X-Amz-Apigw-Id: + - SKn_AEhooAMEQHA= + Cache-Control: + - max-age=0, private, must-revalidate + X-Amzn-Remapped-Server: + - Cowboy + X-Amzn-Remapped-Date: + - Fri, 26 Jan 2024 21:13:03 GMT + X-Cache: + - Miss from cloudfront + Via: + - 1.1 5a2f8eb373b5a17b769c0fee9b0725a6.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - YTO50-P2 + X-Amz-Cf-Id: + - dSq-Gu-wHMIx7HQCutoHf7uSeMsXkFDtLlSpAPP0ivimpBcx7OvOAQ== + body: + encoding: UTF-8 + string: '{"refund":{"user_id":345723,"transaction_reference_id":"R925733488","transaction_id":"R925733488-REFUND","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"-0.0","sales_tax":"-3.56","provider":"api","line_items":[{"unit_price":"-10.0","sales_tax":"-0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-1","id":0,"discount":"0.0","description":"First + Product - Master"},{"unit_price":"-10.0","sales_tax":"-0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":1,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"-10.0","sales_tax":"-1.78","quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":2,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":null,"amount":"-40.0"}}' + http_version: + recorded_at: Fri, 26 Jan 2024 21:13:03 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/transactions/orders + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A + Different Road","line_items":[{"id":2,"quantity":1,"product_identifier":"SKU-2","description":"Second + Product - Master","product_tax_code":"TaxCode - 34067","unit_price":"10.0","discount":0,"sales_tax":"0.89"},{"id":3,"quantity":2,"product_identifier":"SKU-3","description":"Third + Product - Master","product_tax_code":"TaxCode - 34067","unit_price":"10.0","discount":0,"sales_tax":"1.78"}],"transaction_id":"R925733488-1","transaction_date":"2024-01-26T21:12:59Z","amount":"30.0","shipping":"0.0","sales_tax":"3.56"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 201 + message: Created + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '821' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:21 GMT + - Fri, 26 Jan 2024 21:13:04 GMT X-Amzn-Requestid: - - 70615c98-e5a4-46e3-8758-149ca35154fe + - b2f59741-8fb0-4692-ac5e-0df4a6701f16 X-Amzn-Remapped-Content-Length: - - '1019' + - '821' X-Amzn-Remapped-Connection: - keep-alive X-Request-Id: - - F2rJQ2wWnoClFTwM6LxC + - F64CEcDmL-xUvCIJtaoC X-Api-Version: - '2020-08-07' X-Amz-Apigw-Id: - - G41ctGYLIAMF7Ew= + - SKn_DFc_IAMENqA= Cache-Control: - max-age=0, private, must-revalidate X-Amzn-Remapped-Server: - Cowboy X-Amzn-Remapped-Date: - - Wed, 21 Jun 2023 21:18:21 GMT + - Fri, 26 Jan 2024 21:13:04 GMT + X-Cache: + - Miss from cloudfront + Via: + - 1.1 8e6145785e47042f882be946f6c05880.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - YTO50-P2 + X-Amz-Cf-Id: + - T7uFYJsyeittCmiGdnudnTsLMccaecQ7ppRsweQN5z2EuLjzpkr-QA== + body: + encoding: UTF-8 + string: '{"order":{"user_id":345723,"transaction_reference_id":null,"transaction_id":"R925733488-1","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"0.0","sales_tax":"3.56","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"10.0","sales_tax":"1.78","quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"30.0"}}' + http_version: + recorded_at: Fri, 26 Jan 2024 21:13:04 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A + Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":3,"quantity":2,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"}],"shipping":"0.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '2252' + Connection: + - close + Date: + - Fri, 26 Jan 2024 21:13:05 GMT + X-Amzn-Requestid: + - ec6c0dad-b8a1-441a-895d-39f12796b522 + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - SKn_RGE1oAMEHbw= + X-Amzn-Trace-Id: + - Root=1-65b42061-6715064d13ed9519445c792e X-Cache: - Miss from cloudfront Via: - - 1.1 04d07067300da6b0220ea49e4eb899de.cloudfront.net (CloudFront) + - 1.1 6589108eb8812ce79de8a8eef3f72bee.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - Rh_ayhhoV84UVhla6eusMUwjfBnOO8xGkm6guURNvKnXs8EC40Eqhg== + - REIkLVNyB2n8Cl0yaLIlFiXPZKrlckCN4dhaBRFJPXXMkzXxp3LX2w== body: encoding: UTF-8 - string: '{"order":{"user_id":225397,"transaction_reference_id":null,"transaction_id":"R525233498","transaction_date":"2023-06-21T21:18:17.000Z","to_zip":"11430","to_street":"A - Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"100.0","sales_tax":"11.55","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Product - #1 - 574 - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Product - #2 - 9979 - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-4","id":2,"discount":"0.0","description":"Product - #3 - 4201 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"130.0"}}' + string: '{"tax":{"amount_to_collect":3.55,"breakdown":{"city_tax_collectable":1.95,"city_tax_rate":0.04875,"city_taxable_amount":40.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.98,"city_tax_rate":0.04875,"city_taxable_amount":20.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.8,"state_sales_tax_rate":0.04,"state_taxable_amount":20.0,"tax_collectable":1.78,"taxable_amount":20.0}],"shipping":{"city_amount":0.0,"city_tax_rate":0.04875,"city_taxable_amount":0.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":0.0,"state_sales_tax_rate":0.04,"state_taxable_amount":0.0,"tax_collectable":0.0,"taxable_amount":0.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":1.6,"state_tax_rate":0.04,"state_taxable_amount":40.0,"tax_collectable":3.55,"taxable_amount":40.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":40.0,"rate":0.08875,"shipping":0.0,"tax_source":"destination","taxable_amount":40.0}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:21 GMT + recorded_at: Fri, 26 Jan 2024 21:13:05 GMT +- request: + method: post + uri: https://api.taxjar.com/v2/taxes + body: + encoding: ASCII-8BIT + string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A + Different Road","line_items":[{"id":1,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":2,"quantity":1,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"},{"id":3,"quantity":2,"unit_price":"10.0","discount":0,"product_tax_code":"TaxCode + - 34067"}],"shipping":"0.0"}' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Content-Type: + - application/json; charset=UTF-8 + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '2252' + Connection: + - close + Date: + - Fri, 26 Jan 2024 21:13:06 GMT + X-Amzn-Requestid: + - 9918ef36-ad2f-412a-be37-a413f76f64a7 + Access-Control-Allow-Origin: + - https://developers.taxjar.com + X-Amz-Apigw-Id: + - SKn_XHrLIAMEUbA= + X-Amzn-Trace-Id: + - Root=1-65b42062-486ab2480e14caf26ffbb966 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 dcd16c430149132ea12a5783d54ff114.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - YTO50-P2 + X-Amz-Cf-Id: + - H8rzutGPWZDrIFIoEunhfjWs4vtnYntyY1X-Fc-QegWBsvcGE4dRlw== + body: + encoding: UTF-8 + string: '{"tax":{"amount_to_collect":3.55,"breakdown":{"city_tax_collectable":1.95,"city_tax_rate":0.04875,"city_taxable_amount":40.0,"combined_tax_rate":0.08875,"county_tax_collectable":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"line_items":[{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.49,"city_tax_rate":0.04875,"city_taxable_amount":10.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"2","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.4,"state_sales_tax_rate":0.04,"state_taxable_amount":10.0,"tax_collectable":0.89,"taxable_amount":10.0},{"city_amount":0.98,"city_tax_rate":0.04875,"city_taxable_amount":20.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"id":"3","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":0.8,"state_sales_tax_rate":0.04,"state_taxable_amount":20.0,"tax_collectable":1.78,"taxable_amount":20.0}],"shipping":{"city_amount":0.0,"city_tax_rate":0.04875,"city_taxable_amount":0.0,"combined_tax_rate":0.08875,"county_amount":0.0,"county_tax_rate":0.0,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":0.0,"state_sales_tax_rate":0.04,"state_taxable_amount":0.0,"tax_collectable":0.0,"taxable_amount":0.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":1.6,"state_tax_rate":0.04,"state_taxable_amount":40.0,"tax_collectable":3.55,"taxable_amount":40.0},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"NEW + YORK CITY","country":"US","county":"QUEENS","state":"NY"},"order_total_amount":40.0,"rate":0.08875,"shipping":0.0,"tax_source":"destination","taxable_amount":40.0}}' + http_version: + recorded_at: Fri, 26 Jan 2024 21:13:06 GMT - request: method: get - uri: https://api.taxjar.com/v2/transactions/orders/R525233498 + uri: https://api.taxjar.com/v2/transactions/orders/R925733488-1 + body: + encoding: ASCII-8BIT + string: '' + headers: + User-Agent: + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' + Authorization: + - Bearer + X-Api-Version: + - '2020-08-07' + Plugin: + - supergoodsolidustaxjar + Connection: + - close + Host: + - api.taxjar.com + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '821' + Connection: + - close + Date: + - Fri, 26 Jan 2024 21:13:06 GMT + X-Amzn-Requestid: + - 036ae0ba-2f05-47c2-a6c7-c8c3ee79678d + X-Amzn-Remapped-Content-Length: + - '821' + X-Amzn-Remapped-Connection: + - keep-alive + X-Request-Id: + - F64CEkU_iC4JtN0JeJcC + X-Api-Version: + - '2020-08-07' + X-Amz-Apigw-Id: + - SKn_aF9koAMEQeQ= + Cache-Control: + - max-age=0, private, must-revalidate + X-Amzn-Remapped-Server: + - Cowboy + X-Amzn-Remapped-Date: + - Fri, 26 Jan 2024 21:13:06 GMT + X-Cache: + - Miss from cloudfront + Via: + - 1.1 67dd4d73b80aece69a8e725c6d612b6e.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - YTO50-P2 + X-Amz-Cf-Id: + - ahRCSaqxaCk5NIlTzyxtWGP3OHD14kjRHo2KyeTP3M9I7em1D__dKg== body: encoding: UTF-8 + string: '{"order":{"user_id":345723,"transaction_reference_id":null,"transaction_id":"R925733488-1","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"0.0","sales_tax":"3.56","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"10.0","sales_tax":"1.78","quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"30.0"}}' + http_version: + recorded_at: Fri, 26 Jan 2024 21:13:06 GMT +- request: + method: get + uri: https://api.taxjar.com/v2/transactions/orders/R925733488-1 + body: + encoding: ASCII-8BIT string: '' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -482,67 +966,63 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1019' + - '821' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:22 GMT + - Fri, 26 Jan 2024 21:13:06 GMT X-Amzn-Requestid: - - 69b44d96-7c11-47fb-9997-efa7d85d78b6 + - 57efab79-9f9c-4d6f-aa43-f4f9de26d2bd X-Amzn-Remapped-Content-Length: - - '1019' + - '821' X-Amzn-Remapped-Connection: - keep-alive X-Request-Id: - - F2rJQ3eClglPpvYIWUyD + - F64CElSQXR07fM4F2YBB X-Api-Version: - '2020-08-07' X-Amz-Apigw-Id: - - G41cvE97oAMFQuA= + - SKn_cGukoAMEIxQ= Cache-Control: - max-age=0, private, must-revalidate X-Amzn-Remapped-Server: - Cowboy X-Amzn-Remapped-Date: - - Wed, 21 Jun 2023 21:18:22 GMT + - Fri, 26 Jan 2024 21:13:06 GMT X-Cache: - Miss from cloudfront Via: - - 1.1 7db4e24dac37de5a6dd7ddc6e5551834.cloudfront.net (CloudFront) + - 1.1 cfcfb1d8fbf5ce2b107182799687a614.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - jUCMXu0MSeO8Ks7QdaS-NXlJRqrL2iOb1RCR1qvrE5uDhsMfX-E3kg== + - KcA20II6Sbl4cFYDTf7zimmB7a2HM8sblSCbiTPPqAc_F_M9OCG2og== body: encoding: UTF-8 - string: '{"order":{"user_id":225397,"transaction_reference_id":null,"transaction_id":"R525233498","transaction_date":"2023-06-21T21:18:17.000Z","to_zip":"11430","to_street":"A - Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"100.0","sales_tax":"11.55","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Product - #1 - 574 - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Product - #2 - 9979 - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-4","id":2,"discount":"0.0","description":"Product - #3 - 4201 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"130.0"}}' + string: '{"order":{"user_id":345723,"transaction_reference_id":null,"transaction_id":"R925733488-1","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"0.0","sales_tax":"3.56","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"10.0","sales_tax":"1.78","quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"30.0"}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:22 GMT + recorded_at: Fri, 26 Jan 2024 21:13:06 GMT - request: method: post uri: https://api.taxjar.com/v2/transactions/refunds body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A - Different Road","transaction_id":"R525233498-REFUND","transaction_reference_id":"R525233498","transaction_date":"2023-06-21T21:18:17Z","amount":-130.0,"sales_tax":-11.55,"shipping":-100.0,"line_items":[{"unit_price":-10.0,"sales_tax":-0.89,"quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-2","id":0,"discount":-0.0,"description":"Product - #1 - 574 - Master"},{"unit_price":-10.0,"sales_tax":-0.89,"quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-3","id":1,"discount":-0.0,"description":"Product - #2 - 9979 - Master"},{"unit_price":-10.0,"sales_tax":-0.89,"quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-4","id":2,"discount":-0.0,"description":"Product - #3 - 4201 - Master"}]}' + Different Road","transaction_id":"R925733488-1-REFUND","transaction_reference_id":"R925733488-1","transaction_date":"2024-01-26T21:12:59Z","amount":-30.0,"sales_tax":-3.56,"shipping":-0.0,"line_items":[{"unit_price":-10.0,"sales_tax":-0.89,"quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":0,"discount":-0.0,"description":"Second + Product - Master"},{"unit_price":-10.0,"sales_tax":-1.78,"quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":1,"discount":-0.0,"description":"Third + Product - Master"}]}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -563,64 +1043,61 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1045' + - '847' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:22 GMT + - Fri, 26 Jan 2024 21:13:06 GMT X-Amzn-Requestid: - - 85e84761-21a1-4c12-99d2-4fba4e6acf77 + - cfa9976f-29e1-4a70-ad33-bd5f54283e3c X-Amzn-Remapped-Content-Length: - - '1045' + - '847' X-Amzn-Remapped-Connection: - keep-alive X-Request-Id: - - F2rJQ4J5H5VPpvYNQYlC + - F64CEmSB-c-g4PIEf68C X-Api-Version: - '2020-08-07' X-Amz-Apigw-Id: - - G41cwHW8oAMFo7A= + - SKn_fGEjoAMEhDw= Cache-Control: - max-age=0, private, must-revalidate X-Amzn-Remapped-Server: - Cowboy X-Amzn-Remapped-Date: - - Wed, 21 Jun 2023 21:18:22 GMT + - Fri, 26 Jan 2024 21:13:06 GMT X-Cache: - Miss from cloudfront Via: - - 1.1 e00edd9ee60059876e31b4df9cf86e02.cloudfront.net (CloudFront) + - 1.1 12aa3fefbdb5e80269e58f34f94a99e8.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - Bdaryk2Tb3FYLNWERkoYiiwOnGo4Duct2OYOH9K88lwLGV7_hxPxNA== + - 4iSY_0OCvu20hHCxfgEkj3RYdfnQi1uS6FCxz2lsEc1gkdcaWW0C5Q== body: encoding: UTF-8 - string: '{"refund":{"user_id":225397,"transaction_reference_id":"R525233498","transaction_id":"R525233498-REFUND","transaction_date":"2023-06-21T21:18:17.000Z","to_zip":"11430","to_street":"A - Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"-100.0","sales_tax":"-11.55","provider":"api","line_items":[{"unit_price":"-10.0","sales_tax":"-0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Product - #1 - 574 - Master"},{"unit_price":"-10.0","sales_tax":"-0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Product - #2 - 9979 - Master"},{"unit_price":"-10.0","sales_tax":"-0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-4","id":2,"discount":"0.0","description":"Product - #3 - 4201 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":null,"amount":"-130.0"}}' + string: '{"refund":{"user_id":345723,"transaction_reference_id":"R925733488-1","transaction_id":"R925733488-1-REFUND","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"-0.0","sales_tax":"-3.56","provider":"api","line_items":[{"unit_price":"-10.0","sales_tax":"-0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"-10.0","sales_tax":"-1.78","quantity":2,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":null,"amount":"-30.0"}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:22 GMT + recorded_at: Fri, 26 Jan 2024 21:13:06 GMT - request: method: post uri: https://api.taxjar.com/v2/transactions/orders body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"customer_id":"1","to_country":"US","to_zip":"11430","to_city":"Herndon","to_state":"NY","to_street":"A - Different Road","line_items":[{"id":1,"quantity":1,"product_identifier":"SKU-2","description":"Product - #1 - 574 - Master","product_tax_code":"TaxCode - 230591","unit_price":"10.0","discount":0,"sales_tax":"0.89"},{"id":2,"quantity":1,"product_identifier":"SKU-3","description":"Product - #2 - 9979 - Master","product_tax_code":"TaxCode - 230591","unit_price":"10.0","discount":0,"sales_tax":"0.89"},{"id":3,"quantity":1,"product_identifier":"SKU-4","description":"Product - #3 - 4201 - Master","product_tax_code":"TaxCode - 230591","unit_price":"10.0","discount":0,"sales_tax":"0.89"}],"transaction_id":"R525233498-1","transaction_date":"2023-06-21T21:18:17Z","amount":"130.0","shipping":"100.0","sales_tax":"11.55"}' + Different Road","line_items":[{"id":2,"quantity":1,"product_identifier":"SKU-2","description":"Second + Product - Master","product_tax_code":"TaxCode - 34067","unit_price":"10.0","discount":0,"sales_tax":"0.89"},{"id":3,"quantity":1,"product_identifier":"SKU-3","description":"Third + Product - Master","product_tax_code":"TaxCode - 34067","unit_price":"10.0","discount":0,"sales_tax":"1.78"}],"transaction_id":"R925733488-2","transaction_date":"2024-01-26T21:12:59Z","amount":"20.0","shipping":"0.0","sales_tax":"3.56"}' headers: User-Agent: - - 'TaxJar/Ruby (Darwin Nicks-Mac-mini.local 22.5.0 Darwin Kernel Version 22.5.0: - Mon Apr 24 20:53:44 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8103 arm64; - ruby 2.7.8-p225; OpenSSL 1.1.1t 7 Feb 2023) taxjar-ruby/3.0.4' + - 'TaxJar/Ruby (Darwin Noahs-MacBook-Pro.local 21.6.0 Darwin Kernel Version + 21.6.0: Mon Apr 24 21:11:17 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_ARM64_T6000 + arm64; ruby 3.2.2-p53; OpenSSL 3.1.2 1 Aug 2023) taxjar-ruby/3.0.4' Authorization: - Bearer X-Api-Version: @@ -641,47 +1118,45 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1021' + - '821' Connection: - close Date: - - Wed, 21 Jun 2023 21:18:22 GMT + - Fri, 26 Jan 2024 21:13:07 GMT X-Amzn-Requestid: - - ae726675-7bfc-415b-a926-0184c4b6a146 + - aa723125-135e-41a0-9e72-c7c04e83c60b X-Amzn-Remapped-Content-Length: - - '1021' + - '821' X-Amzn-Remapped-Connection: - keep-alive X-Request-Id: - - F2rJQ5JoN8xjG-0NL_NC + - F64CEnllaanYBwkJsCRC X-Api-Version: - '2020-08-07' X-Amz-Apigw-Id: - - G41czGproAMFpuw= + - SKn_iHHMIAMEAxQ= Cache-Control: - max-age=0, private, must-revalidate X-Amzn-Remapped-Server: - Cowboy X-Amzn-Remapped-Date: - - Wed, 21 Jun 2023 21:18:22 GMT + - Fri, 26 Jan 2024 21:13:07 GMT X-Cache: - Miss from cloudfront Via: - - 1.1 94d1167faad8c4981cbe31298f27eeb8.cloudfront.net (CloudFront) + - 1.1 7293b56f3a0eb541aadcbcaa0146d528.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA73-P3 + - YTO50-P2 X-Amz-Cf-Id: - - OtK7Euguao1hZPi7LSHTAxbi0RW0bHPPWBQF_NN0DSqPqVQPyH8Sww== + - 7wAQ8hn5VG32oZWTwFuwXi6pz8H4JaI_Rp7R1XZn8NR7k9Tzd3maDg== body: encoding: UTF-8 - string: '{"order":{"user_id":225397,"transaction_reference_id":null,"transaction_id":"R525233498-1","transaction_date":"2023-06-21T21:18:17.000Z","to_zip":"11430","to_street":"A - Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"100.0","sales_tax":"11.55","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Product - #1 - 574 - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Product - #2 - 9979 - Master"},{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode - - 230591","product_identifier":"SKU-4","id":2,"discount":"0.0","description":"Product - #3 - 4201 - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"130.0"}}' + string: '{"order":{"user_id":345723,"transaction_reference_id":null,"transaction_id":"R925733488-2","transaction_date":"2024-01-26T21:12:59.000Z","to_zip":"11430","to_street":"A + Different Road","to_state":"NY","to_country":"US","to_city":"HERNDON","shipping":"0.0","sales_tax":"3.56","provider":"api","line_items":[{"unit_price":"10.0","sales_tax":"0.89","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-2","id":0,"discount":"0.0","description":"Second + Product - Master"},{"unit_price":"10.0","sales_tax":"1.78","quantity":1,"product_tax_code":"TaxCode + - 34067","product_identifier":"SKU-3","id":1,"discount":"0.0","description":"Third + Product - Master"}],"from_zip":null,"from_street":null,"from_state":null,"from_country":"US","from_city":null,"exemption_type":null,"customer_id":"1","amount":"20.0"}}' http_version: - recorded_at: Wed, 21 Jun 2023 21:18:22 GMT + recorded_at: Fri, 26 Jan 2024 21:13:07 GMT recorded_with: VCR 4.0.0 diff --git a/spec/jobs/super_good/solidus_taxjar/replace_transaction_job_spec.rb b/spec/jobs/super_good/solidus_taxjar/replace_transaction_job_spec.rb index b93967f3..ee686778 100644 --- a/spec/jobs/super_good/solidus_taxjar/replace_transaction_job_spec.rb +++ b/spec/jobs/super_good/solidus_taxjar/replace_transaction_job_spec.rb @@ -6,6 +6,17 @@ let(:order) { create :order } let(:mock_reporting) { instance_double ::SuperGood::SolidusTaxjar::Reporting } + let(:fake_order_transaction) { create :taxjar_order_transaction } + let!(:fake_refund_transaction) { create :taxjar_refund_transaction, order_transaction: fake_order_transaction } + + before do + allow(mock_reporting) + .to receive(:refund_and_create_new_transaction) + .and_return(fake_order_transaction) + allow(SuperGood::SolidusTaxjar) + .to receive(:reporting) + .and_return(mock_reporting) + end it "enqueues the job" do assert_enqueued_with(job: described_class, args: [order]) do @@ -14,12 +25,71 @@ end it "replaces the transaction when it performs the job" do - allow(SuperGood::SolidusTaxjar).to receive(:reporting).and_return(mock_reporting) - expect(mock_reporting).to receive(:refund_and_create_new_transaction).with(order) - perform_enqueued_jobs do subject end + + expect(mock_reporting) + .to have_received(:refund_and_create_new_transaction) + .with(order) + end + + it "creates multiple transaction sync logs with the order transactions and refund transactions" do + expect { perform_enqueued_jobs { subject } } + .to change { ::SuperGood::SolidusTaxjar::TransactionSyncLog.count } + .by(1) + + expect(::SuperGood::SolidusTaxjar::TransactionSyncLog.last) + .to have_attributes( + status: "success", + refund_transaction: fake_refund_transaction, + order_transaction: fake_order_transaction + ) + end + + context "when a replacing the transaction has already partially succeeded" do + let(:fake_order_transaction) { create :taxjar_order_transaction } + let(:fake_refund_transaction) { nil } + + before do + allow(mock_reporting) + .to receive(:refund_and_create_new_transaction) + .and_return(fake_order_transaction) + end + + it "creates a transaction sync log with the order transaction" do + expect { perform_enqueued_jobs { subject } } + .to change { ::SuperGood::SolidusTaxjar::TransactionSyncLog.count } + .by(1) + + expect(::SuperGood::SolidusTaxjar::TransactionSyncLog.last) + .to have_attributes( + status: "success", + order_transaction: fake_order_transaction, + refund_transaction: nil + ) + end + end + + context "when replacing the transaction throws an error" do + before do + allow(mock_reporting) + .to receive(:refund_and_create_new_transaction) + .and_raise(Taxjar::Error.new("something bad")) + end + + it "creates a transaction sync log with the error message" do + expect { perform_enqueued_jobs {subject} } + .to change { ::SuperGood::SolidusTaxjar::TransactionSyncLog.count } + .from(0) + .to(1) + + expect(::SuperGood::SolidusTaxjar::TransactionSyncLog.last) + .to have_attributes( + status: "error", + error_message: "something bad" + ) + end end end end diff --git a/spec/models/spree/shipment_spec.rb b/spec/models/spree/shipment_spec.rb deleted file mode 100644 index ca2c69ef..00000000 --- a/spec/models/spree/shipment_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -RSpec.describe Spree::Shipment do - describe '#update' do - subject { shipment.ship } - - let(:shipment) { create(:shipment, state: 'ready', order: order) } - let(:order) { create :order_with_line_items } - - it 'fires the shipment_shipped event exactly once' do - expect(SolidusSupport::LegacyEventCompat::Bus) - .to receive(:publish) - .with( - :shipment_shipped, - shipment: shipment - ) - .once - - subject - end - end -end diff --git a/spec/models/super_good/solidus_taxjar/order_transaction_spec.rb b/spec/models/super_good/solidus_taxjar/order_transaction_spec.rb index df36451a..eff39755 100644 --- a/spec/models/super_good/solidus_taxjar/order_transaction_spec.rb +++ b/spec/models/super_good/solidus_taxjar/order_transaction_spec.rb @@ -11,17 +11,19 @@ end context "when there are one or more order transactions" do + let(:transaction_date) { 1.day.ago } + let!(:first_order_transaction) { create( :taxjar_order_transaction, - transaction_date: 2.days.ago, + transaction_date: transaction_date, order: order ) } let!(:latest_order_transaction) { create( :taxjar_order_transaction, - transaction_date: 1.days.ago, + transaction_date: transaction_date, order: order ) } diff --git a/spec/requests/spree/admin/order_request_spec.rb b/spec/requests/spree/admin/order_request_spec.rb index 25accf86..441335eb 100644 --- a/spec/requests/spree/admin/order_request_spec.rb +++ b/spec/requests/spree/admin/order_request_spec.rb @@ -101,7 +101,8 @@ subject { get spree.taxjar_transactions_admin_order_path(order) } let!(:order) { create(:shipped_order) } - let(:order_transaction) { create :taxjar_order_transaction, transaction_id: "Test-123"} + let(:order_transaction) { create :taxjar_order_transaction, transaction_id: "Test-123", refund_transaction: refund_transaction} + let(:refund_transaction) { create :taxjar_refund_transaction, transaction_id: "Test-123-refund"} before do create :transaction_sync_log, order: order, order_transaction: order_transaction, status: :success @@ -114,7 +115,7 @@ it "renders the transaction sync logs" do subject - expect(response.body).to have_text("#{order.number} Test-123 Success", normalize_ws: true) + expect(response.body).to have_text("#{order.number} Test-123 Test-123-refund Success", normalize_ws: true) end end end diff --git a/spec/requests/spree/admin/taxjar_transactions_request_spec.rb b/spec/requests/spree/admin/taxjar_transactions_request_spec.rb new file mode 100644 index 00000000..d73c75dd --- /dev/null +++ b/spec/requests/spree/admin/taxjar_transactions_request_spec.rb @@ -0,0 +1,62 @@ +require "spec_helper" + +RSpec.describe Spree::Admin::TaxjarTransactionsController, type: :request do + extend Spree::TestingSupport::AuthorizationHelpers::Request + + stub_authorization! + + let(:dummy_taxjar_client) { + instance_double Taxjar::Client, + nexus_regions: "fake-value" + } + let(:order) { with_events_disabled { create :shipped_order } } + + before do + create :taxjar_configuration, + preferred_reporting_enabled_at_integer: 1.hour.ago + + allow(SuperGood::SolidusTaxjar::Api) + .to receive(:default_taxjar_client) + .and_return(dummy_taxjar_client) + end + + describe "POST #retry" do + subject { post "/admin/orders/#{order.number}/taxjar_transaction/retry" } + + context "when the order has TaxJar order transactions" do + before do + order.taxjar_order_transactions << create( + :taxjar_order_transaction, + order: order, + transaction_id: order.number + ) + end + + let(:dummy_taxjar_order) { instance_double ::Taxjar::Order } + + it "replaces the latest order transaction" do + allow(::SuperGood::SolidusTaxjar.api) + .to receive(:show_latest_transaction_for) + .with(order) + .once + + allow(dummy_taxjar_client) + .to receive(:show_order) + .with(order.taxjar_order_transactions.first.transaction_id) + .and_return(instance_double ::Taxjar::Order, amount: "fake-amount") + + expect { subject } + .to have_enqueued_job(SuperGood::SolidusTaxjar::ReplaceTransactionJob) + .once + end + end + + context "when the order does not have TaxJar order transactions" do + it "reports the initial order transaction" do + expect { subject } + .to have_enqueued_job(SuperGood::SolidusTaxjar::ReportTransactionJob) + .once + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ab5126e6..af3f8b6f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,11 +9,13 @@ } require "solidus_dev_support/rspec/feature_helper" -require 'vcr' + +require "vcr" +require "selenium-webdriver" chrome_options = Selenium::WebDriver::Chrome::Options.new.tap do |options| options.add_argument("--window-size=#{CAPYBARA_WINDOW_SIZE.join(',')}") - options.add_argument("--headless") + options.add_argument("--headless") unless ENV["HEADED"] options.add_argument("--disable-gpu") end @@ -24,23 +26,13 @@ Capybara::Selenium::Driver.new(app, browser: :chrome, options_key => chrome_options) end -# This was pulled from `solidus_dev_support` and the glob was updated to allow -# for a deeper namespacing of our factories folder -# `lib/solidus_dev_support/testing_support/factories.rb`. -paths = ::SuperGoodSolidusTaxjar::Engine.root.glob('lib/**/testing_support/factories') - -FactoryBot.definition_file_paths = [ - Spree::TestingSupport::FactoryBot.definition_file_paths, - paths, -].flatten +SolidusDevSupport::TestingSupport::Factories.load_for(SuperGoodSolidusTaxjar::Engine) -FactoryBot.reload - -# Requires supporting ruby files with custom matchers and macros, etc, -# in spec/support/ and its subdirectories. -Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f } +require "support/solidus_events_helper" +require "support/checkoutable_store_shared_context" RSpec.configure do |config| + config.include SolidusEventsHelper config.infer_spec_type_from_file_location! config.use_transactional_fixtures = false @@ -57,12 +49,10 @@ config.ignore_localhost = true config.configure_rspec_metadata! config.hook_into :webmock - driver_urls = Webdrivers::Common.subclasses.map do |driver| - Addressable::URI.parse(driver.base_url).host - end config.ignore_hosts( "chromedriver.storage.googleapis.com", - *driver_urls + "googlechromelabs.github.io", + "edgedl.me.gvt1.com" ) config.filter_sensitive_data('') { |interaction| auths = interaction.request.headers['Authorization'].first diff --git a/spec/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber_spec.rb b/spec/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber_spec.rb index b5c22170..ad7bb942 100644 --- a/spec/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber_spec.rb +++ b/spec/subscribers/super_good/solidus_taxjar/spree/reporting_subscriber_spec.rb @@ -1,18 +1,10 @@ require "spec_helper" -RSpec.describe SuperGood::SolidusTaxjar::Spree::ReportingSubscriber do - # We only want to trigger the real event action behaviour as our spec - # `subject`s. - def with_events_disabled(&block) - allow(Spree::Event).to receive(:fire).and_return(nil) - - object = yield block - - allow(Spree::Event).to receive(:fire).and_call_original - - object - end - +# These tests will excercise either the `ReportingSubscriber` or the +# `LegacyReportingSubscriber` depending on the version of Solidus they are +# run against. The loading of the correct subscriber is handled by the +# initializer added by this extension's install generator. +RSpec.describe "ReportingSubscriber" do before do create(:taxjar_configuration, preferred_reporting_enabled_at_integer: reporting_enabled_at.to_i) end @@ -33,6 +25,10 @@ def with_events_disabled(&block) context "when the order is completed" do context "when the order has not been shipped" do + let(:order) { + with_events_disabled { create :completed_order_with_totals } + } + it "does nothing" do subject @@ -41,11 +37,7 @@ def with_events_disabled(&block) end context "when the order's payment state is 'credit_owed'" do - let(:order) { - with_events_disabled { - create(order_factory, payment_state: "credit_owed") - } - } + before { order.update(payment_state: "credit_owed") } it "does nothing" do subject @@ -124,9 +116,11 @@ def with_events_disabled(&block) end it "creates a sync log" do - expect { subject }.to change { order.taxjar_transaction_sync_logs.count }.from(0).to(1) + expect { subject }.to change { order.taxjar_transaction_sync_logs.count } + .from(0).to(1) expect(order.taxjar_transaction_sync_logs.last.status).to eq "error" - expect(order.taxjar_transaction_sync_logs.last.error_message).to include "Order cannot be synced because it was completed before TaxJar reporting was enabled" + expect(order.taxjar_transaction_sync_logs.last.error_message) + .to include "Order cannot be synced because it was completed before TaxJar reporting was enabled" end end end @@ -143,8 +137,7 @@ def with_events_disabled(&block) } end - - it "enqueue a job to refund and create a new transaction" do + it "enqueues a job to refund and create a new transaction" do assert_enqueued_with( job: SuperGood::SolidusTaxjar::ReplaceTransactionJob, args: [order] @@ -175,20 +168,13 @@ def with_events_disabled(&block) end context "when a TaxJar transaction does not exist on the order" do - it "does nothing" do - subject - - assert_no_enqueued_jobs - end - - it( - "creates a new transaction", - skip: "in the future, we would like to implement a 'create or update' flow" - ) do - expect { subject } - .to change { SuperGood::SolidusTax::OrderTransaction.count } - .from(0) - .to(1) + it "enqueues a job to report the transaction" do + assert_enqueued_with( + job: SuperGood::SolidusTaxjar::ReportTransactionJob, + args: [order] + ) do + subject + end end end end @@ -215,22 +201,12 @@ def with_events_disabled(&block) end end - describe "shipment_shipped is fired" do - subject do - SolidusSupport::LegacyEventCompat::Bus.publish( - :shipment_shipped, - shipment: shipment - ) - end + describe "shipment is shipped" do + subject { shipment.ship! } - before do - # Ignore other events that may be triggered by factories here. - allow(Spree::Event).to receive(:fire).with("order_recalculated") - end - - let(:shipment) { create(:shipment, state: 'ready', order: order) } + let(:shipment) { order.shipments.first } let(:order) { - with_events_disabled { create :completed_order_with_totals } + with_events_disabled { create :order_ready_to_ship } } let(:reporting) { instance_spy(::SuperGood::SolidusTaxjar::Reporting) } @@ -243,6 +219,11 @@ def with_events_disabled(&block) subject end end + + it "does not enqueue the replace transaction job" do + expect { subject } + .to_not have_enqueued_job(SuperGood::SolidusTaxjar::ReplaceTransactionJob) + end end context "when the order was completed before reporting was enabled" do @@ -263,21 +244,34 @@ def with_events_disabled(&block) SuperGood::SolidusTaxjar.exception_handler = original_handler end - it "doesn't queue to report the transaction" do - subject + it "doesn't queue job to report the transaction" do + expect { subject } + .to_not have_enqueued_job(SuperGood::SolidusTaxjar::ReportTransactionJob) + end - assert_no_enqueued_jobs + it "doesn't queue job to replace the transaction" do + expect { subject } + .to_not have_enqueued_job(SuperGood::SolidusTaxjar::ReplaceTransactionJob) end it "creates a sync log" do expect { subject }.to change { order.taxjar_transaction_sync_logs.count }.from(0).to(1) expect(order.taxjar_transaction_sync_logs.last.status).to eq "error" - expect(order.taxjar_transaction_sync_logs.last.error_message).to include "Order cannot be synced because it was completed before TaxJar reporting was enabled" + expect(order.taxjar_transaction_sync_logs.last.error_message) + .to include( + "Order cannot be synced because it was completed before " \ + "TaxJar reporting was enabled" + ) end it "calls the exception handler" do subject - expect(exception_handler).to have_received(:call).with(RuntimeError.new("Order cannot be synced because it was completed before TaxJar reporting was enabled")) + expect(exception_handler).to have_received(:call) + .with( + RuntimeError.new( + "Order cannot be synced because it was completed before TaxJar " \ + "reporting was enabled") + ) end end end diff --git a/spec/super_good/solidus_taxjar/api_params_spec.rb b/spec/super_good/solidus_taxjar/api_params_spec.rb index 81cc174c..2be1bb19 100644 --- a/spec/super_good/solidus_taxjar/api_params_spec.rb +++ b/spec/super_good/solidus_taxjar/api_params_spec.rb @@ -3,20 +3,22 @@ RSpec.describe SuperGood::SolidusTaxjar::ApiParams do let(:order) do create(:order, - additional_tax_total: BigDecimal("9.87"), - item_total: BigDecimal("28.00"), - line_items_attributes: [line_item_attributes], number: "R111222333", ship_address: ship_address, + line_items: line_items_attributes.map { |attributes| build(:line_item, attributes) }, store: store, - total: order_total, shipments: [shipment], user_id: 12345, completed_at: DateTime.new(2018, 3, 6, 12, 10, 33), - payment_total: payment_total) + payments: payments).tap do |order| + order.update_columns(additional_tax_total: 9.87, item_total: 28.00, total: order_total) + order.line_items.each_with_index do |line_item, idx| + line_item.update_columns(line_items_attributes[idx]) + end + end end let(:order_total) { BigDecimal("123.45") } - let(:payment_total) { BigDecimal("110.45") } + let(:payments) { build_list(:payment, 1, :completed, amount: 110.45) } let(:store) do create( @@ -50,15 +52,17 @@ ) end - let(:line_item_attributes) do - attributes_for( - :line_item, - additional_tax_total: 4, - price: 10, - promo_total: -2, - quantity: 3, - variant: variant - ) + let(:line_items_attributes) do + [ + attributes_for( + :line_item, + additional_tax_total: 4, + price: 10, + promo_total: -2, + quantity: 3, + variant_id: variant.id + ) + ] end let(:variant) do @@ -147,6 +151,8 @@ before do create :state, state_code: "CA" create :state, state_code: "NY" + + end describe ".order_params" do @@ -159,7 +165,7 @@ :adjustment, order: order, adjustable: order.line_items.first, - amount: line_item_attributes[:promo_total], + amount: line_items_attributes.first[:promo_total], source_type: "Spree::Promotion::Action::CreateItemAdjustments", label: "Promo", finalized: true # Prevents this adjustment from being recalculated. @@ -233,15 +239,17 @@ end context "when the line item has zero quantity" do - let(:line_item_attributes) do - attributes_for( - :line_item, - additional_tax_total: 4, - price: 10, - promo_total: -2, - quantity: 0, - variant: variant - ) + let(:line_items_attributes) do + [ + attributes_for( + :line_item, + additional_tax_total: 4, + price: 10, + promo_total: -2, + quantity: 0, + variant_id: variant.id + ) + ] end it "excludes the line item" do @@ -303,7 +311,7 @@ :adjustment, order: order, adjustable: order.line_items.first, - amount: line_item_attributes[:promo_total], + amount: line_items_attributes.first[:promo_total], source_type: "Spree::Promotion::Action::CreateItemAdjustments", label: "Promo", finalized: true # Prevents this adjustment from being recalculated. @@ -338,7 +346,7 @@ context "when the order is adjusted to 0" do let(:order_total) { BigDecimal("0") } - let(:payment_total) { BigDecimal("0") } + let(:payments) { [] } it "sends the order total as zero" do expect(subject[:amount]).to be_zero @@ -363,15 +371,17 @@ end context "when the line item has 0 quantity" do - let(:line_item_attributes) do - attributes_for( - :line_item, - additional_tax_total: 4, - price: 10, - promo_total: -2, - quantity: 0, - variant: variant - ) + let(:line_items_attributes) do + [ + attributes_for( + :line_item, + additional_tax_total: 4, + price: 10, + promo_total: -2, + quantity: 0, + variant_id: variant.id + ) + ] end it "excludes the line item" do @@ -403,6 +413,75 @@ expect(subject).to include(transaction_id: "R0123456789") end end + + context "when all line items have been returned and reimbursed" do + let(:reimbursement_total) { 10 } + let(:reimbursement_tax) { 1.02 } + + before do + reimbursement = create(:reimbursement) + reimbursement.return_items.first.update_columns(additional_tax_total: reimbursement_tax) + refund = create(:refund, reimbursement: reimbursement, payment: order.payments.first) + reimbursement.update_columns(order_id: order.id, total: reimbursement_total + reimbursement_tax) + order.line_items.first.inventory_units.update_all(state: "returned") + end + + it "excludes returned line items" do + expect(subject).to match(hash_including({ line_items: [] })) + end + + it "removes the reimbursed tax from the sales tax amount" do + expect(subject[:sales_tax]).to eq(9.87 - reimbursement_tax) + end + + it "removes the reimbursements without tax from the total amount" do + expect(subject[:amount]).to eq(100.58 - reimbursement_total) + end + end + + context "when some line items have been returned and reimbursed" do + let(:reimbursement_total) { 10 } + let(:reimbursement_tax) { 1.02 } + + before do + reimbursement = create(:reimbursement) + reimbursement.return_items.first.update_columns(additional_tax_total: reimbursement_tax) + refund = create(:refund, reimbursement: reimbursement, payment: order.payments.first) + reimbursement.update_columns(order_id: order.id, total: reimbursement_total + reimbursement_tax) + first_inventory_unit = order.line_items.first.inventory_units.first + first_inventory_unit.update(state: "returned") + return_item = create(:return_item, amount: 34, additional_tax_total: reimbursement_tax / 4) + return_item.update_columns(inventory_unit_id: first_inventory_unit.id, reimbursement_id: reimbursement.id) + end + + it "removes the reimbursed tax from the specific line item" do + expect(subject[:line_items].first[:sales_tax]).to eq(order.line_items.first.additional_tax_total - (reimbursement_tax / 4)) + end + end + + + context "when a refund without a reimbursement exists" do + let(:refund_amount) { 10 } + + before do + create(:refund, payment: order.payments.first, amount: refund_amount) + end + + it "removes the orphaned refunds from the total amount" do + expect(subject[:amount]).to eq(100.58 - refund_amount) + end + end + + context "part of a line item has been returned" do + before do + order.line_items.first.inventory_units.first.update(state: "returned") + order.line_items.first.inventory_units.second.update(state: "canceled") + end + + it "adjusts the line item quanity" do + expect(subject).to match(hash_including({ line_items: [hash_including({quantity:1})] })) + end + end end describe "#refund_params" do diff --git a/spec/super_good/solidus_taxjar/reportable_spec.rb b/spec/super_good/solidus_taxjar/reportable_spec.rb new file mode 100644 index 00000000..73cb0f3c --- /dev/null +++ b/spec/super_good/solidus_taxjar/reportable_spec.rb @@ -0,0 +1,194 @@ +require "spec_helper" + +RSpec.describe SuperGood::SolidusTaxjar::Reportable do + class ReportableTestClass + include SuperGood::SolidusTaxjar::Reportable + + def initialize(order) + @order = order + end + + def test_with_reportable + with_reportable(@order) do + return true + end + false + end + + def test_with_replaceable + with_replaceable(@order) do + return true + end + false + end + end + + let(:reportable_test_class) { ReportableTestClass.new(order) } + + describe "#with_reportable" do + subject { reportable_test_class.test_with_reportable } + + let!(:taxjar_configuration) { create(:taxjar_configuration, preferred_reporting_enabled_at_integer: nil) } + + let(:order) { create(:order) } + + it { is_expected.to be_falsey } + + context "when reporting is enabled" do + let!(:taxjar_configuration) { create(:taxjar_configuration, preferred_reporting_enabled_at_integer: 1.hour.ago) } + + it { is_expected.to be_falsey } + + context "is completed" do + let(:order) { create(:completed_order_with_totals) } + + it { is_expected.to be_falsey } + + context "is shipped" do + let(:order) { create(:shipped_order) } + + it { is_expected.to be_truthy } + + context "the order is not paid" do + before do + order.update_columns(payment_state: :balance_due) + end + + it { is_expected.to be_falsey } + end + + context "when the order has a failed transaction sync log and no order transactions" do + before do + create :transaction_sync_log, :error, order: order + end + + it { is_expected.to be_truthy } + end + + context "when the order has a failed transaction sync log, and an existing order transaction" do + before do + create :transaction_sync_log, :error, order: order + create :taxjar_order_transaction, order: order + end + + it { is_expected.to be_falsey } + end + + context "when the order was completed before reporting was enabled" do + before do + allow(SuperGood::SolidusTaxjar.exception_handler) + .to receive(:call) + + order.update_columns(completed_at: 2.days.ago) + end + + it { is_expected.to be_falsey } + + it "creates a sync log with an error" do + expect { subject } + .to change { order.taxjar_transaction_sync_logs.count } + .from(0) + .to(1) + + expect(order.taxjar_transaction_sync_logs.last).to have_attributes( + status: "error", + error_message: "Order cannot be synced because it was completed before TaxJar reporting was enabled" + ) + end + + it "calls the solidus taxjar exception handler with the error" do + subject + + expect(SuperGood::SolidusTaxjar.exception_handler) + .to have_received(:call) + .with(RuntimeError.new("Order cannot be synced because it was completed before TaxJar reporting was enabled")) + end + end + end + end + end + end + + describe "#with_replaceable" do + subject { reportable_test_class.test_with_replaceable } + + let!(:taxjar_configuration) { create(:taxjar_configuration, preferred_reporting_enabled_at_integer: nil) } + + let(:order) { create(:order) } + + it { is_expected.to be_falsey } + + context "when reporting is enabled and the order is completed and shipped" do + let!(:taxjar_configuration) { create(:taxjar_configuration, preferred_reporting_enabled_at_integer: 1.hour.ago) } + let(:order) do + order = create(:completed_order_with_pending_payment) + order.update_columns(shipment_state: :shipped) + order + end + let(:last_transaction_amount) { order.payment_total - order.additional_tax_total } + let(:dummy_api) { instance_double ::SuperGood::SolidusTaxjar::Api } + + before do + allow(dummy_api) + .to receive(:show_latest_transaction_for) + .and_return(double(amount: last_transaction_amount)) + allow(SuperGood::SolidusTaxjar) + .to receive(:api) + .and_return(dummy_api) + end + + it { is_expected.to be_falsey } + + context "when the order has a previous taxjar transaction" do + before do + create(:taxjar_order_transaction, order: order) + end + + it { is_expected.to be_falsey } + + context "when the order is paid" do + let(:order) { create :shipped_order } + + it { is_expected.to be_falsey } + + context "when the order's amount has changed" do + let(:last_transaction_amount) { order.payment_total - 12 } + + it { is_expected.to be_truthy } + + context "when the order was completed before reporting was enabled" do + before do + allow(SuperGood::SolidusTaxjar.exception_handler) + .to receive(:call) + + order.update_columns(completed_at: 2.days.ago) + end + + it { is_expected.to be_falsey } + + it "creates a sync log with an error" do + expect { subject } + .to change { order.taxjar_transaction_sync_logs.count } + .from(0) + .to(1) + + expect(order.taxjar_transaction_sync_logs.last).to have_attributes( + status: "error", + error_message: "Order cannot be synced because it was completed before TaxJar reporting was enabled" + ) + end + + it "calls the solidus taxjar exception handler with the error" do + subject + + expect(SuperGood::SolidusTaxjar.exception_handler) + .to have_received(:call) + .with(RuntimeError.new("Order cannot be synced because it was completed before TaxJar reporting was enabled")) + end + end + end + end + end + end + end +end diff --git a/spec/support/checkoutable_store_shared_context.rb b/spec/support/checkoutable_store_shared_context.rb new file mode 100644 index 00000000..7830bea1 --- /dev/null +++ b/spec/support/checkoutable_store_shared_context.rb @@ -0,0 +1,19 @@ +# Set up some data that a store needs to work and be realistic. +# +RSpec.shared_context "checkoutable store" do + let!(:default_store) { create :store, default: true } + let!(:taxjar_configuration) { + create :taxjar_configuration, :reporting_enabled + } + + let!(:california) { + create :state, + country: create(:country, states_required: true), + state_code: "CA" + } + + let!(:check_payment_method) { create :check_payment_method } + let!(:shipping_method) { create :shipping_method } + let!(:stock_location) { create :stock_location } + let!(:zone) { create :zone } +end diff --git a/spec/support/solidus_events_helper.rb b/spec/support/solidus_events_helper.rb new file mode 100644 index 00000000..4128b84e --- /dev/null +++ b/spec/support/solidus_events_helper.rb @@ -0,0 +1,26 @@ +module SolidusEventsHelper + # We can use this helper method to ensure that events are not run until after + # the test setup has been completed. This helps us more easily test side + # effects from events or control unintended side effects when attempting to + # test functionality that is not event-driven but would otherwise emit events. + # + # @yield Any test setup you'd like to run without events being emitted. + # @return The return value of the test setup in your block. + def with_events_disabled(&block) + if SolidusSupport::LegacyEventCompat.using_legacy? + allow(Spree::Event).to receive(:fire).and_return(nil) + else + allow(Spree::Bus).to receive(:publish).and_return(nil) + end + + object = yield block + + if SolidusSupport::LegacyEventCompat.using_legacy? + allow(Spree::Event).to receive(:fire).and_call_original + else + allow(Spree::Bus).to receive(:publish).and_call_original + end + + object + end +end
Log IDOrderTaxJar Transaction IDStatusError MessageCreated atUpdated atOrderTxn IDRefund Txn IDStatusErrorCreated atUpdated at
<%= log.id %> <%= link_to log.order.number, spree.edit_admin_order_path(log.order) %> <%= log.order_transaction&.transaction_id || "-" %><%= log.refund_transaction&.transaction_id || "-" %> <%= log.status.capitalize %> <%= log.error_message %> <%= log.created_at %> <%= log.updated_at %> + <% # If the latest log is an error show a retry. %> + <% if log.error? && transaction_sync_logs.count == index %> + <%= link_to_with_icon('repeat', "Retry", admin_order_taxjar_transaction_retry_path(log.order), {method: :post}) %> + <% end %> +