Contributions towards open-source projects are *always* appreciated! You can contribute by:
http://consolibyte.com/?__module=page&__action=actionDisplay&__ID=7
QuickBooks Web Connector Integrations (traditional method)
Lists of CONSTANTS and other important keywords
Before you do anything, here are a few things that will make your life much easier:
$my_var = 2;
function my_function()
{
// This *will not* print "2", it *will* result in a PHP notice/warning
print($my_var);
}
That message means exactly what it says:
The Web Connector and this framework work using a 'queue' concept. Once the queue is empty, there's nothing else to do, and you'll get that message. If you add something to the queue, then it will process those items until there's nothing left to do, and then you'll get the “No Data Exchange…” message again.
So, for instance, say you want to build a process whereby every time a customer is created within your store, the customer gets created in QuickBooks. You'd then want to set up a process where when that customer is created within your store, you queue up a request to add the customer to QuickBooks.
You do your queueing using the QuickBooks_Queue class, and the →enqueue() method. The documentation for that is here:
You can write your own custom authentication handlers like this:
1. Write your function
function your_function_name_here($username, $password)
{
if ( the username and password are valid )
{
return true;
}
return false;
}
2. Register it as the authentication handler:
$handler_options = array( 'authenticate_dsn' => 'function://your_function_name_here', );
This could mean a few different things:
// Here is our $map $map = array( QUICKBOOKS_ADD_CUSTOMER => array( 'add_customer_request_function', 'add_customer_response_function' ), ); // Here's what we queued up $Queue->enqueue(QUICKBOOKS_QUERY_VENDOR); // This will generate an error message "No registered functions for action: CustomerQuery" because you didn't tell the server using $map what functions to call for that type of action, you only told it what to call for QUICKBOOKS_ADD_CUSTOMER. Fix it like this: $map = array( QUICKBOOKS_ADD_CUSTOMER => array( 'add_customer_request_function', 'add_customer_response_function' ), QUICKBOOKS_QUERY_VENDOR => array( 'query_vendor_request_function', 'query_vendor_response_function' ), );
// GOOD (specify the requestID attribute using the provided variable): $xml = "... <CustomerQueryRq requestID="' . $requestID . '"> ... "; // BETTER (leave the requestID out entirely, the framework will add it for you): $xml = "... <CustomerQueryRq> ... "; // BAD (an incorrect requestID): $xml = "... <CustomerQueryRq requestID=" anything else other than $requestID here "> ... "; // REALLY BAD (an incorrect requestID again... why are you re-defining $requestID? it's already passed to you as a parameter to the function): $requestID = "my made up value"; $xml = "... <CustomerQueryRq requestID="' . $requestID . '"> ... ";
Short explanation: Due to various security concerns, 32 character and 40 character passwords are artificially disabled and will never authenticate.
Long explanation: The framework supports multiple hash methods for encrypting the password in the quickbooks_user table. It supports:
Because passwords can be stored as 32-char MD5 hashes, allowing 32-char plain-text passwords opens up the possibility that someone could maliciously submit 32 random characters and potentially match the MD5 hash, even though the submitted hashed password does not match the stored hashed password.
Thus, 32 character and 40 character passwords have an artificial limit in place which always disallows logins when a 32 character or 40 character password is submitted via the Web Connector.
The EditSequence indicates the last time the record changes within QuickBooks. Thus, whenever you update a record with a *Mod command, you need to have the latest EditSequence to do the update.
Usually, the easy way to do things is to issue a query, and use the $extra parameter to store a note to yourself indicating that you really want to do a modify. So, queue up a CustomerQuery with extra data of CustomerMod. In your CustomerQuery response handler, store the latest EditSequence, and then check the extra data. If the extra data is CustomerAdd, queue up a CustomerAdd. If the extra data is CustomerMod, queue up a CustomerMod, etc. If you do it this way, you won't need to muck around with stored procedures. As an added benefit, you can set up an error handler which will catch any 'object not found' errors if the query can't find the record, and handle the error appropriately.
You can use the $priority parameter to the →enqueue() function to set priorities on things in the queue. Higher priority things will get run first, lower priority things later.
If you're not entirely sure what is going wrong, this is what you need to do/know to find out.
The quickbooks_queue table shows a record of each action that we performed on QuickBooks, and what the resulting status was. If you see a status of 'i', that is a bad thing, and generally means that some PHP or database error occurred. If you see a status of 'e', it's bad and means that an error occurred while communicating with QuickBooks. Any other status is OK. The 'ident' field is the primary key of your record you passed into the queueing function (i.e.: The quote ID or the customer ID).
The quickbooks_log table shows a log of all incoming and outgoing XML and SOAP requests/responses, plus other general logging. By watching this table you can see the actual outgoing and incoming qbXML requests and responses your application is producing/consuming.