How to test Square webhooks locally

Documentation for the Square Checkout payment provider for Vendr, the eCommerce solution for Umbraco v8+

Because the Square payment provider uses webhooks to finalize payments, it can make it tricky to be able to test payments locally as for Square to be able to notify you, the site must have a public facing URL.

You could expose your website through your networks firewall, however there is a simpler way by using tools that can create temporary tunnels through your network such as ngrok.

Step 1 - Install ngrok

The first thing you'll want to do is install ngrok itself. Before you continue, be sure to head on over to ngrok.com and download an install the tool on your system.

Step 2 - Launch ngrok

With ngrok installed, we can launch it from the command line, but we find the easiest way is to create a batch file we can run at any time.

To create the batch file, open notepad and enter the following:

C:\PROGRA~1\ngrok\ngrok.exe http -host-header=rewrite localhost:61191

You'll want to swap the local domain / port number at the end according to your sites configuration, but with the contents above, save the file as ngrok.bat in the root of your web project. Now, you can run the batch file at any time to launch ngrok and create a publicly accessible tunnel to your website.

ngrok

When you launch ngrok for the first time, it will ask you to sign in. Enter the credentials you used to sign up with. It will remember them from now on.

Step 3 - Test the site

With ngrok running you can now test the site using the URLs displayed in the console window. Use these URLs (preferably the secure https one) for your Square webhook configuration and you should now be able to test your Square webhooks locally.

You should see webhook requests displayed in the console window, and you can even debug into them in Visual Studio.

Edit this page on GitHub

Site + logo design © 2021 Outfield Digital Ltd. Content contributions licensed under MIT.
Vendr® is a Registered Trademark of Outfield Digital Ltd.