QuickBooks Online Webhooks using PHP
Webhooks allow you to subscribe to certain events that happen in QuickBooks Online. We've included scripts to work with the following QuickBooks Online event triggers:
- Customers: create and update
- Invoices: create and update
- Payments: create and update
When one of these events are triggered QuickBooks will send a JSON payload to the webhook’s configured URL. You can easily add support for additional event triggers by following the pattern we have used in our FileMaker scripts.
You will need to create your own QuickBooks Online app to work with Webhooks in the Developer/Sandbox and Production environments. You can get more information about creating a QuickBooks Online app and the changes you need to make to your copy of the fmAccounting Link (QuickBooks Online Edition) file so it connects to your QuickBooks Online app here.
You can use the supplied PHP file to setup webhooks for the FileMaker Data API and have changes to Customers, Invoices and Payments automatically pushed to the fmAccounting Link (QuickBooks Online Edition) Multi Companies file (or your custom integration).
You'll find a folder called PHP Webhooks in your fmAccounting Link (QuickBooks Online Edition) downloaded that contains the php file for use with FileMaker Server's Data API. To use webhooks with fmAccounting Link (QuickBooks Online Edition) your deployment will need to meet the following requirements:
- your copy of fmAccounting Link must be hosted by FileMaker Server v17 or later
- you will need to enable the Data API and host the fmAccountingLinkWebhook.php PHP file (either on your FileMaker Server or elsewhere, for example Amazon Lightsail or your own web server running PHP)
- the URL to the php file needs to begin with HTTPS: QuickBooks Online only support HTTPS Webhook URLs
- you need to install the supplied fmAccountingLinkWebhook.php file on your Web Server and determine the URL to this page from the outside. For example if your web server has a domain name of www.myserver.com and you create a folder called QuickBooksWebhooks and place the fmAccountingLinkWebhook.php file inside the QuickBooksWebhooks folder the URL will be: https://www.myserver.com/QuickBooksWebhooks/fmAccountingLinkWebhook.php
If you’re not sure about what the external URL to the fmAccountingLinkWebhook.php file is talk to your IT person – they may need to setup port forwarding on your Internet router in some cases.
In January 2021 Claris announced that Custom Web Publishing with PHP is being deprecated and they are making changes to how PHP is bundled with FileMaker Server. Please see this support article for further details.
If you are hosting the fmAccountingLinkWebhook.php file on your FileMaker Server the web server “root” folders for FileMaker Server v17 and later are:
Windows:
[ drive]:\Program Files\FileMaker\FileMaker Server\HTTPServer\Conf
where [drive] is the drive on which the Web Publishing Engine component of your FileMaker server deployment resides.
Mac OS X (HTTPS):
/ Library/FileMaker Server/HTTPServer/htdocs/httpsRoot
N.B. the HTTPS options require a valid SSL certificate to be installed.
Once you have determined the URL to the fmAccountingLinkWebhook.php file you need to enter the Webhook URL into the Endpoint URL field for your Sandbox or Production app:
You'll also need to enable the following Event triggers which are supported by the fmAccounting Link file (you can extend our scripts to support additional Event triggers if required):
Make a note of the Verifier Token value as you will need to enter this into the fmAccountingLinkWebhook.php file.
You will need to copy/paste the Verifier Token into the fmAccountingLinkWebhook.php file where we set the $myWebhookVerifierToken
variable here:
Make sure you also update the $hostname
and $database
variables with the appropriate values for your server/deployment. You can then upload the fmAccountingLinkWebhook.php to your web server. You are now ready to start receiving webhook notifications from QuickBooks Online.
When the QuickBooks Online Webhook makes a successful request it performs the following actions:
- it creates a new record in the Webhooks table and populates the Payload field with the JSON webhook payload data
- it then performs the processQuickBooksOnlineWebHook script which loops through any webhook events in the payload and performs the appropriate actions
- for Create events it will create a new Customer, Invoice or Payment record and then call a subscript to update the Customer, Invoice or Payment record from QuickBooks Online
- for Update events it will attempt to find the matching Contact or Invoice record using the QuickBooks Online ID and if a match is found it will then call a subscript to update the Customer, Invoice or Payment record from QuickBooks Online
We have a video demonstrating QuickBooks Webhooks in action on the fmAccounting Link (QuickBooks Online Edition) videos page (or watch on YouTube here). You can get more information about QuickBooks Webhooks on the QuickBooks Developer site here:
https://developer.intuit.com/app/developer/qbo/docs/develop/webhooks
Intuit also have a Best practices for using webhooks with QuickBooks Online guide.