Integrate QuickBooks Desktop with Ruby on Rails

Processing QB Responses

Let's pretend we're writing a background job that's handling our initial customer import request. We'll need to process the response from QuickBooks and store the customers in our database.

class ImportQuickbooksCustomersJob < ApplicationJob
  queue_as :default

  def perform(webhook_data)
    quickbooks_request = QuickbooksRequest.find_by(qube_id: webhook_data[:id])
    connection = quickbooks_request.qube_connection
    customers_data = parse_customers(webhook_data[:response_json])

    # It's a good idea to scope QB records to a specific connection
    # so we don't have to worry about conflicts when they share the same ListID,
    # change QB company files, etc.
    connection.quickbooks_customers.create!(customers)
  end

  private

  def parse_customers(response_json)
    # There can be multiple requests / responses per 
    # qbxml request with QuickBooks, so the response_json
    #  will be an array of hashes. In this case, 
    # we expect only one response.
    response_json.first.fetch("data")
  end  
end

Next Steps

That's it! Maybe check out the demo application for further implementation ideas. If you have any questions or need help, feel free to reach out to support@qubesync.com.