consolibyte quickbooks php添加简单的xml

时间:2016-08-30 18:33:22

标签: php web quickbooks connector

我正在使用Quickbooks的令人敬畏的consolibyte框架,但是我在添加简单的xml请求时遇到了麻烦。我已经设置了Web连接器,它成功运行了更新,没有任何错误,但没有任何内容添加到quickbooks。我正在使用Keith的样本xml进行测试,我也尝试了自己的xml,我知道通过Quickbooks SDK成功地插入了时间。 我正在使用示例文件docs / web_connector / example_web_connector.php我也尝试了其他示例文件但是没有添加到Quickbooks中。我正在本地开发,所以不使用https。 日志文件不显示错误。有什么建议?谢谢。

sample-time.php是我要连接的文件:(我编辑了example_web_connector.php文件)。我删除了大部分评论。

它不应该排队xml并将ConsoliBYTE,LLCxxxx添加到客户列表中吗?

    <?php
// I always program in E_STRICT error mode... 
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

// We need to make sure the correct timezone is set, or some PHP installations will complain
if (function_exists('date_default_timezone_set'))
{
    // * MAKE SURE YOU SET THIS TO THE CORRECT TIMEZONE! *
    // List of valid timezones is here: http://us3.php.net/manual/en/timezones.php
    date_default_timezone_set('America/New_York');
}

// Require the framework
require_once '../QuickBooks.php';

$user = 'quickbooks';
$pass = 'password';   

// Map QuickBooks actions to handler functions
$map = array(
    QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),    
    );

// This is entirely optional, use it to trigger actions when an error is returned by QuickBooks
$errmap = array(
    3070 => '_quickbooks_error_stringtoolong',         
    );

// An array of callback hooks
$hooks = array(     
    );

// Logging level

$log_level = QUICKBOOKS_LOG_DEBUG;              

$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;        // A pure-PHP SOAP server (no PHP ext/soap extension required, also makes debugging easier)

$soap_options = array(      // See http://www.php.net/soap
    );

$handler_options = array(

    'deny_concurrent_logins' => false, 
    'deny_reallyfast_logins' => false, 
    );      // See the comments in the QuickBooks/Server/Handlers.php file

$driver_options = array(        
    );

$callback_options = array(
    );    

$dsn = 'mysql://douggie:testit@localhost/test';    

if (!QuickBooks_Utilities::initialized($dsn))
{
    // Initialize creates the neccessary database schema for queueing up requests and logging
    QuickBooks_Utilities::initialize($dsn);

    // This creates a username and password which is used by the Web Connector to authenticate
    QuickBooks_Utilities::createUser($dsn, $user, $pass);       

    $primary_key_of_your_customer = 10023;

    $Queue = new QuickBooks_WebConnector_Queue($dsn);
    $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $primary_key_of_your_customer);    
}

// Create a new server and tell it to handle the requests
// __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array()
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(true, true);    

function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{       
    // But we're just testing, so we'll just use a static test request:

    $xml = '<?xml version="1.0" encoding="utf-8"?>
        <?qbxml version="2.0"?>
        <QBXML>
            <QBXMLMsgsRq onError="stopOnError">
                <CustomerAddRq requestID="' . $requestID . '">
                    <CustomerAdd>
                        <Name>ConsoliBYTE, LLC (' . mt_rand() . ')</Name>
                        <CompanyName>ConsoliBYTE, LLC</CompanyName>
                        <FirstName>Keith</FirstName>
                        <LastName>Palmer</LastName>
                        <BillAddress>
                            <Addr1>ConsoliBYTE, LLC</Addr1>
                            <Addr2>134 Stonemill Road</Addr2>
                            <City>Mansfield</City>
                            <State>CT</State>
                            <PostalCode>06268</PostalCode>
                            <Country>United States</Country>
                        </BillAddress>
                        <Phone>860-634-1602</Phone>
                        <AltPhone>860-429-0021</AltPhone>
                        <Fax>860-429-5183</Fax>
                        <Email>Keith@ConsoliBYTE.com</Email>
                        <Contact>Keith Palmer</Contact>
                    </CustomerAdd>
                </CustomerAddRq>
            </QBXMLMsgsRq>
        </QBXML>';

    return $xml;
}    

function _quickbooks_customer_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{           
}    

