QBO API添加付款错误

时间:2014-05-01 14:57:54

标签: php api quickbooks intuit-partner-platform quickbooks-online

我正在使用网络服务器上的IPP_V3连接到Quicbooks。

我正在尝试实施example_payment_add.php

通过将付款分配到发票来添加付款时,我收到了商家验证错误。

我甚至按照以下页面中的说明更改了分配值的顺序:

  

https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/payment

(最后一点:接收行的顺序是保留行的顺序。)

注意:只需向客户添加付款而不将其分配给客户,就可以了。

  

错误:   6000:[处理您的请求时出现业务验证错误,业务验证错误:意外的内部错误。 (-30035)]

代码:         

    require_once dirname(__FILE__) . '/config.php';

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

    ?>

    <pre>

    <?php

    // Set up the IPP instance
    $IPP = new QuickBooks_IPP($dsn);

    // Get our OAuth credentials from the database
    $creds = $IntuitAnywhere->load($the_username, $the_tenant);

    // Tell the framework to load some data from the OAuth store
    $IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH, 
$the_username, 
$creds);

    // Print the credentials we're using
    //print_r($creds);

    // This is our current realm
    $realm = $creds['qb_realm'];

    // Load the OAuth information from the database
    if ($Context = $IPP->context())
    {
// Set the IPP version to v3 
$IPP->version(QuickBooks_IPP_IDS::VERSION_3);

$PaymentService = new QuickBooks_IPP_Service_Payment();

// Create payment object
$Payment = new QuickBooks_IPP_Object_Payment();


$Payment->setTxnDate('2014-04-04');


// Create line for payment (this details what it's applied to)
$Line = new QuickBooks_IPP_Object_Line();
$Line->setAmount(1);

// The line has a LinkedTxn node which links to the actual invoice
$LinkedTxn = new QuickBooks_IPP_Object_LinkedTxn();
$LinkedTxn->setTxnId('10001'); //real invoice number in quickbooks
$LinkedTxn->setTxnType('Invoice');

$Line->setLinkedTxn($LinkedTxn);

$Payment->addLine($Line);

$Payment->setCustomerRef('876');
    $Payment->setPaymentRefNum('8762393');
    $Payment->setTotalAmt(1);

// Send payment to QBO 
if ($resp = $PaymentService->add($Context, $realm, $Payment))
{
    print('Our new Payment ID is: [' . $resp . ']');
}
else
{
    print($PaymentService->lastError());
}

/*
print('<br><br><br><br>');
print("\n\n\n\n\n\n\n\n");
print('Request [' . $IPP->lastRequest() . ']');
print("\n\n\n\n");
print('Response [' . $IPP->lastResponse() . ']');
print("\n\n\n\n\n\n\n\n\n");
*/  
    }
    else
    {
die('Unable to load a context...?');
    }


    ?>

    </pre>

    <?php

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

3 个答案:

答案 0 :(得分:3)

已解决:需要使用发票的交易ID而不是发票编号。

答案 1 :(得分:1)

这几乎肯定是错误的:

  

$ LinkedTxn-&GT; setTxnId(&#39; 10001&#39); //快速书中的真实发票号

您应该使用QuickBooks中发票的Id值。 Id值用户可见的Invoice reference#(DocNumber字段)不同。

您需要使用Id值。

这也没有多大意义:

  

$线 - &GT; setAmount(1);

     

...

     

$费付款,&GT; setTotalAmt(0.01);

如何将总付款金额仅为1便士,然后您尝试将全部美元应用于发票?

答案 2 :(得分:0)

使用httpSnooper工具(如fiddler)或启用devkit记录器,您应该尝试捕获原始请求和响应XML / JSON。

您可以使用ApiExplorer工具中的XML / JSON来调试此问题。

否则,您可以尝试从QBO ui创建付款并使用GetById端点检索相同的付款。这样您就可以找到付款对象的正确结构。

希望它有用。

由于

相关问题