Skip to content

Commit 51e8e32

Browse files
Fix event refresh (#1617)
1 parent 6553855 commit 51e8e32

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/stripe/webhook.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def self.construct_event(payload, sig_header, secret,
1818
# doesn't GC symbols. It also decreases the likelihood that we receive a
1919
# bad payload that fails to parse and throws an exception.
2020
data = JSON.parse(payload, symbolize_names: true)
21-
Event.construct_from(data, {}, nil, :v1)
21+
Event.construct_from(data, {}, nil, :v1, APIRequestor.active_requestor)
2222
end
2323

2424
module Signature

test/stripe/webhook_test.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ class WebhookTest < Test::Unit::TestCase
6363
Stripe::Webhook.construct_event(EVENT_PAYLOAD, header, Test::WebhookHelpers::SECRET)
6464
end
6565
end
66+
67+
should "can call refresh on Event data object" do
68+
payload = {
69+
"id": "evt_123",
70+
"object": "event",
71+
"data": {
72+
"object": {
73+
"id": "cus_123",
74+
"object": "customer",
75+
}
76+
}
77+
}.to_json
78+
79+
header = Test::WebhookHelpers.generate_header(payload: payload)
80+
event = Stripe::Webhook.construct_event(payload, header, Test::WebhookHelpers::SECRET)
81+
assert event.is_a?(Stripe::Event)
82+
83+
event.data.object.refresh
84+
assert_equal("cus_123", event.data.object.id)
85+
end
6686
end
6787

6888
context ".verify_signature_header" do

0 commit comments

Comments
 (0)