$customers_name = 'Keith Palmer';
$primary_key_of_customer_in_your_application = 15;
if ($API->getCustomerByName($customers_name, '_quickbooks_ca_customer_getbyname_callback', $primary_key_of_customer_in_your_application)) {
    print 'Queued up a request to fetch a customer named "' . $customers_name . '"!' . "\n";
}
// Adding a new customer to QuickBooks
//
// This example shows how to queue up a request to add a new customer to
//	QuickBooks. Remember that the Name element of a customer is unique within
//	QuickBooks, and the request will fail and send you back an error message if
//	another customer in QuickBooks already has that name.
$name = 'Shannon\'s Company (' . mt_rand() . ')';
$fname = 'Shannon';
$lname = 'Daniels';
// (the mt_rand() call is just so I don't get duplicate customer errors while testing)
$Customer = new QuickBooks_Object_Customer();
// This is a unique name (usually a company name) for the customer
$Customer->setName($name);
$Customer->setFirstName($fname);
$Customer->setLastName($lname);
$Customer->setShipAddress('134 Stonemill Road', '', '', '', '', 'Toronto', '', 'Ontario', 'H1B 12L', 'Canada');
// Country
$Customer->setMiddleName('B.');
$Customer->setSalutation('Ms.');
$Customer->setPhone('1.860.634.1602');
// Queue up the actual request to be sent to QuickBooks via the Web Connector
//
// Notice that we also provide the primary key of this customer from within our
//	application, so we can create a mapping which maps this customer to the
//	QuickBooks primary key.
//
Exemplo n.º 2
0
 public static function listEstimatesModifiedAfter($method, $action, $ID, $err, $qbxml, $Iterator, $qbres)
 {
     $API = QuickBooks_API_Singleton::getInstance();
     $Integrator = QuickBooks_Integrator_Singleton::getInstance();
     while ($Estimate = $Iterator->next()) {
         // Let's check if this estimate already exists in the system
         $EstimateID = null;
         if ($API->hasApplicationID(QUICKBOOKS_OBJECT_ESTIMATE, $Estimate->getTxnID())) {
             $EstimateID = $API->fetchApplicationID(QUICKBOOKS_OBJECT_ESTIMATE, $Estimate->getTxnID());
         }
         // Now, there's a customer assigned to this estimate, let's make sure the customer exists
         if ($API->hasApplicationID(QUICKBOOKS_OBJECT_CUSTOMER, $Estimate->getCustomerListID())) {
             // Great, it exists!
         } else {
             // Uh oh... create it!
             $Customer = new QuickBooks_Object_Customer();
             $Customer->setListID($Estimate->getCustomerListID());
             $Customer->setName($Estimate->getCustomerName());
             $Integrator->setCustomer(null, $Customer);
         }
         // There are line items assigned to this estimate too, and each line item has a product...
         //foreach ($Estimate->listLineItems
         $Integrator->setEstimate($EstimateID, $Estimate);
     }
     return true;
 }
