2
votes

I am using Keith Palmer's nice php framework: docs/example_online_edition.php to interact with a Quickbooks Online Edition account.

I am able to retrieve invoice information, and enter a Vendor record (default example behavior), but I can't enter an invoice.

I have downloaded the sdk v12 validator, and validated my xml, but no invoice appears in quickbooks. Here is the output of my webpage with signon credentials removed. I have print statements in Gateway/OnlineEdition.php just before the curl. without the print statements, I cannot see the request msg xml.

XXXXX php code with connection information removed: XXXXX

<?php

    /**
     * Example of connecting to QuickBooks Online edition via qbXML
     * 
     * IMPORTANT: 
     *  IF YOU ARE BUILDING A SAAS APPLICATION (E.G. YOU ARE ALLOWING MANY OF YOUR 
     *  CUSTOMERS TO CONNECT THEIR COMPANY FILES TO YOUR WEB APPLICATION) THEN THIS 
     *  IS PROBABLY *NOT* THE FILE YOU SHOULD LOOKING AT. You should look at the 
     *  Intuit Partner Platform (and thus the corresponding docs/example_ipp_*.php 
     *  scripts) in this package.
     * 
     * 
     * 
     * @author Keith Palmer <[email protected]>
     * 
     * @package QuickBooks
     */

    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    header('Content-Type: text/plain');

    require_once dirname(__FILE__) . '/../QuickBooks.php';


    // Register in DESKTOP mode to get these. Docs: 
    //  http://www.consolibyte.com/docs/index.php/QuickBooks_Online_via_qbXML#Connecting_with_the_.27Desktop.27_model_of_communication
    $application_id = 'goodid';
    $application_login = 'goodLogin';
    $connection_ticket = 'goodTicket';

    // Create our new gateway instance 
    $Gateway = new QuickBooks_Gateway_OnlineEdition(
        $application_id,
        $application_login,
        $connection_ticket);

    // Get RefNumber 1014
    $xml =
    '<QBXMLMsgsRq onError="stopOnError">
        <InvoiceQueryRq>
            <RefNumber>1014</RefNumber>
        </InvoiceQueryRq>
    </QBXMLMsgsRq>';

    // Send the request
    $resp = $Gateway->qbxml($xml);

    print($resp);
    print("\n\n\n\n");


    $xml = '<QBXMLMsgsRq onError="stopOnError">
            <InvoiceAddRq requestID="1">
                <InvoiceAdd>
                    <CustomerRef>
                        <ListID>2</ListID>
                    </CustomerRef>
                    <InvoiceLineAdd>
                        <ItemRef>
                            <FullName>Sales</FullName>
                        </ItemRef>
                        <Desc>Item1escriptionGoesHere</Desc>
                        <Amount>29.50</Amount>
                    </InvoiceLineAdd>
                </InvoiceAdd>
            </InvoiceAddRq>
            </QBXMLMsgsRq>';


    // Send the request
    $resp = $Gateway->qbxml($xml);

    print($resp);

    print('\n\n\n\nLast print in file');

?>

XXXXX End php code XXXXX

XXXXX Start of output (with signon removed) XXXXX

<?xml version="1.0" ?>
<?qbxml version="6.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
    <InvoiceQueryRq>
        <RefNumber>1014</RefNumber>
    </InvoiceQueryRq>
</QBXMLMsgsRq></QBXML>

XXXXX successful response:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE QBXML PUBLIC "-//INTUIT//DTD QBXML QBO 6.0//EN" "http://apps.quickbooks.com/dtds/qbxmlops60.dtd">
<QBXML>
 <QBXMLMsgsRs>
  <InvoiceQueryRs statusCode="0" statusMessage="Status OK" statusSeverity="Info">
   <InvoiceRet>
    <TxnID>19</TxnID>
    <TimeCreated>2013-09-11T21:06:33</TimeCreated>
    <TimeModified>2013-09-11T21:17:54</TimeModified>
    <EditSequence>0</EditSequence>
    <TxnNumber>19</TxnNumber>
    <CustomerRef>
     <ListID>3</ListID>
     <FullName>Willy Wonka #442:Bertha Linebacker</FullName>
    </CustomerRef>
    <ARAccountRef>
     <ListID>48</ListID>
     <FullName>Accounts Receivable (A/R)</FullName>
    </ARAccountRef>
    <TxnDate>2013-09-11</TxnDate>
    <RefNumber>1014</RefNumber>
    <BillAddress>
     <Addr1>111 Main</Addr1>
     <City>Denver</City>
     <State>CO</State>
     <PostalCode>98310</PostalCode>
    </BillAddress>
    <ShipAddress>
     <Addr1>111 Main</Addr1>
     <City>Denver</City>
     <State>CO</State>
     <PostalCode>98310</PostalCode>
    </ShipAddress>
    <DueDate>2013-09-26</DueDate>
    <Subtotal>70.00</Subtotal>
    <SalesTaxPercentage>0</SalesTaxPercentage>
    <AppliedAmount>0.00</AppliedAmount>
    <BalanceRemaining>70.00</BalanceRemaining>
    <IsPaid>false</IsPaid>
    <IsToBePrinted>true</IsToBePrinted>
    <InvoiceLineRet>
     <TxnLineID>1</TxnLineID>
     <ItemRef>
      <ListID>1</ListID>
      <FullName>Sales</FullName>
     </ItemRef>
     <Desc>tire storage (season)
