Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Example integration with an application
  5. *
  6. * The idea behind the action queue is basically just that you want to add an
  7. * action/ID pair to the queue whenever something happens in your application
  8. * that you need to tell QuickBooks about.
  9. *
  10. * @author Keith Palmer <keith@consolibyte.com>
  11. *
  12. * @package QuickBooks
  13. * @subpackage Documentation
  14. */
  15.  
  16. // Error reporting for easier debugging
  17. ini_set('display_errors', true);
  18. error_reporting(E_ALL | E_STRICT);
  19.  
  20. // Require the queueuing class
  21. require_once '../../QuickBooks.php';
  22.  
  23.  
  24.  
  25. $user = 'r2g';
  26. $pass = '******';
  27. $map = array(
  28. QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' )
  29. );
  30. $errmap = array(
  31. 3070 => '_quickbooks_error_stringtoolong', // Whenever a string is too long to fit in a field, call this function: _quickbooks_error_stringtolong()
  32. // 'CustomerAdd' => '_quickbooks_error_customeradd', // Whenever an error occurs while trying to perform an 'AddCustomer' action, call this function: _quickbooks_error_customeradd()
  33. // '*' => '_quickbooks_error_catchall', // Using a key value of '*' will catch any errors which were not caught by another error handler
  34. // ... more error handlers here ...
  35. );
  36. $hooks = array(
  37. // There are many hooks defined which allow you to run your own functions/methods when certain events happen within the framework
  38. // QuickBooks_WebConnector_Handlers::HOOK_LOGINSUCCESS => '_quickbooks_hook_loginsuccess', // Run this function whenever a successful login occurs
  39. );
  40.  
  41. $log_level = QUICKBOOKS_LOG_DEBUG;
  42. $soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;
  43. $soap_options = array();
  44. $handler_options = array(
  45. 'deny_concurrent_logins' => false,
  46. 'deny_reallyfast_logins' => false,
  47. );
  48.  
  49. $driver_options = array();
  50. $callback_options = array();
  51.  
  52. $dsn = 'mysqli://root:******@localhost/quick_books_integration';
  53.  
  54. $Server = new QuickBooks_WebConnector_Server(
  55. $dsn,
  56. $map,
  57. $errmap,
  58. $hooks,
  59. $log_level,
  60. $soapserver,
  61. QUICKBOOKS_WSDL,
  62. $soap_options,
  63. $handler_options,
  64. $driver_options,
  65. $callback_options
  66. );
  67. $response = $Server->handle(true, true);
  68.  
  69.  
  70. if (!QuickBooks_Utilities::initialized($dsn))
  71. {
  72. QuickBooks_Utilities::initialize($dsn);
  73. QuickBooks_Utilities::createUser($dsn, $user, $pass);
  74.  
  75. // QuickBooks queueing class
  76. $Queue = new QuickBooks_WebConnector_Queue($dsn);
  77.  
  78. // Queue it up!
  79. $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER,6);
  80. }
  81.  
  82.  
  83.  
  84. function _quickbooks_customer_add_request(
  85. $requestID,
  86. $user,
  87. $action,
  88. $ID,
  89. $extra,
  90. &$err,
  91. $last_action_time,
  92. $last_actionident_time,
  93. $version,
  94. $locale
  95. ){
  96.  
  97. $xml = '<?xml version="1.0" encoding="utf-8"?>
  98. <?qbxml version="2.0"?>
  99. <QBXML>
  100. <QBXMLMsgsRq onError="stopOnError">
  101. <CustomerAddRq requestID="' . $requestID . '">
  102. <CustomerAdd>
  103. <Name>Unifreight CFS Mombasa (' . mt_rand() . ')</Name>
  104. <CompanyName>Unifreight</CompanyName>
  105. <FirstName>Michael </FirstName>
  106. <LastName>Makari</LastName>
  107. <BillAddress>
  108. <Addr1>Unifreight CFS</Addr1>
  109. <Addr2>Makupa Causeway</Addr2>
  110. <City>Mombasa</City>
  111. <State>CT</State>
  112. <PostalCode>06268</PostalCode>
  113. <Country>United States</Country>
  114. </BillAddress>
  115. <Phone>860-634-1602</Phone>
  116. <AltPhone>860-429-0021</AltPhone>
  117. <Fax>860-429-5183</Fax>
  118. <Email>r2g.technology@gmail.com</Email>
  119. <Contact>Keith Palmer</Contact>
  120. </CustomerAdd>
  121. </CustomerAddRq>
  122. </QBXMLMsgsRq>
  123. </QBXML>';
  124.  
  125. return $xml;
  126. }
  127.  
  128.  
  129. function _quickbooks_customer_add_response(
  130. $requestID,
  131. $user,
  132. $action,
  133. $ID,
  134. $extra,
  135. &$err,
  136. $last_action_time,
  137. $last_actionident_time,
  138. $xml,
  139. $idents
  140. ){
  141.  
  142. return;
  143. }
  144.  
  145. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement