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; }
/** * * * */ public function __construct($dsn_or_conn, $integrator_dsn_or_conn, $email, $user, $map = array(), $onerror = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_BUILTIN, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $api_options = array(), $source_options = array(), $integrator_options = array(), $callback_options = array()) { $integrator_onerror = array('3100' => 'QuickBooks_Server_Integrator_Errors::e3100_alreadyexists', '3170' => 'QuickBooks_Server_Integrator_Errors::e3170_errorsaving', '3180' => 'QuickBooks_Server_Integrator_Errors::e3180_errorsaving', '3200' => 'QuickBooks_Server_Integrator_Errors::e3200_editsequence', '*' => 'QuickBooks_Server_Integrator_Errors::e_catchall'); // Merge integration options over default options // (allow overrides, they'll need to handle errors manually...) $integrator_onerror = $this->_merge($integrator_onerror, $onerror, false); // Merge hooks in $integrator_hooks = array(); $integrator_hooks = $this->_merge($integrator_hooks, $hooks, false); // Callback options $integrator_callback_options = array('_error_email' => $email, '_error_subject' => 'QuickBooks Error on ' . $_SERVER['HTTP_HOST'], '_error_from' => 'quickbooks@' . implode('.', array_slice(explode('.', $_SERVER['HTTP_HOST']), -2))); //print_r($integrator_callback_options); //exit; // Merge callback options $integrator_callback_options = $this->_merge($integrator_callback_options, $callback_options, false); // QuickBooks_Server_API::__construct( ... ) parent::__construct($dsn_or_conn, $user, $map, $integrator_onerror, $integrator_hooks, $log_level, $soap, $wsdl, $soap_options, $handler_options, $driver_options, $api_options, $source_options, $callback_options); //header('Content-Type: text/plain'); //print_r($this); //exit; $source_type = QUICKBOOKS_API_SOURCE_WEB; $source_dsn = null; // Set up the API // $api_driver_dsn, $user, $source_type, $source_dsn, $api_options = array(), $source_options = array(), $driver_options = array(), $callback_options = array() $API = QuickBooks_API_Singleton::getInstance($dsn_or_conn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options, $callback_options); $this->_api = $API; // new QuickBooks_API($dsn_or_conn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options, $callback_options); // Set up the integrator $this->_integrator = $this->_integratorFactory($integrator_dsn_or_conn, $integrator_options, $API); // Initialize the Integrator singleton $tmp = QuickBooks_Integrator_Singleton::getInstance($this->_integrator); // Integrator options (shared between the server component and actual integrator) $this->_integrator_config = $this->_integratorDefaults($integrator_options); }
<?php require_once '../../QuickBooks.php'; require_once 'QuickBooks/Integrator/Imscart.php'; $dsn = 'mysql://root:@localhost/imscart'; $driver = QuickBooks_Utilities::driverFactory($dsn); $api = QuickBooks_API_Singleton::getInstance($dsn, 'imscart', QUICKBOOKS_API_SOURCE_WEB); $Imscart = new QuickBooks_Integrator_Imscart($driver, array()); //$Customer = $Imscart->getCustomer(2680); //print($Customer->asQBXML('CustomerAddRq')); //$ServiceItem = $Imscart->getProduct(5); //print($ServiceItem->asQBXML('ItemServiceAddRq')); $Order = $Imscart->getOrder(191); print $Order->asQBXML('InvoiceAddRq'); //$ShipMethod = $Imscart->getShipMethod(50); //print($ShipMethod->asQBXML('ShipMethodAddRq')); //$Payment = $Imscart->getPayment(207); //print($Payment->asQBXML('ReceivePaymentAddRq')); //$Shipping = $Imscart->getShippingForOrder(191); //print($Shipping->asQBXML(QUICKBOOKS_ADD_SERVICEITEM));
/** * * * @param array $arr * @param array $map * @param QuickBooks_Object * @param string $type * @param string $type * @return QuickBooks_Object */ protected function _applyBaseMap($arr, $map, $obj, $type, $path = '') { if ($path) { $path = trim($path) . ' '; } foreach ($map as $field => $tmp) { if (!empty($arr[$field])) { $set = true; $method = $tmp[0]; $qbfield = $tmp[1]; $resolve = false; if (!empty($tmp[2])) { $resolve = $tmp[2]; } $value = $arr[$field]; if ($qbfield and !strlen($resolve)) { // Cast $value $value = QuickBooks_Cast::cast($type, $path . $qbfield, $value); } else { if ($qbfield and strlen($resolve)) { // Try to resolve a value to a ListID or TxnID $obj->{$method}($value); $encode = $obj->get($qbfield); $obj->remove($qbfield); $reftype = null; $reftag = null; $refid = null; $obj->decodeApplicationID($encode, $reftype, $reftag, $refid); $API = QuickBooks_API_Singleton::getInstance(); if ($ListID_or_TxnID = $API->fetchQuickBooksID($reftype, $value)) { $obj->{$resolve}($ListID_or_TxnID); $set = false; } } } if ($set) { $obj->{$method}($value); } } } return $obj; }
/** * QuickBooks API server class * * @param string $dsn_or_conn * @param array $map * @param array $onerror * @param array $hooks * @param integer $log_level * @param string $soap * @param string $wsdl * @param array $soap_options * @param array $handler_options * @param array $driver_options * @param array $callback_options */ public function __construct($dsn_or_conn, $user, $map = array(), $onerror = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_BUILTIN, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $api_options = array(), $source_options = array(), $callback_options = array()) { // NORMAL: // $dsn_or_conn, $map, $onerror = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_BUILTIN, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array() // SQL: // $dsn_or_conn, $how_often, $mode, $conflicts, $users = null, $map = array(), $onerror = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_BUILTIN, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array()) $api_map = array(); foreach (get_class_methods('QuickBooks_Callbacks_API_Callbacks') as $method) { if (strtolower(substr($method, -7)) == 'request') { $action = substr($method, 0, -7); $api_map[$action] = array('QuickBooks_Callbacks_API_Callbacks::' . $action . 'Request', 'QuickBooks_Callbacks_API_Callbacks::' . $action . 'Response'); } } // Register default API error handlers, and merge them with user-supplied handlers $api_onerror = array(1 => 'QuickBooks_Callbacks_API_Errors::e1_notfound', 500 => 'QuickBooks_Callbacks_API_Errors::e500_notfound'); // By default, we register our own error handlers. If the user wants to // register their own error handlers, their error handlers override // the API error handlers, and they'll be expected to handle all of // those errors themselves. $api_onerror = $this->_merge($api_onerror, $onerror, false); // Register default API hooks, and merge them with user-supplied hooks $api_hooks = array(); // Merge user-defined hooks with our API hooks $api_hooks = $this->_merge($api_hooks, $hooks, true); // Initialize the Driver singleton $tmp = QuickBooks_Driver_Singleton::getInstance($dsn_or_conn, $driver_options, $hooks, $log_level); $source_type = QUICKBOOKS_API_SOURCE_WEB; $source_dsn = null; // Initialize the API singleton $tmp = QuickBooks_API_Singleton::getInstance($dsn_or_conn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options, $callback_options); // $dsn_or_conn, $map, $onerror = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_BUILTIN, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array() parent::__construct($dsn_or_conn, $api_map, $api_onerror, $api_hooks, $log_level, $soap, $wsdl, $soap_options, $handler_options, $driver_options, $callback_options); }
public static function addReceivePayment($method, $action, $ID, &$err, $qbxml, $ReceivePayment, $qbres) { $API = QuickBooks_API_Singleton::getInstance(); if (is_object($ReceivePayment)) { // If we found the customer in QuickBooks, create a mapping with the ListID value $API->createMapping(QUICKBOOKS_OBJECT_RECEIVEPAYMENT, $ID, $ReceivePayment->getTxnID(), $ReceivePayment->getEditSequence()); } }