我在这里https://github.com/consolibyte/quickbooks-php使用php devkit添加收款。
问题是快速手册没有响应,也没有问题。我检查了Web连接器日志和php日志文件。 但是响应函数从未被调用过。
我敢肯定,直到几天前,它都能正常工作。 我不知道确切的问题是什么。
qbxml版本:10.0
请求xml:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="10.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<ReceivePaymentAddRq requestID="153">
<ReceivePaymentAdd>
<CustomerRef >
<FullName >Duncan, Dave</FullName>
</CustomerRef>
<TxnDate >2023-12-15</TxnDate>
<RefNumber>Wire</RefNumber>
<TotalAmount>2585.00</TotalAmount>
<PaymentMethodRef><FullName>Check</FullName></PaymentMethodRef>
<Memo>Paid In Full</Memo>
<AppliedToTxnAdd>
<TxnID>28CA9-1702576301</TxnID>
<PaymentAmount >2585.00</PaymentAmount>
</AppliedToTxnAdd>
</ReceivePaymentAdd>
</ReceivePaymentAddRq>
</QBXMLMsgsRq>
</QBXML>
php脚本:
$map = array(
QUICKBOOKS_ADD_RECEIVE_PAYMENT => array( '_quickbooks_payment_add_request', '_quickbooks_payment_add_response' ));
$errmap = array(
// QUICKBOOKS_IMPORT_CUSTOMER => '_quickbooks_customer_query_error',
'*' => '_quickbooks_error_catchall', // Catch any other errors that might occur
..
$hooks = array(
QuickBooks_WebConnector_Handlers::HOOK_LOGINSUCCESS => '_quickbooks_sync_to_qb', // call this whenever a successful login occurs
);
function _quickbooks_sync_to_qb($requestID, $user, $hook, &$err, $hook_data, $callback_config)
{
$database = new Database();
$db = $database->getConnection();
$Queue = new QuickBooks_WebConnector_Queue($database->dsn);
$payment = new Payment($db);
$payment->needSync = true;
$stmt = $payment->read();
$num = $stmt->rowCount();
if ($num > 0) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$Queue->enqueue(QUICKBOOKS_ADD_RECEIVE_PAYMENT, $row['id']);
}
}
$database->destroy();
}
function _quickbooks_payment_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{error_log('start from here');
$database = new Database();
$db = $database->getConnection();
// Grab the data from our MySQL database
$payment = new Payment($db);
$payment->id = (int) $ID;
error_log('1');
// Validation
$stmt = $payment->read();
$num = $stmt->rowCount();
if ($num > 0) {error_log('2');
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
// get trasaction id from invoice
$invoice = new Invoice($db);
$invoice->refNumber = $invoice_ref_number;
error_log('21');
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="10.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<ReceivePaymentAddRq>
<ReceivePaymentAdd>';
if ($customer_ref_listid != '' || $customer_ref_fullname != '') {
$xml .= '<CustomerRef >';
if ($customer_ref_listid != '') {
$xml .= '<ListID >' . $customer_ref_listid . '</ListID>';
// invoice customer ref listid
$invoice->customerRefListID = $customer_ref_listid;
}
if ($customer_ref_fullname != '') {
$xml .= '<FullName >' . $customer_ref_fullname . '</FullName>';
// invoice customer ref fullname
$invoice->customerRefFullName = $customer_ref_fullname;
}
$xml .= '</CustomerRef>';
}
$stmt = $invoice->read();
$num = $stmt->rowCount();
$txnID = '';
$txnDate = '';
if ($num > 0) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$txnID = $row['txn_id'];
$txnDate = date_format(date_create($row['txn_date']), 'Y-m-d');
}
}
$xml .= '<TxnDate >' . $txnDate . '</TxnDate>
<RefNumber>' . $ref_number . '</RefNumber>
<TotalAmount>' . $total_amount . '</TotalAmount>
<PaymentMethodRef>';
if (!empty($payment_method_ref_listid)) {
$xml .= '<ListID>' . $payment_method_ref_listid . '</FullName>';
}
if (!empty($payment_method_ref_fullname)) {
$xml .= '<FullName>' . $payment_method_ref_fullname . '</FullName>';
}
$xml .= '</PaymentMethodRef>
<Memo>' . $memo . '</Memo>
<AppliedToTxnAdd>
<TxnID>' . $txnID . '</TxnID>
<PaymentAmount >' . $total_amount . '</PaymentAmount>
</AppliedToTxnAdd>
</ReceivePaymentAdd>
</ReceivePaymentAddRq>
</QBXMLMsgsRq>
</QBXML>';
error_log('22');
}
error_log('3');
$database->destroy();
error_log('4');
error_log($xml);
return $xml;
}
error_log('5');
$database->destroy();
return false;
}
即使已正确注册,此功能似乎也未调用。
function _quickbooks_payment_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{error_log('_quickbooks_payment_add_response');
$database = new Database();
编辑: 详细记录
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : qbNationality="US"
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : qbXMLMajorVers="13"
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : qbXMLMinorVers="0"
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : Received from sendRequestXML() following parameter:
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : strRequestXML =
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : XML dump follows: -
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="10.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<ReceivePaymentAddRq requestID="158">
<ReceivePaymentAdd><CustomerRef ><FullName >Duncan, Dave</FullName></CustomerRef><RefNumber>Wire</RefNumber>
<TotalAmount>2585.00</TotalAmount>
<PaymentMethodRef><FullName>Check</FullName></PaymentMethodRef>
<Memo>Paid In Full</Memo>
<AppliedToTxnAdd>
<TxnID>28CA9-1702576301</TxnID>
<PaymentAmount >2585.00</PaymentAmount>
</AppliedToTxnAdd>
</ReceivePaymentAdd>
</ReceivePaymentAddRq>
</QBXMLMsgsRq>
</QBXML>
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_sendRequestXML() : Request xml received.
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Processing request #1
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : REQUEST: received from application: size (bytes) = 666
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Sending request to QuickBooks.
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Response received from QuickBooks: size (bytes) = 245
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.ProcessRequestXML() : Sending response back to application.
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : *** Calling receiveResponseXML() with following parameters:
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : wcTicket="35382423-f97d-5fc4-3935-d4a7629367a8"
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : response =
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : XML dump follows: -
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<ReceivePaymentAddRs requestID="158" statusCode="3120" statusSeverity="Error" statusMessage="Object "28CA9-1702576301" specified in the request cannot be found. " />
</QBXMLMsgsRs>
</QBXML>
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : hresult=""
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : message=""
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : Received from receiveResponseXML() following parameters:
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : more="100">
20190327.20:42:17 UTC : QBWebConnector.SOAPWebService.do_receiveResponseXML() : Done. No more to process.
答案 0 :(得分:1)
很难不看日志(确切地说是VERBOSE
模式下的Web连接器日志以及quickbooks_log
SQL表输出),确切地说出了这里的问题,但是这里至少要检查一些事情:< / p>
1。您确定没有收到QuickBooks的回复吗?
您指出“问题是快速手册没有响应”,但此处可能不是实际情况。
您是否已验证在实际日志中未得到答复?例如,如果发生错误(例如,可能客户或发票不存在),则QuickBooks将发回错误,但不会调用您的响应函数-错误处理程序将被调用。
您的代码中是否有类似的内容?
$errmap = array(
3070 => '_quickbooks_error_stringtoolong', // Whenever a string is too long to fit in a field, call this function: _quickbooks_error_stringtolong()
// ... more error handlers here ...
);
也许调用了错误处理程序而不是响应函数?
2。您没有传递requestID =“ ...”属性
Web连接器在XML中使用requestID="..."
属性,以便能够将传出的请求与传入的响应进行匹配。您没有使用它,但是应该使用它。
更改此:
<ReceivePaymentAddRq>
对此:
<ReceivePaymentAddRq requestID="' . $requestID . '">
了解更多:
3。您不是XML编码值
为此:
<Memo>' . $memo . '</Memo>
如果将$memo
设置为bla bla <something> bla bla
,那么您将得到格式错误的XML:
<Memo>bla bla <something bla bla</Memo>
您应该对这些值进行XML编码。
4。 $ memo变量未定义
您是说您生成的XML如下所示:
<Memo>Paid In Full</Memo>
但是,当我查看您的代码时,$memo
是未定义。这使我怀疑您粘贴在此处的XML是不是您要发送给QuickBooks的实际XML。
该变量在哪里设置为Paid In Full
?在您粘贴的代码中没有设置它。
这也应该引起PHP错误/警告未定义的变量,这可能会破坏事情。
5。确保您的Web连接器处于VERBOSE模式
Web连接器中的VERBOSE模式显示更多数据。您应该能够轻松找到有问题的请求并分析/发布相关日志。
6。检查quickbooks_log和quickbooks_queue表
他们显示/说出什么?
排队的记录(qb_status
SQL表)上的状态(quickbooks_queue
字段)和消息是什么?