Friday, December 28, 2007

A Quick Books integration

A few days ago I set about trying to figure out how we're going to add Quickbooks integration functionality to WorkXpress, and today I had my first bit of success.

I've found that the tricky part of developing an "Integration" is almost always figuring out what the other side has to offer. What does *their* API look like? How do I connect to their systems? What 128,000,000,000 bit keys do I need to access their systems, and where do I get them? Now that I have one.. where do I put it?!? It goes on and on.

So what's the first step? Making a Connection to the third party, in an elementary way.

The trouble with Quickbooks is that it's on it's 7th SDK revision. So, the net is covered in a sea of integration examples from all different revisions of Quickbooks connectivity; and I had trouble even figuring out which one would work with the version of quickbooks the client wants to use.

In the end, it was QuickBooks Enterprise 2007, which meant SDK 7.0. This version of QuickBooks uses the "Web Connector", or QBWC.

The Web Connectors role in allowing Quickbooks to be exposed is quite cool.

Quickbooks, as you know, is a "standalone desktop app". Which is tech speak for "a program you install, in Windows, that just works." So, how does a developer connect to this kind of application? Through the web connector!

The QBWC is another desktop app that you install on the computer with the QuickBooks company file. These three things (an install of QuickBooks, QuickBooks Web Connector, and the Company File you want to access) all live on one Windows machine, that becomes the "QuickBooks Server", or the computer with Windows that is always running that always has this quickbooks file open in QB, and the QBWC always running.

Once I got the QBWC running, it was time to tell it about my application; IE : LET ME IN! It turns out, instead of providing access to Quickbooks directly, this little gems job is to make SOAP calls out to another server, retrieve work to do, do the work with QBooks, and return the results from the requested work, via SOAP.

So you don't make "Calls" to Quickbooks really, what you do is you queue up work for Quickbooks to do the next time it connects, which QBWC controls the frequency of.

You provide QBWC with a username and password to give back to you to authenticate itself, and you have to implement authenticate for your own UName/PW. There's a series of simple calls that the QBWC makes to get its work, and report back it's progress/completion/response.

Instead of reinventing the wheel on this side, I found a PHP Framework for Quickbooks on the Intuit Developers Blog, developed by Keith Palmer. Keith went ahead and wrote a MySQL Driven, PHP supported Soap Server that handles receiving communication from QBWC, queueing up tasks to send to QBWC, and sending them when they are requested.

All you have to do is figure out how you want to store your data for the queue, and implement request and response functions which are the interface between your app (the one making the request)... and your app (the one that you need to effect when there is a response).

So, he's gone ahead and ripped out all of the tough stuff, and left us with simple implementation, based on what WE need to tell, and listen to, from Quickbooks. Thanks Keith!

So.. I modified his examples a little bit, and built myself a page, that queues up an Add Customer request, that will add me, myself and I to the QuickBooks File when the QBWC asks for work.

Now that I have the simple implementation working, it's time to move on to what the customer actually wants :-) And, all the while, trying to figure out an elegant way to allow an Implementer to simply create an action, answer some questions, and BOOM, pull data from their QuickBooks installation.

Chances are pretty good, since we're under the time (as usual) on this project, that I will just implement exactly what's needed for this customer, and worry about circling back and implementing something elegant later. Once we have one customer integrated with Quickbooks, we can setup similar integrations for any other customer.

No comments: