1

我正在尝试使用 keith palmer php api 通过我的应用程序向 quickbook 添加发票

我能够添加客户,列出发票并从中做很多事情..

但是当我尝试使用基本示例添加发票时,它不会被创建..

这是我的代码片段

    <?php

        $Invoice = new QuickBooks_IPP_Object_Invoice();
        $Header = new QuickBooks_IPP_Object_Header();


        $Header->setTxnDate('2013-03-20');
        $Header->setCustomerId('{QBO-2}');

        $Header->setTotalAmt(101);

        $Invoice->addHeader($Header);

        $Line = new QuickBooks_IPP_Object_Line();
        $Line->setDesc('Invoice desp comes here');
        $Line->setTaxable('false');
        $Line->setItemId('{QBO-2}');
        $Line->setAmount(101);

        $Invoice->addLine($Line);

        print_r($Invoice->asIDSXML());

        print_r('Request [' . $IPP->lastRequest() . ']');
        print_r("<br/><br/>");
        print_r('Response [' . $IPP->lastResponse() . ']');
        print_r("<br/><br/>");

?>  

print_r($Invoice->asIDSXML()) 给我看这个

<Invoice>
    <Header>
        <TxnDate>2013-03-20</TxnDate>
        <CustomerId idDomain="QBO">2</CustomerId>
        <TotalAmt>101.00</TotalAmt>
    </Header>
    <Line>
        <Desc>test input invoice descp comes here</Desc>
        <Amount>101</Amount>
        <Taxable>false</Taxable>
        <ItemId idDomain="QBO">2</ItemId>
    </Line>
</Invoice>

print_r('Request [' . $IPP->lastRequest() . ']') 给我看这个

Request [GET https://qbo.intuit.com/qbo1/rest/user/v2/666328865?oauth_consumer_key=qyprdorhgMjAeQswpCnBBuFUt5NGlv&oauth_nonce=GCRwB&oauth_signature=FKjWjA8VSwtxKvn%2ByGb1LaYd7Kw%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1363757537&oauth_token=qyprdmoCHU437qAutsaqwMzki7izqqjl7cioaZO4uTxkykse&oauth_version=1.0 HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 0

]

print_r('Response [' . $IPP->lastResponse() . ']') 告诉我这个

Response [HTTP/1.1 200 OK
Date: Wed, 20 Mar 2013 05:32:17 GMT
Server: Apache
Set-Cookie: qboeuid=10.129.32.5.1363757537351379; path=/; expires=Thu, 20-Mar-14 05:32:17 GMT; domain=.intuit.com
Cache-Control: private
Expires: Wed, 31 Dec 1969 16:00:00 PST
Set-Cookie: JSESSIONID=3BC45AC1AAA82F57D777FF1DAB2F9729.c1-pprdqboas30d; Path=/; Secure; HttpOnly
Content-Encoding: gzip
Content-Length: 290
Content-Type: application/xml;charset=UTF-8

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><qbo:QboUser xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo"><qbo:LoginName>jeffery@netconnectweb.com</qbo:LoginName><qbo:Ticket>V1-48-Q0czg6etf4a8rhn9mxnc5a</qbo:Ticket><qbo:AgentId>666328880</qbo:AgentId><qbo:CurrentCompany><qbo:CompanyId>666328865</qbo:CompanyId><qbo:BaseURI>https://sg.qbo.intuit.com/qbo37</qbo:BaseURI></qbo:CurrentCompany></qbo:QboUser>]
4

1 回答 1

3

我的问题是我没有为此添加相应的服务对象以使其生效,下面给出的代码片段现在可以完美运行....

<?php

    $InvoiceService = new QuickBooks_IPP_Service_Invoice();
    $Invoice = new QuickBooks_IPP_Object_Invoice();
    $Header = new QuickBooks_IPP_Object_Header();


    $Header->setTxnDate('2013-03-20');
    $Header->setCustomerId('{QBO-2}');
    $Header->setTotalAmt(101);

    $Invoice->addHeader($Header);

    $Line = new QuickBooks_IPP_Object_Line();
    $Line->setDesc('Invoice desp comes here');
    $Line->setTaxable('false');
    $Line->setItemId('{QBO-2}');
    $Line->setAmount(101);

    $Invoice->addLine($Line);

    print_r($Invoice->asIDSXML());

    $resp = $InvoiceService->add($Context, $realmID, $Invoice);

    pr('New invoice is [' . $resp . ']' . "\n");

    print_r('Request [' . $IPP->lastRequest() . ']');
    print_r("<br/><br/>");
    print_r('Response [' . $IPP->lastResponse() . ']');
    print_r("<br/><br/>");

?>
于 2013-03-20T06:40:36.180 回答