Logo

dev-resources.site

for different kinds of informations.

Recreate shopify webhooks

Published at
9/10/2024
Categories
ruby
rails
shopify
webhook
Author
ugifractal
Categories
4 categories in total
ruby
open
rails
open
shopify
open
webhook
open
Author
10 person written this
ugifractal
open
Recreate shopify webhooks

When developing custom Shopify apps, I usually use ngrok as a reverse proxy for webhooks integration. Since I always use a free service plan from Ngrok, then the URL address always changes. Here is the sample generated Ngrok URL when running

ngrok http 3000
Enter fullscreen mode Exit fullscreen mode

Generated endpoint
https://73d3-2001-448a-3032-c93e-bc56-f800-e58d-8a98.ngrok-free.app

When we hit ctrl+c and rerun the command, we will get a different new URL.

So what I did was just change the .env file of my Rails project, go to console, and recreate Shopify webhooks.

bundle exec rails c
Enter fullscreen mode Exit fullscreen mode
Shop.first.recreate_webhooks!
Enter fullscreen mode Exit fullscreen mode

And here is the code for recreate_webhooks!

# app/models/shop.rb

Ā  def recreate_webhooks!
Ā  Ā  ShopifyAPI::Webhook.all.each do |webhook|
Ā  Ā  Ā  webhook.destroy
Ā  Ā  end

Ā  Ā  ShopifyApp.configuration.webhooks.each do |item|
Ā  Ā  Ā  webhook = ShopifyAPI::Webhook.new(item)
Ā  Ā  Ā  if webhook.save
Ā  Ā  Ā  Ā  puts "webhook #{item} created."
Ā  Ā  Ā  else
Ā  Ā  Ā  Ā  puts "webhook #{item} failed."
Ā  Ā  Ā  end
Ā  Ā  end
Ā  end
Enter fullscreen mode Exit fullscreen mode

So every time you need to regenerate webhooks, you can just run this method from rails console.

webhook Article's
30 articles in total
Favicon
Integrating MongoDB Atlas Alerts with Lark Custom Bot via AWS Lambda
Favicon
Replay failed stripe events via webhook
Favicon
Integrating Stripe Payment Intent in NestJS with Webhook Handling
Favicon
Designing a webhook service: A practical guide to event-driven architecture.
Favicon
Creating a user interface for the Webhook module using Angular
Favicon
Recreate shopify webhooks
Favicon
Creating a configurable Webhook module for a NestJS application
Favicon
Forward SMS to Webhook with iPhone Shortcut Automations
Favicon
Understanding Webhooks: How to Handle Them in Your Application
Favicon
Building a community database with GitHub : A guide to Webhook and API integration with hono.js
Favicon
O Que SĆ£o Webhooks e Como UtilizĆ”-los Eficientemente
Favicon
Simplifying Webhook Handling with Vector.dev: A Modern Solution for Serverless Apps
Favicon
Creating a Websocket server in Hono with Durable Objects
Favicon
Efficient Webhook Handling in Laravel Using Unique Jobs
Favicon
WhatsApp webhook API types
Favicon
Post Reddit posts on Instagram with a simple like on Discord. You will love Webhooks! šŸŖ
Favicon
Manage Telegram Webhooks Using curl
Favicon
Bootstrapping Cloudflare Workers app with oak framework & routing controller
Favicon
Webhook Security Approaches
Favicon
Handling Eventual Consistency in Webhook
Favicon
Sending GitHub Secrets to Docker Apps on VMs Using adnanh/webhooks
Favicon
Troubleshooting 5xx errors with your Stripe Webhook
Favicon
LemonSqueezy Webhooks for Non-Auth Users in Laravel
Favicon
How to use the new Symfony Maker command to work with GitHub Webhooks
Favicon
Webhooks: A Mindset Change for Batch Jobs
Favicon
Trigger Jenkins builds with Github Webhook Using Smee Client
Favicon
How to Setup Webhook in Google Form?
Favicon
Ngrok: Exposing local server on the internet
Favicon
Custom Header in Stripe Webhook Payload
Favicon
Mengenal Webhook, API Tanpa Polling

Featured ones: