I'm doing an integration with PHP my system, so I can launch sales in QuickBooks. To integrate'm using the API provided this link https://github.com/consolibyte/quickbooks-php.
Set everything as instructed, but the moment you throw a sale, I get the following error:
2020: [Required param missing, need to supply the required value for the API, Required parameter Line.DetailType is missing in the request]
The class that generates invoices is currently as follows:
<?php
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>
<pre>
<?php
$InvoiceService = new QuickBooks_IPP_Service_Invoice();
$Invoice = new QuickBooks_IPP_Object_Invoice();
$Invoice->setDocNumber('WEB' . mt_rand(0, 10000));
$Invoice->setTxnDate('2015-12-10');
$Line = new QuickBooks_IPP_Object_Line();
$Line->setDetailType('Example');
$Line->setAmount(12.95 * 2);
$Line->setDescription('Example');
$SalesItemLineDetail = new QuickBooks_IPP_Object_SalesItemLineDetail();
$SalesItemLineDetail->setItemRef('8');
$SalesItemLineDetail->setUnitPrice(12.95);
$SalesItemLineDetail->setQty(2);
$Line->addSalesItemLineDetail($SalesItemLineDetail);
$Invoice->addLine($Line);
$Invoice->setCustomerRef('67');
if ($resp = $InvoiceService->add($Context, $realm, $Invoice))
{
print('Our new Invoice ID is: [' . $resp . ']');
}
else
{
print($InvoiceService->lastError());
}
?>
</pre>
<?php
require_once dirname(__FILE__) . '/views/footer.tpl.php';
Someone has gone through this problem?
I really need help because they do not understand much about QuickBooks.
Thanks,
This error:
Required parameter Line.DetailType is missing in the request
Means you are missing a required parameter named Line.DetailType in your request. More specifically -- in your case, you're actually sending an invalid value for this parameter.
$Line->setDetailType('Example');
That ^^^ is not valid. Please take the time to refer to Intuit's documentation:
https://developer.intuit.com/docs/api/accounting/Invoice
And take the time to refer to the examples:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/example_invoice_add.php#L21
And notices that the documentation/examples show the correct value is:
// Set to SalesItemLineDetailfor this type of line.
$Line->setDetailType('SalesItemLineDetail');
Related
I've a few php files that need to access the Parse backend. I don't know how to connect them. In my previous question the answer was: SESSIONS!
Now i've a new problem:
If i comment out session_start(), i've access to the Parse database, but not to the session variables.
If i uncomment session_start(), i've access to Session variables, but not to Parse anymore.
Why is that?
<?PHP
//session_start();
echo "I'm in PHP!!!";
require 'vendor/autoload.php';
use Parse\ParseException;
use Parse\ParseClient;
use Parse\ParseQuery;
use Parse\ParseUser;
ParseClient::initialize('xxxxx', 'xxxxx', 'xxxxx');
ParseClient::setServerURL('https://xxxxxx');
//if (isset($_SESSION["currentUser"])){
$query = new ParseQuery("CourseInfo");
$query -> equalTo ("CourseID", "Demo2");
$results = $query->find();
echo "Successfully retrieved " . count($results) . " scores.";
// }
echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>"; // just to test
if (isset($_SESSION["currentUser"])) {echo $_SESSION["currentUser"];}
?>
After calling the initialize method, add the following:
ParseClient::setStorage( new ParseSessionStorage() );
Also checkout: http://parseplatform.github.io/docs/php/guide/#session-storage-interface
I think your answer is right, a somewhat more detailed explanation is here:
New parse.com php API - currentUser not giving back a user
Tx
I'm trying to figure out where I'm going wrong with the below code to work with the Coinbase API. I have Composer installed with the Coinbase dependency. Previously I was getting an error that the Coinbase class was not installed, which I figured out was because of the path. I no longer get any error but the code is not executing. Can anyone help?
<?php
require_once __DIR__ . '/usr/bin/vendor/autoload.php';
use coinbase\coinbase;
//I've tried to run it both with and without the following 3 lines of code with no difference
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$apiKey = 'XXX';
$apiSecret = 'XXX';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$account = $client->getPrimaryAccount();
echo 'Account name: ' . $account->getName() . '<br>';
echo 'Account currency: ' . $account->getCurrency() . '<br>';
?>
Per the examples on the Coinbase repository, you've got a namespacing issue. PHP can't find the Configuration or Client classes.
<?php
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
at the top of your file will resolve it. After that, read http://php.net/manual/en/language.namespaces.basics.php and http://php.net/manual/en/language.namespaces.rationale.php.
I have successfully setup the Quickbooks PHP DevKit, but I am currently trying to run the example_customer_add script with my sandbox. When I do, I get the following error:
Notice: Undefined variable: Context in /Applications/MAMP/htdocs/quickbooks-php/test_qb.php on line 54
I've tried to track down the $Context variable, but it is used all over the place, and I'm unsure of where it being set, etc...
Any help is appreciated! Thanks!
EDIT
I'm just using the script included in the docs folder of the Quickbooks PHP DevKit:
<?php
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>
<pre>
<?php
$CustomerService = new QuickBooks_IPP_Service_Customer();
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setTitle('Ms');
$Customer->setGivenName('Shannon');
$Customer->setMiddleName('B');
$Customer->setFamilyName('Palmer');
$Customer->setDisplayName('Shannon B Palmer ' . mt_rand(0, 1000));
// Terms (e.g. Net 30, etc.)
$Customer->setSalesTermRef(4);
// Phone #
$PrimaryPhone = new QuickBooks_IPP_Object_PrimaryPhone();
$PrimaryPhone->setFreeFormNumber('860-532-0089');
$Customer->setPrimaryPhone($PrimaryPhone);
// Mobile #
$Mobile = new QuickBooks_IPP_Object_Mobile();
$Mobile->setFreeFormNumber('860-532-0089');
$Customer->setMobile($Mobile);
// Fax #
$Fax = new QuickBooks_IPP_Object_Fax();
$Fax->setFreeFormNumber('860-532-0089');
$Customer->setFax($Fax);
// Bill address
$BillAddr = new QuickBooks_IPP_Object_BillAddr();
$BillAddr->setLine1('72 E Blue Grass Road');
$BillAddr->setLine2('Suite D');
$BillAddr->setCity('Mt Pleasant');
$BillAddr->setCountrySubDivisionCode('MI');
$BillAddr->setPostalCode('48858');
$Customer->setBillAddr($BillAddr);
// Email
$PrimaryEmailAddr = new QuickBooks_IPP_Object_PrimaryEmailAddr();
$Customer->setPrimaryEmailAddr($PrimaryEmailAddr);
if ($resp = $CustomerService->add($Context, $realm, $Customer))
{
print('Our new customer ID is: [' . $resp . '] (name "' . $Customer- >getDisplayName() . '")');
}
else
{
print($CustomerService->lastError($Context));
}
?>
</pre>
<?php
require_once dirname(__FILE__) . '/views/footer.tpl.php';
The quickbooks_oauth table looks like this after attempting to connect:
'1', 'DO_NOT_CHANGE_ME', '12345', 'qyprdaX1yo1uYqu3GU8xxPvs8raoTss2ZVRBE3fHWy7qZdAB', 'IWZHlW2e956sqR9GVIxa2JOU82NdSrJixZLpb3af', 'KNwiKE2bUXtqFqJ/Vb0NhjzBGYMXwRRcT9xtFOQiV6F8aEgUoqGzA7aheRLPJ/z6EPYy1ZS4e6ZuVpteBaQtxc5H0cN5VcCmWLfj+lryaCpLgw8mGK5+E/Muv2wJ+3UwbOyqVstU+pYQw/yNgFKhfSuA3lOgjgqctuO6ZpMK1wWr42IycA05QrJuOB4+LQ==', 'rCj1V3zl4Jj5mHgTw+BPCPN7SDcJkzLQPWb1tyerEXedsQB0WsZ+caMCBafS+hfN3ECZl3mfNDSyIqKDK+t8RSEAKyFWwRSPOh3UcWDCDEhXrTSUddmKhoIq6pL6yVtNEyETyNtfMaKYN+U6uIwSEMKZB/4IUjK8c0GP5KhoKSl0dv+Bp9w=', '1391140255', 'QBO', NULL, '2015-06-04 19:57:58', '2015-06-04 19:58:36', '2015-06-04 19:58:36'
The code you posted is missing several lines at the top of the script. Look at the example on GitHub:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/example_customer_add.php#L3
There are two require_once statements that you are missing. $Context is defined in those required files.
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
Fix your code so that you're using the example code completely, and making sure those required files actually get included.
If you continue to have trouble, please post your updated code.
You can see where $Context gets defined here:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/config.php#L110
Note that you must be connected to QuickBooks to run the example. I'm assuming you have clicked the "Connect to QuickBooks" button and gotten connected already... right?
ALL,
I am using QBO V3 for PHP. I only have limited php knowledge and don't know anything about XML items and JSON etc. I built a site that interfaces with quick books online and so far I can do time tracking, customer adds etc. I need to be able to send attachments to Quick books online and can not find a simple example IN PHP. This is a similiar format I use for the items I created above, but there is no example on attachements. Their help guide doesn't yeild much either.
// Load the OAuth information from the database
if ($Context = $IPP->context())
{
// Set the IPP version to v3
$IPP->version(QuickBooks_IPP_IDS::VERSION_3);
$ItemService = new QuickBooks_IPP_Service_Item();
$Item = new QuickBooks_IPP_Object_Item();
$Item->setName('My Item');
$Item->setType('Inventory');
$Item->setIncomeAccountRef('53');
if ($resp = $ItemService->add($Context, $realm, $Item))
{
print('Our new Item ID is: [' . $resp . ']');
}
else
{
print($ItemService->lastError($Context));
}
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");
}
Im working on connecting my website to connect to Google Adwords to create ads and campains depending up on the products in my site. I tried connecting by sending direct curl request and parse the received SOAP response. But that is too becoming complex for each request. So i tried using the PHP client library provided in Google Code. But none of the example is working correctly. I changed the user account details in auth.ini file but still on excecuting the example files it says
Failed to get authToken. Reason:
couldn't connect to host'.
I tried running the scripts in different servers but still getting the same error.
Following is the code to fetch all ads from Google adwords and this is a example file from Client library
$path = dirname(__FILE__) . '/../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
try {
// Get AdWordsUser from credentials in "../auth.ini"
// relative to the AdWordsUser.php file's directory.
$user = new AdWordsUser();
// Log SOAP XML request and response.
$user->LogDefaults();
// Get the AdGroupAdService.
$adGroupAdService = $user->GetAdGroupAdService();
$adGroupId = (float) '01';
// Create selector.
$selector = new Selector();
$selector->fields = array('Id', 'AdGroupId', 'Status');
$selector->ordering = array(new OrderBy('Id', 'ASCENDING'));
// Create predicates.
$adGroupIdPredicate = new Predicate('AdGroupId', 'IN', array($adGroupId));
// By default disabled ads aren't returned by the selector. To return them
// include the DISABLED status in a predicate.
$statusPredicate =
new Predicate('Status', 'IN', array('ENABLED', 'PAUSED', 'DISABLED'));
$selector->predicates = array($adGroupIdPredicate, $statusPredicate);
// Get all ads.
$page = $adGroupAdService->get($selector);
// Display ads.
if (isset($page->entries)) {
foreach ($page->entries as $adGroupAd) {
printf("Ad with id '%s', type '%s', and status '%s' was found.\n",
$adGroupAd->ad->id, $adGroupAd->ad->AdType, $adGroupAd->status);
}
} else {
print "No ads were found.\n";
}
} catch (Exception $e) {
echo 'Inside catch exception';
print $e->getMessage();
}
and in the settings.ini file
DEFAULT_SERVER =
"https://adwords-sandbox.google.com"
; AUTH_SERVER = "<SERVER>"
In auth.ini file
My Google account's username and password are set correctly.
Can someone help me in getting this issue fixed.
Thanks
It's the AUTH_SERVER setting, not DEFAULT_SERVER, that indicates where authentication requests are being sent. This should be at the bottom of settings.ini but is normally commented out so that the default setting of https://www.google.com is used. You should check that AUTH_SERVER is commented out and that you can connect to https://www.google.com.