Hi folks! We’re attempting to send a POST request ...
# support
w
Hi folks! We’re attempting to send a POST request to an external API whenever the
order_finalized
event is emitted however, it appears that our event handler is being ignored. Our current setup is a simple 1 line event handler that invokes an ActiveJob which then performs the POST request. We followed the Solidus docs on “Subscribing to Events” and took inspiration from the solidus_subscriptions gem. Our app is hosted on Google Cloud Run with CPU always allocated. In our GCP logs, we do see evidence of other event handlers being executed, such as
SolidusSubscriptions::CreateSubscriptionJob
which is executed on
order_finalized
, however, zero logs appear for ours. Initially, we thought that it might be the serverless environment that is preventing the event handler from executing but seeing
SolidusSubscriptions::CreateSubscriptionJob
running and succeeding, I don’t believe this is the case. Any insight or suggestions would be greatly appreciated. Here are some snippets:
/config/initializers/omnes.rb
Copy code
Rails.application.config.to_prepare do
  TestStore::OrderFinalized.new.subscribe_to(Spree::Bus)
end
/app/subscribers/test_store/order_finalized.rb
Copy code
module TestStore
  class OrderFinalized
    include Omnes::Subscriber

    handle :order_finalized,
            with: :notify_order_completed,
            id: :solidus_prod_func_order_completed

    def notify_order_completed(event, context) 
      TestStore::NotifyOrderCompletedJob.perform_later(event.payload[:order])
    end
  end
end
/app/jobs/test_store/notify_order_completed_job.rb
Copy code
module TestStore
  class NotifyOrderCompletedJob < ApplicationJob
    queue_as :default

    def perform(order)
      handler = "API URL"
      options = {
        body: {
          order: order.to_json
        }
      }

      puts "Sending order to #{handler}"
      <http://HTTParty.post|HTTParty.post>(handler, options)
    end
  end
end
j
is it working locally?