$line2->Id = 1; $line2->Description = 'test journal'; $line2->Amount = 2.0; $line2->DetailType = 'JournalEntryLineDetail '; $line2->JournalEntryLineDetail = $linedet2; // Add a journal $journalObj = new IPPJournalEntry(); $journalObj->SyncToken = '1'; $journalObj->DocNumber = '1'; $journalObj->TxnDate = '2014-12-30'; $journalObj->RefNumber = 't123'; $journalObj->PrivateNote = 'Just testing'; $journalObj->Line = array($line, $line2); $journalObj->Adjustment = TRUE; $journalObj->IsAdjustment = TRUE; $resultingjournalObj = $dataService->Add($journalObj); // Echo some formatted output echo '<a href="javascript:void(0)" onclick="goHome()">Home</a>'; echo ' '; echo '<a href="javascript:void(0)" onclick="return intuit.ipp.anywhere.logout(function () { window.location.href = \'http://localhost/PHPSample/index.php\'; });">Sign Out</a>'; echo ' '; echo '<a target="_blank" href="http://localhost/PHPSample/ReadMe.htm">Read Me</a><br />'; //print_r($resultingjournalObj); echo "<br />Created Journal Id={$resultingjournalObj->Id}. <br /> <br /> Reconstructed response body:<br />"; $xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingjournalObj, $urlResource); echo $xmlBody . "\n"; ?> <script type="text/javascript"> function goHome(){ window.location.href = "http://localhost/PHPSample/SampleAppHomePage.php"; }
// Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Add an account set up as an Accounts Receivable account $accountObj = new IPPAccount(); $accountObj->Name = "Accounts Recv (" . rand() . ")"; if (IntuitServicesType::QBO == $serviceType) { $accountObj->AccountSubType = 'AccountsReceivable'; } else { $accountObj->AccountType = 'Accounts Receivable'; } $resultingObj = $dataService->Add($accountObj); echo "New A/R Account Id: {$resultingObj->Id}\n"; /* Example output: New A/R Account Id: 329 */
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Add a customer $customerObj = new IPPCustomer(); $customerObj->Name = "Name" . rand(); $customerObj->CompanyName = "CompanyName" . rand(); $customerObj->GivenName = "GivenName" . rand(); $customerObj->DisplayName = "DisplayName" . rand(); $resultingCustomerObj = $dataService->Add($customerObj); echo "Created Customer Id={$resultingCustomerObj->Id}. Reconstructed response body:\n\n"; $xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingCustomerObj, $urlResource); echo $xmlBody . "\n"; // Update Customer Obj $resultingCustomerObj->GivenName = "New Name " . rand(); $resultingCustomerUpdatedObj = $dataService->Add($resultingCustomerObj); echo "\n" . "Updated Customer Id={$resultingCustomerObj->Id}. Reconstructed response body:\n\n"; $xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingCustomerUpdatedObj, $urlResource); echo $xmlBody . "\n"; /* Created Customer Id=519. Reconstructed response body: <?xml version="1.0" encoding="UTF-8"?> <ns0:Customer xmlns:ns0="http://schema.intuit.com/finance/v3"> <ns0:Id>519</ns0:Id>
} // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } $rnd = rand(); $taxRateDetails = new IPPTaxRateDetails(); $taxRateDetails->TaxRateName = "myNewTaxRateName_{$rnd}"; $taxRateDetails->RateValue = "7"; $taxRateDetails->TaxAgencyId = "1"; $taxRateDetails->TaxApplicableOn = "Sales"; $taxService = new IPPTaxService(); $taxService->TaxCode = 'MyTaxCodeName_' . $rnd; $taxService->TaxRateDetails = array($taxRateDetails); $result = $dataService->Add($taxService); if (empty($result)) { echo "\n Something was wrong. Please check logs"; } else { print_r($result); } #### # Var-dump output #### /** * object(IPPTaxService)#40 (4) { ["TaxCode"]=> string(23) "MyTaxCodeName_482378853" ["TaxCodeId"]=> string(2) "11"
// Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); $serviceContext->IppConfiguration->Message->Response->SerializationFormat = SerializationFormat::Json; $serviceContext->IppConfiguration->Message->Request->SerializationFormat = SerializationFormat::Json; $serviceContext->IppConfiguration->BaseUrl->Qbo = ConfigurationManager::BaseURLSettings(strtolower(IntuitServicesType::QBO)); $serviceContext->baseserviceURL = $serviceContext->GetBaseURL(); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } $result = $dataService->Add(createTransfer()); echo showMe($result); print_r($result); ################################################################################ # Domain Objects example # ################################################################################ function createTransfer() { $from = new IPPReferenceType(); $from->name = "Checking"; $from->value = 35; $to = new IPPReferenceType(); $to->name = "Savings"; $to->value = 36; $transfer = new IPPTransfer(); $transfer->FromAccountRef = $from;
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Add an employee $employeeObj = new IPPEmployee(); $employeeObj->Name = "Employee"; $employeeObj->FamilyName = "Intuit"; $employeeObj->GivenName = "Employee"; $employeeObj->DisplayName = "Emp" . rand(); $resultingEmployeeObjObj = $dataService->Add($employeeObj); // Echo some formatted output echo '<a href="javascript:void(0)" onclick="goHome()">Home</a>'; echo ' '; echo '<a href="javascript:void(0)" onclick="return intuit.ipp.anywhere.logout(function () { window.location.href = \'http://localhost/PHPSample/index.php\'; });">Sign Out</a> '; echo ' '; echo '<a target="_blank" href="http://localhost/PHPSample/ReadMe.htm">Read Me</a><br />'; echo "<br />Created Employee in QuickBooks with Id={$resultingEmployeeObjObj->Id} and Name={$resultingEmployeeObjObj->DisplayName}<br /> <br /> Reconstructed response body:<br />"; $xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingEmployeeObjObj, $urlResource); echo $xmlBody . "\n"; ?> <script type="text/javascript"> function goHome(){ window.location.href = "http://localhost/PHPSample/SampleAppHomePage.php"; } </script>