Module: WebhookInbox::Receiver

Extended by:
ActiveSupport::Concern
Defined in:
lib/webhook_inbox/receiver.rb

Instance Method Summary collapse

Instance Method Details

#receive_webhook!Object

Run the full receive pipeline:

1. Verify provider signature (401 on failure)
2. Store event in DB (200 silent on duplicate)
3. Enqueue ProcessJob
4. Respond 200 OK


27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/webhook_inbox/receiver.rb', line 27

def receive_webhook!
  provider_name = self.class._webhook_provider
  raise "No provider declared. Call receive_from :stripe, secret: -> { ... }" unless provider_name

  adapter  = WebhookInbox.provider_for(provider_name)
  secret   = self.class._webhook_secret_resolver.call
  raw_body = read_request_body

  verify_signature!(adapter, raw_body, secret) || return
  store_and_process(adapter, raw_body, provider_name) || return

  head :ok
end