I have try to update a record from my database to quickbooks by PHP API, but there is an errors comes out.
My code to update just like this, the dataService is work normally. Since i have use it for query record form quickbooks is ok.
$resultingObj = $dataService->Update($entities[0]);
Object Dump:
object(IPPItem)#2586 (54) {
["Name"]=> string(20) "Factor 46 - X7Y7d-P1"
["Sku"]=> string(8) "X7Y7d-P1"
["Description"]=> string(9) "Factor 46"
["Active"]=> string(4) "true"
["SubItem"]=> NULL
["ParentRef"]=> NULL
["Level"]=> NULL
["FullyQualifiedName"]=> string(20) "Factor 46 - X7Y7d-P1"
["Taxable"]=> string(4) "true"
["SalesTaxIncluded"]=> NULL
["PercentBased"]=> NULL
["UnitPrice"]=> string(8) "11390.00"
["RatePercent"]=> NULL
["Type"]=> string(9) "Inventory"
["PaymentMethodRef"]=> NULL
["UOMSetRef"]=> NULL
["IncomeAccountRef"]=> array(2) {
["value"]=> string(2) "79"
["name"]=> string(23) "Sales of Product Income"
}
["PurchaseDesc"]=> NULL
["PurchaseTaxIncluded"]=> NULL
["PurchaseCost"]=> string(1) "0"
["ExpenseAccountRef"]=> array(2) {
["value"]=> string(2) "80"
["name"]=> string(18) "Cost of Goods Sold"
}
["COGSAccountRef"]=> NULL
["AssetAccountRef"]=> array(2) {
["value"]=> string(2) "81"
["name"]=> string(15) "Inventory Asset"
}
["PrefVendorRef"]=> NULL
["AvgCost"]=> NULL
["TrackQtyOnHand"]=> string(4) "true"
["QtyOnHand"]=> int(0)
["QtyOnPurchaseOrder"]=> NULL
["QtyOnSalesOrder"]=> NULL
["ReorderPoint"]=> NULL
["ManPartNum"]=> NULL
["DepositToAccountRef"]=> NULL
["SalesTaxCodeRef"]=> NULL
["PurchaseTaxCodeRef"]=> NULL
["InvStartDate"]=> string(10) "2016-11-05"
["BuildPoint"]=> NULL
["PrintGroupedItems"]=> NULL
["SpecialItem"]=> NULL
["SpecialItemType"]=> NULL
["ItemGroupDetail"]=> NULL
["ItemAssemblyDetail"]=> NULL
["AbatementRate"]=> NULL
["ReverseChargeRate"]=> NULL
["ServiceType"]=> NULL
["ItemCategoryType"]=> NULL
["ItemEx"]=> NULL
["Id"]=> string(2) "19"
["SyncToken"]=> string(1) "0"
["MetaData"]=> object(IPPModificationMetaData)#2569 (6) {
["CreatedByRef"]=> NULL
["CreateTime"]=> string(25) "2017-06-22T10:25:37-07:00"
["LastModifiedByRef"]=> NULL
["LastUpdatedTime"]=> string(25) "2017-06-22T10:25:37-07:00"
["LastChangedInQB"]=> NULL
["Synchronized"]=> NULL
}
["CustomField"]=> NULL
["AttachableRef"]=> NULL
["domain"]=> NULL
["status"]=> NULL
["sparse"]=> NULL
}
Exception Call Stack (Class 79 does not exist):
In (/data/app/frameworks/yii2/vendor/intuit/QuickBooks/v3-php-sdk-2.4.1/XSD2PHP/src/com/mikebevz/xsd2php/Php2Xml.php) on 257 getXmlFromObj()
XmlObjectSerializer.php:68 getPostXmlFromArbitraryEntity()
XmlObjectSerializer.php:175 Serialize()
DataService.php:447 executeObjectSerializer()
DataService.php:189 Update()
QuickBooksApi.php:347 syncProduct()
QuickBooksController.php:191 actionSyncProduct() :
call_user_func_array()
InlineAction.php:55 runWithParams()
Controller.php:154 runAction()
Module.php:454 runAction()
Application.php:100 handleRequest()
Application.php:375 run()
index.php:20
I also try change my object to JSON
and test in their API Explorer, it can update successfully. What is my problem on my code?
That is an error in your IPPItem due to malformed object. You are using v3-php-sdk-2.4.1, which is really old. The latest version has provided a better way to do it:
$ItemObj = Item::update($oldItemObj, [
"Name" => "Rock Fountain",
"Description" => "New, updated description for Rock Fountain",
"Active" => true,
"FullyQualifiedName" => "Rock Fountain",
"Taxable" => true,
"UnitPrice" => 275,
"Type" => "Inventory",
"IncomeAccountRef" => [
"value" => "79",
"name" => "Sales of Product Income"
],
"PurchaseDesc" => "Rock Fountain",
"PurchaseCost" => 125,
"ExpenseAccountRef" => [
"value" => "80",
"name" => "Cost of Goods Sold"
],
"AssetAccountRef": [
"value" => "81",
"name" => "Inventory Asset"
],
"Id" => "5",
"SyncToken" => "2"
]);
Take a look at our Github for v3.2.6 php sdk now: https://github.com/intuit/QuickBooks-V3-PHP-SDK
It should help you fix the issue.
Thanks hao