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:
(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("\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';
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?