QUICKBOOKS_ADD_CUSTOMER 函数不触发(“无数据交换”)

QUICKBOOKS_ADD_CUSTOMER function doesn't trigger (“no data exchange”)

我正在尝试将我的 OpenCart 与 QB Desktop 同步。 但它不起作用。 QB Web 连接器显示 "no data exchange"。

这是我的代码:

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

$errmap = array(
    '*' => '_quickbooks_error_catchall',
);

$hooks = array();

$log_level = QUICKBOOKS_LOG_DEVELOP;

$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN
$soap_options = array();

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

$driver_options = array(        // See the comments in the QuickBooks/Driver/<YOUR DRIVER HERE>.php file ( i.e. 'Mysql.php', etc. )
    'max_log_history' => 32000, // Limit the number of quickbooks_log entries  to 1024
    'max_queue_history' => 1024,    // Limit the number of *successfully processed* quickbooks_queue entries to 64
);

$callback_options = array();

// Set up our queue singleton
QuickBooks_WebConnector_Queue_Singleton::initialize($dsn);

$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)
{
// Grab the data from our MySQL database
$arr = array(
    'name' => 'opencart' . date('ymdhis'),
    'fname' => 'opencart'. date('ymdhis'),
    'lname' => 'opencart'. date('ymdhis'),
);

$xml = '<?xml version="1.0" encoding="utf-8"?>
    <?qbxml version="2.0"?>
    <QBXML>
        <QBXMLMsgsRq onError="stopOnError">
            <CustomerAddRq requestID="' . $requestID . '">
                <CustomerAdd>
                    <Name>' . $arr['name'] . '</Name>
                    <CompanyName>' . $arr['name'] . '</CompanyName>
                    <FirstName>' . $arr['fname'] . '</FirstName>
                    <LastName>' . $arr['lname'] . '</LastName>
                </CustomerAdd>
            </CustomerAddRq>
        </QBXMLMsgsRq>
    </QBXML>';

return $xml;
}

这是我的测试 handle.php 代码,用于排队新客户:

if (isset($_GET['customer_id']))
{
    $id = intval($_GET['customer_id']);

    // Queue up the customer add

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

    die('Great, queued up a customer!');
}

它向数据库添加了一条新记录:

quickbooks_queue_id = 609
quickbooks_ticket_id = null
qb_username = someuser
qb_action = CustomerAdd
ident = 123456
extra = empty
qbxml = empty
priority = 0
qb_status = q
enqueue_datetime = 2016-02-02 20:58:50
dequeue_datetime = null

Web 连接器日志:

20160204.06:45:32 UTC   : QBWebConnector.WebServiceManager.DoUpdateSelected() : updateWS() for application = 'QuickBooks Bridge for OpenCart' has STARTED
20160204.06:45:32 UTC   : QBWebConnector.RegistryManager.getUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock = FALSE
20160204.06:45:32 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to True
20160204.06:45:32 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppName: QuickBooks Bridge for OpenCart
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): QuickBooks Bridge for OpenCart
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: https://example.com/qbwc.php
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : Received from serverVersion() following parameter:<serverVersionRet="PHP QuickBooks SOAP Server v3.0 at /wce/qbwc.php">
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.2.0.34">
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : Received from clientVersion() following parameter:<clientVersionRet="">
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : This application agrees with the current version of QBWebConnector. Allowing update operation.
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'QuickBooks Bridge for OpenCart', username = 'someuser'
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="someuser"><password=<MaskedForSecurity>
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.updateWS() : Received from authenticate() following parameters:<authRet[0]="1c44d47f-1542-1854-3d22-0d9569718c76"><authRet[1]="13355f1b-4b26-4a7b-b182-15c6dd1246f9"><authRet[2]="1"><authRet[3]="">
20160204.06:45:33 UTC   : QBWebConnector.RegistryManager.setCurrentWebServiceName() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceName has been set to QuickBooks Bridge for OpenCart
20160204.06:45:33 UTC   : QBWebConnector.RegistryManager.setCurrentWebServiceSessionTicket() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceSessionTicket has been set to 1c44d47f-1542-1854-3d22-0d9569718c76
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.CheckCFNResponse() : User authenticated.
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.HandleDelayRequest() : Update has been postponed at 2/3/2016 10:45:33 PM by 'QuickBooks Bridge for OpenCart' for next 60 seconds
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : Done.
20160204.06:45:33 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20160204.06:45:33 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20160204.06:45:33 UTC   : QBWebConnector.WebServiceManager.DoUpdateSelected() : No data to exchange for the application:  QuickBooks Bridge for OpenCart

我在 _quickbooks_customer_add_request 中添加了一个 die() 但它忽略了这个函数。

有人知道怎么解决吗?谢谢。

任何时候您得到 "No data exchange required.",这意味着 Web 连接器要处理的队列中没有任何内容,或者您​​的某些配置严重错误。

由于您 quickbooks_queue table 中有记录,我的第一个猜测是 Web 连接器作为 不同于队列中的用户 table。

您能确认您使用的.QWC 文件使用的是这个用户名吗?

someuser

除此之外,您配置有误。根据您的日志,您似乎配置有误。具体来说:

qb_company_file: 13355f1b-4b26-4a7b-b182-15c6dd1246f9;

这应该是指向您的 QuickBooks 公司文件的 文件路径 (在 QuickBooks 中按 F2 键可以看到它)或者它应该是空的。该值绝对不是有效的 Windows 文件路径。

另外,这个:

qwbc_min_run_every_n_seconds: 60

删除这个。除非你有非常好的、非常具体的理由,否则你也不应该拥有这个集合。它与多个版本的 Web 连接器不兼容。

您是否遵循了快速入门指南?如果您有...

,您就不会 运行 陷入这些问题