I am a very new to QuickBooks. I have created a trial account in Quick Books and I want to add customers, create invoices or similar sort of things to my account. I have downloaded the php SDK from github. Now I have no Idea how to start, from where to start to add the customer to my account after the customer make the order from my website. Can anyone help me with some detail documentation or some examples so that I can move forward. I have no knowledge about the web app connector. I am totally new. Thanks..
-
possibly dublicate http://stackoverflow.com/questions/20387302/adding-a-customer-with-address-details-to-quickbooks – Muhammad Dec 05 '13 at 07:16
-
Duplicate of http://stackoverflow.com/questions/22705695/quickbooks-web-connector-authenticate-with-php-soap-server – hashkishor Mar 21 '17 at 10:37
2 Answers
This is going to be a two-part answer, because you didn't specify if you're using QuickBooks ONLINE, or QuickBooks for WINDOWS.
The process will be DIFFERENT depending on which you're using, so pay attention to the bold headers below:
For QuickBooks ONLINE:
If you're using the open source QuickBooks PHP DevKit from GitHub, then the best place to start is the QuickBooks Online with PHP quick-start guide.
The very first thing you'll have to do is register your app with Intuit. When you do this, Intuit will give you these variables:
- app token
- consumer secret
- consumer key
You will substitute these variables into the config.php file that is included in the example. You'll also update these values to point to your app:
- oauth url (e.g. your-site.com/path/to/example/oauth.php)
- success url (e.g. your-site.com/path/to/example/success.php)
- menu url (e.g. your-site.com/path/to/example/menu.php)
- dsn (your database credentails for OAuth token storage)
Beyond that, you can leave all other variables in config.php at their defaults.
If you then visit the index.php file, it will prompt you to connect to QuickBooks. You can connect, and then visit the example files. Here are some examples of adding customers/orders to QuickBooks Online:
The code ends up looking something like:
$CustomerService = new QuickBooks_IPP_Service_Customer();
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setTitle('Mr');
$Customer->setGivenName('Keith');
$Customer->setMiddleName('R');
$Customer->setFamilyName('Palmer');
$Customer->setDisplayName('Keith R Palmer Jr ' . mt_rand(0, 1000));
// Phone #
$PrimaryPhone = new QuickBooks_IPP_Object_PrimaryPhone();
$PrimaryPhone->setFreeFormNumber('860-532-0089');
$Customer->setPrimaryPhone($PrimaryPhone);
// Bill address
$BillAddr = new QuickBooks_IPP_Object_BillAddr();
$BillAddr->setLine1('72 E Blue Grass Road');
$BillAddr->setLine2('Suite D');
$BillAddr->setCity('Mt Pleasant');
$BillAddr->setCountrySubDivisionCode('MI');
$BillAddr->setPostalCode('48858');
$Customer->setBillAddr($BillAddr);
if ($resp = $CustomerService->add($Context, $realm, $Customer))
{
print('Our new customer ID is: [' . $resp . ']');
}
To implement additional functionality, you'll find other examples included in the code.
The objects/methods available also mirror Intuit's documentation so you'll want to look at that.
For QuickBooks for WINDOWS:
For QuickBooks for Windows, you'll use the Web Connector. Again, start with the open source QuickBooks PHP DevKit from GitHub. Use the QuickBooks for Windows + PHP quick-start guide instead.
That will walk you through setting up a simple Web Connector service which adds test customers to QuickBooks.
Basically you'll create a .QWC file which you'll load into the QuickBooks Web Connector (Start > All Programs > QuickBooks > Web Connector). That .QWC file will point to a PHP script which negotiates the connection between QuickBooks and PHP. All you have to do in that example script is swap this variable:
- $dsn (point it to your own database)
For each new piece of functionality you want to add, you'll end up writing a new request and response function, as detailed in the QuickBooks Web Connector + PHP docs.
Your code will end up looking something like:
function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// You'd probably do some database access here to pull the record with
// ID = $ID from your database and build a request to add that particular
// customer to QuickBooks.
//
// So, when you implement this for your business, you'd probably do
// something like this...:
/*
// Fetch your customer record from your database
$record = mysql_fetch_array(mysql_query("SELECT * FROM your_customer_table WHERE your_customer_ID_field = " . (int) $ID));
// Create and return a qbXML request
$qbxml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="' . $requestID . '">
<CustomerAdd>
<Name>' . $record['your_customer_name_field'] . '</Name>
<CompanyName>' . $record['your_customer_company_field'] . '</CompanyName>
... lots of other customer related fields ...
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $qbxml;
*/
// But we're just testing, so we'll just use a static test request:
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="' . $requestID . '">
<CustomerAdd>
<Name>ConsoliBYTE, LLC (' . mt_rand() . ')</Name>
<CompanyName>ConsoliBYTE, LLC</CompanyName>
<FirstName>Keith</FirstName>
<LastName>Palmer</LastName>
<BillAddress>
<Addr1>ConsoliBYTE, LLC</Addr1>
<Addr2>134 Stonemill Road</Addr2>
<City>Mansfield</City>
<State>CT</State>
<PostalCode>06268</PostalCode>
<Country>United States</Country>
</BillAddress>
<Phone>860-634-1602</Phone>
<AltPhone>860-429-0021</AltPhone>
<Fax>860-429-5183</Fax>
<Email>Keith@ConsoliBYTE.com</Email>
<Contact>Keith Palmer</Contact>
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
You can find additional qbXML reference using the QuickBooks OSR.
We also provide a wiki with lots of example qbXML requests that you can use.

