5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/purchase_kit/webhooks_controller.rb', line 5
def create
event = verified_event
event_type = event[:type].to_s.tr(".", "_").to_sym
PurchaseKit::Events.publish(event_type, event)
PurchaseKit.queue_pay_webhook(event) if PurchaseKit.pay_enabled?
head :ok
rescue JSON::ParserError => e
Rails.logger.error "[PurchaseKit] Invalid JSON in webhook: #{e.message}"
head :bad_request
rescue PurchaseKit::SignatureVerificationError => e
Rails.logger.error "[PurchaseKit] Webhook signature error: #{e.message}"
head :bad_request
end
|