Module: SuperGood::SolidusTaxjar::Spree::LegacyReportingSubscriber

Includes:
SolidusSupport::LegacyEventCompat::Subscriber, Spree::Event::Subscriber, Reportable
Defined in:
lib/super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb

Constant Summary collapse

DELAY =

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.
2

Constants included from Reportable

Reportable::ORDER_TOO_OLD_MESSAGE

Instance Method Summary collapse

Methods included from Reportable

included, #order_reportable?, #transaction_replaceable?, #with_replaceable, #with_reportable

Instance Method Details

#report_or_replace_transaction(event) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb', line 21

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