function _quickbooks_salesreceipt_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
    /*
        <CustomerRef>
            <ListID>80003579-1231522938</ListID>
        </CustomerRef>  
    */

    $xml = '<?xml version="1.0" encoding="utf-8"?>
        <?qbxml version="2.0"?>
        <QBXML>
            <QBXMLMsgsRq onError="stopOnError">
                <SalesReceiptAddRq requestID="' . $requestID . '">
                    <SalesReceiptAdd>
                        <CustomerRef>
                            <FullName>Keith Palmer Jr.</FullName>
                        </CustomerRef>
                        <TxnDate>2009-01-09</TxnDate>
                        <RefNumber>16466</RefNumber>
                        <BillAddress>
                            <Addr1>Keith Palmer Jr.</Addr1>
                            <Addr3>134 Stonemill Road</Addr3>
                            <City>Storrs-Mansfield</City>
                            <State>CT</State>
                            <PostalCode>06268</PostalCode>
                            <Country>United States</Country>
                        </BillAddres>
                        <SalesReceiptLineAdd>
                            <ItemRef>
                                <FullName>Gift Certificate</FullName>
                            </ItemRef>
                            <Desc>$25.00 gift certificate</Desc>
                            <Quantity>1</Quantity>
                            <Rate>25.00</Rate>
                            <SalesTaxCodeRef>
                                <FullName>NON</FullName>
                            </SalesTaxCodeRef>
                        </SalesReceiptLineAdd>
                        <SalesReceiptLineAdd>
                            <ItemRef>
                                <FullName>Book</FullName>
                            </ItemRef>
                            <Desc>The Hitchhiker\'s Guide to the Galaxy</Desc>
                            <Amount>19.95</Amount>
                            <SalesTaxCodeRef>
                                <FullName>TAX</FullName>
                            </SalesTaxCodeRef>
                        </SalesReceiptLineAdd>
                    </SalesReceiptAdd>
                </SalesReceiptAddRq>
            </QBXMLMsgsRq>
        </QBXML>';

    return $xml;
}    

function _quickbooks_salesreceipt_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{           
}    

function _quickbooks_error_stringtoolong($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
{
    mail('your-email@your-domain.com', 
        'QuickBooks error occured!', 
        'QuickBooks thinks that ' . $action . ': ' . $ID . ' has a value which will not fit in a QuickBooks field...');
}

QWClog:

55 UTC  : QBWebConnector.WebServiceManager.DoUpdateSelected() : updateWS() for application = 'Time Keeper' has STARTED
20160830.21:31:55 UTC   : QBWebConnector.RegistryManager.getUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock = FALSE
20160830.21:31:55 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to True
20160830.21:31:55 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20160830.21:31:55 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20160830.21:31:55 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppName: Time Keeper
20160830.21:31:55 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): Time Keeper
20160830.21:31:55 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: http://localhost/quickbooks-2016/docs/sample-time.php
20160830.21:31:55 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20160830.21:31:57 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : Received from serverVersion() following parameter:<serverVersionRet="PHP QuickBooks SOAP Server v3.0 at /quickbooks-2016/docs/sample-time.php">
20160830.21:31:57 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.1.0.30">
20160830.21:32:00 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : Received from clientVersion() following parameter:<clientVersionRet="">
20160830.21:32:00 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : This application agrees with the current version of QBWebConnector. Allowing update operation.
20160830.21:32:00 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'Time Keeper', username = 'quickbooks'
20160830.21:32:00 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="quickbooks"><password=<MaskedForSecurity>
20160830.21:32:02 UTC   : QBWebConnector.SOAPWebService.updateWS() : Received from authenticate() following parameters:<authRet[0]="476baa7e-ee32-5e34-f90b-e3da55df0de5"><authRet[1]="none"><authRet[2]=""><authRet[3]="">
20160830.21:32:02 UTC   : QBWebConnector.RegistryManager.setCurrentWebServiceName() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceName has been set to Time Keeper
20160830.21:32:02 UTC   : QBWebConnector.RegistryManager.setCurrentWebServiceSessionTicket() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceSessionTicket has been set to 476baa7e-ee32-5e34-f90b-e3da55df0de5
20160830.21:32:02 UTC   : QBWebConnector.SOAPWebService.CheckCFNResponse() : No data to exchange for this application. Job ending.
20160830.21:32:02 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : Done.
20160830.21:32:02 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20160830.21:32:02 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20160830.21:32:02 UTC   : QBWebConnector.WebServiceManager.DoUpdateSelected() : No data to exchange for the application:  Time Keeper

0 个答案:

没有答案