phpquickbooksintuit-partner-platformqbxml

i have integrated quickbook desktop with my software(in PHP) using web connector locally, but can i do the same if my software is uploaded on server?


below is my we_connector file.php which is uploaded on server with customer add function

and my software is uploaded on a server. i want to add the online url but web connector is showing error "QuickBooks Web Connector could not verify the web application server certificate.".

error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1);

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');
}


// Require the framework
require_once '../../QuickBooks.php';

$user = 'quickbooks';
$pass = 'password';


$map = array(
    QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),
    );

// This is entirely optional, use it to trigger actions when an error is returned by QuickBooks
$errmap = array(
    3070 => '_quickbooks_error_stringtoolong',              // Whenever a string is too long to fit in a field, call this function: _quickbooks_error_stringtolong()
    // 'CustomerAdd' => '_quickbooks_error_customeradd',    // Whenever an error occurs while trying to perform an 'AddCustomer' action, call this function: _quickbooks_error_customeradd()
    // '*' => '_quickbooks_error_catchall',                 // Using a key value of '*' will catch any errors which were not caught by another error handler
    // ... more error handlers here ...
    );

// An array of callback hooks
$hooks = array(
    // There are many hooks defined which allow you to run your own functions/methods when certain events happen within the framework
    // QuickBooks_WebConnector_Handlers::HOOK_LOGINSUCCESS => '_quickbooks_hook_loginsuccess',  // Run this function whenever a successful login occurs
    );

/*
function _quickbooks_hook_loginsuccess($requestID, $user, $hook, &$err, $hook_data, $callback_config)
{
    // Do something whenever a successful login occurs...
}
*/

// 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(
    //'authenticate' => ' *** YOU DO NOT NEED TO PROVIDE THIS CONFIGURATION VARIABLE TO USE THE DEFAULT AUTHENTICATION METHOD FOR THE DRIVER YOU'RE USING (I.E.: MYSQL) *** '
    //'authenticate' => 'your_function_name_here', 
    //'authenticate' => array( 'YourClassName', 'YourStaticMethod' ),
    'deny_concurrent_logins' => false, 
    'deny_reallyfast_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. )
    //'max_log_history' => 1024,    // Limit the number of quickbooks_log entries to 1024
    //'max_queue_history' => 64,    // Limit the number of *successfully processed* quickbooks_queue entries to 64
    );

$callback_options = array(
    );



$dsn = 'mysqli://water_ways_user:zAEGQKI74YHyz6Do@localhost/water_ways';






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);


    $primary_key_of_your_customer = 5;

    $Queue = new QuickBooks_WebConnector_Queue($dsn);
    $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $primary_key_of_your_customer,$priority);


}


$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);


function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{

$myHost = "localhost"; // use your real host name
$myUserName = "water_ways_user";   // use your real login user name
$myPassword = "zAEGQKI74YHyz6Do";   // use your real login password
$myDataBaseName = "water_ways"; // use your real database name

$con = mysqli_connect( "$myHost", "$myUserName", "$myPassword", "$myDataBaseName" );

if( !$con ) // == null if creation of connection object failed
{ 
    // report the error to the user, then exit program
    die("connection object not created: ".mysqli_error($con));
}

if( mysqli_connect_errno() )  // returns false if no error occurred
{ 
    // report the error to the user, then exit program
    die("Connect failed: ".mysqli_connect_errno()." : ". mysqli_connect_error());
}





    // Fetch your customer record from your database
    $name='';
    $company_name = '';
    $address1='';
    $address2 ='';
    $phone = '';
    $contact = '';
    $email = '';


    $row = mysqli_fetch_array(mysqli_query($con,"SELECT * FROM customer_info WHERE customer_info_id ='$ID'"));
     //$sql=mysqli_query($con,"SELECT * FROM customer_info WHERE customer_info_id ='3'");
     //if($row = mysqli_fetch_assoc($sql))
    // {

    // Create and return a qbXML request

    $name=$row['customer_name'];
    $company_name = $row['company_name'];
    $address1=$row['address_1'];
    $address2 =$row['address_2'];
    $phone = $row['phone_number'];
    $contact = $row['customer_name'];
    $email = $row['email'];

        $qbxml = '<?xml version="1.0" encoding="utf-8"?>
        <?qbxml version="2.0"?>
        <QBXML>
            <QBXMLMsgsRq onError="stopOnError">
                <CustomerAddRq requestID="'.$requestID.'">
                    <CustomerAdd>
                        <Name>' . $name . '</Name>
                        <CompanyName>' . $company_name . '</CompanyName>
                        <BillAddress>
                            <Addr1>' . $address1 . '</Addr1>
                        </BillAddress>
                        <ShipAddress>
                        <Addr1>' . $address2 . '</Addr1>
                        </ShipAddress>
                        <Phone>' . $phone . '</Phone>
                        <Email>' . $email . '</Email>
                        <Contact>' . $contact . '</Contact>
                    </CustomerAdd>
                </CustomerAddRq>
            </QBXMLMsgsRq>
        </QBXML>';

    return $qbxml;


}
function _quickbooks_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. 

    $myHost = "localhost"; // use your real host name
$myUserName = "water_ways_user";   // use your real login user name
$myPassword = "zAEGQKI74YHyz6Do";   // use your real login password
$myDataBaseName = "water_ways"; // use your real database name

$con = mysqli_connect( "$myHost", "$myUserName", "$myPassword", "$myDataBaseName" );

if( !$con ) // == null if creation of connection object failed
{ 
    // report the error to the user, then exit program
    die("connection object not created: ".mysqli_error($con));
}

if( mysqli_connect_errno() )  // returns false if no error occurred
{ 
    // report the error to the user, then exit program
    die("Connect failed: ".mysqli_connect_errno()." : ". mysqli_connect_error());
}

    mysqli_query($con,"UPDATE customer_info SET quickbooks_listid = '" . mysqli_escape_string($con,$idents['ListID']) . "',edit_sequence = '" . mysqli_escape_string($con,$idents['EditSequence']) . "'  WHERE customer_info_id = " . (int) $ID);

}

this is my .qwc file which is on my local machine.

<?xml version="1.0"?>
<QBWCXML>
    <AppName>Water Ways</AppName>
    <AppID></AppID>
    <AppURL>https://pcits.co.in/water_ways/quickbooks-php-master/docs/web_connector/web_connector.php</AppURL>
    <AppDescription></AppDescription>
    <AppSupport>https://pcits.co.in/water_ways/</AppSupport>
    <CertURL>https://pcits.co.in/water_ways</CertURL>
    <UserName>quickbooks</UserName>
    <OwnerID>{90A44FB7-33D9-4815-AC85-AC86A7E7D1EB}</OwnerID>
    <FileID>{57F3B9B6-86F1-4fcc-B1FF-967DE1813D20}</FileID>
    <QBType>QBFS</QBType>
    <Scheduler>
        <RunEveryNMinutes>5</RunEveryNMinutes>
    </Scheduler>
    <IsReadOnly>false</IsReadOnly>
</QBWCXML>

and i am getting error as "QuickBooks Web Connector could not verify the web application server certificate."


Solution

  • This error message:

    QuickBooks Web Connector could not verify the web application server certificate.

    Means that your domain name (e.g. the domain shown in the AppURL):

    Does not have a valid SSL/TLS certificate.

    Talk to your website hosting company/administrator, and ask them to issue/install/configure a secure SSL certificate.