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 オブジェクトからコピーしました。どちらも実際に操作を実行するために親の Service オブジェクトに依存しているため、うまく機能することを期待していました。

まあ、そうではありませんでした。

面白いことに、一生その理由を理解することはできません。誰かが私を助けてくれたら、永遠に感謝します.

出力をキャプチャして「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 での "Internal Server Error" 更新時の QuickBooks API エラーの呼び出し

カスタム フィールドが渡されたことは知りません。この見積もりは API を介して作成されたものです。

私にとって奇妙に見える唯一のことは、最後の Synchromized タグですが、それは intuit API エクスプローラーで動作します。編集: オンラインの Quickbooks の設定からこれを削除しましたが、それでも同じ結果が得られます。

繰り返しますが、上記の xml を取得して intuits api エクスプローラーに配置すると、完全に機能します。私の側では、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て見積もりを追加しようとしているようです。

正しい Service クラス インスタンスを使用していますか?

たまたまコードのスニペットを投稿できますか?

于 2013-09-20T17:41:41.113 に答える