Sha256: 6799fe7c52ce18cfb585da373fc190ac9bcb187fee5162b496514fc55e227a2a

Contents?: true

Size: 525 Bytes

Versions: 2

Compression:

Stored size: 525 Bytes

Contents

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

  def create
    Chargify::Loops.delegate_hook params[:event].to_sym,
      params[:payload].stringify_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

2 entries across 2 versions & 1 rubygems

Version Path
chargify-loops-0.3.0 app/controllers/chargify/hooks_controller.rb
chargify-loops-0.2.0 app/controllers/chargify/hooks_controller.rb