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