【问题标题】:QBO API Add Payment errorQBO API 添加支付错误
【发布时间】:2014-05-01 14:57:54
【问题描述】:

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

我正在尝试实现example_payment_add.php

通过将付款分配给发票来添加付款时,我遇到了业务验证错误。

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

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

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

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

错误: 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';

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 有什么方法可以使用发票编号代替交易编号?
    • 不,您需要在引用客户、发票、付款等时使用 ID #。
    【解决方案2】:

    这几乎肯定是不正确的:

    $LinkedTxn->setTxnId('10001'); //quickbooks中的真实发票号码

    您应该在 QuickBooks 中使用发票中的 Id 值。 Id 值不同于用户可见的发票参考号(DocNumber 字段)。

    您需要使用 Id 值。

    这也没有多大意义:

    $Line->setAmount(1);

    ...

    $Payment->setTotalAmt(0.01);

    总付款金额怎么可能只有1美分,然后你尝试套用一整美元的发票?

    【讨论】:

    • 谢谢,基思!修复了疏忽的金额差异。
    【解决方案3】:

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

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

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

    希望有用。

    谢谢

    【讨论】:

    • 没有必要。他可以通过调用 print($IPP->lastRequest()); 来获取原始请求/响应。并打印($IPP->lastResponse());
    猜你喜欢
    • 2015-04-22
    • 1970-01-01
    • 2021-02-08
    • 1970-01-01
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多