Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Chargify Webhook Reflector. Sinatra app I use in dev to get warm fuzzies as the webhooks fly by. Since Chargify will only post to ports 80 or 443 in production, you'll need to run this on a web accessible box on one of those ports.
require 'sinatra'
require 'openssl'
require 'json'
post '/' do
body =
puts "Time : #{}"
puts "Actual Signature : #{request.env['HTTP_X_CHARGIFY_WEBHOOK_SIGNATURE_HMAC_SHA_256']}"
puts "Computed Signature: #{signature(body)}"
puts "Raw Body"
puts "--------"
puts body
puts "-----------------------------------------------------------------------------"
puts ""
puts "JSON"
puts "----"
puts JSON.pretty_generate(params)
puts "-----------------------------------------------------------------------------"
puts ""
def shared_key
"your Site shared key"
def signature(body)
OpenSSL::HMAC.hexdigest('sha256'), shared_key, body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.