-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rahul
committed
Jun 11, 2018
0 parents
commit 153f1dd
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Intuit Quickbooks Webhooks - PHP - Oauth2.0 | ||
Intuit Developer's sample application for using [Webhooks](https://developer.intuit.com/docs/00_quickbooks_online/2_build/30_webhooks) with the QuickBooks Online APIs and PHP. | ||
|
||
Webhooks are notifications about QuickBooks entities that are sent to developer-created applications. If you want to be get notified when a Intuit user change information like Account, Bill, Payment, Employee, TimeActivity, Invoice etc. on their Intuit account, you can use Webhook feature. | ||
|
||
## Configure your Webhook | ||
1. Login into your Intuit Develper account and click on the app you wish to enable Webhook. | ||
2. Click Webhooks. | ||
3. Enter your endpoint URL in the field provided. This URL must be exposed over the internet and be secured via HTTPS. | ||
4. Select desired events for receive webhooks data. | ||
5. Click Save. It may take up to five minutes for your endpoint to receive its first notification. | ||
|
||
After you are done, click the 'Show Token' button and copy that token, you'll need it on endpoint implementation. | ||
|
||
Connect your app to account to receive webhook using [Oauth2](https://github.com/IntuitDeveloper/OAuth2_PHP) | ||
|
||
If it doesn't work for you, feel free to contact me at rahuldadhich87@gmail.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/** | ||
* Intuit Quickbooks Webhooks - Oauth2.0 | ||
* | ||
* @RAHUL DADHICH - 06-11-2018 | ||
*/ | ||
|
||
// Step - 1 | ||
// Log into your Intuit Developer account and navigate into the application you are developing. Click on settings and scroll down to Webhooks. | ||
// Paste your endpoint URL. This URL must be exposed over the internet and be secured via HTTPS. | ||
// Check the events desired (or Select All to enable all of them). | ||
// Click Save. | ||
// After you are done, click the 'Show Token' button and copy that token and paste here($webhook_token). | ||
$webhook_token = "xxx-xxx-xxxx-xxxx-xxxxxxxx"; | ||
$is_verified = false; | ||
|
||
if (isset($_SERVER['HTTP_INTUIT_SIGNATURE']) && !empty($_SERVER['HTTP_INTUIT_SIGNATURE'])) { | ||
$payLoad = file_get_contents("php://input"); | ||
if ($this->isValidJSON($payLoad)) { | ||
$payloadHash = hash_hmac('sha256', $payLoad, $webhook_token); | ||
$singatureHash = bin2hex(base64_decode($_SERVER['HTTP_INTUIT_SIGNATURE'])); | ||
if($payloadHash == $singatureHash) { | ||
// verified....OK | ||
$is_verified = true; | ||
$payLoad_data = json_decode($payLoad, true); | ||
|
||
foreach ($payLoad_data['eventNotifications'] as $event_noti) { | ||
$realmId = $event_noti['realmId']; // this is your company-ID from Intuit | ||
// now do whatever you want to do with data received from Intuit... | ||
foreach($event_noti['dataChangeEvent']['entities'] as $entries) { | ||
// ... | ||
} | ||
} | ||
} else { | ||
// not verified | ||
} | ||
} | ||
} | ||
|
||
|
||
// check JSON | ||
function isValidJSON($string) { | ||
if (!isset($string) || trim($string) === '') { | ||
return false; | ||
} | ||
|
||
@json_decode($string); | ||
if (json_last_error() != JSON_ERROR_NONE) { | ||
return false; | ||
} | ||
return true; | ||
} |