7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/stripe_webhooks/events_controller.rb', line 7
def create
begin
raw_data = JSON.parse(request.body.read)
rescue JSON::ParserError => e
render :text => e.message, :status => 400
return
end
@event = StripeWebhooks::Event.find_or_initialize_by(:stripe_event_id => raw_data['id'])
if @event.save()
StripeWebhooks::ProcessorJob.perform_later(@event)
render :nothing => true, :status => 200
else
render :text => @event.errors.full_messages.first, :status => 422
end
end
|