Skip to content

Instantly share code, notes, and snippets.

@swalberg
Created November 20, 2011 20:05
Show Gist options
  • Save swalberg/1380806 to your computer and use it in GitHub Desktop.
Save swalberg/1380806 to your computer and use it in GitHub Desktop.
app/controllers/webhooks/versapay_controller.rb:
class Webhooks::VersapayController < ApplicationController
check_versapay_signatures VERSAPAYSIGNINGKEY
...
end
from gem:
class ActionController::Base
def self.check_versapay_signatures(key, *args)
before_filter lambda { |controller| check_versapay_signature(key, controller)}, *args
# before_filter lambda { |controller| ActionController::Base.check_versapay_signature(key, controller)}, *args
end
def self.check_versapay_signature(key, controller)
...
if all_is_good
true
else
raise Versapay::InvalidWebhookSignature
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment