Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Forward the event's signature in the HandleRequest
Stefan Vermaas7861641684fd
diff --git a/api/app/services/spree/webhooks/subscribers/handle_request.rb b/api/app/services/spree/webhooks/subscribers/handle_request.rbindex 59a7a58c9f..6d38e334e4 100644--- a/api/app/services/spree/webhooks/subscribers/handle_request.rb+++ b/api/app/services/spree/webhooks/subscribers/handle_request.rb@@ -39,7 +39,11 @@ module Spreedef request@request ||=- Spree::Webhooks::Subscribers::MakeRequest.new(webhook_payload_body: body_with_event_metadata, url: url)+ Spree::Webhooks::Subscribers::MakeRequest.new(+ signature: event.signature_for(body_with_event_metadata),+ url: url,+ webhook_payload_body: body_with_event_metadata+ )endalias make_request requestdiff --git a/api/spec/services/spree/webhooks/subscribers/handle_request_spec.rb b/api/spec/services/spree/webhooks/subscribers/handle_request_spec.rbindex be38c99239..503ec3426c 100644--- a/api/spec/services/spree/webhooks/subscribers/handle_request_spec.rb+++ b/api/spec/services/spree/webhooks/subscribers/handle_request_spec.rb@@ -35,6 +35,10 @@ describe Spree::Webhooks::Subscribers::HandleRequest do).to_jsonend+ let(:event_signature) do+ Spree::Webhooks::EventSignature.new(event, body_with_event_metadata).computed_signature+ end+it 'debug logs' doallow(Rails.logger).to receive(:debug)allow(Spree::Webhooks::Subscribers::MakeRequest).to receive(:new).and_call_original@@ -43,9 +47,14 @@ describe Spree::Webhooks::Subscribers::HandleRequest domessage_snd = "[SPREE WEBHOOKS] 'order.canceled' webhook_payload_body: #{body_with_event_metadata}"expect(Rails.logger).to have_received(:debug).with(message_fst)expect(Rails.logger).to have_received(:debug).with(message_snd)- expect(Spree::Webhooks::Subscribers::MakeRequest).to(- have_received(:new).with(webhook_payload_body: body_with_event_metadata, url: url)- )++ expect(Spree::Webhooks::Subscribers::MakeRequest).to \+ have_received(:new).+ with(+ signature: event_signature,+ url: url,+ webhook_payload_body: body_with_event_metadata+ )endit "#{with_log_level} logs" do@@ -171,13 +180,21 @@ describe Spree::Webhooks::Subscribers::HandleRequest do).to_jsonend+ let(:event_signature) do+ Spree::Webhooks::EventSignature.new(event, body_with_event_metadata).computed_signature+ end+it 'adds the event data to the body' dowith_webhooks_enabled doallow(Spree::Webhooks::Subscribers::MakeRequest).to receive(:new).and_call_originalorder.finalize!- expect(Spree::Webhooks::Subscribers::MakeRequest).to(- have_received(:new).with(webhook_payload_body: body_with_event_metadata, url: url)- )+ expect(Spree::Webhooks::Subscribers::MakeRequest).to \+ have_received(:new).+ with(+ signature: event_signature,+ url: url,+ webhook_payload_body: body_with_event_metadata+ )endendend