// 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. // // We also provide a priority, we want to make sure that this request runs // *before* the request below, because we need to create the customer *before* // we create an invoice for them. Higher priorities run sooner. $primary_key_of_customer_in_your_application = 20; $priority_of_add_customer_request = 25; if ($API->addCustomer($Customer, '_quickbooks_ca_customer_add_callback', $primary_key_of_customer_in_your_application, $priority_of_add_customer_request)) { print 'Queued up a request to add customer #' . $primary_key_of_customer_in_your_application . ', "' . $Customer->getName() . '" to QuickBooks!' . "\n";
$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); $InvoiceLine1->setAmount(300.0); $InvoiceLine1->setQuantity(3); $InvoiceLine2 = new QuickBooks_Object_Invoice_InvoiceLine(); $InvoiceLine2->setItemApplicationID(11);