Sha256: 222a349c233332721fd44644f7e83d16085eed0f0414b9be9ced52c665cc040c

Contents?: true

Size: 524 Bytes

Versions: 1

Compression:

Stored size: 524 Bytes

Contents

class Chargify::HooksController < ActionController::Base
  before_filter :verify_signature

  def create
    Chargify::Loops.delegate_hook params[:event].to_sym,
      params[:payload].symbolize_keys

    head :ok
  end

  private

  def generated_signature
    Digest::MD5.hexdigest(Chargify::Loops.shared_key + request.raw_post)
  end

  def provided_signature
    request.headers['X-Chargify-Webhook-Signature']
  end

  def verify_signature
    head :forbidden unless generated_signature == provided_signature
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chargify-loops-0.1.0 app/controllers/chargify/hooks_controller.rb