RO# 57, Bertha</Desc>
     <Amount>70.00</Amount>
     <IsTaxable>false</IsTaxable>
    </InvoiceLineRet>
   </InvoiceRet>
  </InvoiceQueryRs>
 </QBXMLMsgsRs>
</QBXML>

XXXXX Request to add an invoice: Note customer '2' is a valid customer

<?xml version="1.0" ?>
<?qbxml version="6.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
        <InvoiceAddRq requestID="1">
            <InvoiceAdd>
                <CustomerRef>
                    <ListID>2</ListID>
                </CustomerRef>
                <InvoiceLineAdd>
                    <ItemRef>
                        <FullName>Sales</FullName>
                    </ItemRef>
                    <Desc>Item1escriptionGoesHere</Desc>
                    <Amount>29.50</Amount>
                </InvoiceLineAdd>
            </InvoiceAdd>
        </InvoiceAddRq>
        </QBXMLMsgsRq></QBXML>
        </QBXMLMsgsRq></QBXML>
    [41] => 
    [42] => 1
    [64] => 
    [81] => 0
)




\n\n\n\nLast print in file

XXXXXXXXX end of output

The server apparently gives no response to the addInvoice request.

Any help in solving this mystery would be greatly appreciated!

Also, assuming I can eventually enter an invoice, will I be able to write the and fields that I can in the IPP API? The following error message I got at one point is not very encouraging:

org.xml.sax.SAXParseException: The content of element type "InvoiceAdd" must match "(CustomerRef,ClassRef?,ARAccountRef?,TemplateRef?,TxnDate?,RefNumber?,BillAddress?,ShipAddress?,IsPending?,PONumber?,TermsRef?,DueDate?,SalesRepRef?,FOB?,ShipDate?,ShipMethodRef?,ItemSalesTaxRef?,Memo?,CustomerMsgRef?,IsToBePrinted?,IsToBeEmailed?,IsTaxIncluded?,CustomerSalesTaxCodeRef?,Other?,LinkToTxnID*,(InvoiceLineAdd|InvoiceLineGroupAdd)*,DiscountLineAdd?,SalesTaxLineAdd?,ShippingLineAdd?)"

Thank you very much!

1
Try also specifying the TxnDate, RefNumber, and Quantity fields and see if you have better luck. I've seen the qbXML API timeout if you don't include some fields sometimes. The error message you got back is telling you to either missed a required field, or you sent XML node data in the wrong order.Keith Palmer Jr.

1 Answers

1
votes

Try this

<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="5.0"?>
<QBXML>
    <QBXMLMsgsRq onError="continueOnError">
        <InvoiceAddRq requestID="SW52b2ljZUFkZHw1NA==">
            <InvoiceAdd>
                <CustomerRef>
                    <ListID>90001-1263558758</ListID>
                    <FullName>Testy McTesterson</FullName>
                </CustomerRef>
                <TxnDate>2010-01-15</TxnDate>
                <RefNumber>21011</RefNumber>
                <BillAddress>
                    <Addr1>ConsoliBYTE, LLC</Addr1>
                    <Addr2>134 Stonemill Road</Addr2>
                    <Addr3 />
                    <City>Mansfield</City>
                    <State>CT</State>
                    <PostalCode>06268</PostalCode>
                    <Country>United States</Country>
                </BillAddress>
                <ShipAddress>
                    <Addr1>ConsoliBYTE, LLC</Addr1>
                    <Addr2>Attn: Keith Palmer</Addr2>
                    <Addr3>56 Cowles Road</Addr3>
                    <City>Willington</City>
                    <State>CT</State>
                    <PostalCode>06279</PostalCode>
                    <Country>United States</Country>
                </ShipAddress>
                <TermsRef>
                    <FullName>Net 30</FullName>
                </TermsRef>
                <SalesRepRef>
                    <FullName>KRP</FullName>
                </SalesRepRef>
                <Memo>Test memo goes here.</Memo>
                <InvoiceLineAdd>
                    <ItemRef>
                        <FullName>test</FullName>
                    </ItemRef>
                    <Desc>Test item description</Desc>
                    <Quantity>1.00000</Quantity>
                    <Rate>15.00000</Rate>
                </InvoiceLineAdd>
            </InvoiceAdd>
        </InvoiceAddRq>
    </QBXMLMsgsRq>
</QBXML>

You can integrate your Authorize.net Invoice ( http://www.fetchflow.com/blog/how-do-i-integrate-payments-with-authorize-net ) account with fetchflow.com so your clients can pay you online via the Web Invoice.