Simple integration with the Quickbooks Online API (not intended for Desktop versions). Quickbooks Online is a leading business accounting solution. Using this module requires a Quickbooks Online account of your own. Quickbooks Online is a product of Intuit.

Dependencies

  • Libraries API
  • Quickbooks Online API SDK (see installation instructions)

Installation

  1. Download the Quickbooks Online API SDK from here. Add it to your libraries directory (ie, sites/all/libraries/qbo).
  2. It's recommended that you comment out the file_put_contents() call in /Diagnostics/Logger.php in the SDK. You can also remove the large _Phpdocs directory.
  3. Download and install this module.
  4. Navigate to the admin settings page at admin/config/services/qbo.
  5. Follow the help instructions to connect Drupal to your Quickbooks Online account.
  6. If you want node or user based connections, enable one or more of the sub-modules included in this package.
  7. Set user permissions accordingly.

Using the API

Upgrading from 7.x-1.x to 7.x-2.x

7.x-2.x was a complete rewrite and if you have custom code that is meant to be used with 7.x-1.x, it will need to be updated to work. Please review the examples below.

The biggest change in 2.x is that QBO connections are now contextual (global, node, user, etc). It is also possible to implement your own context.

Initializing a client
// A site-wide connection (as configured in the admin settings).
$qbo = new QBO();

// A node-based connection. Requires qbo_api_node be enabled.
$qbo = new QBO('QBOContextNode', array('nid' => $node->nid));

// A user-based connection. Requires qbo_api_user be enabled.
$qbo = new QBO('QBOContextUser', array('uid' => $user->uid));
Perform a query
$items = $qbo->query("SELECT Id, Name FROM Item WHERE Id > '5'");
$accounts = $qbo->query("SELECT Id, Name, AccountType, Classification FROM Account");
Load an object
$entry = $qbo->getObject('JournalEntry', 214);
$receipt = $qbo->getObject('SalesReceipt', 883);
Delete an object
try {
  $entry = $qbo->getObject('JournalEntry', 32);
  $response = $qbo->dataService()->Delete($entry);
}
catch (Exception $e) {
  // The operation failed..
}
Create an object
$receipt = new IPPSalesReceipt();
$receipt->PaymentRefNum = 'Order#314';
$receipt->TxnDate = format_date(REQUEST_TIME, 'custom', 'Y-m-d');
$receipt->PrivateNote = t('My store order #314');
$receipt->ApplyTaxAfterDiscount = 1;
$receipt->DepositToAccountRef = 21;
$receipt->TxnTaxDetail = new IPPTxnTaxDetail();
$receipt->TxnTaxDetail->TxnTaxCodeRef = 9;
$receipt->Line = array();
$receipt_line = new IPPLine();
$receipt_line->DetailType = 'SalesItemLineDetail';
$receipt_line->Amount = 415.61; 
$receipt_line->SalesItemLineDetail = new IPPSalesItemLineDetail();
$receipt_line->SalesItemLineDetail->ItemRef = 31;
$receipt_line->SalesItemLineDetail->Qty = 2;
$receipt_line->SalesItemLineDetail->UnitPrice = 64.55;
$receipt_line->SalesItemLineDetail->TaxCodeRef = 'TAX';
$receipt->Line[] = $receipt_line;

try {
  $receipt = $qbo->dataService()->Add($receipt);
}
catch (Exception $e) {
  // The operation failed..
}

More information

Reference the API documentation online or view the API examples inside the SDK within the _Samples directory. Any API function can be executed via $qbo->dataService()->nameOfFunction().

Creating a connection context

This module (and sub-modules) provides three contexts for different QBO connections: global connection, per-user connections, and per-node connections. If you want to add a context of your own, check the qbo_api_node sub-module for an example on how to implement the QBOContext abstract class.

Notes

This module provides no user interface other than the admin configuration form. It is intended for developers.

Supporting organizations: 
Development

Project information

Releases