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 in a simple way from behind a firewall. It’s like ngrok.com, but for POST requests only. In contrast to ngrok.com, the service is completely free and offers static endpoint URLs.
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
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
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:
Finally, the application will be started as usual in development environment. Now it handles incoming webhooks, too.
That’s it. Just fire and forget.