dongshan1396 2014-05-01 14:57
浏览 48
已采纳

QBO API添加付款错误

I'm connecting to Quicbooks using IPP_V3 from my webserver.

I'm trying to implement the example_payment_add.php

I'm getting a Business validation error when adding payment by assigning it to an invoice.

I even changed the order in which the values are assigned as instructed in the below page:

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

(Last point: The sequence in which the Lines are received is the sequence in which lines are preserved.)

Note: Just adding a payment to a customer, without assigning it to a customer, is working.

Error: 6000: [A business validation error has occurred while processing your request, Business Validation Error: Unexpected Internal Error. (-30035)]

Code:

    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("







");
print('Request [' . $IPP->lastRequest() . ']');
print("



");
print('Response [' . $IPP->lastResponse() . ']');
print("








");
*/  
    }
    else
    {
die('Unable to load a context...?');
    }


    ?>

    </pre>

    <?php

    require_once dirname(__FILE__) . '/views/footer.tpl.php';
  • 写回答

3条回答 默认 最新

  • doushai7225 2014-05-01 19:04
    关注

    This is almost certainly incorrect:

    $LinkedTxn->setTxnId('10001'); //real invoice number in quickbooks

    You should be using the Id value from the invoice in QuickBooks. The Id value is different from the user-visible Invoice reference # (the DocNumber field).

    You need to use the Id value.

    This also doesn't make a whole lot of sense:

    $Line->setAmount(1);

    ...

    $Payment->setTotalAmt(0.01);

    How can the total payment amount be only 1 penny, and then you try to apply a full dollar to the invoice?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码