Exemplo n.º 3
0
//$api_driver_dsn = 'pgsql://pgsql@localhost/quickbooks';
$source_dsn = 'http://*****:*****@localhost/path/to/server.php';
$api_options = array();
$source_options = array();
$driver_options = array();
if (!QuickBooks_Utilities::initialized($api_driver_dsn)) {
    //
    QuickBooks_Utilities::initialize($api_driver_dsn);
    //
    QuickBooks_Utilities::createUser($api_driver_dsn, 'api', 'password');
}
$API = new QuickBooks_API($api_driver_dsn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options);
// CUSTOMERS
$fname = 'Shannon ' . mt_rand();
$lname = 'Daniels';
$Customer = new QuickBooks_Object_Customer();
$Customer->setFirstName($fname);
$Customer->setLastName($lname);
$Customer->setShipAddress('56 Cowles Road', '', '', '', '', 'Willington', 'CT');
$Customer->setMiddleName('R');
$Customer->setSalutation('Mr.');
$Customer->setPhone('1.860.634.1602');
$API->addCustomer($Customer, '_quickbooks_customer_add_callback', 15);
// INVOICES
$Invoice = new QuickBooks_Object_Invoice();
//$Invoice->setOther('test of other');		// for some reason this field doesn't work...
$Invoice->setMemo('test of a memo');
$Invoice->setCustomerApplicationID(15);
$Invoice->setRefNumber(125);
$InvoiceLine1 = new QuickBooks_Object_Invoice_InvoiceLine();
$InvoiceLine1->setItemApplicationID(12);
$DebitLine = new QuickBooks_Object_JournalEntry_JournalDebitLine();
$DebitLine->setAmount(45.0);
$DebitLine->setAccountName('Test');
$JournalEntry->addDebitLine($DebitLine);
$CreditLine1 = new QuickBooks_Object_JournalEntry_JournalCreditLine();
$CreditLine1->setAmount(25.0);
$CreditLine1->setAccountName('Services');
$JournalEntry->addCreditLine($CreditLine1);
$CreditLine2 = new QuickBooks_Object_JournalEntry_JournalCreditLine();
$CreditLine2->setAmount(20.0);
$CreditLine2->setAccountName('Sales');
$JournalEntry->addCreditLine($CreditLine2);
//print_r($JournalEntry);
print $JournalEntry->asQBXML(QUICKBOOKS_ADD_JOURNALENTRY);
exit;
$Customer = new QuickBooks_Object_Customer();
$Customer->setFirstName('Keith');
$Customer->set('LastName', 'Palmer');
$Customer->set('ShipAddress Addr1', '56 Cowles Road');
$Customer->setShipAddress('56 Cowles Road', '', '', '', '', 'Willington', 'CT');
$defaults = array('ShipAddress Addr2' => 'bla', 'ShipAddress Country' => 'United States');
//print_r($Customer->getShipAddress(null, $defaults));
//print($Customer->asXML(QUICKBOOKS_OBJECT_XML_DROP, "\t", 'CustomerAdd'));
print "\n\n";
$arr = array('ModifiedDateRangeFilter' => array('FromModifiedDate' => 'test'), 'ModifiedDateRangeFilter ToModifiedDate' => 'test');
$Invoice = new QuickBooks_Object_Invoice($arr);
$qbxml = $Invoice->asQBXML('InvoiceQueryRq');
print $qbxml;
print "\n\n";
/*
$xml = '
Exemplo n.º 5
0
<?php

require_once '../QuickBooks.php';
$Customer = new QuickBooks_Object_Customer();
$Customer->setFullName('web:Keith Palmer');
print 'FullName: ' . $Customer->getFullName() . "\n";
print 'Name: ' . $Customer->getName() . "\n";
print 'Parent: ' . $Customer->getParentName() . "\n";
print "\n";
print $Customer->asQBXML(QUICKBOOKS_ADD_CUSTOMER);
}
// For QuickBooks Online Edition, you can use real-time connections so that you
//	get return values instead of having to write callback functions. Note that
//	if you do this, you make your code less portable to other editions of
//	QuickBooks that do not support real-time connections (i.e. QuickBooks
//	desktop editions via the Web Connector)
if ($API->usingRealtime()) {
    print 'Our real-time response from QuickBooks Online Edition was: ';
    print_r($return);
}
exit;
// You can also create QuickBooks_Object_* instances and send them directly to
//	QBOE via the API as show below. The API takes care of transforming those
//	objects to valid qbXML requests for you.
$name = 'Keith Palmer (' . mt_rand() . ')';
$Customer = new QuickBooks_Object_Customer();
$Customer->setName($name);
$Customer->setShipAddress('134 Stonemill Road', '', '', '', '', 'Storrs', 'CT', '', '06268');
// Just a demo showing how to generate the raw qbXML request
print 'Here is the qbXML request we\'re about to send to QuickBooks Online Edition: ' . "\n";
print $Customer->asQBXML('CustomerAdd');
// Send the request to QuickBooks
$API->addCustomer($Customer, '_add_customer_callback', 15);
// This is our callback function, this will get called when the customer is added successfully
function _add_customer_callback($method, $action, $ID, &$err, $qbxml, $Customer, $qbres)
{
    print 'Customer #' . $ID . ' looks like this within QuickBooks Online Edition: ' . "\n";
    print_r($Customer);
}
// Here's a demo of querying for customers with a specific name:
$name = 'Keith Palmer Jr.';