# Using UltraHook to receive webhooks at development

_Alternative to ngrok.com_

Author: Georg Ledermann  
Published: 2019-03-17  
Tags: Ruby on Rails, Stripe, UltraHook  
Canonical: https://ledermann.dev/blog/2019/03/17/using-ultrahook-to-receive-webhooks-at-development/

Testing webhooks locally is tricky: the sender cannot reach your laptop behind a firewall. UltraHook provides a free tunnel for incoming POST requests, so you can debug them on your own machine.

---

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](https://www.stripe.com/). Stripe sends out webhooks during certain events, so I need a way to test them on my local computer. With [UltraHook](https://www.ultrahook.com/) they can be received simply from behind a firewall. It is like ngrok.com, but for POST requests only. In contrast to [ngrok.com](https://ngrok.com/), the service is completely free and offers static endpoint URLs.

In my Rails application I'm using [foreman](https://github.com/ddollar/foreman), [dotenv](https://github.com/bkeepers/dotenv) and [puma-dev](https://github.com/puma/puma-dev). It is simple to add UltraHook to this setup:

**Step 1:** We need to register at [ultrahook.com](https://www.ultrahook.com/register) 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:

```bash
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`:

```bash
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:

```bash
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.

```bash
foreman start
```

That's it. Just fire and forget.
