// 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);
    $CustomerService = new QuickBooks_IPP_Service_Customer();
    $customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer ");
    foreach ($customers as $Customer) {
        //print_r($Customer);
        print 'Customer #' . $Customer->getXPath('//Customer/Id') . "\n";
        print '  Phone: ' . $Customer->getXPath('//Customer/PrimaryPhone/FreeFormNumber') . "\n";
        print '  Email: ' . $Customer->getXPath('//Customer/PrimaryEmailAddr/Address') . "\n\n";
    }
    /*
    print("\n\n\n\n");
    print('Request [' . $IPP->lastRequest() . ']');
    print("\n\n\n\n");
    print('Response [' . $IPP->lastResponse() . ']');
    print("\n\n\n\n");
    */
} else {
    die('Unable to load a context...?');
<?php

require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>

<pre>

<?php 
$CustomerService = new QuickBooks_IPP_Service_Customer();
$customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer WHERE FullyQualifiedName LIKE '%Keith O\\'Mally%' ");
//print_r($customers);
foreach ($customers as $Customer) {
    print 'Customer Id=' . $Customer->getId() . ' is named: ' . $Customer->getFullyQualifiedName() . '<br>';
}
print "\n\n\n\n";
print 'Request [' . $CustomerService->lastRequest() . ']';
print "\n\n\n\n";
print 'Response [' . $CustomerService->lastResponse() . ']';
print "\n\n\n\n";
?>

</pre>

<?php 
require_once dirname(__FILE__) . '/views/footer.tpl.php';
<?php

require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>

<pre>

<?php 
$CustomerService = new QuickBooks_IPP_Service_Customer();
// Get the existing customer first (you need the latest SyncToken value)
$customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer WHERE Id = '34' ");
$Customer = $customers[0];
// Change something
$Customer->setDisplayName('Updated ' . date('Y-m-d H-i-s'));
// Update their email address too
$PrimaryEmailAddr = $Customer->getPrimaryEmailAddr();
$PrimaryEmailAddr->setAddress('*****@*****.**');
// What are we doing?
print 'Updating the customer name to: ' . $Customer->getDisplayName() . '<br>';
if ($CustomerService->update($Context, $realm, $Customer->getId(), $Customer)) {
    print '&nbsp; Updated!<br>';
} else {
    print '&nbsp; Error: ' . $CustomerService->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() . ']');
Ejemplo n.º 4
0
<?php

require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>

<pre>

<?php 
// Jobs are really just Customers, so we can use the CustomerService and Customer query methods to do this
$CustomerService = new QuickBooks_IPP_Service_Customer();
// Get all jobs that have a parent customer "Derrick Huckleberry"
$jobs = $CustomerService->query($Context, $realm, "SELECT * FROM Customer WHERE FullyQualifiedName LIKE 'Derrick Huckleberry:%' ");
//print_r($customers);
foreach ($jobs as $Job) {
    print 'Job Id=' . $Job->getId() . ' is named: ' . $Job->getFullyQualifiedName() . '<br>';
}
/*
print("\n\n\n\n");
print('Request [' . $CustomerService->lastRequest() . ']');
print("\n\n\n\n");
print('Response [' . $CustomerService->lastResponse() . ']');
print("\n\n\n\n");
*/
?>

</pre>

<?php 
require_once dirname(__FILE__) . '/views/footer.tpl.php';
<?php

require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>

<pre>

<?php 
$Payments = new QuickBooks_Payments($oauth_consumer_key, $oauth_consumer_secret, $sandbox);
$CustomerService = new QuickBooks_IPP_Service_Customer();
$customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer MAXRESULTS 5");
foreach ($customers as $Customer) {
    print 'Customer Id=' . $Customer->getId() . ' is named: ' . $Customer->getFullyQualifiedName() . '<br>';
    $result = $Payments->getCards($Context, $Customer->getId());
}
print "\n\n\n\n";
print 'Request [' . $CustomerService->lastRequest() . ']';
print "\n\n\n\n";
print 'Response [' . $CustomerService->lastResponse() . ']';
print "\n\n\n\n";
print 'Error [' . $CustomerService->lastError() . ']';
print "\n\n\n\n";
?>

</pre>

<?php 
require_once dirname(__FILE__) . '/views/footer.tpl.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);
    $CustomerService = new QuickBooks_IPP_Service_Customer();
    $count = $CustomerService->query($Context, $realm, "SELECT COUNT(*) FROM Customer  ");
    print 'There are a total of ' . $count . ' customers!';
    /*
    print("\n\n\n\n");
    print('Request [' . $CustomerService->lastRequest() . ']');
    print("\n\n\n\n");
    print('Response [' . $CustomerService->lastResponse() . ']');
    print("\n\n\n\n");
    */
} else {
    die('Unable to load a context...?');
}
?>

</pre>
Ejemplo n.º 7
0
 /**
  * Test to see if a connection actually works (make sure you haven't been disconnected on Intuit's end)
  *
  */
 public function test($app_username, $app_tenant)
 {
     if ($creds = $this->load($app_username, $app_tenant)) {
         $IPP = new QuickBooks_IPP();
         $IPP->authMode(QuickBooks_IPP::AUTHMODE_OAUTH, $app_username, $creds);
         if ($Context = $IPP->context()) {
             // Set the DBID
             $IPP->dbid($Context, 'something');
             // Set the IPP flavor
             $IPP->flavor($creds['qb_flavor']);
             // Get the base URL if it's QBO
             if ($creds['qb_flavor'] == QuickBooks_IPP_IDS::FLAVOR_ONLINE) {
                 $cur_version = $IPP->version();
                 $IPP->version(QuickBooks_IPP_IDS::VERSION_3);
                 // Need v3 for this
                 $CustomerService = new QuickBooks_IPP_Service_Customer();
                 $customers = $CustomerService->query($Context, $creds['qb_realm'], "SELECT * FROM Customer MAXRESULTS 1");
                 $IPP->version($cur_version);
                 // Revert back to whatever they set
                 //$IPP->baseURL($IPP->getBaseURL($Context, $creds['qb_realm']));
             } else {
                 $companies = $IPP->getAvailableCompanies($Context);
             }
             //print('[[' . $IPP->lastRequest() . ']]' . "\n\n");
             //print('[[' . $IPP->lastResponse() . ']]' . "\n\n");
             //print('here we are! [' . $IPP->errorCode() . ']');
             // Check the last error code now...
             if ($IPP->errorCode() == 401 or $IPP->errorCode() == 3200) {
                 return false;
             }
             return true;
         }
     }
     return false;
 }
$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);
    $CustomerService = new QuickBooks_IPP_Service_Customer();
    $InvoiceService = new QuickBooks_IPP_Service_Invoice();
    $customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer WHERE FamilyName = 'Palmer' ");
    //print_r($customers);
    if (count($customers)) {
        foreach ($customers as $Customer) {
            print 'Customer Id=' . $Customer->getId() . ' is named: ' . $Customer->getFullyQualifiedName() . '<br>';
            $invoices = $InvoiceService->query($Context, $realm, "SELECT * FROM Invoice WHERE CustomerRef = '" . QuickBooks_IPP_IDS::usableIDType($Customer->getId()) . "' ");
            /*
            print("\n\n\n\n");
            print('Request [' . $IPP->lastRequest() . ']');
            print("\n\n\n\n");
            print('Response [' . $IPP->lastResponse() . ']');
            print("\n\n\n\n");
            exit;
            */
            if (count($invoices)) {
                foreach ($invoices as $Invoice) {