简体   繁体   English

QBO API添加付款错误

[英]QBO API Add Payment error

I'm connecting to Quicbooks using IPP_V3 from my webserver. 我正在从Web服务器使用IPP_V3连接到Quicbooks。

I'm trying to implement the example_payment_add.php 我正在尝试实施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 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. 错误:6000:[处理您的请求时发生业务确认错误,业务验证错误:意外的内部错误。 (-30035)] (-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("\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';

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

This is almost certainly incorrect: 几乎可以肯定这是不正确的:

$LinkedTxn->setTxnId('10001'); $ LinkedTxn-> setTxnId( '10001'); //real invoice number in quickbooks //快速手册中的实际发票号

You should be using the Id value from the invoice in QuickBooks. 您应该使用QuickBooks中发票的Id值。 The Id value is different from the user-visible Invoice reference # (the DocNumber field). 的ID值是所述用户可见的发票参考#(在DocNumber字段) 的不同

You need to use the Id value. 您需要使用Id值。

This also doesn't make a whole lot of sense: 这也不是很有意义:

$Line->setAmount(1); $设备 - > setAmount(1);

... ...

$Payment->setTotalAmt(0.01); $费付款> 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? 总付款额如何只有1便士,然后您尝试在发票上加上一整美元?

Using a httpSnooper tool(like fiddler) or by enabling the devkit logger, you should try to capture the raw request and response XML/JSON. 使用httpSnooper工具(如fiddler)或启用devkit记录器,您应该尝试捕获原始请求和响应XML / JSON。

You can use the XML/JSON in ApiExplorer tool to debug this issue. 您可以在ApiExplorer工具中使用XML / JSON来调试此问题。

Otherwise, you can try to create a payment from QBO ui and retrieve the same using GetById endpoint. 否则,您可以尝试从QBO ui创建付款,并使用GetById端点检索付款。 That way you can find out the correct structure of the payment object. 这样,您可以找到付款对象的正确结构。

Hope it will useful. 希望它会有用。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM