0

我正在尝试将我们的应用程序与 intuit/quickbooks 集成,并且到目前为止已经取得了巨大的成功。我正在使用以下库来帮助我的集成:

http://consolibyte.com/downloads/quickbooks-php-devkit/(2.0 稳定版)

我必须修改代码才能使更新调用正常工作。基本上它传递了未设置的自定义字段,并且通过取消设置 QuickBooks_IPP_Service::_update 中的那些,我能够让客户更新按预期工作。我向这个项目的 github 存储库发出了一个拉取请求,显示了这个修复:github.com/consolibyte/quickbooks-php/pull/6

我的下一个目标是让 Estimates 被推送到 Intuit。EstimateService 对象看起来不完整,所以我添加了更新函数,从 CustomerService 对象中复制了它。他们都依赖父服务对象来实际执行操作,所以我希望它能够正常工作。

好吧,它没有。

有趣的是,我一生都想不通为什么,如果有人能帮助我,我将永远感激不尽。

当我捕获输出并将其放入“intuit api explorer”时,它就可以工作了!从字面上看,从 intuits 端传递给服务器的相同 xml 会产生 200 成功消息,但从我的角度来看,它会因 500 内部服务器错误而窒息。不是最具描述性的错误消息:)

这是一个示例调用(经过编辑以删除安全信息):每个 conolibytes 请求的 $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>

每个 conolibytes 请求的 $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>

在这里查看其他问题,我没有看到他们的解决方案如何应用: QBO Api Update 上的“内部服务器错误”在更新 时调用 QuickBooks API 错误

我不知道传入的任何自定义字段,这个估计是通过 api 创建的。

对我来说唯一奇怪的是最后的 Synchromized 标签,但是它可以在 intuit api explorer 中使用。编辑:我从在线 Quickbooks 的设置中删除了这个,我仍然得到相同的结果。

同样,如果我将上面的 xml 放入 intuits api explorer 中,它会完美运行。在我这边,我收到一个 500 错误返回。我试图提供尽可能多的信息,如果我遗漏了什么,请告诉我。

任何帮助将不胜感激。提前感谢您的宝贵时间。

根据 cosolibyte 的请求编辑更多代码:

//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);
4

2 回答 2

1

基于请求的这一部分:

POST https://qbo.intuit.com/qbo27/resource/customer/v2/**realm**/1 HTTP/1.1

看起来您可能正在使用QuickBooks_IPP_Service_Customer实例来尝试添加估算值。

您确定您使用的是正确的服务类实例吗?

您可以偶然发布一段代码吗?

于 2013-09-20T17:41:41.113 回答
0

应从您的请求中删除同步标记。QBO 将数据直接同步到云端,因此这是一个错误的字段。它仅用于发出 QBD 请求。在此处检查请求 - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/estimate

我同意它可能适用于 API 资源管理器,因为资源管理器必须忽略它并只考虑必填字段。API 资源管理器不使用 SDK。所以,你没有得到错误。但是,当您使用 SDK 连接时,您传递了错误的请求 xml,因此您会收到错误消息。

于 2013-09-20T14:03:47.627 回答