Reputation: 4502
We are importing order and payment data from Magento to Quickbooks Desktop version. Below are two queries - these give successful responses, but no data is imported. Any ideas for us?
First, we create a query to form a orders stack
$qb_order = new QuickBooks_IPP_Object_Invoice();
$qb_meta = new QuickBooks_IPP_Object_MetaData();
$qb_meta->setCreateTime($order->getCreatedAt());
$qb_meta->setLastUpdatedTime($order->getUpdatedAt());
$qb_order->setMetaData($qb_meta);
$qb_header = new QuickBooks_IPP_Object_Header();
$qb_header->setDocNumber($order->getIncrementId());
if (!$qb_customer_id = $this->_getQbCustomerId($order->getCustomerId())) return false;
$qb_header->setCustomerId($qb_customer_id);
$qb_header->setShipDate($order->getDeliveryDate());
$qb_header->setSubTotalAmt($order->getBaseSubtotal());
$qb_header->setTaxAmt($order->getBaseTaxAmount());
$qb_header->setTotalAmt($order->getBaseGrandTotal());
$qb_header->setARAccountId("Accounts Receivable");
if ($address = $order->getBillingAddress()) {
$qb_header->setBillAddr($this->_convertAddress($address, "Billing"));
}
if ($address = $order->getShippingAddress()) {
$qb_header->setShipAddr($this->_convertAddress($address, "Shipping"));
}
$qb_header->setDiscountAmt($order->getBaseDiscountAmount());
$qb_order->setHeader($qb_header);
foreach($order->getItemsCollection() as $item) {
$qb_order->addLine($this->_convertOrderItem($item));
}
Here is the XML, which is formed after query:
<?xml version="1.0" encoding="UTF-8"?>
<Add xmlns="http://www.intuit.com/sb/cdm/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
RequestId="4562cdf8407178e362082c0441dffa74"
xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ./RestDataFilter.xsd ">
<OfferingId>ipp</OfferingId>
<ExternalRealmId>631645715</ExternalRealmId>
<Object xsi:type="Invoice">
<Header>
<DocNumber>100001570</DocNumber>
<CustomerId>103699</CustomerId>
<ShipDate>2013-02-21</ShipDate>
<SubTotalAmt>33.0000</SubTotalAmt>
<TaxAmt>2.6400</TaxAmt>
<TotalAmt>35.64</TotalAmt>
<ARAccountId>Accounts Receivable</ARAccountId>
<BillAddr>
<Line1></Line1>
<Line2></Line2>
<Line3></Line3>
<Line4></Line4>
<City></City>
<Country></Country>
<CountrySubDivisionCode></CountrySubDivisionCode>
<PostalCode></PostalCode>
<Tag>Billing</Tag>
</BillAddr>
<ShipAddr>
<Line1></Line1>
<Line2></Line2>
<Line3></Line3>
<Line4></Line4>
<City></City>
<Country></Country>
<CountrySubDivisionCode></CountrySubDivisionCode>
<PostalCode></PostalCode>
<Tag>Shipping</Tag>
</ShipAddr>
<DiscountAmt>0.0000</DiscountAmt>
</Header>
<Line>
<Desc>Special Product For POS
sdf</Desc>
<Amount>33.0000</Amount>
<ItemType>Product</ItemType>
<UnitPrice>33.0000</UnitPrice>
<Qty>1</Qty>
</Line>
</Object>
</Add>
Here is the Server response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
<Success RequestId="4562cdf8407178e362082c0441dffa74">
<ObjectRef>
<Id idDomain="NG">494527</Id>
<SyncToken>1</SyncToken>
<LastUpdatedTime>2013-02-21T05:44:12Z</LastUpdatedTime>
</ObjectRef>
<RequestName>InvoiceAdd</RequestName>
<ProcessedTime>2013-02-21T05:44:12Z</ProcessedTime>
</Success>
</RestResponse>
=================================================================
Here is the second set of code for creating payments against orders. Again same issue, successful XML but no data imported:
$order = Mage::getModel("sales/order")->load($invoice->getOrderId());
if (!$qb_order_id = $this->getHelper()->getObjectQbId($order)) return false;
$qb_payment = new QuickBooks_IPP_Object_Payment();
$qb_meta = new QuickBooks_IPP_Object_MetaData();
$qb_meta->setCreateTime($invoice->getCreatedAt());
$qb_meta->setLastUpdatedTime($invoice->getUpdatedAt());
$qb_payment->setMetaData($qb_meta);
$qb_header = new QuickBooks_IPP_Object_Header();
$qb_header->setDocNumber($invoice->getIncrementId());
$qb_header->setTxnDate($invoice->getCreatedAt());
if (!$qb_customer_id = $this->_getQbCustomerId($order->getCustomerId())) return false;
$qb_header->setCustomerId($qb_customer_id);
$qb_header->setTotalAmt($invoice->getBaseGrandTotal());
$qb_header->setProcessPayment('false');
$qb_payment->setHeader($qb_header);
$qb_line = new QuickBooks_IPP_Object_Line();
$qb_line->setAmount($invoice->getBaseGrandTotal());
$qb_line->setTxnId($qb_order_id);
$qb_payment->addLine($qb_line);
Here is the XML, which is formed after code:
<?xml version="1.0" encoding="UTF-8"?>
<Add xmlns="http://www.intuit.com/sb/cdm/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
RequestId="dc07317b838eb3d0c89e310b4984468a"
xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ./RestDataFilter.xsd ">
<OfferingId>ipp</OfferingId>
<ExternalRealmId>631645715</ExternalRealmId>
<Object xsi:type="Payment">
<Header>
<DocNumber>100000265</DocNumber>
<TxnDate>2013-02-21</TxnDate>
<CustomerId>103699</CustomerId>
<TotalAmt>35.64</TotalAmt>
<ProcessPayment>false</ProcessPayment>
</Header>
<Line>
<Amount>35.6400</Amount>
<TxnId>494527</TxnId>
</Line>
</Object>
</Add>
Here is the answer from server:
<?xml version="1.0" ?>
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
<Success RequestId="dc07317b838eb3d0c89e310b4984468a">
<ObjectRef>
<Id idDomain="NG">494529</Id>
<SyncToken>1</SyncToken>
<LastUpdatedTime>2013-02-21T05:48:07Z</LastUpdatedTime>
</ObjectRef>
<RequestName>PaymentAdd</RequestName>
<ProcessedTime>2013-02-21T05:48:07Z</ProcessedTime>
</Success>
</RestResponse>
Upvotes: 1
Views: 664
Reputation: 27982
First, just to be clear, make sure you're building for the correct platform - according to the Intuit FAQs (as of Feb 2013), if this is an internal integration just for your company, you shouldn't be using Intuit Anywhere/IPP. From the FAQ:
Q: I want to integrate my custom (non-SaaS, single-tenant) solution with Intuit Anywhere. Can I do this?
A: Not today, but we are considering it.
As a side note, for internal integrations with QuickBooks for Windows, the Web Connector is a whole lot more reliable and easier to troubleshoot than Intuit Anywhere is.
With all that said... your problem is likely related to the line items, and the items that you are (not) referring to. In QuickBooks, every single line item is attached to a specific Item record in QuicKBooks (it's the "Item Name/SKU" drop-down in the GUI).
Your line items, however:
<Line>
<Desc>Special Product For POS sdf</Desc>
<Amount>33.0000</Amount>
<ItemType>Product</ItemType>
<UnitPrice>33.0000</UnitPrice>
<Qty>1</Qty>
</Line>
Only refer to an Item "type" (e.g. "Inventory", "Product", "Service", etc.).
You should have a tag in each line item either:
<ItemName>Your QuickBooks Item Name</ItemName>
Or:
<ItemId>123</ItemId>
If you look at the documentation or some of the QuickBooks IDS/Intuit Anywhere examples floating around the web you'll see they all use either ItemName or ItemId in each and every line item.
You might also want to look into how to fetch the write back errors as that will give you more information (worth noting that the PHP DevKit doesn't have a native method for fetching those errors right now, but it's something we're working on - contact me if you need further help there).
Upvotes: 1