来自 ReceivePaymentAddRq 的 3120 错误 - php devkit

3120 error from ReceivePaymentAddRq - php devkit

我在此处添加使用 php devkit 接收付款 https://github.com/consolibyte/quickbooks-php

问题是quickbooks没有反应,也没有问题。我检查了 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 &quot;28CA9-1702576301&quot; 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.

如果不查看日志(Web 连接器以 VERBOSE 模式登录以及 quickbooks_log SQL table 输出),很难说出这里到底出了什么问题,但是这里至少有几件事要检查:

1.您确定没有收到 QuickBooks 的回复吗?

您指出 "The problem is no response from the 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 ...
    );

(来自 https://github.com/consolibyte/quickbooks-php/blob/master/docs/web_connector/example_web_connector.php

可能调用的是错误处理程序而不是您的响应函数?

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>

但是当我查看您的代码时,$memoundefined。这让我怀疑您在此处粘贴的 XML 是 而不是 您发送到 QuickBooks 的实际 XML。

该变量在哪里设置为 Paid In Full?它没有在您粘贴的代码中的任何位置设置。

这也应该导致关于未定义变量的 PHP error/warning,这可能会破坏某些东西。

5.确保您的 Web 连接器处于 VERBOSE 模式

Web 连接器中的 VERBOSE 模式显示更多数据。您应该能够轻松找到有问题的请求和 analyze/post 相关日志。

6.检查 quickbooks_log 和 quickbooks_queue tables

他们show/say做什么?

排队记录 (quickbooks_queue SQL table) 的状态(qb_status 字段)和消息是什么?