From 707db65108006f06a34fee95ed507b0ae855ef57 Mon Sep 17 00:00:00 2001 From: Jared Norman Date: Tue, 25 Jun 2019 14:48:34 -0700 Subject: Add logging This will log the params sent to and responses received from TaxJar in order to facilitate debugging production issues. --- lib/super_good/solidus_taxjar/api.rb | 8 +++++++- lib/super_good/solidus_taxjar/api_params.rb | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/super_good') diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb index 7309a64..0d182ce 100644 --- a/lib/super_good/solidus_taxjar/api.rb +++ b/lib/super_good/solidus_taxjar/api.rb @@ -13,7 +13,13 @@ module SuperGood end def tax_for(order) - taxjar_client.tax_for_order APIParams.order_params(order) + taxjar_client.tax_for_order(APIParams.order_params(order)).tap do |taxes| + next unless SuperGood::SolidusTaxJar.logging_enabled + + Rails.logger.info( + "TaxJar response for #{order.number}: #{taxes.to_h.inspect}" + ) + end end def tax_rates_for(address) diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb index 7c6942f..5412232 100644 --- a/lib/super_good/solidus_taxjar/api_params.rb +++ b/lib/super_good/solidus_taxjar/api_params.rb @@ -8,6 +8,13 @@ module SuperGood .merge(order_address_params(order.tax_address)) .merge(line_items_params(order.line_items)) .merge(shipping: order.shipment_total) + .tap do |params| + next unless SuperGood::SolidusTaxJar.logging_enabled + + Rails.logger.info( + "TaxJar params: #{params.inspect}" + ) + end end def address_params(address) -- cgit v1.2.3