I am new to quickbook and my client wants to sync his Magento orders with QuickBooks. He uses QuickBooks Enterprises desktop edition to sync the orders. We are using PHP devkit web connector and trying sample example given in the doc to add customer.
For the first time the add customer example worked fine but after that when I tried to add another customer, I got 'Data Exchange Required' message in quick web connector and the user was not added to quickbook.
Please help me to solve it and guide me how to add the Magento order to quickbook and customers. Below is the code I was using:
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
if (function_exists('date_default_timezone_set')){
date_default_timezone_set('America/New_York');
}
require_once '../QuickBooks.php';
$user = 'quickbooks';
$pass = 'password';
$map = array(
QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),
QUICKBOOKS_ADD_INVOICE => array( '_quickbooks_invoice_add_request', '_quickbooks_invoice_add_response' )
);
$errmap = array();
$hooks = array();
$log_level = QUICKBOOKS_LOG_DEVELOP;
$dsn = 'mysql://root:root@localhost/quickbooks_server';
if (!QuickBooks_Utilities::initialized($dsn))
{
QuickBooks_Utilities::initialize($dsn);
QuickBooks_Utilities::createUser($dsn, $user, $pass);
$primary_key_of_your_customer = 5;
$Queue = new QuickBooks_WebConnector_Queue($dsn);
$Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $primary_key_of_your_customer);
$Queue->enqueue(QUICKBOOKS_ADD_INVOICE, $primary_key_of_your_customer);
}
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(true, true);
function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="' . $requestID . '">
<CustomerAdd>
<Name>Muralidhar, LLC (' . mt_rand() . ')</Name>
<CompanyName>Muralidhar, LLC</CompanyName>
<FirstName>Muralidhar</FirstName>
<LastName>Jampa</LastName>
<BillAddress>
<Addr1>Muralidhar, LLC</Addr1>
<Addr2>134 Stonemill Road</Addr2>
<City>NewYork</City>
<State>NY</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>murarimaniram@gmail.com</Email>
<Contact>Muralidhar Jampa</Contact>
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
function _quickbooks_customer_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
return;
}
function _quickbooks_invoice_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceAddRq requestID="' . $requestID . '">
<InvoiceAdd>
<CustomerRef>
<FullName>Muralidhar Jampa</FullName>
</CustomerRef>
<TxnDate>2014-04-14</TxnDate>
<RefNumber>9869</RefNumber>
<BillAddress>
<Addr1>56 Cowles Road</Addr1>
<City>Willington</City>
<State>CT</State>
<PostalCode>06279</PostalCode>
<Country>United States</Country>
</BillAddress>
<PONumber></PONumber>
<Memo></Memo>
<InvoiceLineAdd>
<ItemRef>
<FullName>Test Item</FullName>
</ItemRef>
<Desc>Item 1 Description Goes Here</Desc>
<Quantity>1</Quantity>
<Rate>295</Rate>
</InvoiceLineAdd>
<InvoiceLineAdd>
<ItemRef>
<FullName>Test Item</FullName>
</ItemRef>
<Desc>Item 2 Description Goes Here</Desc>
<Quantity>3</Quantity>
<Rate>25</Rate>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
function _quickbooks_invoice_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
return;
}
?>