by Georg Ledermann

Using UltraHook to receive webhooks at development

Alternative to ngrok.com

Photo by Alex Ronsdorf on Unsplash

Photo by Alex Ronsdorf on Unsplash

When building web applications, it may be necessary to process incoming webhooks. With UltraHook these requests can also be received during development on the local computer.

I’m currently working on a shop-like web application using Ruby on Rails that can process credit card payments with Stripe. Stripe sends out webhooks during certain events, so I need a way to test them on my local computer. With UltraHook they can be received simply from behind a firewall. It is like ngrok.com, but for POST requests only. In contrast to ngrok.com, the service is completely free and offers static endpoint URLs.

In my Rails application I’m using foreman, dotenv and puma-dev. It is simple to add UltraHook to this setup:

Step 1: We need to register at ultrahook.com to get a personal API key and a namespace. Also, a small Ruby gem needs to be installed.

Step 2: The API key needs to be added to the local .env file:

1
2
3
4
STRIPE_PUBLIC_KEY=pk_test_12345678
STRIPE_PRIVATE_KEY=sk_test_12345678
STRIPE_WEBHOOK_SECRET=whsec_12345678
ULTRAHOOK_API_KEY=my-ultrahook-api-key # <= This is the added line

Step 3: Assuming the local URL (served by puma-dev) is http://my-shop.test, we need to add this line to the Procfile:

1
2
3
backend: bin/rails s -p 3000
frontend: bin/webpack-dev-server
ultrahook: ultrahook my-shop http://my-shop.test # <= This is the added line

Step 4: At the external service (e.g. Stripe), we add this endpoint URL to send webhooks to:

http://my-shop.my-namespace.ultrahook.com

Finally, the application will be started as usual in the development environment. Now it handles incoming webhooks, too.

foreman start

That’s it. Just fire and forget.