From 392b27563a9b2aa4063112d733311d9f163757d4 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 28 Jul 2016 07:55:20 -0400 Subject: [PATCH] Webhooks --- app/controllers/qbo_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/qbo_controller.rb b/app/controllers/qbo_controller.rb index 3f0cd48..676a7ce 100644 --- a/app/controllers/qbo_controller.rb +++ b/app/controllers/qbo_controller.rb @@ -64,12 +64,15 @@ class QboController < ApplicationController # Quickbooks Webhook Callback def qbo_webhook - # If the body contains the event notifications parameter... - if params[:eventNotifications].present? - # Process the entities - #TODO stuff + if request.headers['Content-Type'] == 'application/json' + data = JSON.parse(request.body.read) + else + # application/x-www-form-urlencoded + data = params.as_json end + entities = data[0]['eventNotifications'][0]['dataChangeEvent']['entities'] + # The webhook doesn't require a response but let's make sure # we don't send anything render :nothing => true