2017-10-16 4 views
1

나는 약간의 코더가 고귀한 원인으로 도움이되기를 바랍니다.Consolibyte의 PHP Devkit을 사용하여 Quickbooks에 고객 추가 POS 데스크탑 v.12 (웹 커넥터 포함)

나는 대학 수업 외의 많은 프로그래밍을하지 않았으며 몇 가지 기본 사항에 대한 도움이 필요합니다. 다른 비영리 단체를 위해 비영리 기술 서비스 제공 업체를 시작했습니다. 아래에 설명 된 통합은 내가 기부 한 첫 번째 프로젝트의 일부입니다. 수수료를 부과하는 경우 휠 하우스가 아니기 때문에이 도움에 대한 비용을 지불합니다. 나는이 프로젝트에 참석할 다른 많은 항목들을 가지고 있으며, 누군가가 함께 속력을 내는데 도움이되기를 바라고 있습니다.

내가 작업하고있는 통합은 간단합니다. 비영리 단체는 기부 물품을 판매하고 할인 프로그램에 가입하는 사람들에게 10 % 할인을 제공합니다. 현재 사용자는 Google 양식을 통해 가입하고 있으며 나중에 Quickbooks v. 12 POS 시스템에 정보가 수동으로 추가됩니다. 조직이 wordpress를 사용하고 있기 때문에, php는 goodfit처럼 보였습니다. 나는 다른 방법에 완전히 열려 있습니다. 다음은 단순히 내 연구가 착륙 한 곳입니다. 내가 http://dlm2.download.intuit.com/akdlm/SBD/QuickBooks/2015/Latest/QuickBooksPOSV12Trial30.exe

  • 웹 커넥터 v 다음

    1. 인튜이트의 Quickbooks에 POS의 12 절을 사용하고

      . 2.1.0.30 developer.intuit.com/docs/ 0200_quickbooks_desktop/0100_essentials/quickbooks_web_connector

    2. 키스 팔머/Consolibyte의 PHP 개발자 키트 consolibyte.com/downloads/quickbooks-php-devkit/

    나는 (이 dev에 램프 스택의) 사용에 성공했습니다 lamp.pond.im/ qb/docs/web_connector/example_web_connector_point_of_sale.php 정적 고객 레코드를 추가하려면

    저는 다음 몇 가지 기본 단계에 어려움을 겪고 있습니다. 문서를 올바르게 이해하고있는 경우 : http://www.consolibyte.com/docs/index.php/PHP_DevKit_for_QuickBOoks_-_Point_of_Sale_Quick-Start

    다음 단계는 양식에서 제공하는 사용자를 대기열로 보내는 것입니다. 내 목표는 조직을위한 워드 프레스 플러그인을 사용하여 이것을 구현하는 것입니다. 즉,이 시점에서 나는 단지 일을 기능적으로 할 필요가 있다고 말했다. 아래 코드는 새 사용자를 큐에 넣어야한다고 생각하지만 구현과 관련하여 고민 중입니다. 양식을 작성해야하지만 다음 코드 (docs/example_web_connector_queueing.php)를 docs/example_web_connector_point_of_sale.php와 함께 사용하는 방법을 이해하지 못합니다.

    문서/example_web_connector_queueing.php

    <?php 
    
    /** 
    * Example integration with an application 
    * 
    * The idea behind the action queue is basically just that you want to add an 
    * action/ID pair to the queue whenever something happens in your application 
    * that you need to tell QuickBooks about. 
    * 
    * @author Keith Palmer <[email protected]> 
    * 
    * @package QuickBooks 
    * @subpackage Documentation 
    */ 
    
    // Error reporting for easier debugging 
    ini_set('display_errors', true); 
    error_reporting(E_ALL | E_STRICT); 
    
    // Require the queueuing class 
    require_once '../QuickBooks.php'; 
    
    if (isset($_POST['customer'])) 
    { 
    // Oooh, here's a new customer, let's do some stuff with them 
    
    // Connect to your own MySQL server.... 
    $link = mysql_connect('localhost', 'your_mysql_username', 
    'your_mysql_password'); 
    if (!$link) 
    { 
        die('Could not connect to MySQL: ' . mysql_error()); 
    } 
    
    // ... and use the correct database 
    $selected = mysql_select_db('your_database_name', $link); 
    if (!$selected) 
    { 
        die ('Could not select database: ' . mysql_error()); 
    } 
    
    // Insert into our local MySQL database 
    mysql_query("INSERT INTO my_customer_table (name, phone, email) VALUES ('" . $_POST['customer']['name'] . "', '" . $_POST['customer']['phone'] . "', '" . $_POST['customer']['email'] . "') "); 
    $id_value = mysql_insert_id(); 
    
    // QuickBooks queueing class 
    $Queue = new QuickBooks_WebConnector_Queue('mysql://root:[email protected]/my_database'); 
    
    // Queue it up! 
    $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $id_value); 
    

    }

    다음은 데이터베이스에 입력 무엇이든 워드 프레스 형태와 저장소를 만듭니다 example_web_connector_point_of_sale.php 코드

    <?php 
    
    /** 
    * Example QuickBooks SOAP Server/Web Service for QuickBooks Point of Sale 
    * 
    * This is an example Web Service which adds test dummy customers to QuickBooks 
    * Point of Sale via the Web Connector. 
    * 
    * You should probably also look through docs/example_web_connector.php for 
    * some additional documentation about what things do. 
    * 
    * @author Keith Palmer <[email protected]> 
    * 
    * @package QuickBooks 
    * @subpackage Documentation 
    */ 
    
    // We need to make sure the correct timezone is set, or some PHP installations will complain 
    if (function_exists('date_default_timezone_set')) 
    { 
        // * MAKE SURE YOU SET THIS TO THE CORRECT TIMEZONE! * 
        // List of valid timezones is here: http://us3.php.net/manual/en/timezones.php 
        date_default_timezone_set('America/New_York'); 
    } 
    
    // Error reporting for easier debugging 
    error_reporting(E_ALL | E_STRICT); 
    ini_set('display_errors', true); 
    
    // Require the framework 
    require_once '../QuickBooks.php'; 
    
    // A username and password you'll use in: 
    // a) Your .QWC file 
    // b) The Web Connector 
    // c) The QuickBooks framework 
    $user = 'quickbooks'; 
    $pass = 'password'; 
    
    // Map QuickBooks actions to handler functions 
    $map = array(
        QUICKBOOKS_ADD_CUSTOMER => array('_quickbooks_pos_customer_add_request', '_quickbooks_pos_customer_add_response'), 
        // ... more action handlers here ... 
        ); 
    
    // This is entirely optional, use it to trigger actions when an error is returned by QuickBooks 
    $errmap = array(
        ); 
    
    // An array of callback hooks 
    $hooks = array(
        ); 
    
    // Logging level 
    //$log_level = QUICKBOOKS_LOG_NORMAL; 
    //$log_level = QUICKBOOKS_LOG_VERBOSE; 
    //$log_level = QUICKBOOKS_LOG_DEBUG;     
    $log_level = QUICKBOOKS_LOG_DEVELOP;  // Use this level until you're sure everything works!!! 
    
    // What SOAP server you're using 
    //$soapserver = QUICKBOOKS_SOAPSERVER_PHP;   // The PHP SOAP extension, see: www.php.net/soap 
    $soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;  // A pure-PHP SOAP server (no PHP ext/soap extension required, also makes debugging easier) 
    
    $soap_options = array(  // See http://www.php.net/soap 
        ); 
    
    $handler_options = array(
        'deny_concurrent_logins' => false, 
        );  // See the comments in the QuickBooks/Server/Handlers.php file 
    
    $driver_options = array(  // See the comments in the QuickBooks/Driver/<YOUR DRIVER HERE>.php file (i.e. 'Mysql.php', etc.) 
        ); 
    
    $callback_options = array(
        ); 
    
    // * MAKE SURE YOU CHANGE THE DATABASE CONNECTION STRING BELOW TO A VALID MYSQL USERNAME/PASSWORD/HOSTNAME * 
    $dsn = 'mysql://root:[email protected]/quickbooks_pos_server'; 
    
    if (!QuickBooks_Utilities::initialized($dsn)) 
    { 
        // Initialize creates the neccessary database schema for queueing up requests and logging 
        QuickBooks_Utilities::initialize($dsn); 
    
        // This creates a username and password which is used by the Web Connector to authenticate 
        QuickBooks_Utilities::createUser($dsn, $user, $pass); 
    
        // We're going to queue up a request to add a customer, just as a test... 
        $primary_key_of_your_customer = 5; 
    
        $Queue = new QuickBooks_WebConnector_Queue($dsn); 
        $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $primary_key_of_your_customer); 
    } 
    
    // Create a new server and tell it to handle the requests 
    // __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array() 
    $Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options); 
    $response = $Server->handle(true, true); 
    
    /** 
    * Generate a qbXML request for QuickBooks Point of Sale 
    */ 
    function _quickbooks_pos_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale) 
    { 
        // We're just testing, so we'll just use a static test request: 
        $xml = ' 
         <?xml version="1.0" encoding="utf-8"?> 
         <?qbposxml version="3.0"?> 
         <QBPOSXML> 
          <QBPOSXMLMsgsRq onError="stopOnError"> 
           <CustomerAddRq> 
            <CustomerAdd> 
             <CompanyName>ConsoliBYTE, LLC</CompanyName> 
             <EMail>[email protected]</EMail> 
             <FirstName>Keith</FirstName> 
             <LastName>Palmer Jr.</LastName> 
             <Phone>860-341-1464</Phone> 
             <Salutation>Mr.</Salutation> 
             <BillAddress> 
              <City>Willington</City> 
              <Country>USA</Country> 
              <PostalCode>06279</PostalCode> 
              <State>CT</State> 
              <Street>56 Cowles Road</Street> 
             </BillAddress> 
             <ShipAddress> 
              <City>Willington</City> 
              <Country>USA</Country> 
              <PostalCode>06279</PostalCode> 
              <State>CT</State> 
              <Street>56 Cowles Road</Street> 
             </ShipAddress> 
            </CustomerAdd> 
           </CustomerAddRq> 
          </QBPOSXMLMsgsRq> 
         </QBPOSXML>'; 
    
        return $xml; 
    } 
    
    /** 
    * Receive a response from QuickBooks 
    */ 
    function _quickbooks_pos_customer_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents) 
    { 
        // Great, customer $ID has been added to QuickBooks with a QuickBooks 
        // ListID value of: $idents['ListID'] 
        // 
        // We probably want to store that ListID in our database, so we can use it 
        // later. (You'll need to refer to the customer by either ListID or Name 
        // in other requests, say, to update the customer or to add an invoice for 
        // the customer. 
    
        /* 
        mysql_query("UPDATE your_customer_table SET quickbooks_listid = '" . mysql_escape_string($idents['ListID']) . "' WHERE your_customer_ID_field = " . (int) $ID); 
        */ 
    } 
    
  • +0

    이 예제 코드를 사용하지 마십시오. 잘못 작성되었으며 쓸모없고 안전하지 않습니다. –

    +0

    대체 솔루션을 제공하고 의견을 설명하면 도움이 될 것입니다. –

    +0

    mysql_ * 함수를 사용하지 마십시오. v5.5 (2013 년 6 월)부터 사용 중지되었으며 v7.0 (2015 년 12 월) 이후 삭제되었습니다. 대신 [** mysqli _ ***] (https://secure.php.net/manual/en/book.mysqli.php) 또는 [** PDO **] (https://secure.php.net/** ** prepared statements **] (https://secure.php.net/manual/en/pdo.prepare.php) 및 [** bound parameters **]와 함께 /manual/en/book.pdo.php) ] (https://secure.php.net/manual/en/pdostatement.bindparam.php). –

    답변

    0

    우선입니다. 온라인 튜토리얼을 온라인으로 제공합니다.여기에 하나입니다 : 당신은 당신이 삽입 된 레코드에 대한 Id 값의 일종을 다시 받아야

    . 즉시 데이터베이스에 저장 한 후 레코드를 큐에 그 사용

    require_once 'path/to/QuickBooks.php'; 
    
    // QuickBooks queueing class 
    $Queue = new QuickBooks_WebConnector_Queue('mysql://root:[email protected]/my_database'); 
    
    // Queue it up! 
    $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $id_value); 
    

    별도로, 완전히 별도의 스크립트에서, QuickBooks에 POS에 고객을 추가하는 함수를 수정 : 다른로서

    function _quickbooks_pos_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale) 
    { 
        // Pull the data out of the database that we stored from the WordPress form submission 
        $arr = mysql_fetch_array(mysql_query("SELECT * FROM your_table WHERE id = " . (int) $ID)); 
    
        // Build $xml using the data in $arr 
        $xml = ' 
    

    사용자가 지적한 바,이 코드는 이므로 정리하고 안전한 지 확인하십시오. 데이터베이스가를 쿼리에 대한 (가되지 않습니다)

  • 준비된 문 또는 매개 변수가있는 문은 좋은 생각이있는 mysql_* 기능의 이상 대신

    • 사용 PDO 또는 mysqli 또는 다른 데이터베이스 : 것들 중 당신이보고 싶을거야
  • +0

    덕분에 상품권 발급이 발견되었을 때 신속하게 문제가되지 않았습니다. 당신이 그 일을 끝내기 위해 어떤 지침을 주셔서 감사하겠습니다. 별도의 질문을 만들었습니다. –

    관련 문제