Problem
After much struggling, my local index.php has finally achieved an access token from the Intuit server (I don’t even know what to call all these small OAuth2 transactions).
Solution
Here is the solution to that:
This file:
E:\wamp\www\qbo\vendor\quickbooks\v3-php-sdk\src\Core\HttpClients\CurlHttpClient.php
One person on the internet* said to comment the line out that looks for an SSL certificate where it will not find one. I found that changing a value from true to false accomplishes the same thing.
/**
* Set the SSL certifcate path and corresponding varaibles for cURL
*/
private function setSSL(&$curl_opt, $verifySSL) {
$curl_opt[CURLOPT_SSL_VERIFYPEER] = false;
if($verifySSL){
$curl_opt[CURLOPT_SSL_VERIFYHOST] = 2;
//based on spec, if TLS 1.2 is supported, it will use the TLS 1.2 or latest version by default
//$curl_opt[CURLOPT_SSLVERSION] = 6;
$curl_opt[CURLOPT_CAINFO] = CoreConstants::getCertPath(); //Pem certification Key Path
} else {
$curl_opt[CURLOPT_SSL_VERIFYHOST] = 0;
}
}
*https://github.com/intuit/QuickBooks-V3-PHP-SDK/issues/55
This information was from 2017 so not current, but still led me to try my solution. The answer was from joemancuso.
Background
In attempting to access the Quickbooks API / SDK, I have created a sandbox company and acquired the Client ID and Client secret, etc. Using Composer I installed the sample code from Github on my local WAMP web server.
composer require quickbooks/v3-php-sdk
I think I tried all the PHP samples but this one is the only one that seems to be sort of up-to-date: https://github.com/intuit/QuickBooks-V3-PHP-SDK.
I’m not great with PHP but it’s the language I’m most familiar with that works with the Quickbooks SDK. I also started working with ngrok again. I tried it once a long time ago but I wasn’t getting it, apparently. Turns out it’s a super cool utility that creates a secure tunnel for the outside world to securely (https!) allow access to your local web server. This is how the Quickbooks authorization scheme finds you to do the OAuth2 handshake thing that provides access to the API.
So, mind you, I haven’t even begun to actually build my app. I fear it’s a loooonng way off. but I think using the API Explorer on the Intuit development website will make what I need doable.
The app design
Here’s what I’m trying to accomplish:
I hope to create an app that we can use at my job to notify customers when their orders are ready for pickup. By entering the invoice number of the order, the screen will populate showing the customer name and contact information (just to verify that we’ve arrived at the correct customer). Then it will generate a text message and/or an email to notify them. There will also be a choice of a standard boilerplate message, or a custom message field. A button will initiate the message to be sent.
I want a small interface, large enough to accommodate the following fields:
- a field to enter the invoice number
- a small area to show the customer information (name, phone, email) based on the invoice entered
- two radio buttons to choose “text message” and / or “email”
- a dropdown list defaulting to a boilerplate message (“Your order ” . $invoicenum . “is ready at Chrome”, etc.), but allowing a custom message if requested.
- a textarea box if a “custom” text or email message is chosen
- a button to send
That’s it. Doesn’t seem too pie-in-the-sky but neither did some of the other projects that nearly did me in.
I believe I’ll be able to use Twilio or something similar to send sms and email messages, but that will need further investigation.