来自ReceivePaymentAddRq的3120错误 - php devkit

问题描述 投票:0回答:1

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

问题是快速书没有回应,也没有问题。我检查了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();

编辑:VERBOSE LOG

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.

quickbooks
1个回答
1
投票

没有看到日志(Web连接器登录VERBOSE模式以及quickbooks_log SQL表输出)这里很难说清楚这里有什么问题,但这里至少要检查一些事情:

你确定你没有收到QuickBooks的回复吗?

您指出“问题是没有来自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>

但是当我查看你的代码时,$memo是未定义的。这让我怀疑您粘贴的XML不是您发送给QuickBooks的实际XML。

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

这也应该导致关于未定义变量的PHP错误/警告,这可能会破坏事物。

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

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

6.检查quickbooks_log和quickbooks_queue表

他们表示/说什么?

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

© www.soinside.com 2019 - 2024. All rights reserved.