Skip to content

Commit

Permalink
Add LemonSqueezy webhook metadata to objects Fixes #1107
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Nov 26, 2024
1 parent 937b85b commit 822b5f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/pay/lemon_squeezy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def self.construct_from_webhook_event(event)
"subscription-invoices" => ::LemonSqueezy::SubscriptionInvoice
}.fetch(data["type"])

type.new(data)
object = type.new(data)
object.meta = event["meta"]
object
end
end

Expand Down
6 changes: 6 additions & 0 deletions test/pay/lemon_squeezy/webhooks_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
require "test_helper"

class Pay::LemonSqueezy::WebhooksTest < ActiveSupport::TestCase
test "lemon squeezy webhook metadata" do
object = Pay::LemonSqueezy.construct_from_webhook_event json_fixture("lemon_squeezy/order_created")
assert_equal ::LemonSqueezy::Order, object.class
assert_equal {"event_name" => "order_created"}, object.meta
end

test "lemon squeezy order_created webhook" do
json = json_fixture("lemon_squeezy/order_created")
event = Pay::Webhook.new(processor: :lemon_squeezy, event: json).rehydrated_event
Expand Down

0 comments on commit 822b5f4

Please sign in to comment.