与QuickBooks集成时出错

时间:2015-12-10 12:45:49

标签: php quickbooks-online

我正在与PHP系统集成,因此我可以在QuickBooks中启动销售。要使用API​​集成,请提供此链接https://github.com/consolibyte/quickbooks-php

按照指示设置所有内容,但是当您进行销售时,我收到以下错误:

2020: [Required param missing, need to supply the required value for the API, Required parameter Line.DetailType is missing in the request]

生成发票的类目前如下:

<?php

require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';

?>

<pre>

    <?php

    $InvoiceService = new QuickBooks_IPP_Service_Invoice();
    $Invoice        = new QuickBooks_IPP_Object_Invoice();

    $Invoice->setDocNumber('WEB' . mt_rand(0, 10000));
    $Invoice->setTxnDate('2015-12-10');

    $Line = new QuickBooks_IPP_Object_Line();
    $Line->setDetailType('Example');
    $Line->setAmount(12.95 * 2);
    $Line->setDescription('Example');

    $SalesItemLineDetail = new QuickBooks_IPP_Object_SalesItemLineDetail();
    $SalesItemLineDetail->setItemRef('8');
    $SalesItemLineDetail->setUnitPrice(12.95);
    $SalesItemLineDetail->setQty(2);

    $Line->addSalesItemLineDetail($SalesItemLineDetail);

    $Invoice->addLine($Line);

    $Invoice->setCustomerRef('67');

    if ($resp = $InvoiceService->add($Context, $realm, $Invoice))
    {
        print('Our new Invoice ID is: [' . $resp . ']');
    }
    else
    {        
        print($InvoiceService->lastError());
    }

    ?>

</pre>

<?php

require_once dirname(__FILE__) . '/views/footer.tpl.php';

有人遇到过这个问题吗?

我真的需要帮助,因为他们对QuickBooks了解不多。

谢谢,

1 个答案:

答案 0 :(得分:0)

此错误:

Required parameter Line.DetailType is missing in the request

表示您在请求中缺少名为Line.DetailType的必需参数。更具体地说 - 在您的情况下,您实际上是为此参数发送无效值

$Line->setDetailType('Example');

^^^无效。请花点时间参考Intuit的文档:

花时间参考示例:

并注意到文档/示例显示正确的值是:

// Set to SalesItemLineDetailfor this type of line.
$Line->setDetailType('SalesItemLineDetail');