- 27,666
- 16
- 68
- 105
-
1I am using the Quickbooks online Thanks for your help.... I have tried that and now I am getting the following error when I click on the connect button "Call to undefined function mcrypt_module_open()" on quickbooks-php-master/QuickBooks/Encryption/Aes.php on line 34. – Yunus Aslam Dec 05 '13 at 11:33
-
Because of the security standards Intuit requires, you will need the PHP mcrypt module installed and enabled. http://us2.php.net/mcrypt Talk to your web host if it's not installed/enabled already. – Keith Palmer Jr. Dec 05 '13 at 11:42
-
Yes I just now contacted the sever administrator.. Another question, I had created an app. SO when I add a customer the customer must show up in the customer page in Quick books right ?? – Yunus Aslam Dec 05 '13 at 11:53
-
Yes, when you do a $CustomerService->add(...), that will add a customer to QuickBooks. – Keith Palmer Jr. Dec 05 '13 at 12:56
-
Thanks a lot Keith.. I am now able to connect and add customer.. Also can you provide me a link where I cam see the examples of adding custom fields as well as email and phone numbers..?? – Yunus Aslam Dec 05 '13 at 13:29
-
Here is an example of adding custom fields to an invoice (note that you have to define the field names in QBO first): https://github.com/consolibyte/quickbooks-php/blob/master/docs/example_app_ipp_v3/example_invoice_with_custom_fields_add.php – Keith Palmer Jr. Dec 05 '13 at 16:46
-
The example I posted above already shows how to add emails and phone numbers. https://github.com/consolibyte/quickbooks-php/blob/master/docs/example_app_ipp_v3/example_customer_add.php – Keith Palmer Jr. Dec 05 '13 at 16:51
-
Hello Keith.. I am trying to add the details as you have mentioned above but that is not doing anything.. In the response I see the details but when I refresh my customer page I see only the name of the customer and nothing else.. – Yunus Aslam Dec 06 '13 at 05:06
-
Thanks a lot Keith for helping me every time... I tried a lot and I have reached up to this.. Now when I am trying to add application through the web connector. I am getting the following error "This application does not have permission to access this Quickbooks company data file. The Quickbooks administrator can grant permission through the Integrated Application preferences." How can I solve that.. Thanks for your great support.. – Yunus Aslam Dec 06 '13 at 13:12
-
Web Connector is only for QuickBooks for Windows, and it requires SSL. If you having trouble getting addresses/emails/phone numbers to work, start a new SO post and post the code you're using, along with the output of print($IPP->lastRequest()); print($IPP->lastResponse()); immediately after calling $CustomerService->add(...) – Keith Palmer Jr. Dec 06 '13 at 13:20
-
Is QuickBooks running, and are you logged into QuickBooks as the user "Admin"? – Keith Palmer Jr. Dec 06 '13 at 13:20
-
Yes I am logged in to Quickbooks as admin and it is running fine. I have installed and also added a trial company for all my test purposes. – Yunus Aslam Dec 06 '13 at 14:11
-
Start a new post on SO, post your Web Connector log in VERBOSE mode and your code. – Keith Palmer Jr. Dec 06 '13 at 14:33
-
Can any one provide Quickbooks online API with RubyOnRails example or link which work properly? – harsh4u Mar 14 '14 at 11:32
-
@Gravitoid That's a fork, here is the official: https://github.com/consolibyte/quickbooks-php – Keith Palmer Jr. May 11 '15 at 20:34
-
1Keith. Old topic but it needs this comment. It feels like on a lot of these questions regarding quickbooks that do not ask about your code, but about the actual PHP SDK from intuit, you refer them to your code every time. I know you consider your code to be the best way to manage things but this causes quite an issue when someone is looking for PHP SDK information and you refer them to your code which is, well, unrelated. This feels like advertising on stackoverflow to get users to use your product rather than address the actual question regarding the official SDK. If I am wrong, I apologize. – Jesse Sep 30 '15 at 00:07
-
@Jesse I will definitely try to avoid that/make things clearer. I'm not actually sure if this particular question is referring to Intuit's code or ours, the original asker really didn't make that clear, so I was just trying to be helpful. I do generally try to refrain entirely from answering questions about Intuit's SDK unless they note a specific problem that I know can be worked around with our code instead (e.g. Intuit's dependency on the PECL OAuth package). – Keith Palmer Jr. Sep 30 '15 at 04:36
-
The only reason I bring it up is, while I'm sure your code is fine and when looking through it it looks great for a full quick books setup, while attempting to write a class to wrap up some basic functions from the php sdk intuit has for my day job, it was very hard to find information on SO without seeing your replies recommending your framework. That's the main problem simply because we both know intuit is bad with keeping pages alive and this problem extended my work day by hours – Jesse Sep 30 '15 at 04:41
-
Could you please update your answer for purchase order as I've been able to create employee but unable to create a purchase order. – Basheer Kharoti Oct 14 '15 at 05:33
-
@BasheerKharoti No, but you are welcome to post a new question and ask for that, while showing the code you're tried so far, and I will answer there with an example/corrections. – Keith Palmer Jr. Oct 14 '15 at 12:17
-
@KeithPalmer-consolibyte tnx for your resposne I've posted my question but no one answered it at last I accomplished my own task by myself.. – Basheer Kharoti Oct 14 '15 at 14:58
-
@KeithPalmerJr. do you know if there's any solution to integrate the web application with QBs Mac? I have this question: http://stackoverflow.com/questions/33767981/integrate-angular-web-application-data-with-quickbooks-desktop-maybe-mac Also it's my wish not to prompt user to install web connector because it may not be very user-friendly. Is there a simple quick export and import way? – WABBIT0111 Nov 17 '15 at 23:05
-
@WABBIT0111 QuickBooks for Mac does not support integration. Intuit does not provide a way to integrate with it. End of story. If you want integration, use QuickBooks Online. – Keith Palmer Jr. Nov 18 '15 at 01:43
-
1@KeithPalmerJr. for the php kit ^^^^ for Quickbooks, does it work well with all version of QuickBooks Windows, including quickbooks Pro, and quickbooks Premier? – WABBIT0111 Nov 18 '15 at 22:09
-
Yes, it works with all versions of QuickBooks for Windows, and all versions of QuickBooks Online. – Keith Palmer Jr. Nov 18 '15 at 23:36
From the SDK,use example_ipp_ids_6.php for adding customers.
Here is the link to the full code on GitHub:
And a quick-start guide:
example_ipp_ids_6.php
<?php
// Turn on some error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
header('Content-Type: text/plain');
/**
* Require the QuickBooks library
*/
require_once dirname(__FILE__) . '/../QuickBooks.php';
/**
* Require some IPP/OAuth configuration data
*/
require_once dirname(__FILE__) . '/example_ipp_config.php';
// Set up the IPP instance
$IPP = new QuickBooks_IPP($dsn);
// Set up our IntuitAnywhere instance
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret);
// Get our OAuth credentials from the database
$creds = $IntuitAnywhere->load($the_username, $the_tenant);
// Tell the framework to load some data from the OAuth store
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
$creds);
// Print the credentials we're using
//print_r($creds);
// This is our current realm
$realm = $creds['qb_realm'];
// Load the OAuth information from the database
if ($Context = $IPP->context())
{
// Set the DBID
$IPP->dbid($Context, 'something');
// Set the IPP flavor
$IPP->flavor($creds['qb_flavor']);
// Get the base URL if it's QBO
if ($creds['qb_flavor'] == QuickBooks_IPP_IDS::FLAVOR_ONLINE)
{
$IPP->baseURL($IPP->getBaseURL($Context, $realm));
}
print('Base URL is [' . $IPP->baseURL() . ']' . "\n\n");
$CustomerService = new QuickBooks_IPP_Service_Customer();
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setName('Willy Wonka #' . mt_rand(0, 1000));
$Customer->setGivenName('Willy');
$Customer->setFamilyName('Wonka');
$resp = $CustomerService->add($Context, $realm, $Customer);
print_r($Customer);
print('New customer is [' . $resp . ']' . "\n\n");
print("\n\n\n\n");
print('Request [' . $IPP->lastRequest() . ']');
print("\n\n\n\n");
print('Response [' . $IPP->lastResponse() . ']');
print("\n\n\n\n");
}
else
{
die('Unable to load a context...?');
}
Configure your keys and username in example_ipp_config.php
<?php
/**
* Intuit Partner Platform configuration variables
*
* See the scripts that use these variables for more details.
*
* @package QuickBooks
* @subpackage Documentation
*/
// Your OAuth token (Intuit will give you this when you register an Intuit Anywhere app)
$token = 'c640731cb411db4132b8475b4198a7efae08';
// Your OAuth consumer key and secret (Intuit will give you both of these when you register an Intuit app)
//
// IMPORTANT:
// To pass your tech review with Intuit, you'll have to AES encrypt these and
// store them somewhere safe.
//
// The OAuth request/access tokens will be encrypted and stored for you by the
// PHP DevKit IntuitAnywhere classes automatically.
$oauth_consumer_key = 'qyprdzUiOLX60UK4cMwYhg1QVGfOGT';
$oauth_consumer_secret = '32mIB75pqqPreOADcxRvryC0fBduJhnRr52JfUdf';
// This is the URL of your OAuth auth handler page
$this_url = 'http://localhost/quick/docs/example_ipp_oauth.php';
// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$that_url = 'http://localhost/quick/docs/example_ipp_ids_6.php';
// This is a database connection string that will be used to store the OAuth credentials
// $dsn = 'pgsql://username:password@hostname/database';
// $dsn = 'mysql://username:password@hostname/database';
$dsn = 'mysql://root:@localhost/quickbooks';
// You should set this to an encryption key specific to your app
$encryption_key = 'abcd1234';
// The user that's logged in
$the_username = 'test@gmail.com';
// The tenant that user is accessing within your own app
$the_tenant = 12345;
// Initialize the database tables for storing OAuth information
if (!QuickBooks_Utilities::initialized($dsn))
{
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
}

- 27,666
- 16
- 68
- 105

- 750
- 4
- 15
-
Can U say me from where can I get token, consumer key, consumer secret encryption_key and the tenant please... – Yunus Aslam Dec 05 '13 at 07:44
-
When you go through registration with Intuit, they will *give you* all of this information. $tenant you can just leave as the default value. – Keith Palmer Jr. Dec 05 '13 at 10:54
-
Hi @KeithPalmerJr. the website http://www.consolibyte.com/ is not accessible anymore. This is a very useful project till now after a long time. Is there any way we can access the whole documentation ? – Sandipan S Aug 20 '19 at 07:41