11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/models/stripe/event_dispatch.rb', line 11
def retrieve_stripe_event(request)
id = request['id']
body = request.body.read
= request.['HTTP_STRIPE_SIGNATURE']
endpoint_secret = ::Rails.application.config.stripe.signing_secret
if id == 'evt_00000000000000'
event = Stripe::Event.construct_from(JSON.parse(body))
elsif Object.const_defined?('Stripe::Webhook') && && endpoint_secret
event = ::Stripe::Webhook.construct_event(body, , endpoint_secret)
else
event = Stripe::Event.retrieve(id)
end
yield event
end
|