At Zao, one of our passions is building modular tools that solve client problems, and (our favorite part) releasing them to the public.
We were tasked with integrating QuickBooks Online with WooCommerce for one of our super rad clients, Brooklyn Tweed. Specifically, Brooklyn Tweed needed to be able to create QuickBooks invoices every time a manual wholesale order is generated (sidenote: If you’re familiar with WooCommerce, you know there is no such thing as a manual wholesale order [yet], but stay tuned for a future blog post and plugin release).
Naturally, the first step was to look for a WooCommerce/QuickBooks plugin. It might surprise you, as it did me, to find that there is not much available. Sure, there are a few SAAS options available, but nothing looked quite plug and play for what our client needed and wanted.
So, the next step was to look for a WordPress QuickBooks plugin. I found what looked like a perfect fit, only to be met by the requirement for a “Cartpipe account,” which looked to be another SAAS solution. I checked it out anyway, only to be met with:
As any good developer would do, I continued the hunt for existing tools that we could commandeer for our purposes. Fortunately, Intuit has a ton of developer documentation and resources.
Note: At this point, I should warn you that we are about to talk about OAuth. Consider this your warning.
Unfortunately, they also have a ton of their old docs and deprecated information documented, so my initial google search got me on the OAuth 1.0a path. Previously, we built this tool/library for connecting to the REST API for WordPress via OAuth 1.0a, along with a UI wrapper, so I went about forking it and attempting to use the plugin’s existing OAuth 1.0a architecture for connecting to the QuickBooks developer app. This process was… not pleasant (hint: it never is!). I eventually discovered that much of the agony in this case was self-inflicted. I was
_doing_it_wrong by using OAuth 1:
If your developer account has not created any apps until after July 17, 2017, all apps created by that account will use OAuth 2.0. (source)
So back to square one…or is it two? Thankfully, OAuth 2.0 is a bit simpler in application (no signature keys, sigh of relief), and Intuit provided this OAuth2 sample app. It wasn’t long before I had converted the tool to use OAuth 2.0 and updated the UI to reflect the change, where applicable.
Why do we do this?
Much like with the WP API Connect tool (and others), we prefer to build these things in a way that they can be decoupled and used across multiple projects, and most importantly (to us), open-sourced. If you’ve ever had to rip the guts of something out of an existing project and re-apply it to another one, you know the agony I’m talking about. Building things this way selfishly helps me out, because I can use the same low-level tool in many ways, but can also help the broader community.
Here are a few examples:
- QuickBooks Online Connect is a low-level library for making an authenticated connection to a QuickBooks Online account.
- QuickBooks Online Connect UI adds a UI to that library so you can connect to your QuickBooks developer client app from your WordPress dashboard.
- Zao WooCommerce QuickBooks Online Integration Uses that Connection UI and the underlying library to allow us to integrate and import QuickBooks objects into WordPress/WooCommerce (this is in progress… use at your own risk).
- WP API Connect is a low-level library for making an authenticated connection between two WordPress instances, using the OAuth plugin.
- WP API Connect UI adds a UI to that library so you can set up that connection from your WordPress dashboard.
- [redacted] is a custom client plugin that allows the client to have a publication workflow on a completely separate WordPress install and selectively publish vetted/completed content to the public site. It uses the Connect plugin to make authenticated requests, and the UI plugin to establish that authenticated connection.
- TwitterWP again, is a low-level library for making authenticated requests to the Twitter API.
- WDS Twitter Widget is, as expected, a widget which outputs recent tweets which relies on TwitterWP.
- And DsgnWrks Twitter Importer is an automatic tweet importer built with TwitterWP used for backing up or archiving your tweets.
And the list goes on!
CMB2 is another perfect example of a modular tool that is being used all over the place and bundled into many projects (including the above QuickBooks Online Connect UI and WP API Connect UI plugins!).
Yet another (possibly overlooked) benefit to releasing your modular tools, is the continual contribution and improvement by others in the broader community. The Intuit Quickbooks PHP SDK that we worked with for this project is an open source project (and on GitHub), so we were able offer some improvements to their library with two small Pull Requests. The benefits to releasing your tools often goes both directions.
When you can put the effort in to make a tool or library available modularly, it can provide a huge head-start to your future self, and even better for many others in the community.
If you need more information for how to use this stuff, look at this example file. If you’re interested in more things Zao has released/worked on in the spirit of sharing and modular development, check out these posts:
- View PDFs in Your WordPress Site with Zao PDF Viewer
- A Healthier Option Helps WordPress Users Improve the Options Table
- Zao Mock API: A WordPress Plugin for Testing API Responses
- Zao Adopts Asset Queue Manager
- CMB2 Grows: Where Human Made, Zao, and WebDevStudios Meet
- Zao Client Spotlight: Our Collaboration with Qpractice