From d99453601762c58885a19c0365b1d9252f89405b Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sun, 27 Apr 2014 17:27:53 -0700 Subject: [PATCH] initial test for figuring out the stripe webhook --- app.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app.rb b/app.rb index 0ebe6760..1eaa211d 100644 --- a/app.rb +++ b/app.rb @@ -12,9 +12,11 @@ use Rack::Recaptcha, public_key: $config['recaptcha_public_key'], private_key: $ helpers Rack::Recaptcha::Helpers before do - if request.path.match(/^\/api\//i) + if request.path.match /^\/api\//i @api = true content_type :json + elsif request.path.match /^\/stripe_webhook$/ + # Skips the CSRF check for stripe web hooks else content_type :html, 'charset' => 'utf-8' redirect '/' if request.post? && !csrf_safe? @@ -705,6 +707,11 @@ post '/contact' do end end +post '/stripe_webhook' do + event_json = JSON.parse(request.body.read) + puts event_json.inspect +end + post '/api/upload' do require_api_credentials