d
Topic
Posts:
2
5 months ago

Webhooks - Not Working This post is outdated

Below is the code im using to create a webhook

#Webhook creation in shopify_app.rb file:
    config.webhooks = [  {   topic: 'carts/update',      address: '********************************'  , type: 'json'
   } ]

#Job for the webhook

class CartsUpdateJob < ActiveJob::Base
     def perform (shop_domain: , webhook:)
         shop = Shop.find_by(shopify_domain: shopify_domain)
         shop.with_shopify_session do 

             line_items = webhook[:line_items]
             line_items.each do |item|
                 variant_id = item[:variant_id]
                 price = item[:price].to_f

                 ShopifyAPI::Variant.new({

                     id: variant_id,
                     price: price + 1
                     }).save
             end
         end
     end  
end

I'm using a heroku to deploy our app. So what address do i need to fill in the webhook creation ?? 

Is is  'https://****heroku.com/webhooks' ?? if i use my heroku URL following is the error been displayed in my logs.. 

ActionController::RoutingError (No route matches [POST] "/webhooks") . although i have the route mentioned as  root :to => 'home#webhooks' in my routes.rb

Please help me to solve this.

 

Log in or sign up for an account to reply.

f
Your Reply