我正在尝试将我们的应用程序与直觉/quickbooks集成起来,到目前为止已经取得了很大的成功。我正在使用以下库来帮助我的集成:
http://consolibyte.com/downloads/quickbooks-php-devkit/ ( 2.0稳定)
我必须修改代码才能让更新调用正常工作。基本上,它传递的是未设置的自定义字段,通过取消QuickBooks_IPP_Service::_update中的设置,我能够使客户更新按预期工作。我为这个项目向github.com发出了一个拉请求,显示了这个修复程序:github.com/控制台/quickbooks-php/ pull /6
我的下一个目标是把估计数推到Intuit。EstimateService对象看起来不完整,所以我添加了update函数,从CustomerService对象复制它。它们都依赖于父服务对象来实际执行操作,所以我希望它能够正常工作。
但事实并非如此。
有趣的是,我不知道为什么我的生命,我会永远感激如果有人能帮助我。
当我捕获输出并将其放入“直觉api资源管理器”中时,它就能工作了!从直觉端传递给服务器的xml实际上是200条成功消息,但从我的最后看,它会阻塞500个内部服务器错误。不是最具描述性的错误信息:)
下面是一个示例调用(编辑以删除安全信息):每个控制台请求的$Service->lastRequest()的输出:
POST https://qbo.intuit.com/qbo27/resource/customer/v2/**realm**/1 HTTP/1.1
Content-Type: application/xml
Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="****", oauth_nonce="***", oauth_timestamp="1379677509", oauth_token="****", oauth_consumer_key="***", oauth_version="1.0"
Content-Length: 952
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Estimate xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:ns2="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:ns3="http://www.intuit.com/sb/cdm/qbo">
<Id idDomain="QBO">1</Id>
<SyncToken>4</SyncToken>
<Header>
<DocNumber>1001</DocNumber>
<TxnDate>2013-09-19-07:00</TxnDate>
<Status>Pending</Status>
<CustomerId idDomain="QBO">28</CustomerId>
<SalesTaxCodeId idDomain="QBO">1</SalesTaxCodeId>
<SalesTaxCodeName>IS_TAXABLE</SalesTaxCodeName>
<SubTotalAmt>3.00</SubTotalAmt>
<TaxAmt>0.21</TaxAmt>
<TotalAmt>3.00</TotalAmt>
</Header>
<Line>
<Desc>test 2</Desc>
<Amount>2.00</Amount>
<Taxable>true</Taxable>
<UnitPrice>2.00</UnitPrice>
<Qty>1</Qty>
</Line>
<Line>
<Desc>TEst</Desc>
<Amount>1.00</Amount>
<Taxable>true</Taxable>
<UnitPrice>1.00</UnitPrice>
<Qty>1</Qty>
</Line>
<Synchronized>false</Synchronized>
每个控制台请求的$Service->lastResponse()的输出:
HTTP/1.1 500 Internal Server Error
Date: Fri, 20 Sep 2013 17:04:30 GMT
Server: Apache
Set-Cookie: qboeuid=****; path=/; expires=Sat, 20-Sep-14 17:04:30 GMT; domain=.intuit.com
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 190
Connection: close
Content-Type: application/xml
<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?-->
<faultinfo xmlns="http://www.intuit.com/sb/cdm/baseexceptionmodel/xsd">
<message>Internal Server Error</message>
<errorcode>500</errorcode>
<cause>SERVER</cause>
</faultinfo>看看这里的其他问题,我看不出它们的解决方案是如何适用的:"Internal Server Error" on QBO Api Update call QuickBooks API error when updating
我不知道传入的任何自定义字段,这个估计值是通过api创建的。
唯一让我感到奇怪的是最后的同步化标记,但是它可以与直觉api资源管理器中的标记一起工作。编辑:我删除了这个设置为Quickbook在线,我仍然得到相同的结果。
同样,如果我使用上面的xml并将其放入到直觉api资源管理器中,它就能很好地工作。在我这一边,我得到了一个500错误返回。我已经尽力提供了尽可能多的信息,如果我错过了什么,请告诉我。
任何帮助都将不胜感激。提前谢谢你抽出时间。
编辑来自Cosoli字节的每个请求的更多代码:
//login info/OAuth is setup before this and I know it works
//I use it elsewhere to successfully add the estimate in the same class
//also i'm able to add/edit/update customers with the same auth code
$this->EstimateService = new QuickBooks_IPP_Service_Estimate();
$Estimate = $this->EstimateService->findById($this->Context, $this->realm, $quickbooks_id);
$Header = $Estimate->getHeader();
$Header->setTaxAmt(number_format($tax_amount, 2));
$Header->setCustomerId($qb_customer_id);
$Header->setTotalAmt(number_format($total_amount, 2));
//this was added when I was trying to figure out what is going on
//Adding this section did not change the status returned from intuit
$Header->remove('BillAddr');
$Header->remove('ShipAddr');
$Header->remove('ToBePrinted');
$Header->remove('ToBeEmailed');
$Header->remove('DiscountTaxable');
$Estimate->setHeader($Header);
//remove all lines from the current estimate to re-add in updated ones
$Estimate->remove('Line');
foreach($line_items as $item)
{
$Line = new QuickBooks_IPP_Object_Line();
$Line->setDesc($item['description']);
if($item['tax_percentage'])
{
$Line->setTaxable('true');
}
$Line->setUnitPrice($item['price']);
$Line->setQty($item['quantity']);
$Line->setAmount(number_format(($item['price'] * $item['quantity']), 2));
$Estimate->addLine($Line);
}
//$this->Context, $this->realm are set up properly and work
$this->EstimateService->update($this->Context, $this->realm, $Estimate->getId(), $Estimate);发布于 2013-09-20 17:41:41
根据请求的这一部分:
POST https://qbo.intuit.com/qbo27/resource/customer/v2/**realm**/1 HTTP/1.1看起来,您可能正在使用一个QuickBooks_IPP_Service_Customer实例来添加一个估计值。
您确定使用的是正确的服务类实例吗?
你能偶然地发布你的代码片段吗?
发布于 2013-09-20 14:03:47
应该从请求中删除同步标记。QBO直接将数据同步到云,因此这是一个不正确的字段。它仅用于发出QBD请求。检查这里的请求- online/estimate
我同意它可能在API资源管理器上工作,因为浏览器必须忽略它,并且只考虑所需的字段。API资源管理器不使用SDK。所以,你不明白这个错误。但是,当您使用SDK进行连接时,您传递的请求xml是错误的,因此会得到错误。
https://stackoverflow.com/questions/18916599
复制相似问题