summaryrefslogtreecommitdiff
path: root/lib/super_good/solidus_taxjar
diff options
context:
space:
mode:
Diffstat (limited to 'lib/super_good/solidus_taxjar')
-rw-r--r--lib/super_good/solidus_taxjar/api.rb4
-rw-r--r--lib/super_good/solidus_taxjar/api_params.rb12
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb
index d52a4a4..301fba4 100644
--- a/lib/super_good/solidus_taxjar/api.rb
+++ b/lib/super_good/solidus_taxjar/api.rb
@@ -20,6 +20,10 @@ module SuperGood
taxjar_client.rates_for_location(*APIParams.address_params(address))
end
+ def create_transaction_for(order)
+ taxjar_client.create_order APIParams.transaction_params(order)
+ end
+
private
attr_reader :taxjar_client
diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb
index 4e61253..f75713c 100644
--- a/lib/super_good/solidus_taxjar/api_params.rb
+++ b/lib/super_good/solidus_taxjar/api_params.rb
@@ -21,6 +21,18 @@ module SuperGood
]
end
+ def transaction_params(order)
+ {}
+ .merge(order_address_params(order.tax_address))
+ .merge(
+ transaction_id: order.number,
+ transaction_date: order.completed_at.to_formatted_s(:iso8601),
+ amount: order.total - order.additional_tax_total,
+ shipping: order.shipment_total,
+ sales_tax: order.additional_tax_total
+ )
+ end
+
private
def order_address_params(address)